←back to thread

155 points samuell | 1 comments | | HN request time: 0.208s | 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 #
philwelch ◴[] No.44750232[source]
Zig is designed to interoperate like this with C, and Kotlin with Java.
replies(1): >>44751544 #
nielsbot ◴[] No.44751544[source]
...and Swift w/ Obj-C
replies(1): >>44752421 #
gilgoomesh ◴[] No.44752421[source]
Swift can also 2-way operate with C++. Its coverage of the C++ language is incomplete but I suspect it might outpace Carbon.
replies(2): >>44752829 #>>44752967 #
troad ◴[] No.44752967[source]
I really struggle to imagine an organisation that shepherds a large and venerable C++ codebase migrating over to Swift.

For all of C++'s faults, it is an extremely stable and vendor-independent language. The kind of organisation that's running on some C++ monolith from 1995 is not going to voluntarily let Apple become a massive business risk in return for marginally nicer DX.

(Yes, Swift is OSS now, but Apple pays the bills and sets the direction, and no one is seriously going to maintain a fork.)

replies(3): >>44753405 #>>44755315 #>>44764120 #
philwelch ◴[] No.44753405[source]
Maybe not, but an Objective-C++ codebase might be a good candidate.
replies(1): >>44754738 #
volemo ◴[] No.44754738[source]
Do you have projects with huge code bases of Obj-C++ in mind?

I guess, some Mac apps? In that case I think most platform independent "guts" would be in C or C++, and the Obj-C++ part is tied to the frameworks, so the devs would have to rewrite it anyway.

replies(1): >>44764118 #
1. saagarjha ◴[] No.44764118[source]
Facebook iOS