Sep 15, 2005

Problem of Arabic Music: Take 2

I have started discussing the problem of Arabic Music in a previous post. Roba has helped with a nice comment, that I would like to use in continueing the discussion.

The question: why are there many bad Arabic songs today?

Roba had 3 main points:
1- Some modern songs are better (e.g. Nanci) than others (e.g. Maria).
2- The younger generation (kids, as Roba called them) actually think that Maria is good.
3- Music is not just good or bad - it depends on the occasion (e.g. wedding vs every day)

Before we delve into the discussion, let me re-cast the question. Of course, music is one of those "taste" issues that people cannot just agree upon. Furthermore, people tend to like their own music and hate that of younger generations. The question I'm posing is beyond all these variations. If you take all these measures in account, you will still find that the modern Arabic pop songs are not just different; they are actually bad relative to older ones.

In the first post, I stated that since music is taste-based, then "good/bad" criteria must be defined by the collective opinion of people, thus: popularity. And that created a dilemma: how come many people say that modern songs are bad but still they listen to them?


The solution is simple: popular does not necessarily mean good. As Roba has said, she might not mind dancing to a Maria song at a wedding, but that does not mean that the song is actually “good music”. So, people might like bad songs, but they appreciate good ones.


I think this is true in all ages. The Viennese audience was amazed by Beethoven’s 9th symphony, but, they were not dancing to it at their festivals or little parties. There must have been some form of light folkloric “dummy” compositions that were played at homes.


So now the question we have is: Why is some music popular but not good?


And that, I will inshallah try to think more about for my next blog...

Sep 13, 2005

islamic computer virus! funny

http://www.sophos.com/virusinfo/analyses/trojyusufalia.html
This virus will detect if you're watching a porn website. If so, it'll minimize the porn window and show a verse from Quran instead!

From the website's description of the virus:


Troj/Yusufali-A is a Trojan for the Windows platform.

Troj/Yusufali-A analyzes the title of the window in focus looking for various words. Some of the words Troj/Yusufali-A searches for are:

sex
teen
xx
Phallus
jegger
Priapus
Phallic
Penis
Exhibitionism

If Troj/Yusufali-A finds one of these words in the title bar it will minimise the current window and display the following message in English along with other messages in other languages:

YUSUFALI: Know, therefore, that there is no god but Allah, and ask forgiveness for thy fault, and for the men and women who believe: for Allah knows how ye move about and how ye dwell in your homes.

The message displayed by the Trojan horse

The message displayed by the Trojan horse.

Troj/Yusufali-A will continue to display messages if the offending window is left open, and after a while it displays a box in the middle of the screen containing the current time and a button 'For Exit Click Here'. As soon as the mouse is moved the box changes to have vertical bars and the text 'OH! NO i'm in the Cage'. The box contains LogOff, ShutDown and Restart buttons and the mouse pointer is locked within the confines of the box. All the buttons actually cause a logout. The keyboard is still useable.

Another message displayed by the Trojan horse

Another message displayed by the Trojan horse.

Sep 6, 2005

Ibn Battuta - funny!

(sorry I'm mixing Arabic & English here - but I can't figure out how to write Arabic on my Linux machine - Gnome-Fedora 4, for those who can help..)

As I couldn't sleep well yesterday, I started reading Ibn Battuta (thanks to alwaraq.com), and what an interesting read it was. Few interesting quotes from the book:

1- Ibn Battuta & the Eskimos!! (Ard Al-Thulma)
وكنت سمعت بمدينة بلغار فأردت التوجه إليها لأرى ما ذكر عنها من انتهاء قصر الليل بها وقصر النهار أيضاً في عكس ذلك الفصل. وكان بينها وبين محلة السلطان مسيرة عشر. فطلبت منه من يوصلني إليها فبعث معي من أوصلني اليها وردني إليه. ووصلتها في رمضان فلما صلينا المغرب أفطرنا. وأذن بالعشاء في أثناء إفطارنا فصليناها وصلينا التراويح والشفع والوتر. وطلع الفجر إثر ذلك. وكذلك يقصر النهار بها في فصل قصره أيضاً. وأقمت بها ثلاثاً.
وكنت أردت الدخول إلى أرض الظلمة والدخول إليها من بلغار وبينهما أربعون يوماً. ثم أضربت عن ذلك لعظم المؤونة فيه وقلة الجدوى. والسفر إليها لا يكون إلا في عجلات صغار تجرها كلاب كبار. فإن تلك المفازة فيها الجليد فلا يثبت قدم الآدمي ولا حافر الدابة فيها.
والكلاب لها الأظفار فتثبت أقدامها في الجليد. ولا يدخلها إلا الأقوياء من التجار الذين يكون لأحدهم مائة عجلة أو نحوها موقرة بطعامه وشرابه وحطبه. فإنها لا شجر فيها ولا حجر ولا مدر. والدليل بتلك الأرض هو الكلب الذي قد سار فيها مراراً كثيرة وتنتهي قيمته إلى ألف دينار ونحوها وتربط العربة إلى عنقه ويقرن معه ثلاثة من الكلاب. ويكون هو المقدم تتبعه سائر الكلاب بالعربات. فإذا وقف وقفت. وهذا الكلب لا يضربه صاحبه ولا ينهره وإذا حضر الطعام أطعم الكلاب أولاً قبل بني آدم وإلا غضب الكلب وفر وترك صاحبه للتلف.

2- Ibn Battuta speaking Indian:
وقالت لهم: مارا ميترساني ازاطش " آنش " من ميدانم أواطاش است رهكاني مارا وهي تضحك ومعنى هذا الكلام أبالنار تخوفونني أنا أعلم أنها نار محرقة

3- Ibn Battuta & Women: Quiz: In what country do you think this has happened?
a- Andalus, b- Sudan, c- Turkey, d- China

