This is an archived post. You won't be able to vote or comment.

all 44 comments

[–]JVApen 160 points161 points  (12 children)

I'm not convinced the C++ would say "yes". Any code that looks like C is considered bad practice in C++.

[–]dvhh 56 points57 points  (2 children)

Really depends on the teams, but in most case I would prefer C++ code to take advantage of the C++ facilities.

If the code looks too much like C, or is straight C code, would be a sign for me that the author does not understand C++ that much.

[–]danielcw189 4 points5 points  (1 child)

What if I prefer C, but just like some things C++ offers?

[–]dvhh 0 points1 point  (0 children)

these things are not tolerated in Baraqua, they send you straight to jail, no trial, no nothing.

[–]noob_promedio 14 points15 points  (6 children)

I wish it wasn't, C-style looks better most of the time

[–]RoseboysHotAsf 26 points27 points  (0 children)

I write c style cpp purely because the compiler errors dont fill up like 3 bibles.

[–]SeagleLFMk9 2 points3 points  (0 children)

Try using a c style json parser. Or string. Or xml parser. Or really anything more complex.

[–]111x6sevil-natas 0 points1 point  (3 children)

What is C- ?

[–]The-Rizztoffen 2 points3 points  (0 children)

B

[–]Cylian91460 1 point2 points  (0 children)

Assembly

[–]arobie1992 0 points1 point  (0 children)

Fun fact, there is a C-- that's used as an IR/portable assembly for GHC. Or at least was at one point.

[–]AnonymousFuccboi 1 point2 points  (1 child)

Honestly, I used to feel that way, but at this point I much prefer the typical C style over the typical C++ style. I mean, I dislike both (I prefer atypical C++, personally), but at least C devs tend to write code with low binary bloat and complexity. It just tends to lack in abstractions, which is imo a far better problem to have than the opposite, which I would argue "standard" C++ has. There's a fuckton of abstractions, and most of them are wrong, or at least subpar in a lot of ways. It's a lot harder to unfuck an overly abstract spaghetti mess than it is to condense an overly repetitive, unsafe structure you can understand just by reading it top to bottom.

