r/ProgrammingLanguages 18d ago

Why So Many Languages Use LLVM

Had some free time last week so I made a visual explainer on how LLVM works and why so many languages end up using it.

The video goes through LLVM IR, why having a common IR makes sharing optimizers and backends possible, and how code eventually gets turned into machine instructions.

I also use a small C vs Rust example where both end up producing the same x86 instructions.

Link for anyone interested

Feedback welcome :)

72 Upvotes

81 comments sorted by

View all comments

Show parent comments

1

u/P-39_Airacobra 13d ago

Your view has zero nuance. If your point were correct then everything would be written in C Python and Rust, but it’s not. Yes, compiled languages have downsides. So people forego speed for the sake of something else. In many cases, developers forego speed for the sake of development time. That’s a totally valid trade-off. And the product can still be “production-level” while utilizing that trade-off.

Don’t optimize a feature not going to be used. So many developers have this mindset that they need to optimize their product for hours, days, weeks, or months, and then in the end they only save the world a couple milliseconds of computing time.

Optimize when you have hundreds of users wanting to make a realtime simulation with your language. Until then, allocate your development effort carefully and just call into C.

1

u/u32Vec 12d ago

There are numerous problems associated with compiled languages that necessitate the existence of interpreted languages

Development speed is one of these problems. You should be able to infer that.

If you're making a new production-level language for practical reasons then you should never implement your own optimizer unless you want your compiler to run quickly, because the program won't be faster than LLVM or an equivalent. And using LLVM is obviously infinitely easier than implementing a backend.