Hacker News new | ask | show | jobs
by fbsvvc123 2047 days ago
Actual ocaml user here. User-facing web apps just aren’t a core application target for most people who use Ocaml, and probably won’t ever be. There are many perfectly good languages out there that address that need, so if ocaml doesn’t, so be it.

Maybe I’m just in the minority - I like the fact that there are lots of languages out there, some of which choose not to cater to every possible development scenario. This is why I know lots of languages - instead of trying to apply one to every situation, I look at a situation presented to me and can go into my mental toolbox to pull the right language out for the job. I don’t see language design/implementation as a competition to acquire users. Do a job, do it well, and some subset of people will be happy - those that aren’t can move along and continue browsing the catalog of languages until they find one that meets their needs.

6 comments

The ML family is really good at (safe!) string processing, e.g. the meme that they're only good for writing compilers.

Lots of Web stuff is just that (DB queries, GET/POST parameters, HTML, templating, URLs, JSON, XML, etc.). Whilst lots of that can be done via bytes, there are certainly cases where Unicode is needed (e.g. finding word boundaries, case-insensitive comparison, etc.).

Ocaml (and SML) have the enviable position of being safer+faster than scripting languages, and more approachable+familiar than the likes of Haskell (which otherwise has a similar feature set). That makes it very well suited to such domains IMHO.

^ This. Exactly my experience with it. Though, recently I'm using Java when I work with others on cloud-related projects and Scala (which is a ML+typeclasses+concurrency on the JVM) to write a compiler for OpenCL. For me, OCaml is great if you want compilation speed, fast iterations. Lacks in other departments: concurrency, parallelism, ergonomics, availability of libraries (outside compiler territory). Also, there's Flix that can have a lot of potential in the future, which is on JVM also: https://flix.dev/
Even if you need, for example, word boundaries, you might be better off pretending that no non-ASCII non-word chars exist than pretending that everything is valid UTF-8 or whatever. Depends on your inputs and requirements.
> User-facing web apps just aren’t a core application target for most people who use Ocaml, and probably won’t ever be.

Some industrial Ocaml users use the web as a UI. I'm fairly certain Jane Street does it for exemple. That's very much user-facing web apps.

I understand that it's not something that interests you but there has been plenty of work geared towards building web applications in Ocaml (and Reason). Saying it probably won't ever be a core application target seems quite wrong.

> User-facing web apps just aren’t a core application target for most people who use Ocaml, and probably won’t ever be.

this is a self-fulfilling prophecy

> User-facing web apps just aren’t a core application target for most people who use Ocaml, and probably won’t ever be.

I wouldn't be so sure. The way that the ReasonML and ReScript communities have been attracting frontend developers, webapps may already be the single biggest target platform for OCaml (well, a derivative) today.

I am not american and use a european alphabet with more characters. So if I need to handle user input or parse files with data I need unicode handling, so even for non web apps it can be needed.
I am not american and use a european alphabet with more characters. So if I need to handle user input or parse files with data I need unicode handling, so even for non web apps it can be needed.

And yet OCaml is French and its French authors do not feel constrained by the lack of unicode or they would have "scratched their own itch".

In all fairness, OCaml is somewhat historically centered on Latin1 encoding which does include French characters.
are there any advantages to using OCaml for making web apps?
No. You can get similar language-level benefits from languages with stronger ecosystems around web-relevant technologies. For example, F# is very close to Ocaml, but has a healthier ecosystem for web stuff.
ReScript (formerly called ReasonML), is an interesting option for web apps (especially the front-end part), if you are interested in Ocaml-like languages.

Language-wise, it is Ocaml with a different syntax layer, so all of the nice things about the language are still available.

Yes, especially in the ReScript toolchain ( rescript-lang.org/ ), there are many benefits:

- Super-fast compiler

- Readable and succinct JS output with nearly 1-to-1 mapping from OCaml source

- Simple module system with no need to explicitly import modules--the compiler takes care of it for you

- High-quality React and other bindings

- The standard advantages of the type system like expressive power of data types and pattern matching with exhaustivity checking

- Tons of super useful built-in lints like 'unused variable', 'unused function parameter', 'discarding a value', etc.

If you are interested in web apps, you should pick a platform first:

* Node with TypeScript

* JVM with Scala

* CLR with F#