Saturday, 13 March 2010

A Comparison of Qt and Java for Large-Scale, Industrial-Strength GUI Development


Here is an interesting paper for you to read: http://turing.iimas.unam.mx/~elena/PDI-Lic/qt-vs-java-whitepaper.pdf.
Just skimmed through it. The good thing is that it is based on research (numbers do not lie ;) ) and not just some anecdotal "evidence". My thoughts? If you are a computer scientist who really knows their stuff and can choose between C++ and Java for your next project - choose C++. If you are an entrepreneur or a manager - hire the best programmers and choose C++... or Python... or Python & C++... and Qt ;)... or use OpenLaszlo... or ZK... or whatever ;)...
BTW, if you are a Java (or C#) programmer interested in mastering C++ & Qt then here is a nice book for you, which, apart from introducing Qt, contains a chapter (well, an appendix really) entitled "Introduction to C++ for Java and C# Programmers":

C++ GUI Programming with Qt 4 (2nd Edition)

The best thing is that the book has been published under the Open Publication License so it can be also legally downloaded from the Internet.

But returning to the paper... if you don't feel like reading the whole then here are some interesting excerpts:

--
In conclusion: both research and practice contradict the claim that Java programmers achieve a higher programmer-efficiency than C++ programmers.


Both independent academic research and industrial experience demonstrate that the hype favouring Java is mostly unjustified, and that the C++/Qt combination is superior.


Research shows that in practice, garbage collection and other Java features, do not have a major influence on the programmer-efficiency. One of the classic software estimation models, Barry Boehm’s CoCoMo1 predicts the cost and schedule of a software project using cost drivers which take into account variables like the general experience of a programmers, the experience with the programming language in question, the targeted reliability of the program, etc. Boehm writes that the amount of effort per source statement was highly independent of the language level. Other research, for example, A method of programming measurement and estimation by C.E. Walston and C.P. Felix of IBM, points in the same direction.


This is also backed up by our own experience: if programmers can choose their favorite programming language (which is usually the one they have most experience of), programmers with the same level of experience (measured for example, in years of programming experience in general) achieve about the same programmer-efficiency.


Another interesting aspect that we noted (but which is not yet supported by any formal research) is that less experienced developers seem to achieve somewhat better results with Java, medium-experienced developers achieve about the same results with both programming languages, and experienced developers achieve better results with C++.


Again, Prechelt provides useful data. The amount of data he provides is huge, but he arrives at the conclusion that "a Java program must be expected to run at least 1.22 times as long as a C/C++ program". Note that he says at least; the average runtime of Java programs is even longer. Our own experience shows that Java programs tend to run about 2-3 times as long than their equivalent C/C++ programs for the same task. Not surprisingly, Java loses even more ground when the tasks are CPU-bound.

When it comes to programs with a graphical user interface, the increased latency of Java programs is worse than the runtime performance hit. Usability studies show that users do not care about whether a long running task takes, say, two or three minutes, but they do care when a program does not show an immediate reaction to their interaction, for example when they press a button. These studies show that the limit of what a user accepts before they consider a program to be "unresponsive" can be as little as 0.7 seconds.


Prechtelt provides figures which state that on average (...) and with a confidence of 80%, the Java programs consume at least 32 MB (or 297%) more memory than the C/C++ programs (...). In addition to the higher memory requirements, the garbage collection process itself requires processing power which is consequently not available to the actual application functionality, leading to slower overall runtimes.


When dealing with external programs and devices, for example, during I/O or when interacting with a database, it is usually desirable to close the file or database connection as soon as it is no longer required. Using C++’s destructors, this happens as soon as the programmer calls delete. In Java, closing may not occur until the next garbage collecting sweep, which at best may tie up resources unnecessarily, and at worst risks the open resources ending up in an inconsistent state.


The fact that Java programs keep memory blocks around longer than is strictly necessary is especially problematic for embedded devices where memory is often at a premium.


To sum up this discussion, we have found C++ to provide much better runtime- and memory-efficiency than Java, while having comparable programmer-efficiency.

Wednesday, 10 March 2010

VirtualBox - hibernation of a host system may cause problems

Your virtual machines may not resume properly after thawing (i.e. starting the system after hibernation) - problems with vboxdrv kernel module. Here is my script which solves this issue (most of you can just put it in /etc/pm/sleep.d/action_virtualbox). I use Debian GNU/Linux but the script should work perfectly with other distros as well (e.g. Ubuntu, Fedora or Suse). The script puts all VMs to sleep (saves their state) and stores information about the associated processes (X Window display, real uid) in a file and tries to resume all VMs upon thawing, running them with correct user/display combination.

Do not worry if you cannot see the whole script (i.e. it appears to be clipped) just select and copy it with your mouse (or make your browser window wider).

#!/bin/sh
# suspend virtual machines on hibernate and resume them on thaw

# a file for storing a list of running vms
RVF='/var/run/running_vms'

PATH=/sbin:/usr/sbin:/bin:/usr/bin

if [ ! -x $SCRIPT ]; then
      exit 0
fi

SELF=action_virtualbox
COMMAND=

# pm-action(8) -  
#
# On hibernate, suspend all running VMs to disk
# resume them on thaw.

case "${1}" in
      hibernate)
              # 1. get a list of processes for all running virtual machines
              # 2. for each list item extract a login name, vm uid and display and store them in $RVF file
              # 3. save state of each vm
              ps eax -o user,cmd|
              grep '\bVirtualBox\b.*--startvm\b'|
              grep -v '\bgrep\b'|
              sed 's/\(^\w*\b\).*--startvm\( [[:alnum:]-]*\b\).*\( DISPLAY=:[0-9.]*\).*\($\)/\1\2\3\4/'|
              awk -v rvf=$RVF '
                      BEGIN {system(">"rvf)}
                      {print "\nSuspending VM "$2" (user: "$1")";
                       system("su -c \47VBoxManage -q controlvm "$2" savestate\47 "$1);
                       print "Appending VM data to file "rvf".\n";
                       system("echo "$0">>"rvf)}'
              # \47 is the single quote (i.e. "'")
              ;;
      thaw)
              if [ ! -s $RVF ]
              then
                      echo "No virtual machines suspended at the last hibernate which haven't already been thawed, therefore nothing to thaw."
                      exit 0
              fi
              cat $RVF|awk '
                      {print "\nResuming VM "$2" (user: "$1"; "$3")";
                       system("su -c \47"$3" VBoxManage -q startvm "$2"\47 "$1)}'
              echo "\nAll thawed. Deleting $RVF."
              rm $RVF
              ;;
