Earlier quoted context omitted.
> The other safe languages have explicitly taken the view the interop with C++ is bad I think it's more that interop with C++ is hard and ultimately a lot less valuable than interop with C, which is what the vast majority of languages use for FFI. > It doesn’t matter how “safe” your language is if the first thing you have to do is make a pure C (even losing potential for automatic lifetime management the C++ would al…
If you consider the context of Carbon (Google having a _lot_ of C++), solving for "interop with C++ is hard" might be considered worth the price. Whether that's true in practice...? I guess we'll need a few more years to tell.
Carbon’s most exciting feature is its calling convention
71–80 of 223 posts
Re: Carbon’s most exciting feature is its calling convention
#72Earlier quoted context omitted.
That's a buffer overflow. The optimizer doesn't need to reason about changing the behavior of such things.
The point is that on systems where that code returns 42, `p` has the exact same value it would if I did `int *p = &x;` instead, but not the same provenance.
As written p is a one-past-the-end pointer into object arr, but the address one past the end of arr may well be the address of x. If pointers are just addresses, these pointers are the same... right?
Neither C nor C++ currently actually explain how this works for their "abstract machine" in the standards documents. The reality is that your C++ compilers (and any non-toy C compilers) have pointer provenance because it's a nightmare to optimise C programs without, but since it isn't documented anywhere (my understanding is that C23 might fix this for C by taking a TS and an equivalent fix via P2318 could land in C++ 26) it's difficult to say if you ever find bugs in their behaviour.
Re: Carbon’s most exciting feature is its calling convention
#73Re: Carbon’s most exciting feature is its calling convention
#74Earlier quoted context omitted.
The point is that on systems where that code returns 42, `p` has the exact same value it would if I did `int *p = &x;` instead, but not the same provenance.
And because C++ says "one past the end" pointers are a thing, both these pointers can exist. As written p is a one-past-the-end pointer into object arr, but the address one past the end of arr may well be the address of x. If pointers are just addresses, these pointers are the same... right? Neither C nor C++ currently actually explain how this works for their "abstract machine" in the standards documents. The realit…
While one-past-the-end pointers are allowed to exist, they are not allowed to be dereferenced.
> these pointers are the same... right
The entire point of provenance is that even though their numerical values are the same, they are not the same.
> Neither C nor C++ currently actually explain how this works for their "abstract machine" in the standards documents.
While it isn't mentioned explicitly, it can be inferred from other things that the standard does say. The compiler authors didn't just make it up.
Re: Carbon’s most exciting feature is its calling convention
#75C++ also pays a price for insisting not only that objects have addresses, but those addresses are distinct. If you've got a 1.6 billion empty tuples in variable A, 1.4 billion in variable B and 1.8 billion in variable C, C++ can't see a way to do that on a 32-bit operating system. It needs to give each empty tuple an address, so it must think of 4.8 billion integers between 0 and 2^32 and it can't do that, so your pr…
since C++20 you can get around this https://en.cppreference.com/w/cpp/language/attributes/no_uni...
Re: Carbon’s most exciting feature is its calling convention
#76Earlier quoted context omitted.
Google engineers: "Let's make our languages hard to Google!" Google managers: "Whatever floats your boat. How about Go, Dart and Carbon?"
I've been a Dart developer for three years and had zero issues finding anything Dart related. I also had to write some Go, that was actually pretty bad in terms of searchability.
Re: Carbon’s most exciting feature is its calling convention
#77Dunno about the most exciting but the most irritating so far is seeing it up. Admittedly I didn't spent a lot of time trying(I didn't have all that much time today) but in the 40 minutes or so, I was unable to get it going. I'll go back to attempting tomorrow and make sense of the errors.
I'd only worry about compiling it yourself if you intend to participate in Carbon's development in the near future.
Re: Carbon’s most exciting feature is its calling convention
#78Are they trolling Go here?
Re: Carbon’s most exciting feature is its calling convention
#79C++ also pays a price for insisting not only that objects have addresses, but those addresses are distinct. If you've got a 1.6 billion empty tuples in variable A, 1.4 billion in variable B and 1.8 billion in variable C, C++ can't see a way to do that on a 32-bit operating system. It needs to give each empty tuple an address, so it must think of 4.8 billion integers between 0 and 2^32 and it can't do that, so your pr…
Maybe the right question to ask is, why you have 4.8 billion empty tuples? And why you're still on a 32-bit system?
Admittedly, those probably aren't running on 32-bit systems, nowadays ...
Re: Carbon’s most exciting feature is its calling convention
#80Earlier quoted context omitted.
Maybe the right question to ask is, why you have 4.8 billion empty tuples? And why you're still on a 32-bit system?
Gamedev, presumably. It's not unusual to have a LOT of triangles and coordinates flying around and GameDev is basically locked to C++ (for many good reasons even if I find C++ distasteful). Admittedly, those probably aren't running on 32-bit systems, nowadays ...