# from Carlos Konstanski # on Thursday 04 February 2010 12:37: >There are a host of commonly-used interpreted languages today that are >slow because they are interpreted. BASH, perl, python, ruby,
Every one of those interpreters is/was written in C and compiled into machine code. If your compiled program is going to do the same amount of work as the interpeter, it becomes the interpreter (definitions being what they are and such.) If you can take a shortcut by dropping a bunch of features from your runtime, of course the resultant machine code will be faster. The engineering decision is simply about how long it takes you to code that shortcut vs what it's worth at runtime. Meanwhile, vast quantities of XS extensions are available on the CPAN (e.g. dbi, expat, libusb, libgsl, wx, gtk, qt) which let you run the heavy lifting through some compiled machine code (at the expense of a bit of marshalling overhead) while you happily write more expressive code without worrying about memory allocation or buffer overflows. You can generalize about compiled vs interpreted but it really doesn't count for much by the time you pile 100 other trade-offs into the decision. >Let's see the list of counterexamples. Your unoptimized regular expression engine vs Perl's is an easy one. I'll grant that most of the others are hard to win on time benchmarks. And that's fine if you get infinite time to write code, debug it, maintain it, and have zero cost for downtime or security breaches. Spherical horserace in a vacuum and all that. > FB is making their PHP run faster by compiling it. Why would they do > that if the slowness of their interpreted language, and the benefit > gained by compiling it, is a myth? It's always faster to do less work. For the machine, there are cases where you can accomplish this without giving up the expressiveness and dynamic code. Some JIT work promises to outrun naively compiled C because it can examine a running loop to e.g. remove several conditionals. There are more and more shades of gray between compiled and interpreted as time goes on. >From what I've read about the facebook php, they're simply caching another step in the process. Interesting tech, but probably vastly different in lifetime cost compared to rewriting everything in C++. "Myth" isn't the right word to describe the typical gross over- simplification of comparing dynamic/static interpreted/compiled code, but bugs per KSLOC and SLOC/day/developer are still very cruel constants. If you're interested in the shades of gray and some pretty nifty stuff happening in the world of VMs, please join us next week at pdx.pm for an introduction to parrot. http://pdx.pm.org/ :-D --Eric -- Atavism n: The recurrence of any peculiarity or disease of an ancestor in a subsequent generation, usually due to genetic recombination. --------------------------------------------------- http://scratchcomputing.com --------------------------------------------------- _______________________________________________ PLUG mailing list [email protected] http://lists.pdxlinux.org/mailman/listinfo/plug