esac

Wednesday, 29 October 2008

Atheist propaganda

I have stumbled upon yet another atheist propaganda clumsily disguised as a balanced article whose author pretends to be objective and friendly towards theists and their beliefs. Here are some excerpts with my "subtitles" showing what the author tried to smuggle, in between lines, to his readers' heads:



'Being openly atheist can have drawbacks for some of us. Your God fearing boss might not give you that promotion - or worse.'

Religions other than Atheism make people unethical.



'You are often confused as having God hatred. The ignorant think you belong to a cult.'

Atheists are bright. Theists? Not so much.



'But I am a man of reason and logic.'

Atheists are enlightened. Theists are backward and have huge problems with logic and rational thinking.



'If you say 'cows can fly' I will laugh heartily in your general direction but not completely dismiss you. Show me evidence of the orbiting bovine and I will take that laugh back.'

Theists' belief that God exists is laughable and on a par with statements like "cows can fly".



'You see by default everyone is born atheist in the technical sense of the word. Children are too young to understand the complexities of religion and what it means to believe in a God.'

Theists' beliefs are unnatural because people do not know nor understand them when we are born. If they were true, they would be natural, like atheism, which is natural and therefore true because we know that all babies both understand atheism and are atheists. Apart from the false belief in God, everything else in existence we don't know when we are born, like Physics and the laws of nature, is an exception to this rule and, as such, is true.