ذكر مسوفة الساكنين

...
وأما هؤلاء فهم مسلمون محافظون على الصلوات وتعلم الفقه وحفظ القرآن. وأما نساؤهم فلا يحتشمن من الرجال ولا يحتجبن مع مواظبتهن على الصلوات. والنساء هنالك يكون لهن الأصدقاء والأصحاب من الرجال الأجانب وكذلك للرجال صواحب من النساء الأجنبيات. ويدخل أحدهم داره فيجد امرأته ومعها صاحبها فلا ينكر ذلك...
ولنسائها الجمال الفائق وهن أعظم شأناً

حكاية
دخلت يوماً على القاضي بعد إذنه في الدخول فوجدت عنده امرأة صغيرة السن بديعة الحسن فلما رأيتها ارتبت وأردت الرجوع فضحكت مني ولم يدركها خجل. وقال لي القاضي: لم ترجع إنها صاحبتي. فعجبت من شأنهما فإنه من الفقهاء الحجاج واخبرت أنه استأذن السلطان في الحج في ذلك العام مع صاحبته لا أدري أهي هذه أم لا فلم يأذن له.
حكاية نحوها دخلت يوماً على أبي محمد يندكان المسوفي الذي قدمنا في صحبته فوجدته قاعداً على بساط وفي وسط داره سرير مظلل عليه امرأة معها رجل قاعد وهما يتحدثان. فقلت له: من هذه المرأة فقال: هي زوجتي. فقلت: ومن الرجل الذي معها فقال: هو صاحبها.
فقلت له: أترضى بهذا وأنت قد سكنت بلادنا وعرفت أمور الشرع. فقال لي: مصاحبة النساء للرجال عندنا على خير وأحسن طريقة لا تهمة فيها ولسن كنساء بلادكم. فعجبت من رعونته وانصرفت عنه فلم أعد إليه بعدها. واستدعاني في مرات فلم أجبه

Ibn Battuta visits Baghdad after it has been destroyed by the Mongols. His account of that city, a broken city but yet great, is very sad - especially given the situation today in Iraq.

For those who want to read it, his adventures in the south pacific islands are the most amusing. The book is available on Alwaraq.com

Sep 3, 2005

C++ programming style question

Salam All,
This is a c++ programming post/question. So, if you're not a programming geek, please ignore gracefully :-)

I'm looking for advice on choosing a simple & elegant programming style for a certain type of functions. I will first explain the function, and then list several solutions I've seen (and don't totally like so far), and then I'll keep it open for people to post back their suggested answers.

The Function (i want to write)
The function simply has several statements to execute in order. Each statement may return an error code. The statements must be called in order, and if any fails, none of the rest must execute. The function also has initialization & clean up code that must run (whether the statements fail or not).

How to write this function in an elegant readable style that would allow future additions & modifications easily?

Following are several solutions I've seen. However, there's something I do not like about each. My question is... do you know of different method that would avoid any of my dislikings?

Style #1, if-else-if, example
int TheElegantFunction () {
/*** init-code ***/
int rc = 0; //return value. 0 means no error
mutex.get();

/*** the statements s1, s2, & s3 ***/
if (0 != (rc == s1())) {
} else if (0 != (rc == s2())) {
} else if (0 != (rc == s3())) {
} else {
//we were successful
}

/*** clean up ***/
mutex.release();
return rc;
}

advantages:
1- no code repetition
2- one-exit-point for the function
3- compact code (each statement takes 1 line)
disadvantages:
1- not very readable (sequential code does not belong to the if-conditional-expression)
2- what to do with non-error-returning statements, or addign-statements
3- placing those statements in else {} will force creating several levels of nested else { if... }


Style #2, if-error, example
int TheElegantFunction () {
/*** init-code ***/
int rc = 0; //return value. 0 means no error
mutex.get();

/*** the statements s1, s2, & s3 ***/
rc = s1();
if (rc != 0) {
/*** clean up ***/
mutex.release()
return rc;
}
rc = s2();
if (rc != 0) {
/*** clean up ***/
mutex.release()
return rc;
}
rc = s3();
if (rc != 0) {
/*** clean up ***/
mutex.release()
return rc;
}

/*** clean up ***/
mutex.release();
return rc;
}

advantages:
1- readable
2- easy
disadvantages:
1- you have to repeat the clean up code for every single statement
2- multiple exit points for the function - can be confusing to follow the logic

Style #3, goto-solution, example
int TheElegantFunction () {
/*** init-code ***/
int rc = 0; //return value. 0 means no error
mutex.get();

/*** the statements s1, s2, & s3 ***/
rc = s1();
if (rc != 0) goto end;
rc = s2();
if (rc != 0) goto end;
rc = s3();
if (rc != 0) goto end;

end:
/*** clean up ***/
mutex.release();
return rc;
}

advantages:
1- readable
2- one function exit point
3- compact
4- no repetition
disadvantages:
1- the frowned-upoen, spagetti-programming, goto statement!
2- the goto can mask the logic and make the function not very readable - especially if there are loops


Style #4, my-dream-language, example
int TheElegantFunction () {
/*** init-code ***/
int rc = 0; //return value. 0 means no error
mutex.get();

conditional_block (rc == 0 /* exit block when expression doesn't hold */) {
/*** the statements s1, s2, & s3 ***/
rc = s1();
rc = s2();
rc = s3();
}

/*** clean up ***/
mutex.release();
return rc;
}

advantages:
1- (I think) readable & elegant & clear logic-flow
2- no code-repetition
3- one entrance, one exit for the function
disadvantages:
1- imaginary (maybe a nice C# v3.0 feature? hint hint ;-))

so what do you guys think? do you know of a nice style of write such common-functions?