r/cpp • • 7d ago

Why C++ is so hated!!!

I love C++. High level + low level at the same time. But Linus Torvalds don't want C++ in the Kernel, industries hate it, people hate it but why? Why be so angry? Memory management? I mean ok maybe it has problems that I don't even see but why so much hate.

For me it's really sad! šŸ˜ž

Why something so powerful it's so hated. Now I feel "strange" doing projects in C++ because… sometimes I question myself "Why do I write C++ code if people hate it". Can someone explain what is happening and… can I use C++ for fun in peace?

0 Upvotes

100 comments sorted by

24

u/jwezorek 7d ago

C++ haters are just really loud online.

28

u/FckXFckMusk 7d ago

Most people don't know why they hate stuff, they just hate it because someone or something told they should.

6

u/ilPlayerdiGD 7d ago

I agree

5

u/yazilimperver 6d ago

I also agree that, people should understand that it is just a tool and as a software engineer, it need to be used carefully and in locations suitable for the intended purpose.

Nevertheless, i like it because, it allows me to execute my ideas in various ways and offers flexibility with maximum performance.

I can't say there aren't emotional reasons, either šŸ˜…

1

u/ilPlayerdiGD 3d ago

How is to be a "software engeneer"? I maybe want to become a software engeneer so I'm only asking.

2

u/yazilimperver 3d ago

Getting a degree might be an option or great start, but it's not the whole story. You also need to have sharp analytical thinking, the ability to break complex problems into manageable solutions and having fun dealing with problems, Imho.

1

u/ilPlayerdiGD 3d ago

Wait… can I learn the "analytical" stuff while I'm a junior maybe in job? I don't have a degree and I'm not intelligent šŸ„€

2

u/yazilimperver 2d ago

Why not, solve small problems daily, ask why, before jumping to a fix, break big tasks into tiny steps, solve them as fully understanding each step and underlying problem.

Do that at your junior job and the analytical stuff will come. The degree might be optional, but the practice isn't.

1

u/ilPlayerdiGD 2d ago

So "Just do experience"

2

u/yazilimperver 2d ago

Exactly; imho, having such concern is an indication that you will handle it šŸ˜‰

2

u/ilPlayerdiGD 2d ago

Wow thanks! šŸ˜‚. Well first I need to learn C++. Like I know 0.0000000000000000000001% of the like 1 million feature of C++ šŸ„€.

34

u/No-Dentist-1645 7d ago edited 7d ago

It's not hated. Tons of companies and software use C++, it's extremely popular in that aspect. There are just places and contexts where it is a good choice, and places where it isn't.

They tried to use C++ in the kernel before, realized it wasn't that good of a fit, and moved on. Nothing to be sad or hold grudges about that.

10

u/delta_p_delta_x 6d ago

They tried to use C++ in the kernel

This is really just a Linux problem. Other OS kernels use C++ just fine. See: Windows, macOS.

2

u/donaljones 3d ago

While Windows uses C++, I don't think the NT kernel uses it. Don't know about Apple. BeOS is also known for its extensive use of C++, but I don't think its kernel used C++ either.

9

u/pjmlp 6d ago

Contrary to Linus hate for C++, other operating systems do use C++ in the kernel.

Yes it is a subset, just like no C written OS uses full ISO C on the kernel.

2

u/serviscope_minor 3d ago

>They tried to use C++ in the kernel before, realized it wasn't that good of a fit, and moved on. Nothing to be sad or hold grudges about that.

I don't think that quite covers it really.

They did try C++, specifically g++ in something like 1996?. The problem from what I recall was it was kinda slow: gcc wasn't great back then and the g++ burned a register needlessly which was a colossal penalty on x86 which has so few GPRs. As a result, changing the kernel to the common subset of C and pre standard C++ and recompiling was not a great experience.

And the advantages of C++ were also fewer: the gcc optimizer was also not good at the whole zero cost abstraction thing that we've taken for granted since about 2005: while now we can have a stack of templated inner classes calling methods within methods within methods, and the optimizer will flatten them out to really good code, that was not the case reliably before (I recall it got quite good with gcc 3.3 and really good with 4.x).

