• 0 posts
  • 37 comments
Joined 3 years ago
Cake day: July 9th, 2023
  • Something about the language promotes writing it using these kinds of idioms.

    As someone who has used Rust professionally for 3 years, the idioms are good. I wouldn’t want the idioms to go away, and I don’t particularly want the style/aesthetics of the language to change unless it can be done without negatively affecting the idioms.

    It’s not a situation where the aesthetics are actually bad, it’s just different than what most programmers are used to, but almost all of the differences are for pretty good reasons. With enough familiarity and practice you’ll start to recognize those differences as benefits of the language rather than detriments.

    But I think a lot of people have so much inertia about tweaking their way of thinking that they don’t feel motivated to try long enough to make it over that hump, especially when their expectations get set by rabid Rust promoters like myself who insist that Rust is vastly superior to any other languages in almost all situations. The stark contrast between how good they’re told the language is and how they feel when first exposed to it might be too much whiplash for some people.

  • I get it there are people who want to play around and have language/compiler babysit them, but there are also people like me who want to see exactly what something is.

    This is a false dichotomy when it comes to Rust. Despite everything I said and despite Lucy’s complaint, there is nothing that actually stops someone from explicitly annotating the exact type when declaring a variable. It’s just not required by the language, and most developers eventually realize that it’s not actually useful.

    You’re right that these preferences are subjective, be although much of that subjectivity has more to do with how our past experiences have shaped what we’re familiar with, rather than any intrinsic characteristics of person. By that I mean, someone who uses Rust enough will most likely come to like the way the general community styles its code, sooner or later. In the meantime you’re welcome to do things in a way that suits your needs.

    The only thing that Rust’s type system is weak on is runtime reflection. There are ways to achieve it within Rust’s type system, but it’s considerably more work than what you get in Python and JavaScript. Imo the only reason to choose a language other than Rust for a greenfield project is if you have a strong need for runtime reflection all over the place and aren’t very concerned about performance, threading, or avoiding entire categories of bugs that the Rust compiler protects you from.

  • Types are not implicit, they’re inferred by the compiler when there is no ambiguity about what the type needs to be. This is a huge benefit for refactoring code and reducing maintenance. I acknowledge that sometimes you might care to know the exact type of the variable, and sometimes that’s not as easy for a human to infer as it is for the compiler, but every decent IDE will provide inline type hints for you. Interpreting code by reading it in plaintext is an exercise in masochism.

    Python is actually the opposite on this, and it’s one of Python’s worst characteristics. The type is unknown until runtime unless you annotate it, and then the annotation isn’t really enforced. It’s the worst of every dimension.

    C++11 introduced auto, and now the community is split between “almost always auto” and “never auto”.

    JavaScript needed a whole new compiled language (Typescript) to fix its type system problems, and Typescript is only an incremental improvement at best.

    Rust has the best type system of any modern language by far. If you’re tripped up by not always seeing the type declarations then you’re either focusing on the wrong details in the code or you just need a little more practice. The key thing that needs to sink in for new Rust users is that the compiler is always providing safety rails. That means it’s no longer your job to verify that every aspect of the code is correct. You can relax a little and actually have something akin to duck typing without all the pitfalls that usually come with it.

  • It’s hilarious to me that people talk about “ugly” as if their opinions are objective.

    I found Rust unpleasant to look at for the first two weeks of learning it, and now that I’ve been using it professionally for three years I loathe when I need to read code in other languages.

    No other language can rival Rust in showing the exact information needed to understand the code — never too much and never too little — while being concise, correct, and handling all edge cases.

    You can be more concise in other languages, but it will come the loss of handling every little possible bug. You can be prettier in other languages, but it will come at the price of adding a lot of useless boilerplate.

    Of course there are cases where Rust can be verbose or confusing, but that’s when you’re doing very esoteric things that would be just as confusing in other languages.

    Like any opinion on aesthetics, how someone feels about the prettiness of a language will have far more to do with familiarity than with any objective metrics.

  • I assume you’re referring to the technicality that the thirteenth amendment allows unpaid labor to be legally compelled out of prisoners, and that’s a valid thing to be outraged about, but your statement is wildly misleading to anyone who isn’t already aware of that technicality.

    The existence of the loophole is terrible and should be amended, but it’s nowhere near the humanitarian crisis that widespread chattel slavery was. Ironically that will probably make it that much harder to be fixed since it’s more difficult to draw pubic outage towards it.

  • Your description actually illustrates how terribly inaccurate the metaphor was. If enslaved people imitated the people who enslaved them, they’d be sitting in a rocking chair on a porch sipping lemonade.

    The US has a unique and relatively recent relationship with chattel slavery so people are more sensitive to it now.

    The earliest record of the master/slave terminology being used in engineering is 1904 by which point slavery was already outlawed in almost every country, including the US. You’re right to say that chattel slavery in the US was a uniquely grotesque form of slavery, but there is no system of slavery in history where slaves are primarily imitating their masters. No matter what anyone’s sensitivity to the topic is, it’s a bad fit for what’s being described.

  • Did the software industry learn nothing from Y2K? Was it too long ago already for people to remember the mess we made for ourselves?

    Saving two characters in a file name is not worth the hell you are leaving in your trail by shoving this nonsense in an obscure corner of production code that people are going to forget about until it’s too late.

  • I recently had an accountant file something for the IRS that was dated as expiring in 1940 when it should’ve been 2040. I had to catch it myself after reading through 70 pages of dense forms before it was sent off, and I could’ve easily missed it.

    Digital records have existed long enough now that it’s downright irresponsible to leave off the century for anything where having an accurate date might even slightly matter.

  • There are several ways to achieve an effect equivalent to operator overloading in Rust, depending on exactly how you want the overloading to work.

    The most common is

    fn do_something(arg: impl Into<Args>) {
        ...
    }
    

    This lets you pass in anything into the function that can be converted into the Args type. If you define the Args type yourself then you can also define any conversion that you want, and you can make any construction method you want for it. It’s a small touch more explicit than C++'s operator overloading, but I think it pays off overall because you know exactly what function implementation all different choices of arguments will be funneling into.

    I’ll admit there’s one thing from C++ that I frequently wish were available in Rust: specialization. Generics in Rust aren’t exactly the same as templates in C++ but they’re close enough that the concept of specialization could apply to traits and generics. There is ongoing work to bring specialization into the language, but it’s taking a long time, and one of my projects in particular would seriously benefit from them being available.

    Still, Rust will have specialization support long before C++ has caught up to even a quarter of the benefits that Rust has over it.

  • Even with modern C++ it’s loaded with seg fault and undefined behavior footguns.

    The times when C++ feels more ergonomic than Rust are the times when you’re writing unsafe code and there’s undefined behavior lurking in there, waiting to ambush you once you’ve sent it to production. Code that is 100% guaranteed safe is always, and I really want to emphasize this: always more ergonomic to write in Rust than it is to write in C++.

    Show me any case where C++ code seems more ergonomic than its Rust equivalent, and I will always be able to show you how either the C++ code has a bug hiding in it or how the Rust code can be revised with syntactic sugar to be more ergonomic than the C++.

  • C++ was far and away my favorite language (I used it professionally for 10 years and was always excitedly keeping up with new ISO developments), until I learned the basics of Rust…

    Now it’s my firm belief that the world will become a better place when C++ stops existing. C++ just has no positive role to play in a world where Rust exists at the level of maturity that it already has.

    Whatever they might try to do to C++ to make it less intolerable will be in vain until they’re ready to break backwards compatibility. And once they’re willing to break backwards compatibility to legitimately improve the language, they’re just going to end up with a messy knock off of Rust.