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

help-circle


  • I agree in general, that a crash is much better than silently failing, but well, to give you some of the nuance I’ve already mostly figured out:

    • In a script or CLI, you may never need to move beyond just crashing.
    • In a GUI application or app, a crash may be good (so long as unsaved data can be recovered), but you likely need to collect additional information for what the program was doing when the crash happened.
    • In a backend service, a crash can be problematic when it isn’t actually necessary, since it can be abused for Denial-of-Service attacks. Still infinitely better than failing silently, but yeah, you gotta invest into logging, monitoring and alerting, so you don’t need to crash to make it visible.
    • In a library, you generally don’t want to trigger a crash, unless an irrecoverable error happens, because you don’t know where it’ll be used.

  • Currently implementing error handling for a library I’m building and the process is basically to just throw all of the information I can find into there. It makes the error handling code quite verbose, but there’s no easy way for me to know whether the underlying errors expose that information already, so this is actually easier to deal with. 🫠



  • Ephera@lemmy.mltoProgrammer Humor@lemmy.mlCareer Advice
    link
    fedilink
    English
    arrow-up
    0
    ·
    11 days ago

    Last year, money was running out in our project and the guy who had trained me decided he’d take the L and move to another project, so we could continue in the project. And yeah, suddenly I was in the role of the lead developer.

    Like, don’t get me wrong, I would’ve been the one to be moved to another project, if I wasn’t up for the task. It’s not like I was a complete dumbass.
    But it did still feel more like “I guess, we doin’ lead development now” rather than something I had intentionally worked towards.





  • Ephera@lemmy.mlOPtoOpen Source@lemmy.mlWhat's up with FUTO?
    link
    fedilink
    English
    arrow-up
    3
    ·
    15 days ago

    From a communication viewpoint, that is fair, but to my knowledge (from being a professional software developer), effectively any license that is not ‘open-source’ or ‘free’ is by definition proprietary.

    Because those two terms describe licensing standards (the only established ones that I know of). Whereas I believe, “proprietary license” uses this meaning of proprietary:

    Nonstandard and controlled by one particular organization.

    So, they wrote that license themselves is the point. What it says in there is secondary in meaning.

    This is so highly relevant because in legal disputes, there is certain license compatibilities which are known to be possible.
    You can take a library licensed under the MIT license and use it in a project that uses the Apache-2.0 license and you’re perfectly fine. This is the foundation of why the open-source ecosystem exists at all.

    But you cannot take the source code from FUTO and use it in a differently licensed project, because no legal precedents exist to support this. (I believe, the FUTO license also actively prohibits this in some way, but that’s beside the point.)
    This has massive implications. Like, yeah, you can look at the code, but it is useless. If FUTO closes shop or enshittifies, you cannot fork their projects.
    And because you cannot legally re-use their source code in other projects, likely no one looks at it in depth either.




  • There’s no way they actually checked that it works. It includes code for:

    • XDG
    • GNOME
    • “GNOME_old”
    • KDE

    Verifying this would mean logging into several different desktop environments.

    It’s also extremely fragile code, running external commands and filtering through various files. There just is no good API on Linux for querying whether the desktop environment is using a dark theme, so it’s doing absolutely inane shit that no sane developer would type out.

    Because it’s a maintenance nightmare. Because they almost certainly don’t actually need to solve this. That’s software development 101, to not write code that you don’t actually need. But apparently some devs never got the memo that this is because of the maintenance cost, not because you weren’t able to generate the code up until now.


  • I figured, I’d involuntarily sign up for counter suggestions by posting this. 😅

    Using lib.escape is a good idea, thanks.

    But yeah, basically I want to configure Alacritty and I’m using the respective home-manager module.
    Even more specifically, I want to pass stuff, including a regex, into the settings parameter, which more-or-less just takes the Nix expression that I shove in and then outputs it as TOML on disk.

    As for how I would’ve liked this to work:

    But the TOML is templated with "double-quotes", so I do need to escape the regex after all.

    I did just try to understand how the Alacritty module does the templating and found this gem:

    # TODO: why is this needed? Is there a better way to retain escape sequences?
    "substituteInPlace $out --replace-quiet '\\\\' '\\'"
    

    Source

    So, that doesn’t fill me with a whole lot of confidence. 🙃

    But yeah, it’s working now without me having to write a whole bunch of backslashes, so that’s good enough in my book.


  • I guess, there’s technically nothing which dictates that a debugger has to work by stepping through a program. It could also present you some diagram of variable values changing over time. But yeah, gonna be hard to find a more useful representation than those values being interleaved with your logs, at least for most applications. I have heard of more advanced debuggers being used in gamedev, which makes sense, since logs aren’t nearly as useful there.

    But yeah, given that most people think of the stepping debuggers, them being the default advice does feel emblematic of our industry still shying away from concurrency.


  • This meme brought to you by me trying to pass a regex from Nix into a TOML, which is certainly not the worst backslash orgy I’ve seen, but tragic in its own right. Both Nix and TOML have a way to specify raw strings, which do not need escaping. But Nix uses a normal string when passing into TOML, so I do have to escape anyways. 🫠

    My regex also contains a double-quote, which was just guesswork as to how many backslashes I need there.




  • Ephera@lemmy.mltoProgrammer Humor@lemmy.mlAlways happens
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    I’ve been trying to basically build a library that helps you put together a distribution archive.
    And my initial plan for the API looked something like this:

    Distribution::new("my-program")
        .dir("assets")
        .file("favicon.png", |path| build_favicon(path));  // "|path| ..." is a lambda function that gets the target path passed in
    

    So, it would allow you to define the file structure, and for the parts that actually need to be built, you’d provide a lambda function, which it would automatically run or not, depending on whether the inputs changed.

    Right, inputs, what are those? I kind of need my user to tell me. So, I decided to implement the caching as a separate API, which you would call on your own when you get called by the lambda function.

    Then I realized, I kind of don’t need the lambda function then. I could just construct file paths and then my user calls their build_favicon(...) function or similar on their own.

    There is just one crucial problem with that. This is what the file API in the stdlib looks like:

    PathBuf::new("my-program")
        .join("assets")
        .join("favicon.png");
    

    I might not have built anything, really. 🫠



  • Ah, I’m not talking about Ruby, I’m talking about language design in general.

    I’m currently mostly doing Rust, so I can only really name that as an example (even though there’s very likely other languages that allow this, too), but yeah, here’s for example the 64-bit signed integer in Rust: https://doc.rust-lang.org/stable/std/primitive.i64.html

    That is a primitive type, not an object, so it is exactly 64-bits in size and stored on the stack, not the heap. But as you can see in the documentation, Rust allows for associated function anyways, like for example:

    let my_number: i64 = -3;
    my_number.abs()  //returns the absolute value, so 3
    

    That’s because that last call is just syntactic sugar for calling the same function statically on the type:

    i64::abs(my_number)
    



  • Ephera@lemmy.mltoProgrammer Humor@lemmy.mlPython!
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    I do think, it’s fair to use Python code which uses C under the hood in benchmarks, because it does often match reality. But then it also has to be realistic code. If it’s just a single line of Python code, which calls into C and then everything happens there, then there is really no point for you to use Python.

    Python only makes sense to use, if you do write some amount of glue code with it. And then it does require significantly more skill to write performant code than it does with many other languages, as lots of costly abstractions are hidden from you. And it often also requires more effort, since you might not find performant libraries, since so much of the ecosystem only has performance as an afterthought. Reality is messy, which is why realistic Python code still tends to do terribly in benchmarks, whether it calls into C or not.