5 ms·
I had similar? thought many years ago when strong typing became another one of the programming mantras touted on the internet. Even dynamically type programmin
by hackthemack 29d ago
I had similar? thought many years ago when strong typing became another one of the programming mantras touted on the internet.
Even dynamically type programming languages will layout what types the languages has. But that is usually the conventions built off of years of history, usually based on C.
But what if you wanted to define a custom type to use? Say you wanted to make type mysmallint, and it was an integer that is between 1 and 1000. Now, you can write up code to do this but it is not the same thing as declaring type int. *
*unless you are using Haskell, F#, or others I am not aware of.
What if you wanted to define a custom type that says this string only contains ascii characters? You can not easily define that as a type and pass it around the code. You have to write custom code and do checks.
- kamma4434 29d agoThis is one of the beauties of Clojure’s spec. You can define a ‘type’ that is a string which length is a prime number and contains only Ascii characters but ‘x’. To put those invariants in code and not in your head is so liberating.
- matltc 27d agoDon't know anything about clojure, but isnt this true with any language or library that implements schema validation? I'm thinking zod, for instance. Does clojure make it trivial?
- rramadass 28d agohttps://news.ycombinator.com/item?id=49381231 https://news.ycombinator.com/item?id=49381231