Gabriella439 / post-rfc

Blog post previews in need of peer review
Creative Commons Attribution 4.0 International
2.19k stars 171 forks source link

Scripting / Command-line applications best in class? #140

Open ad-si opened 6 years ago

ad-si commented 6 years ago

I feel like scripting / cli apps should maybe be "Best in class". Especially because scripts are normally not tested (well), type-safety should be mandatory. Furthermore there are some really good modules available for building CLI apps.

Gabriella439 commented 6 years ago

The main reason why I don't give Haskell a "Best in class" is mainly due to scripting (as opposed to more stable command-line applications). Specifically, if users want to be able to edit and run source code directly (i.e. using runghc or something similar) then they need to have the Haskell toolchain installed. However, the Haskell toolchain has a large footprint and is not installed by default on most systems. Compare to Python, which doesn't have these issues.

However, for stable command-line applications (i.e. such as pandoc or bench) then I think you can possibly make an argument for this but I'm still not 100% convinced it is best in class. The strongest argument in favor of Haskell is that it is typed and much easier to author compared to other type-safe languages, but I think the strongest arguments against is that the ergonomics for small programs are still not as good as some dynamically typed languages. For example, the ease of parsing/manipulating JSON is still not as good as languages which have anonymous records or ergonomic dictionaries. As another example, Haskell has no analog of Python's docopt package.

ad-si commented 6 years ago

Ok, having to install the Haskell toolchain first is indeed a problem.

JSON parsing with Aeson feels pretty solid. Even more so if you want to make sure the parsed JSON objects are consistent / valid.

Mh, maybe someone should port https://github.com/felixSchl/neodoc to Haskell. It's basically docopt written in PureScript.

But yeah, I'm not insisting it should be "Best in class", just wanted to hear your thoughts on it and I guess giving it some more time is the right thing.

nponeccop commented 6 years ago

Ok, having to install the Haskell toolchain first is indeed a problem.

I find binary dynamic GHC libraries pretty unbloated. However, this approach doesn't work well in practice:

Another issue for me is that Haskell dictionaries have pretty low performance compared to PyPy and Perl. While CPU performance can be solved by mutability, the memory footprint remains several times larger than state of the art, so this lack of densely packed dictionaries prevents adhoc analysis of large text datasets. So I use other languages for that.

Another issue is IO - if I need to split and join pipelines it doesn't work well yet. Some packages are not fully symmetric yet (I mean duality between production and consumption, map/contramap), some errors are not catched statically (it's pretty easy to shoot yourself in the foot by creating code which doesn't work, mostly in the domain of non-linear - forking and joining - pipelines). And without pipelines Haskell's code becomes too ugly and/or prone to leaks.