'I might add that unlike a lot of my God fearing friends'

Theists live their life in fear. The life of an atheist is better. Be free from fear!



'This isn't the dark ages after all. And besides, I would consider that a form of child abuse.'

Theists are child abusers still living in the dark ages. Atheists are different as they do not train their children to adhere to theist beliefs but allow them to "choose" atheist belief.



'I want my children to learn about God and read the Bible, and when they are old enough even explore other religions if they so desire.'

Atheists are better than theists, because they do not force anything on their children but rather allow them to study Bible and other religions from the atheist point of view (i.e. after children fully "understand" that all beliefs incompatible with Atheism are false).



'The reason I want my children to learn about religion is because although no-one can prove the existence of God to me, I on the other hand cannot 100% disprove the existence of God, even though every last shred of evidence would seem to.'

Not only are atheists the only people who were able to estimate the probability of non-existence of God (and, as such, can make legitimate evaluations of which belief is more probable and which is not) but there is overwhelming evidence (?!) clearly showing to any reasonable mind that there is no God.
No one could even try to prove the existence of God. On the other hand, though it is true that the author cannot FULLY disprove God but it does not mean that disproving God is impossible. Quite the opposite... probably...



'This is what separates believers from atheists. Religious people will not allow for the possibility that God might not exist. If they did, then they are technically Agnostic.'

Atheists are open-minded. Theist are not. Theists who are open-minded stop being theists so, by definition, there are no open-minded theists. Open-minded atheists do not stop being atheists even when they become agnostic and stop claiming that there is no God.



'Science however acknowledges the possibility of God however remote, because good science is about the collection of evidence to support theories, and the subsequent process of trying to disprove said theories.'

There is no God and Science knows it, but it needs to acknowledge the possibility of God to be able to prove its impossibility ;). Atheists do not need to wait for Science to disprove anything because they know the truth and Science will also, eventually, learn that truth.



'When my children get older they will naturally follow what they believe or disbelieve, and I will want it to be their choice - not mine or anyone else's.'

Unlike theists, atheists are good for their children because they allow them to "choose" atheism while theists, in contrast, force their children to choose theism.



'They (children) are too young to understand now but one day they will thank me for it.'

Atheists' children are too young to understand why they have to become atheists but it is for their own good and, since atheism is so much superior to theism, they will eventually feel grateful. Let us remind everyone here that theists' children are abused and forced to believe in theism! No one would be grateful for something like that!



'The chances are high you were doctrined into the same religion as your parents.'

All belief systems other than atheism are guilty of brainwashing their younglings. Atheism is different. Atheism is all about free will and the freedom of choice.



'You could argue the same can be said for atheists - that they need to have experienced religion before simply discarding it. That may be an overstatement, because you could say 'how do you know you wouldn't like Nazism if you haven't tried it?' - as there are some things we can all be certain of without trying.'

All religion (apart from Atheism) is as despicable as Nazism and people should not try it because even without trying it is obvious that it is better for them to be atheists.



'But religion differs in that there is a common theme of peace, harmony, enlightenment etc...and one main difference of course being the Deity in question. Jehovah? Ganesh? Christna? Yet some people will kill in the name of rather than concede there may be more than one God.'

Theists are dangerous hypocrites - they tell you lies about peace and harmony but what their religions are really about is killing and deception. And, of course, there is no God because all belief systems other than Atheism differ between themselves. Oh and Pol Pot did not used to murder families of theists who did not want to become atheists because he was a fanatical atheist but because he was evil. By the way, crusaders and popes were killing other theists not because popes and crusaders were evil but because theism implicates killing and suffering.



'But I like to think that this generation (my generation) might be a little more open minded when it comes to religion.'

