• 13 Posts
  • 818 Comments
Joined 4 years ago
cake
Cake day: May 31st, 2020

help-circle

  • I’ve been telling all the juniors we have, that they’re free to use a GUI tool, but they do not get around learning the CLI. If you fuck up or Git breaks, you’ll need to look up how to unfuck it and that’s where the only help you find is for the CLI.

    In particular, it’s also been my experience that you rapidly come into a situation where suddenly you’re the Git expert and need to help others. If you only know one specific GUI, you can only help others who use that GUI. If you know the CLI, you can help anyone.

    It also happens that you need to interact with Git repos on a server where you simply won’t have a GUI.

    And yeah, given that whole opinion, personally I seriously do not care to learn a GUI in addition to the CLI.



  • The guy keeps on picking on Go, which is infamous for having terrible error handling, and then he has the nerve to even pick on the UNIX process return convention, which was designed in the 70s.
    The few times he mentions Rust, for whatever reason he keeps on assuming that .unwrap() is the only choice, which’s use is decidedly discouraged in production code.

    I do think there is room for debate here. But error handling is a hellishly complex topic, with different needs between among others:

    • short- vs. long-running processes
    • API vs. user-facing
    • small vs. big codebase
    • library vs. application code
    • prototyping vs. production phase

    And even if you pick out a specific field, the two concepts are not clearly separated.
    Error values in Rust usually have backtraces these days, for example (unless you’re doing embedded where this isn’t possible).
    Or Java makes you list exceptions in your function signature (except for unchecked exceptions), so you actually can’t just start throwing new exceptions in your little corner without the rest of the codebase knowing.
    I find it quite difficult to properly define the differences between the two.





  • As many here have commented, the map is pretty bad and lots of these are not officially recognized as national flowers.

    Having said that, actual national flowers, much like national animals, are often just whatever commonly grows in the country (assuming there is one flower that really sticks out).
    They don’t have to be unique, because you’ll have a flag or a coat of arms for that purpose (which may portray that flower or animal, for what it’s worth). So, they’re rather just part of the “national branding”, if you will.





  • I have actually seen it in an XML file in the wild. Never quite understood why they did it. Anything they encoded into there, they could have just added a node for.
    But it was an XML format that was widely used in a big company, so presumably somewhere someone wrote a shitty XML parser that can’t deal with additional nodes. Or they were just scared of touching the existing structure, I don’t know.


  • The thing is, it was never really intended as a storage format for plain data. It’s a markup language, so you’re supposed to use it for describing complex documents, like it’s used in HTML for example. It was just readily available as a library in many programming languages when not much else was, so it got abused for data storage a lot.


  • If you’ve so far been able to do this stuff in Java, then presumably all your hardware has an OS and such and you don’t need this, but a colleague has been having a lot of fun with Rust and proper embedded development.

    It’s very different from regular development, as you’ve got no OS, no filesystem, no memory allocations, no logging. It can most definitely be a pain.
    But the guy always has the biggest grin on his face when he tells that he made a custom implementation of the CAN protocol (TCP is too complex for embedded 🙃) and that he had to integrate an LED to output error information and stuff like that. At the very least, it seems to be a lot less abstract, as you’re working directly with the hardware.




  • I tried something like that once. Basically, I was trying to create an API with which sysadmins could script deployments. That involves lots of strings, so I was hoping I could avoid the String vs. &str split by making everything &'static str.

    And yeah, the problem is that this only really works within one function. If you need to pass a parameter into a function, that function either accepts a &'static reference which makes it impossible to call this function with an owned type or non-static reference, or you make it accept any reference, but then everything below that function has normal borrowing semantics again.

    I guess, with the former you could Box::leak() to pass an owned type or non-static reference, with the downside of all your APIs being weird.
    Or maybe your prototyping just happens at the top and you’re fine with making individual functions accept non-static references. I guess, you’ll still have to try it.

    Since you’re already at the bargaining stage of grief programming, maybe you’re aware, but Rc and Arc are the closest you can get to a GC-like feel. These do reference counting, so unlike GC, they can’t easily deal with cyclic references, but aside from that, same thing.
    Unfortunately, they do still have the same problem with passing them as parameters…



  • Yeah, I don’t think that can happen without splitting the whole ecosystem in half. Garbage collection requires a runtime, and tons of the code semantics are also just different between the two, particularly with asynchronous code.

    I also imagine that many people wouldn’t just leave their particular program in the GC version, but never even bother to learn the ownership/borrowing semantics, even though those largely stop being painful after a few months.

    But yeah, I actually don’t think it’s too bad to have individual parts of the ecosystem using their own memory management strategies.
    The two examples that I can think of are ECS for gamedev and signals/reactivity for UI frameworks. Which is what is used in C++ or JavaScript, Kotlin, too. You’d probably still want to use these strategies, even if you’ve got garbage collection available…


  • How many bugs you encounter is unfortunately not a good metric, because devs will compensate by just thinking harder. The goal is rather to not need to think as hard, which increases productivity and helps out your team members (including your future self).

    It took me a few months of working in an immutable-by-default language before I had the epiphany that everything is exactly like it’s written down in code (so long as it’s not marked as mutable). I don’t need to look at each variable and think about whether it might get changed somewhere down the line. A whole section of my brain just switched off that day.

    As the other person said, there’s also nothing stopping you from using mutability, it’s just not the default, because most variables simply don’t get mutated, even in C code.
    But I would even go so far that Rust is actually making mutability fashionable again. It has introduced various new concepts in this regard, which you won’t know from other languages.

    For example, you can opt a variable into mutability, make your changes and then opt out of it again.
    And if a function wants to modify one of its parameters, you have to explicitly pass a mutable reference, which is visible both in the function signature and where you’re calling the function.

    But perhaps most importantly, it blocks you from mutating variables that you’ve passed into a different thread (unless you wrap the value in a mutex or similar).
    In most of the immutable languages up until this point, the immutability was achieved by always copying memory when you want to change it, which is insanely inefficient. Rust doesn’t need this, by instead requiring that you follow its ownership/borrowing rules.

    Edit:
    I also don’t know what you heard, but this is for example written in Rust: https://bevyengine.org/examples/3d-rendering/bloom-3d/
    The code is right below. It uses lots of mutability…