So it's not that C++ was not a good fit per-se, it is that GCC specifically in 1996 was a bit weak optimization wise. This is feel is quite different. I can't think of anything that C does better than C++ (except in some, increasingly rare cases, exist) when it comes to low level programming. I've never written a kernel, but I've spent plenty of time of micro controllers too small to have one.

Then later, Torvalds went on a famous but rather irrational rant about C++ which also encouraged a lot of people who really wanted to be angry about something.

2

u/ilPlayerdiGD 7d ago

Oh. Well C++ is good for game. Am I right? Onestly I use SDL2 for making game in C++. I like the abstraction of C++. I'm more calm now. Thanks ā¤ļø

-1

u/No-Dentist-1645 7d ago

Depends on the game, tbh. If it's a simple-ish 2D game, then yeah definitely, C++ is great and there are very neat libraries such as Raylib for them, which imo is nicer than SDL2. But for more complex games or 3D ones, there's a reason why people use game engines like Unity or Godot for them

14

u/tibithegreat 7d ago

C++ is good for complex games as well, you just have to use a mature engine, like Unreal or join a company that has a proprietary engine (most of them are C++ as well).

2

u/No-Dentist-1645 7d ago

True, I just don't know much about Unreal to vouch for that, and sometimes game development using large engines like Unity and such tend to add a lot of abstractions on top of the programming language itself where I would consider it their own variant or "dialect"

3

u/tibithegreat 7d ago

I understand and what you are saying, and in some way it is indeed true.
However I worked with both Unreal and a proprietary engine of a big company which I will not name (rhymes with boobysoft), and most of the peculiar things were usually around added preprocessors to be able to handle reflection and data serialization. Other than that it's usually just plain old baisc C++, when writting code you are mostly just thinking about c++.
There are obvious custom implementation for a lot of low-level stuff (but that's generally the case for most big companies), but in the end you still have to deal with pointers and making sure you don't leave them out to dangle :).

5

u/pjmlp 6d ago

Which are written in C++ for the most part.

2

u/ilPlayerdiGD 7d ago

Wait… My whole path is creating 3D games in SDL2 + OpenGL. I don't want to use a boring engine! I want to learn like EVERYTHING. Yeah I'm trying to do the hard things. At least I'm trying šŸ˜­šŸ˜‚

2

u/serviscope_minor 3d ago

This is good! There's nothing like doing it all from scratch and having the entire thing in your head. If you're not on a budget for a client, then this is a great way to do things since it's frankly a lot of fun and really useful. I think you'll have a blast.

1

u/ilPlayerdiGD 3d ago

Thanks! Yeah it's a little hard not because it's really hard but because it's slow. On Godot I'm creating a 3D game and I'm in a good point in just a few days! Something that with raylib could cost me weeks and weeks! Only for this projects because I want to create a horror game in OpenGL! :).

1

u/yazilimperver 6d ago

If you want to learn underlying technology and how stuff works "this is the way 🤠", imho.

I have to say that this path isn't easy as others pointed out and I recommend starting with the basics. You might end up with a lot of unfinished libraries or engines, but don't give up. Ultimately, you'll benefit from all of them. Don't ask me how I know šŸ˜…

1

u/No-Dentist-1645 7d ago

Good luck! It's definitely possible and even a good learning experience, it's just that you're gonna have to reinvent a lot of wheels in the process, and real "production" projects outside of hobby projects don't see much reason to do that, which is why game engines are a thing to begin with

2

u/YoureNotEvenWrong 7d ago

It's also not fashionable though. Ask anyone that doesn't know C++ or Rust what they want and they'll pick Rust

-1

u/angel_devoid_fmv 7d ago edited 6d ago

Just because companies and majorities acquiesce to terrible things doesn't mean they're not hated. I've had to use many technologies and submit to managerial practices I knew were stupid and bad. I wasn't in a position to refuse them, just hostage to bad management. Funny how that works.

13

u/Aprelius 7d ago

C++ is one of the most used programming languages in the world. It can compile and run on almost anything. I use it every day in game dev.

C++ is a tool. It solves a problem. Are there different tools that solve that same problem: yes, Rust and C are both great alternatives.

Stop caring what other people say about their favorite tool for the job they do.

