Readit News logoReadit News
Posted by u/vanilla-almond 3 years ago
Ask HN: Who’s using Ruby for web development, without Ruby on Rails?
Ruby on Rails (RoR) dominates web development in Ruby. It's rich in features, but it's also a heavyweight framework.

Do you eschew RoR and use an alternative Ruby web development approach? (Example: different framework, or writing your own framework)

kyledrake · 3 years ago
I like Ruby but I don't like Rails. No idea if this is better now but I would get weird exceptions that would be from metaprogramming goofiness that was really difficult to debug and find documentation for, and it uniquely bothers me when I can't figure out where errors are coming from in code (same critique of async/nodejs). The general heaviness also just didn't mesh well with my programming style, I like things cleaner and more simple.

The Neocities frontend is basically something much simpler built on top of Sinatra and I haven't regretted that decision at all. It's (relatively) clean and simple, and if I need to do something weird that doesn't conform to the paradigm (this happens a lot), it quickly gets out of my way. You can generally do anything you want with Rails, but in my experience that more frequently involves digging through a bunch of documentation and google searches to try to figure out how to get the framework out of my way.

I've also found ruby to be a really solid language for doing lower level glue tasks, for an unusual example I use it to glue a redis database to powerdns, which serves a lot of query requests, it's plenty fast and very reliable. I've never had to rip out ruby from something more performance-oriented and replace it with something "faster".

At the same time if I had a team of 10 people I was working with I might appreciate Rails keeping everybody on the same design structure so I there's not an endless battle over how it should be put together, but in my past experience this kind of just happens with Rails too.

aliqot · 3 years ago
> The Neocities frontend is basically something much simpler built on top of Sinatra and I haven't regretted that decision at all.

Hey good job on Neocities btw.

I've noticed that a lot, and while it's not wrong to adhere to the "golden path", I take issue when it becomes instilled as rhetoric in a developer and precludes them from understanding or dignifying someone else's choices or questions when deviating from it.

There's always this aggression-of-curiosity in response, never a "well you'd do x, y, and z, but it's not recommended". It's always "Well why would you do that? That's wrong, you're supposed to..." and then an hour later after someone is red in the face just asking a question it comes down to "yeah I've never used 0mq before with rails, sorry maybe try Slack"