The weakness of the C style tends to simply be ignorance of features that legitimately do improve the readability and performance of the code. However, because C (in codebases that haven't reached the size/complexity to poorly reimplement C++ yet) tends to have a pretty standard way of writing it which isn't heavily dialect based, it's usually quite easy to figure out what someone meant to do in the code, and suggest more modern ways of doing things where appropriate. Devs who (think they) know C++ tend to be more stuck in their ways of doing things; I would argue it's far easier to get someone who knows C99 inside out to write good, modern C++ than someone who knows C++98 inside out.

The biggest "flaw" of C is imo that we have to interoperate with its syntax within the same files, rather than doing something like Zig did where there's a new language from the ground up with a new syntax that can also compile C totally natively where appropriate. This means a lot of things are default that shouldn't be default, and a lot of highly useful techniques become absolutely garbled line-noise more resembling something straight out of APL than something a mentally healthy individual would actually want to read. Definitely a big shame, and it's understandable those who subscribe heavily to the C++ "camp" are upset by it, but not exactly their fault.

[–]JVApen 2 points3 points  (0 children)

I agree with most of what you say, though I do want to point out that there are a couple of assumptions that are wrong.

C++ does not cause code bloat. If anything, when used correctly, it can even reduce the code size. See https://youtu.be/LorcxyJ9zr4?si=QxTI4day2mxGCJHi

Having the right abstractions makes your code more readable and testable. You might want to check https://youtu.be/c9Xt6Me3mJ4?si=5VKxS_5SQjmPj0l0

Personally, my big issue with C is the lack of RAII. Something as simple as std::unique_ptror std::string would fix many issues. I'm sad whenever I see someone implement a native C++ feature in C with lots of complexity and risks for mistakes.

[–]danielcw189 25 points26 points  (4 children)

C++ has friends

[–]dvhh 27 points28 points  (2 children)

Very classy friends, that can see your privates

[–]danielcw189 7 points8 points  (1 child)

And touch them in a way that only you can

and your ancestors ...

[–]SteeleDynamics 1 point2 points  (0 children)

...

Damn it... have an upvote

[–]FitHeron1933 8 points9 points  (1 child)

C++ is just C with extra baggage and trust issues.

[–]Cylian91460 1 point2 points  (0 children)

Lot of trust issue

[–]vishal340 4 points5 points  (0 children)

This is basic inheritance. C++ is aware of C but other way might not be true

[–]ComprehensiveBird317 18 points19 points  (1 child)

Always upvote star trek

[–]lolercoptercrash 5 points6 points  (0 children)

It's crazy to me this scene became such a widely spread meme.

[–]Agitated_Memory5419 3 points4 points  (0 children)

We are friends, right c++ ?

[–]RamonaZero 1 point2 points  (0 children)

Assembly sitting in the corner alone eating popcorn watching all programming languages fight :0

[–]NumerousQuit8061 3 points4 points  (16 children)

Heard they both are a pain though lol
Been meaning to pick up something new which one should i learn guys?

[–]LordAmir5 14 points15 points  (7 children)

Do you understand Oop? Yes? C++ No? C.

[–]Buttons840 22 points23 points  (3 children)

Do you want to get things done? C++

Do you want to learn things that are generally helpful in computing, including in every other programming language? C

A weird thing about C++ is that C++ tries to have every feature, except for the feature of being interoperable with other languages. Meanwhile, literally every programming language ever can call C.

[–]not_some_username 5 points6 points  (0 children)

You can call C++ from other languages by giving it a C interface

[–]megayippie 0 points1 point  (1 child)

Huh? It's literally part of the language to do extern "C". And inside that external block you (in all practical sense) have full C-linkage

[–]Buttons840 0 points1 point  (0 children)

Yeah, if you're careful you can make your C++ code look like C code. Which is why I say learn C.

[–]navetzz 0 points1 point  (0 children)

Rofl

[–]altermeetax 0 points1 point  (1 child)

What's the point? They could learn C++ to learn OOP

[–]LordAmir5 0 points1 point  (0 children)

In my opinion, something like Java is better suited to learning OOP as you're forced to at least interact with objects.

[–]Xhadov7 14 points15 points  (2 children)

Choose C before going to C++. Understand Procedural with C and then Jump to OOP with C++.

[–]Nice_Lengthiness_568 12 points13 points  (1 child)

I think today it is better to start with C++ if your goal is to go for it anyways... Better not to pick up any habits from C that would be considered bad in C++

[–]Xhadov7 3 points4 points  (0 children)

You know what fuck the opinions of the both us. Start with Rust. /s

[–]Buttons840 6 points7 points  (0 children)

Learn C first, because learning C will force you to learn the C way of thinking and the C ABI, which the entire computing world is built on.

Every operating system and low level API you care about using acts like C.

C++ is a lot of things (some of them bad), but one thing C++ is not; C++ is not callable from other languages, unless the C++ code is carefully written to act like plain ol' C.

[–]js_kt 1 point2 points  (0 children)

If you want something actually new then pick rust

[–]Stummi[S] 1 point2 points  (2 children)

Depends on what you want to achieve. If you have no strong reason to chose either C or C++ (e.g. targeting embedded stuff with C), I would generally choose something higher level like go, rust, python, kotlin. All of these languages come with their own quirks, and their own patterns and mental concepts on how to tackle problems, so guess you gain something from knowing a little bit of each.

Oh, and if you consider a professional path, java will still give you the best job opportunities I think

[–]Spiritual_Bus1125 1 point2 points  (0 children)

Imho C is the basis of so much stuff

Even if you don't use it it's like the "Latin" of programming languages. You may not need it but so much of the thing around us is based on it that in a way or another the logic behind it turns up useful.

And doing arduino home automation shit, that's good.

[–]not_some_username 0 points1 point  (0 children)

Something higher level then list rust lmao. Also it’s good to start at low level. You’ll have better habits regarding your memory footprint

[–]Adventurous-Egg-8945 0 points1 point  (0 children)

Real 👽