HN user

mmoll

107 karma
Posts0
Comments29
View on HN
No posts found.

We once rented bikes in Copenhagen, they all looked like they were fresh from the junk yard. We had to try several to find ones where at least one of the brakes was still working. It was a horrible experience, and we tried several different places. That was after we found out that the public bikes that were supposed to be available all over the city had all been stolen.

Why Haskell? 2 years ago

True. I often think of Rust as a best-of compilation of Haskell and C++ (although I read somewhere that OCaml had a greater influence on it, but I don’t know that language well enough)

In real life, I find that Haskell suffers from trying too hard to use the most general concept that‘s applicable (no pun intended). Haskell programs happily use “Either Err Val” and “Left x” where other languages would use the more expressive but less general “Result Err Val” and “Error x”. Also, I don’t want to mentally parse nested liftM2s or learn the 5th effect system ;-)

If only I had known this earlier in my career! They should really add a feature to make a hard copy of the big bucket list to minimize memory overhead, though.

Misra C++:2023 3 years ago

Most standard containers have no way to communicate allocation failure to the caller in the absence of exceptions (think of constructors that take a size). Worse, the implementations I’ve seen would eventually call operator new, assuming it would throw if it fails. That is, subsequent code would happily start copying data to the newly created buffer, without any further tests if that buffer is valid. In the absence of exceptions, that won’t work.

Misra C++:2023 3 years ago

On the other hand, once your embedded system is sufficiently large, people will want to use (and inevitably will use at some point) standard containers such as std::string or std::vector. And without exceptions, all of those might invoke UB at any time (I have yet to see a standard library that understands and honors -fno-exceptions; usually they just drop all try-catch blocks and all throws)

Real const data doesn't exist

Ever seen a ROM?

And the C library‘s hacks around not being able to overload functions (which is the only reason for strstr et al‘s weird signature) wouldn‘t stop me from using const. It can be really useful both for documentation and for correctness. Think memcpy, not strstr.

But code using these monadic operations can also be quite clean… toy example:

   auto askForUsername = [&] { … };
   auto lookupUserByName = [&](auto name) { … };
   auto printUserDetails = [&](auto userId) { … };
   
   auto details = 
     askForUsername()
       .and_then(lookupUserByName)
       .and_then(printUserDetails);

A much better idea than that horrible asterisk and its pronunciation. However, I think it still misses the mark. There‘s an opportunity to make German simpler AND more gender-neutral by completely dropping both the masculine and feminine forms. Other languages have done so (or got really close) before. English and Dutch (not the Flemish variant) being the closest ones to German. Instead of saying „die Bürger*innen“, you could just say „die Bürger“, which would simply be the plural form of „das Bürger“. It also avoids the whole „Bürger* innenmeister* innen“ issue…