the fact that == and .equals() both exist and == is the bad one is a fucking disgrace to every language that doesn't allow == to do sensible things. JS in particular is terrible for this - it has Object.is to do identity comparison but === also does identity comparison. and as far as I can tell typescript-eslint can't be configured to yell at you if your === is useless.

this is why I don't respect Zig or other languages that brag about not having hidden control flow. you know what hidden control flow is? it's a fucking encapsulation. and encapsulations are good.


You must log in to comment.

in reply to @cactus's post:

imo not having operator overloading is a mistake in zig and shouldn't have anything to do with their stance on hidden control flow.

like they say "in c++, d, and rust the + operator might call a function" but like that's literally what every operator does? operators execute code? in zig if you use an operator on large enough numbers, it will literally emit a 'call' instruction into a compiler-rt function?

what they actually mean is that '+' is guarenteed to be a pure function. and that has nothing to do with 'hidden control flow'


i think the no hidden control flow thing is a nice ideal though when you're not using it to justify not having operator overloading

  • functions can't cause exceptions that jump to some parent handler - errors are regular return values instead like in rust
  • types can't put deinitializers that execute whenever they feel like it like in c++ - you use the defer statement to say when to run the deinitializer

this way a function can only ever do one of two things: return or crash/hang the program. and preferably it never does the second one. but this is zig so like. it probably will.