Live data from Hacker News

From Rails to Clojure, Then to Java, Then Back to Rails

engineering-management.space

71–80 of 157 posts

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#71
post #65
post #41

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.

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?

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 — points of interest are in lib, as well as how they organize and call service objects from app/services.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#72
post #10

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.

As someone stated, good OO and good functional is approaching the same goal from different sides. Your code being functional doesn't really make it less OO.

Except if you're using immutable data, pure functions and explicit state there's a lot less room for OO which (as presented by ruby, java etc) involves mutable data accessed/changed via methods that conceal their state.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#73
post #30
post #18

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

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 t…

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)).

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#74
post #34

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 he…

What libraries do you use for building web stuff? Over on Reddit[0] one of the problems for newbies to Clojure is not knowing what to use for web development. https://www.reddit.com/r/Clojure/comments/858g9z/what_clojur...

compojure-api[1] is great for building a REST API, and I really like HugSQL[2] for talking to databases. Buddy[3] is good for handling auth.

[1]: https://github.com/metosin/compojure-api

[2]: https://www.hugsql.org/

[3]: https://github.com/funcool/buddy

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#75
post #34

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 he…

If you want end-to-end Clojure/Lisp while retaining access to large ecosystems there's Clojurescript for the browser and Node.js, Hy (http://hylang.org) for scripting and data science plus Clojure for JVM/large applications with performance. Now you can get a VPS with 4Gb of RAM for £5/month at Hetzner (http://hetzner.com) so JVM memory usage is no longer an issue. These are exciting times indeed for developers.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#76

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.

I don't think it's that newcomers won't like Rails. I feel it just makes sense to go all Javascript instead since that's where the momentum is now and doing everything in one language has a lot of benefits especially when it's something as ubiquitous as javascript.

That wasn't what I was thinking about, there are good reasons to choose one stack over another once you are in a job. When you are job searching though there are a ton of criteria: salary, opportunities to learn and develop, autonomy in the role, enlightened management, realistic schedules, short commute, holidays, decent desk, chair and screen. I'd put all of those over a choice between Ruby and JavaScript.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#77
post #58
post #54

Earlier quoted context omitted.

re-frame is the uncrowned king of web dev at the moment, there is nothing like it out there

That's only for the front end though. Lots of people use Compojure which is essentially Sinatra if you're coming from Ruby. Luminus is a far more complete solution that feels like Rails. After I cut my teeth enough times starting from nothing, Luminus unfortunately feels a little clunky because you have to figure out how it's all glued together.

There's Macchiato (https://macchiato-framework.github.io) by the author of Luminus if you want to target Node.js.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#78
post #45

Earlier quoted context omitted.

Isn’t there something called LazyEnumerator that deals with this? In terms of chained .map at least

Lazy enumerators don't make each individual step of the iteration any more efficient. They just let you stop the iteration partway through without traversing the entire original enumerable. Given this contrived example: a = (1..1000).lazy.select(&:even?).map{|i| i*2 }.map{|i| i + 1 }.map(&:to_s).map(&:reverse) There is no benefit from lazy if you do `a.join(",")`, since that iterates over the entire sequence. But if…

Ruby's composabilty really puts Python to shame. I can't imagine how Ruby lost out to Python.

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#79

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 s…

My reaction to this claim was that, since Clojure is on the JVM, any advantages Java has, Clojure also has.

Of course, idiomatic Clojure might require less mindshare to make highly performant, concurrent code...

Re: From Rails to Clojure, Then to Java, Then Back to Rails

#80
post #34

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 he…

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.

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).

Post reply on HN