5

u/pjmlp 6d ago

On top of that, the industry C compilers are written in C++ nowadays, and the Rust reference compiler is not yet fully bootstraped, also depends on C++ for its implementation.

2

u/serviscope_minor 3d ago

I wouldn't really say C is a great alternative: the common subset of C and C++ is so close to C, that for just about all practical purposes C is a subset of C++.

At that point it's "missing features is a great alternative to having them", which I don't really hold with. There's literally no advantage to not having references and type safe equivalents to macros for example.

4

u/pdp10gumby 6d ago

Torbaldā€˜s position is a left over and very common belief (once correct) that compiled C++ code is bulkier than equivalent C code. its been true for a long time that C++ code can actually be more efficient than C code because C++ is more expressive, but it’s true that it’s easy to casually do something that will make the code bulkier.

As for the general case: most C++ complaints boil down to ā€œwhat have the Romans ever done for us?ā€

9

u/kevinossia 7d ago

It’s hard and complicated. Ignore the haters.

2

u/angel_devoid_fmv 7d ago edited 7d ago

Eh, it's not that complicated. It's just that not well done. It makes or is inured to lots of regrettable design decisions whose absence would simplify many things. It does suck to heave out a lengthy entry on cppreference.com every time you want to be assured you won't shoot yourself in the foot.

4

u/KAMEHAMEHAMEHAAAA 6d ago

The hate for a language is proportional to the number of languages created with intent to replace the said language.

It is a long and sad list for C++ replacements, each more ambitious the next yet none stood the test of time.

4

u/tinrik_cgp 6d ago

IMO, C++ is a great language to work alone (e.g. as a hobby). But it's a horrible language to work together with other people (e.g. in a large company).

There is too many pitfalls and ways of doing the same thing, therefore it's very hard to have a consistent style. Some people will overengineer the simplest thing just because the language allows them to.

Linters don't enforce everything. So you have to spend a lot of time creating guidelines about how to do things, and have a lot of friction about it during code review.

8

u/AshKetchupppp 7d ago

Ignore what other people think, if you like it then use it, if you're not being paid to write it then enjoy your programming hobby! There's good reasons why other languages are preferred to C++, memory (mis)management is why languages like Rust have come about. I love C++ also but encounter pitfalls I wouldn't run into in other languages

3

u/FckXFckMusk 7d ago

One can do silly things with rust too...

I would have preferred if they made C++ safer, compilers more helpful et al.

3

u/ilPlayerdiGD 7d ago

But at least don't insult it. Look on YT! There is a whole video of 2 hours that yaps about "C++ is the worse programming language" like bro calm down!

1

u/FckXFckMusk 7d ago

Its marketing.... Paid influencers paid to say things...

2

u/segv 7d ago

If it was the same video i am thinking of, it felt more like a senior developer venting their frustrations rather than marketing

Edit: Found the video: https://www.youtube.com/watch?v=7fGB-hjc2Gc

0

u/FckXFckMusk 7d ago

Do a history check on the guy and see who he is affilated with...

even the IT world has its Influencers.

1

u/no-sig-available 7d ago

Nobody makes videos about "Everything is fine!".

1

u/ilPlayerdiGD 7d ago

Ok! ā¤ļø

6

u/Ok_Independence_9841 7d ago

Those who can't write C++, hate it, and find excuses for that hate. Just like those who can't do object oriented falsely claim that OO is a bad idea while they continue to use the very same ideas themselves, often while not understanding that's what they're doing. It's just humans being human. Anything excellent and difficult will garner hatred.

2

u/angel_devoid_fmv 7d ago

I can. The fact that I am a good programmer is what makes me resent C++ actually, having to deal with all the schlock code from vendors in India who think it's still 1996. Actually that's most western C++ programmers too, let's not pick on poor India.

5

u/amoskovsky 6d ago

Several reasons, all related to Rust.

1 - memory safety of Rust.

Rustaceans believe the memory safety of Rust is enough for other languages to stop existing.

It's definitely not true for C++ as it has much more features than some safety concerns can address. And not every project needs "guaranteed" memory safety (don't get me started on the guaranteed part in Rust; spoiler: it's not).

