23 ms·
I had great hopes for Rust as the future of systems programming, but they've decreased over time. Parts of the language are just too cute. The borrow checker w
by Animats 10y ago
I had great hopes for Rust as the future of systems programming, but they've decreased over time. Parts of the language are just too cute.
The borrow checker was brilliant. Any future language that doesn't use garbage collection will have to have one. That was the big advance in Rust.
But the object system (yeah, they're called structures and traits) is too weird. The enum approach to variant records is too weird. The error handling is too weird. The half-functional style is too weird. The widespread use of closures for simple stuff is too weird. There's too much unnecessary originality. Trying to port something from another language to Rust is difficult because Rust's ways of doing things are so different from other languages.
I have the feeling that Rust is destined for a niche like Haskell - cool, but not mainstream. That's sad. I really thought early on that Rust meant the end of the decades of hell from the lack of memory safety in C and C++. But that's not happening.
The Go crowd knew when to stop. The Rust crowd didn't.
- tomjakubowski 10y ago> But the object system (yeah, they're called structures and traits) is too weird. It's equivalent to writing C++ with: * No structural inheritance (i.e. no inheritance of data) * Inheritance only from pure virtual interface classes * MyCppPureVirtualClass * pointers in various interfaces Except that traits are also usable for static dispatch as in templates/concepts. This isn't the most common style of C++, but it's not uncommon either, and I happen to like it a lot; it's all over Cef's and Chromium's code, for example. > The enum approach to variant records is too weird. What's weird about it? It's just the same as e.g. Haskell, ML, but with a different (arguably slightly overloaded) keyword. Swift uses the same terminology. > The error handling is too weird. Eh. I certainly like the way that explicit error handling is "forced" on the caller with mechanisms like Result<T,E>::unwrap. But I agree that magical things like the question mark operator are a little too cute. > There's too much unnecessary originality. FWIW, I can't think of much real originality in Rust. It just brings together "exotic" features from lesser-known languages.
- Animats 10y agoI can't think of much real originality in Rust. It just brings together "exotic" features from lesser-known languages. I think you're right. Except for the borrow checker, which was a major breakthrough.
- tmccrmck 10y agoThe borrow checker is Cyclone's region-based memory management combined with linear/affine types. Edit: As an aside, I found a Reddit post the other day asserting that the Cyclone developers knew that it would never become mainstream but thought it was important because other languages would adopt it's ideas. It's amazing that they predicted that regions would be picked up later on by Rust. You can find it here: https://twitter.com/tmccrmck/status/850465514807631872 https://twitter.com/tmccrmck/status/850465514807631872
- parenthephobia 10y agoCompile-time checking of owned and borrowed references was in Vala, a C#-inspired language for the GNOME ecosystem, four years earlier.
- steveklabnik 10y agoDoesn't Vala use reference counting? [1] I'm not actually sure; do you have some pointers I could read here? 1: http://www.vala-project.org/doc/vala/Overview.html#Memory_management http://www.vala-project.org/doc/vala/Overview.html#Memory_ma...
- ssokolow 10y agoFrom what I remember, it just uses GLib's system for implementing reference-counted pointers in C and is equivalent to using Rc<T> or Arc<T> everywhere in Rust.
- steveklabnik 10y agoYeah, that's what I thought. Which is very different than most Rust code!
- kibwen 10y agoThis critique makes no sense to me. The composition-based object system mirrors Go's. enums aren't original (ML, anyone? 1970s tech?) or weird (every new language from this decade has them, including Swift, and C++ will have them by C++20). Error handling is literally Go's `if err` pattern but first-class (Swift's error handling is quite similar as well). And your disdain for closures has long been noted and I reiterate that your concerns are overblown. If you don't like Rust, that's A-OK. If you can't quite put your finger on why you don't like Rust, that's fine too. But please don't pass off your vague concerns as substantive criticism.
- zzzcpan 10y agoIt makes a lot of sense if you take that "weird" is about familiarity, not functionality.
- koenigdavidmj 10y agoYou don't have to do any of that in your code. All the main compiled languages (or at least C++, Java, and C#) are all getting features roughly equivalent to what think is difficult in Rust: closures, functional pipelines, option types, pattern matching, and the like. Sure, you've got to know about Option and Result to do anything with Rust, but you've got to know about exceptions and null pointers in the rest of those languages. But you can write coherent Rust using for loops everywhere instead of stupid closure tricks.
- biokoda 10y agoThis is like reading criticism of Erlang which we use. A bunch of people (the vast majority of which never shipped anything in it) have plenty of arguments against it, those of us that actually use it love it to bits. Rust is productive, efficient and a joy to use. For things we required C/C++ before, we will be using Rust now.
- eridius 10y agoI don't know why you're calling all of that stuff "weird". I have to assume it's simply because you were never exposed to another language that had stuff like it. But you're definitely wrong about that keeping Rust from going mainstream - just look at Swift, which has a very similar trait system (called protocols), enum variants with associated values, an arguably weirder error system, widespread closures, and half-functional style. And I'd say Swift is already fairly mainstream.
- lossolo 10y agoSwift is mainstream because Apple replaced Objective-C with it for iOS and said that it's new standard for writing apps. How much of Swift is written out of Apple ecosystem? Not much.
- eridius 10y agoApple didn't replace Obj-C. They added Swift alongside it. Literally nobody is being forced to switch, and all of Apple's frameworks are still written in Obj-C (they can't be written in Swift until Swift has ABI stability). Yes, Apple's weight helped Swift tremendously. But people are switching from Obj-C to Swift because they think it's better, not because Apple's making them. > How much of Swift is written out of Apple ecosystem? Not much. Not much yet, because the Linux support is still missing a lot, but it's being filled in quickly, and a lot of people seem to be excited about being able to start using Swift on Linux.
- pcwalton 10y ago> But the object system (yeah, they're called structures and traits) is too weird. So you praise Go for having structures and interfaces, but you criticize Rust for having structures and interfaces because that's "too weird". > The enum approach to variant records is too weird. Why? Because of the keyword? Swift uses that keyword too! > The error handling is too weird. What would you rather see? > The half-functional style is too weird. I can't think of any way that Rust differs in this regard from, say, Ruby. Or JavaScript. > The widespread use of closures for simple stuff is too weird. Again, it doesn't differ from Ruby. (Actually, Rust uses closures/blocks quite a bit less than Ruby does, because of the pull-style iterators...) > There's too much unnecessary originality. Such as? None of the features you've mentioned are at all original.
- soulbadguy 10y ago>> The error handling is too weird. >What would you rather see? Exceptions
- pcwalton 10y agoWe would lose lots of users from C and C++ if we mandated exceptions for error handling. The code size and complexity of unwinding is too much of a price for many to pay.
- soulbadguy 10y agoNot mandate them , use have them as an options where the monadic Errors types are not enough or are too cumbersome to use.
- pcwalton 10y agoAnd thereby prevent people from writing code that needs to catch errors but can't use exceptions. Won't work.
- soulbadguy 10y ago
- lossolo 10y ago> The half-functional style is too weird. The widespread use of closures for simple stuff is too weird. There's too much unnecessary originality. Trying to port something from another language to Rust is difficult because Rust's ways of doing things are so different from other languages. This. I've spent some time researching Rust but it's just ugly language for me, really. When I read D everything is so clean, so readable. When I need to read/write Rust, it's just not enjoying for me. There are people that will enjoy it for sure, that came for example from Haskell. Create language like Rust with D like syntax, no GC, no additional indirection, RAII, less strict rules or possibility to turn off some of them and I am sold.
- pcwalton 10y ago> Create language like Rust with D like syntax, no GC, no additional indirection, RAII, less strict rules or possibility to turn off some of them and I am sold. I think that language will end up looking a lot more like Rust than you think. You can't just compare a language that wasn't designed for zero-cost memory safety to one that was, as if the zero-cost memory safety features have no learning curve.
- lossolo 10y ago> I think that language will end up looking a lot more like Rust than you think. I disagree, I think you could pick different way based on Cyclone coupling with some modern static analysis techniques, it would not have so many features as Rust have but it would be less invasive and more "C/D'ish".
- kbenson 10y ago> and more "C/D'ish" This I think is where a lot of the pushback comes from. People say want a new C replacement, but some portion of them look at what that actually means, and find they actually want C with a new feature or two because actually learning something new, even new looking, is work. Rust is not C or C++ with a few new features, it's a new language, and some people really want that, and some people are put off by how different it is. It's perfectly fine for people to have a preference, but people should be aware of what it is - a preference. It's not some inviolate law that C's syntax and way of doing things is good, and we should make sure a successor follows that. It's importance to distinguish the familiar from the good. C has a huge advantage in that it's familiar, through it's own popularity and history and in those languages that it influenced. That doesn't mean it's inherently better though.
- sidlls 10y ago> But the object system (yeah, they're called structures and traits) is too weird. Alternative view: the clean separation of data from API has a nice analogy to the manipulation of data in C, and a powerful way to maintain that separation while still allowing for powerful object oriented programming where appropriate. > The enum approach to variant records is too weird. I disagree. The tagged union is an oft-used pattern in C and C++ code. Maybe calling it "enum" is a bit off, but the concept is incredibly useful, and Rust's compile-time support for it is incredibly useful and powerful in my opinion. > The error handling is too weird. It's very C-like, but more strongly typed and, thanks to the Rust developers' efforts, quite clean. A C programmer, or a C++ programmer who sets the "no exceptions" flag as a matter of best practice should feel quite comfortable with Rust's error handling. > The half-functional style is too weird. The widespread use of closures for simple stuff is too weird. I would substitute "cute" for weird, but overall I don't mind it. I do agree that emphasis on making these features more prominent, especially at the expense of more explicit (e.g. explicit for-loop) constructs, might hinder traction.
- kbenson 10y ago> I do agree that emphasis on making these features more prominent, especially at the expense of more explicit (e.g. explicit for-loop) constructs, might hinder traction. I thin kit depends on both where the new users are coming from, and how much they've modified their thinking to a specific programming style. If you are a C or C++ programmer and already think in conceptualized for loops when planning steps, then it seems odd. If you haven't gone that far into letting that style define your thoughts, or continued to use other languages that were a bit more functional, you might find that that conceptually it's easier to reason about. I.e. "I'm going to transform each of these items by doing X, Y and Z and store them here" as a concept is neither directly a for loop nor a map a the basest level, but you might start thinking in maps or loops after a while if that's your only option.
- mmstick 10y agoOdd that you find closures weird. I use them everywhere that I can because it allows you to make your library more modular and, at the same time, allows you to write unit tests for otherwise impossible functions to test without dependency injections and other convoluted external setups that won't pinpoint the cause of an error very well. Case in point, in the Ion shell that I am working on, I have a shell expansion module within that takes a structure containing closures that are used to grab and expand array variables, string variables, tilde variables, and process expansions. Because of this, the module can live as an entirely separate piece of software with no dependency on the specifics of Ion, and I can write reduced unit tests that extensively test every component. I could strip it out of Ion and use it with a completely different shell project. That shell would just have to provide the batteries (closures) that define what to do with certain tokens.
- dragonwriter 10y ago> Trying to port something from another language to Rust is difficult because Rust's ways of doing things are so different from other languages. That's the whole reason to have a new language; if we just wanted a language that works like elcurrent popular languages, we wouldn't need a new language for that. > I have the feeling that Rust is destined for a niche like Haskell - cool, but not mainstream. Becoming a Haskell or a Lisp -- never an industrially dominant language but one from which later and more industrially popular languages are continuously mining for some subset of their ideas because they solve problems long before most users of industrially popular languages even recognized the problem, much less the value of the particular solution, is not a failure. And it makes the language one that is valuable to learn even if you don't often get to use it anger.
- leshow 10y agoThe fact that you think all these features are 'weird' just solidifies you haven't used a typed language with any modern features