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

help-circle
  • Ephera@lemmy.mltoProgrammer Humor@programming.devfoss
    link
    fedilink
    English
    arrow-up
    2
    ·
    6 hours ago

    To be fair, you can also somewhat steer whether it will take off as a dev, by how you promote it and how much time you take to make it easily usable by others. Many devs really don’t care to have their passion projects take off, because it means you’ll likely spend less time doing your passion thing, more time doing user support.



  • Ephera@lemmy.mltomemes@lemmy.worldI appreciate our community
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    15 hours ago

    Yeah, I get called a tankie on the regular now, just because my user account is on .ml and I still don’t actually know what it’s supposed to mean. Apparently, I’m supposed to have political opinions on topics that I’m significantly more ignorant on than the people who call me that.





  • Ephera@lemmy.mltoComic Strips@lemmy.worldShallow
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    2 days ago

    I have never heard a guy decline a girl because she is poor.

    I mean, I’ve never heard it said explicitly, and our still-largely-partriarchical society does expect and therefore respect penis-havers to bring home the money. So, it doesn’t matter that much, with how much money the person without the penis starts out with.

    But I do think class differences implicitly still play quite a big role.
    To some degree as part of secondary factors, for example you might look for an educated, physically fit partner, which a poor person cannot afford to take the time for.
    To some degree, you just won’t ever get to know certain poor people, because they might not be able to afford the same hobby as you, or shopping at the expensive store etc…

    But even if you do meet someone and they could tick your preferences, it is easy to dismiss their interest outright as just being about money, if you can tell that they have less of it than you.
    Even in a patriarchical society, you don’t particularly want to be the guy where friends and family snicker that you’re being used…


  • Yeah, as I’m implementing this, I’m also now noticing how problematic that crate split is.

    If you want to generate code which uses (non-generated) types that your crate provides in its public API, you have to re-export the macro from a separate crate that also re-exports the types.
    That in itself is clunky, but it’s just complexity for the implementer, not the user, so it’s fine.

    But where it stops being fine is that this means you cannot easily provide a usage example in the macro’s documentation.
    If you try to use it like normal, it has to generate code referring to your API crate, which will not be defined in your macro crate, so the documentation test won’t compile.

    So, basically your choices are:

    • Do some hacky horseshit, where you try to re-define the public API in the usage example.
    • Provide a usage example, which is not checked for compile errors.
    • Provide a usage example on the module that re-exports the macro rather than on the macro itself.
    • Don’t provide a usage example.

    And yeah… if you’ve coded Rust for long enough, you will recognize these patterns of bad/missing usage examples, which is particularly problematic, because proc-macros are rarely terribly obvious to use. Really hope they can fix this sooner rather than later.
    As far as I can tell, it would even be a valid fix, if editors and such consistently showed the documentation declared on top of the re-export, then you could write out your usage example there.






  • Ephera@lemmy.mltomemes@lemmy.worldWelcome to Germany
    link
    fedilink
    English
    arrow-up
    6
    ·
    4 days ago
    1. ß isnt used when you have a pair of s letters next to each other. Its most commonly used if you have long vowels beforehand. See “Trasse” vs “Straße”.

    Perhaps worth adding that we had a spelling reform in 1996, which kind of put this rule in place.
    If you learned German before then or had a teacher who learned it before then, it’s possible that you got taught it the old way…


  • Oh yeah, I’m not saying this is what makes Rust special. Rust’s strength in comparison to Bash is that it’s a lot more competent at control flow and structuring programs. But yeah, virtually any programming language is at least better at that than Bash, so whichever one you’re most comfortable with, is probably the best choice. This trick just allows you to make use of Bash’s biggest strengths, which is easily running commands and piping between commands, while also having the competent control flow and structuring of your programming language of choice.


  • “I think proc macros are a really big superpower for Rust.”

    Yeah, been working on a framework and proc-macros are really useful to simplify the API.

    For example, previously I needed users to define a struct and then an impl block with a function inside. Well, and they need to do that a lot, so it was genuinely a bit of a pain to write out, but it also made the code feel more complex than it really was.

    Now I’ve got an annotation, which you can slap onto a function and then it generates the struct from the function parameters and puts the function into the impl block.
    And while you do need to be aware that the function parameters will be put into a struct and therefore you want owned parameters, all-in-all it still feels really nice to just delete dozens of boilerplate lines and an indentation level in the codebases where I’ve introduced it.


  • One of the simplest tricks is that you can throw down a function, which you can call with a command like e.g. this: run("cat /etc/os-release | grep NAME")
    by constructing a Command like so:

    Command::new("sh")
        .arg("-c")
        .arg(command) //the string passed as parameter
    

    There’s proper libraries to make running commands even easier and more robust, but if you don’t want to pull in a library, that’s really easy to write out ad-hoc and gets you 95% of the way there, with shell piping and everything.



  • I really don’t agree with saving keypresses being a useful metric, since auto-completion is a thing and code is read significantly more often than it is written. I am also a staunch opponent of abbreviations being used for variable names.

    But I will say that I don’t mind abbreviations in keywords, since well, you need to learn the meaning either way.
    And yeah, I’ve come to somewhat like them being used for keywords, since it reduces visual noise where it really isn’t useful, and it distinguishes keywords from actual code.
    Ultimately, keywords are just syntax where letters were used instead of a symbol. You do read them like a symbol, so if they don’t look like a real word, that seems to work quite well for my brain.



  • 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:

    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.