• 5 Posts
  • 299 Comments
Joined 1 year ago
cake
Cake day: June 19th, 2023

help-circle

  • The more I read about these kind of article the more I am amazed that our digital future is at hand in utterly incompetent people.

    This person clearly have no understanding of monadic error (AKA Maybe/option monad or slightly more advanced Either monad), which is the first monad we teach at a class targeting second year undergrad.

    The performance comparison is just plain factual error. The functional error code will continue to compute n2 when computation of n1 failed; the same do not happen in the exception version. If you compare codes with completely different traces, of course they will have different performance…

    A properly implemented monadic error will return as soon as compute for n1 failed, and never execute the rest of the code. This is the default and idiomatic behavior in Haskell, OCaml, F#, and rust. This performance problem doesn’t even happen in LINQ-style handling like in C# and Kotlin (maybe also Typescript?).

    The point of monadic error is that its control flow is local, whereas exception is non-local. Specifically, the exception can be handled and occur anywhere in the code base, with no indication on the type level. So programmers will be constantly worrying about whether the exception in a function call is properly handled.

    Even worse, when you try to catch a certain error, there is always the risk to accidentally catch similar exceptions in a library call or someone else’s code. Writing good code with try-catch requires a lot of principle and style guides. But unlike monads, these principle and rules cannot be enforced by the type system, adding extra burden to programmers.

    In fact, we have known for a long time that non-local control flows (goto, break, contiune, exception, long jump) are the breeding ground for spaghetti code. As an evidence, many non-local control flows (goto, long jump) are baned in most languages.

    That being said, there are certainly cases, with proper documentation, that exception style is easy to write and understand. But I think they are very specific scenarios, which have to be justified on a case-by-case basis.















  • recently I have encountered a problem with this, it is indeed not so straightforward to create a bootable windows 10 USB instillation media under linux.

    The media created by fedora media writer is not bootable and the media created by ventoy lacks drivers. I was then able to create a media quite easily with the last windows machine in my household. I don’t know if it is a temporary bug or fundamental incompatibility.

    So I would suggest you to keep a windows installation media at hand in case you need to switch back, or make sure at least one of your friend has a windows machine you can borrow.