Hacker News new | ask | show | jobs
by GodelNumbering 6 days ago
Personal opinion: C++ is the most elegant language I have used (for about 15 years). If you are the 'systemizer' type and like to have an extremely precise mental model of the thing you write down to the last bit, nothing beats C++. I acknowledge the limitations and uncertainties that come from compilers etc, but still
4 comments

An elegant language is one that achieves a lot with very little. Forth and Scheme are elegant languages. You're free to like working in C++, and you can sure achieve a lot with it, but I don't think it's controversial to say that it does not do so with very little.
It's easy to make a minimal language that can technically do everything via Turing completeness. That can look elegant until you start writing reptitive or hard to read code with it. Golang "if err" is a classic.
The notion of Turing completeness isn't relevant here, it encompasses almost none of the interesting distinctions between programming languages in practice. And yes, simplicity alone isn't what matters here, or else we'd all be applauding Brainfuck. What matters is strength:weight ratio, or the interesting expressiveness and abstractive power of your language weighed against its surface area.
Makes sense. This appears to be also a symptom of whatever you work on most (or start with), your brain starts to absorb that into its way of thinking.
> If you are the 'systemizer' type and like to have an extremely precise mental model of the thing you write down to the last bit, nothing beats C++.

I would say the same thing of Rust.

I very much prefer to work in Rust but it does force you to design things in an counter-intuitive way in certain situations (linked lists for the canonical example). Specially for lower level software I find C or C++ to allow for much more flexibility and thus the most straightforward design possible.
I really don't think Rust does, but that's if you're outright refusing to use `unsafe` anywhere. Might be a little noisier if you're using things like ManuallyDropped instead of just using raw pointers, but the language doesn't stop you from doing things in ways you would with C or C++, it encourages you to encapsulate the hard parts so you can worry less about correctness of 98% of your codebase, instead of fearing incorrect behaviors can silently sneak in.
That's absolutely correct. Wild to see it downvoted without explanation, while you preemptively mentioned the tradeoff that you do need to worry about correctness in that case (just as much as in C/C++), but that only applies to a small part of your codebase, so it's still a huge benefit.

The only downside is that unsafe rust is more verbose than C/C++.

Can you please share an example of the precise mental model of something?
I would think c would?