
Ask HN: Fed up with Ruby/Rails; what language should I learn? - abvdasker
I&#x27;m a programmer in need of a new programming language. I&#x27;ve been doing full-stack Rails web dev for about 3 years and find myself increasingly bumping up against the limitations of Ruby&#x2F;Rails. I won&#x27;t catalog all the issues since other people have done it far better than I can, but it comes down to the same hackneyed but true complaints around Rails: trends towards poor maintainability for large projects and bad performance.<p>So I&#x27;m looking for something new. I&#x27;ve done Java development on-and-off professionally for about 4 years. While I love the static typing and simplicity of Java, it&#x27;s too verbose. I always end up writing a lot of boilerplate code, and I absolutely hate Java projects&#x27; XML-centric configuration.<p>All this lead me to start playing around with Elixir in the last month since that seems to be the new hotness, but so far it&#x27;s really chafing for me. Simple things like loops and encapsulation seem incredibly complicated. Something as simple as setting a value in a two-dimensional array becomes:<p><pre><code>  new_row = array
  |&gt; Enum.at(row)
  |&gt; List.delete_at(column)
  |&gt; List.insert_at(column, new_value)
  
  new_array = array
  |&gt; List.delete_at(row)
  |&gt; List.insert_at(row, new_row)
</code></pre>
I&#x27;m finding myself passing tons of variables into short methods because there aren&#x27;t any objects to hold ivars. No doubt some of these difficulties are due to the fact that I don&#x27;t have much FP experience, so I&#x27;m wondering if I should persevere or try something else.<p>On the other hand I&#x27;ve heard some really good things about Scala — that it offers Java&#x27;s benefits around type while being more concise and readable. I&#x27;ve also heard that Scala has some great capabilities around FP and concurrency.<p>TL;DR Should I learn Scala, Elixir or some other language I haven&#x27;t considered?
======
erac1e
It all depends on so many things.

Do you want to learn the language for fun, or to improve your career prospects
in the near term.

What languages are used in the jobs you would like to get?

For example for me I want to get into high frequency trading or prop trading.
I know C#, and I am very busy with a family. Therefore as much as I love
Haskell, I am going to stick to C# and learn more deeply about multithreading
and sockets, how to build muilithreaded systems like servers, exchanges etc.
in C#. Then I will be in a good position to apply for those jobs.

For you the answer may be different.

If you don't know the answer, maybe 'spike' a few languages. By spike I mean
try out for 6 months in your spare time.

Haskell is a good one, but with FP you can't give up the fight easily. It is
possible to get your head around but it takes time, patience and passion.

Once you learn FP, then your brain is upgraded. It is like running a marathon,
if you can run a marathon then a 10 mile run becomes something you do to
unwind and relax. 10 miles is hard for most people but easy for the marathon
runner.

Similarly learning Haskell, type theory etc. will make other formerly hard
stuff in Ruby, Java, etc. will now seem easy because you are smarter. This is
my experience anyway.

------
RobertKerans
This is a more just WRT you fighting with Elixir:

> Simple things like loops and encapsulation seem incredibly complicated.
> Something as simple as setting a value in a two-dimensional array...

\- Elixir doesn't have loops. You use recursion.

\- Elixir only has modules for organisation, and modules are just functions.
It's just functions functions functions all the way down. You can nest modules
in modules and so on, that's how you would achieve encapsulation.

    
    
        > defmodule Foo do
        ..   defmodule Bar do
        ..     def add(a,b), do: a + b
        ..   end
        .. end
        > Foo.Bar.add(1,2)
    