And when C++ devs ignore them, rustaceans become aggressive and loud, which looks like many people hate C++. It's just an illusion

2 - AI

In the era of AI, big corporations hope to replace devs with AI, and based on the memory safety promises of Rust initiate migration from C++ to Rust, expect the slop code AI produces in Rust would require less efforts avoiding crashes/vulns than C++ slop. That's partially true, but since the migration can be only automatic due to huge C++ code bases - the resulting code is just a huge pile of source code that no human has ever reviewed, which is a ticking bomb of tech debt.
This process though causes massive job market effects and people now suddenly want to dev in Rust just to be in the job market trend.

And when you have to do something you start hating those who don't have to do it :)

1

u/rodrigocfd WinLamb 5d ago

AI produces in Rust would require less efforts avoiding crashes/vulns than C++ slop.

Theoretically yes, but in practice we see LLMs generating lots of unsafe blocks amidst their slop rewritings. What is better is the toolchain: Cargo is much harder to fuckup than makefiles.

9

u/HxSigil 7d ago

it’s also a massive, messy language with UB, insane complexity, decades of baggage, and a pretty painful ecosystem. CMake alone should tell you that much

the Linux kernel is probably the worst example here. It already has decades of C code, tooling and conventions built around C, and kernel code generally wants very explicit control over allocation, runtime behavior and failure paths. You can disable exceptions, RTTI and avoid most of the standard library, sure, but then you’re already using a heavily restricted subset of C++, so the obvious question is what you actually gain by switching.

Nobody is stopping you from using C++. If you like it, use it. But treating ā€œpeople hate my languageā€ like some personal crisis is a bit weird. It’s a programming language, not a personality trait

6

u/Thesorus 7d ago

it's not hated.

It's just not the shiny new language

it's just that there is a lot of existing software using old(ish) C++ that needs maintaining and that it sucks that is nearly impossible to upgrade to better language features.

Linus is also a dick (rightfully) in what he wants to do with the linux kernel and what language he wants people to use.

5

u/wyrn 7d ago

Linus is also a dick (rightfully) in what he wants to do with the linux kernel and what language he wants people to use.

Linus also ended up having to implement an ad-hoc, bug-ridden, slow implementation of half of C++ because "pure" C just doesn't cut it -- it's more a stupid bias and project management failure on his part.

5

u/CreativeAlbatross319 7d ago

Linus is just a normal C dinosaur. I have seen so many such kind of people in my circle. The problem is they either adapt or get fired and they end up writing C with classes.

0

u/ilPlayerdiGD 7d ago

Ok!

5

u/no-sig-available 7d ago

Linus saw some bad C++ code in 1992, and decided that C++ - and all C++ developers - will suck, forever.

https://www.reddit.com/r/learnprogramming/comments/1dss1jo/linus_torvalds_on_c/

Therefore, we have not donated any C++ code to the Linux kernel since. Instead it features "Object Oriented C", which apparently is fine.

https://lwn.net/Articles/444910/

3

u/t_hunger 6d ago

Well, Linus uses C++ for some of his user-space work. He also has no trouble with rust in the kernel. He was just very plain in stating his no C++ rule for the kernel because we were very obnoxious with our "convert your C project to C++" campaigns back then. Its funny how things repeat -- and how many people I know nagged projects to switch to C++ when they were young are now pissed at young people asking them to rewrite their projects in rust.

And there have been quite a few attempts to get C++ into the kernel since then. They usually do not get much media coverage before fizzling out again.

4

u/pjmlp 6d ago

Meanwhile OS X has replaced NeXTSTEP Objective-C drivers with C++ drivers back in the 2000, which naturally run in kernel space.

Symbian and BeOS were written in C++.

Windows has had C++ in kernel space since Windows Vista, as kernel mode was added to Visual C++, and eventually the WIL template framework came to be, originally designed for drivers, naturally also running on kernel space for the most part.

Genode OS is also written in C++.

Hyper-V, a type 1 hypervisor, which are basically the revenge of microkernels, virtualizing OSes and serverless language runtimes on top, is written in C++.

Linus hate on C++ is nonsense, especially after they adopted Rust, where most of his complaints against C++ are equally valid.