[edit: The comment I was originally replying to has gone from 1 sentence to a paragraph and is still receiving edits. Including this note for posterity just in case it looks like I'm talking to myself in a closet.]

syx · 3 years ago
Today I learned Neocities uses Sinatra, thanks for sharing your point of view and for the work you're doing on Neocities!
kyledrake · 3 years ago
Thanks! If you want to look at our embarrassingly bad code it's all here: https://github.com/neocities/neocities

(I'm not saying it's better than Rails, just that it's better than Rails for me.)

duffyjp · 3 years ago
Was your Rails experience quite a while ago? Stuff like the method_missing matching a regex stuff that was common years ago has basically disappeared from common use, at least in my circle.

Rails 7 has been my favorite version since 3. Version 3 was probably the peak of metaprogramming and when basically anything you tried worked which was fun but really cowboy.

Tomte · 3 years ago
Please do this:

> We’ll be doing some deep dives into our new infrastructure in the future, including discussing how we built our own anycast network

(https://blog.neocities.org/blog/2017/03/26/huge-space-increa...)

Alifatisk · 3 years ago
> I've also found ruby to be a really solid language for doing lower level glue tasks

This!!! I can't express this enough, Ruby is the sweet spot for gluing things togheter and rapid prototyping.

TigerTeamX · 3 years ago
This sounds like my experience with Django... After 5 years I still haven't mastered it and it still continuous make me think why is this so complicated.
WJW · 3 years ago
I see a fair amount of companies writing internal services in sinatra/hanami/etc and using Rails for user-facing routes. The smaller frameworks are great but as soon as you hook up an ORM, user session management, conditional view rendering for different clients, background jobs, caches and all the rest then you often end up with a worse Rails. If you have a service that you know upfront will need not need that then the simpler frameworks are a much better choice.
davidthewatson · 3 years ago
I worked with a four person startup tech team that shipped a production rails system in six months based on a python/flask/mongo prototype that I demoed in a week a decade ago that is still being used and sold today, though I'm not sure of its technical evolution.

I've built a few Sinatra/Flask systems since, so I'm definitely a fan of the virtue of simplicity, no matter the language.

The design mistake here is not applying lessons learned reading Danny Greenfeld's book (which I don't believe shipped before 2012) on Django and realizing the chapter on "vanilla Django" applies just as much to any system, like "vanilla Rails", because they are the same "stranger in a strange land" problems where the system as we know it becomes undocumented and unbounded by architectural style - a kind of McMansion Hell for system design.

The use of DSLs is complex territory. When in the hands of a master, amazing work can happen, but when too many DSLs are combined together, you wind up with exactly the opposite of what Greenfeld described in the chapter on vanilla Django, you wind up with byzantine Rails, because the boundaries that Alan Kay described decades earlier are not architectural. As with much software, there is no physics, real or implied, that applies to the phenomenological understanding of the system, the individual and social human scaling of brains that turns out to be a larger problem than computer hardware and software scaling.

There is a semantic asymptote, if you will, where the problem leaves the empirical world and becomes phenomenological - very difficult to share socially unless you are Kay, Knuth, or one of their contemporaries.

thunderbong · 3 years ago
I've been on the Roda [0] and Sequel [1] framework for over 10 years now across various projects. Even after all these years, starting a project in this stack feels like a breath of fresh air even compared to the newer language/frameworks that jabe come out since.

Jeremy Evans is the creator and maintainer of both of these Ruby gems and is super helpful in resolving ask kinda of issues.

[0]: https://roda.jeremyevans.net/

[1]: https://sequel.jeremyevans.net/

veesahni · 3 years ago
We[0] use Ruby without Rails - Sinatra for the most part.

I started the codebase over a decade ago now, and at the time Rails felt a little heavy (inline with your comments). That said, Rails does let you get started pretty quickly without needing much of anything else.

Rails has more magic. If you prefer less magic, then Sinatra is the way.

0: https://www.enchant.com

Alifatisk · 3 years ago
I wouldn't say there is anything "magical" if you follow Rails conventions

See https://richstone.io/why-do-we-call-it-ruby-and-rails-magic/

quest88 · 3 years ago
What do you mean by "heavyweight"? Also why is it a problem that something is "heavyweight"?

What problem are you trying to solve by asking these questions? What context is this question for? Are you curious how many people use a non-rails solutions for enterprise apps? Cloud apps? Personal projects? Apps you want users to pay for? A blog?

I'd suggest stating what problem you'd like to solve by asking this question so you can receive more detailed feedback. For example, if your company is spinning up a new app and you're evaluating choices, someone may respond that they used sinatra but found themselves reinventing rails so they wish they would have used rails. I'd say this is more insightful than "yea, we use sinatra". Alternatively, maybe someone used sinatra for a personal project and found the experience of reinventing rails rewarding and educational on their own time. Let us help you!

aliqot · 3 years ago
If I were the person asking the question- I'd get frustrated by this answer. Nothing against you, the response is accurate, sufficient, and true, but woo I was subconsciously leaning forward and covering my mouth while reading.
quest88 · 3 years ago
Why's that? Given the original question people can simply reply "me", but I assume they're looking for more than that.
capableweb · 3 years ago
> What do you mean by "heavyweight"?

Rails latest release (7.0.4) have 386,970 lines of code in total, 310,779 of it being Ruby code. 3000 files in total. Just the `lib` directory of `activerecord` has 33,036 lines of code, across 369 files.

By most metrics, RoR is pretty heavyweight, as their literal taglines are "Ruby on Rails scales from HELLO WORLD to IPO" and "A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern", so it needs to be pretty big to support those use cases.

Full `cloc` report in case someone is curious:

        4268 text files.
        3839 unique files.
         511 files ignored.
    
    github.com/AlDanial/cloc v 1.96  T=1.25 s (3079.1 files/s, 434339.6 lines/s)
    -------------------------------------------------------------------------------
    Language                     files          blank        comment           code
    -------------------------------------------------------------------------------
    Ruby                          3013          73152          54669         310779
    Markdown                        92          19324            388          45525
    JavaScript                      87           2974           2170          20955
    YAML                           171            406            350           3679
    CSS                             23            347            152           2409
    ERB                            386            303              9           2244
    CoffeeScript                    12             97            125            413
    JSON                            11              7              0            372
    HTML                            21             15              3            200
    Bourne Shell                     2             20             25            167
    Text                             7              0              0             51
    yacc                             1              4              0             46
    SQL                              1              6              0             43
    Dockerfile                       1              7              7             40
    SVG                              7              0              1             36
    builder                          3              1              0             10
    DTD                              1              0              0              1
    -------------------------------------------------------------------------------
    SUM:                          3839          96663          57899         386970
    -------------------------------------------------------------------------------

BilalBudhani · 3 years ago
> By most metrics, RoR is pretty heavyweight, as their literal taglines are "Ruby on Rails scales from HELLO WORLD to IPO" and "A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern", so it needs to be pretty big to support those use cases.

Not sure what do you mean by "most metrics". Framework supporting features is not same as they being used all at once in every app.

PostgreSQL has more than 1.3M lines of code and it gets used by projects of all sizes, would you call it "heavyweight" too?

TheRealDunkirk · 3 years ago
Compared to what? How about Django or Laravel?

And does ANYONE here want to compare Rails with the standard "enterprise" stack of Java and React, and all their implied dependencies (Spring, Lombok, etm.)?

quest88 · 3 years ago
I don't know why something with many LOC is a problem. Why does OP care about LOC?
1123581321 · 3 years ago
The question was obviously in reference to something like Sinatra or Hanami, or simply using individual gems.
hk1337 · 3 years ago
> Also why is it a problem that something is "heavyweight"?

One issue I could think of when a framework dominates a language is that it could steer changes in that language that benefit itself more than the language.

juanse · 3 years ago
I am a solopreneur with Smart Kiosks running on Raspberry pi.

The whole service (which isn't too complex) is a file script in Ruby managed through SystemD. This script turns off/on the screen based on API calls, and is also in charge of scheduled/remote restarts, pinging the backend and stuff like that.

What I like the most is how easy and reliable is. Beeing a below average guy, ruby makes really easy to combine system calls, API calls and shell commands within the same context.

cortesoft · 3 years ago
We have a lot of internal APIs written using Sinatra.

I first started writing my APIs using Sinatra about 10 years ago. I had started with Rails when it first came out around 2005, liked it, but then ran up against a lot of issues. Sinatra and the Sequel gem were amazing so I switched to that, since I didn’t need most of what Rails had.

Now I just use those two out of habit. Rails is a LOT better now, but i still just reach for Sinatra and Sequel usually.

yamtaddle · 3 years ago
Sinatra + Sequel is the only way I've ever loved using Ruby for Web development. After extensive contact with Rails across several projects, I've... concluded I simply cannot enjoy using it, is a nice way to put it, I guess. Sinatra + Sequel is a delight, though.
hk1337 · 3 years ago
I really like Sinatra but a lot of the Rails improvements kind of took away some of the benefits of using Sinatra over Rails.
cortesoft · 3 years ago
I believe it. I keep reading about Rails improvements but haven’t really tried it in anger in a long time.

I started with Rails when migrations were just .sql files you wrote by hand. I switched to Sinatra mostly to use Sequel, because ActiveRecord at the time would do horrible queries unless you wrote them by hand. I know they have solved that issue, so I should try Rails again… but my Sequel muscle memory is pretty strong at this point.

LanceH · 3 years ago
I see a good bit of Sinatra out there in the wild for exactly this -- API only services. I even see it in shops that are running Rails everywhere else.

It does seem to be much more the exception than the rule. But it may be getting more common with kubernetes deployments which make lots of individual services a bit easier to manage.