6 ms·
>The omission of assert() makes Go a non-starter. A small syntactic sugar you can trivially implement yourself makes Go a non-starter? Go doesn't include asse
by mixedCase 10y ago
>The omission of assert() makes Go a non-starter.
A small syntactic sugar you can trivially implement yourself makes Go a non-starter?
Go doesn't include assert in the language because you're supposed to do better than assert. Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions. Go prevents you from compiling with unused variables, and that combined with the Go documentation goes a long way towards teaching new Go programmers how they're expected to work.
And neither Go nor Rust could possibly be good fits for SQLite. A Go hello world is bigger than all of SQLite while an idiomatic Rust one is on par, and neither's nearly as portable as the current C implementation, one that is both programatically and battle-tested like pretty much nothing else in the world.
- PDoyle 10y ago> Assert easily allows lazy programmers to let their programs freely crash without properly handling error conditions. This is what he meant by misuse. Properly-used assertions are meant to document and check conditions that were thought to be impossible by the developer. Not just unlikely, or illegal, but impossible. If a condition is possible, and you check it with assert, that's a bug.
- mixedCase 10y agoThose are panic territory, which carries a different connotation than the word assert (which has very likely influenced in its very widespread misuse).
- kruhft 10y agoThe biggest problem I've seen with assert[1] is putting functioning code inside one and then not knowing why your code no longer works with NDEBUG. [1] http://en.cppreference.com/w/c/error/assert http://en.cppreference.com/w/c/error/assert
- dvirsky 10y agoI came to detest assert when I was working on a project with another guy, who used it generously, as a substitute for assertions in (non existing) unit tests. Nothing would annoy me more than working on my code, running it, and having all sorts of weird assertions pop up all over the place from this guy's code.
- deleted 10y ago[deleted]
- jimmaswell 10y ago>Go prevents you from compiling with unused variables, and that combined with the Go documentation goes a long way towards teaching new Go programmers how they're expected to work. Things like this make me not want to use a language. Want to comment a=b; to a=3;//b temporarily? Too bad, either assign b to 3 or comment out b too, and if b was the only variable to make use of c, same for c, and so on. Same obnoxious nonsense as Java not letting unreachable code exist, making me have to comment out the rest of the function body if I want to put in a return in the start to test something, which happens often enough that it's a pain.
- mixedCase 10y agoYou can always use the black hole variable _ That mild inconvenience (which I almost never face while writing Go code after getting accustomed to the language and getting my editor to run goimports on save) has a big RoI in safety and program quality, which are much loftier goals than short term code-writing convenience.
- jimmaswell 10y agoI doubt the RoI is much more than if these were just suppressible warnings instead of errors, which work out great in C#.
- mixedCase 10y ago>which work out great in C#. They're greatly ignored in the real world.