Earlier quoted context omitted.
They look a lot nicer in ML and Haskell, IMO. Of course I implemented them in Virgil, too. (shameless plug: https://github.com/titzer/virgil )
I don't intend to derail the discussion further, but I'm curious about Virgil. I can't find any information on it that tells me who is behind it or how to contact them. Do you have anywhere I could look to learn more about the project in general?
Type-Safe Unions in C++ and Rust
41–50 of 140 posts
Re: Type-Safe Unions in C++ and Rust
#42Re: Type-Safe Unions in C++ and Rust
#43Earlier quoted context omitted.
Only if development of the language and OS are separate. If you co-develop the language with the OS, then it makes perfect sense to push safety features into the language (or conversely, to remove them from the language when they are no longer appropriate). LISP-strength macros give you most of this capability.
OS are not the only use cases for system languages and developing a language to be tightly tied to an os (and viceversa) is a great way to condemn both to obscurity.
Re: Type-Safe Unions in C++ and Rust
#44Re: Type-Safe Unions in C++ and Rust
#45Earlier quoted context omitted.
OS are not the only use cases for system languages and developing a language to be tightly tied to an os (and viceversa) is a great way to condemn both to obscurity.
Erm... I think Dennis Ritchie would have had a few things to say about that.
Re: Type-Safe Unions in C++ and Rust
#46Earlier quoted context omitted.
Ada and Pascal are not really research languages, though. But still, there are improvements taken from research, see Ada 2012 contracts for example.
Right, like I said, this particular feature exists in a million languages. I'm talking about the whole set of features that Rust has; some are from research languages and may have never been seen in the industry before (e.g. regions/borrow checking), but they're not really new. This particular feature in Rust descended from the ML family (since Rust used to be ML-like), which in turn probably got it from Ada or w/e.
Re: Type-Safe Unions in C++ and Rust
#47Earlier quoted context omitted.
Putting them well together in Rust is debatable. Writing proper and safe concurrent code in Rust still looks horrible compared to languages which supports it natively in the type system, e.g. ponylang type capabilities. You still have to manually maintain locks, and it's also much slower. There's a safety model, but it's only best practice, not enforced by the language nor the compiler. So calling it "safe" and "trul…
Having a language-imposed concurrency model would be useless and actively harmful in a system language. Rust provides the building blocks to build whatever safe abstractions are appropriate for the problem and domain at hand, plus a set of out of the box abstractions relatively low level that will be familiar to people coming from other system languages. And of course the means to get rid of any abstraction and safet…
It works fine in Ada.
Edit: Why am I downvoted for this? A language-defined concurrency model is indispensable for having safe and deadlock-free concurrency in the language (rather than in arbitrary utility libraries). That's why concurrency was explicitly included into Ada and into the additional Ravenscar profile. The rationale for this has always convinced me and it also works fine in Ada, so anybody care to elaborate what's wrong with it?
Re: Type-Safe Unions in C++ and Rust
#48In this case, when I first encountered Rust's enums the first thing that came to mind is the fact that C and C++ both offer the ability to support tagged-unions, but certainly not as a first-class entity and definitely with a lot more cruft, with or without safety checks.
For me the jury is still out on where the best "fit" for Rust is. I really appreciate the enforced safety of Rust for higher-level systems applications programming. I'm not convinced yet it won't just get in the way pointlessly for much lower level programming (especially embedded). Perhaps that's just my relative novice understanding of Rust, though.
Re: Type-Safe Unions in C++ and Rust
#49Earlier quoted context omitted.
Right, like I said, this particular feature exists in a million languages. I'm talking about the whole set of features that Rust has; some are from research languages and may have never been seen in the industry before (e.g. regions/borrow checking), but they're not really new. This particular feature in Rust descended from the ML family (since Rust used to be ML-like), which in turn probably got it from Ada or w/e.
ML predates Ada by about 7 years, so that's unlikely. The way it is implemented in ML is most likely just an implementation of the mathematical concept of sum types rather than a feature influenced by existing programming languages.
Ha! I didn't know that. Thanks :)