39

In the OCaml world at present there appear to be a number of competing extensions to the standard library, Batteries and Jane Street Core being the major ones as far as I can determine (I understand that ExtLib has been subsumed into Batteries?). What are the pros and cons of each one? Are they equivalent? Can they coexist? Does it make sense to "mix and match" or should I pick one and focus on it? Is Core widely used outside of Jane Street?

If it makes a difference I am on Debian, so Windows support is not a factor for me.

Thanks!

Gaius
  • 2,556
  • 1
  • 24
  • 43
  • Also wonder if one or the other (or a combination of both) could be added to the OCaml standard lib in the next major release of OCaml (3.13?). I've played with Batteries (but not core) and it certainly adds a lot of useful functionality. – aneccodeal Oct 10 '10 at 06:07
  • 2
    @aneccodeal There probably won't be an extended library in OCaml 3.13. The core OCaml maintainers have been very clear about their thoughts about that. I think they expressed their thoughts at the first OCaml User meeting, which was in 2008, so it's too soon for them to have changed their minds considering how categoric they were. – Pascal Cuoq Oct 14 '10 at 08:42
  • Indeed, this was one of the reasons to start Batteries. – Yoric Oct 16 '10 at 08:55

2 Answers2

33

Caveat: I'm one of the authors of Batteries (although I've been out of touch for a year now) and the author of the about page linked above.

The big differences are the following:

  • Core is used daily in an industrial environment, while afaik Batteries doesn't have the same following
  • Core is maintained by one company, while Batteries is community-maintained
  • afaik (but I can be wrong), Core doesn't accept submissions or feature requests, while Batteries does
  • Batteries aims to accept any program written for OCaml's standard library, while Core doesn't aim to maintain backward-compatibility
  • Batteries used to come with additional external tools (they're not in the standard distribution at the moment, but I hope they'll return as an additional package), e.g. an improved toplevel, a compiler that requires zero configuration to use Batteries instead of OCaml's stdlib, etc.
  • Batteries comes with additional language extensions e.g. to handle Unicode natively, with a new, safer and more extensible printf, etc.
  • Batteries comes with lots of documentation, while last time I checked, Core didn't.

P.S.: Yes, ExtLib is now a subset of Batteries.

Yoric
  • 3,348
  • 3
  • 19
  • 26
  • 1
    Unicode support is there, through `pa_string` (unless you're talking about something more sophisticated than being able to say `u"string"`). I don't remember the current status of the formatting extensions. – Michael Ekstrand Oct 16 '10 at 03:10
  • Ok, thanks, amending the answer. – Yoric Oct 16 '10 at 08:52
  • 6
    It should be noted that Jane St is now hosting the library on bitbucket to promote external contributions. They will still control what contributions get accepted but they are moving in the direction of greater community involvement. – Ashish Agarwal Jan 08 '12 at 14:57
  • @Yoric After 2 years how much has your answer on this question changed? – samaras Aug 23 '13 at 10:17
  • 1
    @Yoric After 6 years how much has your answer on this question changed? – also with regards to https://github.com/janestreet/base – malthe Sep 22 '16 at 09:54
  • Deflecting to someone more involved in Batteries than me these days. – Yoric Sep 23 '16 at 12:54
  • 1
    One illustration of a syntactic difference (partly related to the fourth bullet point): Batteries' `List.map` follows the traditional syntax `map function list`, while `Core.Std.List.map` puts the list first: `map list function`, though you can put the function first if you label it: `map ~f:function list`. – Mars May 15 '17 at 23:14
9

The Batteries about page seems to include a comparison to other libraries that answers this question

(scroll down to "Relations to other libraries")

http://batteries.forge.ocamlcore.org/doc.preview:batteries-alpha3/html/about.html

blueberryfields
  • 45,910
  • 28
  • 89
  • 168