I would take the FP zealots more seriously if they stopped asserting that FP makes things more correct. Zero evidence that this is the case. I can tell you that debugging a compiler written in ML is a dumpster fire compared to debugging a compiler written in C++. If take C++ over any FP language for compilers any day of the week.
> I would take the FP zealots more seriously if they stopped asserting that FP makes things more correct. Depends on the correctness requirements in question. But overall you are 100% correct about this. FP, among other aspects, enables and promotes some ways of reasoning, for instance when mutation is avoided, that can be relatively easy to use to verify correctness of certain types of properties. For instance, indu…
OCaml Programming: Correct and Efficient and Beautiful
41–50 of 60 posts
Re: OCaml Programming: Correct and Efficient and Beautiful
#42Earlier quoted context omitted.
There is no evidence that any of those things lead to more correctness. It’s all feels
There's plenty of evidence. Here's the OCaml compiler catching a redundant rule in the Unicode line-breaking algorithm: https://www.unicode.org/mail-arch/unicode-ml/y2020-m03/0000.... People who like rejecting this kind of stuff as 'feels' are ironically also being guided by their 'feels'.
Re: OCaml Programming: Correct and Efficient and Beautiful
#43Could an OCaml expert give a quick take on the view that if FP, why not go all the way and do Haskell instead? I mean, if "correct, efficient, beautiful" are attributes of OCaml (and I know opinions differ, but let's assume for a moment..) then shouldn't they be attributes of Haskell too, maybe even more so in some ways?
FP is great but not necessarily at all costs. OCaml is immediate by default instead of lazy, and allows imperative code with side-effects. Both escape hatches from the pure FP world. So, performance is easier to reason about and you can interact with your side-effecty real world stuff without having to reorganize your whole program around the correct monad. Most of the time you want your loops to be higher order func…
Laziness by default was definitely an opinionated design choice for a language when using it in production
Re: OCaml Programming: Correct and Efficient and Beautiful
#44Earlier quoted context omitted.
FP is great but not necessarily at all costs. OCaml is immediate by default instead of lazy, and allows imperative code with side-effects. Both escape hatches from the pure FP world. So, performance is easier to reason about and you can interact with your side-effecty real world stuff without having to reorganize your whole program around the correct monad. Most of the time you want your loops to be higher order func…
It's really worth noting that one of the biggest real world Haskell codebases in the world (ie Standard Chartered) wrote their own compiler to make Haskell evaluation strict and make it easier to do interop with C++ Laziness by default was definitely an opinionated design choice for a language when using it in production
Re: OCaml Programming: Correct and Efficient and Beautiful
#45Could an OCaml expert give a quick take on the view that if FP, why not go all the way and do Haskell instead? I mean, if "correct, efficient, beautiful" are attributes of OCaml (and I know opinions differ, but let's assume for a moment..) then shouldn't they be attributes of Haskell too, maybe even more so in some ways?
FP is great but not necessarily at all costs. OCaml is immediate by default instead of lazy, and allows imperative code with side-effects. Both escape hatches from the pure FP world. So, performance is easier to reason about and you can interact with your side-effecty real world stuff without having to reorganize your whole program around the correct monad. Most of the time you want your loops to be higher order func…
Re: OCaml Programming: Correct and Efficient and Beautiful
#46I would take the FP zealots more seriously if they stopped asserting that FP makes things more correct. Zero evidence that this is the case. I can tell you that debugging a compiler written in ML is a dumpster fire compared to debugging a compiler written in C++. If take C++ over any FP language for compilers any day of the week.
OCaml is not just FP. It's FP + strong static typing + modular programming + exhaustive pattern matching + fast compiles + great set of built-in compiler lints (eg unused code warnings, mutation warnings). All of these things together help write very reliable code.
Re: OCaml Programming: Correct and Efficient and Beautiful
#47I just want OCAML to have curly braces, please. And the variable scope thing in OCAML is extremely off putting.
You can use the ReasonML syntax with the standard OCaml toolchain, it's the same language with curly braces. (Not to be confused with ReScript which spun off of it, but is now a different language that only targets the JavaScript stack.) Do you simply dislike the OCaml syntax or is it some particular quirk? > the variable scope thing The what thing? Variables are just lexically scoped, are you referring to shadowing?
(When you look at the blog, you'll see that the last blog update was in 2018, and you might conclude that the project is dead. But it's actually not -- their Github repo is still getting new commits!)
Re: OCaml Programming: Correct and Efficient and Beautiful
#48I just want OCAML to have curly braces, please. And the variable scope thing in OCAML is extremely off putting.
You can use the ReasonML syntax with the standard OCaml toolchain, it's the same language with curly braces. (Not to be confused with ReScript which spun off of it, but is now a different language that only targets the JavaScript stack.) Do you simply dislike the OCaml syntax or is it some particular quirk? > the variable scope thing The what thing? Variables are just lexically scoped, are you referring to shadowing?
a = 10; { a = 20; } print(a)
This would print 10. Something like that. I just remembered that the first time I encountered this, I thought "this is going to be one of those things where I will unnecessarily trip over" and closed the page.
Re: OCaml Programming: Correct and Efficient and Beautiful
#49Earlier quoted context omitted.
There is no evidence that any of those things lead to more correctness. It’s all feels
There's plenty of evidence. Here's the OCaml compiler catching a redundant rule in the Unicode line-breaking algorithm: https://www.unicode.org/mail-arch/unicode-ml/y2020-m03/0000.... People who like rejecting this kind of stuff as 'feels' are ironically also being guided by their 'feels'.
There's no scientific experiment you could run that proves, or disproves, that type systems lead to more correctness. It's a thing you cannot possibly know.
Re: OCaml Programming: Correct and Efficient and Beautiful
#50I would take the FP zealots more seriously if they stopped asserting that FP makes things more correct. Zero evidence that this is the case. I can tell you that debugging a compiler written in ML is a dumpster fire compared to debugging a compiler written in C++. If take C++ over any FP language for compilers any day of the week.
Yet all mainstream languages, including C++, keep adding FP concepts. Better spend some time having fun with std::variant, visit, and ranges transformers.