Live data from Hacker News

Rails for everything

literallythevoid.com

201–210 of 250 posts

Re: Rails for everything

#201
post #174

One thing I don't get about the current Rails direction is pushing hard to use SQLite and removing external dependencies but at the same time also advocating to use Docker. Running Postgres and Redis in Docker is a matter of adding a few lines of YAML to a file once and never thinking about it again. I have done this for 10 years, it is painless. I'm all for reducing moving parts and would also choose the same strate…

> I have done this for 10 years > it is painless Huh, I wonder why.

> Huh, I wonder why.

I didn't start with 10 years of experience if that's what you mean.

A basic Redis config inside of Docker Compose could be:

    services:
      redis:
        image: "redis:7.4.1-bookworm"
        restart: "unless-stopped"
        volumes:
          - "redis:/data"

    volumes:
      redis: {}

Now you have Redis running with your project and you can use "redis" as the hostname to connect from your app. It even persists to disk with a volume if needed.

It's similar for Postgres except you'd also want to set the PG username and password with environment variables so your initial user and DB get set up with reasonable defaults.

A working version of this is in my Rails starter app at: https://github.com/nickjj/docker-rails-example

It sets a few more properties but those aren't essential to get going.

Re: Rails for everything

#202

I always read how great Ruby/Rails are, but learning language just for one thing (Rails) rubs me up the wrong way. Especially when alternative (Python) is so much more useful (on a surface) and Django can do the job of Rails (while not as good or nice as Rails (from what I gathered), but still). Kinda like learning Dart for Flutter. Those of you who struggled with the same dilemma, what did you do?

As others have pointed out, there are many use cases for ruby. It's probably the best choice for scripts (rake, optparse, fileutils, ...). There's embedded stuff (mruby), music (Sonic Pi), cross-platform GUI apps (e.g. glimmer), game development, and much more. But I'd be interested to know where Python is more useful, apart from science, data science, ML, AI, and such.

I don't doubt there are many uses for Ruby. But if we're talking strictly about employment, there's literally nothing outside of Rails (quick search of Ruby vs Python in the Netherlands yields 762 vs 20k hits (many of those are garbage, but you get the idea)).

Python also has far stronger typing story, it is used as a glue in many orgs (just look at Mozilla, Chrome and countless more codebases), there's also an order of magnitude more people using Python which means far more nicer LLM story.

On the other hand Ruby evangelists swear by Ruby like it's the second coming, so there must be something that makes people so happy. I'm trying to understand if it matters enough to pay opportunity cost for switching to Ruby.

And yes, I know that you can learn both, but becoming proficient in languages takes time and practice. Ruby isn't something that I'll be able to sell at my org, which means I'll have to invest into it in my own free time. On top of that you have to stay up to date with language developments if you want to stay relevant.

Re: Rails for everything

#203
post #79

Earlier quoted context omitted.

Ruby doesn't really have a learning curve... Maybe block syntax but that's super easy. Rails gives you way more structure than Django.

I tell people that Ruby is a language optimized for reading. Things just make sense when you are reading what someone else wrote, but it can be much more difficult to write something from scratch with no guidance. Take dates, for example. Let's say you are fixing an issue, validation was set to accept one week in the future, but should have been one day in the past. 1.week.from_now becomes... well, how do you look th…

That isn't Ruby, that's Rails. Ruby doesn't have nearly as big of a learning curve as Rails.

Re: Rails for everything

#204
post #142
post #133

for auth - instead of devise or the rails 8 auth - you can also opt for authentication-zero. what's hardly ever mentioned is how great hotwire is. it takes time getting used to, documentation is sparse but oh man oh man - hotwire is nice. you get to skip a majority of spa shenanigans.

I am really struggling to get hotwire running to be honest. I now just postponed implementing it till after the launch. Any good ways of getting up to speed on hotwire and debugging it?

