Live data from Hacker News

Does C++ still deserve a bad rap?

nibblestew.blogspot.com

201–210 of 310 posts

Re: Does C++ still deserve a bad rap?

#201

Earlier quoted context omitted.

it depends on what you're doing of course. It can even go the other way[1] Generally languages like C++ are obviously much faster, but a lot of primitive stuff in languages like python is also just C calls and may be optimised to the point of being faster, because doing things in low level compiled languages often comes with its own tricks and problems. [1] https://stackoverflow.com/questions/9371238/why-is-reading-l…

To be fair, C++'s standard I/O library is really bad. There is probably an almost universal consensus in the C++ world that the locale library is the worst standard library, immediately followed by iostreams. For small programs that's annoying, although using libc IO is usually fine for them. However, C++ is probably one of the top 3 languages for developing large applications (Java would also be there, not sure whic…

In terms of large projects C++’s role is very much shrinking. C++’s last major strength is being cross platform, but new platforms keep excluding it. You can’t program on iOS or client side websites with it. Microsoft actively discourages using C++ on Windows, and C# took over for large projects.

Essentially C++ and the modern ideas about computer security are at war.

Re: Does C++ still deserve a bad rap?

#202

I have nothing against C++ per se. Used it on and off for 10 years (but most actively 3). It's a fine language. To me using C++ means you are ready to give up a lot of time and energy in order to gain a complete control over certain aspects of your program. I was very much into that at the start of my career and gradually started drifting away to more immediate productivity while reserving the right to poke under the…

I used to work with C++ almost exclusively, but accepted to use more interactive languages for most of my work mostly for faster iteration. C++ is definitely not my main choice anymore, but still use it daily. C++ has pretty much unmatched tooling due to the massive ecosystem. I have my own long list of gripes against it's syntax and historical baggage, however it's a language that doesn't really impose a style/idiom…

Fair and accurate points. I admit Rust needs to sort some kinks out still but it builds up on the experience of C++ and I believe it's already heading in a very productive direction. I love what they're doing with their async stack, being just one example.

I can't deny compiler and linker speed in general are better in C++ land but Rust is gradually catching up (too slow for my taste still but sigh). That's a very strong point against Rust to this day.

You might be right that compromises for running in embedded environments might load Rust with the same ugly historical baggage as C++. That's very possible and I can only hope it won't happen, but you do still have an excellent point about the genesis of these problems.

D and Nim I admittedly didn't evaluate very fairly -- gave them half an afternoon each. They were quite nice in fact, but I found the small ecosystem off-putting, especially in a situation when I want to play with an idea that might require libraries for 5+ well-established technologies. So yeah, I wasn't very fair to them but didn't want to dedicate much time for prototyping ideas regardless.

Re: Does C++ still deserve a bad rap?

#203
My beef with C++ is with its dependency (non)management.

For almost every modern language, you can easily build and run code - pull code from repo, run the included script or standard command to get the dependencies and build it, bam, you're done without needing to know much about that language.

With C++ it seems like half of the time pulling someone else's old project from github and running make (or whatever the author's instructions in README are) results in failure with some error that's tricky to diagnose and fix. For example, you would get some weird code error message that has zero indication with the actual cause which is that your system has a newer version of some core library than the author had.

Re: Does C++ still deserve a bad rap?

#204
post #164

Earlier quoted context omitted.

What are the cases where you would use specifically Ocaml instead of C++ or Rust?

(EDIT: I misread your question, apologies. OCaml vs. C++ is mostly because of much less surprises to start working with it. OCaml vs. Rust is mostly because Rust mandates you to pay attention to a lot more initially (`Result`-s being a prominent example, although using `.expect()` or `.unwrap()` actually helps a lot) and even if I absolutely love that you have to iron-proof your code, it does get in your way when you…

OCaml is a much smaller language than Haskell.

Similarly, Erlang (and thus Elixir, I guess) is also comparatively small and simple.

Surprisingly, C would be in the same category, if it wasn't so primitive and likely to make you shoot yourself in the foot.

I've programmed professionally in both OCaml and Haskell (and Erlang and C etc). I find that Haskell is generally more terse than OCaml.

They are both fine languages. Subjectively, Haskell feels a bit more fun to me. But if you want to really get into it, it helps to have some people around who know what they are doing.

Re: Does C++ still deserve a bad rap?

#205
post #193

Earlier quoted context omitted.

I find it very interesting that you put Haskell in one camp, and OCaml into the other. I am more of a Standard ML guy instead of OCaml, but can you elaborate a bit why you feel you can iterate faster in OCaml than in Haskell?

OCaml is quite a lot more pragmatic and 'loose' than Haskell. But that's just my impression. They even have for-loops in OCaml.. (I would be really slow writing code in vanilla JavaScript. There's no static checking, and not much dynamic checking. So you need to watch your step very carefully---in some sense, very much like in C++.)

