Why would I reach for it?
Why would I reach for it?
It also has object-oriented features, though they aren't widely used the attitude is something like OO is there if we need it and we're definitely willing to use it in places that require it.
Its pretty fast for a functional language and you could probably get pretty far with it before you'd have to consider using a real low level langauge.
The disadvantages I think are pretty uncontroversial: a smaller community, not as many libraries, a bit of a fractured stdlib and build situation and until now no multicore.
Does anyone have any idea why it’s such a contentious issue?
The Unix way is winning on the web, and I think Microsoft has made some moves toward UTF-8, but I don't understand what they are exactly:
https://en.wikipedia.org/wiki/Unicode_in_Microsoft_Windows#W...
JavaScript and Java inherited the Windows way. Go and Rust use the Unix way (and apparently OCaml too). Python supports both which some say is a needless source of complexity, but it is flexible if you know how to use it.
https://www.joelonsoftware.com/2003/10/08/the-absolute-minim...
After all, it's obvious features my native language has are important and need to be first class APIs in the standard library, while any features that language doesn't use has aren't important and the standard library shouldn't be clogged up with anything so useless. Also things that are easy to do for my preferred writing system must be supported, if the easy way to implement them doesn't work for some other widely used languages, just ignore that, those people don't matter anyway.
I'm not quite sure what you're going for here. The Hindley-Milner type system Haskell is based on essentially does not require any type annotations [1]. By convention, every top-level declaration is annotated, but that is only for documentation and clarity.
Or did you mean that in comparing OCaml and Haskell to other (imperative) languages?
[1] There are a few buts that don't have much to do with the argument, but I'll list them here anyway:
1) Sometimes the type you end up with is too ambiguous and you'll need type annotations: E.g. what is the type of the term "2+3"? It is something like "Num a => a" (read: any type that is roughly number-like), but that is not useful if you want to run the program. However, in practice you won't need an annotation in almost all cases as long as some function you work with restricts the type.
2) Some Haskell extensions increase ambiguity in certain cases.
I don't think your example works in the case of OCaml since the signature of (+) is int -> int -> int. Basic operators not being polymorphic is one of the specificities of OCaml.
OCaml is high performance, Garbage Collected, hybrid system and application programming language
You can use OCaml to write high performance Apps and System tools without worrying too much about performance, or doing crazy manual memory management
I would also say, if you like Go, but think you hit a wall with it, then try OCaml
system programming language: C, C++, Rust
Hybrid system and application languages: OCaml, Go , D
If you need a language in this class (Hybrid system and app)I think currently Go and OCaml are your only options, Go being closer to C, Java familly of languages and OCaml is an ML language, so choose as per your preference
I haven't heard of Haskell being used for the kind of "high level" systems programming that go is used for.
OCaml, can achieve good GC performance because its immutable by default
D by design, will never outperform OCaml, at least this is my understanding
That, and I think D's community is too small to fix the language, while it does have several brilliant members and developer, its just too small and underfunded
So, you have two reason why D should not be an option the first technical ( D will never have a good GC ) the second is more of a logistics issue, the community is just not there to support a language as complex and as ambitious as D and deliver on all its claims
I'm not so sure considering Java probably has better GC performance than D/OCaml/Go and is completely mutable.
and as i said D has a very small community Java is on the opposite side of this spectrum its immensely popular, and as I understand it took Java several iteration, and tons of resources before gaining good performance, and still today, Java optimization is a specialized experts job
No its not. Modern Java GC's require 0 tuning. ZGC with default settings can achieve submillisecond pauses.
> and as i said D has a very small community Java is on the opposite side of this spectrum its immensely popular, and as I understand it took Java several iteration, and tons of resources before gaining good performance
This wasn't your argument. You stated that mutability was the reason that D couldn't have a good GC, not the size of its community or resources. According to tiobe D is more popular than OCaml as well.
Hopefully, the multicore GC will be as good, or one will be able to disable multicore abilities when not in use (which is going to be most of the time, I believe)
Here's an example of one very widely used production application: https://github.com/libguestfs/virt-v2v/tree/master/v2v
It fits a similar niche to Golang or C++, but unlike those it's an enjoyable language to program in.
No multithreading seems to be a pretty big problem. Hopefully, it will be fixed soon, but still
I played with it some back when I was dabbling in every language I could get my hands on. About when Scala was new (and constantly breaking between releases) and before Rust, Go, JS v8 were around. I really liked the functional aspect, which wasn't bolted on after the fact, and that it could be compiled to a real binary, not interpreted bytecode. In my naive youth, I viewed AOT compilation as the path to a true high level language that was also fast.
While it was neat, I moved on to Lisps/Schemes and now modern JS is my very happy compromise of functional and practical.
- Modules can be stored in variables, based on runtime conditions, this is all statically type checked to ensure tht the module exports the binding of the proper type. Modules can also be passed to functions and functions can produce different results based on which module is passed.
- There are keyword arguments and optional arguments with full static type checking.
- It has full support for row type polymorphism, or “static duck typing” as some call it: it tests statically whether an object quacks like a duck.
* functional
* strongly, statically typed
* garbage-collected
OCaml can compile to a native binary, or to JS via ReScript (formerly BuckleScript).
It can also compile to JS via js_of_ocaml!