News for hackers. Stuff that matters.
Re:Google Launches Carbon, an Experimental Replacement for C++ by robmccoll on Monday July 25, 2022 @09:54AM (#32224310)
I'm probably just biased, but to me the problem with modern C++ is its complexity. The mental model of the language, its syntax, and the amount of history / number of interfaces a programmer needs to be familiar with to be productive are all too large. Rust isn't any more complex, but it's not radically simpler either. Carbon doesn't look like it solves this problem. It would seem that creating a language that is expressive, performant, and small while still general purpose is quite a challenge.
Re:Google Launches Carbon, an Experimental Replacement for C++ by pkolaczk on Monday July 25, 2022 @10:00AM (#32224410)
> Rust isn't any more complex, but it's not radically simpler either.

Safe Rust doesn't have classes, inheritance, copy constructors, move constructors, header files, preprocessor, textual substitution macros, code executing before main(), exceptions, global variables, pointer arithmetic... Looks radically simpler to me.

Re:Google Launches Carbon, an Experimental Replacement for C++ by epicide on Monday July 25, 2022 @10:18AM (#32224633)
In general, I think it's easy to conflate simplicity with ease. Ease is always a matter of context and what one is familiar with.

I agree that Rust is simpler than C++ and I think a lot of people mean that Rust isn't easier (up front). Given how new and different it can be, that makes sense.

Re:Google Launches Carbon, an Experimental Replacement for C++ by htyden on Monday July 25, 2022 @11:34AM (#32225839)
Obligatory Rich Hickey plug: https://m.youtube.com/watch?v=SxdOUGdseq4
Re:Google Launches Carbon, an Experimental Replacement for C++ by moomin on Monday July 25, 2022 @01:39PM (#32228029)
That’s a great talk, but you have to wonder what that era Hickey would have made of overloading arity on list operations the way modern Clojure does.
Re:Google Launches Carbon, an Experimental Replacement for C++ by sudosysgen on Monday July 25, 2022 @11:01AM (#32225309)
Instead Rust has a borrow checker, procedural macros of different types, half a parallel language when using unsafe, etc...

And by the way, Rust does have pointer arithmetic.

It's not clear to me that either is simpler or easier. The big point of Rust is really memory safety, not ease of use or simplicity.

Re:Google Launches Carbon, an Experimental Replacement for C++ by tialaramex on Monday July 25, 2022 @01:43PM (#32228090)
Rust's slogan is: "A language empowering everyone to build reliable and efficient software."

Now, that "everyone" there has a bunch of social consequences, like you're going to see a bunch more diversity in Rust's community than we've traditionally seen in this sort of endeavour. But it also means technically there's work put in to actually deliver on the slogan by making it easier for everyone to use the language.

This is how Rust has those excellent compiler diagnostics. That's not an accident, it's part of "empowering everyone". Experts could manage with a compiler that outputs terse errors like "Syntax error, line 14" but that's not going to empower everyone.

Re:Google Launches Carbon, an Experimental Replacement for C++ by moomin on Monday July 25, 2022 @01:46PM (#32228161)
Yes, but C++ isn’t complex because it set out to be complex, it’s complex because they’re constantly trying to enhance it whilst maintaining backwards compatibility with a system that was originally basically just a big set of CPP macros.

Rust has a heck of a lot of features, but it’s got nothing like the “too perfect forwarding” problem of the language behaviour just being plain hard to predict.

Re:Google Launches Carbon, an Experimental Replacement for C++ by pitaj on Monday July 25, 2022 @11:51AM (#32226146)
Rust doesn't have pointer arithmetic in the same way that C and C++ do. All you can do with pointers in rust is offset them.
Re:Google Launches Carbon, an Experimental Replacement for C++ by al_mandi on Monday July 25, 2022 @01:55PM (#32228314)
Why are classes automatically somehow assumed as complex? Rust's structs are basically classes without class inheritance.
Re:Google Launches Carbon, an Experimental Replacement for C++ by zahllos on Monday July 25, 2022 @06:47PM (#32231975)
The idea of classes on their own isn't complicated. The problem is that C++ provides an extreme amount of flexibility in how you use them.

You can have multiple inheritance. You can have as many levels of partially implemented, partially abstract classes as you like provided you eventually have a concrete class, and these abstract classes can have member data. You can have static methods, which I've seen abused as namespaces so often. You can have static methods and non static ones in a class hierarchy. Finally you can mix templates into this.

In an ideal world the developers of a project in a company would collaborate to keep this from getting out of control and enforce a relatively consistent philosophy. However in practice people have their quirks and specific not always rational views, and programmers are in general not always the best at dealing with other people, programmers included.

So a strong personality is determined to do it one way and refactors a bunch of code to their liking, and on and on, and now a variety of features have been used in different ways.

No language is immune to this as it is fundamentally a human problem, but taking out features generally helps. Since we can get by without inheritance most of the newer languages have done away with it.

Re:Google Launches Carbon, an Experimental Replacement for C++ by learn-forever on Monday July 25, 2022 @05:23PM (#32231122)
Dealing with inheritance is pretty complex!
Re:Google Launches Carbon, an Experimental Replacement for C++ by al_mandi on Wednesday July 27, 2022 @06:55PM (#32258133)
Rust has traits (similar to interfaces). And limiting to single inheritance like Java/C#/etc. makes things quite manageable.
Re:Google Launches Carbon, an Experimental Replacement for C++ by fooker on Monday July 25, 2022 @01:01PM (#32227326)
“Make things as simple as possible, but not simpler.”

Rust lacking some of these makes it a somewhat unfriendly language to write libraries in.

Re:Google Launches Carbon, an Experimental Replacement for C++ by jandrewrogers on Monday July 25, 2022 @11:52AM (#32226180)
It is difficult to tell sometimes due to its religious backward compatibility, but C++ has been becoming significantly less complex over time. I have a large C++ code base (originally hundreds of thousands LoC) that I aggressively modernize, essentially rewriting it idiomatically in new versions of C++. It was originally written in C++0x/C++11, rewritten in C++17, and is currently being rewritten in C++20. You can barely tell the code bases are related beyond being functionally similar.

It is also important to separate C++ the language from its standard library.

As C++ the language has modernized, it has dramatically reduced the lines of code to express a given thing. And the more modern way of expressing the thing has stronger type safety, more flexibility, and better composability. Things that used to require a lot of template metaprogramming magic to pull off are now clean one-liners. Particularly in C++20, which is probably the biggest step-change since C++11, metaprogramming is simultaneously much more powerful and much more readable. A lot of code that used to be written is now metaprogrammed. Previous use cases that required C macros largely have native C++ equivalents at this point.

The major issue that makes C++ seem complex is the standard library, which was largely designed and written for legacy versions of C++. If you use the standard library heavily, it tends to want to be used in the style of C++ for which it was originally written. If you built a standard library for C++20 from first principles, it would look quite different from the one we have. Hence the proliferation of non-standard "standard" libraries for C++.

Re:Google Launches Carbon, an Experimental Replacement for C++ by kinjba11 on Wednesday July 27, 2022 @12:27AM (#32246844)
> You can barely tell the code bases are related beyond being functionally similar.

Not sure if you've missed this, but this is a number one reason many consider C++ absurdly complex. To actually know C++ is to know many different similar languages based on the year the code was written. C++20 is very different than C++03 as noted. Now compare this with C, or Go, Java, etc. which in comparison have barely changed.

Re:Google Launches Carbon, an Experimental Replacement for C++ by flakiness on Monday July 25, 2022 @08:07PM (#32232640)
> Hence the proliferation of non-standard "standard" libraries for C++.

Any examples for this? My knowledge stopped at boost and I guess there are more.

Re:Google Launches Carbon, an Experimental Replacement for C++ by flakiness on Monday July 25, 2022 @08:07PM (#32232634)
I'm not sure your code is simplified either because of the modern features of C++ or because of the rewrite.

That said, I like the idea of rewriting old C++ code with modern C++. That'd be also a good way to learn modern C++ in a practical way and having legacy code serves well for this context ;-)

Re:Google Launches Carbon, an Experimental Replacement for C++ by gpderetta on Monday July 25, 2022 @10:54AM (#32225203)
A language in the niche of C++ is always going to be complex (see rust), although possibly not as complex as C++.

I think that Carbon is not meant to be 100% backward compatible at least at this point, so they can iteratively try to smooth the rough edges of the language.

Re:Google Launches Carbon, an Experimental Replacement for C++ by 2c2c2c on Monday July 25, 2022 @11:57AM (#32226249)
This seems to be a very hard idea to convey to people. Zig is on the opposite extreme-- the mantra being "There must only be one way to do something". Ergonomics and simplicity seem to be overlooked aspects of programming language design
Re:Google Launches Carbon, an Experimental Replacement for C++ by dzonga on Monday July 25, 2022 @09:57AM (#32224365)
to me that's the greatest benefit of C++ and hence why it's so successful.

it's kitchen sink language.

choose what features you want.

choose your own style. you wanna do OOP | DOP suit yourself.

that versatility is why C++ is unmatched in terms of where it's deployed.

Re:Google Launches Carbon, an Experimental Replacement for C++ by est31 on Monday July 25, 2022 @10:38AM (#32224932)
That's great if there is one developer working on each component of the software. The moment you have people trying to do cross-component changes, or developing someone else's component, they don't just have to learn how the code works on a domain level, but also the features of the language the code is using.
Re:Google Launches Carbon, an Experimental Replacement for C++ by robmccoll on Monday July 25, 2022 @10:03AM (#32224448)
The more recent editions of C++ do seem to support this idea. Things are at least better than when the trade off was taking advantage of C++ features (and more C++ like) or performance (and more C-like C++). The problem that there are only a handful of people who could realistically claim to be experts in C++ has gotten worse over time as the language has expanded though. It's a language where you potentially have to train new C++ programmers that join your team in how your team uses C++.
Re:Google Launches Carbon, an Experimental Replacement for C++ by cute_boi on Monday July 25, 2022 @10:54AM (#32225194)
Well upto certain limits versatility is important. But, being too versatile also brings more complexity and it makes language confusing. I read more code than I write, so this versatily is not good for people like me.
Re:Google Launches Carbon, an Experimental Replacement for C++ by BitwiseFool on Monday July 25, 2022 @11:41AM (#32225941)
Isn't the 'kitchen sink' approach what ended up causing Perl to fade from relevance? I am only casually aware of this, and I may be totally misremembering things, but Perl used to be seen as a swiss army chainsaw but people eventually came to realize that maintenance was a nightmare.
Re:Google Launches Carbon, an Experimental Replacement for C++ by fractalb on Monday July 25, 2022 @11:55AM (#32226228)
Perl faded away because there was an alternative (Python) and it was not a kitchen sink. For C++, there's no alternative at all. People have to bear with it.
Re:Google Launches Carbon, an Experimental Replacement for C++ by robmccoll on Monday July 25, 2022 @01:02PM (#32227354)
I think Python's original take on kitchen sink was relatively small language with large "batteries included" standard library.
Re:Google Launches Carbon, an Experimental Replacement for C++ by kasabali on Monday July 25, 2022 @12:16PM (#32226532)
Ironically Python is now fast approaching the kitchen sink status.
Re:Google Launches Carbon, an Experimental Replacement for C++ by pornel on Monday July 25, 2022 @08:17PM (#32232718)
From my webby perspective mod_php has been the Perl killer, and PHP isn’t known for being lean either.
Re:Google Launches Carbon, an Experimental Replacement for C++ by rkangel on Monday July 25, 2022 @10:59AM (#32225280)
It's not inheriting the complexity though. That's sort of the whole goal - the next 'generation' of C++ that can be used interchangeably with actual C++ but allowing re-visiting most of the design decisions and throwing out old features.

The Github Page[1] says this: "The best way to address these problems is to avoid inheriting the legacy of C or C++ directly, and instead start with solid language foundations like modern generics system, modular code organization, and consistent, simple syntax."

[1] https://github.com/carbon-language/carbon-lang

Re:Google Launches Carbon, an Experimental Replacement for C++ by klaussilveira on Monday July 25, 2022 @10:58AM (#32225265)
You can choose to be simple, expressive, performant and small with C++: https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b