[ prog / sol / mona ]

prog


Does C/C++ still make sense?

1 2022-12-13 20:09

People keep saying "C/C++" to treat the two languages as "basically" the same. I know that C++ has some C at its core, but from what I have seen, at least in its actual use, C++ has diverged so much that it makes zero sense to group them together.

2 2022-12-13 21:11

I think so, yes. C++ is still a strict syntactic superset of C.

3 2022-12-14 06:42

>>2
Syntactic only, yes.
https://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

4 2022-12-14 08:16

>>2
So do you call our favourite language LambdaCalculus/Scheme too?

5 2022-12-15 06:39

>>4
Neither Scheme nor Lisp ever had anything to do with lambda calculus.

6 2022-12-16 00:02

The C++ language is close to a superset of C, but the culture of C++ programmers is completely different. It's considered bad style to use most of the C subset. And you can argue it's just to compete with Rust, but if code gets past the Core Guidelines checker it's mostly memory-safe.

Time will tell, but I suspect C++ with Core Guidelines could be "good enough", hence superior to Rust in the Gabriel "Worse is Better" sense. For $DAYJOB, developing products with security requirements, C isn't really in the running because it's inhumanly hard to use in this domain.

7 2022-12-16 02:14

>>6
Would be happy to use C++ for systems programming once they figure out next steps.

In fact I've sought out a systems programming language to learn for the past couple of weeks, only to conclude that it's incredibly difficult to just choose something.

Would be nice to have a functional flavor to it though.

Out of some vendetta I refuse to use Rust though.

So it's currently between using Zig or Odin.
Ultimately it's out of a desire to create my own game (engine and all for an amusing exercise).

8 2022-12-16 07:20

>>7
There's no such thing as a "systems programming language", it's a meaningless marketing term. And having a vendetta against a programming language? Are you twelve years old or something? Why are programmer so superstitious?

9 2022-12-16 07:34 *

Honestly, you would think that a field where most practitioners call themselves "engineer" would be less divorced from reality. Of course most of those "engineers" have done nothing to deserve the title, but still, you need logical thinking and reconciling lots of small details for programming, right? That surely counts for something! But every time I visit a forum dedicated to programmers it is full of imbeciles who keep parroting stale memes that are obviously false to anyone who worked a single day in the field. It's like the whole internet is stuck in the "we conjure the spirits of the computer with our spells" phase where reciting the correct string of words is the key to success.

10 2022-12-16 10:57

>>7
Not sure what "next steps" are. Probably because it's so widely-used in industry, I always thought C++ was reactionary, e.g. the Core Guidelines could be just a response to Rust's popularity.

Modern C++ design style has really gone away from the OO stuff and more towards functional, with lambdas, iterators, the STL algorithms, etc. You can always just play around with simple stuff to start--there's a good book "Accelerated C++" by Koenig and Moo which is a bit old, but gives a good foundation. And after finishing that you'd know enough to catch up to C++20 & Core Guidelines by yourself.

I wouldn't call it a vendetta, but there is a risk to using Rust. I work in a diverse company, some of my colleagues although staying within the law hold fairly National Socialist or Fascist opinions. This could mean that you are blacklisted and get no support from the Rust maintainers.

Human lifespan is finite, so I'm trying to limit learning new languages for personal interest to those with something like an ISO standard. Haven't looked at Zig & Odin, but have learned some Go (for money) and Rust (since it has a brand-new language spec). Totally up to yourself if it's only for hobby reasons, and no money.

If it's only for fun, fire away with developing both a game and an engine (C++ & Lua are definitely still the most popular languages in this domain). But I've heard if you want to actually finish anything, you need to pick either the engine or the game.

11 2022-12-17 04:24

>>11
By "next steps" I meant that there seem to be some pending movements to make C++ practical, less footguns. Migrating away from OO, like you've shared, sounds enticing.

I may give your book a shot, thanks for recommending.
If you have any popular C++ repos that are written in the modern C++ design style that I could reference, I would enjoy looking through them.

I'm not that versed but from what I read there are some pending developments for https://en.wikipedia.org/wiki/C%2B%2B23 and there's also some novel stuff, like https://www.circle-lang.org/ or https://github.com/hsutter/cppfront

From what I read elsewhere, there are so many ways to do something in C++ and plenty of footguns that you only acclimate to by osmosis it seems. This is what makes the languages I referenced attractive as there's only one way to do things.

You're right on the game engine vs game aspect. But I found the background of CaveStory inspiring (where one guy wrote the engine and the game) -- Maybe game engines are excruciatingly boring or obnoxiously complex to implement, but I think building a game from scratch has some unseen benefits. Just knowing how everything works sounds satisfying.

What do you mean by "brand-new language spec" w.r.t. to Rust?

12 2022-12-17 15:13

>>11
I think the "next steps" you want are basically complete, so not really "next" any more. Use the Core Guidelines and their checker tool. The idea here is that this will force you to rewrite old unsafe C-style code to modern C++ and hopefully avoid most of those footguns.

As has always been the case, most C++ code is written inside corporations with a proprietary license. But https://github.com/scylladb/seastar is an interesting open-source project, albeit probably too advanced for beginners. Maybe https://github.com/RainerGrimm/CppCoreGuidelines or https://github.com/LearningByExample/ModernCppCI to start? I don't know, I didn't read a lot of code, I just started writing simple code myself, then reworking it to get past the checker.

cppfront is very interesting to me, but not suitable for commercial use (the NC part of the license). So I'm just keeping an eye on it for now.

For the Rust spec, I was talking about https://spec.ferrocene.dev/

13


VIP:

do not edit these