logoalt Hacker News

Tweyyesterday at 6:40 PM2 repliesview on HN

> The reason for this is that in Rust, a struct couples type-checking to a fixed data representation. You can't get one without the other.

> Clojure decouples data representations from type checking.

This is funny to me because seen from the other side, (this) Clojure couples runtime type information to data structures: you're no longer allowed to define a data structure that doesn't have some runtime type information attached. A fixed static structure is just the consequence of not adding dynamic type information.

Meanwhile in Rust you can get type-checking ‘without’ a fixed structure by using trait objects.


Replies

weavejestertoday at 1:35 AM

Regardless of whether the type information is static or dynamic, you're still coupling some type to some data. The type is still implicit even after compilation; there still exists a structure to the data, even if that structure isn't easily discerned without the source. Or to put it another way: just because there's no runtime type information, doesn't mean that the data now is entirely decoupled from the type.

stephenlfyesterday at 7:28 PM

Yeah that example was pretty flimsy and contrived.

show 1 reply