2

u/t_hunger 6d ago

Yes. If we had not been so annoying with our "rewrite your C project in C++" campaigning back in the day, we might have ended up with the Linux kernel being mostly C++ today. But we were super annoying as a community back in the late 1990s. I blame the strength of his reaction back then mostly to being super annoyed with us repeatedly nagging him to switch and ignoring his responses till it escalated.

2

u/pjmlp 6d ago

Well, the whole Rewrite whatever in Rust seems to be going rather well, including the Linux kernel, which was originally started by Microsoft and Google employees.

2

u/angel_devoid_fmv 7d ago edited 6d ago

If you'd actually consider what Torvards said you'd have an answer to your question.

You can also find loads of C++ hate in the interviews book "Coders at Work", specifically from Ken Thompson, who worked with Stroustrup at Bell Labs and had a hand in designing C. Stroustrup allegedly lost his shit at Thompson for Thompson complaining to, I don't remember specifically, an interviewer, that the C++ compiler he used at Bell seemed to change by the day, so that programs that worked one day were broken the next. A reasonable complaint to have if you want a peaceful and quiet life as a programmer IMO. Stroustrup took this as Thompson saying that C++ was a bad language.

But yeah, Thompson's criticism boils down to C++ being too much of an all purpose multi-tool/committee language that refused the demands of nobody.

2

u/Able_Development2478 6d ago

Not every language is useful for everything. There are legitimate usecases like explosion of technical debt when you use C++ in a project which does not need it. C++ code can become very complex over time and that can make it very difficult for project heads, etc. to reason about it if managed poorly and they i guess do not want the headache so you often see specific features being banned from use.

There's also stuff about perception that people build over the years. If you think from how long C++ has been there and how initally the standard was so slow in adopting features (C++11) you can see why people would be upset and hold onto the negative perception. Then there's the other segment of people who feel it's progressing so fast to keep up and then people who want changes which C++ committee doesn't answer. The list goes on and on.

I'd say do not worry about why someone hates C++ as it's just a tool. I don't think you'll be super angry if someone doesn't like using a nailgun and prefers to hammer a nail in XD.

1

u/abandoned_idol 3d ago

hammers in glue, splattering it everywhere

I feel so accepted.

3

u/Tamsta-273C 7d ago

Never ever i saw a man who really hate it, frustrated - yes, mad because miss semicolon - also yes, to the Hades all the linking - call me in.

But i never heard anyone to hate it for real.

Look up Java boys if you wish to learn what true hatred is.

3

u/ilPlayerdiGD 7d ago

Ok! I will check out (for real). I'm curios šŸ˜‚

3

u/CletusDSpuckler 7d ago

It all depends on where you hang out. You think there's any love lost for Java in this sub?

3

u/Electronic_Tap_8052 7d ago

C guys like C because it can really only do things one way. There's no hidden function calls (ex deleters when things fall out of scope, operator overloading, etc). Like assembly, what you see is what you get.

But at the same time that's why I like C++. There are many ways to skin a cat and it lets you hide implementation details behind a clean, foolproof interface.

Can it be abused? Sure. All tools can be. But so can C. C forces you to have raw pointers which almost always leads to subtle bugs later on unless you are very diligent about memory management and and lifetimes.

1

u/serviscope_minor 3d ago

>C guys like C because it can really only do things one way.

I've often heard such a claim put forward by proponents of a language they say is "simple". I really don't understand it, I will admit. In every language I've ever used there are loads of ways of doing everything. That's one of the joys of programming after all: the world is at your fingertips. See also the "zen of python". What it usually ends up meaning to me is (pithily) "if you are terminally online, then there are well known idioms for quite a few things".

2

u/Resident_Educator251 7d ago

There are only two kinds of languages, the ones people talk about, and the ones people don't use.

2

u/cfeck_kde 7d ago

If you really want to know why people hate C++, you shouldn't ask in a C++ forum.

2

u/TheRavagerSw 6d ago

People write posts like that never actually worked on a C++ project

3

u/gfoyle76 7d ago

it's not hated, you are in the wrong company

2

u/Technical_Introvert0 7d ago

Because it's not abstracted like Java and because it's useful

