Thursday, March 24, 2011

JavaScript Performance vs. Delphi

Native compiled code should be faster than JavaScript interpreted code, the usual saying goes.

New Kids on the Block?
There are many reasons why Delphi developers claim Native development is better: It creates smaller EXEs (if you consider that 20megs setup packages to be pushed every month is fun for customers), it is faster (with certain exceptions) and better overall experience (like no garbage collection, so Delphi apps usually crash Windows 7, with Delphi Server Apps crashing Windows 2008 server with unstable TCP/IP and consuming 2 Gigs before dying).

JavaScript is considered the worst language (by Delphi developers' point of view) for coding:
  • It is not strictly type-cast, 
  • Has overall very poor performance and very, very poor floating point performance
  • Consumes lot of memory 
  • Waste of development time (i.e., the answer is IntraWeb instead)
  • Is interpreted and therefore, easy to make mistakes.
Yet, since Delphi developers eyes are closed to the world (i.e., the world revolves around Delphi and nothing else. A Delphi developer is a Delphi developer for life, they cannot open their eyes to learn other things).

The world passes by Delphi, both in price, feature and performance.

With JavaScript, there is:
  • Server Side Java Script (SSJS)- use JavaScript on server to stream web-pages,
  • Desktop JavaScript - why use Delphi for, when you can use JavaScript for "native" development
  • JavaScript.NET - the "unpopular" version of JavaScript
  • Javascript Java - see Rhino.
  • SQL with SQL - Using JavaScript to query Oracle, MSSQL and MySQL (except Delphi proprietary databases)

Costs for learning JavaScript is free with many IDEs available (see: Eclipse). There is working Intellisense (This is broken in many versions of Delphi), many free scripts available (example: HotScripts.com), many Ajax frameworks available (see: Moo Library, Node.JS, JQuery and so on).


Project Disclosure?
Your reviewer was looking at a post by Eric Grange how "another language" beat Delphi.

The problem with this lies in the way how formerly Borland handled disclosure of "floating point  benchmarks", performance benchmarks. Many (former) professors (i.e., the gray-hair one who teaches you computer science) were silenced by Delphi's license agreement preventing them to speak up against Delphi.

While other compiler vendors (D++, C++, PHP) started to optimize their floating point with lesser languages (FreePascal, GCC, RealBasic) starting to compile with SSE2 (and even SSE3, SSE4) optimizations and giving developers good floating point performance, C++ Builder & Delphi languished with i386, i486, MMX (Pentium) performance.

It was like saying, since the day Anders Hejlsbery left, Borland could find nobody to fix floating performance since Delphi 2.

It could be considered a classic conspiracy theory - Floating Point are like UFOs and floats around in the sky and the official policy is that floating points that fly faster than the average thing in the sky does not officially exist.

If the next version of Delphi still have same floating point performance, same problems and just bug-fixes (i.e., it should be called Delphi 2009 update '11)... it would be really, really tough sell...

7 comments:

yeyo said...

is Visual Studio C# better in floating point than Delphi??
(I'm trying to be ex-delphian)

Ciprian Khlud said...

@yeyo
All .Net implementations generate code using SSE2. Also Mono can use LLVM for better optimization level. So yes, I think is predictable to expect performance will get that well on any desktop VM (maybe a Phone VM would not, like Dalvik).

yeyo said...

@ciplogic
Ok, thx!!

Anonymous said...

But that JavaScript example is only faster on new(er) generation CPU...

That is not fair...compare it on x87 era CPUs ;-)

PG said...

C# is faster than Delphi in floating point code. I was investigating this back in February and ported the Scimark benchmark to Delphi.

You can browse the source code and download the binaries from http://code.google.com/p/scimark-delphi/

PG said...

In my experience, C# is faster than Delphi when it comes to floating point operations. I investigated this back in February, and ported over the Scimark benchmark to Delphi.

You can download the binaries from http://code.google.com/p/scimark-delphi/

I've more or less lost interest in Delphi since then.

Delphi Haters said...

Mr. Phillip,
I posted an article about this for you.

http://delphihaters.blogspot.com/2011/03/scimark2-and-delphi.html