\- Further to that, you'd generally use processes for holding state, but those
processes are also just functions, nothing special or different. See
[http://ferd.ca/the-zen-of-erlang.html](http://ferd.ca/the-zen-of-erlang.html)

\- Use maps, not lists, to emulate a 2d array. Lists are not designed to do
what you're trying to do there. As you've found out, it becomes incredibly
ungainly. Daniel Berkompas wrote a post on this exact thing recently:
[http://blog.danielberkompas.com/2016/04/23/multidimensional-...](http://blog.danielberkompas.com/2016/04/23/multidimensional-
arrays-in-elixir.html)

I would stay stick with it. If you shifted across to Scala and tried to do
things in the way I think you're doing them atm, you might as well be writing
Java: changing to Scala won't make it any easier to adapt to a functional
style.

------
aaronbrethorst
You're fed up with a language and framework, but only ask about which new
language you should learn. Methinks there is a piece of the puzzle missing.

edit: The point I'm trying to make is that you should be asking for
suggestions about languages _and_ frameworks, not just languages. Whether or
not you have issues with MRI, you're going to have to deal with your new
language's ecosystem, not just its runtime.

~~~
abvdasker
I see some of Rails' problems — particularly around performance — as symptoms
of Ruby's design. Ruby isn't all that performant to begin with, which coupled
with the metaprogramming and magic the language encourages can result in some
very slow applications. Rails' issues around performance are also a direct
result of Ruby's lack of true concurrency caused by the GIL.

In terms of maintainability, I've found that unless you're one of Ruby's
"gurus" or know all the best practices around the language, it's far too easy
for the average developer to write code that will be difficult to maintain
long-term.

------
jdiscar
It's really up to what kind of project you want to work on and how much
resources (time/effort/stress/money/etc..) you want to put into it. The
learning curve for something new is definitely not negligible, especially as
you get deep into your project.

Newer languages/frameworks look great when you run through tutorials, but
you're going to have issues once you need to do more complicated stuff. Very
new frameworks are unlikely to have much documentation and discussions, which
means that at some point, you're probably going to need cross your fingers and
hope someone replies to your questions or dig into source code yourself.
There's nothing wrong with this, it's just the cost of using something that
isn't old and popular.

Maintainability for large projects and bad performance are an issue in
whatever language or framework you use. A lot of the problems are avoidable
once you move past relying on the magic of your web framework and understand
how all the stuff you're using works under the covers. After playing with a
few languages and frameworks, I'd say it's really useful to just choose one to
become an expert in. Being an expert in one and knowing how to mitigate all
the warts will help you infinitely when you do eventually move to something
new. I think it's much more valuable to be an expert in one stack and
intermediate in two than to be intermediate in 20 stacks.

If you have something you really want to build and are already comfortable
with Java, I'd suggest just sticking with Java. Newer frameworks like
SpringBoot or Play! remove a lot of the XML, if that's your primary complaint.
Verbosity... well, every language is going to have something that doesn't
match your personal aesthetics. A lot of the really verbose Java can be
avoided by changing up your coding style.

If you're just going for self-enrichment, sticking with an FP until you're
comfortable with it is great. Just be aware that you may never use the
language/framework as an employee. But you'll definitely get huge benefits in
your overall skills by learning an FP.

~~~
BWStearns
> Newer languages/frameworks look great when you run through tutorials, but
> you're going to have issues once you need to do more complicated stuff.

I think this might be a bit of a benefit. I've been messing around with
clojure/clojurescript in my free time and playing with a lot of libraries that
while reliable are certainly less documented than say Rails or Django. It's
actually been a really positive experience since it does force you to either
dig through all the relevant source code or go have conversations with members
of the language's community. Going to the source is just good exercise and
also helps avoid the feeling of encountering magic. Talking with other
developers using or making the libraries I've found I end up having more
conversations about how things should or could be done (and why). At work or
when talking about older stacks there is usually a Right Way(tm) that has been
found and accepted and so the why or [sh|c]ould conversations have already
been had and are academic at best and crying over spilt milk at worst.

------
dineshp2
Functional programming is different from object oriented programming and takes
some time to understand.

In elixir, data is immutable and hence you can't simply modify data like in
non functional programming languages and that leads to complexity when you
don't think in terms of functional programming. And regarding the code you
posted, I would suggest using _maps_ , then you can access values as

    
    
      arr[row][col]
    

and set values using the put_in macro as

    
    
      put_in arr[row][col], val
    

I would suggest using elixir + Phoenix framework. It should also be mentioned
that given your RoR background, you will feel comfortable using Phoenix and
elixir. Performance will not be an issue compared to RoR.

------
alexgaribay
I can't speak about experiences with Ruby/Rails since I don't use that stack
but I can give you advice about both Scala and Elixir.

I used to be a Java programmer and fell in love with Scala and functional
programming. Scala helped me do things that I couldn't do so easily in Java in
a more explicit way. However, I found doing web development with Scala to be
more cumbersome than helpful but was still a great learning experience for FP
in general.

Since late 2015, I've been all-in on Elixir. Elixir does everything I wanted
to Scala, specifically pattern matching everywhere and how powerful it is.
Since Elixir uses BEAM, it's incredibly lightweight but can scale without any
configuration. The community around Elixir is fantastic and helpful and
everyone is growing together.

Brian Cardarella (well known in the Elixir community) gave a conference talk
at Rails Conf about switching from Rails to Phoenix (Elixir's goto for web)
and that may be a good start to empower you to make a decision:
[https://www.youtube.com/watch?v=OxhTQdcieQE](https://www.youtube.com/watch?v=OxhTQdcieQE).

A great resource for learning Elixir if you choose that route is Programming
Elixir 1.2 by Dave Thomas. It's a great book for beginners and can help with
you understand Elixir semantics and functional programming.

------
baccheion
Newer/Modern: Kotlin, Rust, Go, Nim, Elixir, Racket, Swift, Julia, Crystal,
Idris, Red, and Elm.

Older: C, Python, Scheme, Lua, Lisp, Haskell, Clojure, C#, and Scala.

~~~
runT1ME
Kotlin/Go are really not more modern than Haskell/Scala or heck even OCaml.

------
imauld
I would suggest Go if you want a statically typed, performant language. Echo
is a promising looking framework for Go although you really get a lot out of
the box with Go.

If you would like to stick with a dynamic language I would suggest Python.
Django is there if you absolutely need it but there are a wide range of of
smaller frameworks available for smaller more focused projects (Falcon,
Bottle, Flask).

------
nostrademons
Try Kotlin or Swift. Both are statically typed, but with a lot of syntactic
conveniences and type inference to lessen the verbosity.

~~~
egeozcan
Another vote for Kotlin. I find it to be at the sweet spot of expressiveness
and safety. Also has an official to-JS compiler.

~~~
partisan
Have you put it through any rigorous development? Any pain points?

------
cdnsteve
Try a framework that doesn't make you follow big conventions and allows your
freedom and flexibility. Try playing around with some micro-frameworks like
Flask using Python 3x. Plug in SQLalchemy, a brilliant ORM that uses the data
mapper pattern - a very big change from the active record pattern and great
for flexibility.

------
dkarapetyan
Start using a simpler stack then. There is no language out there that can
prevent creeping complexity.

------
percept
"Pick your poison," "Familiarity breeds contempt," and all that.

Perhaps focus on your goals: whatever makes you happiest or wealthiest or most
creative or marketable (with the understanding that this may be cyclical).

------
al11588
Swift and Python.

------
weatherlight
checkout
[http://elixirlang.org/docs/stable/elixir/Kernel.html](http://elixirlang.org/docs/stable/elixir/Kernel.html)

Traverse nested structures with `get_in`, `update_in`, `put_in`, and
`get_and_update_in`.

Double down and stick with elixir. Any FP principles you learn there will help
you should you decide to learn another FP language.

------
brightball
Phoenix and Elixir is probably your best bet.

------
edoceo
I'm having a lot of fun with Go. I had previously done PHP and Ruby and JS
server side. Go is kinda fun.

------
raptaml
Try Java with Ninja Framework, it is really nice and the JVM rocks.

