10 ms·
> While C lends itself to building libraries, it has no consistent API model. What language has? Wouldn't this require first class modules (which few systems h
by _pmf_ 11y ago
> While C lends itself to building libraries, it has no consistent API model.
What language has? Wouldn't this require first class modules (which few systems have; JS' hacked together solution is obviously not to be considered a true solution)?
- vog 11y agoOCaml has a typesystem in which modules are first-class citizens, just like functions. They have a clear separation between interface (they call it "signatures") and implementation. The compiler enforces that you can only write against the interface, making modules with the same interface really exchangeable. The modules are also parametrizable (they call such modules "functors"). http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.html http://caml.inria.fr/pub/docs/manual-ocaml/moduleexamples.ht... https://realworldocaml.org/v1/en/html/functors.html https://realworldocaml.org/v1/en/html/functors.html https://realworldocaml.org/v1/en/html/first-class-modules.html https://realworldocaml.org/v1/en/html/first-class-modules.ht...
- tom_mellior 11y agoThat's all true, but it doesn't mean that OCaml has a "consistent API model", whatever that may mean. Unless "provide a fold and a map for all datatypes", which I guess is consistent across most APIs, is a "model".
- deleted 11y ago[deleted]
- tomjen3 11y agoJava, C#, heck even PHP has classes support for languages these days. So has JS if you don't mind compiling using traceur.