Live data from Hacker News

Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

joaomdmoura.com

21–30 of 62 posts

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#21

If you had to make a comparison, what would be the pros and cons of using elixir vs node.js?

This biggest pro for node.js, is the large community. JavaScript is everywhere, there is a literally a stable library for anything you can possibly conceive at this point, and if you're already doing front end, it's an easy pickup.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#22

If you had to make a comparison, what would be the pros and cons of using elixir vs node.js?

Elixir's greatest strength is it's simplicity with modules and it's functional paradigm.

No confusion as to how to import a module and what to namespace it. Just call it. No fuss.

Immutability. Your functions returns transformed data, you don't transform the data itself. That's liberating and makes for such a compelling unit testing experience you find yourself writing more tests to make 100% sure that function does what you want it to do and handle edge cases.

With Node (Javascript), you don't have that. You have a cobbled together solution that works just barely. But how? I don't know.

You npm installed something now the project won't work, you spend three hours debugging and out of desperation you npm install again and now it's working - but why, who knows. Multiply this strange experience to 5 times a day and you get kind of exhausted of Javascript.

Maybe it's not Javascripts fault. Maybe it's Node/NPM itself that ruined the experience, I haven't used Yarn yet.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#23
post #4

If you had to make a comparison, what would be the pros and cons of using elixir vs node.js?

More fair comparison would be Phoenix [1] to node.js Elixir is a programming language whereas node is a framework. [1] http://www.phoenixframework.org/

Node.js isn't a framework. It's a JS runtime, and for most purposes can be considered a variation of JavaScript. However, like Go, Node.js has such a rich networking support in its standard library, that some people go "frameworkless" when developing web apps in Node. But not as many as in Go, probably.

Something like Express would be more analogous to Phoenix in Elixir.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#24

Earlier quoted context omitted.

I know depending on the use case some tools are better than others, but to clarify my original question, for someone who might just be getting into the back-end and looking towards the future, what would be a better choice to focus on, elixir or node.js? and say for example that the person has done both some Ruby and JavaScript programming, including some basic apps with Rails and Express.

Javascript is a very common language. Elixir is generally a better language, but less popular. If you're looking to get a job you could probably do either but there are probably more Javascript jobs. At the hobbyist level Node might be easier to pick up, especially if you know Javascript already.

I think Javascript is generally a safe bet for the next few years because the Frontend is firmly embroiled in Javascript as well.

Elixir seems poised to keep growing on the backend, so it's probably not a bad one to learn either.

My real advice to someone starting out would be to learn a language but focus on learning general programming and computing concepts through it. The better you are at programming and computing, the more easily you can pick up new languages and switch between them seamlessly.

Also, as you learn new languages, focus on learning the right way to do things in that language. It's extremely helpful to be able to separate programming concepts from language constructs.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#25

If you had to make a comparison, what would be the pros and cons of using elixir vs node.js?

There's a lot of replies to you here but I'm going to touch on the big one.

Node.js's biggest concurrency perk is non-blocking I/O thanks to a cooperative scheduler. When I/O is about to happen, the scheduler relinquishes control.

Elixir has non-blocking everything. Each process is prescheduled making it impossible for a runaway method to completely takeover the process.

The a comparative example server with millions of small requests in each language. An infinite loop in node would disrupt every other request to the server. In Elixir, the other requests would go on as if nothing happened.

The tradeoff to prescheduling is that you'll never hit a top end benchmark with Elixir vs other fast languages, but you'll get a very consistent response time. Makes it ideal for real time work, which is what most servers really are.

There's many more that other folks are describing here. Natural clustering ability due to lack of shared memory, immutability, message passing, etc. Really cheap processes (goroutine = 2k, elixir process = 0.5k) that makes it so cheap that the model is to create two. One as a supervisor and the other as the actual process. If anything crashes the process, the supervisor instantly restarts it.

The combination of the supervisor tree and prescheduling make it possible to run entire applications within the runtime that other parts of the system depend on. Imagine running a database INSIDE of your Node application. Pair that with the natural clustering ability and you get the ideal platform for a self-contained distributed system. Just keep tacking on servers as you grow.

You'll hear the term "OTP" a lot and that's essentially a set of patterns on top of the foundation that I just described that provides best-practices and models for utilizing the stack in different scenarios.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#26

Earlier quoted context omitted.

I'm currently working in both. If we are just talking about them in terms of their respective merits, Elixir is my preference. It has a wonderful compiler, pipes allow for composable chains of logic, the Phoenix framework is wonderful for web development. Literally every interaction with it I've had has made me think "wow that's just a great example of excellent programming taste...". In terms of scaleablilty, I've h…

I'm working on both too, and one point that I faced was the Node 1.5GB RAM limit per node process (at least on Heroku https://devcenter.heroku.com/articles/node-concurrency - I know it can be worked around though, although not on Heroku), which can force you to run multiple processes (aka clustering) depending on your use cases (e.g. thousands of client websockets connections from the process, if you need to listen t…

Good points!

> where a single Elixir process will be able to use more RAM & all the cores, too.

I think you mean a "single instance of the BEAM" here as a single Elixir process is pegged to 1 CPU core.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#28
As a Ruby programmer trying to take a look at Elxir, i still find it hard to read. Maybe functional languages take time to get used to but it doesn't seem as "clear" as procedure or oop style. I know the added benefit of speed and concurrency, but for most apps we build it is not needed for now.

Do any Ruby programmer find Elxir easier to write or read? Im genuinely curious to hear about this because a lot of Ruby devs are writing Elixir.

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#29

As a Ruby programmer trying to take a look at Elxir, i still find it hard to read. Maybe functional languages take time to get used to but it doesn't seem as "clear" as procedure or oop style. I know the added benefit of speed and concurrency, but for most apps we build it is not needed for now. Do any Ruby programmer find Elxir easier to write or read? Im genuinely curious to hear about this because a lot of Ruby de…

I'm a proficient Ruby developer (with code in production since 2004).

Ultimately I find it's easier to go back to some Elixir code and understand what it does, compared to Ruby.

The main reason is (to me) the fact that I now see Ruby object instances as "living things" (with always something hidden underneath, that can change), while Elixir types are more like "stable messages".

So yes, I believe doing Elixir maintenance is ultimately going to be easier than with Ruby.

(Note that I work with both Elixir & Ruby now, and also with Node & other platforms, I don't intend to stop using Ruby at all).

Re: Learn Elixir with a Rubyist (IV) – Types, Data Structures and Pattern Matching

#30
Can the Ruby people please stop blogging about Elixir and explain things relative to Ruby? There are way too many 'Elixir-for-Ruby-programmers' tutorials on the net already.

Elixir is pretty great and enthusiasm is good but I feel this leaves a large group of people in the dark.

Post reply on HN