Live data from Hacker News

Does C++ still deserve a bad rap?

nibblestew.blogspot.com

161–170 of 310 posts

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

#161

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 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?

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

#162

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…

From memory, a thing i've implemented in C++ that its basically impossible in almost any other languages (with few exceptions). Represent a data table in memory where the columns are from different types, where the data is backed by a arena allocator and represented contiguously in memory. Of course you can do a data table representation in almost any language, but once you benchmark the implementations, the language…

> Of course you can do a data table representation in almost any language, but once you benchmark the implementations, the languages that gives you full control of memory and are good at moving bytes are the ones that lead in performance.

The thing is, once you need even more performance, you might need parallel evaluation. And in C++, there are plenty of opportunities to shoot yourself with which even very experienced programmers have sometimes extreme difficulty doing it correctly:

https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedL...

https://preshing.com/20130930/double-checked-locking-is-fixe...

And this is the area which Rust, while being as performant as C++, is heavily improving on.

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

#163

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 love this concept! I think it's more linked to experience than anything specific language feature.

I used to think it was typing, then I became more proficient in Haskell and the type system actually saved me time.

My in-the-flow languages right now are Haskell, JavaScript and PHP, but I'm trying to add rust to it.

I have a friend who reaches out to C for quick prototyping. I know many more going for .Net or Java (which are not that far from C++)

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

#164

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…

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

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

#165
I still love C++ but rarely code in it any more. One interesting thing is that the whole modern approach to immutable data structures seems so wasteful to me now. C++ you literally take strings and overwrite characters, where now people duplicate lists of records just to stay clean.

Once you have the discipline you need in C++ to make mutable data structures work its a hugely efficient place to be. However I sleep much better in the non-C++ world.

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

#167

Earlier quoted context omitted.

It should return a range of string views, no allocation is necessary.

That sounds like a great idea. Not sure if it might present a bit of a hurdle if the caller prefers it to be random-access, but I'm kind of tempted to try this out and see if it might present issues in practice. It might be worth suggesting it to the standards committee?

I think it should be bidirectional. Random access is expected to mean O(1) advancing of the iterator. I don't think it can be done without upfront work and allocation at construction.

If one needs random access they can always do the bidirectional range -> vector of string_views conversion.

Ranges are relatively new in the standard and not many algorithms landed in the library. I'm pretty sure there will be many new range algorithms in the upcoming standards. This particular algorithm is probably worth suggesting. I recommend floating the idea on the cpplang slack (there are #ranges and #future_standard channels) and/or the std-proposals mailing list. I never wrote a proposal, but you can chat with people who did.

https://cpplang.slack.com/

You can get an invitation here: https://cpplang-inviter.cppalliance.org/

https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

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

#168

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 like several other modern/newer languages do, making it vastly more applicable from anything from embedded to large-scale programs without restrictions. Modern C++ has smoothed a lot of the rough edges in terms of productivity, but it's still an overly complex language that cannot shed any weight due to backward compatibility, and it's a shame.

Contrarily to many other guys tough, I'd take a dash of C++ compared to "simple" C/C99 any day, especially in embedded. C++ can be vastly simpler and more readable, while retaining 100% control over memory and layout. Most of the memory/threading issues essentially disappear with very little fanfare, but few people talk about that.

I don't want to detract against static checking though! But I feel like newer languages such as Rust are still too young and idealistic, and haven't been beaten by implementation requirements or a system's programming language yet where your silly requirement is somebody else's essential feature. This is how it gets ugly, and this is where C++ has probably something to say.

I still like modern languages though. I like Rust, but won't be able to use it effectively until they get rid of static compilation. I wish I had D's metaprogramming over C++ templates any day, but the GC is a again non-starter. Nim has no static checking, but it should deserve much more consideration than it currently has: it's much more pragmatic than Rust IMHO, and it's also much easier to integrate into existing programs will less hassle.

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

#169

Serious question to those in the gaming industry: I heard C++ is mostly dominant there, can any other language even be considered for writing a game engine in? For serious AAA titles?

Game Oriented Assembly Lisp: https://en.m.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

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

#170

Earlier quoted context omitted.

> 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. Any books or resources for digging deeper in these kinds of topics? I’m a Python developer and would like to learn C++ but the just the reasons you mentioned make i…

Python developer here just switched jobs to one that does C++. Let me warn you right now. It's not worth it. At all. Don't go down this path. Memory management is easy, but that's not the only crap you have to deal with. Templating and the whole C++ ecosystem with Cmake compiling to make is a giant headache. It takes about a week to integrate a new C++ library in source code and people are worried about installing or…

> while in python I'll install an entire library in seconds just to try out a function.

but... surely you are aware that the memory leak concern absolutely does not disappear ? you just choose to not care about it in the python case for "reasons" - likely you've never been hit by a system which appends to a dynamic array without ever emptying it, and that can happen in every single language in the world.

Post reply on HN