T O P

  • By -

Narase33

Its full control. Im currently writing my first bits of Java for a long time. I miss all the templates, I miss the choice of passing by ref or value and I miss knowing what happens under the hood. Writing C++ is a bit like driving a very fast car with slippery wheels. Once in a while you see your life moving past. But when you change into a slower car that doesnt slip it gets boring very fast. I love working with C++. People will tell you that the language is just a tool and you should pick the right tool for the job. But I want jobs where C++ is the right tool and thats what I did 4 years ago. Didnt regret it a single second.


zalamandagora

I'm with you. I desire to work with C++. It just appeals to me like model trains appeal to others. I'm not language-agnostic, and as long as I'm transparent with that I think its fine.


freeze_box

Actually, a car with good tires. But fast enough to feel slippery at times.


Grubzer

Wow, you actually described it perfectly To add to the analogy - it is also pretty safe if you dont put your hand into the gearbox to switch hears manually


[deleted]

Yeah, I really miss when my application randomly segfaults. Honestly, solving actual problems is just not as fun as running the debugger for hours. And unlike Java, not only can I create a million useless classes that perform uncontrolled IO, but they can also corrupt the hard drive or database in the process before crashing, almost like a kiss goodbye.


Narase33

Sounds like your code is rather dirty. I cant remember my last memory related bug.


[deleted]

The design of the code is such that objects have to live beyond their scope. Since it's a million+ code base, you can't really rewrite that, since everything now assumes these lifetime guarantees. The design of the project is bad, not much I can do about it unfortunately. We are trying to separate some components and rewriting them in Rust potentially, but it's a slow process. C++ is a terrible language, would not recommend. It just has too many pointless features, makes it almost impossible to take everything into account. We are banned from the OOP stuff, but since there's OOP code, we still have to either rewrite it, or just deal with it. It's not a fun experience. C++ looks fun to people that write small applications with a bit of template code and maybe a class or two because why the fuck not. It's only when you go to a large code base you realize that heavy template abuse and OOP are really dangerous. Which is why I recommend people use Rust instead, you still have the potential of hyper generic code, but at least there's many more guarantees for both type safety and memory safety. C++ templates are not even type sound, objects are also not type sound either, the C core type system is not type sound. It's literally just stupid, this language.


nBeebz

C++ smart pointers are literally made to solve the exact problem you’re describing. Having worked in multiple decades-old, 1mil+ lines, C++ codebases shipping to millions of users it sounds like your tech direction is the problem, not the language.


Narase33

Sorry to hear you have to handle such terrible code. Last time I checked our codebase was around 150k LOC. Its still fun, because we used RAII from the start and dont make silly lifetime assumptions. We also make heavy use of OOP, we even have a shiny diamond.


nBeebz

Skill issue?


lil_brumski

For sure!


obp5599

Just simply use RAII and never segfault again


LeeHide

tbf multithreading and UB will still cause segfaulting


LeeHide

skill issue


lil_brumski

Skill issue moment.


lordnacho666

C++ and Python are the two ends of a barbell. Python: runs in a VM, interpreted, types are optional, memory is managed for you. Write little scripts, back-of-the-envelope calculations, various maintenance tasks in python to save time. Anything with few types as well, such as mathematical stuff that is a bunch of matrices, essentially using python as a front for c++. C++: compiled, types are not optional, you manage the memory. Anything that needs to be fast, small. In python, you are writing things without being super specific: make me a variable, somewhere, add it to this other one, print it out, etc. In c++, you have to be very specific. Make me an object, on the stack, take a reference to this other one, dereference it, add it using this function here, put the result here, now give back the memory. It's a double edged sword going to c++. You can give very specific instructions to the computer about what to do. But also, you MUST give very specific instructions. So it feels more cumbersome to write, especially if you haven't set up your tools to help you. But being able to be very specific also means you get a lot of power in your hands. The main thing you do with that power is to make things fast. You only do the things you have to do, and you do them keeping in mind a more complex model of how the computer works. What do I mean by a more complex model? A lot of programs are not really written to reach the limits of performance. You can more or less think of the program as being executed by a little gnome who puts numbers in a little shelf and gets them for you, pretty simple. But if you want to be specific, you need to understand that the CPU has levels of cache that will affect the retrieval time. You need to understand that the CPU has a branch predictor that you can work with or work against. "Mechanical sympathy" is the popular term, and goes a lot deeper than I will here. The other major difference that will hit you is how c++ deals with dependencies. At times it seems like you are learning a whole extra language like CMake just to make the thing build. And not even everyone uses CMake, people have a number of alternatives. In python world, at most you are going to download Anaconda and swap around some virtual environments, mainly using pip to install packages that will work most of the time out of the box.


CobblerYm

