Live data from Hacker News

Choosing Ruby on Rails for web development project in 2019

ideamotive.co

81–90 of 216 posts

Re: Choosing Ruby on Rails for web development project in 2019

#81

Rails is ideal for the "Get Shit Done" approach to development. However, Ruby's type system does not provide many assurances, making mature codebases harder to maintain, refactor, and extend (as compared to codebases in, say, well-written Java). I am surprised this was not listed as one of the criticisms. Sorbet, a type checker for Ruby, stands to make this criticism less valid: https://sorbet.org/

I have to be honest, I don't understand why people care so much about typed languages. I almost never face type related issues, and when they occur they are the easiest to catch.

Type errors aren't the problem, understanding what the code is doing is the problem. I like to know what I'm looking at -- is it a primitive? A simple array? A complex, stateful object? This helps establish clearer relationships between systems.

Re: Choosing Ruby on Rails for web development project in 2019

#83
post #12

Earlier quoted context omitted.

Ruby 3x3 is a thing (make Ruby 3.0, 3x faster), and Ruby 2.6 is said to include an optional JIT compilation mode. I haven't seen any benchmarks or analysis that say JIT is ready for production use, but indications are strong that the next version of Ruby will include a lot of surprising things, like maybe a type system? Ruby got a reputation for being slow very early on, and my understanding is a lot of that was due…

I was listening to a recent interview with DHH and he makes a great point that Rails and Ruby are about optimizing for developer happiness and dev speed. Computing power keeps becoming cheaper and ruby keeps getting faster but developer's salaries continue to be the number one cost for software companies.

It's not so easy.

Computing power can be increased by scaling vertically or horizontally. Vertical scaling has an upper limit, and when one reaches it, in certain contexts, end of the happiness :-)

Case in point: GitLab; they have Go microservices. GitHub was also hiring Go developers, so very likely they've done the same.

Of course, few companies are GitLab/GitHub, but the point is that it's not possible to make absolute statements about power being cheap.

Re: Choosing Ruby on Rails for web development project in 2019

#85

Rails is ideal for the "Get Shit Done" approach to development. However, Ruby's type system does not provide many assurances, making mature codebases harder to maintain, refactor, and extend (as compared to codebases in, say, well-written Java). I am surprised this was not listed as one of the criticisms. Sorbet, a type checker for Ruby, stands to make this criticism less valid: https://sorbet.org/

I have to be honest, I don't understand why people care so much about typed languages. I almost never face type related issues, and when they occur they are the easiest to catch.

Passing a string where you expect a number is not the only kind of type errors modern type systems are about. They can catch a particular class of domain-level bugs, and more importantly, it acts as a pair programmer who tells us about all the logical edge cases that we forgot to think about, as we program.

This is done using what is called "sum types" - we can tell the compiler that say a user can be "Premium" or "Regular". This distinction will affect policies across the codebase - eg. Premium customers get a discount on their shipping costs. We'll have robust unit tests and integration test that cover all these policies.

But even with the tests, we run into trouble when the feature request to create a new type of User comes in - "Semi-Premium" who gets only their _domestic_ shipping free. We now have to hunt and peck across the codebase, and change all our policies so that it handles this possibility well. Our tests are of no help here - they are meant to verify existing facts about the system, and can't tell when this user fall through certain policies because we forgot to handle it there. The type system on the other hand knows exactly the places where we decide things based on the kind of user. It will then realize that a new type of user has come in, and our policies don't handle them. This turns what usually is a high-risk and difficult task into an almost mechanical one.

What's happening here is that we're telling the compiler more things about our domain. This means the compiler can then remind us as we go about our business writing code, to handle every case, to never pass a null, and to help model our data structures that prevents inconsistent states from ever happening. The more we can encode in types, the more powerful this becomes.

Re: Choosing Ruby on Rails for web development project in 2019

#86
post #11

Earlier quoted context omitted.

> I've been slowly working on a backend for a web app in Rust I'm interested in why you made the choice to use Rust for a web app? It feels like you love a good challenge, but there are obviously technical constraints for some apps. I look around and wonder if the options have really changed a whole lot since 2006? If you need productivity, choose Ruby or Python (or maybe JS.) Java and .NET exist if you have more exa…

Or if you want productivity and a performant web server, try Elixir + Phoenix. Number crunching still has to be dished off to something else like C, Rust or Go, though.

The lack of a type system in Elixir is a productivity killer though :(

Re: Choosing Ruby on Rails for web development project in 2019

#87
post #48

Earlier quoted context omitted.

When Rails came out, Ruby was the slowest language by far because its interpreter literally just walked an AST. No intermediate byte code, no VM, it just eval'd an AST. This reputation stuck longer though, although yeah I imagine Ruby is still slower than Python and Node even now despite having a VM.

Current stable version Ruby 2.6.2 with --jit is actually faster than Python 3 according to this: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

And actually slower also.

Re: Choosing Ruby on Rails for web development project in 2019

#88
> What is special about Ruby? Blocks

As far as I can tell, blocks are just some sort of hack to get around the performance overhead of using lambdas. They feel like more of a bug than a feature. Why, otherwise, would it be sane to have an ubiquitous feature that is almost a lambda, but less flexible, while also having lambdas that no one uses.

Ruby was my first programming language. I would agree that it's natural feeling, but it is the opposite of simple.

Re: Choosing Ruby on Rails for web development project in 2019

#89

Earlier quoted context omitted.

I've taken the approach of building the monolith first with an architecture that allows me to easily pull parts of it out into services when I hit constraints and need that scalability.

How?

Elixir and Phoenix. The contexts pattern used in Phoenix is the most modular, easily microserviced way of structuring apps I’ve ever used. I slapped myself on the forehead when I first saw it. Duh. It’s really fantastic. Highly recommend

Re: Choosing Ruby on Rails for web development project in 2019

#90
post #11
post #3

The beauty of rails is how simple and quick it is to get a robust (if bare) application up and running. Even if you use sinatra or padrino instead, the wealth of the web community built around ruby still makes it rather easy. If I were a tech lead and had to make a choice now, in 2019, I would still (probably) choose rails-api for a backend with some separate frontend. I've been slowly working on a backend for a web…

> I've been slowly working on a backend for a web app in Rust I'm interested in why you made the choice to use Rust for a web app? It feels like you love a good challenge, but there are obviously technical constraints for some apps. I look around and wonder if the options have really changed a whole lot since 2006? If you need productivity, choose Ruby or Python (or maybe JS.) Java and .NET exist if you have more exa…

Ruby and Python aren’t any more productive than C# or Java in my opinion. Especially when you consider the errors static typing helps you avoid.
Post reply on HN