DEV Community

Discussion on: Why programming languages are slow

Collapse
 
sucuturdean profile image
David

First of all, you keep saying that syntax is bad in c, c++ and Rust but that is very debateble, some may say that is better because it is more verbose/expresive, so don't just say that they have bad syntax, what you might have wanted to say is that they have a step learning curve because of the syntax. Second of all java and c# compile to byte code, not python and what other language you typed there. Python code runs on a program called interpreter which reads "raw" python code and executes it at the same time, that's why python is slow. Java and c# on the other hand, they use a compiler that produces byte code and you as the programmer distribute that byte code instead of the java or c# code you wrote. The difference between java like languages and c like languages is the code that is produced, the byte code is cross platform but needs a VW to run while the binary produced by c like languages is not cross platform but doesn't need a VW to run. That's why C like languages are the fastest, Java like languages are second fastest and Python like languages are the slowest.

Collapse
 
kopylov_vlad profile image
Vladislav Kopylov • Edited

And I just want to clarify one point:

Second of all java and c# compile to byte code, not python and what other language you typed there.

Each modern interpreted language doesn't read and execute each line of the source code at the same time. Honesty they aren't "pure" compilation languages.

Starting with Ruby 1.9 the official Ruby interpreter implementation switched to YARV ("Yet Another Ruby VM"). It pre-compiles Ruby into bytecodes. Once Ruby source code is converted to bytecode, a VM executes the bytecode. Converting source code to bytecode gave significant speed advantages to Ruby.

Python source code is also compiled to bytecode. In Python, you can directly observe it in the .pyc files. In Ruby 2.6.0 we have Just-In-Time compiler (JIT). It compiles instructions that are used often into optimized binary which runs faster.

So these languages are a hybrid of compiled and interpreted code.

Collapse
 
kopylov_vlad profile image
Vladislav Kopylov • Edited

Thank you for your comment. Yes, I agree that the syntax isn't "bad" (even I didn't use the word "bad"). In a university I enjoyed writing code on C, before I saw PHP and Python. But some people agree that it's challenging to write code and you always care about memory.

Grigory Petrov clarified it in the comment

Collapse
 
sucuturdean profile image
David

You are saying both here and in your post that you allways have to think about memory in c, c++, rust and objective-c, but that is not true for c++ no more. With so many abstractions it has gotten hard to actually think about memory in that language. In rust its a similar story, but you have to worry about refrences instead of "memory".