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

I wish Janet used Option types instead of using nil. No idea why modern Lisps don't borrow from Rust's goodness.


Lisps and nil have a symbiotic relationship, not an adversarial one.

They are an everyday falsy value that you program _with_ not around. Nil doesn't signal that you forgot to initialize a value. It simply means stuff like "I don't have this" or "no more". You don't check for it at every corner like an anxious squirrel, but pass it around freely, knowing that your code knows, accommodates and embraces nils.


Option types are inherently a bad idea for languages without value semantics. In rust, the Some variant of an option type can just be allocated on the stack at almost no cost, but doing this here would require a million small allocations every time you want to return something. Beyond that, it makes no sense to have union types when every value is already a union of all possible types.


I love option types, but I don't think they make a lot of sense in dynamically typed languages.


Agreed.

We used them at work (Clojure) and it didn't solve anything; normal idioms don't apply to monads and the mental overhead of having to know when they are used is the exact same as having to know when something might be nil.


Option types are from ML, not rust. ML predates rust by about 40+ years.


Rust did not invent Option types.


I would say from Boost C++ or from C++ std. Rust came far later.


Or from Haskell


Or OCaml


Or ML


Maybe


Oh, that’s funny.




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

Search: