←back to thread

155 points samuell | 3 comments | | HN request time: 0.775s | source
Show context
kjksf ◴[] No.44749375[source]
I think this page describes "what" but not "why" of Carbon.

Carbon exists so that it's possible to migrate a large C++ code base, like Chrome, from C++ to something saner, incrementally.

The most important attribute of Carbon is not the specifics of the syntax but the fact that it's designed to be used in a mixed C++ / Carbon code base and comes with tooling to convert as much of C++ as possible to Carbon.

That's what makes Carbon different from any other language: D, Zig, Nim, Rust etc.

It's not possible to port a millions line C++ code base, like Chrome, to another language so large C++ projects are stuck with objectively pretty bad language and are forced to continue to use C++ even though a better language might exist.

That's why Carbon is designed for incremental adoption in large C++ projects: you can add Carbon code to existing C++ code and incrementally port C++ over to Carbon until only Carbon code exists.

Still a very large investment but at least possible and not dissimilar to refactoring to adopt newer C++ features like e.g. replacing use of std::string with std::string_view.

That's why it's a rational project for Google. Even though it's a large investment, it might pay off if they can write new software in Carbon instead of C++ and refactor old code into Carbon.

replies(14): >>44749770 #>>44750227 #>>44750232 #>>44750657 #>>44751685 #>>44751728 #>>44752039 #>>44752523 #>>44752948 #>>44753844 #>>44754061 #>>44756351 #>>44758133 #>>44758430 #
justcuriousab ◴[] No.44754061[source]
> It's not possible to port a millions line C++ code base, like Chrome, to another language so large C++ projects are stuck with objectively pretty bad language and are forced to continue to use C++ even though a better language might exist.

One good aspect about C++ is its backwards compatibility or stability. Also a drawback, but companies not having to spend huge amounts of time, expertise and money rewriting their whole codebases all the time is something they appreciate.

Rust is often somewhat stable, but not always.

https://internals.rust-lang.org/t/type-inference-breakage-in...

https://github.com/rust-lang/rust/issues/127343

300 comments on Github.

https://github.com/NixOS/nixpkgs/pull/332176

Rust has editions, but it's a feature that it will probably take years to really be able to evaluate.

What kind of compatibility story will Carbon have? What features does it have to support compatibility?

replies(2): >>44755317 #>>44755983 #
1. pjmlp ◴[] No.44755317[source]
I can write C++98 or C++11 code that will fail in a C++23 compiler, because C++ also isn't 100% backwards compatible.
replies(1): >>44756672 #
2. justcuriousab ◴[] No.44756672[source]
But the changes required are generally significantly smaller and less frequent, right?
replies(1): >>44757909 #
3. pjmlp ◴[] No.44757909[source]
If the build breaks when changing the value of -std= (or equivalent), it hardly matters how big it is.