Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not sure I would still have the will to keep coding without ruby



Ruby has definitely helped me get through some rough and tight spots. So many things are easily able to bum me out, while Ruby goes out of its way to make me happy.

> Welcome home. Things are going to be fine. Don't worry about nonsense. Just `:chill`

A beloved safety blanket that makes it easy and fun to do boring everyday tasks.


What are your thoughts about it being the 7th most dreaded language on Stack Overflow's 2020 developer survey? I've never programmed in Ruby, but it seems attractive to me.


I honestly cannot believe that this is a solid metric. I believe the question, or their answers are poorly parsed.

I presume a lot of the dread is really about Rails. And the rest partly hearsay of the slow performance of Ruby.

Rails is, to me, a blessing, but also a terrible framework. It helps to rapidly ship products. Just cobble some gems together in a controller or two, mix a gem or three into your models and you have a demo. A rapid Proof of Concept. But also a product that is practically unmaintainable. I've been doing Rails from its very beginning, solving this (trying to) has been my primary job for over seven years now.

And performance? Yes Ruby is slow. But the speed of the language is unmeasurable in, I daresay, the vast majority of the projects of people who tell you it is too slow.

That legacy mysql setup, this poorly evolved domain model, or that badly integrated external API is almost always the thing making it slow. The ms of Ruby handling that JSON to CSV conversion then is practically unmeasurable.

Rust is not going to speed up those 3000ms spend in that ugly SQL query. Go's multithreading is not going to solve the slow API which you call thrice per minute. And Java is not magically making the tangle of classes, jobs, callbacks, listeners and whatnot dissapear.


Rails is alright. It's just a great scapegoat for bad teams working under impossible deadlines: "Our code is unmaintainable because Rails! We need 1 year to rewrite it in Go/Elixir/Java". I mean, because Rails has a flat structure you couldn't ever take the time to reactor that piece of crap code you wrote for 2 years? really? You didn't notice a model stopped making sense or growing in complexity? I see the same criticism with PHP. It's perfectly fine, stop blaming the tool.


Rails doesn't help you form a proper domain model. Or force you to put side-effects in the proper place; it doesn't help with evolving a proper data model, or avoid tight coupling in unwanted places, it has hardly any tooling in place to employ design patterns.

On contrary: often it encourages bad practices through "defacto" standard gems, or by making "the wrong choice" easier than "the proper design pattern". A "concern" is a simple way to turn a 800-lines controller into four 300 lines modules that amount to the same ball-of-mud, for example. (Concerns have great use-cases, but most often it is not the solution to your problem). Rails offers things like `try(:foo)` to quickly solve that equivalent of the "null-pointer"- exception, without forcing the developers to dive and in and solve the reason why it is nil, or solve it with some design pattern (adapters, null-pattern etc) either: just keep sprinkling `try()` keeps it rattling along too. Somewhat.

So, yes: lack of proper design and architecture is the real problem behind those "ball-of-mud" rails projects. But Rails' lack of training-wheels and the ease at which to make the wrong choices, really doesn't help teams aim at proper design and archicture either.


> Rails doesn't help you form a proper domain model. Or force you to put side-effects in the proper place; it doesn't help with evolving a proper data model, or avoid tight coupling in unwanted places, it has hardly any tooling in place to employ design patterns.

I think this is only half true. Rails certainly forces very little on you - but has lots of documentation and helping hands pushing you towards tdd - and it has fairly powerful and simple tools to help with data modeling - as long as your data can fit reasonably in the ActiveRecord pattern.

More complex subsystems can be split out into rails engines or services.

All that said,it is indeed easy, without some discipline, to roll out complected controllers and views.

But I don't think it's fair to say that rails the framework via structure or its official guides, encourages that.

Quite the opposite.

