• 20 Posts
  • 1.2K Comments
Joined 5 years ago
cake
Cake day: May 31st, 2020

help-circle


  • Ephera@lemmy.mltoRust@programming.devstruct in Rust
    link
    fedilink
    English
    arrow-up
    10
    ·
    5 hours ago

    Maybe one thing to add, in addition to methods, you can also have associated functions, by leaving out the &self parameter:

    impl Point {
        fn new(x: i32, y: i32) -> Point {
            Point { x, y }
        }
    }
    

    You call this function like so: Point::new(3, 5)

    The example is quite deliberate. Most of the time, these associated functions are used for constructing the type itself, especially if you need to do more complex things for that than just initialize the struct. At that point, you don’t have an object yet, so you couldn’t be taking it as &self anyways. 🙃



  • Yeah, that frustrates me a lot, too. They almost had it right, that they need to go beyond realism to make truly good-looking games. But in practice, they say that only to show you the most boring-ass graphics known to humanity. I don’t need your pebbles to cast shadows. I can walk outside and find a pebble that casts shadows in a minute tops. Make the pebbles cast light instead, that could look cool. Or make them cast a basketball game. That’s at least something, I haven’t seen yet.






  • The big problem for these AAA studios is that this is their unique selling point. Hyper-realistic graphics and sprawling game worlds. If they stop doing these, they’re hardly different to the games from five years ago (which you can still buy and cheaply at that). And they’re hardly different from indie titles. They would enter quite the competitive market.

    I do agree that we’re at somewhat of a breaking point. The production costs grow to absurd levels. The graphical advances are marginal. And not many gamers can afford the newest hardware to play these titles. But I don’t think, there’s an easy exit strategy for these AAA studios…


  • Also, do we just trust all these random libraries? Not just about malicious code, but also what kind of quality/usability are you including?

    I mean, no, I don’t trust them. At best, I largely trust the libraries that I’ve included directly, and somewhat trust them to themselves pick libraries which don’t look too fishy. But I do not know what most libraries in my project actually even do, so it would be ridiculous to claim that I trust them.

    In terms of quality/usability, well, Rust has the advantage that the compiler is very strict and checks a lot of things. If it compiles, it’s already half-decent.
    You also get easy access to a linter and unit testing. Documentation tooling is built-in. If you put in the tiniest amount of effort, it’s really not hard to create something usable.

    Rust, like JS, also locks the dependencies. So, it picks out a set of versions that works together and then it documents those versions (as well as checksums of the libraries) in a file, which you put into the repo. And then it uses those documented versions until I run cargo update to grab new versions. So, if a library author pushes a malicious version, I won’t be affected unless I do run cargo update at the wrong time. This gives the ecosystem at least some time to react or to find malicious code, if it’s been included in an inactive state. Certainly no silver-bullet, but it makes it less attractive for malicious devs to try to include malware in a library.

    The huge benefit of the standard library is that I can always trust it, and it will always be the idiomatic way to do things.

    Well, counter-example: Python.
    Python chose to have a pretty big std lib, which kind of makes sense, because you want scripts to be able to run without having to install dependencies first.
    But as a result, Python’s std lib also has relatively poor quality, with sometimes just bugs or unexpected behavior in there. And if you look online how to do XYZ, chances are half the people will tell you to use the std lib and the other half will tell you that the std lib is awful, you should use xyzlib instead.
    In general, in many languages, parts of the std lib get implemented before anything else, when the language typically hasn’t found its style yet. In Python, you can see that, for example, with some stdlib functions not using snake_case. So, I kind of get what you mean with “idiomatic”, in that it’s normal to use the std lib, but the way how you invoke that std lib function may not be idiomatic at all…


  • Speaking as a Rust programmer, I feel like the biggest hurdle to using libraries in place of one-liners, is finding out about those libraries. At some point, you’re going to search “How to pad string in Rust/JS?”. And then StackOverflow, or an LLM mindlessly parroting it, will tell you to use leftpad, or well, in the case of Rust, this functionality is actually in the std lib.

    So, I’d say, it actually depends a lot on the culture of a given programming language, whether the use of a library will be the top response or a short code snippet.
    And I do feel like JS is in somewhat of a special spot in this regard, having been designed by committee, so there’s some really silly omissions from the std lib. And it’s also often used by hobbyists, who just dish out a project and then move on, never having to deal with the dependency hell that follows…



  • We do. We even have an accompanying rant.

    This meme was, uhm… inspired by Jamendo.
    Great service. You can download Creative Commons music for the cost of creating an account there. That’s at least part of why it’s “Oh dear, oh dear. Gorgeous.”.

    But well, the button for downloading whole albums is broken.
    So, what I’ve been doing, is to just open each song in a new tab, and then repeatedly click download → confirm → close tab.
    And then by resizing the window, it’s even possible to align the download- and confirm-buttons, so it’s just double-click → Ctrl+W.

    But because of said loading screen, I have to remember to resize the window before I open all the tabs. Otherwise, I’ll get the loading screen every single time I’m put onto a new tab.

    I’m guessing, it doesn’t use CSS to do the responsiveness, but rather it’s JavaScript that grabs the window dimensions and calculates how big everything has to be. But it doesn’t get told about the window having been resized until the tab is shown again, and because the JavaScript rendering is slow, you get this short loading screen every single time.


  • I have both my parents on KDE with essentially the defaults. They came from Windows 7, so many things were familiar to them, like the systray in the bottom-right, the start-menu in the bottom-left and so on.

    I mostly decided to go with KDE, because I use it myself. My dad can be extremely negative, so being able to tell him, nope, it works on my machine, often defuses the situation. But I also expected my parents to potentially want lots of little tweaks, which well, it didn’t happen.
    They use a browser and a printer, that’s basically it. I have considered setting up an E-Mail client for my dad, and thought about setting up tiling window management for my mum, but done nothing so far. The OS could boot straight into Firefox and they would hardly notice.

    As such, I’m definitely fine with how little problems they’ve had using KDE.
    One time, I noticed my dad had a million tabs open in the file manager, because that got updated to remember open tabs, and something he did, would always open a new tab in there. Another time, he had managed to create a second panel, which sat at the top of the screen wasting space.
    So, it would be somewhat nicer, if he couldn’t do that stuff, but at the same time, it’s not really a problem and I learned computers by dicking around, too, so I really don’t feel like I want to lock that down somehow.

    A dumb thing he did one time, which he could do independent of the desktop environment, is that he deleted all the folders in his home-directory. Intentionally. He has this habit of cleaning everything up, completely disregarding that he has like 99% free storage space. Again, he doesn’t really use much beyond a web browser, and he didn’t find out about hidden folders, so the only real effect was that his wallpaper disappeared.

    I don’t think that’s the answer you wanted, but yeah, I would not want to lock them down to prevent this stuff from happening, unless it really becomes a problem.


  • They’re being defined right in this post. 🙃

    Prolog is a language that allows you to specify a whole bunch of rules/axioms and then you can query logical conclusions that can be made from these.

    If you go to https://swish.swi-prolog.org/ and click on “Create a [Program]”, then paste the post text on the left side (without the Theorem 1, as that one doesn’t compile), then you can query it in the bottom right.
    For example, if you ask it between which keys there’s a gap of just 1 semitone:

    ?- semitone_gap(X, Y, 1)
    

    Then it will first tell you that X=e & Y=f, as the first possible solution. Then you can click “Next” and it’ll tell you another solution is X=b & Y=c.



  • As a vegetarian, I wouldn’t care much for it. I feel like the plant-based alternatives have got everything covered I could want from meat (and more, if you look beyond Western cuisine). And then I just feel like it’s hard to compete with them in terms of sustainability, efficiency, price etc… In particular, I also really cannot be fucked to put more perishable things into my fridge. I had bought these meatball-like things for Christmas, but didn’t eat the whole load on the first go, so had to cram them in a few days later. Meanwhile my lentils, beans, TVP, peas, nuts etc. just sit there for months, not needing any of my attention.