6 ms·
Is it really slow? I ported a bunch of code from PHP to Python, nothing incredibly complicated, but it was easy to switch and the Python code all ended up runni
by bluedino 9y ago
Is it really slow? I ported a bunch of code from PHP to Python, nothing incredibly complicated, but it was easy to switch and the Python code all ended up running about 25-40% faster.
I'm sure it would have been even faster to use Java or something like that but it would have taken 5 times as long, and I would have needed to know a lot more Java than Python.
- weberc2 9y agoYeah, slow is relative. PHP is no one's standard for "fast". I program in Python by day, and I find Go much easier to work with, and it's roughly 10 times faster. There are other performant options besides Java these days.
- zerkten 9y agoWhat are you actually programming? You mention some languages, but you don't actually give any context.
- deleted 9y ago[deleted]
- jack9 9y ago> PHP is no one's standard for "fast". PHP is my standard for "fast" in the realm of scripting. Just behind Perl. Python is slower in every prototype benchmark we have ever tried. It's a practical problem that hand waving cannot remedy.
- hasenj 9y agoFast would be something like Go or D or any of the other compiled languages.
- jack9 9y agoI'm not sure how that relates. None of those are scripting languages, although when you start talking about "compiled" it gets a little messy with definitions. Either way, it's not what I'm talking about.
- weberc2 9y agoYou're the one who invoked "scripting" out of the blue. There's no reason to artificially limit the conversation to scripting languages, especially since "scripting" is itself poorly defined (what constitutes a scripting language? An interpreter? Where do interpreters end and VMs begin? Python's "interpreter" is a VM; is Python not a scripting language? Python even compiles to Python bytecode--is Python then a compiled language?). If you're going to scope the languages being evaluated, do it by something meaningful, like problem domain--for example, "web applications". I can't speak to D, but Go is certainly a competitor in this space, and speaking from experience, it's much, much more performant than Python and PHP by virtually all metrics. Maybe you mean data science, in which case Python and Go can be compared, but I don't know that anyone is doing real data science work in PHP. Maybe you mean "general purpose language", in which case all of the previously discussed languages can be compared, and in which case Go and D completely outclass Python and PHP.
- cygx 9y agowhat constitutes a scripting language? It's indeed a bit fuzzy, but program execution without separate compilation (which is not a feature of a language per se) is something I'd look for. As far as intrinsic language features go, a lack of boilerplate in the sense of print("hello") vs class Hello { public static void main(String[] args) { System.out.println("hello"); } } is a good indicator, as is dynamic typing.
- weberc2 9y agoThis isn't a meaningful definition because compilation and execution under a single command is trivial for any compiled language, including Go and Python and PHP. As for lack of boilerplate, Haskell and many statically-typed, compiled functional languages have less boilerplate than PHP or Python. Dynamic typing is more meaningful, but regardless of definition, I fail to see why it's useful to restrict the scope to scripting languages. However, even if you make this restriction, there are many, many languages that are dynamically typed "scripting" languages that are much faster than PHP and Python (JRuby, Lua, JS, Wren, most lisps, etc).
- cygx 9y agoPHP is supposedly faster than Python, nowadays. Not at the JS or LuaJIT level, but it eats CPython and CRuby for breakfast.
- igouy 9y agoI wonder which version of PHP you were using?