←back to thread

157 points matt_d | 1 comments | | HN request time: 0.495s | source
Show context
kubb ◴[] No.45136229[source]
For people using OCaml, there’s one thing that kinda discourages me in it, that is exceptions as part of the API in the standard library.

Because exceptions aren’t checked, this effectively means that a language designed for type safety has as much type safety as python, because it’s very easy to forget handling something, and get runtime errors.

How do you deal with this day to day? I assume it’s impossible to just believe that all the code you pull in doesn’t use exceptions?

replies(4): >>45136795 #>>45137250 #>>45137299 #>>45142057 #
1. johnisgood ◴[] No.45137299[source]
Your comment does not make much sense even if it is true.

Factor (Forth-like language) implements even its own ":" (defines a word, i.e. a function) using the language itself, it is not builtin, same with "if", and so forth. Thus, "MEMO:" or locals[1] ("::") being implemented as a library does not mean it is a bad thing, on the contrary, in the case of Factor, it makes it quite powerful. The object system is entirely implemented in Factor, too. "Large chunks of functionality are not part of the core language, they are in just as library".[2]

And to compare OCaml's type system to Python's is straight out absurd.

[1] Locals are entirely implemented in Factor, too, which is only about ~500 lines of code. It is not part of the core language, and on top of that, there is no performance penalty whatsoever!

[2] See more here: https://www.youtube.com/watch?v=f_0QlhYlS8g.