Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)E
Posts
112
Comments
5167
Joined
6 yr. ago

  • I'm not sure, what you mean by "Chekhov's footgun", but well, it isn't a footgun, so you won't accidentally return a wrong value from the function, if that's what you're thinking.

    It's not a Rust invention, most functional programming languages have implicit returns, but basically think less of them as a function return and more just as the value that a scope evaluates to.

    So, here's a simple example:

     rust
        
    let sum = {
        let x = 5 + 9;
        3 * x
    };
    
    
      

    Obviously, this is an extremely contrived example, but yeah, as you can see, it does not even have to involve a function. The implicit return makes it so that sum is set to the result from 3 * x.And the scope-braces are nice here, because you can do intermediate steps without having x in scope for the rest of your function.

    In practice, if you see scope-braces and the line at the end does not have a semicolon, then that's the value that the whole scope evaluates to. Those scope-braces can also be the braces of a function, but then you need to annotate what the function is going to return, too, so it's practically impossible to return a wrong value.

    Well, and I would actually argue that explicit returns are a footgun in comparison.Because someone might introduce clean-up code at the end of the function and not realize that an explicit return skips that clean-up code, somewhere further up in the function.The implicit return always has to be at the end of the scope, so it's not possible to accidentally skip code.

  • That is, like, genuinely an advantage, though. At $ DAYJOB, we have a project that spans embedded, backend, web frontend and CLI, and for all of these, Rust is decent.

    Like, I can see why a frontend dev would want to use HTML+CSS+JS/TS (rather than HTML+CSS+Rust), mainly because the massive ecosystem of JS components makes you more productive.

    But you pretty much won't ever develop a web frontend without an accompanying backend, and then being able to use the same language-expertise, libraries, utility functions and model types, that is also a big boost to productivity, especially if you won't have a dedicated frontend dev anyways.

    Realizing that also made me understand why people subject themselves to NodeJS for their backend, which has the same advantage, just with the big ecosystem in the frontend and the small ecosystem in the backend.

  • Fuck Microsoft

  • me_irl

    Jump
  • Nah, it's gotta be boobies

  • Very interesting, thanks! 🙂

  • Huh, did that emerge out of unrelated design decisions or did they just figure

  • Donner is German for "thunder"...

  • I know some of my programs used to have lines with just x.unwrap().unwrap().unwrap() or whatever, which is not pretty.

    That goes away with experience, though. At least, I can't think of a reason why you'd nest three Results or Options. Normally, you would collate them right away.

    The most you see in the wild is something like Result<Option<_>> to express that a check can fail, but even if it doesn't, then a valid result can still be that there is nothing there.

    If you don't care that your program crashes (like .unwrap() does), then anyhow is the error handling library of choice. With it, you can just write a ? in place of an .unwrap() for practically any error type. And well, it automatically combines the errors, so you won't be writing ??? either.

  • To be honest, I think, they both have their place. In Rust, you typically wouldn't return just a bool, but rather the element that you removed, so like this:

     rust
        
    fn getofmylawn(lawn: Lawn) -> Option<Teenager> {
        lawn.remove()
    }
    
      

    And then with such a more complex return-type, C-style means that you can't see the function name right away:

     c
        
    Option<Teenager> getofmylawn(Lawn lawn) {
        return lawn.remove();
    }
    
      

    I also really don't think, it's a big deal to move your eyes to the ->...

  • Yeah, I was gonna say, error handling easily makes up 80+% of the code paths, and depending on whether you're building a library or service or script etc., different strategies are most suitable for how to deal with those code paths.

    In a script, you often just want it to crash. In a library, you want to make these code paths matchable, in case the user cares why something failed. And then you have the awkward in-between, which is that 99% of your application codebase will be used by your main-function like a library, but you don't want to spend as much effort on error handling for that as a proper library does, in particular also because you know what all consumers of your application-library need to know.

    So, it's kind of multiple different problems, with overlap, and people are hoping for one easy solution to cover all these problems.

  • For Germany, there's also https://www.gesetze-im-internet.de/index.html which lists the laws in their current version, similar to dejure, but well, the webpage is actually hosted by our government. It's as official as you're gonna get on the internet.

  • Hmm, well, no idea then. Maybe you do just not like the taste then. ¯(ツ)_/¯

  • Same here in Germany, but only for the German word "Ingenieur". You can call yourself "engineer", no problem. 🥴

  • As I understand, there's some genetic invariant, which makes them taste like literal shit to some folks. I think, the same is then true for broccoli and presumably other brassica cultivars...

  • A few years ago, a colleague had the title "software craftsman", because he thought it was utter bullcrap to call our profession "software engineer".And yeah, now that I'm part of a project for a few years, I'm definitely feeling "software mechanic". I might install half a spoiler every so often, but aside from that, it's mostly just repairs...

  • Add computer science and you have a programmer.

    I mean, while this definitely does happen in reality, in particular if you count data scientists towards programmers, I feel like I need to point out that neither knowing computer science, nor maths, makes you a good programmer.

    In fact, if you tell me someone is a computer science professor, I will assume that they are a bad programmer, because programming takes practice, which is not something they'll have time for.

  • Yeah, although it doesn't mean that, say, the top 10 pop songs aren't blander today than they were 50 years ago.

    I've heard it argued that Spotify pushes songs to be blander, for example, because:

    • they don't typically get played back as part of an album anymore, so they're more samey in that they all have to work as a single,
    • you don't want to be the song that stands out, where the user presses Skip, because Spotify will rank those lower, and
    • lots of folks now consume music as background noise, so the intricacies of a guitar solo, which would've hit like a truck for active listeners, are often just drowned out by traffic noise or may just be too much to take in while you're learning for school or whatever.

    Having said all that, there is the flipside that the top 10 pop songs are less relevant than ever. You've got practically an infinite supply of songs to choose from, so you kind of just have to find the good stuff.That is work, I admit, so I can understand a certain level of frustration, but yeah, it is also something to be excited about, that there is such a huge selection to choose from.

  • I always just do ss -ltnp | grep <port-number>, which filters well enough for my purposes and is a bit easier to remember...

  • Dungeon Crawl Stone Soup @lemmy.ml

    0.32 “Gods and Makers”

    crawl.develz.org /wordpress/0-32-gods-and-makers
  • ich_iel @feddit.org

    ich🎓iel

  • VeganDE @discuss.tchncs.de

    Hülsenfrüchte richtig kochen

    landeszentrum-bw.de /,Lde/Startseite/wissen/huelsenfruechte-richtig-kochen
  • ich_iel @feddit.org

    ich🌰iel

  • VeganDE @discuss.tchncs.de

    Neue Ketzerei: Tofu in der Butterdose

  • ich_iel @feddit.org

    ich📦❌➡️📦iel

  • Vegan Circlejerk @lemmy.ml

    Red lentils <3

  • Vegan Circlejerk @lemmy.ml

    Milk Gymnastics

  • Programmer Humor @lemmy.ml

    Throwing a whole tech stack at this problem...

  • Web Development @programming.dev

    Hardest Problem in Computer Science: Centering Things

    tonsky.me /blog/centering/
  • Programmer Humor @lemmy.ml

    When you support package managers from A to Z...

  • You Don't Surf @lemmy.world

    July

  • Dungeon Crawl Stone Soup @lemmy.ml

    Of course...

  • Dungeon Crawl Stone Soup @lemmy.ml

    So close and yet so far...

  • Programmer Humor @lemmy.ml

    Spent 10 minutes debugging...

  • Programmer Humor @lemmy.ml

    Someone pushed the wrong thing to production...

  • Programmer Humor @lemmy.ml

    Single-Page Application

  • Dungeon Crawl Stone Soup @lemmy.ml

    0.31 “The Alchemy of Forms”

    crawl.develz.org /wordpress/0-31-the-alchemy-of-forms
  • Dungeon Crawl Stone Soup @lemmy.ml

    Mirror Match

  • Memes @lemmy.ml

    Lies and Slander