> OCaml is quite a lot more pragmatic and 'loose' than Haskell. But that's just my impression.

Mine too. I still dislike the lack of Unicode strings by default, and the somewhat confusing tooling (initially) but outside of that I quite love the language. It has a huge potential and I can only hope that the arrival of Multicore to the upstream language will kick it forward and put it in the same league as Rust (although due to GC it can never be that fast I'd think; but who knows).

Re: Does C++ still deserve a bad rap?

#206

My beef with C++ is with its dependency (non)management. For almost every modern language, you can easily build and run code - pull code from repo, run the included script or standard command to get the dependencies and build it, bam, you're done without needing to know much about that language. With C++ it seems like half of the time pulling someone else's old project from github and running make (or whatever the au…

Might just as well be a strength.

At least you won't get these packages that will pull 309 dependencies, and that might build or not with the dependencies that are automatically pulled or not (with a considerable chance that it doesn't).

With C/C++, there's a bigger manual upfront investment if you want to integrate a library, but it might just be that you get cleaner libaries.

Re: Does C++ still deserve a bad rap?

#207
post #204

Earlier quoted context omitted.

(EDIT: I misread your question, apologies. OCaml vs. C++ is mostly because of much less surprises to start working with it. OCaml vs. Rust is mostly because Rust mandates you to pay attention to a lot more initially (`Result`-s being a prominent example, although using `.expect()` or `.unwrap()` actually helps a lot) and even if I absolutely love that you have to iron-proof your code, it does get in your way when you…

OCaml is a much smaller language than Haskell. Similarly, Erlang (and thus Elixir, I guess) is also comparatively small and simple. Surprisingly, C would be in the same category, if it wasn't so primitive and likely to make you shoot yourself in the foot. I've programmed professionally in both OCaml and Haskell (and Erlang and C etc). I find that Haskell is generally more terse than OCaml. They are both fine language…

Interesting how different experiences with the same thing can be! :)

> it helps to have some people around who know what they are doing

I think that's the crux of my issue. OCaml wasn't the easiest to start with either but it took me 2-3 casual evening sessions to just be able to sketch code and run it immediately with almost no hassle.

But yeah, can't deny Haskell kind of rubbed me the wrong way so I am likely biased now.

Re: Does C++ still deserve a bad rap?

#208
post #101

C++ fills a niche and probably if you use it all on your own you don't even see the problems. But if you use it at scale with multiple developers you can see it's layers of leaky abstraction laid down since the 80s that can never really be cleaned because too much is built on this foundation. This slightly over 100 page book on move semantics https://leanpub.com/cppmove shows some of the iceberg like complexities dot…

> C++ will eventually peak and die off but the timeframe is probably measured in decades and I'm sure there'll places where it holds on even then, like Fortran today. I certainly would't recommend it to a programmer starting out today, instead C or Rust would be better places to get an idea of system level programming. Unlikely. The only candidates for replacement are Rust and D, none of these are anywhere near the a…

> Unlikely. The only candidates for replacement are Rust and D, none of these are anywhere near the adoption of C++.

Neither C nor C++ have replaced Fortran in that sense, either. Yet, as far as I can tell, Fortran has peaked a long time ago.

Re: Does C++ still deserve a bad rap?

#209

Like every programming language out there, C++ is a tool. And like every tool out there it has its uses. There isn't any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there's one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data. While you don't need it in most of the cases, it becomes a ki…

> [...] fully control the memory layout of your data.

Is that actually guaranteed by the standard?

> * Try doing anything non-trivial on a microcontroller with 32KB of RAM. You could theoretically use a higher-level language, but you will end up using >10x amount of RAM.

It's a shame Forth never took off. Sometimes I wonder what it would have been like to live in an alternate universe where Forth had been the lingua franca instead of C.

(Ie imagine that universe's equivalent of Unix being implemented in Forth as its killer application and going from there.)

Re: Does C++ still deserve a bad rap?

#210

Like every programming language out there, C++ is a tool. And like every tool out there it has its uses. There isn't any point of using C++ to count words in a text file. Any high-level language like Python will beat you to it. However, there's one thing you can do in C++ and not in Python or JavaScript or PHP: fully control the memory layout of your data. While you don't need it in most of the cases, it becomes a ki…

Aren't you describing compiled languages with manual memory management vs interpreted languages with automatic memory management? Not merely C++ vs python or js

Of course, it's not inherent to a language whether it's compiled or interpreted. That's just an implementation detail.

You can total write a C++ interpreter. And there are Python and JavaScript compilers.

C++'s memory management isn't even necessarily particularly manual. Nowadays people use reference counting in C++ occasionally. (They call them 'smart pointers' I think.)

Post reply on HN