1

u/ilPlayerdiGD 7d ago

AHAHA!

1

u/Technical_Introvert0 7d ago

The people that hate c/cpp the most are java devs.. because C++ is way more useful in every way

2

u/pjmlp 6d ago

You know that Java is younger than C++ and based on how famous C++ GUI frameworks like OWL, VCL, MFC and PowerPlant used to be like?

Also that the famous patterns book was full of Smalltalk and C++ examples, Java was several years away to be invented.

1

u/Technical_Introvert0 6d ago

Who doesn't know Java is young.. java is like 17-20 youngers than C++ šŸ˜‚šŸ˜‚..

2

u/balefrost 7d ago

C++ and Java are both fine languages that serve different purposes. When I write C++ day-to-day, there are things that I miss from Java. Likewise, if I were to work in Java, there would be things I would miss from C++.

1

u/Technical_Introvert0 7d ago

I miss nothing from Java.. at all..java just looks more confusing for no real benefits except code that ships across OSs...

4

u/balefrost 7d ago

Fair enough, maybe your use case wouldn't benefit at all from Java. Like I said, the languages serve different purposes.

Things that I miss from Java:

  • Co- and contra-variant generics
  • Reflection (though it's coming to C++, and we'll be able to use it eventually)
  • Fast build times
  • No need to maintain separate header files
  • No need for forward-declaration or careful ordering of symbols in your file
  • Dynamic bytecode generation. I worked on a project where we did generate bytecode at runtime and loaded it into our own process, using a child classloader. I'm not saying that you can't do self-modifying code in C++, but it's directly supported in Java, whereas it would require implementation-specific support in C++.
  • C++ smart pointers have really solved a lot of memory management issues, but you do still have to worry about lifetime issues. GC in Java lets you mostly ignore memory issues.

4

u/segv 7d ago

Don't forget about decent package management, being able to easily find & use libraries for even super niche things (parsing excel/xlsx/xssf files by hand is not fun, ask me how i know), being able to quickly get a prototype out of the door that can grow into a full fledged production application (looking at you, spring boot), or just language features like immutable records, pattern matching or built-in first-class green(virtual) threads. I know it goes contrary to the narrative, but there's plenty of stuff it has going for it.

0

u/ilPlayerdiGD 7d ago

C++ is like the programming language that can do anything! Game, language, servers… Am I right?

1

u/Technical_Introvert0 7d ago

Yes.. C++ is C but with the same high level features Java has except garbage collection.. basically C++ is the best of both worlds.. depending on what compiler you use , you can even have access to inline assembly inside of C++.. C too..C++ and C (90% the same thing) is what you use to make other programming languages.. Java and Python are C/C++ underneath...

You can write high level code with classes and objects in cpp but also write strictly low level code that runs below the OS layer...java and every other high level language can't do that.. no jvm runs on bare metal...

Your BIOS is C/C++ ...so is code for robotics that runs on embedded systems...

0

u/angel_devoid_fmv 7d ago edited 7d ago

Java is dogshit too ackshually. There are many programming languages apart from C++ and Java. Java is a sort of adulteration of C++'s worst idea, that of statically typed object orientation. You can do a lot better than C++ and by extension Java.

1

u/CheesecakeTop2015 1d ago

can I use C++ for fun in peace?

Of course.
Don't waste time worrying about people who don't agree with you, know your arguments, be curious about their arguments, draw your (temporary) conclusions that work for you and accept there are many differing opinions out there, some more informed/valuable than others.

1

u/fortsnek274 7d ago

Well, there's certainly a laundry list of grievances.

1

u/Wild_Meeting1428 6d ago

linus torwalds is using c++ himself for his private stuff. He doesnt hate it. Its the developers which are missusing c++ in a way that it may become unmaintanable or hard to review. Adding another language was not worth at the time the decision was made. Rust is accepted, because it cherrypicked the best of C++ while leaving the opiniated stuff out / took another approach. Like exception free, memory safe by design, no dynamic polimorphism via RTTI, other approach for templates and comcepts (traits and impl)....

C++ is catching up tho.

1

u/C00CKER 7d ago

Some people may hate it, but there are areas that run almost exclusively on C++; e.g., high-performance computing.

