• 0 Posts
  • 113 Comments
Joined 1 year ago
cake
Cake day: September 24th, 2023

help-circle

    1. If your alternative is C++ then it removes the enormous burden of manually tracking lifetimes and doing manual memory management. C++ does have RAII which helps with that enormously but even then there are a gazillion footguns that Rust just doesn’t have - especially with the newer stuff like rvalue references, std::move, coroutines etc. It also saves you from C++'s dreaded undefined behaviour which is everywhere.

    2. It has a very strong (and nicely designed) type system which gives an “if it compiles it works” kind of feel, similar to FP languages like Haskell (so they say anyway; I’ve not used it enough to know). The borrow checker strongly pushes you to write code in a style that somehow leads to less buggy code. More compiler errors, but much less debugging and fixing bugs.

    3. The libraries and APIs are generally very well designed and nice to use. If you’ve ever used Dart or Go think how nice the standard library is compared to JavaScript or PHP. It took C++ like 2 decades to get string::starts_with but Rust started with it (and much more!).

    4. Fast by default.

    5. Modern tooling. No project setup hassle.

    6. It’s a value based language, not reference based. References are explicit unlike JavaScript, Java, C#, etc. This is much nicer and makes things like e.g. copying values a lot easier. JavaScript’s answer for ages was “serialise to JSON and back” which is crazy.

    Downsides:

    1. Slow compilation sometimes. I’d say it’s on par with C++ these days.

    2. Async Rust is kind of a mess. They shipped an MVP and it’s still kind of hard to use and has unexpected footguns, which is a shame because sync Rust avoids footguns so well. Avoid async Rust if you can. Unfortunately sometimes you can’t.

    3. Interop with C++ is somewhat painful because Rust doesn’t have move constructors.

    Great language overall. Probably the best at the moment.










  • One nice thing about XML is that there’s an official way to link to the schema from within the document. If you do that you can easily automatically validate it, and even better you get fantastic IDE support via Red Hat’s LSP server. Live validation, hover for keys, etc.

    It’s a really nice experience and JSON schema can’t really match it.

    That said, XML just has the wrong data model for 99% of use cases.





  • Think of it from the company’s point of view. If you’re hiring a new employee then the options for a good candidate are a) move jobs and work for you, b) move jobs and work for someone else. You’re competing with other companies.

    If you’re reviewing an existing salary for a good employee their options are a) do nothing and accept the shitty raise, b) move jobs and work for someone else.

    Moving jobs has significant cost for most people - it’s time consuming, stressful, might involve moving house, etc.

    That downside gives employees who haven’t proven they are looking for a new job a significant negotiating disadvantage.

    If you really want you can tell your boss you are actively looking for new jobs. That will increase your chances of getting a bigger raise, but of course it has other downsides so most people don’t do that.



  • Languages that make use of references rather than pointers don’t have this Dualism.

    It’s not about references vs pointers. You could easily have a language that allowed “null references” (edit: too much C++; of course many languages allow null references, e.g. Javascript) or one that properly separated null pointers out in the type system.

    I agree with your point though, using a special Null value is usually worse than using Option or similar. And nullptr_t doesn’t help with this at all.



  • The biggest problems with gRPC are:

    1. Very complicated. Way more complexity than you want in most cases.
    2. Depends on HTTP 2. I’ve seen people who weren’t even doing web stuff reach for gRPC, and now boom you have a web server in your stack for now reason. Compare to Thrift which properly separates out encodings, transports, etc.
    3. Doesn’t work from the web. There are actually two modifications to gRPC to make it work on the web which means you have three different incompatible versions of gRPC with different feature sets. IIRC some of them require setting up complex proxies, some don’t support streaming calls, ugh. Total mess.

    Plain HTTP can be type safe. Just publish JSON schema or Typespec files or even use Protobuf.


  • TOML is not a very good format IMO. It’s fine for very simple config structures, but as soon as you have any level of nesting at all it becomes an unobvious mess. Worse than YAML even.

    What is this even?

    [[fruits]]
    name = "apple"
    
    [fruits.physical]
    color = "red"
    shape = "round"
    
    [[fruits.varieties]]
    name = "red delicious"
    
    [[fruits.varieties]]
    name = "granny smith"
    
    [[fruits]]
    name = "banana"
    
    [[fruits.varieties]]
    name = "plantain"
    

    That’s an example from the docs, and I have literally no idea what structure it makes. Compare to the JSON which is far more obvious:

    {
      "fruits": [
        {
          "name": "apple",
          "physical": {
            "color": "red",
            "shape": "round"
          },
          "varieties": [
            { "name": "red delicious" },
            { "name": "granny smith" }
          ]
        },
        {
          "name": "banana",
          "varieties": [
            { "name": "plantain" }
          ]
        }
      ]
    }
    

    The fact that they have to explain the structure by showing you the corresponding JSON says a lot.

    JSON5 is much better IMO. Unfortunately it isn’t as popular and doesn’t have as much ecosystem support.