Live data from Hacker News

Carbon Language: An experimental successor to C++

github.com

341–350 of 521 posts

Re: Carbon Language: An experimental successor to C++

#341

(Speaking only for myself, I just watch from the sidelines and have no involvement) This seems like Google’s response to 1. Rust not being sufficiently “Go-like” (in the sense of the “The key point here is our programmers are Googlers, they're not researchers” quote) where C++ lets a bunch of people who are not really experts in the language write footguns that Google has to deal with when they cause problems at scal…

I work at smaller scale c++ than google and I found most of their proposals reasonable but undoable for practical reasons rather than first principles reasons. For instance compiler vendors who have a veto power over language changes strongly prefer not breaking ABI. ABI changes are fine if you build the world at every commit, but also if you don't have legacy. C++ users 200 years from now would most likely benefit from the things Google wishes it could do in the language but can't

Re: Carbon Language: An experimental successor to C++

#342

If you are like me and wondering "What makes carbon different from Rust or Zig? 1. The ability to interoperate with a wide variety of code, such as classes/structs and templates, not just free functions. 2. A willingness to expose the idioms of C++ into Carbon code, and the other way around, when necessary to maximize performance of the interoperability layer. 3. The use of wrappers and generic programming, including…

Nim is even better at that, as it generates C/C++ code natively and compiles it using GCC.

Re: Carbon Language: An experimental successor to C++

#343
post #35

From the end of the safety document: > Overall, Carbon is making a compromise around safety in order to give a path for C++ to evolve. C++ developers must be comfortable migrating their codebases, and able to do so in a largely automated manner. In order to achieve automated migration, Carbon cannot require fundamental redesigns of migrated C++ code. While a migration tool could in theory mark all migrated code as un…

I wonder what would happen if Security became a compiler flag?

For instance, just like the -O1 or -O3 flags work for optimization, something like a -S1 or -S3 would be really useful.

To me, there are lots of times when I just need to get an idea into code. Then there are times when I need to make sure that code just works™.

Having different compiler flags would really make that nice, and for devops, allow anything pushed to production have to complete a -S3 successfully first.

Re: Carbon Language: An experimental successor to C++

#344

No. No. No. This reminds me of Dart - another big company thinking they can invent a new language to tackle old language problems. This is not the way to improve C++ - because this path already exists, either as D or if compatibility or OO model isn't an issue, Rust. C++ has been improving slowly but surely - just remember that 90% (heck even more) of C++ issues stem from the hell that's compatibility with C and that…

Google is in the business of making software in exchange for money and they have internally determined that the way C++ is and the direction C++ is headed isn't good for them. They don't "care" about C++, they care about running a business. They have determined that C++ as it is isn't sufficient and the direction its going is not acceptable to meet long term goals, whether that be implementing new products or maintai…

Do you mind sharing a reference for the changed Google wanted to make to unique_ptr? I tried searching but couldn't come up with the right set of keywords to find anything relevant. TY!

Re: Carbon Language: An experimental successor to C++

#346
post #7

Earlier quoted context omitted.

It's std::vector that was weirdly named. In plenty of codebases "Vector", particularly gamedev and scientific, will mean the mathematical object with that name. Other languages don't need to replicate this mistake.

An std::vector is a vector in the mathematical sense, though. It's a homogeneous tuple. It's just that using an std::vector of std::vectors to store a list of points would be inefficient.

>An std::vector is a vector in the mathematical sense

No, because you can't prove that std::vector obeys all vector space axioms[1] for all T, which is good because it's impossible, I can trivially define a T that will break any number of axioms and the cpp compiler will happily let me instantiate std::vector on it.

[1] https://www.math.ucla.edu/~tao/resource/general/121.1.00s/ve...

Re: Carbon Language: An experimental successor to C++

#347

Earlier quoted context omitted.

The README doesn't expand on what is probably the most challenging problem: how do you achieve effortless C++ interop without burdening Carbon with all the odd behaviour and memory safety / UB issues prevalent in C++? In Rust for example, `unsafe {}` blocks are not just "local unsafety". They can freely operate on all memory, so they are infectious and are essentially a marker for "dangerous code below, be extra care…

C++ has many many issues other than memory safety. For example implicit type conversion, template duck typing, the include system, the very very very complicated name lookup system, a gazillion footguns inherited from C. You can definitely massively improve upon C++ without touching its actual computation model.

Starting by using a sane set of compiler flags to make code safer by default.

Re: Carbon Language: An experimental successor to C++

#348
post #280
post #252

Earlier quoted context omitted.

And if they named it “vector”, a developer familiar with mathematics might believe it to be a vector.

Which is not a footgun.

It actually can be, mathematical vectors gaurantee for example that x+y == y+x for all x,y, but no such gaurantee can be ever made on the user-defined operator+, indeed you can't even gaurantee that it is defined to begin with, let alone in the manner prescribed by linear algebra.

Re: Carbon Language: An experimental successor to C++

#349
post #344

Earlier quoted context omitted.

Google is in the business of making software in exchange for money and they have internally determined that the way C++ is and the direction C++ is headed isn't good for them. They don't "care" about C++, they care about running a business. They have determined that C++ as it is isn't sufficient and the direction its going is not acceptable to meet long term goals, whether that be implementing new products or maintai…

Do you mind sharing a reference for the changed Google wanted to make to unique_ptr? I tried searching but couldn't come up with the right set of keywords to find anything relevant. TY!

Its in this talk https://www.youtube.com/watch?v=rHIkrotSwcc

Re: Carbon Language: An experimental successor to C++

#350
Some quick notes about interesting features of the design:

* Source file encoding is required to be UTF-8. Strings are UTF-8. No apparent provision for binary strings, but I haven't delved into the string API.

* Retains the C/C++ definition of overflow of signed integers cannot overflow, unsigned can. That's o_O-worthy; the two should be aligned, and if they can't overflow, provide some form of wrapping integers as well.

* Yay, tuples.

* Struct type syntax is ... weird? {.name: String, .count: i32}

* Expressions. Partial order for precedence (i.e., a | b * var and let for declaring variables; one is constant, the other not--that's somewhat jarring. It seems that the : is mandatory, and inferred type is : auto instead of letting it be omitted? Feels unnecessarily verbose to me.

* No goto, nor labeled break and continue. Huh. Also, 'for (var name: String in strings)' is again feeling unnecessarily verbose... (Can break break out of an if statement, or does it have to be a loop?)

* You declare "returned var c: Circle" instead of relying on named return value optimization. Again with the verbosity, although I haven't yet reached copy/move constructor stuff to understand how much automagic happens.

* The [me: Self] syntax is weird. I'd like something closer to the C++ deducing this syntax or Rust's &self/&mut self, where the type of the this parameter is specified via the first argument rather than what feels like a somewhat-out-of-bounds information.

* Mixin (aka multiple inheritance) is unspecified at this point.

* The keyword for enums is "choice"? Really?

* Name lookup retains the C/C++ rules of need-to-declare-before-use. Again, is this really necessary? It's fiddly...

* The [me: Self] syntax appears to be a specific instance of the generalized syntax for generics, but only for method parameters, because generic types use () instead. Again, why differentiate from the C-family standard practice of for generics? Also, the : versus :! in generics strikes me as overdrawing the weirdness budget one too many times. Props for using something closer to a constexpr if than C++ SFINAE; SFINAE is not a design model I would carry forward in any future languages.

* Stable ABI appears to purely be defined in C ABI terms. Sigh, can we get people on these language committees together to start thinking about post-C standardized ABIs?

* Async, coroutine, lambda stories are unclear.

* Error handling also unclear. (That's kinda important!)

* Not clear from the main design document is how the distinction--if any--between trivial/nontrivial copy/move types work. There appears to be an explicit move operator (with obvious syntax ~x), so support for nontrivial move or immovable is better than Rust already, but the avoidance of a NRVO setup still makes me wonder what the actual story is here.

Post reply on HN