As for "try" (now for a long time largely subsumed by ruby's built in &-operator) - that can be helpful where appropriate, like with handling input,and occasionally with explicitly optional relationships and nullable values. But of course NULLs should normally be avoided, and the database should be leveraged to ensure data integrity. And rails allow you to do that.


Rails has a flat structure, it has no knowledge how big your project will become. For many, many code bases this is good enough. Look at Gitlab, which is quite big. If you need more structure there are many design patterns you can follow and introduce into your codebase.


GitLab is also notoriously difficult to deploy by yourself (okay, lately it has been better though) and slow as hell.


I like their UI just fine. Speed, smoothness, never had much of a problem. And the amounts of features they were able to come up with the last few years is pretty impressive.


In terms of features I quite like GitLab as well. I just think it's time they rewrote it in something much faster than Rails.

I have literally never used a fast GitLab instance. Anecdotal evidence, I am aware. I'd still venture out to claim this says something about the average speed of your average GitLab installation though.

I'm rooting for them. GitHub needs competition.


Hmm don't see any rewrite in their cards though...they're pretty much gonna ride this thing with Ruby. If Shopify did it with their monster scale I bet they can as well.


On the nulls bit, in a context where nil is a legitimate value, my team's policy is to use the ampersand operator. To be honest this is preferable because it clutters up code the least. I don't think we use a single try() anywhere, even before I used ampersands it was always `blah_blah unless x.nil?` etc etc


There are legitimate cases for `nil`, but far less than most people allow.

What does "user.last_login_at == nil" mean? `NoMethodError `to_human_date` for `nil` in email.erb. "Quick! lets fix that with a `try(:last_login_at, "Never")`: if nil, it means the user never logged in.

You now, without proper thought, you introduced a business meaning to a missing value. Adding tight coupling, slowly painting yourself in a corner. How does this translate to "Could you give me a CSV with all users that never logged in"?

Maybe you did mean to assign such domain-meaning to "last_login_at == nil", but then it is far better to explicitely do this. E.g. a `NeverLoggedInUser` subclass, a method on the model `never_logged_in?` an explicit flag in the database, or maybe even a special table "inactive_users" that holds these. All depending on domain-meanings, discussions, use-cases and thought. This is always a lot more work than just throwing another `try` at the bug. Rails "rewards" the bad choice, and somewhat opposes the proper solution.

Rails makes it easy to prototype and rapidly move forward: those are good features. But often you should, instead, be forced to halt for a second. To push you towards the whiteboard. Being able to throw in a quick `try` here, or a `sort(last_logged_in: :desc)` with another `where.not(last_logged_in: nil)` there, and so on, are a blessing when quickly moving forward. But they will haunt you in the future.

Balancing that is hard, regardless of framework, but Rails' features balance towards the "moving fast" a bit too often in my liking. Esp. because it rewards that team-member who "Gets stuff done" by abusing those "quickfixes", while leaving the project with ever more technical debt etc.


Having worked and working with rails projects spanning ruby 1.9 through 2.4 and rails 3.2, 4.1, 4.2 and 5.2 - the major issue I've seen with legacy rails is how difficult it is to keep views refactored and seperateted into widgets. Some teams seem to blame erb for this and run towards various different template dsls like haml (equivalent to writing a template language for php, which already is a template language, because the team can't keep views/templates simple).

Fat/smart models help - but the old/standard tools in rails (helpers and partials) INMHO is poor tooling for the "view" layer - and this just gets worse with Javascript in the mix.

That is finally being addressed - I've yet to experiment with it, but I like the idea: https://github.blog/2020-12-15-encapsulating-ruby-on-rails-v...

Another option is of course to just use rails as an api server, and do the front end in react/vue etc. Although, at that point, you might be better off just using postgraphile or hasura.

The other real problem I see in some of our projects, is developers simply not trying to learn minimal best practices (just reading a few paragraphs on rails guides...). And that leads to many awkward choices, a lot of re-inventing subsystems that already exist in rails (because developers didn't have a look before coding up a quick fix) - and few tests and poor testability. But those strike me as much more cases of people "holding it wrong" than rails being the problem.

Finally, I think there's still some issues in rails 6 with asset handling - but overall rails 6 seems like a comprehensive, solid and easy to use framework.


> But those strike me as much more cases of people "holding it wrong" than rails being the problem.

My idea exactly.

To stretch that analogy: Rails has guides, books and neat API documentation explaining how you should "hold it properly" (and when not to etc.). But it also lacks "notches", "crossbeams" or "ridges" that help people "hold it properly" on a daily basis.


Well, what you said would be true if management was sympathetic to the argument of "the language and framework we are using no longer serves the project well, so let's rewrite". Since they are not, projects are, 99% of the time, stuck with their first choice of language / framework for life.


What I meant was you can take a messy Rails monolith and do a million things to improve it (including breaking it into smaller independent services if that's your thing). Rewriting in another language is the last thing I would do if the project is big.


> And Java is not magically making the tangle of classes, jobs, callbacks, listeners and whatnot dissapear.

Make it disappear, no, but it can make it much easier to create, using Spring's ClassJobCallbackListenerTangleFactory.


Ruby isn't new or novel anymore, and is a relatively small niche. Learning it properly takes time and effort - hence the "dread". I'm pretty sure 10 years ago no one dreaded Ruby yet the language was almost identical to what it is now. So I think it speaks less about languages per se and more about hype cycles and job markets.


There's a saying that Ruby gives "Every toddler a chainsaw" (https://codefol.io/posts/ruby-python-and-freedom/). You can use it and it's metaprogramming to write some really elegant APIs. You can also write entirely the wrong abstractions, and it will not stop you. You can even extract private variables from lambdas if you're willing.

Now, imagine that in the hands of someone with poor taste, or, even, just rather different taste than yours.


I think that says more about who takes the survey.


Not a big fan of Ruby (okay, with 3.0 I might become a fan again!) but to be fair, these SO surveys are asking really weird questions that appeal much more to emotion than to reason.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: