• 24 Posts
  • 985 Comments
Joined 5 years ago
cake
Cake day: May 31st, 2020

help-circle
  • I don’t have experience with Jujutsu, but I always have the same problem with these alternative frontends, which is that I’d still want to be proficient with the original. If you need to look up how to fix something or you want to help others in your team or you want to script something, then the language to speak is simply the Git CLI.

    And I don’t feel like I even use the Git CLI enough where a different tool could be so much better that it’s worth learning both.
    Obviously, your priorities may differ, but yeah, that’s just always the reason for me why I prefer the Git CLI, even if it were objectively more difficult to use.


  • It’s mainly horrid, because it means you have to code extremely defensively (or I guess, use a different API).
    You can’t rely on new Date("not a date") aborting execution of your function by throwing an error. Instead, you have to know that it can produce an Invalid Date object and check for that. Otherwise a random NaN shows up during execution, which is gonna be extremely fun to try to find the source of.

    I understand that it’s implemented like that partially for historical reasons, partially because it’s often better to display “NaN” rather than nothing, but it’s still the sort of behavior that puts me in a cold sweat, because I should be memorizing all kinds of Best Practices™ before trying to code JavaScript.




  • I mean, for what it’s worth, I’m a seasoned dev and just did a run where I tried to answer everything as it makes sense to me (which is “throws an error” or “invalid date” for all of them) and I also got a score of 4/28.

    …and two of those points were given to me, because the quiz interpreted my answer differently than I meant it.

    In other words, this quiz exists to highlight that JavaScript’s Date functions make no sense.




  • Not if you never get your application into production…

    Insert tips head GIF here.

    I wish this was as much of a joke as I’m pretending. It’s so common for software projects to get cancelled that lots of tooling differences are just in terms of how long they let you not deal with long-term problems and how violently they do then explode into your face.

    For most of the development lifecycle of a GCed project, you’re gonna ignore memory usage. And if you’re lucky, it can be ‘solved’ by just plonking down a thiccer piece of hardware…


  • Yeah, it’s easy to underestimate how big of a leap it is from a toy application to real-world usability. Not just in terms of security, but also:

    • useful error messages
    • logging / monitoring
    • configuration
    • building a distribution
    • deploying in a reproducible way
    • documentation
    • integration with existing infrastructure
    • data migration strategies
    • etc.

    This adds a lot of complexity, so you’ll need to learn additional complexity to be able to deal with it at all:

    • modularization
    • version control systems
    • software specifications (via unit/integration tests)
    • team communication
    • helper tooling, like package managers, linters etc.

    Learning about all this stuff takes years, especially if no one in your surroundings has much experience with any of it either. Professors don’t have the time to gain or retain this experience, since they already have a different full-time job.

    My advice would be to get students to do internships or to take a job as a working student in a company/organization. Sometimes, these can be shitty for the students, but they can often provide significantly more real-world context than college ever could.




  • Ah, interesting. I went from garbage-collected languages where thinking about ownership might be useful for keeping complexity low and occasionally comes up when you manage lists of objects, but ultimately isn’t needed, to Rust where well-defined ownership is enforced by the language.

    So, I wasn’t aware that ownership is even as concrete of a thing in other languages…







  • Yeah, these become a lot less relevant with routine.

    • Avoiding the main-thread panicking is mostly just a matter of not using .unwrap() and .expect().

    • String vs. &str can mostly be solved by generally using owned datatypes (String) for storing in structs and using references (&str) for passing into function parameters. It does still happen that you forget the & at times, but that’s then trivial to solve (by just adding the &).

    • “temporary value dropped while borrowed” can generally be avoided by not passing references outside of your scope/function. You want to pass the owned value outside. Clone, if you have to.

    • “missing lifetime specifier” is also largely solved by not storing references in structs.


  • The thing with OOP, particularly how it’s used in GCed languages, is that it’s all about handing references out to wherever and then dealing with the complexity of not knowing who has access to your fields via getters & setters, or by cloning memory whenever it’s modified in asynchronous code.

    Rust has quite the opposite mindset. It’s all about tracking where references go. It pushes your code to be very tree-shaped, i.e. references typically¹ only exist between a function and the functions it calls underneath. This is what allows asynchronous code to be safe in Rust, and I would also argue that the tree shape makes code easier to understand, too.

    But yeah, some of the patterns you might know from OOP will not work in Rust for that reason. You will likely need to get into a different mindset over time.

    Also just in case: We are talking OOP in the sense of the paradigm, i.e. object-oriented.
    Just using objects, i.e. data with associated functions/methods, that works completely normal in Rust.

    ¹) If you genuinely need references that reach outside the tree shape, which is mostly going to be the case, if you work with multiple threads, then you can do so by wrapping your data structures in Arc<Mutex<_>> or similar. But yeah, when learning, you should try to solve your problems without these. Most programs don’t need them.