17 ms·
Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohi
by SQLite 10y ago
Go has chosen to omit assert(), because assert() is frequently misused they say. Antibiotics are also frequently misused, but that is not a good reason to prohibit them. The omission of assert() makes Go a non-starter.
Rust seems more promising, but it is still not to the point where I am interested in rewriting SQLite in Rust, though I may revisit this decision in future years.
Some current reasons to continue to prefer C over Rust:
(1) Rust is new and shiny and evolving. For a long-term project like SQLite, we want old and boring and static.
(2) As far as I know, there is still just a single reference implementation of rustc. I'd like to see two or more independent implementations.
(3) Rust's ever-tightening interdependence with Cargo and Git is disappointing.
(4) While improving, Rust still needs better tooling for things like coverage analysis.
(5) Rust has "immutable variables". Seriously? How can an object be both variable and immutable? I realize this is just an unfortunate choice of terminology and not a fundamental flaw in the language, but I believe details like this need to be worked out before Rust is considered "mature".
- noir_lord 10y agoPragmatism over "Oooh Shiny", one of the reasons I have huge respect for the sqlite project ;). Rust looks pretty decent but I'm still in the wait and see stage as well.
- jandrese 10y agoI was trying to teach myself some Rust and found the state of the documentation to be very frustrating. The core language is decently documented with the manual, but the standard library documentation was out of date in many places, most annoyingly in the first few hits on Google. I found 5 different ways to read a file on Google, and only one of them still worked. Plus I saw the release notes on the newest version that the syntax that worked is now obsolete in favor of a new operator.
- AsyncAwait 10y agoWhat are you missing from the up-to-date API reference[1]? [1] - https://doc.rust-lang.org/std/ https://doc.rust-lang.org/std/
- jandrese 10y agoI was trying to read a file one line at a time (reading only the first few lines of a very large file), and it turned out to be somewhat difficult as the built-in functions seemed to be really keen on operating on the entire file at once.
- steveklabnik 10y agoThe docs should never be "out of date" as in not working, though some parts don't have more than type signatures yet. Working on it. Please file bugs if something is not working, or swing by #rust-beginners, we love to help!
- sidlls 10y agoReally? I read the documentation for file I/O directly out of the Rust online docs and put together a complete serialization module for a project I'm working on. It was actually quite straightforward.
- ehsanu1 10y agoYou still have to be a bit careful about finding old posts and old docs on the internet about Rust, given that many APIs have only been stable for a short while. In general, unless you know your source is up to date, I'd recommend ignoring the internet at large completely when it comes to Rust APIs and just focusing on the official docs for the release that you're using. They're plenty good enough, though you do have to get used to navigating them.
- 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.
- AsyncAwait 10y ago> Rust has "immutable variables". Seriously? How can an object be both variable and immutable? "Immutable variables" is frequently used, true, but the official term is "immutable bindings".
- SQLite 10y agoReassuring news. Thanks.
- steveklabnik 10y agoTo elaborate slightly, there's three components here: let x = 5; let mut y = 6; The let statement binds a variable to a value: * x and y are the variables * 5 and 6 are values * let does the binding You can have an immutable binding, like x, or a mutable binding, like y. But most people turn "a bound variable" into "a variable" (or "an immutable variable") and "a mutably bound variable" into a "mutable variable".
- naasking 10y ago> (3) Rust's ever-tightening interdependence with Cargo and Git is disappointing. I can see the latter, but why the former? Package management that has understanding of language dependencies is a huge productivity booster. > (5) Rust has "immutable variables". Seriously? How can an object be both variable and immutable? I realize this is just an unfortunate choice of terminology and not a fundamental flaw in the language, but I believe details like this need to be worked out before Rust is considered "mature". A variable/binding is mutable, the object is not. I don't see the problem.
- the_why_of_y 10y ago> (5) Rust has "immutable variables". Seriously? How can an object be both variable and immutable? Variables have been called variables since the dawn of time, i.e., the lambda calculus, which doesn't even have assignment. The name derives from the idea that for every invocation of a function, a variable in its definition may be bound to a different value, hence it "varies" at runtime.
- dbaupp 10y agoFurthermore, it's terminology from mathematics, where, just like the lambda calculus, mutation isn't a thing: https://en.wikipedia.org/wiki/Variable_(mathematics) https://en.wikipedia.org/wiki/Variable_(mathematics)
- SwellJoe 10y agoThat's an interesting take. I don't think I've heard that complaint about go from anyone (other than you, I think, in a previous HN conversation). I've worked on code that had assert (Squid before the C++ rewrite, and it used assert correctly to the best of my knowledge), but I never considered it vital to the end result. Have you read about panic (https://blog.golang.org/defer-panic-and-recover https://blog.golang.org/defer-panic-and-recover)? I'm not meaning to assign you homework, as I know you know more about this than I do, I'm just curious what about assert makes it mandatory for you...panic in go does require you to write your own error check (presumably just an if, for assert-like behavior, but you could do more complex error-handling). All of your other comments are certainly valid reasons to choose C. Though I like cargo, and I suspect C would be well-served by something similar.