5 ms·
I write a lot of Scala for living, Ocaml looks a bit outdated to me. Having said that, Ocaml compiler is one of the greatest miracles in PL when it comes to spe
by AzzieElbab 5y ago
I write a lot of Scala for living, Ocaml looks a bit outdated to me. Having said that, Ocaml compiler is one of the greatest miracles in PL when it comes to speed vs complexity of the language. Scala/Haskell/TS are not even close. I hear Ocaml's runtime performance is not too shabby either
- bobbylarrybobby 5y agoOut of curiosity, what problems does Haskell's compiler(s) (I think it's really just GHC these days?) face that OCaml's doesn't?
- AzzieElbab 5y agospeed. Ocaml compiler is probably as fast as Go one
- pjmlp 5y agoGHC has many backends and there is GHCi as well. No need to always go through the slowest path.
- Zababa 5y agoThe regular backend is the fastest according to their docs: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html https://downloads.haskell.org/~ghc/latest/docs/html/users_gu.... Having an interactive toplevel isn't a substitute for fast compilation (and OCaml has both).
- Zababa 5y agoWhat do you find outdated about it? > Having said that, Ocaml compiler is one of the greatest miracles in PL when it comes to speed vs complexity of the language. Scala/Haskell/TS are not even close. Someone will probably come correct me but what I've heard is that the compilation speed partially comes from the Pascal/Modula-3 influence, since Niklaus Wirth took compilation time into account when designing programming languages. From what I understand, OCaml doesn't allow circular dependencies outside of a single file, and that helps. Go doesn't allow them too, and is also known for its compilation speed.
- octachron 5y agoThe OCaml module system and its separation between interface and implementation is inspired from Modula-3 indeed. And the OCaml compiler is built to be able to compile compilation units while only knowing the types of its direct dependencies. This helps with both separate compilation (you don't need to recognize cycles, nor do you need to know anything about the implementation of your dependencies) and incremental compilation (you can minimize the number of components to rebuild if only an implementation changed and not an interface). It is surprisingly easy to break this property, for instance by requiring to have some global knowledge of all types involved in a program during compilation, or only compiling monomorphic functions.
- Zababa 5y agoThank you for the explanation.
- sidkshatriya 5y agoAgree - there are some aspects to OCaml that feel a bit outdated but the language has been trying to refresh itself over the last few years. With multicore (and a minimal version of effects) in OCaml 5.0, certain aspects of the OCaml will become state of the art again. This is just the start though -- lots of interesting features (around effects especially) should land in the future. You mention that you write a lot of Scala for a living -- just as a friendly (and intended to be a light hearted) riposte, some aspects of Scala strike me as "long in the tooth" too. With Scala 3 the language has done an admirable job to modernize but I find: - The language feels heavy and (unnecessarily) "enterprise-y" -- reminiscent of the early 2000s rather than 2021 - The JVM is capable and performant, no doubt, but adds another heavy-weight and monolithic feel to the Scala platform. (Scala native likely to be essentially minuscule for years to come) - The language veers towards a C++ style "I will have every PL feature." Sometimes less is more - A Scala IDE (metals or JetBrains) feels clunky. sbt is over engineered and slow and given how important it is to Scala, does not give a good overall impression of the Scala platform - Some questionable language features like implicits remind me of magic in Ruby (implicits are addressed in Scala 3 but I wonder how many years the ecosystem will have to deal with their complications -- forever??) - The JVM seems to let down Scala in other places. Example (a) Null is rarely used in Scala but it could still pop-up in weird situations and not always because of Java interop. (Scala 3 tries to fix this via "explicit nulls" but there are compromises with that feature also). (b) A Functional style Scala (Cats and others) is popular. But true functional style has a lot of recursion. This, according to me, requires proper tail call support in the runtime which the JVM will never have. The Scala compiler tries to be smart but I wonder if it is able to deal with tail calls without blowing the stack in _all_ situations. In other words, it is difficult to do a "Haskell" on the JVM -- which we can see in a lot of places in the Scala ecosystem. (BTW, I have pointed out some flaws of Scala but notwithstanding my criticism, Scala has got many good features that make it worthwhile. I may use it for a future project, lets see...) > Having said that, Ocaml compiler is one of the greatest miracles in PL when it comes to speed vs complexity of the language. I totally agree with the statement. Its a very balanced language in all important parameters: a high level of programming abstraction is possible, the LSP language server is responsive, the dune build system is great, compile times are really miniscule and run-time performance is great for a garbage collected language.
- yawaramin 5y agoThat's funny because the Scala 3 new syntax seems to copy quite a bit from OCaml.