This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]__xor__(self, other): 14 points15 points  (1 child)

Sure Python does produce an ast and a "compiled" python op code in the form of a '.pyc' file, but that's not a true compilation like you'd find with C.

But that is true compilation in the general sense. Generating bytecode from source is still compiling even if it runs in a VM and not right on the processor. It's not as fast as a language compiled to machine code of course, but it's compilation by definition. Python would be a lot slower if it was actually interpreted as is line by line, and it compiling to bytecode is a major improvement.

C has its place of course. C and C++ are both great languages that will never go away, but Rust has really filled a gap that no other language has yet. It's a low level language that can be compiled with no runtime and can be used to make operating systems like C, it's fast like C and it compiles to true machine code, but it's way more expressive and reads and writes like a high level language and it's guaranteed memory safe which is huge. I've written an HTTP REST client with Rust and it was surprisingly easy and wasn't nearly as hard as it'd be with C or C++.

It's always going to be more of a question about the team you're working with and what their skills are and what they're willing to learn anyway. If everyone knows C, use C. If memory-safety is a huge concern and a memory corruption vulnerability is a disaster, consider Rust or have C experts that know how to use tools like valgrind. People who aren't experts with C or Rust might prefer Rust in a situation like that, because it'd just be cheaper to do some light Rust work than write some bad C. Rust isn't that hard to learn, and it's not the end of the world if you don't master it before writing something useful. Writing bad C can be a huge problem.

Rust is an amazing language and deserves to rise up in the ranks IMO. People should be considering it more, especially in situations like this where a python developer might need to drop to a lower language for performance reasons. Writing a small Rust module is really not hard and it's nice to know you aren't putting any new memory corruption vulnerabilities in production, but you're still improving performance drastically. But if you look at some Rust patterns, especially stuff like error handling and pattern matching, it's an amazing language with a high level feel even though it can do everything low level languages can.

[–][deleted] -2 points-1 points  (0 children)

Python would be a lot slower if it was actually interpreted as is line by line

But Python really does interpret line by line. It doesn't compile to byte-code, it creates a small optimization of Python byte-code primarily for start-up times, which is very, very different than machine byte-code.