Theists are so close-minded. If you want to be cool you have to become an atheist. Choose the bright future, not the gloomy past!



'If we don't keep asking the question, we will be slaves to the religious concept forever without knowing an alternative.'

All theists are blind slaves. Atheists are different because they do not believe in some unproven superstitious nonsense but in scientifically proven truth revealed to all atheists.



'Partly as a 'guess what?' to those who didn't know this about me, and also for anyone who might be afraid to explore atheism.'

Explore atheism or everyone will think you are a coward!



'The mere fact you are questioning religion says you are probably more open minded than your religious colleagues.'

So you are questioning your religion? Good boy...
No? Better start questioning it or everyone will know you are a narrow-minded fool!

New marketing trick is being used by atheists to brainwash less bright

Atheists love to announce to everyone that their credo is on a par with any scientifically proven assertion. Recently, I have noticed that some of them adopted a new way of deceiving agnostics and theists (and, in most cases, I am sure, also themselves) into believing that Atheism is not based on belief. Since it was impossible for them (or anyone else for that matter) to prove their claim that "there's no god" they modified it and now you can hear and read everywhere (e.g. on some buses in the UK) that "there's probably no god". This way they try to avoid the necessity of confronting the fact described in my previous post, where I explained that Atheism is, without doubt, based purely on belief (like any other religion - be it (in alphabetical order ;) ) Christianity, Islam or Judaism).

Are atheists right? Is their new claim any more "scientific" than the previous one? No.

What did they confuse this time?

They abused the word "probably". Since no one can calculate (or even estimate) the probability of (non-)existence of god their use of this word, from the scientific point of view, is invalid. In other words, both their statements are basically the same as "probably" just does not mean anything when (ab)used this way.

So what do I think about the new atheist campaign in the UK? Is it silly? Certainly... but will it be successful? I expect that a crowd of new atheist converts will soon mushroom in Britain. It is a shame that such a primitive trick will wreck havoc among weaker minds.

Monday, 11 August 2008

Atheism - a new religion ashamed of being a religion

Remains of a tiny fraction of ~2,000,000 victims massacred by an atheist regime led by Pol Pot.
As most (if not all) of the Atheists I have met so far seem to have a real problem with semantics and accepting the fact that Atheism, like any other religion, is based on belief, I will follow Jesus's example and explain it using plain words (plus a pinch of elementary Logic).

Let us start...


When one asks a question "Does God exist?", one will get the following answers from the following different categories of people:

Theist: Yes.

Agnostic: I don't know.

Atheist: No.




Let p represent the statement "God does exist.". Here are the statements made by our actors:

Theist: p

Agnostic: p v ~p

Atheist: ~p

Agnostic's statement (p v ~p) is a tautology and, as such, is always true. The other two are not tautologies and, before any of them can become anything more than just a mere hypothesis, must be proven. Since neither Theist (p) or Atheist (~p) can prove their hypothesis, neither of them can be called a fact. Everyone who still maintains that one of these hypotheses is true, is nothing more, than a believer. This is an unquestionable fact and anyone who tries to fool you into thinking otherwise is denying the laws of Logic and, as such, should be called either a fool or a charlatan.

Q.E.D. ;)


Actually, let me share one more thing with you.  Here is a definition of religion by a titan of modern anthropology, professor Clifford Geertz, who studied religion and defined it as a "system of symbols which acts to establish powerful, pervasive, and long-lasting moods and motivations in men by formulating conceptions of a general order of existence and clothing these conceptions with such an aura of factuality that the moods and motivations seem uniquely realistic.".  Atheism, Buddhism, Christianity, Communism, Islam, Judaism - they all have something in common: each of them is a religion.  Two of them are different from the others in one respect though - the followers of those two usually do not like to admit that they are part of a religion… probably because religion is just opium for the masses and nowadays everyone wants to be special ;).


Popular Posts