by Sam » 01 Feb 2018, 02:08
smithy wrote:nice @sam would check it out asap, what about from high levels to low level?
Cython for Python and Haxe do just that.
Here's a couple of other examples that compile to lower or higher level langauges or native machine code:
- Kotlin (compiles to machine code). It's a popular Java - like language that can run on JVM or natively or via JavaScript.
- Nim-Lang. Python - like syntax but built for speed. Compiles to C++, JavaScript and C.
Some languages make use of LLVM to produce binary machine code. See:
https://stackoverflow.com/questions/235 ... ly-is-llvm.
I think a good question to ask is if it is worth it? If you're looking to speed up Python you should ask the following:
1. Do I really need extra speed? Is my application that time critical?
2. Have I coded this in good form? Can I replace lists with dictionaries or sets? Am I using bulky libraries and can I use ones which are Cython optimized? How am I storing and searching? (think Big(O)).
3. What's worth more: my developer time or code completion time? (if it's code completion you should start looking at faster languages like C, Java, Nim etc. Java is actually really fast if you look at benchmarks... I even coded something in python and java and shaved 1s off the completion time. Obviously you aren't going to get C-speeds on Java but Java is just a nicer language to code in).
4. Would PyPy (for JIT) speed up my code enough?
5. What are my time critical functions? Should I be using Cython?
Just remember, making a language switch is kind of a big deal. It's often best to stick with something you know. I only code for fun with Python because I don't code enough to keep up with other languages on top f that (including ones I learned at uni like R, Java, C, C#, F#). My next language that I fully learn will probably be C because that works nicely with Python. Python + C and you can accomplish anything.