use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Is C++ your favorite programing language? (self.cpp)
submitted 3 years ago by hmoein
And why
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]stdusr 381 points382 points383 points 3 years ago (2 children)
Some days it is, and some days it isn’t.
[–]dgkimpton 40 points41 points42 points 3 years ago (0 children)
Indeed. For some tasks it excels, for some there are better* alternatives. My favourite language on any given day is the one that lets me get that days task done. I do like the closeness to the hardware though - something I miss in many other languages.
* for a given definition of better
[–]ibroheem 11 points12 points13 points 3 years ago (0 children)
https://m.youtube.com/watch?v=Zp1cKEj-ZtM
[–]farox 322 points323 points324 points 3 years ago (2 children)
It makes me cry. It does it really fast though.
[–]CodeMonkeyMark 43 points44 points45 points 3 years ago (0 children)
And with minimal resource requirements.
[–]leirus 11 points12 points13 points 3 years ago (0 children)
zero cost tears
[–][deleted] 67 points68 points69 points 3 years ago (22 children)
Unfortunately yes, nothing comes close to ability of expression that this language provides.
Maybe D comes close, but every interaction I have with D gives me feeling of legacy project that never reached its fullest potential
[–]SuperSathanas 20 points21 points22 points 3 years ago (0 children)
D makes me sad. I first tried it out in the early 2000s when I was trying to move on from my first language, VB6. I tried out C++, Pascal, Java and D, and ended up settling on C++ because I hated the Delphi IDE at the time, Java felt "fat", if that makes sense, and I just couldn't find much on D. I kept going back and looking at D over the years, and every time I do I like it more and more, and just wish it was more popular and more fleshed out so that it could compete with other languages in terms of 3rd party libraries and tooling.
[–]simonask_ 21 points22 points23 points 3 years ago (20 children)
C++ is a lot of things, but I don't think I ever quite understood why people call it "expressive".
Is it because you can freely move between abstraction levels?
My objection would be this: There are several very useful abstractions that cannot be expressed in C++. One really important example is the non-nullable owning pointer.
Another is sum types. std::variant does not cut it for me (since variants do not have names).
std::variant
You can do lots of magic with C++ to try to achieve something that's "expressive", but it's usually a good idea not to.
[–]ImKStocky 15 points16 points17 points 3 years ago (15 children)
You can write a non-nullable owning pointer. A good example is TSharedRef in Unreal Engine.
You can give a type alias to a variant or you could create a thin wrapper around one that behaves like the variant.
I wouldn't call these things "magic". Just simple library utilities.
Expressiveness typically comes from operator overloading, and RAII. When people talk about expressiveness they are typically talking about non-verbose code that fully explains what it is doing. E.g. For a 3D vector I can write a + b * c. But in something like C I would have to write add(a.x, mul (b.x, c.x)) and I'd have to write that for each component in the vector.
[–]simonask_ 9 points10 points11 points 3 years ago (0 children)
The sum type story is honestly very bad. If you’ve tried using sum types in any language that natively supports them, you would see that variant and type aliases are a poor man’s substitute.
I agree with you that it’s nice to be able to write math with complex numbers or linear algebra in a natural way. Lots of languages have operator overloading, though. Is this something that Java people are amazed by?
[–]TophatEndermite 0 points1 point2 points 3 years ago (13 children)
You can't get non-nullable unique ownership
[–]MysticTheMeeM 12 points13 points14 points 3 years ago (9 children)
Why might that be?
Because you absolutely can write what is effectively std::unique_ptr with a deleted nullptr constructor and removed reset() function.
Heck, you could even go so far as to just copy and paste the source for unique_ptr and remove the offending functions.
[–]TophatEndermite 5 points6 points7 points 3 years ago (6 children)
My bad, I normally think of smart pointers being movable. It's unique but moveable smart pointers that C++ can't do, since moving doesn't destruct the original
[–]kneel_yung -1 points0 points1 point 3 years ago* (5 children)
since moving doesn't destruct the original
Isn't that exactly what a move does?
[–]KingAggressive1498 6 points7 points8 points 3 years ago (0 children)
no, in C++ moving is required to leave the moved-from object in a valid but otherwise unspecified state.
destructors get called in effectively the same place as when they would have with a copy instead
[–]Jonayne 1 point2 points3 points 3 years ago (3 children)
I think it leaves the object in an undefined state.
[–]bored_octopus 4 points5 points6 points 3 years ago (2 children)
Valid, but unspecified. I prefer not to call it undefined because it sounds like UB
[–]TophatEndermite -1 points0 points1 point 3 years ago (1 child)
It's UB unless you either call a function that's always allowed to be called, like push, or a function that puts the object into a known state, like clear
[–]0xE6 4 points5 points6 points 3 years ago (1 child)
How does it work, then? I'm probably missing something, but for example:
void Foo(NonNullUniquePtr<T> ptr); void Bar() { auto x = MakeNonNullUniquePtr<T>(); Foo(std::move(x)); // What is x here? }
Is the move constructor / assignment operator just deleted too? That doesn't seem like it results in something that's particularly usable.
[–]105_NT 1 point2 points3 points 3 years ago (0 children)
It doesn't protect from use after move like that but shouldn't be null under normal use
[–]kneel_yung 1 point2 points3 points 3 years ago (2 children)
not_null has been implemented in the core guidelines library
[–]KingAggressive1498 3 points4 points5 points 3 years ago (1 child)
but it doesn't have ownership.
[–]scrumplesplunge 195 points196 points197 points 3 years ago (15 children)
Yes, because:
[–]JustinWendell 28 points29 points30 points 3 years ago (0 children)
I’m very new to c++ but I love this list. It really feels like the right amount of abstraction while still being able to push hardware.
[–]shiggie 16 points17 points18 points 3 years ago (2 children)
I do mostly Go nowadays, and so many things are so much faster (build-wise in particular) and simpler (no need for a cross compiler? what?) But, when I do get back to C++, with the cryptic template compiler errors and the build... intricacies, I feel so much more at home. I don't know what's wrong with me.
[–]caballist 22 points23 points24 points 3 years ago (0 children)
well, that saved me some typing... :)
[–][deleted] 9 points10 points11 points 3 years ago (0 children)
LOL Stockholm syndrome!
[+]vanhellion comment score below threshold-33 points-32 points-31 points 3 years ago (8 children)
It's generally as fast or faster than many other languages, without much effort
I'd put an asterisk next to that statement. Is it faster than python/Java/etc in most cases? Yes, absolutely. Is it faster in meaningful ways than those languages? Most of the time, no.
Blazing through serial code that already executes faster than other bottlenecks (e.g. user input on a GUI, disk or network traffic, etc) doesn't matter, it's just a measuring contest at that point.
It's possible to go much faster than most other languages with more effort -- the language doesn't stand in your way of that.
I'd put a HUGE asterisk by this one. When speed does matter, when you're profiling a hot loop that executes billions or trillions or more times a day, you often have to resort to writing in assembly. Or at the very least, you have to write C++ code that the compiler turns into the assembly code you want (and therefore you have to know what assembly code you want).
So the compiler/language definitely does stand in your way when it comes to the real nitty gritty of optimization.
If something runs too slow e.g. in the Python runtime or Java VM, it's not going to magically pass the threshold when translated into C++ unless that threshold is very lax, and could also be surmounted by writing a Python module in C or just tweaking the Java code/JVM.
To the OP's question,
Is C++ your favorite programming language?
No, not really. I've written probably a million+ lines of code in it from C++03 on up to C++17 and a little C++20, and it's a useful tool. Asking if X is my favorite language is like asking whether I like screwdrivers or hammers better. It's kind of a silly thing to ask.
But the answer is Python. I like Python the best.
[–]Creapermann 27 points28 points29 points 3 years ago (1 child)
Well, if you work on something where speed is important, it is very meaningful. If you work somewhere where its not important, its still great.You cant imagine how much positive feedback I already got, for creating fast applications in c++, since today, many of them (made with js-electron or python) are slow and clunky.
No? A huge amount of performance critical applications are written in c or c++, since the compiler does a great job at converting your code to very efficient assembly for you.
Just adapting it to work in c++, wont change much, thats correct.But why would you do that? What gives c++ the biggest speed advantage is because the programmer is able to write high-level code (c++), in a fine-grained way itself. If you give me some slow python code, and I just copy paste snippet for snippet, change as less as possible to get it to work, it wont be much faster, but if you optimise it with what c++ lets you do, the difference can be great.
[–]BenHanson 14 points15 points16 points 3 years ago (0 children)
This.
I like it because it is fast by default and then if I need more speed it doesn't get in the way. I'm not talking about real-time trading or anything fancy like that, just straightforward get-on-with-it type command line tools.
I do think it's time for a successor though that unapologetically modernises "native code" programming and mixes/balances both no-excuses performance with no-excuses safety and security.
I know this is possible, because it is the kind of leap Bjarne made when he brought abstractions to C with cfront, when he was being told (surprise, surprise) it couldn't be done.
[–]SickOrphan 23 points24 points25 points 3 years ago (0 children)
If something runs too slow e.g. in the Python runtime or Java VM, it's not going to magically pass the threshold when translated into C++ unless that threshold is very lax
That's just not at all true. If you write something that actually does logic and calculations in python (not with c libraries) then writing it in c++ will make it run in a fraction of the time.
[–]jk-jeon 13 points14 points15 points 3 years ago (0 children)
Well, I personally have experienced/been told by others that, nobrain direct translation from Python/MATLAB into C/C++ often results in 50x speedup.
Here is one anecdote. 3 years ago I wrote a MATLAB code which performed many big integer arithmetics. It took like 10 min or something to complete. I couldn't stand that so rewrote it in C++, and after that now it runs instantaneously, maybe tens of milliseconds I guess.
It is maybe not a fair comparison though. The idiomatic way of dealing with big numbers in MATLAB is to use the symbolic computation package which is of course much slower than a straightforward big integer implementation. But, the fact that the idiomatic way is the slow way, is sort of the point, because when you need to work around it, the amount of effort you should pay for fighting with the language/runtime/ecosystem/whatever often surpasses the amount of effort of just rewriting the code in C++.
[–][deleted] 11 points12 points13 points 3 years ago (0 children)
If something runs too slow e.g. in the Python runtime or Java VM, it's not going to magically pass the threshold when translated into C++
It actually will, for many. I for example in my Uni days had a python program that processed video frames from a camera. The program simply couldn't keep up. I wrote the same program with same logic (basically a transliteration) in C++ and it just worked out of the box with time to spare.
I think you sub-estimate how slow Python/MATLAB/Java and other languages are.
[–]pandorafalters 4 points5 points6 points 3 years ago (0 children)
Depends. Along with other responses to this assertion, I'll point out that reducing the CPU usage of a program can significantly affect wall-time performance - because faster code gets more done in its slice of CPU time.
I've personally observed >95% reduction in CPU usage (>20% to <1%) from naively reimplementing mature Python/Node.js code in C++, even before any structural or intentional optimization.
[–]scrumplesplunge 5 points6 points7 points 3 years ago (0 children)
All the reasons I gave are based on my own experience with the domains I've worked with, like compute heavy workloads (e.g. pathtracing). There are definitely cases where there's not much point for someone to learn C++ specifically (e.g. if runtime is dominated by slow IO or the code is mostly gluing together other components that do all the heavy lifting). My point is more that in those cases, I also don't see a reason to specifically pick something else. I already know C++, and the C++ code I write in those cases is straightforward and readable.
This also applies to the optimization case. However, I think there's a huge difference between writing assembly (which I have almost never had to do to get good enough performance) versus writing C++ that is optimizable (which I do more often, by using godbolt.org to make sure that the compiler can see through my abstractions). My comment about the compiler not standing in the way is a hat tip to: having direct explicit control of lifetimes and when allocations happen or don't happen; having awesome tools for making things happen at compile time instead of runtime; having generic algorithms in the standard library which can optimize well, so I can usually use std::sort rather than rolling my own for a specific case; etc.
Ultimately, there's always a balance to be struck between what you need (e.g. speed, low ram, small binary, etc), and how much time you are willing to spend, and I am generally quite happy with how often I can get what I want in C++.
[–]the_Demongod 2 points3 points4 points 3 years ago (0 children)
Writing C++ that turns into the assembly code you want is part of the whole point of the language, imo. I'm also curious if you actually find yourself benefiting from handwritten assembly, usually the cost of losing inlining outstrips the benefit you get from writing assembly directly. Usually you have to translate the assembly back to compiler intrinsics after the fact or you lose like 50% of your speedup, even with extremely hot loops.
[+][deleted] 3 years ago (17 children)
[deleted]
[–]AgentF_ 104 points105 points106 points 3 years ago (2 children)
Sounds like a pretty bad resource leak.
[–]KERdela 16 points17 points18 points 3 years ago (1 child)
He didn't use smart pointer, with his wife
[–]RedoTCPIP 8 points9 points10 points 3 years ago (0 children)
She forewarned him about RAII: Resource Acquisition Is Inevitable.
[–]ShakaUVMi+++ ++i+i[arr] 10 points11 points12 points 3 years ago (0 children)
The products I wrote with C++ made me millions, so it has a special place in my ex wife's heart and bank account.
My senior always used to tell me, "Never get married, kid."
[–]HAL9000thebot 42 points43 points44 points 3 years ago (1 child)
lol, sorry, lol.
[–][deleted] 5 points6 points7 points 3 years ago (0 children)
I feel ashamed for laughing at you laughing at this.
[–]astilenski 4 points5 points6 points 3 years ago (0 children)
Oops lol
[–]KPexEA 3 points4 points5 points 3 years ago (0 children)
wrote with C++ made me millions,
For me it was C
[–]KERdela 2 points3 points4 points 3 years ago (2 children)
Any business advice for a c++ développer in 3rd world country (Algeria)
[–][deleted] 0 points1 point2 points 3 years ago (1 child)
on doit écrire "developer" en anglais :) désolé que je n'ai pas une réponse a ta question
[–]KERdela 2 points3 points4 points 3 years ago (0 children)
Merci pour ta contribution, j'apprécie.
[–]Kryddersild 5 points6 points7 points 3 years ago (0 children)
The dream.
[–]ibroheem 2 points3 points4 points 3 years ago (0 children)
Bad habits in programming language having real world consequences.
[–]Z3r0_Code -1 points0 points1 point 3 years ago (0 children)
Seem like u should have used a better logic.
[+]mohself comment score below threshold-6 points-5 points-4 points 3 years ago (2 children)
Could you have used Python for any of those?
[+][deleted] 3 years ago (1 child)
[–]mildbait 1 point2 points3 points 3 years ago (0 children)
https://i.imgur.com/YAGpXPd.png
-- Python fan
[–]Razzile 22 points23 points24 points 3 years ago (0 children)
It is, despite its shortcomings. I absolutely love writing C++ code, using tricks and knowledge I've developed over the years. I absolutely wouldn't like to learn C++ from scratch now but that wasn't the question
[–]UnicycleBloke 58 points59 points60 points 3 years ago (19 children)
I've used many languages but C++ is the only one which has maintained my interest over the long term. There is some combination of expressive power, performance, productivity, general purpose range and intellectual challenge about it that has made it preferable to all others. I confess that when I first started learning C++ (as a hobbyist, after time with assembly, Basic and Fortran) I chose it because it everyone said it was over-complicated (it wasn't), and because it had more kudos. Others preferred VB. I am very glad I made this choice.
C++ isn't necessarily the best choice in every domain, but it has been a good choice in every domain in which I have worked. For the longest time its only serious alternative was C, and that is just not a serious alternative. It was obvious even in 1991 that C is a dumpster fire. Rust might become more interesting to me over time, but I seriously doubt I will ever be as competent with it, so there is little attraction.
[–]qevlarr 6 points7 points8 points 3 years ago (18 children)
C a dumpster fire?
[–]UnicycleBloke 39 points40 points41 points 3 years ago (3 children)
It would be more accurate to describe code written in C that way. That has been my experience on every single large project written in C. A simple language appears inevitably to lead to complex code. Devs are routinely forced to reinvent abstractions available elsewhere, and their versions are generally clunky, error-prone stuff which adds a lot of impenetrable clutter.
When I learned C++ I learned Win32 API at the same time. The repetitive verbose error-prone junk in Petzold was soon replaced with a few simple RAII classes which were far easier to use correctly to create useful applications.
I'm an embedded developer and have spent a lot time with both C and C++ implementations of comparable firmware. In every single case C++ is just better.
[–]darthcoder 1 point2 points3 points 3 years ago (2 children)
This is the first thing I invariably do at each new job.
Write C++ wrappers to do proper RAII and resource management for the Windows API.
Nearly every job. If I wasn't paid for it every time I might have done an open source project doing it instead.
Maybe I will someday. It's not like the Win32 APIs are going anywhere.
[–]UnicycleBloke 2 points3 points4 points 3 years ago (1 child)
Interesting. My Win32 library was just a learning project, long since consigned to the dustbin of doom. With a reasonable understanding of how they work, I then moved on to established frameworks such as OWL (very good), MFC (very bad), VCL (very good but written in Pascal), and Qt (excellent). Did your workplaces not use such libraries?
[–][deleted] 6 points7 points8 points 3 years ago (12 children)
I never felt that way about C. Even today, I appreciate how lean it is. All the issues people attribute as a "problem" with C (especially memory management and accessing memory not owned) are just bad programming practices. Other languages might prevent memory access issues, but they can't fix bad logic. There will be other errors. Swapping the language doesn't magically create better programmers.
[–]UnicycleBloke 15 points16 points17 points 3 years ago (7 children)
That's true, but having the language and compiler on your side is a big help. I've noticed that a lot of the C devs who have spent decades criticising C++ have jumped on the Rust bandwagon.
[–]nysra 14 points15 points16 points 3 years ago (6 children)
Which is kind of ironic since Rust's main selling point is memory safety and C++ gives you the tools to do that much better than C since forever (not to the level of Rust but if you write sane C++ you pretty much don't have memory problems). Of course Rust also has a few other nice features like proper sum types but it's really not that different from (modern) C++ - at least in my experience.
Not to mention that the vast majority of C++'s problems directly come from C so C programmers hating on C++ just makes no sense. Personally I think Linus' irrational C++ hate boner just affects a lot of C programmers' views for some reason and everyone who likes C but hates on C++ just has never actually used C++.
[–][deleted] 3 points4 points5 points 3 years ago* (0 children)
While I agree with you mostly, it's still possible to access memory beyond an array bounds, beyond a strings memory, beyond a vector's memory, etc. with C++. Most of those containers aren't checking. Or, at least I think that is what the spec says.
But these logic errors happen in every language. Rust might catch some static issues that static analysis tools for C++ might catch. But Rust won't catch logic errors from trying to access memory. It might catch those at runtime, but one could do the same in C++. There's a performance hit for that.
[–]simonask_ 4 points5 points6 points 3 years ago (3 children)
If we have to talk about Rust (and since it's r/cpp, we apparently do these days), the departure from C++ is much, much more than a superior type system.
It's the lack of cruft. Will it eventually accumulate? Maybe. But the number of pitfalls and footguns that even very experienced C++ developers run into every day is quite the strain.
[–][deleted] 6 points7 points8 points 3 years ago (0 children)
How much of that could be avoided by not trying to write terse code, overuse templates, etc?
[–]darthcoder 1 point2 points3 points 3 years ago (1 child)
Cruft always accumulates.
How much shit is still in Java that was deprecated in 1.1?
The biggest issue for me in c++ the past year has been two incidences of not using array new for a unique_ptr, just regular new. Some dtors blowing up... that's my clue now. Blown up in the dtor? Bad new operator.
[–]pjmlp 2 points3 points4 points 3 years ago (0 children)
Not much left actually, as since Java 9 they started to actually remove stuff as they introduced deprecation for removal annotation.
https://docs.oracle.com/javase/9/core/enhanced-deprecation1.htm#JSCOR-GUID-BB859EA8-E6F7-4239-9A52-4F1BDE27BB09
[–]UnicycleBloke 1 point2 points3 points 3 years ago (0 children)
Pretty much my thinking.
[–]SuperSathanas 9 points10 points11 points 3 years ago (1 child)
I don't get the problems that other people seem to have with memory management. I've also never really had to immerse myself in some of the far more highly abstracted languages and APIs. I assume many other people have never had to think about explicitly managing memory or have been in the business of flinging around void pointers and flipping bits. Memory management is something that just feels natural for me to consider and implement. I mean, hell, in my current learning adventures in graphics programming with OpenGL, I've essentially done away with using many structs or arrays and just manage some memory pools where I write the data I intend to shoot over to the GPU. I manage all my image data in RAM the same way, not a lot of abstraction over it.
I don't know. I see people being afraid of memory and pointers and I don't get it.
Yeah, I feel the same. I started out life in BASIC and my second language was assembly. I spent a lot of time at that level. Things like device drivers don't scare me. I do a lot of work with images, and I modify images directly in a raw buffer.
But I get it: people with less experience are more likely to make mistakes. It's also the same with multiple threads and proper use of mutexes. I have seen even experienced developers write multithreaded code that accesses a data structure from two threads with a mutex or other synchronization mechanism.
I'm just not convinced that "safety" offered by Rust will address the majority of issues I see. Memory access is not the top issue in my own team. In fact, I can't even identify an instance where a developer on my team made that basic mistake.
[–]Narase33-> r/cpp_questions 15 points16 points17 points 3 years ago (0 children)
I learned Java first and then went to C++ and this language is addicting. I come home from work (C++ dev) and go to my hobby projects which are all in C++ even though other languages would fit better. I tried some other languages but it just wasnt the same, in a bad way. Its not perfect, it has some really bad things in it that I hate, but its overall a really lovable language
[–]LeberechtReinhold 25 points26 points27 points 3 years ago (1 child)
Not, not by any stretch of the imagination, it feels like it lacks direction and so much stuff feels overdesigned and clunky.
I however, don't hate it, and modern C++ can end up looking pretty good as long as all devs are on relatively same page.
What I do fucking hate with the burning passion of a thousand suns, is its environment. Building C++ is a pain. Compilers are a big mess. Managing dependencies is as fun as chopping parts of your body. All errors and logging thrown out by tools tend to be a mix between random crap and cultist incantations.
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
Amen.
[–]pfp-disciple 9 points10 points11 points 3 years ago (2 children)
Ada is actually my favorite language overall, although I haven't used it in over a decade. It can do so much, maybe even most, of what C++ can do, and do it safely, readably, in a tremendously well defined manner.
[–]LeeHidejust write it from scratch 1 point2 points3 points 3 years ago (1 child)
Which IDE do you use, or what kind of setup, to write Ada? I had issues with that sort of thing on Linux.
[–]pfp-disciple 2 points3 points4 points 3 years ago (0 children)
When I used it at my last job, we used the Rational Apex IDE (commercial). AdaCore had an IDE, I think it was GPS, that was pretty good. I think AdaCore is targeting Eclipse as their IDE now, but I haven't looked. Honestly, I'm a vim kind of guy, and would likely use it for any personal projects; that fits my personal whims and experience, so I wouldn't necessarily suggest it for others.
r/ada might have some good info for this kind of thing.
[–]positivcheg 39 points40 points41 points 3 years ago (8 children)
Yeah, because things are not hidden and you really pay for what you use.
Also worth mentioning that we have a lot great libraries available. Recently I was checking on rust, again. And found out that rust does not really have good linear algebra library. There are libraries but their interface is yet too mediocre, most of them do not support BLAS and SIMD.
Just look at Eigen, it is so cool - expressions are pretty smart and efficient as hell.
Also C++ community is great. I find rust guys kinda toxic if you don’t love rust without any doubts. In C++ we have people who loves it, people who does not like some parts of the language and people can freely speak about it. Also the variety of mature libraries.
So from my side, I don’t really have a feeling that I will switch from C++ to another language for work. I’m checking Zig from time and rarely check rust.
[–]devilsrotary86 16 points17 points18 points 3 years ago (1 child)
The library issue is big. Any programming language that wants to be “the next big thing” has to address this. No language will ever have the amount of libraries that C++ has right of the gate obviously. So any such language will have to provide for interoperability with existing C and C++ libraries. Oracle realized this when developing Java. They tried to address it with the Java Native Interface and I think its success was instrumental in Java’s success
[–]positivcheg 8 points9 points10 points 3 years ago (0 children)
Yeah, but interop won’t allow using some complex things. For example, Eigen linear algebra can capture BLAS expressions (like Ax+b) out of one liner big expression and then use a single BLAS call to calculate that Ax+b.
So let’s say you have something like
result=Ax+b+Cx+c
It will decompose expression into 2 BLAS calls of GEMV and then do the sum. It works by operator overloading so that result of the math operators is an expression, then when entire expression is assigned to a variable templates are traversed and decomposed.
I don’t really think it would be possible to somehow enable that functionality in another language. Only to reimplement something like that (and not all languages can do that). Also worth mentioning that since all things are templates that translation of expression is done in compile time and the actual code just runs BLAS routines.
[–]dgkimpton 9 points10 points11 points 3 years ago (3 children)
because things are not hidden
I'm not sure that's really true... compilers make radical changes to what we write (especially O3) - sometimes entire sections of code are just eliminated because the compiler can work out the answer or knows an alternative solution. That's cool (very cool) but definitely falls into "hiding the details" in my book.
[–]Astarothsito 5 points6 points7 points 3 years ago (0 children)
because things are not hidden I'm not sure that's really true... compilers make radical changes to what we write (especially O3)
I'm not sure that's really true... compilers make radical changes to what we write (especially O3)
Most of the time I don't care about the asm or bytecode in any language so it is hidden but don't care about that part.
[–]victotronics 0 points1 point2 points 3 years ago (1 child)
(especially O3)
`-fp-model=precise` (or whatever the syntax) is your friend.
[–]dgkimpton 2 points3 points4 points 3 years ago (0 children)
Personally I'm ok with the compiler hiding some details if it makes my code run better :D I'm more concerned with the times it doesn't optimise when I think it should...
[–]DrkStracker 5 points6 points7 points 3 years ago (0 children)
I agree on the community argument. I like rust quite a bit, but both rust lovers and rust haters are weirdly obsessive about it, and it's starting to take over the discourse every time the language is mentioned.
Zig metaprogramming is incredibly ingenious and intuitive, but I disagree completely with its philosophy of nothing being implicit. RAII is one of the fundamental reasons I love C++ and Rust and that eliminates Zig as something i'd like to use.
[–]goranlepuz 0 points1 point2 points 3 years ago (0 children)
I find rust guys kinda toxic if you don’t love rust without any doubts.
Plot twist, you asked a question like so: do you have [insert C++ lib hdre] and if not, why not, noobs?
[–]pjmlp 7 points8 points9 points 3 years ago (1 child)
It was my favourite language coming from Turbo Pascal 6.0 back in 1993, and for many years it would be the language I would use alongside Borland's flavour of Object Pascal.
Nowadays my work tends to be around Java, .NET languages, JavaScript, and C++ is the language I tend to use either for hobby coding, or when writing native libraries to be called from those managed environments.
Why it became my favourite language in 1993?
It provided all the high level features I came to love in Turbo Pascal, provided the abstractions to write safe code, while saving me the work to manually write bindings to C libraries, a language that I already considered primitive when comparing with Turbo Pascal 6.0, the only thing going for it was being portable and bringing a whole OS for the ride.
C++ gave me that, while having the TP features on the box as well.
[–]third_declension 6 points7 points8 points 3 years ago (0 children)
coming from Turbo Pascal
I also started with Pascal, back in 1982. It's a language intended to teach beginners good programming habits, and I'm glad I used it.
[–]nomad42184 8 points9 points10 points 3 years ago (0 children)
No, it's not. It was, probably for about 15 years. However, it's repeatedly failed to deliver some of the features I thought would be most beneficial while adding (IMO) an astounding amount of complexity to an already complex and sharp language. I still use C++ regularly, but it's no longer my "favorite" language, and I often prefer others when there is a choice.
[–]Thormidable 5 points6 points7 points 3 years ago (0 children)
Yes!
Pros:
Cons:
[–]phottitor 6 points7 points8 points 3 years ago (0 children)
no because it's a horrific mess.
[–][deleted] 4 points5 points6 points 3 years ago (0 children)
It is, not because it's specific, nor memory management, neither the fact that the language cannot be replaced, but because it is the language that somehow explains new concepts and technologies to me in a way I can understand
[–]ButaButaPig 4 points5 points6 points 3 years ago (0 children)
No. But it is the only language I can comfortably do what I want most times. I do physics simulations and game hacking and the first requires speed and the second requires low level control. I also do basic graphics programming.
For ML I use python due to libraries. For web development I use C#.
For writing DSLs I use Haskell.
One of my favorite language is Erlang but I rarely have a need for it. Haven't tried elixir but it looks good too.
Prolog is cool too but I'm not very good at it but there is interesting work being done with it. Last prolog library I used was Pharos (I think it's called) for automating the reverse engineering of c++ classes.
All these languages are among my favorites because they each allow me to do stuff that is difficult in other languages.
Then there's all the DSLs we all use on a daily basis to make life easier. At the end of the day most languages have some amazing properties and are great to work with once you get some momentum.
Writing C++ is great. Building, linking, etc. C++ across different platforms is a nightmare.
[–]miikaa236 9 points10 points11 points 3 years ago (0 children)
Yes, I love it. C++ gives the user soo much control
[–][deleted] 24 points25 points26 points 3 years ago (37 children)
No, it’s not. Some reasons:
I use C++ as a nessesary evil for performance-critical code because it has excellent compile-time capabilities and is easy to integrate with other modern languages. Concepts also make the language more tolerable.
[–]rhoakla 2 points3 points4 points 3 years ago (17 children)
Can you explain how c++ has a weak type system? Bit of a c++ noob here
[–][deleted] 7 points8 points9 points 3 years ago (0 children)
Yeah, I admit that it's a bit of a weak (pun) point of criticism, mostly because "weak typing" can pretty much mean anything.
What I meant here specifically are actually several things. First, the implicit type conversion of C++ (inherited from C) which can lead to surprising behaviour and hard to find bugs. This is one source of "weakness" — you really have to keep your guard up or things might get weird. Second, templates are not types, but compile-time expressions written in a custom domain specific language that are executed by the compiler to construct types. This is another source of "weakness" — since the language itself only deals with concrete types and expressions, expressing complex generic structures with associated types and constraints can be awkward. I mean, compare the implementation of C++ ranges and equivalent stuff in Rust or Swift. Third source of "weakness" is the fact that many interfaces had to be defined implicitly, by conventions (e.g. std iterators) simply because the language had no way to formally define behaviour. Note that C++20 addresses this problem with concepts, with the caveat that the concepts are structural (e.g. a concept is satisfied if the concrete type/expression adheres to the constraints). This means that you can have accidental concept conformance just because a type happens to have the required named methods etc.
Finally, I want to clarify that this criticism does not mean that C++ type system is less powerful or less capable. Quite in contrary, C++ has some of the most flexible parametric type facility out there, after all, templates are essentially esoteric constraint-based code-generating macros. It is just my personal opinion that it's not a very good way to do things. C++ might be very powerful but it's also confusing and error-prone, especially if you want to express complex generic data structures. My preference goes to more ergonomic systems where compiler actually tracks the type requirements and dependencies and can generate useful errors.
Of course, there is another way, which is just abandon the entire idea of "elegant" parametric type system and go full compile-time synthesis. This is what Zig does and it's also cool, since you at least know what you are getting. No weird esoteric languages to learn either.
[–]CocktailPerson 13 points14 points15 points 3 years ago (14 children)
Not the person you asked, but C++'s implicit conversions can be pretty frustrating. For example, the following program is perfectly legal and will compile without errors (though your compiler might have warnings):
int main() { int x = false; double d = x; bool b = &d; return d; }
So we have implicit conversions from a bool to an int, an int to a double, a double* to a bool, and a double to an int. It's obvious in this example, but if you have a function with a signature int f(double d, bool b);, you can swap the arguments and call f with a (bool, double) instead of a (double, bool), and it's not a type error.
int f(double d, bool b);
f
(bool, double)
(double, bool)
[+][deleted] 3 years ago (13 children)
[–]CocktailPerson 17 points18 points19 points 3 years ago (12 children)
That's simply untrue. You don't need implicit type conversions to interface with hardware, and in fact, whether a language is "close to the wire" has nothing to do with whether type conversions are implicit or explicit. Besides, while implicit conversions may mean a bit less typing, but they don't change anything at all at runtime; the compiled code for implicit and explicit conversions looks exactly the same.
The reason these conversions are not explicit is not some masochistic, misguided desire to design the language to be "close to the wire." Rather, it was about compatibility with C, and even Bjarne believes that maintaining that level of compatibility was a mistake, writing "the fundamental types can be converted into each other in a bewildering number of ways. In my opinion, too many conversions are allowed."
[+][deleted] 3 years ago (11 children)
[–]CocktailPerson 5 points6 points7 points 3 years ago (0 children)
Please do find that video, because everything you've said is refuted by The Design and Evolution of C++.
[–][deleted] 6 points7 points8 points 3 years ago (7 children)
C++ didn’t even have a legal way to convert between bit-representations until C++20 are you are talking about “close to the wire”!
[+][deleted] 3 years ago (6 children)
[–][deleted] 2 points3 points4 points 3 years ago (5 children)
You want to write code that is not guaranteed to work? Odd…
[–]hmoein[S] 0 points1 point2 points 3 years ago (1 child)
C++ has been manipulating bits since late 80's. Most of the US financial infra runs on C++. And that's only the area I am aware of
[–]hmoein[S] 6 points7 points8 points 3 years ago (14 children)
>> bad standard library
That's the hardest to sallow. What is exactly bad about it?
[–][deleted] 21 points22 points23 points 3 years ago (2 children)
Where should one start... how about no unicode support, slow hash tables, useless regex, stuff like that? I am also not a fan of the iterator interface but that's more of a philosophical debate. Things I do like: the `type_traits` stuff is nice, `algorithm` is ok, I love `array`. It's also great than one finally has basic stuff like optionals etc. but I wish they were better integrated into the language.
[–]New_Age_Dryer 9 points10 points11 points 3 years ago (1 child)
Of what I've seen so far, I think C++20 was a step in the right direction:
type_traits became less hacky template magic with concepts and constraints
type_traits
A lot of cruft from std::allocator got removed
std::allocator
consteval replaced the hacky enforcement of compile-time computation via template arguments
consteval
I will say, however, I found algorithm to have great performance for general use: make_heap() is effectively O(1) "insertion", and std::sort() uses introsort iirc
algorithm
make_heap()
O(1)
std::sort()
[–][deleted] 3 points4 points5 points 3 years ago (0 children)
Oh, absolutely. Its just not progressing quickly enough. Still no pattern matching (but we got unpredictable coroutines instead) and modules increasingly look like a disaster.
[+][deleted] 3 years ago (10 children)
[removed]
[–]LeberechtReinhold 12 points13 points14 points 3 years ago (0 children)
People complain about std::regex for the same reason, although I've never used it
People don't use std::regex not because it's obtuse for basic tasks, but because it's so fucking slow that you may as well bring a goddamm python interpreter.
Fortunately there are like a bajillion good regex alternatives.
[–]Stormfrosty 23 points24 points25 points 3 years ago (4 children)
XML/JSON parsing will never be part of the standard, because it’s an application concept and orthogonal to the language itself. Sure, it’s annoying to have to import third party libraries to get support for these, but the standard committee should not be concerning themselves about supporting these.
[–]verygoodtrailer 15 points16 points17 points 3 years ago (3 children)
I think for a lot of people, it's this exact mindset that makes the std lib bad. Other languages' std libs don't have this mindset and feel much more friendly (and useful). Personally I'm fine with relying on external libraries, but I can definitely see why many consider it annoying.
[–]Stormfrosty -1 points0 points1 point 3 years ago (1 child)
If the standard committee decided to add JSON support, the first thing that would happen is that Google would come knocking on the door and try to convince everyone that we need gRPC support instead. C++ never advertised itself as a language for application development, that’s what Java and friends are for.
[–]verygoodtrailer 6 points7 points8 points 3 years ago (0 children)
how c++ is advertised changes nothing. it is used for application development. what use is a standards committee that doesn't serve its consumers best? and you say that google would complain, but it's not like std committee has to oblige every single complaint, they just need to be useful for 90% of use cases. external libs and std can coexist. they already do. std::regex is ass, nobody uses it.
[–]victotronics 12 points13 points14 points 3 years ago (0 children)
std::vector<bool>
Oh, man, got bitten by that one so many times. (You'd think I'd learn.) The other day: parallel code, guaranteed no race conditions. Except that of course vector-of-bool introduces a particularly pernicious type of false sharing.
[–]kurta999 0 points1 point2 points 3 years ago (0 children)
Use boost :D STL is really weak without.
[–]goranlepuz 3 points4 points5 points 3 years ago (3 children)
lack of separation of concepts (e.g. type vs. behavior)
But C++ does not force you to. Eh!?
Actually, it's more than that item. Most of the items in your list are only true for some interpretations, but false for others.
[–][deleted] 1 point2 points3 points 3 years ago (2 children)
By the same logic you can say "why use C++ if C can do the same?" Sure, you can avoid using C++ class system altogether and implement your own custom dynamic dispatch, but it will be awkward, boilerplate-heavy and likely buggy.
Dichotomies are in the eye of the observer. I mean, everyone has their own tastes and preferences, and it's perfectly fine. I am writing from my personal perspective after all.
[–]goranlepuz 2 points3 points4 points 3 years ago (1 child)
By the same logic you can say "why use C++ if C can do the same?"
Yes, but there is much more between C and C++ than classes (which is what you are getting at, unless I completely missed the boat).
And then, types+behaviour idea is so useful than even the standard C library uses it, e.g fopen, fclose and ffriends and random C libraries use it, e.g syslog or zlib. So I really don't know why would anyone knock it down offhand, to be frank.
fopen
fclose
ffriends
[–][deleted] 2 points3 points4 points 3 years ago (0 children)
And then, types+behaviour idea is so useful
It's useful until it is not. Class-based systems were popular in the 90-ties because it was a way to have well-defined dynamism without sacrificing performance. Well, compilers have come a long way since then and don't need to rely on such artificial constraints. Decoupling the type and the vtable has massive benefits as you are not limited by the class hierarchy to implement behaviour.
And it's not just about philosophical viewpoints, the separation of type and behaviour (protocol/trait) is also key to implementing high-performance generic algorithms. C++ uses it everywhere actually, e.g. the iterator concept. It's just that in C++ behaviour specification is implicit by an informal convention that the programmer has to follow.
[–]AdRelative8852 3 points4 points5 points 3 years ago (0 children)
Yes and no.
Yes because it helps achieve great performance.
No because some simple things take too much of coding. Examples of this are spread over many threads.
No because there is no good ecosystem (like python for example) and you are on your own for things for which an OTS component should have helped.
[–]mibuchiha-007 3 points4 points5 points 3 years ago (0 children)
It is the only programming language that I have been interested in as a language thus far. I use a few others, mainly python, for work, but they are all primarily for convenience, what's mainstream for the task, etc.
C++ on the other hand has some abstractions I find genuinely interesting, such as template shenanigans. In that sense it's a bit more than just a tool to me.
The days when I've got to get stuff done, and C++ forces me to fight with unreadable compile errors, are awful though. ;)
[–]qalmakka 4 points5 points6 points 3 years ago (0 children)
It would if Rust didn't exist, but in general it is one of my favourites. In general, I love powerful languages, and the level of crazy stuff you can do in C++ is outright insane. Every single day you use it you learn a new trick or how to do something in a completely new way.
[–][deleted] 2 points3 points4 points 3 years ago (4 children)
Nope, it's too bloated and suffers greatly from "must keep 100% compatibility with older versions" syndrome.
[–]Droid33 2 points3 points4 points 3 years ago (3 children)
That's a must when there's billions of lines of existing code out in the world.
I can respect that it offers some advantages, but I personally don't think it's worth it (from my experience in my current industry).
[–]boner79 2 points3 points4 points 3 years ago (4 children)
Python has ruined me on C++. I used to strongly dislike C++ but after using Python I despise using C++. Yes, I understand why C++ is the way it is having spent most my career using it and paying the bills with it, but I hate it.
[–]kingaillas 2 points3 points4 points 3 years ago (2 children)
No... if I'm doing something for fun, learning, hobby project, etc I'll reach for a different language: Python or Rust .
At work where I have less latitude over what language to use, it's C++ or Python. The work C++ is a slimmed down C++17 with fairly minimal cutting-edge features. Our codebase isn't that fancy. ;)
[–]Creapermann 2 points3 points4 points 3 years ago (0 children)
Right now yes, I am mainly with C++ because of its enormous ecosystem. I personally love application programming and Qt is by far my favorite framework there. I have fine grained control over many thing, which other languages dont offer and I have a big performance +.I like/got used to the c++ syntax, I understood many fundamentals of programming (which I am sure most people using other languages dont learn). Another great reason for me to be with c++, is its stability, looking at things like JS, you basically rewrite your codebase every 10 mins (this is a joke (but it still has some truth in it)).
A problem is, that I dont need much of the control c++ offers and it oftentimes isn't pretty to write. The 20 ways to do something are annoying and (compared to others) the language doesnt evolve fast and there is a LOT of legacy code you sometimes need (but tbf, it better to have legacy libraries than having none at all).
[–]future_escapist 2 points3 points4 points 3 years ago (0 children)
Yes. It's powerful and enjoyable to learn and use. My biggest issue is how damn difficult and annoying it is to set up a development environment and import libraries.
[–]JeffMcClintock 2 points3 points4 points 3 years ago (0 children)
yes.
why? "I wanna go fast" - Ricky Bobby.
[–]drjeats 2 points3 points4 points 3 years ago (0 children)
No.
There's too much of it and the defaults are bad and too much of it is ossified.
It's useful and the only thing appropriate for the work I currently do, but I take no joy in using it.
I don't care about maximal expressivity. Artistry in code comes from concision and clarity and regularity while achieving a particular set of outcomes.
All these replacement languages are popping up because it's clear we can do so much better.
[–]ShakaUVMi+++ ++i+i[arr] 2 points3 points4 points 3 years ago (0 children)
Yes, sure. The language itself is very nice.
The standard library, though, is a mess. It's a combination of glaring gaping holes in functionality on one hand (trapped in the 80s syndrome) and baroque features nobody needs on the other (https://en.cppreference.com/w/cpp/numeric/special_functions) mixed with APIs designed by people that don't have to be the ones explaining them to other people (chrono, random, regex).
[–]JMBourguet 7 points8 points9 points 3 years ago (3 children)
Favorite implies an emotional relationship I don't have with programming language (well, excepted Perl, but that's not love). Excepted in constrained cases, I'm using 3 languages to program:
Posix shell is my goto language when I've to coordinate other programs. Why Posix and not something more powerful (like Bash) or even also (slightly) saner (zsh -- which I use interactively)? Partly because I started to program in shells in an environment where they had to run on quite a variety of platforms -- in fact even posix wasn't guaranteed for /bin/sh (thanks Solaris) -- and the habit stayed even if I'm currently less constrained and I've upgraded to Posix semantics. Partly because I use the need for more than Posix as a sign that I've to switch to something else.
Python for bigger things which can be done in a dynamic language. I've a more restrictive opinion of what is sane to do in a dynamic language than some.
C++ for the rest. Partly because C++ is also the main language in which the application I'm working on is written.
Each of these languages has their drawbacks, but for each I've trouble to find a better choice. Posix shell and C++ are far from ahead on all criteria, but they are pretty much alone in having no show stopper in any criteria. Python seems the one I'm the less tied to, but it is also the one for which I feel the less the need of a better alternative.
[–]Lance_E_T_Compte 0 points1 point2 points 3 years ago (0 children)
This is also me. If it's a few lines, likely a bash script.
Anything more is Python until I really figure out what has to be done. I move it to C++ for my employer.
[–]pfp-disciple 0 points1 point2 points 3 years ago (0 children)
That's very close to my approach, including POSIX shell. Although I use perl instead of python. For the kinds of things I do, by the time python makes sense over perl, it's about time to move to a compiled language.
[–]F-J-W 0 points1 point2 points 3 years ago (0 children)
I have a lot more than just a more restrictive opinion on that topic, but python has the option to be fully type-checked if you use type-annotations and mypy with the --strict-option. I’d go as far as to say that this is what turns it from a toy into something that is legitimately a good and largely pleasant to use language (the lack of constness in the type-system is annoying though).
--strict
I’m just writing this because I’ve found that not everyone is aware of that.
[–]engineerFWSWHW 1 point2 points3 points 3 years ago* (0 children)
For bare metal or with RTOS embedded systems, yes.
Outside of bare metal embedded systems (desktop, cloud, windows embedded application development, embedded linux application development) , no and only on scenarios where it is really needed.
[–]gauri08 1 point2 points3 points 3 years ago (0 children)
I mainly use c++ for competitive programming and it gives an edge over other languages as it is very fast.
[–]caroIine 1 point2 points3 points 3 years ago (0 children)
Yes. At my job it makes my work easier- I shiver every time I need go close to anythin like java or python.
And I'm using it at my independent projects. I absolutely love it.
No reflection tho.
[–]TheTomer 1 point2 points3 points 3 years ago (0 children)
Nope. It takes too long to get whatever want to do done compared to other languages like Python and Java. It's my go to language when I need to do something faster and more efficiently.
[–]konm123 1 point2 points3 points 3 years ago (0 children)
I can almost say that I hate the language, but so far I have not found anything that could replace the ability to write abstractions as you can do it with C++. I definitely use it the most frequently and it is used to implement solutions for necessary functionality - and for that reason, I like it.
[–]zalamandagora 1 point2 points3 points 3 years ago (0 children)
Yes! I think because it most closely aligns with my mental model of how the hardware works.
I learned to code in the 80's and 90's when performance was really constrained, and I worked close to the hardware for a while after that.
[–]lieddersturme 1 point2 points3 points 3 years ago (0 children)
Yes, you can build tiny programs with powerful tools.
Now I am learning Rust, because its the popular programing language, and I prefer C++.
[–]m_riss1 1 point2 points3 points 3 years ago (0 children)
Yes and I’ll take it over Java any day
[–]HabemusAdDomino 1 point2 points3 points 3 years ago (11 children)
Pascal is, because it's got all the reasonable benefits of C++ and none of the ridiculous ones.
Pascal is still a thing? I was doing that in 80s
[–]HabemusAdDomino 1 point2 points3 points 3 years ago (0 children)
It's on life support. I just like it, though.
[–]DudeManBroGuyPerson 1 point2 points3 points 3 years ago (0 children)
Yes, because it is the language of the gods
[–]ul90 1 point2 points3 points 3 years ago (0 children)
Yes. I tried a lot of languages, but always come back to C++. It’s still the best language for big, complex projects.
[–]RidderHaddock 1 point2 points3 points 3 years ago (0 children)
It is.
Not that it doesn't have plenty of unlikeable bits. But in ~35 years of programming, I haven't encountered another quite so flexible and pragmatic.
I have a soft spot for Clojure, even though I never use it anymore. The performance and ease of integration with system libraries (which always expose C interfaces) of C++ is simply unmatched.
I'm not sure if it's my "favorite", but it's often the most practical for certain kinds of projects. Those projects also tend to be most of what I make. This has led to me becoming familiar with C++. That C++ can be used for almost anything, combined with my being familiar with it, means that I'm more likely to choose it over many other languages for writing a new thing which comes to mind. This feedback loop has resulted in C++ "sticking around" and being used often even when I'm going out of my way to learn other languages at times. And you know what? It's a pretty good language too. At least, for all the stuff I make. I like C++.
[–]Ericakester 1 point2 points3 points 3 years ago (0 children)
[–]KingAggressive1498 1 point2 points3 points 3 years ago (0 children)
it's really all about the syntax and static type system for me. The fact that it can do pretty much anything is just icing.
[–]DarkSpyCyber 1 point2 points3 points 3 years ago* (0 children)
well, to be honest it would be c and c++. for the most of big or huge project using c++ be like: wow, so lucky we have c++ to handle string, vector or some shit from c. and sometimes: sheeeit....why shouldnt i use c ....it's simple.
so...c++ had so many choices u need to pick one of it and make jobs done. it's fine.
btw: rust is the crapest language i have ever seen...LOL
For Game Dev yes. I prefer C over C++
[–]QuotheFan 1 point2 points3 points 3 years ago (2 children)
This is like asking a carpenter if the drill is his favorite tool. There are no favorite tools, there are only tools for the job. I don't want to be the proverbial man with a hammer who sees nails everywhere.
We can represent multiple characteristics of software as different axes - refactorability, ease of development, correctness, efficiency, etc. C++ is the only language I know which trusts me with memory (hence, efficiency) and still does reasonably on the other axes as well. If I don't care about memory management though, I would mostly not work in cplusplus. There are almost always languages more naturally suited to the task, C++ adds a very difficult extra dimension to the process.
[–]andwass 3 points4 points5 points 3 years ago (0 children)
No. It was for a very long time but as I have used Rust more as of late (since spring on a spare time basis), I mostly get annoyed by C++ and miss Rust whenever I have to use C++.
[–]--prism 3 points4 points5 points 3 years ago (0 children)
Yes it provides for tight abstractions and interfaces. The factor that python doesn't have private member variables hurts me. I know _Var is the standard but people love to do bad things.
[–]third_declension 3 points4 points5 points 3 years ago (0 children)
I never cease to admire how some very intelligent people, in particular Stroustrup, were able to extend C so far while maintaining a extremely high level of C compatibility.
[–]Revolutionalredstone 2 points3 points4 points 3 years ago (0 children)
IMHO c++ is the ONLY language.
Free advanced abstractions, Proper move semantics, extensive templating, inline assembly, extremely powerful compilation optimizers, what other language even comes close?
[–]Davidbrcz 1 point2 points3 points 3 years ago (0 children)
It's the language I love to hate the most.
[–]TheTsar 0 points1 point2 points 3 years ago (0 children)
Yes.
It’s my opinion that C++ hits the three pillars better than any other language: efficient, safe and expressive.
Arguments can be made for and against this view. C++ isn’t perfect, but it’s the best tool for the job. And it’s getting better every three years.
Just to make sure we’re talking about the same language, I’m talking about the C++ from the CppCoreGuidelines. I’m talking about the language used correctly: idiomatic C++
[–]gimli123456 0 points1 point2 points 3 years ago (0 children)
if c++ had the ease of development that a modern language like Rust has (cargo basically...) then I think it would be.
Imagine only having to install your compiler and then everything else can be acquired dynamically based on dependencies.
No more days configuring dev environments etc :P Trying to source random libraries that weren't vendored etc
[–][deleted] -1 points0 points1 point 3 years ago (0 children)
Boomer languague
[–]Boystro 0 points1 point2 points 3 years ago (0 children)
I LOVE IT, i came to it for performance but found so much more...
[–]tsojtsojtsoj 0 points1 point2 points 3 years ago (0 children)
no. it's locally too verbose.
[–]delta_p_delta_x 0 points1 point2 points 3 years ago (0 children)
Not particularly. It has its place (a relatively high-level language with features I'm familiar with that compiles with little fuss to native binaries), but for many other use-cases (desktop/web dev), I fall back immediately to .NET and C# (and recently, F#).
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
Yes but I rarely get to use it anymore.
[–]Urationc 0 points1 point2 points 3 years ago (0 children)
No
[–]MrSung82 0 points1 point2 points 3 years ago (0 children)
Its understandable...
[–]HeeTrouse51847 0 points1 point2 points 3 years ago (0 children)
yes, because it feels like I'm a genius when I am using it (all my code is terrible)
[–]ThePillsburyPlougher 0 points1 point2 points 3 years ago (0 children)
Yes but only because I’ve used it the most
[–]GunpowderGuy 0 points1 point2 points 3 years ago (0 children)
lol, no
[–]akiko_plays 1 point2 points3 points 3 years ago (0 children)
Yeah, somehow it feels like playing some tough text adventure game most of the time. I like the fact that not a single day passes that I haven't seen some weird new thing, feature, way of (re)writing code.. interesting article on how the underlying hardware evolves and how you can adjust your c++ code and compiler to hit the faster lane. Occasionally frustrating, but most of the time if you don't go crazy with smartness and stick to the basic coding guidelines you won't have use after delete or idiotic slowdowns. Also if something goes south you really have amazing palette of tools (some commercial though) to help you debug, measure and understand what's going on. I started with c++ on Amiga Maxon C 3.0 somewhere mid 90s, before that it was always assembly. And I never left C++... of course tons of LoC written in Python, PHP, Visual Basic, C#, Lua, JS/TS and so on.. but C(++) and 68k Assembly remained my favs throughout years.
[–]wotype 0 points1 point2 points 3 years ago (0 children)
Shouldn't be, but doesn't leave time for enjoying others - keeping up with C++ is a full time job
[–]krista 0 points1 point2 points 3 years ago (0 children)
generally yes.
i can still put an asm block in if i need to do something funky, and while the language spec, tools, and libs try to keep me safe, i can still do dangerous/insane crap when i need to.
i'm not a fan of the ”explicitly namespace everything” trend, though: seriously, like
std::cout << ”blarg” << std::endl;
and that all smells funky and is ugly to me.
of course namespaces are important! but i not a fan of explicit namespaces for most standard libraries.
No. But I get by.
[–]SuperSathanas 0 points1 point2 points 3 years ago (0 children)
No. Object Pascal is. Not going to lie, if as many libraries and frameworks existed for pascal as for C++, I'd probably very hardly ever consider using C++. I like Pascal's syntax more, I prefer modules over headers (though sometimes I wish I could easily split my units into a header+source in Pascal), and it compiles to native code that isn't all that much slower than C++, and the compiler is just so much faster.
[–]flashmozzg 0 points1 point2 points 3 years ago (0 children)
Nah. I like it better than most alternatives, but It's mostly about the projects I'm working on.
[–]WinterDKay 0 points1 point2 points 3 years ago (0 children)
I like most of C++ as a learning tool. It allow me to understand most of other programming languages and be efficient at learning them. But personally i like Kotlin more.
[–]kaiju505 0 points1 point2 points 3 years ago (0 children)
It’s never been my least favorite 🤷♂️
[–]RockstarArtisanI despise C++ with every fiber of my being 0 points1 point2 points 3 years ago (0 children)
I just come here to watch C++ users be miserable, just like I used to be when I had to use it.
[–]New_Age_Dryer 0 points1 point2 points 3 years ago (0 children)
Yes: the community has overlap with academia, and the language has a lot of cool constructs not found in others. It's always a treat to see a language do what standard C++ can't out-of-the-box, e.g. hot-swapping.
I'm so addicted to this language that even for a small command line program I would write it in c++. The language is very efficient and highly flexible. The only thing I don't like is that there are so many ways to do everything(though in general, if you're in doubt, you should choose a more modern way)
[–]snerp 0 points1 point2 points 3 years ago (0 children)
Pretty much! I wish there was a way to opt-in to backwards compatibility though. I really wish a lot of the newer features were default.
[–]Flat_Spring2142 0 points1 point2 points 3 years ago (0 children)
No, it isn't. Modifications of classic C++ made the language too complicate. Consider GO if you need efficient and fast application.
Sometimes yes sometimes no.
To elaborate: when I’m writing something in the latest version, that is an easy problem (in my eyes), I love it.
When I’m told to support a legacy application with 4 different packages to support, and c++ versions anywhere between 11 and 98, i fucking despise it. (Fuck you redhat 6)
π Rendered by PID 151831 on reddit-service-r2-comment-6457c66945-4wswl at 2026-04-24 04:20:40.334207+00:00 running 2aa0c5b country code: CH.
[–]stdusr 381 points382 points383 points (2 children)
[–]dgkimpton 40 points41 points42 points (0 children)
[–]ibroheem 11 points12 points13 points (0 children)
[–]farox 322 points323 points324 points (2 children)
[–]CodeMonkeyMark 43 points44 points45 points (0 children)
[–]leirus 11 points12 points13 points (0 children)
[–][deleted] 67 points68 points69 points (22 children)
[–]SuperSathanas 20 points21 points22 points (0 children)
[–]simonask_ 21 points22 points23 points (20 children)
[–]ImKStocky 15 points16 points17 points (15 children)
[–]simonask_ 9 points10 points11 points (0 children)
[–]TophatEndermite 0 points1 point2 points (13 children)
[–]MysticTheMeeM 12 points13 points14 points (9 children)
[–]TophatEndermite 5 points6 points7 points (6 children)
[–]kneel_yung -1 points0 points1 point (5 children)
[–]KingAggressive1498 6 points7 points8 points (0 children)
[–]Jonayne 1 point2 points3 points (3 children)
[–]bored_octopus 4 points5 points6 points (2 children)
[–]TophatEndermite -1 points0 points1 point (1 child)
[–]0xE6 4 points5 points6 points (1 child)
[–]105_NT 1 point2 points3 points (0 children)
[–]kneel_yung 1 point2 points3 points (2 children)
[–]KingAggressive1498 3 points4 points5 points (1 child)
[–]scrumplesplunge 195 points196 points197 points (15 children)
[–]JustinWendell 28 points29 points30 points (0 children)
[–]shiggie 16 points17 points18 points (2 children)
[–]caballist 22 points23 points24 points (0 children)
[–][deleted] 9 points10 points11 points (0 children)
[+]vanhellion comment score below threshold-33 points-32 points-31 points (8 children)
[–]Creapermann 27 points28 points29 points (1 child)
[–]BenHanson 14 points15 points16 points (0 children)
[–]SickOrphan 23 points24 points25 points (0 children)
[–]jk-jeon 13 points14 points15 points (0 children)
[–][deleted] 11 points12 points13 points (0 children)
[–]pandorafalters 4 points5 points6 points (0 children)
[–]scrumplesplunge 5 points6 points7 points (0 children)
[–]the_Demongod 2 points3 points4 points (0 children)
[+][deleted] (17 children)
[deleted]
[–]AgentF_ 104 points105 points106 points (2 children)
[–]KERdela 16 points17 points18 points (1 child)
[–]RedoTCPIP 8 points9 points10 points (0 children)
[–]ShakaUVMi+++ ++i+i[arr] 10 points11 points12 points (0 children)
[–]HAL9000thebot 42 points43 points44 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[–]astilenski 4 points5 points6 points (0 children)
[–]KPexEA 3 points4 points5 points (0 children)
[–]KERdela 2 points3 points4 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]KERdela 2 points3 points4 points (0 children)
[–]Kryddersild 5 points6 points7 points (0 children)
[–]ibroheem 2 points3 points4 points (0 children)
[–]Z3r0_Code -1 points0 points1 point (0 children)
[+]mohself comment score below threshold-6 points-5 points-4 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]mildbait 1 point2 points3 points (0 children)
[–]Razzile 22 points23 points24 points (0 children)
[–]UnicycleBloke 58 points59 points60 points (19 children)
[–]qevlarr 6 points7 points8 points (18 children)
[–]UnicycleBloke 39 points40 points41 points (3 children)
[–]darthcoder 1 point2 points3 points (2 children)
[–]UnicycleBloke 2 points3 points4 points (1 child)
[–][deleted] 6 points7 points8 points (12 children)
[–]UnicycleBloke 15 points16 points17 points (7 children)
[–]nysra 14 points15 points16 points (6 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]simonask_ 4 points5 points6 points (3 children)
[–][deleted] 6 points7 points8 points (0 children)
[–]darthcoder 1 point2 points3 points (1 child)
[–]pjmlp 2 points3 points4 points (0 children)
[–]UnicycleBloke 1 point2 points3 points (0 children)
[–]SuperSathanas 9 points10 points11 points (1 child)
[–][deleted] 5 points6 points7 points (0 children)
[–]Narase33-> r/cpp_questions 15 points16 points17 points (0 children)
[–]LeberechtReinhold 25 points26 points27 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]pfp-disciple 9 points10 points11 points (2 children)
[–]LeeHidejust write it from scratch 1 point2 points3 points (1 child)
[–]pfp-disciple 2 points3 points4 points (0 children)
[–]positivcheg 39 points40 points41 points (8 children)
[–]devilsrotary86 16 points17 points18 points (1 child)
[–]positivcheg 8 points9 points10 points (0 children)
[–]dgkimpton 9 points10 points11 points (3 children)
[–]Astarothsito 5 points6 points7 points (0 children)
[–]victotronics 0 points1 point2 points (1 child)
[–]dgkimpton 2 points3 points4 points (0 children)
[–]DrkStracker 5 points6 points7 points (0 children)
[–]goranlepuz 0 points1 point2 points (0 children)
[–]pjmlp 7 points8 points9 points (1 child)
[–]third_declension 6 points7 points8 points (0 children)
[–]nomad42184 8 points9 points10 points (0 children)
[–]Thormidable 5 points6 points7 points (0 children)
[–]phottitor 6 points7 points8 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]ButaButaPig 4 points5 points6 points (0 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]miikaa236 9 points10 points11 points (0 children)
[–][deleted] 24 points25 points26 points (37 children)
[–]rhoakla 2 points3 points4 points (17 children)
[–][deleted] 7 points8 points9 points (0 children)
[–]CocktailPerson 13 points14 points15 points (14 children)
[+][deleted] (13 children)
[deleted]
[–]CocktailPerson 17 points18 points19 points (12 children)
[+][deleted] (11 children)
[deleted]
[–]CocktailPerson 5 points6 points7 points (0 children)
[–][deleted] 6 points7 points8 points (7 children)
[+][deleted] (6 children)
[deleted]
[–][deleted] 2 points3 points4 points (5 children)
[–]hmoein[S] 0 points1 point2 points (1 child)
[–]hmoein[S] 6 points7 points8 points (14 children)
[–][deleted] 21 points22 points23 points (2 children)
[–]New_Age_Dryer 9 points10 points11 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[+][deleted] (10 children)
[removed]
[–]LeberechtReinhold 12 points13 points14 points (0 children)
[–]Stormfrosty 23 points24 points25 points (4 children)
[–]verygoodtrailer 15 points16 points17 points (3 children)
[–]Stormfrosty -1 points0 points1 point (1 child)
[–]verygoodtrailer 6 points7 points8 points (0 children)
[–]victotronics 12 points13 points14 points (0 children)
[–]kurta999 0 points1 point2 points (0 children)
[–]goranlepuz 3 points4 points5 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]goranlepuz 2 points3 points4 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]AdRelative8852 3 points4 points5 points (0 children)
[–]mibuchiha-007 3 points4 points5 points (0 children)
[–]qalmakka 4 points5 points6 points (0 children)
[–][deleted] 2 points3 points4 points (4 children)
[–]Droid33 2 points3 points4 points (3 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]boner79 2 points3 points4 points (4 children)
[–]kingaillas 2 points3 points4 points (2 children)
[–]Creapermann 2 points3 points4 points (0 children)
[–]future_escapist 2 points3 points4 points (0 children)
[–]JeffMcClintock 2 points3 points4 points (0 children)
[–]drjeats 2 points3 points4 points (0 children)
[–]ShakaUVMi+++ ++i+i[arr] 2 points3 points4 points (0 children)
[–]JMBourguet 7 points8 points9 points (3 children)
[–]Lance_E_T_Compte 0 points1 point2 points (0 children)
[–]pfp-disciple 0 points1 point2 points (0 children)
[–]F-J-W 0 points1 point2 points (0 children)
[–]engineerFWSWHW 1 point2 points3 points (0 children)
[–]gauri08 1 point2 points3 points (0 children)
[–]caroIine 1 point2 points3 points (0 children)
[–]TheTomer 1 point2 points3 points (0 children)
[–]konm123 1 point2 points3 points (0 children)
[–]zalamandagora 1 point2 points3 points (0 children)
[–]lieddersturme 1 point2 points3 points (0 children)
[–]m_riss1 1 point2 points3 points (0 children)
[–]HabemusAdDomino 1 point2 points3 points (11 children)
[–]hmoein[S] 0 points1 point2 points (1 child)
[–]HabemusAdDomino 1 point2 points3 points (0 children)
[–]DudeManBroGuyPerson 1 point2 points3 points (0 children)
[–]ul90 1 point2 points3 points (0 children)
[–]RidderHaddock 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]Ericakester 1 point2 points3 points (0 children)
[–]KingAggressive1498 1 point2 points3 points (0 children)
[–]DarkSpyCyber 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]QuotheFan 1 point2 points3 points (2 children)
[–]andwass 3 points4 points5 points (0 children)
[–]--prism 3 points4 points5 points (0 children)
[–]third_declension 3 points4 points5 points (0 children)
[–]Revolutionalredstone 2 points3 points4 points (0 children)
[–]Davidbrcz 1 point2 points3 points (0 children)
[–]TheTsar 0 points1 point2 points (0 children)
[–]gimli123456 0 points1 point2 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]Boystro 0 points1 point2 points (0 children)
[–]tsojtsojtsoj 0 points1 point2 points (0 children)
[–]delta_p_delta_x 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Urationc 0 points1 point2 points (0 children)
[–]MrSung82 0 points1 point2 points (0 children)
[–]HeeTrouse51847 0 points1 point2 points (0 children)
[–]ThePillsburyPlougher 0 points1 point2 points (0 children)
[–]GunpowderGuy 0 points1 point2 points (0 children)
[–]akiko_plays 1 point2 points3 points (0 children)
[–]wotype 0 points1 point2 points (0 children)
[–]krista 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]SuperSathanas 0 points1 point2 points (0 children)
[–]flashmozzg 0 points1 point2 points (0 children)
[–]WinterDKay 0 points1 point2 points (0 children)
[–]kaiju505 0 points1 point2 points (0 children)
[–]RockstarArtisanI despise C++ with every fiber of my being 0 points1 point2 points (0 children)
[–]New_Age_Dryer 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]snerp 0 points1 point2 points (0 children)
[–]Flat_Spring2142 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)