
From Rails to Clojure, Then to Java, Then Back to Rails - donbonifacio
https://engineering-management.space/post/from-rails-to-clojure-to-java-to-rails/
======
tcopeland
In the "things learned from Ruby" section:

    
    
      Focus on strong object oriented programming
    

What I've learned from Ruby is to favor functional programming concepts -
minimize side effects, isolate state mutation, etc. Ruby is definitely OO, but
when my Ruby code is more functional it's less buggy, easier to understand and
move around, and generally less convoluted.

~~~
dzuc
Like Gary Bernhardt's notion of a "Functional Core, Imperative Shell" —
[https://www.destroyallsoftware.com/screencasts/catalog/funct...](https://www.destroyallsoftware.com/screencasts/catalog/functional-
core-imperative-shell)

~~~
faitswulff
Damn, I knew I got this idea from somewhere, I just totally forgot where.
Thanks for posting this link - I'll have to rewatch it.

~~~
aardvark179
Brian Goetz has talked about this as well - see FP is Dead - Long Live FP
([https://youtu.be/ROL58LJGNfA](https://youtu.be/ROL58LJGNfA)).

------
jcadam
I've tried a lot of different languages over the years including Ruby, Go,
Scala, and Haskell.

Ruby actually isn't too bad if you don't use Rails. Between Rails and stuff
like Spring over in Java-land I've developed a strong hatred of huge
frameworks :)

Clojure, however, is the one language that just 'clicked' for me almost
immediately. In fact, I'm pretty certain I'll be sticking to Lisps as much as
possible from here on out. That is, when I have the choice: I work in a Java
shop during the day like everyone else :O

~~~
kureikain
I'm agree with you as well except the Rails point.

I have used and deploy Go/Elixir/Clojure to some certain success. One thing I
feel is that no code is as beautiful as Ruby code to my own eye.

What make Rails bad in your opinion? Is its performance? I think Rails is just
a framework with many utility/helper to help you out.

~~~
NegativeLatency
I think there's a valid case to be made that Spring and the rails auto-loader
are pretty annoying/stupid in larger projects (or anytime you're going against
the grain).

Every framework has its downsides. Personally I think rails is nice (I am very
productive with it).

~~~
mtarnovan
GP was talking about this Spring: [https://spring.io/](https://spring.io/) not
the Rails preloader...

~~~
jcadam
Yes, I meant the Java uberframework beloved by architecture astronauts. I
suppose I should have been more clear - I haven't uses RoR since version 3, so
my knowledge of that ecosystem isn't very current :)

------
lkrubner
This is a bit odd, that concurrency would be listed as something they gained
from Java, rather than Clojure:

" _Clojure: considering the difference between being easy and being simple.
Clear difference between data and logic that changes that data. Distinction
between pure functions and functions with side effects, try to separate them.
Let’s try to make simple code by default._ "

" _Java: performance, concurrency and strictness._ "

Maybe they mean they were forced to think about concurrency in Java?

I don't think any reasonable person would argue that concurrency is easier in
Java than in Clojure.

~~~
drawnwren
The author mentioned that the Clojure project never had to scale. My guess is
that the size of the Java project demanded concurrency and the Clojure project
didn't. Overall, this blog is light on details and heavy on how the
languages/projects made the author feel.

------
joshmn
The articles touches on this but just to reiterate because it's worth saying:
The most important thing about Rails is knowing how the internals work and
maintaining a clean code architecture. Too many times have I seen a mess in
Rails because developers only use the APIs and DSLs given to them.

The best Rails codebases are the ones who have ample "vanilla" Ruby and just
happen to use Rails alongside said Ruby.

~~~
jwdunne
Really interesting comment.

I've started working on a Rails project. I don't have any professional
experience with Rails in particular.

Can you recommend any code bases I can read that meet these criteria?

~~~
joshmn
My personal favorite codebase is GitLab (thanks syste and team!) — they do a
very fine job of pumping out Ruby while hanging out in the Rails ecosystem.
[https://gitlab.com/gitlab-org/gitlab-ce](https://gitlab.com/gitlab-
org/gitlab-ce) — points of interest are in lib, as well as how they organize
and call service objects from app/services.

~~~
fyfy18
As well as services, a couple of other folders you might want in app are for
decorators and form objects.

Form objects aren’t very common, but I’ve found it to be a really great patten
for simplifying code. Strong params and ActiveRecord methods are fine for
simple updates, but as soon as you get to something more complicated (e.g.
what if you want validations to apply only for certain users?) it just becomes
a mess - and you need to decide whether to have fat controllers or models.

The idea is you put all the logic for parsing params and updating records into
a form object. It keeps controllers and models skinny, and can easily be
tested without having to go through a controller. The reform gem provides a
few helpers that make them easy:

[https://github.com/trailblazer/reform/blob/master/README.md](https://github.com/trailblazer/reform/blob/master/README.md)

~~~
faitswulff
Awesome, the form pattern is a useful one. My coworker and I were just talking
about how frustrating it was to have validations coupled so tightly to the
models and this would have helped a lot. Thanks!

~~~
joshmn
I guess the idea is that you don't need to only use what Rails provides you,
and you're free to bake in your own Ruby as you see fit. Rails is just Ruby,
after all, and its modular enough at its core to be extensible for all sorts
of applications. You just might have to do some digging to get your Ruby code
Rails-friendly, such as using POROs alongside a form builder requires you to
include ActiveModel::Naming

------
kureikain
I may sounds weird but Ruby is what make me look more into functional
programming. I get done a lot with Ruby due to all method it has on
Array/Object/Enumerable.

The beauty of `&` is awesome and I discover that Elixir/Clojure has that and
bring it to next level. I think Ruby has inspired many other language to take
that path too.

One of the thing about Ruby is that it optimize for happiness, which sound
weird. But I really feel happy to write Ruby code. I feel like the language
really care about me.

Who don't want to have stuff like this:

``` 10.seconds.from_now ```

Or just call method without `()`, and without even wrapping hash in `{}`.

Of course, lots of these are do-able in Lisp and I like Clojure. But I think
the flexibility Ruby gives us is under estimated.

~~~
pavlov

      *> 10.seconds.from_now*
    

I don't understand this kind of weird "urban sprawl OOP" where classes are
extended with anything.

Why is 'seconds' a method on numbers? Is there also a 'pixels' method so that
I could draw a line like this:

    
    
      10.pixels.from.top_left_corner.to.southeast.using.red.stroke
    

If this doesn't seem like a sensible way of programming graphics, why does the
10.seconds thing get a pass?

~~~
tinco
It's not just 'anything' that objects are extended with in Ruby, they are
extended with suitable methods pertaining to the domain at hand. 'seconds' is
a conversion method of one type into another. You might as well ask why do
objects have a 'toString' method. Because it is convenient.

~~~
pavlov
Why does one conversion method have the “to” prefix and the other doesn’t? I
guess because the inconsistency looks somehow prettier.

But this is what drives me up the wall with the Ruby ecosystem: seems that
whenever API designers had the choice between consistency and fun gimmick,
they chose the latter. It makes some people feel happy, but often makes the
next person who has to read and maintain the code miserable.

~~~
jashmatthews
10.seconds is not part of the Ruby stdlib. It's Rails ActiveSupport. That's
why it's different.

------
slowmovintarget
As a hiring manager, I now look for _at least two_ languages, and they don't
need to be the tech stack we're currently using. If you're a good developer,
and you know more than one language, you understand that picking up another is
not an insurmountable barrier. You'll pick up our stack soon enough.

What I need to know is if you can think critically, not if you already know
what we plan to teach.

~~~
tro2102
Same here. Depending on the team I'm leading, I can actually consider not
having the current stack a plus, as an outsider's perspective on architecture
can help grow a team and codebase that's been stuck doing things the same way
for a long time.

There's some penalty in ramp-up time, but I find it more than pays for itself
down the road.

------
brandonbloom
Years of Clojure has made me a dramatically better Rails programmer. The
biggest change for me is that I now treat ActiveRecord models as gloried
hashes with easy-access to a namespace of related functions (ie. methods) that
operate on all manner of underspecified partial data, rather than traditional
OOP-style objects with sophisticated invariants. I'm also very careful to
strictly separate reads from writes, and to discard/reload all mutated objects
immediately after transacting with them.

My new business is built on Rails for a very long list of reasons, not the
least of which is that both Ruby is quite a nice language, and Rails is
actually quite good for back-office/lo-fi/quick-and-dirty, server-side-
rendered UX with relatively low web traffic.

~~~
cutler
Have you tried Elixir/Phoenix?

------
blunte
Clojure does not have an alien syntax. As with Lisps in general, it has almost
no syntax. (operator param param ...) Done.

~~~
ken
It has much more syntax than any other Lisp I know, and it seems alien even
coming from Common Lisp. In addition to the usual (list) and 'quote and
`backtick and :keyword and ;comment, it has [vector] and {map} and #{set} and
#(function) and @deref and #"regex" and ^metadata and #?(:conditional) and ...

(Yes, several of those are implemented as reader macros. I don't see how that
would make them any easier to learn than the same feature implemented as
"syntax".)

That's not a knock against it. I think Clojure is the best general-purpose
language today, but we've come a long way in the past few decades. Lisp is no
longer a language whose implementation fits on a blackboard (and everyone
extends it in their own way). We've discovered a bunch of common functionality
that almost all programs need, and pushed it up into the stdlib and language.

~~~
dragandj
It's only optional though. You can use (list 1 2 3), (vector 1 2 3), (hash-map
1 2 3 4), and (fn [x] (inc x)).

~~~
ken
I wouldn't say features like [vector] are optional alternatives to (vector),
if you can't write even the simplest function without using the [vector]
syntax.

------
tonyedgecombe
_Another thing I’m getting is that the new kids won’t like rails, and it’s
being harder to hire._

I'm surprised by this, to me the language used would be a long way down the
list when evaluating an employer.

~~~
oregontechninja
It's because we don't like or approve of rails. It doesn't make business sense
to us (us being a completely anecdotal group of young developers I'm friends
with). There are other solutions that provide sufficiently more developer
speed and safety, while also providing much better performance than any rails
application.

Edit: I guess I just hang out with like minded people, but our biases
shouldn't negate the fact that this is a very common feeling where I am.

~~~
erokar
What other solutions are you youngsters using then? Elixir/Phoenix?
Django/Python? Node? Haskell?

~~~
mattnewton
Not OP but in my limited experience the MVP slot is mostly held by Django,
with Node + typescript, Go and Elixir being the “safer, faster” variants
“kids” are using.

~~~
jarsin
Ha it's funny seeing Django in that list because back in day (10 years ago or
so) before rails took over I was trying to get everyone to use Django at my
job. Then rails exploded and I moved to that.

I honestly thought Django was mostly dead now.

~~~
stevenwoo
Anecdotally Django seems less common in the job listing post every month than
Rails but is still present, and the python experience is relevant to many
more.

~~~
mattnewton
Yeah I think it has to do with there being just more python scripts floating
around, and Django (or flask) make it easy to turn that random script into a
proper api. Plus CS courses have now started teaching python.

------
Xeoncross
I'm waiting for JavaScript to consume everything.
[https://www.destroyallsoftware.com/talks/the-birth-and-
death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-
javascript)

------
whack
This might be a stupid question and a tangent, but what does he mean by: _"
don’t use raw strings as constants"_

~~~
w4tson
Probably saying something like

    
    
      public String getDescription() {
        return “some constant”;
      }
    

Versus

    
    
      public String getDescription() {
        return FOO_DESCRIPTION;
      }
    

it’s a fairly weak example but you get the idea.

------
zombieprocesses
That reminds me of me after browsing HN's flavor of the month. Go -> Clojure
-> Ruby -> Rust -> F# -> ...

~~~
iammiles
Let me know when F# becomes flavor of the month. I'll gladly hop on that
bandwagon.

~~~
zombieprocesses
[https://news.ycombinator.com/item?id=13708453](https://news.ycombinator.com/item?id=13708453)

[https://news.ycombinator.com/item?id=14506287](https://news.ycombinator.com/item?id=14506287)

Enjoy. If you want to dip your toes in the water, you can go through

[https://learnxinyminutes.com/docs/fsharp/](https://learnxinyminutes.com/docs/fsharp/)

for a quick introduction.

If you have background in functional languages/programming, most of it should
look familiar. If you come from an OO or a procedural background, then it
might take some getting used to.

But if you are looking to get a job at a windows shop, I'd stick to C# ( or
VB.Net ) as that's where most of the jobs are.

------
pbreit
I am shocked at how many situations I've been in where the engineering team
has delivered a drastically over-complicated, usually micro-service-based,
system. Ten engineers working for a year where I could easily see 1-2
Rails/Django devs delivering more in 2 months.

------
blackmagevivi9
Clojure was fun overall. The not so fun part was integrating with necessary
Java libraries with crazy/stereotypical abstraction patterns. Necessary
because Clojure library offering isn't rich; not to knock on all the beautiful
open source work that's out there.

------
CryoLogic
I switched from rails to full-stack js and couldn't be happier. EmberJS +
ExpressJS is so simple to set up, and than you have everything in one language
and you can even share files and just use a build script to distribute them to
client and server (e.g. regex)

------
pmarreck
Would have been a bit more interesting had he passed through a BEAM VM
language on the way...

------
pimeys
My career so far:

Delphi -> Microsoft stack -> Rails/Ruby -> Scala -> Clojure -> Rust

The stuff I remember well starts from Ruby. Good things:

\- Ah man code is like a book.

\- Lots of people were writing Ruby back then, so lots of libraries.

Bad:

\- Deployments in general, this was before Docker, but I prefer having single
binary/jar deployments

\- Slow

\- Lots of runtime errors

\- You need lots of tests

Scala, good:

\- If using IntelliJ, the development experience is kind of slick

\- Quite modern, JVM libs work

\- You can go functional or OOP, whatever you wish

\- Fast

\- Type system helps you out, so no need for that many tests

Bad:

\- IntelliJ, I need my Emacs

\- SBT is not very nice in the end, making a huge jar file can cause trouble
sometimes

\- Not the biggest fan of implicits

Clojure, good:

\- Lisps are SO MUCH FUN to write

\- ...especially if writing pure functions, stuff like code generators

\- Emacs is good here, Cider rocks!

\- JVM libs are available

\- Leiningen is definitely nicer than SBT

\- Everything is pretty easy and straightforward

Bad:

\- Concurrency and effects can cause trouble, especially if doing it through
Java libraries

\- Leiningen is nice, but slow. You must use Cider.

\- Runtime errors, as with every dynamic language

\- Again lots of tests, but at least they're fun to write

Rust, good:

\- Concurrency, IO and so on. Just damn nice with Rust

\- Refactoring without fear

\- Cargo is the best dependency management / build tool ever

\- Small binaries

\- Total control of CPU/RAM, you can do pretty fast systems

\- If it compiles, it usually works

\- Type system is great, libraries are quite nice already

\- Community feels like the good old Ruby days, but better

Bad:

\- Borrow checker still sometimes hurts, hopefully non-lexical lifetimes land
to stable soon

\- Problems with the current 0.1 tokio and futures can be pretty daunting.
It's not a good idea to do super complex stuff with them yet

\- Write your own libraries, especially if you started two years ago. That was
fun though

I think the next thing I must grasp well is Haskell, just for the fun of it.

~~~
hashmal
> Community feels like the good old Ruby days, but better

I really miss that old Ruby community. It was full of that hacker spirit,
everyone trying stuff, no one to crush your creativity. Then the startup
hipsters took over and came up with good practices, style guides, gems you
absolutely had to know to get hired, etc.

It drove me away from Ruby, actually. It just wasn't fun anymore.

I hope it doesn't happen with Rust. I did not have so much fun writing code
for a long time.

~~~
innocentoldguy
Your comment really speaks to me. I'm in the process of transitioning my
career out of development altogether for the reason you mentioned getting out
of Ruby. It just isn't fun anymore. I haven't been able to find a company with
a good hacker-spirit since 2010. I like programming, and will probably
continue with languages like Elixir and Haskell, but as far as the day-to-day
work goes, I'm done.

~~~
cutler
Is that, perhaps, more to do with JS fatigue than anything related to Ruby or
Rails? What I can't fathom is how every shitty little SPA has to be done in
React these days.

------
freeslugs
thoughts on rails 5? coming from rails 3 -> 4 -> 5, it solved a lot of issues
for me.

