Thursday, September 23, 2010

Why free pascal on the server side ? speed and memory and yes you can press the turbo button

If php tries to mimic a modern language with adding strict typing
http://www.otton.org/2008/08/06/stupid-php-tricks-true-false-comparison/
and some disoriented view of objects and namespaces (dos style "\" namespace anyone instead of "::" or "." ?) and then compiling it to pure c++ then asm with llvm
then why not using a proper language that do proper compilation and type checking from the start and is way faster

How fast ? 100 times , yes that is not a typo
and bonus 100 times less memory or more ~ 1000 times

Pascal can beat any of the dynamic languages for speed and memory and can beat anytime c++ at compilation speed :)
And by default it beats java at memory allocation :P i think anyone can beat that

here are some examples :
Let's first beat php
http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=fpascal&lang2=php
Then ruby
http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=fpascal&lang2=ruby
then javascript v8
http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=fpascal&lang2=v8
then python
http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=fpascal&lang2=python
and so on ...lua , mono c# , ...

It's just like having another 100x memory needed for one server or the cpu power
nobody gives you that for free : ask Amazon how much they charge per server or cpu power
and you get something 100x memory on your servers for free
let's say is 4G in typical configuration and with pascal in some area is like 100*4 = 4000G
compared with typical php/ruby one.
I mean no one will give you a sgi type machine with 1000 cpus and 4T of ram for free just to run some webpage or host a facebook type application
from 10.000 concurent users you can host more 100.000 or more 1M on the same machine
and that without working it to make it scalable
There are things to be improved the in benchmark war but pascal looks good on the server side
check extjspascal
and howto use json/javascript with object pascal on the server side

1 comment:

Ciprian Khlud said...

Why pick PHP (or Ruby, but 1.8 that have a global lock and an interpreter) to show this 100 times difference?
Why not to pick Java EE with less than 1 ms transaction time in London Stock Exchange, why not pick Mono or .Net?
PHP is slower than FreePascal for some reasons: PHP runs in interpreter, it is dynamic typed so have bigger overhead.
Anyway, are you serious about peeking FPC as your server side development? Do you like the deployment tools? Your FPC web tutorials? A proven forum, blog written in PHP?
I think we both agree that if you know assembly or LLVM at least you get better code than FreePascal generates. Should we pick assembly for web development?
Or is better to write in PHP and eventually to compile your code with HipHop compiler, or as ASP.NET and for critical area code use good coding practices? Scientific code? Use Mono with LLVM backend.
If you are a skilled development you know that web applications do use a lot of strings and other constructs, and if you will use classes everywhere, C++ and FPC like memory allocators are much prone to memory fragmentation, when GC will mostly give a much predictable throughput on long running applications (combined with Java Hotspot warming, give fairly consistent performance all over the board).