7 ms·
"one of the major purposes of using higher level languages [is] to avoid writing in C" And one of the major purposes of using C is to write fast libraries that
by parenthesis 16y ago
"one of the major purposes of using higher level languages [is] to avoid writing in C"
And one of the major purposes of using C is to write fast libraries that can then be called from high level languages.
- fauigerzigerk 16y agoRight, so if you cannot write solid C code, don't use a C based Ruby runtime, because not being able to write a fast library if need be cripples you as a programmer.
- weaksauce 16y agoI don't know if it cripples you but it certainly makes the problem domains that you are going to be able to tackle effectively smaller. But a lot of the time you are going to get the most speed improvement by just looking for an appropriate algorithm.
- fauigerzigerk 16y agoSure, and when I have chosen a good algorithm, I want to implement it in a language/runtime that is suitable for algorithmic code, not in Ruby or Python or PHP. To be able to do that is something I expect of myself and everyone I work with.
- msbarnett 16y agoRuby and Python aren't suitable for "algorithmic code"? Is there any other kind?
- fauigerzigerk 16y agoIt's obviously not a formal distinction. Algorithmic means "spends a lot of time running loops doing something interesting" as opposed to "copies data back and forth between the UI and the DB". Or CPU intensive versus IO intensive. [Edit] And just to be completely clear and also reap all the downvotes that I can get from disgruntled web devs: Python and Ruby are indeed totally unsuitable for writing CPU intensive, complex algorithms. If you write Ruby or Python code, avoid loops! Try to be declarative so all the loops stay in the C code.
- lsb 16y agoAlternately, if you use a high-level-language like Haskell that can compile into machine code, you can rewrite something like regexp matching (like regex-tdfa[1]) and get better performance than what the stdlib gives you on some inputs. [1] http://www.haskell.org/haskellwiki/Regular_expressions#regex-tdfa http://www.haskell.org/haskellwiki/Regular_expressions#regex...
- jrockway 16y agoYeah, exactly. I rarely have to call out to C in my Haskell applications. When I do, it's only to get or send data to a C library that I don't want to rewrite. Internally, things like Data.Vector work just like the C equivalent. The internal representation of the data is the same (i.e., Vector.Unboxed Double == a big block of memory with CDoubles in it), and the machine instructions that run on the data are the same. High-level languages need not be slow. It's just that Perl, Python, Ruby, and PHP are.