7 ms·
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)
- orangeplus 4y agoChef rules everything around me
- aliqot 4y agoget the money
- bradgessler 4y agoI went the opposite direction and built a static site generator on top of Rails: https://sitepress.cc/ https://sitepress.cc/ Turns out, Rails is a really good web framework! I tried building Sitepress on something “light weight”, Tilt and Rack, and it was a pain. I found myself constantly solving the same problems that were already solved in Rails. At some point it dawned on me that I could just build on top of a few parts of Rails, so I did. I wrote about it at https://fly.io/ruby-dispatch/single-file-rails-app/ https://fly.io/ruby-dispatch/single-file-rails-app/ I’m glad I did! Now I can plug all of the Rails template handlers, view components, and other Rails plugins into it and ride off that entire community’s docs. If you find yourself thinking, “rails is too heavy”, consider shedding the parts of Rails that you don’t need. Then as your application grows in complexity and you find yourself needing more parts of Rails, bring it back in.
- dorianmariefr 4y agoStripe uses Ruby without Rails
- multiplegeorges 4y agoCame to post this. I would bet that Stripe is the large non-Rails Ruby user in the world?
- dorcus_maximus 4y agoI've been a Rubyist for over ten years. I've never built using Rails. I've been stuck with Ramaze because of decisions that were made long ago. Betting I'm the only person here using Ramaze...Plan to convert to something else, probably Sinatra but not Rails, if I'm ever given the bandwidth.
- cortesoft 4y agoWe 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.
- LanceH 4y agoI 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.
- hk1337 4y agoI really like Sinatra but a lot of the Rails improvements kind of took away some of the benefits of using Sinatra over Rails.
- cortesoft 4y agoI 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.
- hk1337 4y agoIt's not just Sinatra. Devise, AFAIK, has been a staple for authentication and authorization and rails (or at least in blog posts it has) and in Rails 7 it seemed like it complicated things more than helped and I can do all the secure handling pretty easily in Rails.
- notwedtm 4y agoSinatra is my go to for barebones pages-style server side rendering.
- brightball 4y agoA lot of people use Sinatra for this type of thing.
- quest88 4y agoWhat 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 4y agoIf 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.
- capableweb 4y 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 -------------------------------------------------------------------------------
- huimang 4y agoThere's Sinatra for more barebones things, but honestly, homegrown solutions always grow into a shittier version of Rails. You don't have to use all of the features Rails provides. As others have mentioned, for simple APIs Sinatra is fine.
- fknorangesite 4y ago> homegrown solutions always grow into a shittier version of Rails. An old joke: any sufficiently advanced Sinatra app is indistinguishable from Rails.
- chucke 4y ago> You don't have to use all of the features Rails provides. You kind of do. First, you have to opt-out, not opt-in. And the opt-out path is less battle-tested, so there's a lot of skeletons to be found there. Use it at your own risk. If you want the best modern example of a ruby framework which starts small (like sinatra) but allows you to opt into a wider feature-set (like rails), you should give roda a look: https://www.youtube.com/watch?v=9fukis_VHl4 https://www.youtube.com/watch?v=9fukis_VHl4
- drchiu 4y agoRuby is pretty good for writing scripts to run in the terminal. For things where I need to do a bunch of string manipulations, I prefer it over something like creating a shell script.
- TheRealDunkirk 4y agoYes! No more bash, sed, and awk, or Perl.
- revscat 4y agoSame. I’ve moved a lot of my personal scripts from zsh/bash to Ruby, and they’re so much easier for me to reason about now — or six months in the future when I’ve forgotten what exactly they do.
- caseyf 4y agoIt completely replaced Perl for me
- whalesalad 4y agoThere aren’t many compelling reasons to choose ruby without rails, for a greenhorn project. unless you already have a big pool of devs who know and enjoy ruby, and/or a lot of home grown gems/libraries.
- BirAdam 4y agoI’ve done some simple CGI stuff in Ruby before. Those are normally for ephemeral tasks tho, not anything intended to be used long term.
- kyledrake 4y agoI 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 4y 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.]
- wintorez 4y agoMonitoring this to see who will mention Hanami
- hanamimastery 4y agoMe!
- wintorez 4y ago<3
- hanamimastery 4y agoI solely use Hanami since 1.5 year, and I had never looked back! It provides everything needed, while still allowing to fully control which features I want to disable.
- thinking001001 4y agoBeen a few years since I tried Rails (I don't do much web development), but seriously considering giving it another try. I do wonder if a "Lite" version of Rails could happen somehow - DHH was talking about JSON APIs in his latest blog post, and indeed they are more no-ops than an SQL database. I have tried Ruby CGI but very barebones - no MVC. I haven't tried Sinatra, but someone at a Ruby web development company told me Sinatra works for APIs but difficult for websites, but it isn't battle-tested like Rails.
- Alifatisk 4y agoHave you seen Hanami 2?
- syx 4y agoyet another comment about Sinatra, I've been using it for 10 years, first on heroku now on fly.io. It's such a great and stable framework, most people probably don't even need RoR.
- rubyist5eva 4y agoWe have a Rails monolith with a couple internal Sinatra services if that counts. To be honest, I love working with Sinatra and Sequel (when using an ORM) vs. working with Rails and ActiveRecord. We provide public apis via. Grape, but that's mounted as an engine inside our monolith vs. deploying our own Grape application on Rack just for operational simplicity.
- veesahni 4y agoWe[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 https://www.enchant.com
- Alifatisk 4y agoI 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/ https://richstone.io/why-do-we-call-it-ruby-and-rails-magic/
- aidog 4y agoMade my "own" static page generator using chatgpt recently: kramdown for markdown, erb for layout, filewatcher to reprocess on file changes, rss and sitemap. docker-compose file with nginx pointed at the out directory. Deploying with git. Works great.
- WJW 4y agoI 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.
- bitwize 4y agoI work at a medical analytics company that uses Ruby + Sinatra. Our product is a "real" application that allows for sophisticated reporting drawing from huge data sets. No Rails is involved.
- RickHull 4y agohttps://socketry.github.io/falcon/ https://socketry.github.io/falcon/ looks pretty nice but I haven't used it anger yet. Async fibers FTW. I have a small project to explore the various multitasking paradigms in Ruby, here: https://github.com/rickhull/miner_mover https://github.com/rickhull/miner_mover
- juanse 4y agoI 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.
- thunderbong 4y agoI'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/ https://roda.jeremyevans.net/ [1]: https://sequel.jeremyevans.net/ https://sequel.jeremyevans.net/
- ksherlock 4y agoI've used ruby/sinatra/passenger/nginx for a few projects -- html/preact/javascript front-end calling into the ruby backend. Sometimes python/flask instead of ruby/sinatra.
- quechimba 4y agoI've been working on a framework for a while. It's a server side VDOM that streams updates to a small JS runtime. Components are written in Haml. https://github.com/mayu-live/framework https://github.com/mayu-live/framework
- Alifatisk 4y agoThat's so cool! Makes me happy seeing HTTP/2 being suppport as well.
- quechimba 4y agoThank you! HTTP/2 is great. It's really convenient to have one connection per client.
- Alifatisk 4y agoAny thoughts or plans about HTTP/3 in Ruby? I've been searching around and it's dead silent within the community, only seen a presentation about implementing QUIC in Ruby using Ractors but nothing more.
- quechimba 4y agoSorry, I just saw this now! I don't know anything about HTTP/3 in Ruby, or at all actually. I'm using the async-http gem for the HTTP/2 server and it works great for my use case.
- davidthewatson 4y agoI 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.
- mxhoncharov 4y agoI haven't touch Rails in production for more than 3 years now. My main stack is roda+sequel+rspec+aws and it's awesome. It gives me a ton of flexibility because I'm not limited with common approaches and I can add any tools I want and implement any solutions I feel might be better. My stack is only a part of global world of gems. Anytime we can make own tools with our vision and it's amazing.
- Alifatisk 4y agoI see people mentioning Sinatra a lot, do you write everything from scratch or is there a scaffolding tool? I've used Sinatra plenty of times but only used as a backend api, no frontend rendering.