News for hackers. Stuff that matters.
Re:An Ode to Ruby by bachmeier on Monday January 10, 2022 @10:13AM (#29876052)
One of my goals for 2022 is to write my first real web app. I want to understand things like authentication, creating an API, and security. My initial impression is that the JS/Node world is miserable. Rails looks 1000 times more pleasant.
Re:An Ode to Ruby by revscat on Monday January 10, 2022 @11:46AM (#29877543)
> My initial impression is that the JS/Node world is miserable. Rails looks 1000 times more pleasant.

God, yes. Especially with Hotwire [1], which advertises being able to do modern web apps with a minimum of JS. I've played around with it, and for me it completely eliminates the need for AngularJS/React/whatever.

[1] https://hotwired.dev

Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:33PM (#29887131)
Yes but Node's built-in async will scale a lot better especially if you're calling 3rd party services.
Re:An Ode to Ruby by billyruffian on Wednesday January 12, 2022 @05:27AM (#29904558)
The Async gem and Ruby 3+ is an incredible piece of work. If you need to coordinate 3rd party services, it's the way to go in ruby and it just reads beautifully.
Re:An Ode to Ruby by matwood on Monday January 10, 2022 @10:23AM (#29876206)
I don't know about miserable, but definitely easier to get side tracked deciding what libs to use. Rails tends to push users down a path that works for most things. This makes it much easier for new users. JS leaves it up to the developer to pick and choose what libs which is not new user friendly.
Re:An Ode to Ruby by Mikeb85 on Monday January 10, 2022 @01:41PM (#29879430)
Rails is shockingly easy, especially Rails 7.

Strait up, use Rails with all the defaults (ImportMap, Hotwire) but use Postgres and maybe Tailwind (`rails new myapp --database=postgresql --css=tailwind`). No extra gems are needed really (if anything, they add more complexity as not all are updated to be compatible with Rails 7).

Re:An Ode to Ruby by ascendantlogic on Monday January 10, 2022 @10:37AM (#29876441)
Rails and Django are both very pleasant and have enormous ecosystems where every imaginable problem has been encountered and "solved". It's been a while since i was writing Rails but from what I gather Rails 7 is a homerun release and has a lot of buzz around it.
Re:An Ode to Ruby by midrus on Tuesday January 11, 2022 @02:27AM (#29888614)
I'd also add Laravel here.

Regarding Django, my problem with it is that it is not a "full stack" framework anymore. Both Rails and Laravel provide a very good frontend solution. Rails with hotwire, etc and Laravel with livewire. Just the fact that django has no official way to compile/build assets, and the templating language is really arcane and limited for today's needs. Just compare that with Blade (Laravel's templates) which allow you to build components out of the box.

Re:An Ode to Ruby by clairity on Monday January 10, 2022 @01:39PM (#29879384)
ruby and rails is a much nicer, more complete, more consistent, and easier to learn ecosystem relative to js/node. and node is just the js server, so you need need a framework on top of it, like react/angular/vue/ember, to be equivalent. for most use cases, i really can't recommend the js-heavy route now that rails comes with hotwire (a transparent js framework for live/async html transfer, rather than json).

for authentication/authorization/security, it's great to learn by writing those from scratch, but unless you want that to be your career focus, you'd really be much better off to defer to battle-hardened libraries in those areas for any commercially-/publicly-oriented web app.

Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:40PM (#29887192)
Comparing Rails/Hotwire to plain Node or Express is apples to oranges. Try Next.js or Redwood.
Re:An Ode to Ruby by tyre on Monday January 10, 2022 @10:30AM (#29876315)
Rails is quite pleasant. There is a reason it became so popular.

I’d recommend using rails without any front-end framework initially so you understand the HTTP calls going on. Just return HTML from your controllers (classes that run specific code when you hit an endpoint.) Build up from there and you’ll get the hang of it while understanding what’s happening underneath.

Re:An Ode to Ruby by tjpnz on Monday January 10, 2022 @10:21AM (#29876172)
Definitely consider Python with FastAPI too. I got a simple API up and running in a few hours with OAuth2. Auth comes batteries included and wasn't nearly as complex as I feared.
Re:An Ode to Ruby by jebronie on Monday January 10, 2022 @02:09PM (#29879997)
When you learn Rails, you mostly just learn Rails. If you want to learn the nitty gritty details I think a different language might be better suited. I think Go strikes a nice balance between "doing everything yourself" and "just putting pieces together" If you constrain yourself to the standard library.
Re:An Ode to Ruby by ReleaseCandidat on Monday January 10, 2022 @10:51AM (#29876644)
Elixir with Phoenix and Liveview.
Re:An Ode to Ruby by Toutouxc on Monday January 10, 2022 @11:25AM (#29877206)
I'm a Rails dev at $JOB, currently flirting with Phoenix, and while I think that both Elixir and Phoenix are really solid and even quite enchanting, I don't think they're the best choice for someone's first contact with webdev. Most people are more comfortable with imperative languages and Elixir only adds to the initial friction of not knowing the proper webdev lingo and concepts.
Re:An Ode to Ruby by dnautics on Monday January 10, 2022 @02:52PM (#29880965)
> Most people are more comfortable with imperative languages

Unscientific poll with possibly a biased sample: more people find functional easier to work with. But telling, the difference is more pronounced among bootcampers and informally educated programmers than formally educated programmers https://twitter.com/DNAutics/status/1459348334007787526.

Not to mention that Elixir is basically "mostly functional but you don't have to faff around with monads or anything to do imperative".

Re:An Ode to Ruby by montblanc on Tuesday January 11, 2022 @10:14PM (#29901835)
Lol I like how you substantiated your argument with that Tweet. Looks like serious research.
Re:An Ode to Ruby by dnautics on Friday January 14, 2022 @08:19PM (#29942659)
whether or not it's serious it does call into question the parent assertion:

"Most people are more comfortable with imperative languages"

Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:31PM (#29887107)
Language elegance is not the reason Node is chosen over Ruby. Async and performance is. If I want my app to call a couple of services without using a ton of memory Node is the better option.
Re:An Ode to Ruby by charcircuit on Monday January 10, 2022 @10:45AM (#29876548)
Having tried both Node and Rails, Rails was a horrible experience. I hated every minute of it and will ignore any job listings including it. Your whole project is in a billion files and everything works by "magic." There is so much complexity and different flies that it sucks to work with. Meanwhile with Node you can start with a simple index.js and work your way up.
Re:An Ode to Ruby by troxwalt on Monday January 10, 2022 @11:22AM (#29877156)
Node and Rails aren't close to the same thing. I would think a better comparison would be Node - Sinatra.
Re:An Ode to Ruby by cutler on Monday January 10, 2022 @10:45PM (#29887242)
Even that's a bit apples to oranges. Raw Node is very low level so comparable to Rack in Ruby.
Re:An Ode to Ruby by fourseventy on Monday January 10, 2022 @12:04PM (#29877851)
So you come from the Node ecosystem and your main complain about Rails is that the project has a lot of dependencies and files? lol
Re:An Ode to Ruby by charcircuit on Monday January 10, 2022 @03:19PM (#29881593)
When you create a project it makes like 100 files that are all automatically executed somehow. Nothing really includes them, but you know it works. These files arp part of your project, but they is also a bunch of rails stuff so it blurs what is and isn't a dependency for your project.

With node projects they typically keep all of their dependency neatly under node_modules/ and you can clearly see how things are included and how things work.

Re:An Ode to Ruby by NoSorryCannot on Monday January 10, 2022 @12:49PM (#29878571)
I hear your point but the quantity of files produced by initializing a new rails project is very large, larger than an equivalent node project with server and framework. These aren't transient build artifacts either, they will live in the repo and may occasionally need attention.
Re:An Ode to Ruby by syspec on Monday January 10, 2022 @03:10PM (#29881363)
Except with node you have to roll everything yourself, so jumping between different projects is a nightmare (each one a snowflake)

Roll your own session management, auth, ORM, db migrations, html templating, CORS, cross site scripting protection, the list goes on and on.

Re:An Ode to Ruby by montblanc on Tuesday January 11, 2022 @10:15PM (#29901841)
Rails is doing a lot for you. There's no point in comparing it to something lean like Express. If you want that in Ruby use Sinatra, not Rails.
Re:An Ode to Ruby by gwright on Monday January 10, 2022 @12:08PM (#29877914)
FWIW It seems to me your comment about Rails is a more general comment re: frameworks.

Learning a language/runtime takes some effort but much less, IMHO, than learning a framework. Doesn't matter if that is Rails, Django, Ember, Angular, iOS SDK, Android SDK, React+Redux+???, and so on.

Re:An Ode to Ruby by charcircuit on Monday January 10, 2022 @03:27PM (#29881749)
I don't think so out of your list I've used the Android SDK along with a react and redux stack and I didn't get the name kind of feeling. With those you start out with a mainly clean project and everything makes more sense to me how it works.
Re:An Ode to Ruby by gwright on Monday January 10, 2022 @08:57PM (#29886209)
The Android SDK is huge. If you view learning that framework as significantly easier than learning Rails, you're a better programmer than I.
Re:An Ode to Ruby by charcircuit on Tuesday January 11, 2022 @01:42AM (#29888355)
I never said it was quick or easy. It just makes more intuitive sense in how it works. Rails has a lot of "invisible" that is stored in libraries which obscrues how it works.