It is hated mostly by people who don't really use it for anything or by people who know only some super-old legacy code.

What is somewhat true is that, due to how old it is, some design decisions are not ideal and there are many features that exist but shouldn't be used.

However, memory management in most use cases of modern C++ shouldn't really be an issue; you shouldn't manage memory manually unless you need to for some specific (performance-related) reasons.

1

u/neppo95 7d ago

Use what you want to use. In terms of companies, they (should) use what is best for their purpose. Sometimes that is C++, most of the times it simply isn’t. It’s not about hate, at least not to 99%

0

u/Powerful_Attention_6 7d ago

I too love C++ but you really need to know your stuff, because C++ has very long rope it offers to hang yourself

And the new C++ standards has become so complex that you can take an actual PhD in it

However, if you are in a position to select your favorite/good subset of C++, then that language can help enormously in writing safe code that is easy to discuss

-1

u/Existing_Ratio_957 7d ago

C++ is god but for the industry is prefered something that is consider more "stable", the industry that i know uses c++ in majority is game industry for development purposes, but at the end it doesnt matter the language you program just do it with passion! You dont need the others like something you like.

1

u/ilPlayerdiGD 7d ago

"The language it's just a tool", got it!

-2

u/Technical_Introvert0 7d ago

C++ is literally like giving someone who's never driven a vehicle a car and telling them to figure it out.. if they crash and die oh well.. if they learn how to drive from that then great ... There's 0 safeties with C++.. literally.. in other languages like Java you can't run uninitialized variables like a+b=c without specified values.. you can in C/C++ and it will give you random garbage.. in java/python you are prevented from writing the same thing twice to be used differently outside of a class or rather naming conflicts..

In C++ nope.. it will use the 1st specified value of that variable until it reaches the next specified value of something named similarly but used for a different thing.. and still compile without error codes.. to of course give you garbage outputs...

C++ is God mode.. you create with C++.. then you manage your creation with abstracted languages like Java or Python.. but you better know what you are doing otherwise you will build an app that stays in the background eating RAM despite being closed like me.. java and others make this hard..

C++ makes making a virus or malware easy whether you intended to or not.. very easy to make something that is catastrophically dangerous to a system in C++. PS, stay away from malloc until you have 6 years of experience coding in C++...

This is part of why people don't like it...they just can't understand it well because it requires an understanding of the hardware you are coding for...it's not some high level crap like Java although it can be

-1

u/AutonomousOrganism 7d ago

The power of C++ brings a lot of complexity with it. As Stroustrup said "Within C++, there is a much smaller and cleaner language struggling to get out".

Another more practical issue is that the c++ standard library is not stable.

-2

u/makmanos 7d ago

I am not sure "hated" is accurate. However building and maintaining production level stuff in C++ is not "cheap" or "fast" or "easy" while there are alternatives, and absolute speed is not a critical factor in what you need to build. That's as far as the "industries" in general is concerned.
Not sure about the Linux kernel though.

-2

u/bukuzoski 7d ago

C++ is extremely fast but to achieve that its doing memory alignment(unpredictable at some times) and therefore not suitable for kernel development. As far as I know no one hates it (apart for the people that complain that is hard or big, which in that case, you shouldnt listen to them)

P.S: there are also more reasons to it but biggest problem for Linus was that, as far as I know.

-3

u/[deleted] 7d ago

[removed] — view removed comment

2

u/khaled-Ahmed-- 7d ago

If you are right, why is HFT Engines built only with C++ ? C++ is faster and better on everything.

0

u/segv 7d ago

Funnily enough there's at least a couple of HFT engines built with Java ;) The juicy stuff is obviously private (they make money off it after all), but I believe Peter Lawrey had a couple of talks outlining how it is done.

(if i recall correctly they avoided allocations on the transaction processing path, which while was annoying the boost in developer velocity paid off)

1

u/KAMEHAMEHAMEHAAAA 6d ago

That is because contrary to popular belief most HFT doesn’t need to be that fast.

When speed actually matters, you aren’t even reaching for C++ or being careful with allocations in hot paths written in some GC language or anything that touches the CPU, instead you are opting for FPGAs.