News for hackers. Stuff that matters.
Re:Rust: Not So Great For Codec Implementing by cryptonector on Tuesday August 01, 2017 @01:59PM (#14903480)
"do what I want" usually means "simple ABI that is trivial to interface with" which means you "can layout structures the way you want" and "calling conventions are simple so you can call C from assembly and any HLL FFIs and vice-versa".

Really, that's all. If it was possible to build C++ classes in C or assembly, it would be done. But it's not because C++ doesn't have the kind of ABI (or any) that would allow one to do that.

Of course, in practice C only gets you 95% of the structure layout functionality you need, as the rules for packing structures and bitfields(!) aren't sufficiently nailed down. Still, 95% out of the box is pretty good, and with some care you can get 100%. This matters when writing, e.g., drivers, but also codecs for another example.

Any systems programming language aiming to replace C has to provide support for a C-like ABI.

I'm not praising C here, mind you. It can't be replaced (with Rust or similar) quickly enough.

Re:Rust: Not So Great For Codec Implementing by flavio81 on Tuesday August 01, 2017 @04:27PM (#14904976)
> If it was possible to build C++ classes in C or assembly

You would be surprised, but Object-oriented programming has been done in C many times... and even before C++ existed.

Re:Rust: Not So Great For Codec Implementing by cryptonector on Tuesday August 01, 2017 @04:30PM (#14905000)
I'm not surprised. But you'll note I said "C++ classes", and I did that for a reason: it's not possible to write C++ classes in C because there's no stable, public ABI for one to write to. (Well, for some compilers there may be a public ABI, and some might even be stable, but even so, it's a mess.)
Re:Rust: Not So Great For Codec Implementing by adrianratnapala on Tuesday August 01, 2017 @04:42PM (#14905110)
On particular platforms they have nailed down the C++ layout enough to make this possible. I think windows did it for COM (or DCOM?). But in general you are right.

On of the most infuriating things about fancy languages is the way they all have their own ABIs. I mean it's nice that they support special features through those ABIs, but standardized vtables and dictionaries would take us a long way.

And Kudos to Microsoft for having a second crack at getting that right with .Net.

Re:Rust: Not So Great For Codec Implementing by cryptonector on Tuesday August 01, 2017 @06:20PM (#14905983)
Yes, that's right, and multiple compilers support the Windows C++ ABI. You still couldn't write portable C++ in C or assembly (or anything else not C++). Does anyone write C or assembly to that ABI? Probably not, though to be fair that's probably in large part because if you're going to do that you might as well write in C++ :^)

Still, I think a public and stable ABI with fine-grained control of binary elements is a critical aspect of a systems programming language.

Also, the linker contributes a lot to making a systems language. E.g., being able to map globals to specific physical addresses. And, of course, either an ABI has to be dead trivial from a linker's perspective, of the linker has to be very intimate with it (think of symbol mangling). The linkers we use all evolved in a C world, and it shows. C w/ a really good link-editor and RTLD (I'm thinking of Illumos') is a much more advanced beast than C with plain old static linking. Even the ABI aspects of dynamic linking are simple, public, and stable.

A great systems programming language has to have a great linker story as well.

Re:Rust: Not So Great For Codec Implementing by sitkack on Tuesday August 01, 2017 @08:56PM (#14906963)
I would like a declarative language for laying out the heap, stack, objects, etc. Why have one ABI and not an ABI configuration protocol? Would love to share data structures between languages w/o having to write serializers.
Re:Rust: Not So Great For Codec Implementing by krallja on Wednesday August 02, 2017 @12:38AM (#14907965)
You can't just wake up and decide to be Don Box like that!
Re:Rust: Not So Great For Codec Implementing by sitkack on Monday August 14, 2017 @12:28AM (#15006579)
I am going to out Box, Don Box!
Re:Rust: Not So Great For Codec Implementing by aidenn0 on Wednesday August 02, 2017 @01:15AM (#14908113)
As a counterpoint, PowerPC has at least 3 mutually incompatible ABIs for C.
Re:Rust: Not So Great For Codec Implementing by cryptonector on Wednesday August 02, 2017 @12:40PM (#14912101)
But generally there's only one per-OS, so it's not that bad. C++ ABIs are per-compiler, or worse, per-{compiler, version}, with few exceptions (Windows).
Re:Rust: Not So Great For Codec Implementing by pjmlp on Wednesday August 02, 2017 @02:38AM (#14908427)
> And Kudos to Microsoft for having a second crack at getting that right with .Net.

IBM did it first with TIMI for AS/400.

Also Microsoft is now in their third crack at getting it right with UWP (based on COM).

Re:Rust: Not So Great For Codec Implementing by dep_b on Tuesday August 01, 2017 @07:05PM (#14906312)
Objective-C used to be a precompiler to C. Hence the weird syntax, they needed some character patterns that weren't used yet in C to be able to preprocess the Objective-C parts.
Re:Rust: Not So Great For Codec Implementing by pjmlp on Wednesday August 02, 2017 @02:36AM (#14908419)
> Really, that's all. If it was possible to build C++ classes in C or assembly, it would be done.

IBM's mainframe OS/400, nowadays known as IBM i supports OO Assembly.

MASM also used to have OO Macros.