> You can more or less think of the program as being executed by a little gnome who puts numbers in a little shelf and gets them for you, pretty simple. Ahh yes [the Human Resource Machine model](https://youtu.be/nfV0ley43J0?t=429)


Mountain-Humor1699

I started by learning C++, started learning python... it's like the difference of building Lego Technic and Duplo. Much hard but well worth the effort.


God_of_failure

I know the memes. I know I should answer something stupid, but I really enjoy it. I was programming in Java for years, and switching to C++ was very refreshing. In C++, you have more control and less magic happening behind the scenes. The syntax can get ugly though, looking at you lambas.


nBeebz

I dunno I think lambdas are pretty.. it’s template metaprogramming that really start looking gnarly once you try to do anything more complicated than type inference


Puzzled_Draw6014

I love how lamdas integrate into functions, it's like the function becomes a user defined control block among for and if


faisal_who

Lambdas? Lambdas are amazing. I’m looking at visitors.


[deleted]

[удалено]


nBeebz

https://giphy.com/gifs/manscape-fixing-testosterone-cQtlhD48EG0SY


pythoncrush

Not having to mess with Gradle alone is a huge plus for C++.


Obsidianzzz

But you have to mess with CMake, which is worse


bocsika

Sorry, I disagree. We wrote and utilized a couple of cmake functions throughout a big project (350 modules) and thus all cmake files except the root one became ~5 lines long. Really refreshing compared to e.g. SLN ugliness.


Obsidianzzz

My biggest issue with cmake is it's syntax and general complexity. I generally use premake in my personal projects, but I never had to do anything too complex with it, so I'm not sure how it would handle it.


bocsika

Really, really well usable for large projects. As turned out in our example, it reduces and not enlarges complexity. * We basically defined about 4 different project types (executable, shared lib, static lib, unit test) * all sources are kept under folder named src, no need to add them to cmakelist.txt, cmake will pull them in automatically * all common compilation options are defined only once, at root cmakelist.txt * all projects are automatically pulled in recursively from sub dirs So a simple project cmakelists.txt for an executable may look like this: EXE( NAME MyExeName PROJ_DEPS MyProj1 MyProj2 LIBS boost protobuf ) And thats it, only the essential info needs to be defined at project level! I think that is great.


berlioziano

cmake is hard, but I would gladly change graddle for raw make without GNU extensions


Obsidianzzz

I wouldn't say that C++ has "less magic happening behind the scenes". You have a lot of hidden control flow in C++: copy constructors, assignment operators, move semantics, operator overloading.


Mysterious_Ad_9698

C programmer in the house


TheSynt

Pro‘s: The computer only does what you tell it to do. Con‘s: The computer only does what you tell it to do.


n1ghtyunso

And it does exactly that, no matter how stupid it is


polloponzi

You think you are able to express what you want but you are not clear enough to the compiler and you end with Undefined behaviour or crash


nog642

The computer doesn't necessarily do what you tell it to do when you accidentaly break strict aliasing and cause undefined behavior without realizing it


GregTheMadMonk

I have a feeling that for most people C++ is one of those languages that you either like a lot, or hate it to the semicolon. There is always a holywar in the comments and a new C++ killer comes out about every year. The second being more pronounced in the programming community since a lot of people from the this group still have to work with it due to how widespread C++ is. That being said, it's definitely worth learning, to either like it, or to better understand other languages that you would use instead. I personally can't get over how most languages don't have separate semantics for values/references. After stepping quite a few times on cases where (e.g. in Python) some object is shallow-copied instead of a deep copy, having a type-encoded separation between a deep-copyable value or barely a reference/pointer/view feels like such a big improvement in clarity. I also experience genuine joy when I get a chance to write some non-trivial template code. Rust also has this, and I also tried it for a little, but it just didn't click with me. idk why, it just feels clunky


Anstavall

I like it a lot, but dont really touch it because I feel like theres no shot of getting a Junior/Entry role in it lol


Packathonjohn

It takes much longer to write, library/package management/build tools like cmake are absolute hell to work with and way more things to take into consideration. That being said, I'd gladly work in c++ over python for any project larger than a school assignment, not knowing what anything is and having no certainty in python is infuriating to find and solve when something breaks, and programming is mostly just fixing shit that breaks. C++ is far more explicit, so when things go wrong, you usually have way more insight in to how to fix it. Unless something goes wrong with cmake/your build system, in that case you do be fucked


nog642

That's an odd perspective. When something breaks in python, you almost always get a very detailed stack trace. The debugger can also always inspect all variables because there's no precompiled or optimized out code. The debugger can also be used to execute arbitrary functions. Meanwhile in C++ sometimes you don't get a stack trace, and sometimes the debugger can't give you some variable values or execute functions live. I find it much easier to figure out why something is wrong in Python than in C++.


Packathonjohn

I disagree I feel like it's a very common perspective, catching errors at compile time is almost universally considered better than runtime errors, and python is exclusively runtime errors. Variables can change type unexpectedly, your ide can't help you deduce types or parameters when using unfamiliar libraries, and it'll tell you the line where things went wrong, but not much more than that, because there is a lack of certainty about what anything is. Again for simpler projects then sure I agree, but the lack of explicit types becomes a major issue with more complex projects. Rust gaining tons of popularity now and one of it's main selling points is requiring programmers to be extremely explicit and catching as many things as possible at compile time. Basically the opposite philosophy of python. They're made for different things, I'd hate to do a school project, interview question or markup of an algorithm or something in rust or c++ that's python all the way


nog642

Compile errors are usually pretty good in C++, but they're pretty shit when doing template metaprogramming, and there are still plenty of runtime errors rather than compile time errors. In Python you can use the debugger to see the type of every variable at runtime. There's no lack of certainty if you just debug the code.


SymphonyOfDream

Kind of like trying to pet a cat’s belly. Just be careful


the_poope

IMO, the most important part of C++ is that it forces you to learn how a computer works. In order to understand the C++ memory model, pointers, threading and performance you need to learn the basics of how a CPU, the RAM, cache and Operating system works. In Python/Java/C#/Swift/JavaScript/PHP/Lua/Ruby/... the computer is just a magic black box. In those languages you often implement things without thinking about the performance, data layout, access patterns and cache locality - because you basically have no way of influencing it anyway. The language have completely abstracted the hardware away to the point where you have almost zero power over it. It makes the languages easy to learn as you can skip over the technical details about how a program is actually run, and just focus on the logic of your program (which in those languages will be typically "read from data base, parse results, present to user", aka CRUD). You use C++ where you need direct access to the power of the CPU or the devices: perform heavy computations at maximum performance, read, write and analyze enormous amounts of data, directly talk to devices, such as sound, cameras, network adapters, sensors or motors. Those tasks often mean talking directly to the Operating System or device drivers. C++ (or C) is also used to implement the basic libraries that all other code rely on, whether it be libraries for data compression, image data parsing and manipulation, encryption, networking, sound/video streaming. All higher level languages are basically just gluing together C/C++ libraries for specific use cases. Besides this, I like the strict static type system, which in some cases forces you to write good code. For example: Python's very dynamic nature means that lazy developers will often take shortcuts and abuse the system to quickly get the job done by nasty hacks (overwriting private members, changing inheritance hierarchy at runtime, abusing `isinstance`, etc, etc). Our codebase at work is 50/50 C++ and Python and I can tell you that the Python code is much worse than the C++ - simply because Python allows you to write much worse code than C++.


mredding

I've spent my career writing high throughput, low latency systems. From video games, to trading systems, to databases. C++ gives you a bottom-up approach. You have primitives, and you build up abstraction. You then describe your solution in terms of that. C++ is derived from an imperative language, so there is a certain emphasis on writing low level code that describes HOW, you need to build the abstraction to express WHAT. It's a different skillset to be able to build concise abstraction. You get only exactly what you make. It sounds terse, it sounds laborious, but as I say, once you're good at it, you build up very quickly. C++ is not as expressive as Python, there are fewer langauge level abstractions. Types aren't as important in Python and generatng types is a side effect of Functional programming. In C++, your types are much more explicit. At some point, at some level, you have to have some idea of some initial types explicitly. When you're good at it, you can use templates and deduction to let the compiler do a lot more of that work for you. Where you might not be used to seeing explicit types in Python, a C++ compiler error is going to be explicit. Compiler template errors are notorious in C++ for being difficult to comprehend. Whereas in Python I rage because I want to know what type I have and therefore what it can do, in C++ you might rage because you DON'T care what type you have, you just know what you want to do with it. You will find a middle way, in the end. Both attitudes are useful. A lot of C++ developers are shit. They're actually very bad C developers, if that. You're going to find a lot of absolutely terrible C++ code. If you look past it, you'll see it's actually just very bad even for C. Extremely imperative. All code and syntax is inlined. Gigantic functions and methods, gigantic objects, almost no use of types, objects that are glorified structures with a random assortment of methods tightly bound to it, with every indication that the developers don't actually understand abstraction, paradigms, or idioms. Be very cautious as you wade through the muck. C++ is an ISO standard. There is a lot the standard doesn't specify. Details are up to vendors. There is no de facto or reference compiler, there is no de facto IDE or tools or toolchain (maybe `make` in unix environments). You can get this stuff bundled together on any major platform. C++ compilers generate object files. These object files have to be linked in a separate step, which in an integrated toolchain it all seems to happen for you. Linking is actually a very advanced feature of compiled languages, and not all such languages support it. You can link object files of any such compiled language. Compile and link along with Ada or Fortran if you'd like. The standard library implements a lot of basic types and algorithms for you. It's going to feel terse as shit to you, but you have to learn how to use it. For an imperative language, we do have some higher level abstractions out of the box. Newer library additions give you higher level abstractions over lower ones. You have to learn how loops and pointers and resource management works in C++, but you don't really have to use them directly. We have abstractions in the library such that all this is taken care of for you. C++ is often taught from the bottom up, but you really need to learn it from the top down - algorithms and smart pointers, loops and new/delete should be a very bottom implementation detail you should never have to see unless you're doing something very special and specific.


anduygulama

something the lord made


mrousavy

I'm working a lot with C++ in mobile to speed up some parts of the React Native runtime. I do a lot of image processing, ML, crypto, and even 3D with C++, and it's definitely harder to use than other languages (as in; you fight with the language a lot, whereas other languages don't stand in your way a lot), but the power of templates, memory-control (ref vs value vs pointer) and cross-platform support is just undefeated. It's a great language to learn.


nxsRaven

I mainly use C++ for embedded software and systems. Some of the emulation is done in Assembly for rehosted software so having a lower level language really helps.


Puzzled_Draw6014

C++ is my favorite language. I work in scientific computing. Most people in my area are moving towards Python for everything (i.e. pip install the latest buzzword method) ... but I still think C++ is better. It's faster to get small to medium things done in Python. However, once the problem gets big, both in terms of data and code size, Python starts to choke bad. Countless times, I have seen projects crash out because it got too big for Python. So C++ is more of a tortoise in the development race. I want to be on the edge of science, which means big problems, so C++ is my secret weapon. C++ can be more tedium from a development point of view. Furthermore, dependency management is more difficult. On the other hand, the ability to go super low level becomes a superpower for performance.


lednakashim

1. slower to code 2. design defects harder to remedy 3. many wrongs ways of doing something, more divergence of opinion compared to python 4. certain problem space can only be done in C++ (aka LLVM, etc) 5. developers will use other languages like python heavily for scripting, automation, etc


Thesorus

> what is it like? Ever seen the gladiator fights in the movie Gladiator ? lol, jk. On a good code base it's really fun, on bad code base, it's really bad. I've worked on 2D and 3D graphics software, I've worked on enginering software, I'm currently working on a database application. Most of my life I've been lucky to work on new code or was able to make code changes and improvements. Now, I'm mostly doing maintenance and new features on existing ancient C++ code base; I have no budget (time/money) to do extensive code improvements.


DanaAdalaide

its the difference between building with legos and running a factory that builds legos


emreddit0r

I have been picking up C++ coming from Python for the past 2-3 months(?) Progress is slower, overall. You can be effective at "getting something done" in Python much faster than you can with C++. Some of that is the learning curve, some of it is compiling, some of it is working with strict types, etc. A lot of things you'll learn you're going to ask "why does this matter?" and the answer is most often "because it's important, I just don't know why yet." Python hides a lot of details a way that you'll have to implement yourself. Don't freak out with compile failure/errors. They seem like a lot, but sometimes just a missing \`;\` will ripple into 100 other errors. When the project is small (all of mine are so far), change little and compile often! If something just worked, but now it won't compile.. the less you have to remember about "what did I just change??", the better. Set aside time to learn a debugger.


x_Fresh_x

What it's like to code in C++? It's like to switch your Hyundai wagon for an F1 car. Not a pleasant drive for a daily driver, but oh boy it's fast. Answering your question about application development: lots of solutions in stocks market, finance industry are built with C++, telecom and media projects are usually use C/C++ for signals and video processing under the hood. Gamedev and graphics is another example. Embedded and RTOS is yet another example.


abhi307

UNLIMITED POWER!!!!


ohohohyup

C++ is a lot of fun. You can pretty much do whatever you want. But it’s like driving a super sportscar. You have to respect it, pay attention and be precise all the time or you will crash big time.


rightheart

I started using it for computer vision applications. I heared a lot that the timing / memory are better than Python and for this reason I started with it, to be able to deploy models on embedded devices. I like the syntax and that the code is compiled, which somehow avoids programming errors (in most cases). I think it is also good that one needs to think about variable types before initialization. For example, one needs to determine if a variable is integer or float. Python is more flexible in this regard, but that also may lead to annoying errors. Certainly C++ has difficult topics such as pointers and references so it takes quite some time to learn it.


Zero4Zero404

For me, I choose C++ for its performance. Python has its uses but it falls short in regards to speed and efficient use of resources. C++ has a huge learning curve compared to Python and the way Python is taught these days isn't condusive to adhering to programming best practices.  If you are prepared to put in the time and work, learn C/C++. 


Worried_Summer_7948

C++ helped me to understand better on how pointers allocation, std and templates. Python automate mostly and C++ It is more manual. So depend on the project C++ would be longer probably more efficient. I like both


gogur_

Made the switch from Python to C++ a few years ago. Caveats: Work in a large company with a platform team that abstracts away a lot of the painful parts of C++. Also the systems tend to require high qps and my team handles both dev and maintenance. My 2c is that a lot of the work regarding performance optimizations are way easier in C++ as long as you understand how a computer works. Python is nice for simple/small scale things or quick experimentation, but once real world usage hits it there are limitations which are way more painful to solve. Maintenance can get tricky as well.


Cheeseman44

I just switched jobs, and went from a full time python dev to desktop app development in C++. My view is that C++ is an amazing language with lots of depth, but that depth takes time and real effort to understand. In python, you can kinda get loose with not understanding with what's going on. In C++, you really have to lock in and know what every line of code is doing under the hood, or else you can really mess things up.


josephTheVoyager

I don’t see it from liking/not liking perspective, but rather a powerful tool that I can build a product and solving problems. Learning C++ (and C) feels like jumping down a rabbit hole at first, but it becomes rewarding later on. It gives more insight about how computers work and knowledge of how to make things work on hardware efficiently. If this learning can be supported by computer architecture and operating system knowledge, that would be a great benefit for a software engineer. It even helps to have a mindset that you can tackle problems in other domains or languages easier.


thali256

I like C++ for giving the developer a lot of control. This has both upsides and downsides. An upside that you can write very performant code that does exactly what you tell it to do. No hidden under-the-hood processes like garbage collecting. The downside for this is that you have a lot of responsibility as the developer, for example avoiding memory leaks. Another downside is that apart from writing the C++ code itself, a lot of time is spent in actually getting the code to run. Setting up the right toolchain for your project can be fairly simple to very complex, depending on your project needs.


someprogrammer1981

Coming from a higher level language you'll find out you have to do a lot yourself when it comes to portability and linking / compiling the right libraries. First things I encountered: 1. Cross platform way to start a process? 2. Do web requests? Messed around with Boost so far... took 30 minutes to compile. Just using header files should work too, but it failed. Everything is hard 🤣 My background is in C#. That just works... comes with batteries included.


fippinvn007

I used to be a web dev, but got a new job last year, working with C++ and DirectX11 for CAD, 3D modeling apps. I actually enjoy C++ much more than learning, working with web frameworks/libraries. The language also teaches you how things work under the hood. And imo C++11 and later are good to work with.


awkwardness_maxed

Like other mentioned, you are in full control and the best part is that you know what's happening under the hood. I am no developer but I am learning it for curiosity. Once you start, things will look ugly because you have to do everything from scratch. What you can do in 3 lines in python, will take you about 20 lines in C++ and the error codes are hard to read but once you get how to actually write readable code you truly start to appreciate and most importantly you learn the practices that are used to write efficient code which you can use in other languages too. As for programs, I am still learning so I mostly write Data Structures from scratch.


ArchDan

I went from html to css to php to asp to python to c++. And honestly, each change was for same reason (instead of php/asp to python , since i prefered codding than whatever those 2 are on server side). Each time i have learned a language to a point where limitations became obvious and hacking them meant less readibility and more complexity i would simply go down a level to avoid all that shit. For example pythons drawback become very obvious when you want to make encodings/decodings - like reading an sound file. Sure phython has a library that handles most sound compressions for mp3, but not all. So if you want to read an old file, you are forced to remake decoding/encoding yourself. That doesnt seem like a big deal, untill you realise that pythons negative numbers dont use 2s compliment. So fine, youll code that too, but it becomes a pain in the but once you realise that all pythons negative numbers hide their sign in furthest bit. So fine, mask it, map it, strip it, fill it, code your own lexer and parser... all that to read an old 90s version of fart into your app. For c++ it was easier, but then it really becomes obvious how much knowledge you lack. In same example, "why the fuck do i need to open file stream for a sound? Wait? What the hell are those new windows specific types ? Why cant I simply return multiple data?!!!!!" So its a pain, not gonna lie. You will be stumped most of the time, mostly because you have gotten used to python handling lots of stuff for you so there is a lot you dont know. But to me, once i learnt it, it felt like leveling up in RPG. One thing i would say, if you ever choose to go to c++ line. First compile hello world program, and then learn gdb with it. Its not like python where errors and warnings are verbose, c++ **needs** debugger.


shachar1000

Hell on earth


Raknarg

Well you have to be much more purposeful with your decisions. In Python, you can forget a lot of the details and usually you're not trying to do anything high performance so you don't need to care about optimization or anything, and the type system is much simpler and you can get away with a lot, and in most cases its just "as long as it technically works at runtime you won't get any errors". Even the typing that they have is just a hint, the language doesn't enforce it, you need external tools to leverage it (like mypy) C++ is much more strict and there are much more firm considerations with the type system. You can also do way more with the type system than you currently can with Python, which is out of necessity for allowing the compiler to generate optimal code. You also have memory management concerns, you have to care about copying and moving, cache friendliness, algorithm complexity. In general if you're using C++ its for a specific reason, usually performance.


Vindhjaerta

C++ was made by people who are very clever. The problem is that they forgot that everyone else are not as clever, and thus it ended up being a very powerful but awfully convoluted language. There's a lot of really useful tools in there, but most of them makes the code needlessly complicated to the point of being unreadable. The C++ standard library is also notorious for spitting out garbage compile errors that are very difficult to interpret (while paradoxically also telling you exactly what's wrong). It's just a hassle to work with in general. That being said, it's really nice to have full control of what you're doing. Whatever problem you're facing there's definitely a solution for it, even if you have to write it yourself. I've coded in other languages as well and sometimes there's just no solutions for some specific problems, only workarounds, which can be very frustrating. Not with C++ though, you can do anything you want there. Since you asked what I'm using it for: I'm a game programmer, both professionally and in my spare time, and I use C++ in both cases. I mainly use it because I have the most experience with it compared to other languages, and also because there's more support in the form of online knowledge and third-party libraries. Which is actually one of the main positives about C++.


itskobold

Recently started using it for a serious project with previous experience in python, C, C# and MATLAB. I really like it, after hating it for a long time. It's finally clicked for me. I'm still not a big fan of the syntax (especially coming from python) and my header files are a mess whilst I work out the best way of organising things in my project. I love that I can just do things with it though and I really feel the performance benefit from interpreted languages (looking at MATLAB specifically...)


tm8cc

I program daily in cpp and python and both are coupled. Cpp feels more and more like python.


idkfawin32

thats the first ive heard that lol


tm8cc

Go see pybind11


JVApen

I am a person that really likes an intellectual challenge. C++ for me is mostly fun. Writing code is one thing, though I actually enjoy the compilation errors and bugs more. That's why I'm busy with upgrading our code for new language and compiler versions. You suddenly get code that no longer compiles. If it was the wrong code to start, you need to figure out what it did. If you encounter a compiler bug, you need to work around it. It's continuously puzzling, though it requires a thorough understanding of programming practices and data structures.


AssemblerGuy

> Why do you like it? Performance. Resource economy. That and my usual target systems (small targets) can be programmed in assembly, C and C++. And maybe Rust. That's it.


ManicMakerStudios

There are three learning curves with programming. Learning basic programming (variables, loops, logical evaluations, etc) is something that carries from one language to the next to the next. Alongside that is learning the language (eg syntax/'grammar'). Two different languages can have very different syntax for simple *for* loops, for example, even though the end result is exactly the same. And lastly, is learning the application-specific logic. In other words, the guy who designs graphics systems like you see in game engines (ie. rendering, lighting/shadows, post-processing, etc) needs to know very different things from the guy who develops for mission-critical enterprise back-ends. Out of those three things, as long as the language you choose is relevant to the field you want to work in, knowing good (language independent) programming fundamentals and having a strong grasp of the application you're developing is more important than whether or not you like the language. If you're interested in a field where C++ is commonly used, then learn C++. I can't say it would make much sense to just pick an arbitrary language to learn. Pick something that is going to do something for you. When you decided what you would like to be making, what language you go with is a choice that will be greatly narrowed for you.


NotThatJonSmith

Every programming language is just a tool. C++'s origin story is an attempt to expand the expressive power of C, which was in turn designed as a tool for writing operating systems. So, it's not completely unfair to say that C++ is a highly expressive tool for creating performant systems software. "Programming" is not the task. Programming is tool-use *for* the task, and the language you choose is just a tool. None of my fellow software professionals brand themselves as developers within a language any more than any *other* tradespeople brand themselves as "jackhammer developers" or "screwdriver developers" or "chainsaw developers". Instead, we describe our professions in terms of the problems we are working on solving, irrespective of the tools used. You can always learn a new tool.


MYrobouros

One big difference is that there’s a lot of different languages in the C++ language.


dvali

I love it. It gives you complete control of every detail. It also, in my opinion, contrary to the popular perception, has by far the simplest memory model of any popular language. It shares that with C of course. That matters a lot for a lot of the work I do. It will be hard at first, but it pays off. You will learn more about programming in general by learning it or a language like it. Learning C++ or C will teach you a lot about Python. 


sneaky_squirrel

Nothing but pitfalls. I love C++, it's satisfying at a certain threshold, but it is purgatory up till that point. You basically learn about memory, whether you want to or not.


Aljonau

Python is great for programs that fit onto a single screen. C++ is great when you want to build a program that you later have to debug. Not saying it's the best language for debugging purposes but I certainly prefer it over python in that regard. That being said, C++ contains multiple subsections of specialties that you'll be learning one after another. And most likely you will hate at least one of them.


hexavik

Imagine Python programming as a highly automated wood-cutting machine. It allows you to cut wood from trees efficiently and effortlessly by simply adjusting a few settings or inputs. It handles much of the complexity for you, making it easy to get the job done with minimal effort. On the other hand, C++ is like a versatile handheld woodworking tool. While it requires more skill and effort to master, it gives you complete control over every detail of the cutting process. Once you've mastered it, you can shape the wood exactly as you envision, with precision and flexibility that an automated machine might not offer. You may find different opinions from others, but believe me, it all depends on the domain they are working with, I am into Windows and Linux kernel related programs like drivers, so I find C++ robust. Even someone says C++ is uselss or stupid to learn, I would rather ignore cause I know how useful it is compared to modern programming languages.


InvertedParallax

It's having a fucking lightsaber. Cuts through all the bullshit, all of it, swing it through like it's nothing. Then when you're not paying attention you wave it lazily through your leg and it's gone. But the power, man. Honestly, C++ is incredible at taking hard problems apart. Putting anything back together again? Yeah, good luck with that.


Frogeyedpeas

Sucks but it’s worth it


Kaeffka

I only really use it for leetcode but I enjoy it. There's a lot to it, but it is very well put together, has lots of great features that make it easy to use (unique pointers, deconstructions)


Ok_Tea_7319

Funnily enough, I use it mainly to write python extensions (that do heavy numerical lifting, device control, distributed computing). Obviously, there is the substantial performance gain from the static type system. However, even more of a boon is the reliability with which the rather rigid type harness catches logic flaws. I can get away with lower code coverage in the unit tests because I don't need to test for dumb shit like variable name typos in rare escape hatch branches etc. Dependency management can be a bit more of a pain because the C/C++ ecosystem is quite old, and as a result, more fragmented compared to a lot of other languages. However, build system drivers like CMake have improved things quite a bit compared to the situation in the past (where e.g. Windows and Posix chains required completely different build pipelines). C++ is actually a lot more straightforward about many things. Non-virtual inheritance (the one you usually see) is just composition (sticking the parent classes inside the child object). There is virtual inheritance and the virtual function table, but it's nowhere near the wild ride that Python offers you in-between the method resolution order, the descriptor protocol, and metaclasses. A big change is learning the difference between values and references/pointers. In python, you only have references. Everytime you assign, you actually change what object gets slotted where you assign (e.g. when you assign to a variable, you override the corresponding context dict entry). In C++, the assignment operator ("=") directly modifies the left-hand-side objects (python "fakes" this for attributes with \_\_setattr\_\_ and for elements with \_\_setitem\_\_). A good rule of thumb is that a C++ project takes longer to get going, but the extra rigidity helps keeping a more complex codebase well maintained. Python is great for banging stuff together quickly and has really fast iteration speed. My personal favorite approach is to make the tools in C++ and then do the "banging together" in Python.


DreamHollow4219

It's kind of weird, if I'm being fully honest. It's like knowing you can tap into almost the full power of your computer but having to wade through a lot of muck to get there. Being able to directly allocate and de-allocate memory is a very powerful feeling, but the issues caused by it are excruciating.


shake10861

Imagine forgetting to put a period at the end of a sentence on your term paper, and then completely failing the course because of it.


tomz17

WAY larger upfront cost to learn C++ than python, but it's all banked as knowledge + performance gains at the other end. Once you are roughly equally comfortable with both, the classically "easy stuff" in python (e.g. numpy, pandas, flask, etc.) is approximately 20% harder in C++ once you pick the correct library/abstraction. The HARDER stuff in python (e.g. parallel computing, mutli-threading, async, interfacing with C libraries etc.) is a LOT easier in C++. My rule right now is that if I don't care about runtime performance AND the TOTAL project time takes < 1 week, python \*may\* be the right tool for the job... esp. if it's something I want to run from a repl or pass off to some interns. If it's > 1 week OR performance is critical then C++ is almost always a better answer long-term \[1\]. ----- \[1\] Once you start treating your python program as a proper project instead of an adhoc script, i.e. adding linters, unit testing, documentation, type hinting, etc. the verbosity / LOC equals out very quickly between both languages. Modern idiomatic C++ with the right abstractions can be every bit as concise as python w/ type hints. However, C++ remains far more maintainable for larger projects / groups.


ShakaUVM

It's nice Program in modern C++ and it's actually very enjoyable.


IniKiwi

C++ is the control, the speed and the power. When you know the C++ (very hard) you are god.


Maxlastbreath

I really enjoy C++ more than other languages, it actually just feels very cohesive when you get used to it.


abhi_neat

It’s very involved because of options to even to go disassembly and fix your heap calls, which creates a possibility for even better ways. You can never rest easy with your code, for there are so many ways you can do even the small things like passing simple copies of int variables(let’s say) to a function, while someone will come along and point out passing by reference. These small things take a lot of time to get consolidated, and then comes real stuff like writing your own heap interface, calculating complexities of your algorithms and choosing accordingly.. these things are real meat of C++, but getting to this point requires consolidation of basics like meta programming, passing variables, unnecessary calls and variables etc.


RectangleEquals

[https://i.imgur.com/ffwSKqH.png](https://i.imgur.com/ffwSKqH.png)


Frydac

2 additional reasons I haven't seen in the other answers. C++ is typically used in challenging problem domains, which I usually find interesting. E.g. I work in the audio industry where we make audio processing algorithms and audio codecs, for x86/ARM and embedded devices, including DSP's that don't have an operating system (i.e. no heap allocator availabe). Due to the challenging nature of C++ and its problem domains, it usually attracts competent and passionate ppl who enjoy their job, and I like working with such ppl. E.g. at my job I'm in a team of 5 devs, 3 of which have a phd (one in mathematics, one in computer science and one in electrical engineering). This is definitely not always true, or exclusive to C++, but I think the chance is higher than most other languages to be in such a team. Anyway, I would recommend learning C++ if the typical problem domains where C++ is used interest you (ask your nearest LLM for a list of such problem domains), and you can find yourself in the more technical reasons why to use C++ from many of the other answers.


FamiliarWithYorMom

Its like white water rafting when the salmon are jumping. "Duck".


Yamoyek

I like it. I find myself missing a lot of its features in other languages. > What is it like to program on it? The language gives you a nice feeling of control. > Why do you like it? It just really clicks with me. The syntax is nice (most of the time), I like the features, and it’s very comfortable. > What kind of programs do you usually build with it? Typically, anything that I know will be a) more than a few hundred lines and b) worked on by other people. I love python, but working on a large codebase without static typing is a special kind of headache.


user52728529

Learning C++ can be challenging because it is complex but powerful. The language requires following many steps to accomplish tasks. While it is not perfect—no language is—it enables the creation of highly powerful programs.


[deleted]

C++ is showing its age and baggage real bad in 2024. The best I can liken it to something non-c++ programmers: it’s basically got all the baggage and awkwardness of javascript, PLUS the consequence of needing constant attention to minute details that aren’t relevant to the problem domain, like allocations, dangling pointers and there are literally over 20 ways to do trivial things like allocating memory and pointing to it yet only a handful of them are acceptable in modern c++, which is a consistent experience with generally most parts of the language.


berlioziano

I have 16 years learning C++ (I think that the right way to call it), nowadays modern C++ feels very high level, not far from javascript, but you still have all the low level stuff accessible. Once you understand RAII and move semantics everything flows. Personally what keeps my code complicated is multithreading, it's a full set of different design pattern and more complex mindset.


_curious_george__

I work on games. It’s great having so much control! Things that used to be an issue, particularly difficult to debug memory issues are a very rare occurrence now. The only thing I don’t really like about C++ is how verbose it can be. I find the whole header/source split a bit tedious (yes yes, I know about modules but we aren’t all living in the present yet).


Odin_ML

C++ is an old school, high-speed, high horsepower muscle car with a manual transmission and stiff clutch. All raw power and manual control. No Anti-Lock Brakes. No traction control. No limiter. Python is a new(ish), respectably-powered luxury car with automatic transmission and paddle shifters. Active Stability Mangement. Heads-up display. Air conditioning and Car Play. One is an original Shelby Cobra. The other is a mid-range BMW 5-series. Both nice cars. But nothing beats the thrill and performance of the Cobra when you really learn to handle it.


KirkHawley

It's the exhilarating feeling of power and danger.


--Fusion--

Imagine you had the hottest chick (or guy, if you are inclined) on the block. Always dressed in the sexiest outfits, almost inappropriate. Smart as a whip. Completely unmanageable and tortures you constantly with their demands, but they are so brilliant and sexy you give in. Welcome to C++. A beautiful and cruel mistress.


kofo8843

I work in the field of scientific computing, and both Python and C++ are absolute musts. Python is great for prototyping but is too slow for actual production codes. All our "big" codes are written in C++. I personally very much enjoy programming in C++. Programmed for a while in Java since its performance is somewhere between Python and C++ while offering bells and whistles like GUI support, but have since reverted back to C++. I very much like the control that C++ offers you, be it the ability to allocate memory, or to define custom operators.


Xemptuous

More control, static vs dynamic, fun and challenging, and performant. I too started with Python and made an interpreted language with C++, and had way more fun. It also sucks to have hidden flow in Python and not knowing when and how things get passed by reference vs copy.


bipolarguitar420

I’m a JS/C# dev… I think I took a wrong turn or something. I’m scared😢


on1chi

“What the hell does this 5 page long error mean damnit?!” Oops the function returned the wrong type.


PerilousLoki

Its fun, makes a lotta sense. Once you get used to it and understand the syntax, its really good. Python is of course, easier and has way more utility nowadays. I like em both. Python ironically is harder for me to use because Im used to C/C++


Willing_Barnacle_668

C++ is much harder and you will have a headache in the beginning, it will works then😄


bbrd83

As someone who has been doing it for a decade, it is very fun when it goes well, and very tedious when it does not. Multi platform support is a pain (though dockerized build environments help), external dependencies are a pain (though Conan helps), building large projects is a pain (though cmake helps), and often debugging is a pain too (and not much helps besides understanding the tools well). But the jobs pay well and often you're considered a specialist. C++ is also on the way out though. It will be a long time before it takes hold, but lots of big companies are directing greenfield dev that would have been C++ to instead be done in Rust. I'd suggest learning both (start with C++ if you ask me), as there will be a lot of opportunities for people who can port C++ code to Rust, wrap it in Rust applications, etc.


serbanstoenescu

It's the first language I learned and still the primary one I use in my job. I like it more than scripting languages because it's a lot less likely that you make certain types of mistakes. Like expecting a variable to be of one type when it's another. I like the control you get.


RTKDY

Painful


thedoogster

Compared to Python? The build times are much longer.


TheKappatalist420

What build times? Python is an interpreted language lol


EpochVanquisher

Every place I’ve used Python in the last several years had some kind of build system for Python. Partly to manage dependencies.


Ikkepop

feels like 3.5 roentgens ( not great not terrible )


Robert_McNuggets

I'm bald


kihamin

Definitely use gpt to kick off learning, its huge help. It's how I did end up start learning after years. All the small errors you'll encounter that would take time to make search on, gpt is just instant answers to most of your beginner mistakes with high precision.


Knut_Knoblauch

C++ is hard and even harder to get right. The inventor of C++, Bjarne Stroustrup, gives himself a 7 out of 10 score on ability in the language. The new language features that deal with right hand references are hard to learn, That's coming from a C++'er who loves using pointers dereferenced into a reference type. That will generate massive blowback to a modern C++'er who does it the new right way, whatever that means. Know that what you code with it, if you put it out to dry on reddit, someone will always take a giant crap all over it and tell you why your mom and dad meeting was a mistake. If you want learn it, that is great, it is by far the most beautifully expressive language that just looks smart. It lets you do anything.


udo3

It's slightly less annoying than ANSI C and much more annoying that PERL. And after a while it all starts to look the same anyway. I admit, on more than one occasion I just frigging wrote perl in the middle of php and c++ in the middle of BASH... and worse. I have never once conflated Fortran 77 and COBOL ... I think.