A lot of people seem to overcomplicate it by bringing their thoughts on how other modern js apps are written. It would be helpful to have a specific example of some of the things you need to work through. Reading through the [handbook](https://hotwired.dev/) should get you most of the way there.

One of my colleagues recently switched from mostly react to default full stack Rails. He was really struggling with how to filter things in a table. When I showed him how I would do it, his comment was along the lines of: “I can’t believe how simple this is. Modern JS just doesn’t work this simple any more. This is like how jquery used to work but way more organized”.

I can’t say I know enough about modern js development to validate that comment. He noted something about expectations of how the dom managing things…

So, if you’re coming with a certain mindset of how to do things, try to leave that behind a moment and read through the handbook. Especially if it involves making fetch requests to do things. That’s like, the number one “you probably shouldn’t do it like that” in Hotwire.

Re: Rails for everything

#205
post #182

Anyone know any good hosting options for little personal, experimental Rails apps that might not go anywhere (i.e. that I might well lose interest in but forget to cancel)? I’ve always liked Vercel’s approach for these kind of side-projects, as I don’t have to worry about cancelling anything if I stop using it. But I guess that is a perk of it being serverless, which precludes Rails. What’s the next best option, some…

You're correct. You need a server, so Vercel approach with serverless are not applicable here. As for the hosting, any VPS should be fine. I host mine on Digital Ocean. You can use Kamal to setup for database too. Or if it's simple enough, sqlite is great.

Re: Rails for everything

#206

Earlier quoted context omitted.

Every time I step out of elixir I feel like I’m coding with some cumbersome construction gloves and everything is kinda coerced to work together. But for some reason it’s not picking up a lot of steam and the job situation is rough

Typed languages are in big time, and any dynamic language is facing an uphill battle for adoption, no matter how good it is. Elixir seems to recognize this and is getting there, but it hasn't fully arrived yet.

Types and editor tooling IMO. Both places they're making investments, but both areas where I feel like I'm giving up a lot of power, even though it's admittedly to GET a lot of power.

Re: Rails for everything

#207

Earlier quoted context omitted.

It does have validations but the integration of then in Rails goes much further. In Rails you associate the form with the model and the validation errors somatically show up on the form.

I'm amazed that some people think that coupling your forms to your database models is a good practice.

More often than not, forms are the database model. They very frequently evolve together. The entire data transfer object to model copy back and forth is unnecessary most of the time

Re: Rails for everything

#208
post #79

Earlier quoted context omitted.

Ruby doesn't really have a learning curve... Maybe block syntax but that's super easy. Rails gives you way more structure than Django.

I tell people that Ruby is a language optimized for reading. Things just make sense when you are reading what someone else wrote, but it can be much more difficult to write something from scratch with no guidance. Take dates, for example. Let's say you are fixing an issue, validation was set to accept one week in the future, but should have been one day in the past. 1.week.from_now becomes... well, how do you look th…

Literally everything you described is fixed by reading the documentation.

Using Rails? Read Rails documentation.

Using bare Ruby? Read Ruby documentation.

And literally every programming language is like this. C# won't contain Unity C# classes. Basic Python won't have Numpy classes. JS won't have React functions. And so on. Also it's not like Ruby is the only language to ever have monkey patching...

It's absurd that this is being brought up as a Ruby weakness when both the Ruby website and the Rails website each have amazing documentation and if you actually read the documentation, go through tutorials, it's all laid out very clearly.

https://www.ruby-lang.org/en/documentation/

https://rubyonrails.org/docs

Dunno, whenever I learn a new language, I read the official docs. When I learn a new framework, I read the official docs. Even when I was an absolute newbie, I learned from the resources on the official website.

Re: Rails for everything

#209

Earlier quoted context omitted.

As others have pointed out, there are many use cases for ruby. It's probably the best choice for scripts (rake, optparse, fileutils, ...). There's embedded stuff (mruby), music (Sonic Pi), cross-platform GUI apps (e.g. glimmer), game development, and much more. But I'd be interested to know where Python is more useful, apart from science, data science, ML, AI, and such.

I don't doubt there are many uses for Ruby. But if we're talking strictly about employment, there's literally nothing outside of Rails (quick search of Ruby vs Python in the Netherlands yields 762 vs 20k hits (many of those are garbage, but you get the idea)). Python also has far stronger typing story, it is used as a glue in many orgs (just look at Mozilla, Chrome and countless more codebases), there's also an order…

I agree to all your points but the stat stands out in particular:

> 762 vs 20k hits

That's impressive! I guess the difference is smaller here in Berlin as we have a lot of rails shops, but internationally speaking, your stat might well be representative. There might also be less competition in the Ruby job market, but perhaps not to such a degree to offset the difference in job numbers.

In the end, Python is probably the safer and more career friendly option, especially if you're interested in AI. However, if you enjoy coding, Ruby is IMHO the top choice to maximize this enjoyment. I don't think it's the second coming, but there's no other commonly used language where you can do things as easily and so without bending to any limits of the language. The downside of this power is that you're never done learning about it. Maybe people who are drawn to coding as a hobby are more likely to enjoy Ruby than those with more of a separation between work and private interests.

Re: Rails for everything

#210
post #47

Rails is awesome, and so is Django. I’ve built mission-critical apps in both and still do with Python. That said, I’d love to switch to Go for building large monoliths since it has a tighter type system and better concurrency constructs. The problem is, Go community has never really filled that gap. I love Go, but the whole "Go doesn’t need a Rails or Django" mindset is part of why it hasn’t taken off in this space.…

I could really recommend Encore https://encore.dev/ that works best when you use their PaaS offering https://encore.cloud/ (think of NextJS & Vercel combo).

One can argue it goes against some of the Go principles, but it's a really nice stack for solos or small teams without dedicated SREs. And as you grow you can BYOC & deploy it yourself or completely rewrite your API layer using Go stdlib.

You would still need NextJS or Remix/RR7 for the front-end, but one nice thing is that it would auto-generate the client SDK in TypeScript which makes integration a breeze. And while I personally prefer Remix/RR7 for frontend, Encore has integration with Vercel PR feature which is really hard to beat.

Post reply on HN