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

Don't immutable data structures give us most of the benefits? Clojure, for example, approaches this by preferring values over hidden, mutable state (e.g. classes). We see libraries like Om take advantage of the fact that comparing two complex structures (e.g. a hash map) is simply a reference equality test.

http://clojure.org/state

http://swannodette.github.io/2013/12/17/the-future-of-javasc...



Not at all. Linear types ensure that types are "used" exactly once. Mutability would correspond to type creation while reading would be a use.

For a fun little example of thinking in linear types, take a look at Brent Yorgey's blog post: http://byorgey.wordpress.com/2011/02/24/enumerating-linear-i...

(Edit: The Yorgey post listed links to the whole cycle, but it begins here: http://byorgey.wordpress.com/2011/01/26/counting-linear-lamb...)


Immutable data structures give us many benefits, but linear types promise most of those plus safe mutability. Think of it as a compile-time proof that you'll be getting vector fusion style speed-ups.


Clojure transients are linear types.


How? Please refute this claim: "Transients have very little, if anything, to do with types."

Why would I claim this? Transients are about the internal nature of a function but have nothing to do with the return value or type. See "Transient data structures are a solution to this optimization problem that integrates with the Clojure model and provides the same thread safety guarantees you expect of Clojure." at http://clojure.org/transients


Transients are a different type from the corresponding persistent, as seen by the fact that different operations are supported. Clojure's programmer-facing type system doesn't expose the transient type explicitly, but the semantics certainly implements a linear type system.

From the page you linked:

"""

Capture return value, use for next call

Not persistent, so you can't hang onto interim values or alias

"""

From Rich Hickey himself: http://www.infoq.com/interviews/hickey-clojure-protocols

More context: http://c2.com/cgi/wiki?LinearTypes




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

Search: