Hacker News new | ask | show | jobs
by gls2ro 1519 days ago
For people in this thread comparing _Rails_ with _Go_ can you please help me understand something about Go: Is it a language that also has in std/core library web framework like support? Like PHP?

I ask as I dont understand why people say drop Rails and learn Go. And I am looking to learn a new language along with Ruby and Elixir.

Why is Go compared with Rails and not with Ruby?

If Go does not include a default support for web frameworks then what web framework would you suggest for doing a web SaaS like management of posting on social media?

I dont want to create this but i use it as an example as it has image uploads, date/time, jobs, … things I can do easily in Rails and have already battle tested solutions available.

4 comments

The Go standard library has all you need to stand up a basic HTTP service. Which isn't the same as Rails by a long shot, but it does fit in well with what a lot of places are doing these days.
yeah, you'll see this argument a lot.

If someone feels like re-implementing all the wonderful conveniences of rails in Go, more power to them. However, that's a MASSIVE amount of work that you'll be doing _instead_ of actually making the webapp.

Go is great, but it's built in HTTP support isn't even _remotely_ equivalent to the many years of accreted utility in Rails.

To put it another way, it's a false equivalence. No-one should EVER say "learn go" instead of rails. Now, if they said "lean Buffalo" ( https://gobuffalo.io/ a Railsish framework in go) instead of Rails you could have a very reasonable discussion.

This is fairly inaccurate. The stdlib accomplishes a lot and unless you absolutely must have a wizard in your CLI to generate routes then you really aren't missing much at all. Having designed products in both, I'd prefer Go these days because unless I'm making todo apps there is a lot of decision and freedom taken out of my hands by using rails.

All of this disregards the speed advantage of go. There is no comparison between the two.

Generators, while nice, are nowhere near the most important thing that Rails brings that are often overlooked, even by "full featured" frameworks in other ecosystems.

- Migrations are well-implemented, and I've definitely wasted many cycles at other startups dealing with hand-rolled migration tools that are nowhere near Rails.

- The ORM (ActiveRecord), while very opinionated, is pretty full featured and suitable for 95% of use cases (and makes it fairly easy to drop out of it if needed)

- There's a host of security features that are taken care of you by Rails out of the box, including CSRF protection, session security and password hashing with a sane strategy and good algorithms (I'm sure there's others I'm missing)

- Websocket functionality comes out of the box with newer versions of Rails

- Asset handling, including minifying and digesting assets is included.

- Directory structure is set up for you (seems minor, but it's a huge productivity boost when joining a new team knowing where everything should be).

- A standard approach to background queueing, built in a way that it's extensible for different queue / worker backends (i.e. your jobs are cross-compatible with different background libraries and backend servers - I can come onto a Rails job that stores background jobs in Postgres, SQS, Redis, or anything else and how the jobs work is consistent).

Regarding speed, I'm certainly not going to argue that Ruby is faster than Go, but at least for the problems that I tend to work on, raw language execution performance is never really the bottleneck. It's cheap to throw money at, and 99% of the time when I look at poorly performing actions the culprit is the database or an external service.

There are a lot of things that rails gives you out of the box automatically which require either a lot of additional code in Go’s ecosystem.

CSP, csurf tokens, param parsing with array and hash map params, strong params, automatic response codes (201 for created for example), etags, … just from the top of my head. I’m sure I could find dozens more if I start looking.

All of those are possible in every stack of course but rails already gave you all of that from the time you typed “rails new”

you can go quite far with golang without needing any other library/framework with just std library which means less dependencies and lesser things to worry about in case of maintaining your code base, upgrading it with newere go version and ease of operation(since it is single executable). Some of the basic things that you need that don't require frameworks are 1. http/https 2. authentication 3. sending mails 4. templating(it isn't powerful but you get by) 5. background jobs 6. date/time etc.

I am not familiar with ruby but my understanding is you don't get these out of the box you will need framework like rails for it. How easy/difficult it is to upgrade rails? for golang if you are sticking to stdlib it is trivial. If it is easy to upgrade/maintain/operate rails and you are familiar with it than don't switch.

Upgrading Rails itself has been relatively simple for at least the last few versions. Between Rails 2 and Rails 4 upgrades were very painful, but that's settled down significantly. You won't necessarily get the new features available with new versions, but especially recently things tend to stay fairly backwards compatible, and when functionality is removed it's almost always moved to a separate library that can just be included with little fuss.

Rails is also a fairly complete package, and you can get very far without additional libraries. Once you do start to bring in libraries it can get painful, particularly if you stray off the path of very popular libraries, but it's nowhere near the Javascript ecosystem.

You're right that Ruby itself won't get you far in terms of a webserver, but the vast majority of web development is done with Rails so in that context it's analogous to thinking of Rails as almost part of stdlib when thinking about web development specifically.

I don't think most are directly comparing them as it might seem on the surface. Simply pointing that, if ruby is past its prime, then rails is as well. We don't know what the end project is for everyone, so choosing a web framework here in the comments is kinda early in the discussion anyway.
There simply is no evidence whatsoever that Ruby is past its prime. People are committing myriad logical fallacies: comparing go language to rails framework, anecdotes about Ruby monoliths, incorrect statements of fact about Ruby capability and more.

I like Go, but this is a terrible comparison and I’ve not seen a single comment make a valid point about Ruby’s alleged demise.

Sounds a bit defensive, it is "past its prime":

https://octoverse.github.com/#top-languages-over-the-years

However, that doesn't mean it is dead, or you can't still do great things with it. Most platforms continue fine on into their twilight years :rofl:. Lotsa folks here getting shit done with perl and lazarus ide.

You are confusing popularity with capability. Ruby is less popular than it was, but it is still very healthy and solving problems. It is also actively developed.

This entire exchange would not have happened if you had simply said, Ruby is less popular than it used to be.

“Past its prime” is a derogatory expression that is invalid in this use case.

You've just defined “Past its prime,” congrats. :-D
> I ask as I dont understand why people say drop Rails and learn Go

Agreed. I don't think Go is that great for normal CRUD web development at all, maybe its interesting for super high concurrency / low level stuff.