Hacker News new | ask | show | jobs
by dochtman 4989 days ago
IIRC, typestate was one of the big things in the initial releases/presentations of Rust. Is there an overview/discussion/ideas on why it ended up being removed?
2 comments

One such discussion in the mailing list: https://mail.mozilla.org/pipermail/rust-dev/2012-July/002094...

An example github issue discussing problems encountered: https://github.com/mozilla/rust/issues/1105

I asked Graydon about this near the release of 0.3. Here's the exchange:

  me:      so what were the reasons that nobody ever used typestate? was it just too cumbersome?
  graydon: combination of incomplete and wound up not often able to benefit from much code-path-distance between site of check and site of constraint-enforcement.
  graydon: I'm still unconvinced that could not be overcome
  graydon: but the result is that using it has effectively caused all callers to do checks just before they call, which isn't much of a win
  me:      graydon: was typestate the whole reason you started rust in the first place? I'd be really interested to read a retrospective :)
  graydon: no, I started rust because I was sick of hacking in C++ and wanted something with a saner compilation model, grammar, safety properties, concurrency properties ...
  graydon: I'd used lots of other languages and kept not being able to use them in an industrial setting, because they failed to be similar-enough to C++ in important ways, usually.
  graydon: typestate was just a property that hermes had that I liked because it looked like a way to statically optimize DBC, which I like in languages that have it
  graydon: (sather, eiffel, some of the C# derivatives)
  graydon: I tend to program over-defensively when left to my own devices. make copies of every datum to be local. make everything const. run a lot of internal consistency self-checks. etc. etc.
  graydon: (the one habit I hadn't picked up yet, which I'm still trying to, is adequate unit testing and fuzzing ... sigh)
  me:      graydon: so are you confident yet that even if someone was forcing you to write rust, you would't be sick of it? :)
  graydon: my experiences writing rust so far have been pretty positive. it has a number of the parts I like in other languages. the grammar is simpler, the compilation model is better, it's AOT and static, it has algebraic types, clear integer types, is eager and reasonably fast, doesn't force OO style...
  graydon: and crucially: doesn't need to allocate / GC like crazy, so can close that residual gap on inner loops without having to hit the FFI
  graydon: there are still odd bits we need to whittle down
  graydon: oh also the safe references are lovely. and getting better.