Hacker News new | ask | show | jobs
by bcrosby95 2107 days ago
I don't think Elixir aims to be a general purpose scripting language. I only use it for hobby stuff, but lately I've been writing my scripts in a few languages to compare their characteristics: performance, lines of code, and delta code change when making a single threaded script into multi threaded.

I find that Elixir code for these tasks tends to be a bit longer than standard scripting languages, a bit shorter than Go/Java, with performance around Go and slightly better than Java. One of the interesting things I find though is that with the Flow library, bringing it from single to multiple threads tends to require fewer changes - generally I just have to change some uses of Stream to Flow and I'm up and running with a solution that's using all my cores.

2 comments

That'd be about my assessment as well, though it's been a while since I programmed Java/C++ etc. I ported Vault's Shamir secret algorithm from Go to Elixir, and it was about 25% less lines of code. Though Python scripts tend to be shorter for small projects, bigger ones get more verbose when dealing with classes and data sharing, IMHO. Python scripting is also more prone to difficult debugging issues due to immutability and inconsistent/dated libraries. For example, a Python SPI library I tried for an IoT sensor deleted all of the items from the list of SPI bytes given to it... which took an hour to figure out as that was completely unexpected and I kept thinking my part was bad (though perhaps I'm too used to Elixir's immutability now).
For others not familiar with "Flow" I'm guessing it is this (which looks awesome): https://hexdocs.pm/flow/Flow.html
Also of note is Broadway (https://github.com/dashbitco/broadway)

"Comparison to Flow You may also be interested in Flow by Dashbit. Both Broadway and Flow are built on top of GenStage. Flow is a more general abstraction than Broadway that focuses on data as a whole, providing features like aggregation, joins, windows, etc. Broadway focuses on events and on operational features, such as metrics, automatic acknowledgements, failure handling, and so on." - (https://github.com/dashbitco/broadway#comparison-to-flow)