Live data from Hacker News

Carbon’s most exciting feature is its calling convention

foonathan.net

1–10 of 223 posts

Re: Carbon’s most exciting feature is its calling convention

#4
I was very confused by what the author is pointing out in the opening Point / Print example. ("[T]he compiler is allowed to convert that to a T" -> wait, why did the compiler change a struct to an int32?)

I think this boils down to: Carbon defaults to passing parameters that fit in a single register by value, and all others by const reference. This affects a few things you might take for granted in C++, like whether you can take a reference to a parameter.

The opening example is showing two samples of Carbon and the equivalent C++ code, noting that the "undecorated" parameter `p : Point` is equivalent to `const Point& p` (pass by const reference to a struct) and `x : i32` is equivalent to `std::int32_t x` (pass by value).

Re: Carbon’s most exciting feature is its calling convention

#5
post #3
post #2

At first I thought this was about Mac OS around the 9 and 10 times... but I suppose not everyone is going to make that link with this name.

You’re certainly not the only one. It’s a confusing choice of naming.

I think the statute of limitations on “confusing name” when Mac OS Carbon was removed from OS X 10 years ago has passed.

Re: Carbon’s most exciting feature is its calling convention

#6
I really think the most exciting feature of Carbon (indeed, it's justification for existence) is its backwards compatibility with C++, followed closely by it's more modern and flexible governance structure. Even the docs in the repo say you should avoid Carbon unless you have lots of C++ code you need to interact with.

Re: Carbon’s most exciting feature is its calling convention

#7
post #3
post #2

At first I thought this was about Mac OS around the 9 and 10 times... but I suppose not everyone is going to make that link with this name.

You’re certainly not the only one. It’s a confusing choice of naming.

I hope they picked that name for the same reason Apple picked it: because all life is built on carbon.

Re: Carbon’s most exciting feature is its calling convention

#8
post #5
post #3

Earlier quoted context omitted.

You’re certainly not the only one. It’s a confusing choice of naming.

I think the statute of limitations on “confusing name” when Mac OS Carbon was removed from OS X 10 years ago has passed.

Carbon was removed two years ago.

Re: Carbon’s most exciting feature is its calling convention

#9
That's been done before. The original Modula 1 compiler had that. In a language where the default parameter mode is a read-only reference, it's an obvious optimization.

The reverse is true. Anything passed by value can be treated as const reference by the compiler if the compiler knows enough about access and lifetime. The compiler must be able to determine that the parameter is neither deallocated nor modified while the function is using it. Rust compilers should be able to do that.

Re: Carbon’s most exciting feature is its calling convention

#10
post #2

At first I thought this was about Mac OS around the 9 and 10 times... but I suppose not everyone is going to make that link with this name.

Apple's Cocoa framework itself reused the name of a 90's visual programming language for kids developed by its own Advanced Technology Group. It was certainly a play on "java for kids."

https://en.wikipedia.org/wiki/Stagecast_Creator

Post reply on HN