Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Has Mozilla given up on Typestate? I see no mention of it in the release notes.


(Note: not a Rust dev, I just hang out in the IRC channel)

Typestate's still there for the time being, but it may not be for much longer. The problem is that it's not being used anywhere in the compiler, so it's not getting exercised nor is it providing any constructive design feedback. Last year there was an attempt to begin using typestate throughout the compiler and standard library, but it proved so clunky to use in practice that nobody had any patience to deal with it. So now there are two camps among the developers: those who consider the (quite large) subsystem to be a useless maintenance albatross, and those who would still like the idea of typestate but who acknowledge that it's not usable in its current form. Rust's BDFL appears to be slowly migrating from the latter camp to the former, so typestate may not be around for much longer.

Either way, making the whole thing work would require more effort than anyone has time for at the moment. Of course, this doesn't mean that it can't be removed now and then reintroduced in some future version of Rust.

Actually, wait, I remember asking Graydon (the Rust lead) about this. I was saving this for the 0.3 release discussion, so now's the perfect time:

  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.


Reformatted:

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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: