5 ms·
Is Elixir really the general purpose productivity tool that comments here (and on other HN posts) make it out to be? I've loved playing with Erlang and Elixir.
by jpittis 6y ago
Is Elixir really the general purpose productivity tool that comments here (and on other HN posts) make it out to be?
I've loved playing with Erlang and Elixir. The concurrency model and approach to failure are fascinating and clearly powerful for certain problems. Elixir's Pheonix feels as productive as Rails. I've read most of Joe Armstrong's books and watched most of his talks.
However, I feel like I can throw my daily driver programming languages including Go, Ruby, Rust... even Haskell at any problem and give or take performance, come out the other end with high quality software at scale.
When I last wrote Elixir, it felt great when I was doing basic Rails shaped work or lower level concurrency heavy networking (I was playing with TUN/TAP interfaces), but I really can't imagine it as a general purpose programming language.
For example I can't imagine scripting in Elixir, but I can and do in the other languages mentioned above. Also I remember trying to write a parser library and it felt way more verbose and unmaintainable than the equivalent Haskell or Rust.
This is hand wavy, but does anyone feel what I'm getting at? Any thoughts?
- slindz 6y agoElixir has been my daily driver for four years, I came from a brief stint in Ruby. It's true that most problems are largely manageable by most/all languages. What I've come to appreciate is how often Elixir has made me a better programmer with its conventions. Their choices have steered me away from a lot of foot guns and forced me to learn better ways to do things.
- bcrosby95 6y agoI 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.
- freedomben 6y agoFor others not familiar with "Flow" I'm guessing it is this (which looks awesome): https://hexdocs.pm/flow/Flow.html https://hexdocs.pm/flow/Flow.html
- jeremy_k 6y agoAlso of note is Broadway (https://github.com/dashbitco/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 https://github.com/dashbitco/broadway#comparison-to-flow)
- elcritch 6y agoThat'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).
- nickjj 6y agoI think it would be hard for Elixir to replace Python or Go for general purpose CLI tools. Part of what makes Python nice is it's available everywhere. If you have a zero dependency CLI tool, using Python is nice because you can just run the script straight up. The standard library also has good support for argument parsing. I've written a bunch of little tools to help my daily workflow on the command line. I always reach for Python or Bash depending on what I'm doing. I haven't really seen a compelling reason to switch.
- deltron3030 6y agoNew Elixir thread -> nickjj pointing out the superiority of Python or Ruby. Lol!
- nickjj 6y ago> New Elixir thread -> nickjj pointing out the superiority of Python or Ruby. Lol! Not really. He asked a question about using Elixir as a general purpose programming language so I gave my honest advice and opinion on using it as a scripting language based on prior experience. Instead of cherry picking my replies out of context, why not go through my entire comment history in all Elixir and Phoenix HN threads? I'll guarantee you'll find tons of positive comments. Here's a couple to get you started after spending 60 seconds searching: - https://news.ycombinator.com/item?id=20267184 https://news.ycombinator.com/item?id=20267184 - https://news.ycombinator.com/item?id=20357572 https://news.ycombinator.com/item?id=20357572 - https://news.ycombinator.com/item?id=17616692 https://news.ycombinator.com/item?id=17616692 - https://news.ycombinator.com/item?id=18838449 https://news.ycombinator.com/item?id=18838449 The first two have over 100 up votes combined for reference. I'm not looking to argue on the internet, but I do find it strange that so many folks in the Elixir community cannot take any constructive criticism of the language in any way. You realize we're all on the same team right? To build kick ass applications that we enjoy building while users enjoy using it.
- dnautics 6y agoJust gonna say, I'm pretty upfront about when not to use elixir, and I have found your attitude to be very pessimistic across several platforms.
- ch4s3 6y agoI'd be curious to hear about your experience writing a parser vs Rust. NimbleParsec or just plain binary pattern matching make parsers suer easy to write in Elixir. I wrote a pretty complicated one for an old telecom data exchange format a few years ago and it was a breeze.
- enraged_camel 6y agoNo, Elixir does not aim to be a general-purpose language. It is built for a virtual machine that greatly excels at distributed, fault-tolerant systems.
- ch4s3 6y agoAre you sure about that? I heard Jose say that they did aim for it to be general purpose during a talk at ElixirConf last week.
- enraged_camel 6y agoThat may be the case, but I don't know how it can beat Go's ability to build executables for any platform, or Python's ubiquity.
- ch4s3 6y agoI don't think it'a trying to do that. It has its own merits and a number of great use cases. Being general purpose doesn't mean that it needs to compete head to head on cross platform scripting tasks.
- dnautics 6y agothere are degrees of general purpose. I think the point is "more general purpose than just web servers". That it excels at high-end embedded is part of the point. Should you sue it for low-end embedded? Probably not.
- freedomben 6y agoI'm in the same place as you. I love using Elixir, but like you it doesn't feel very general purpose to me. I mostly just write Phoenix apps with it though. I went through Dave Thomas' book and it did feel like a mostly general purpose language when going through that, but of course those examples were chosen intentionally. It makes me think I just need to try more often. I'm so productive and fast with Ruby however that I always reach for that for scripts. I really need to buckle down and make myself write a non-trivial CLI tool in Elixir. Part of what I suspect might make it feel less general purpose is that unless you spend time really learning the internals then it seems somewhat mysterious and constraining. The immutability for example (which most of the time I love) made it a nightmare when I was trying to process and transform deeply nested JSON. I tried a few times in Elixir and just bailed to Ruby where I could directly mutate stuff 5 levels down with ease and efficiency. The code seemed way more straight forward and readable. How do people deal with things like deeply nested JSON in Elixir? Is there a way to make use of actors to avoid some of the pain points?
- akiselev 6y agoHard to say without knowing more about your usecase but normally I reach for lenses [1] [1] https://github.com/obrok/lens https://github.com/obrok/lens
- freedomben 6y agoThanks, I haven't heard of lens before. For others there's a blog post that introduces it: https://yapee.svbtle.com/nested-data-structures-with-lens https://yapee.svbtle.com/nested-data-structures-with-lens
- grantjpowell 6y ago> How do people deal with things like deeply nested JSON in Elixir? Have you gotten to play with the `put_in/2` [0] and `update_in/2` [1] macros? They're designed to manipulate deeply nested structures like JSON iex(2)> my_parsed_json = %{"some" => %{"deeply" => %{"nested" => %{"key" => 1}}}} %{"some" => %{"deeply" => %{"nested" => %{"key" => 1}}}} iex(3)> update_in(my_parsed_json["some"]["deeply"]["nested"]["key"], & &1 + 1) %{"some" => %{"deeply" => %{"nested" => %{"key" => 2}}}} As a side note, a common misconception is that updating a large data structure on the BEAM is inefficient because values are immutable, so you have to copy the whole structure to make a tiny change. This is untrue, as Elixir (and Erlang) "maps" are implemented as HAMTs[2], which support very memory efficient updates by "sharing" the unchanged parts between the the old and updated maps. [0] https://hexdocs.pm/elixir/master/Kernel.html#put_in/2 https://hexdocs.pm/elixir/master/Kernel.html#put_in/2 [1] https://hexdocs.pm/elixir/master/Kernel.html#update_in/2 https://hexdocs.pm/elixir/master/Kernel.html#update_in/2 [2] https://en.wikipedia.org/wiki/Hash_array_mapped_trie https://en.wikipedia.org/wiki/Hash_array_mapped_trie
- AlchemistCamp 6y ago> However, I feel like I can throw my daily driver programming languages including Go, Ruby, Rust... even Haskell at any problem and give or take performance, come out the other end with high quality software at scale. You're probably right. With a very high-level language like Ruby and an extremely efficient systems language like Rust, you've pretty much got the entire spectrum covered. With libraries like Helix, you've even got an escape hatch if you start with Rails and hit unexpected bottlenecks. IMO Elixir is nearly ideal for web startups due to productivity, enough performance, easy scaling and a very gentle learning curve. If you've already got all those other tools under your belt, then those pluses are probably less of a draw.
- dnautics 6y agoI've written scripts in elixir that did performance testing of parallel downloads over cloud storage services. Also I have a script that I run once a year year to scrape Google maps for driving mileage. The deployment story for elixir scripts sucks because it is less portable than say ruby or python (the person running the script needs to have elixir and you can't really use library deps in a sane way), but I don't mind it, because it's totally worth having less hassle for the cases where you want a well-defined deployment. At work, I am using elixir to: orchestrate VMs (this is more traditional elixir-ish), but definitely not really a website or embedded, as a PXE boot provisioning system for metal systems, as a substitute for ansible for laying out software on systems, which are more script-ish, but on the side of "scripts for which you are really going to want to have a consistent deployment story".
- triplejjj 6y agoIt really depends on what you mean by general purpose. At work we use Elixir for web and data ingestion, and I could have used Ruby for web but Ruby is considerably behind for data stuff. Elixir is fine for one-off scripts, Ruby and Python may be a bit more convenient, but overall they are all too heavy to distribute compared to languages like Go and Rust. Elixir is also used for high-end embedded and there is the whole distributed programming bits, which is quite specific to its platform, and more complicated to setup in almost all other places. So overall it does provide some nice coverage across a couple areas although it lacks on other ones (GUIs, ML, etc).