| ▲ | srj 7 months ago |
| Am I the only one who loves writing C++? I've used some newer languages like Kotlin, and that's good too, but I always come back to C++. I think a lot of the criticism is from the old way it was written, before C++11/17. |
|
| ▲ | MathMonkeyMan 7 months ago | parent | next [-] |
| C++ is a lot of fun, and there exist many compelling subsets, but the language as a whole is a minefield that you need years of experience to navigate, and probably can never master. |
| |
| ▲ | nightowl_games 7 months ago | parent [-] | | Kinda. The vast majority of c++ I encounter is simple orthodox c++. No one I know cares about new features in c++ and bemoans having to ever write a template. No one really cares about bulletproofing types, ie: copy/move constructors and all that stuff. I'm sure it's different at big companies but the vast vast majority of c++ is just simple procedural code. | | |
| ▲ | 8fingerlouie 7 months ago | parent [-] | | > the vast vast majority of c++ is just simple procedural code. Probably because where C++ is needlessly complex, C is beautifully simple. I've used both C and C++ in my career, spending 10+ years as a C programmer (kernels, applications and embedded stuff), as well as 4-5 years as a C++ programmer in a financial institution. I find the thing most "new C/C++ programmers" complain about is memory management and type safety, but honestly, once you have a few years worth of experience, memory management is almost second nature. Most of the time i write the free() statement at the same time as i write the malloc() statement (if applicable). | | |
| ▲ | weebull 7 months ago | parent [-] | | One of the things I loved about Python when I learnt it was how it dealt with `public`\`private`\protected``. It was "we're all responsible adults. No need to hide anything. We'll just use a naming convention for members that we don't expect people to directly use." "Enforce encapsulation" suddenly became. "Respect encapsulation" in my head and a bunch of Java/C++ problems evaporated. | | |
| ▲ | kstrauser 7 months ago | parent [-] | | I do love that about Python. The encapsulation is there but you can work around it if you’re willing to take responsibility for breaking the gentlemen’s agreement. That’s a lovely pattern. | | |
| ▲ | karmakurtisaani 7 months ago | parent [-] | | This gets more and more horrible the larger the code base grows and the more developers get involved. My current preference is to have everything public, but immutable. Edit: except for functions. Private functions are a great way of keeping downstream users from touching them. Only expose what you are willing to support. | | |
| ▲ | kstrauser 7 months ago | parent [-] | | My experience has been otherwise. There’s almost never a reason to be playing with something like db_connection._socket, but in that one place in your codebase you really really need to, it’s a lifesaver to have access to it. Linters should be shouting about it and in the PR you’d need to explain why you turned off the warnings to do it anyway, with comments explaining why there was no other feasible option and this was the least bad choice. BTW, I rarely write _methods and almost never __protected attributes. _something just means “it’s here but you really shouldn’t be playing with it.” I don’t see an advantage to using __anything. |
|
|
|
|
|
|
|
| ▲ | jayd16 7 months ago | parent | prev | next [-] |
| Tooling is a pain, packages are a pain, compiles are slow, the language is inconsistent, header files why..., the list goes on and on and its not outdated complaints. (lots of reasons to like it, too) |
|
| ▲ | pjmlp 7 months ago | parent | prev | next [-] |
| I love C++, it was my next language after Turbo Pascal, there was a small stint with C, but already in 1992 it felt outdated. However, during the last decade C++ culture suffered, probably it has taken too many C refugees. What you call old way, it is still how many folks write C++ in big corporations, I tend to complain that I only see Modern C++ in conference slides, and my own hobby coding. |
|
| ▲ | macgyverismo 7 months ago | parent | prev [-] |
| I love it too, it tends to bend to my will, for better or worse. It feels like it doesn't stand in my way, and that further translates to feeling like there is nothing between my program and the hardware it runs on. No need to school me on how that isn't true, I'm just describing my feeling and why I love C++. |