Rails 7.1 Released
github.com
github.com
I'm truly amazed how much simpler things are. I feel sad most of us have forgotten how easier things could be, and I'm terrified about new people joining this industry that will never know about how easier things could be because they'll never experience that (as things are right now, who knows the future...).
If you're reading this and never tried Rails, or discarded it because you listened somebody say the usual "PHP is ugly/Rails is dead/JavaScript is messy" give it a try with an open mind and ignore what others say for a moment. I can't recommend it enough.
It might not be the best tool if you have 1k engineers working on the same repository, but as a small team it has no competitors, it's just miles ahead everything else (well, honestly, maybe Laravel is as good).
Rails wins every battle for initial development speed, as the conventions are so thorough and well thought out that nothing even remotely comes close. Laravel is creeping in, but it's not there yet IMO.
LiveView however, scales better (in every sense of the word). It also comes with batteries included (auth, database access, jobs, mailer, complete testing kit etc), little-to-no-DIY-JS, and one of the finest VMs there is (BEAM).
If nothing else, I'm happy that these projects all fight the "let's take a step back"-fight. At $DAYJOB I write React with Relay and the amount of hoops one needs to jump through is exhausting, even though I've been writing frontend JS for many years now and consider myself half decent in it.
At a glance it's hard to see the value or believe that it has the same longevity or $$$ value.
In terms of $$$ value, it is extremely efficient --including all the "alien" stuff, and that's why it's so cool. An Elixir team will generally create things cheaper to build and operate.
Now, the question is how many Elixir shops you are going to find a job with, but the answer to that depends on the type of career trajectory you are choosing. For example, Rails is not an industry standard by any means if you think in terms of classic IT consulting jobs but has a stronger dev mindshare in startups, so there you go.
Personally, I'm comfortable betting my career on Elixir at the moment. It's too goddamn good to remain a niche language - I expect it to get a lot bigger in the years ahead as more companies and devs fall in love with it. It'll happen slowly, and it's never going to reach the level of saturation that that, say, Javascript has, but I think it has a bright future.
Phoenix and LiveView are a joy to work with, much more so than any previous technology I've used. I haven't yet looked at any of the exciting new ML stuff that's happening in the Elixir world (Nx etc.) but hopefully they'll drive adoption too. I'm never going back to my old ways.
(And of the two, I'm more productive in Phoenix, but I didn't mention that in the comment you're replying to.)
(I think the only way to join the Slack atm is to be manually invited because the signup app got broken by Heroku's pricing changes - but if you email the address in my profile then I'll ask someone to invite you.)
It saddens me that ruby, python, elixir, JS... many of the best and most productive backend frameworks have types as an afterthought only.
Rust is cool, but it's also hard to write(did last year's AoC using it, and it was fast to run, slow to write).
Anyone have any recommendations for me? Should I look at go/gin perhaps? No Java please - I need type inference because I'm a spoiled baby.
Edit: anyone tried crystal? Looks promising, but doesn't seem popular...
Could you elaborate on this?
The project structure of a Rails project is fixed and it's easy to jump into somebody's else project. The structure of a Django project is potentially pure anarchy, good luck with that.
That's mitigated by the lack of autoloading so you can learn the structure of the project by looking at the import statements at the top of the files. Unfortunately that means that you have to waste time by writing those imports. I hated that in Java even if the inevitable Java IDE added them for me.
The ORMs are more or less equivalent. I have a dislike for having to actually type the default scope (not the Django term) in Django as in
Model.objects.filter(...)
when Rails lets me type Model.where(...)
The real time waster is the templating language which in Rails is basically Ruby and in Django is not Python. It's something else much less powerful so you have to either prepare all the data in the controller (which is called a view in Django) exactly as they'll be displayed in the page, or write a templatetag and use it to transform the data inside the page. That loses an unbelievable amount of time. If I count the cumulative hours, days, weeks spent at writing templatetags instead of a couple of Python statements I don't know whether to thank Django developers for the easy money or to roll my eyes because that time is useless.To recap, Django wastes developer time. It's death by a thousand cuts. I'll never use it for one of my personal free time projects.
Edit: don't be too smart in Rails, that is don't build too much magic and waste the time of the next developer into a quest for finding where something really happens. Write straightforward code and if some method name is created automatically, put a comment hinting at the source.
But yeah, if I had an option I'd prefer things to be more explicit.
When you find yourself interacting with the magic parts, it is imperative that you comment what is going on so the next dev, which will probably be you, isn't also surprised.
Great point around project structure and ability to move between codebases - I think the lack of enforced structure in Django absolutely helps increase codebase entropy over time.
Django has support for Jinja templates so you could just use that and call methods in your templates, which negates the need for most template tags.
Although its been a while, I do remember struggling a lot with autoloading in rails for two reasons: you can't find your dependencies from the code itself and when it breaks down its quite hard to debug. Maybe things are better now with rails and when you get really proficient you know how to find where things are - however that increase the learning curve which is supposed to be a benefit with rails. With django, I can generally look at the imports to see what this module is using. With the help of the right tools I can:
- 'go to definition' of any symbol and 99% of the time land in the source, even of django itself - automatically add imports so you don't have to write them - automatically sort and format imports and see the unused ones
With the optional static typing that is being greatly improved with recent releases, things get even easier.
I prefer this a lot above the rails 'magic', for me it is a huge time saver because my memory is not so good, there is minimal friction moving around between code and is various dependencies to see exactly how its done. With rails I'm more often looking at the docs (not so great) or examples, with django I'm most of the time looking at the source code itself or running the shell (which is very, very good).
> Model.objects.filter(...)
Its called a manager. I understand you don't like to type 'objects', it fits in the rails culture of being allergic to redundancy, though I can't really empathize with it.
> The real time waster is the templating language which in Rails is basically Ruby and in Django is not Python.
I hate both but prefer the django template language. I'm surprised this is such a time waster for you. I think its good practice to not put too much logic in the templates so the division of labor in django is much better imo. But then again, I'm not a good frontend person and have problems with the deeply nested structures in html. Everything can help me simplify the template is a huge timesaver for me, bugs in the frontend code are terribly annoying. Honestly I hate frontend.
> Its called a manager. I understand you don't like to type 'objects', it fits in the rails culture of being allergic to redundancy, though I can't really empathize with it.
The point it that the objects method adds zero information to the statement. However it's an opportunity to add a soon to be discovered bug when Django crashes because one forgets to type .objects
They should have made filter a method of all model classes and of the models.Manager class. Same thing for all its sibling methods.
This is time well spent in my opinion. Everyone, including future you, benefit from it.
One of my biggest gripes in Rails is not being able to do this.
The frontend situation in Django is terribly outdated. Just the templating system is the worst thing I've ever seen, and it doesn't even have an asset pipeline.
Rails has pretty good code generation. If I want just want to get started and add a birthday field to the settings page, I can run a short one sentence command and it will go off: it will know how to do schema migration, routing, views, controller, etc. This is possible because everything is so straightfoward and consistent. I'm not saying generators are a good way to write your code, its just one example of how rails has very a high level of abstractions.
Django however has the admin. Once you have a model, it will generate a fully functional cms for it and its very tweakable. For a lot of businesses, the admin is quite servicable as a cms or administation tool, and it is a _huge_ timesaver.
I generally prefer django over rails, it just seems all much more explicit and easier to discover to me, however I do agree you can be a lot faster with rails once you learn how things fit together.
Rails has the optional ActiveAdmin gem but it has basically no automatic integration with the Rails app and it's not included. That means that any Django app has a basic admin and most Rails app don't have one.
To be fair, it's easy to hit the limits of those admins but by baking a user hierarchy in the main web app with a super user, you can use the standard web app for many administration tasks. If you can impersonate users (handy for debugging and you have all their data anyway) you can do a lot of things without an admin interface.
Architecture-wise I really like the ember-data approach because it allows a lot of automations when it comes to left join/right joins of datasets, with an integrated mockup server etc.
But it's not as cool as the other ones I guess, because it just works too well enough!?
As I said in my previous post, it's a framework based on conventions, so it'd a batteries-included approach to both frontend and backend.
[1] https://emberobserver.com/categories/ember-data-adapters
I’m thinking of building a side project with Rails and I’m wondering if they are worth it?
I would say that's a success for having an easy upgrade path. Now the fun part is going back to refactor some of the code to use the new features in 7.1.
If anyone is curious, I updated my Rails / Docker example app to use 7.1 too https://github.com/nickjj/docker-rails-example. Even though Rails 7.1 comes with a Dockerfile, there's still a lot of opinions you can add such as using Docker Compose to have a fully working out of the box experience that works in development and production -- complete with Postgres, Redis, Action Cable, Sidekiq and more.
Rails is great when you stick with the defaults and a land of pain as soon as you leave them.
Maybe it's just me but I just don't like DHH's governance lately. Not in a bad way, but following him on Twitter I just no longer respect him.
1. all data flow through the rails app (no pre-signed s3 upload or download links for direct uploading).
2. no support for CDNs (I think newer rails versions added support)
3. blobs and attachments were unnecessary abstractions.
3a. Querying was annoying (extra joins) and easy to add n+1 queries.
3b. In my app, images are moderated and it was unclear where to put the moderation metadata (on blobs? attachments? create a new table? why so many tables?) or `deleted_at` type columns.
4. GraphQL gem didn't support it: https://github.com/rmosolgo/graphql-ruby/issues/1777
2. What do you mean? Point whatever CDN you want at your origin
3. Maybe
3a. Yes
3b. Metadata or a new table
4. GraphQL is the single worst technology that has ever been adopted. We adopted at my company...twice. Twice we made the same mistake now we're stuck with it for mobile clients. In fact we're stuck on the old Graqphl RB gem that used a DSL instead of classes, which also blocks our Rails upgrade. We've been able to revert everything back to good ole Rest for another part of the app. Be cautious adopting technologies of large companies.
2. CDN support is via monkey patch: https://github.com/rails/rails/issues/44136
3. yep
4. yep
It's not really governance, that's kinda the problem. To be fair, he never claimed that he was providing governance. Rails was extracted from basecamp. The impression I get is that he sees Rails as a gift to the community created from the profit-making Basecamp. Which is great; and I appreciate the fact that I've been able to build a career using Rails.
But there is no governance really. Rails goes in the direction that 37signals wants it to, which is largely pretty good. You and I don't get much of a say in it though; especially if DHH disagrees.
- if you're looking to hire frontend engineers, the candidate pool for React is a few orders or magnitude bigger
- it's getting harder and harder to find vanilla JS packages that you can wrap in Stimulus controllers for common tasks, compared to finding React packages
- Stimulus doesn't really offer a way to write unit tests for your controllers. With React, you can use jest and react-test-renderer like normal.
Additionally, the recent Turbo TypeScript debacle did not instill confidence in the long term stewardship of the Hotwire ecosystem.
We're still on the fence about it. Stimulus does feel like a very Railsy way to write frontend code, which is definitely a plus for small teams of people who're already familiar with Rails.
And the state library, and the hooks for side effects, and the SSR, and the hydration, and the VDOM, and... It's not that simple.
For all its flaws, React is still extremely "small" as far as front end and server side front end goes.
That might change with the increased push towards next.js and SSR though.
Can't these candidates quickly learn Hotwire? Seems like its much simpler than React (less moving parts)
In short, it's probably better for your career to work on React.
What I don't get is why as an owner/stakeholder/CTO/lead would pick the worse tool (in some context) just because everyone is using it. Well, I do get it... I just don't agree.
If you read between the lines here, everyone is just picking React because everyone else is picking React, that's the only reason apparently. It drives me mad, but honestly I do understand it.
But I would be tempted to go react and inertia js for MUI or EUI for the predesinged components and nice datagrids.
Main issue I've seen is Rails shops don't hire devs without Rails experience, or expect you to interview well with backend OOP type code.
I guess that's okay for someone wanting to get away from frontend and be "full stack", but it's not for a lot of people.
> if you're looking to hire frontend engineers, the candidate pool for React
While this is true, I think you will also need less people to achieve the same, the amount of work is incredibly less. So maybe finding one or two developers with an open enough mind and a good salary will provide even more value than a full team of backend devs + a full team of frontend devs + all the coordination efforts.
> - it's getting harder and harder to find vanilla JS packages that you can wrap in Stimulus controllers for common tasks, compared to finding React packages
Any example of this? I don’t find this to be the case, given that any “vanilla” library will work out of the box and many of the react packages are there to solve react creates problems.
> Stimulus doesn't really offer a way to write unit tests for your controllers. With React, you can use jest and react-test-renderer like
This might be controversial, but I don’t find testing UI with unit tests useful at all. Tools such as cypress provide a lot more value for the effort it takes to write and maintain, and those tools work with any underlying implementation. Mocking browser APIs is not fun at all.
Regarding typescript, I honestly just don’t get the drama. It’s just a tool. If it solves a problem for you use it, if you don’t, don’t use it. And you can’t force others to use the tool you like the most.
Also, given how these tools work (mostly with data attributes and in the fly generated methods from those data attributes) I’m not convinced typescript or not will make any noticeable difference as the user of the library.
At the end of the day it’s all trade offs. But something I can guarantee is that going the React way is a ton more work, decisions, maintenance, people and headaches. If your app/project really requires react then you’ll have to bite the bullet and go for it. What’s sad to me is going with react just because everyone uses it.
But doing things that way means nearly every fronted dev can work with their favourite patterns and frameworks. I love that they can debate replacing create-react-app and i do not have to care beyond saying "as long you meet the openapi spec". Moreover, everything you've described along with most of what has changed recently in the ecosystem goes away. I don't have to care what is happening to hotwire, or the asset pipeline in general or around scss gems being deprecated.
And this is a big problem in my opinion. We should decide the stack that better solves the problem, and then hire people that are happy to work with that, not the other way around.
It's like saying you're in the business of putting screws into walls, but you do it always with hammers because most people like to use hammers.
The trick is not to look for React developers, or Stimulus developers, but to look for frontend developers. Those who can competently write javascript/typescript, have a good understanding of browser apis, and are competent in css and html.
Maybe I'm biased but I feel like rails + stimulus makes it incredibly easy for anybody with any kind of programming background to grok the entire project, and maybe you can reconsider even even having dedicated "frontend developers" at all. I know that specialization is a thing, but it's just so easy to be a "full stack" developer on such an app that I think almost anybody could pick it up.
Two comments on this - I know it will not change your mind, but maybe other people will read this:
1. Of course, the candidate pool for React is bigger, I think Hotwired - in its current form was released in 2021 (November or December). So this expectation is kinda “Planning to fail” right? If you put this as a criteria of course you are going to choose React. Are you sure you are not already decided to use React and then found reasons for the decision. It is totally fine if you did as we are all doing this constantly (first deciding and then finding reasons or explanations for the decision)
2. I think if you have a React developer (so a person who should know JS and HTML) who cannot write Hotwire code, that is a big problem. Anyone with a good foundation of JS and HTML should be able to write Hotwire code (Stimulus + Turbo)
Recommendation: Don't put in your job ad "Required skill: Hotwired". Just hire people who understand how the web works (browser + HTML ...) and they will be able to write Hotwire-compliant code.
> it's getting harder and harder to find vanilla JS packages that you can wrap in Stimulus controllers for common tasks, compared to finding React packages
I am not sure what packages are you trying to find. But I would suggest if you are trying to find an 1-on-1 corresponding React package to Stimulus package the way the UI and UX is designed is not for Hotwire. You should not choose Hotwire to replace React but keep the same page behaviour. You should think your UX web experience different - more back to basics with interactivity sprinkled around
> Stimulus doesn't really offer a way to write unit tests for your controllers
Again if you have an application like say Figma UI then probably you need unit tests. But if you think the UX to be Rails 7 + Hotwire, you will not write so much JS code that you need unit tests for it.
Testing an end-to-end feature should be enough.
Of course, this is just me talking about a product (yours) that I don't know what it is an I am making so many assumptions.
I either do SSR with slim or do API only with a separate frontend.
Rails changed direction too many times trying to do JS (coffee script, asset precompiling, webpack, etc)
There's also SSR with react and other js frameworks, but I don't think that's what they meant.
n.b., I've been building Rails apps since 2007. I was a diehard Haml user up until about 2021 when I made an all-in bet on Tailwind and had to switch back to ERB because Haml with Tailwind felt too obtuse.
The only downside is I am now spoiled.
You can of course just drop to `markdown:`.
Still, I use it where I can on personal stuff, but tend to opt for Erb when collaboration with others is needed.
Rails 5 & 6 were rough, you forgot yarn! That was my biggest pain point. I still have Coffeescript code, we have been slowly converting as needed.
Rails 7 has been a lot better to deal with, we use vanilla JavaScript (outside the coffeescript lol). Makes it pretty easy tbh. We load partials as needed (via js) and the site is fast and light.
My recommendation is to stick close to html with rails or as mentioned, a separate front end. What we have works super well for us, but definitely custom
You just described every framework. Frameworks are great if your application is fairly simple and aligns with its way of doing things. Libraries are where to look if you need a more complex, flexible setup.
As a result, projects are frozen in time because everyone's afraid of touching anything, less it triggers Armageddon.
Maybe AI can help? Instead of copilot writing new code, or chat systems explaining a couple of lines, there could be an app that ingests a huge code base at once (spanning multiple languages and subsystems) and
- explains what each part does
- is able to spot potential side effects for each new addition
- suggests simpler ways of doing things / nice refactoring
There are some startups trying to address this but none seems to be there yet (I think); the market is huge though and people would pay through the nose for this.
1. Longevity of Engineers: Attrition is a killer from a knowledge perspective. Teams that keep their engineers have healthier systems
2. Avoid Over Abstraction: Simple understandable code is easier to maintain. Too many mid level engineers go overboard with abstraction and bad abstraction is worse than no abstraction.
3. Choose tech that is likely to be well maintained decades later. It's better to pick tech that will be well maintained than to pick tech that is better in some way but more obscure and more likely to poorly maintained in decades.
The fix for this is pretty easy though. Keep employees and avoid the churn.
The usual explanation is inversion of control—you call into a library, but a framework calls you. But now that pretty much every language has closures, it's a lot harder to use that as a distinction: is React a library since it all starts with createRoot/render (you called it), or is it a framework because from that point on it's calling you? There are tons of people who are highly opinionated in both directions, which suggests that this dichotomy is artificial and doesn't reflect a deeper reality.
If doing things exactly the way you envision involves building the world from scratch, it's often better business to go with a "less elegant" solution that can be rapidly pieced together from mainly ready-made components.
I've often earned long-lasting trust and cooperation of clients by asking whether they would like to adjust (or forego entirely) that one feature, if the project ended up being 20 or more % cheaper/faster to deliver. And given that choice, it's surprising how flexible businesses can be.
That’s only because this can turn into a real rabbit hole in my experience. But at that size maybe it won’t be so bad.
Best of luck!
Yeah, that is one way of phrasing it. Another way to phrase it is that Amazon took it over, turned it into an ingestion funnel to their book store, and has done as little as possible after that.
The Goodreads dev said "the site was originally built as a giant pile of Rails spaghetti with views mixed with business logic and such and then a fuck ton of weird features built and left to sit there". I'm not sure why you think that is or ever was "the Rails way", but it seems more like the classic "move fast and break stuff" startup engineering than anything resembling rails to me.
Here is a competitor build with Rails https://thestorygraph.com/
Seems kinda cool. So I think Rails is not the problem here.
The youngins always learn the hard way.
The field is extremely diverse these days, and tools that are appropriate for small data science teams may not work as well in enormous monorepos maintained by thousands of developers (and vice versa). What's missing from most discussions of static/dynamic typing is context—each career is unique and what projects you've worked on will have a huge impact on your perception of which is preferable.
Given different parameters, I'm sure the decisions would be different as well.
For writing an application or something that actually require design and libraries? Why bother? You need to be meticulous anyway, why not be meticulous in code?
The focus for me is on the tools and frameworks, not the underlying language. Show me a Typescript-based or Go-based language that can go from zero to production as fast as Rails with the same-sized team with no productivity loss, and I'd happily use it.
It was almost a drop in replacement for webpack for me
FWIW the Rails 7+ way of doing single page app JS is also more reasonable than it used to be. You pretty much just use whatever build tool you want in isolation from your rails app. You have to run something like `yarn build --watch` alongside `rails s` in development but IMO that's not so bad and makes things a lot simpler.
My company builds software to automate Rails upgrades, and offers a full service where we'll upgrade Rails for you. steve (at) infield.ai if that's interesting or you can generate a free rails upgrade plan at https://app.infield.ai/users/sign_up (no cc required). https://docs.infield.ai/docs/creating-an-upgrade-path for some more details.
It's a really good framework, and for someone like me who needs to stand up a website from time to time it really is the path of least resistance.
What bugs me is the pain of setting up a new laptop to run Rails. I need node, which means npm. I'm a backend guy, I don't understand how to set up node, what order to do things in, etc. I do it rarely enough that it always seems a fight. Eventually I get it done, but I'm never sure why it finally all comes together.
An installer that puts together all the requirements so my rails just works would be great. The rvm installer will set up rails on top of ruby but won't set up the node system underneath it.
Other typical back ends are more complicated (except Go) Java, C#, Python for example
Python is a disaster.
dotnet new webapp - for crud
dotnet new react - using react
How is that complicated?
Also it's fairly easy to install node. Too easy in fact. I wish it was much harder, and required a degree.
Eventually only one person can get it working so I suppose it’s job security so perhaps it’s not so bad
That’s for every framework though, Rails isn’t that bad, relatively
I understand that Node is mostly known as a frontend tool and Rails uses it for that, but as far as I remember Node was as least initially developed to bring JavaScript runtime to backends.
Even without a package manager node is just a node.exe under Windows, and I think you just have to download and unpack npm and then put node and npm into your PATH environment variable.
JavaScript is just a tool, like any other. And it's a very important one like it or not. And like it or not it's going to stay here for a long time.
Just have a bit of an open mind and try to learn the basics at least, it will make things easier.
My last sentence on the parent message was directed to the comment I was replying to (which said they couldn't set up node properly).
What I do think is that there's a huge % of Rails devs that hate on JavaScript as if it were some kind of enemy to beat or something, and often that leads to people not wanting to learn it properly.
Luckily, I no longer need a PhD in webpack or node packages in order to run rails s successfully.
The idea to have a node_modules that has tens of thousands of folders/files for the simplest package that I needed to install. Ruby has gems, but they have few files, I can easily know where to go to understand how something works or add a debugger.
But just trying to read the name of all those seemed for me always like a task that I dont want to do.
The language itself letting aside some warts is good, can be enjoyed and good code maybe can be written.
Using Rails with Slim/HAML is an absolute bliss. If you prefer there are also libraries like `ViewComponents` that can facilitate partial rendering even further. Add in some web components and you can build very interactive pages with it. Even use React if you really need it in specific pages.
HATEOAS cuts the complexity of applications drastically. And if you still need APIs, it's extremely easy to respond to different mime types and even have the same endpoints if you desire.
IME the majority of applications that use React don't need it at all. They use React for a couple of menus that have to pop ups. So hopefully once some larger apps start popping up with no React (or only sprinkles of it), it finally clicks for some people how unnecessarily complex our applications are today.
But I already read comments saying they need to switch to React because everyone else uses it. SMH.
One can dream!
On the front-end it’s been a mess for a really long while now though
I actually went the exact opposite route, at least when possible: https://github.com/amacneil/dbmate
Pure SQL migrations, regardless of the back end technology that you use, completely decoupled from how each framework/library views things and therefore not dependent on them (you could even rewrite the back end in another technology later on, if needed; or swap ORMs; or avoid issues when there's a major ORM version update).
It's really nice when you can generate entity mappings based on a live database, like with https://blog.jetbrains.com/dotnet/2022/01/31/entity-framewor...
So in my case, I can have:
* a DB that has migrations applied with dbmate, completely decoupled from any back end(s) that might use it
* a back end that has entity mappings for ORM (if used) generated from the live local test database container during development, used for an API and not much more
* a front end that's typically a SPA using the API, but is otherwise just a bunch of prepared files that can be served off of any web server
Of course, if you need SSR then things move around a bit, but that decoupling works great for me (but might not for others)!“Just use another framework when you need performance” they say.
Well, The performance of Ruby is still a nightmare. Not just serializers. It's that serializers in Rails are the most prominent place where you'll have cpu-bound performance made visible.
But really. Just try anything cpu-bound (e.g. transform a huge list or CSV or so), and the lack of native, safe, threading, the horrendous performance of both the JIT compiler and the runtime and the language become apparent.
This isn't to criticize Ruby. Because once you see all the runtime inflection, the way it can modify itself runtime and the DSL magic it allows, the current performance is a magnificent feat! It should be impossible to have it perform at all, given these features. That people managed to make such a beautiful language, with such marvelous features and still have it perform like it does, is a true engineering marvel.
Sorry, what other interpreted language has significantly better serializiation/deserialization performance than Ruby?
E.g. https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
And I have measured ser/de for PHP, Ruby (and Rust, we needed to know how much faster JSON serde in rust would be, and compared it to Ruby and PHP). Php is probably much faster because the JSON ser/de is apparently written in C.
Sometimes it's more than 2x faster than before. They now have JIT and are planing to have an intermediate language for even more speed.
Most PHP stdlib code is pure C/C++ so it tends to be very fast, but I'm guessing Ruby is the same.
Ruby is not, however statically typed, nor does it have a type checker (well, there is sorbet and RBS) Those are fixed terms.
I’ve been liking Golang but I haven’t had a job that used it in a while. Who knows what’s it’s like right now
Propshaft should bring sanity back to it, but its going to be a while before that's mainstream.
Starting with 3.2 and the introduction of the asset pipeline, every new version was “This is all about to change. A totally new way of using assets is coming.”
Every new version is supposed to solve all of the problems of the previous version. It’s exhausting to constantly change to keep up with the new One True Way™, only for it to be replaced with another assets strategy powered by a gem with a cute name.
RJS and Prototype, then UJS and jQuery, then Sprockets and CoffeeScript and Sass, then Turbolinks, SCSS, then Dart Sass, then Stimulus and Webpacker, then esbuild and TypeScript, then Turbo, then import maps but there’s also jsbundling/cssbundling, then Hotwire, then Strada, then “Turbo 8” and TypeScript is suddenly phased out because DHH doesn’t like it, and now Bun.
I’m probably leaving something out and this is certainly out of order. But my point stands: the prescribed way of handling assets with Rails is ridiculous.
What would the alternative be for a 20 year old project?
I think what we're seeing is a natural progression based on how the web changed over the last 2 decades.
I'd be more concerned if Rails didn't change and `rails new` produced a jQuery / SCSS / CoffeeScript loadout and made it difficult to use modern tools. Now it's easier than ever to plug in whatever front-end you want.
There's a point when change is just too much and the returns are diminishing.
How tho?
Things naturally progressed from a lot of asset related things with few choices being baked into Rails to being more componentized but still tightly baked into Rails (Webpacker) to even more componentized and mostly decoupled from Rails (current state of things) to even more decoupled from Rails (Propshaft).
Current day if you want to use Webpack or esbuild or something else or nothing it's easy because Rails no longer cares. It only cares that assets end up in a specific directory. How they get there is up to you. The framework also provides value by giving you generators to tie things together based on the choices you want so you don't have to figure it out individually from ground zero.
If you look at it from that perspective I think things unfolded reasonably well.
Personally I didn't like Webpacker at all. Webpack was complicated enough on its own and then having to learn the Rails way of configuring it made it even harder. But I think it was a good tipping point to demonstrate that from a maintainer's POV it's hard and time consuming to create good abstractions over front-end tools on the back-end and from an end user's POV it's bad because of the complexity.
Being able to look directly at esbuild's documentation and apply it 1:1 is a much nicer outcome for everyone. Maintainers don't have to keep up with every change and users don't have another layer of abstraction to deal with.
It did take Rails a while to come to this solution but it's really good that they did. This is how I managed front-end tools in Flask and other frameworks for around the last ~decade. You have the framework look for assets in 1 spot and how they get there is up to you. It was easy for me to do that because I only had to make it work for my apps, my client's apps and the starter apps I posted on GitHub, but applying that to a framework that has hundreds of thousands of people using it is for sure a bigger project.
Today the perception is that the JS community doesn’t seem to care about providing a stable experience for those outside of it, which is why projects like Rails and Phoenix are successful with “No/Low-JS” features.
Where Rails screwed up is not updating their docs to reflect this new reality for a really long time. It wasn’t clear what people should be using. They’re still creating confusion by making it unclear if Turbo is for Rails or all web frameworks, which you’ll notice when you go to the Hotwire landing page and see no mention of Rails.
I don't disagree, but also front-end was a mess for a long time.
Now Rails (with Rails 7.1 + Hotwired + Importmaps) is a pleasure to work with.
But we had to wait for good support in browsers of at least ES6 + Import Maps.
See the date of this article here: https://web.dev/import-maps-in-all-modern-browsers/ -> 28 March 2023 announcing importmaps is available on all modern browsers.
Thus there was no way around Webpack Yarn or any other helping tool for JS until now.
Now we have importmaps and good support in browsers for east least ES6 (https://caniuse.com/?search=es6) thus there is almost no need for extra tooling so you can write modern JS.
Well, here we go, PR coming up. Even if it has to stack behind the 7.0 one that's been sitting there for months.
If you have time to answer - why would I upgrade?
The main thing with older versions is vulnerabilities in associated gems, e.g. nokogiri which you can't upgrade without a major rails upgrade. However most apps don't do fancy XML parsing for example so most vulns are not applicable. So there is a bit of maintaining to ensure things are safe. Often you might add in a monkey patch to cover a bug.
Upgrading therefore makes it more secure and lowers maintenance time. However there's the cost of the non stop upgrades to factor in. Another factor might be faster Ruby support in newer versions.
(Generally when I make a rails app I use the latest release but I don't upgrade the rails version afterwards unless it's popular or the app is very old and stuff doesn't work on newer systems)
I used to make good money doing upgrades from one version to another as well...
I hear your gripes here... I think with Rails if you run into problems, this is because you created (or someone in your org) them for you.
> […] One bonus you get from having an enemy is a very clear marketing message. People are stoked by conflict. And they also understand a product by comparing it to others. With a chosen enemy, you’re feeding people a story they want to hear. Not only will they understand your product better and faster, they’ll take sides. And that’s a sure-fire way to get attention and ignite passion.
> This project has been founded, funded, and maintained predominantly by the resources and investment of 37signals. We will set the direction as we see fit...
With TensorFlow recently discontinuing support for Windows, it's very concerning to me that one day one person or organization decides that "we will set the direction".
They don't even try to use nicer language. Don't get me wrong, I respect the work and effort. But 37signals are no saints. There was a scandal, and employee exodus not so long ago.
Hotwire is so deeply integrated into Rails, so Rails is even more 37signals' tool than ever before. Before we had webpack, and JavaScript libraries that sometimes were not easy to use. Now things are easier, but instead of JS libraries we've gotten 37signals dependency, which is VERY concerning.
The actual incident was a horde of morons piling on top of that repo in the days that followed.
Rails backend is in a good shape, but I don't like being dependent on a dictator's decisions on the frontend. I don't understand why Rails team don't understand that.
But from the other side I'm thankful to DHH, because now I use more Elixir, and Crystal. Those are awesome tools, and 37signals-free world feels so much better. It's not toxic.
As a Rails developer myself, it was much harder to contribute to Turbo. I had to learn Typescript before doing so, which makes the bridge too high.
90+% of the people who were complaining didn't even know Turbo existed.
Could it be communicated a bit better? Yeah sure, I give you that. Is it bad moving forward? Maybe initially as there were broken PRs but I think eventually it is in a much better place. In my opinion.
If someone suggested using Rails for a new project to me today, I would show them the door.
There are so many more mature frameworks in more robust and performant languages.
IMO the only reason to use Rails today is if you’re too uncurious to learn something better.
Or Asp.Net.
Or Flask with SqlAlchemy + the migration and validation libs(marshmallow?)
Or whatever is good in Golang.
There is no such thing in Go and most likely will never be given the perspectives held by the greater Go community (less is more).
Comparatively, the Ruby community is the complete inverse: any perceived friction can and should be abstracted to be (subjectively) nicer. It's why some people love the language, and it's also why some people dislike the language.
My comment definitely applies to the other two options you listed.
(but then again, if you are doing complex migrations through framework in-language, you might be setting yourself up for failure)
Not saying that those are the best choice under all circumstances but they certainly aren’t wrong.
I was an RoR developer for a decade. These code bases do not age well. The test requirements of loosely typed languages are so much greater. The lack of ability to automate refactors alone is enough to avoid ruby.
Also, the list they gave you will be different next month.
I’m also on a fence re Hotwire, but apparently it works for them in Basecamp and Hey, so that’s what they are investing into.
Anecdotally, recently in Ruby shops I see an increase in new projects using Hotwire as a push back against bloated and hard to maintain React front ends and people are delighted how everything is easier now. RoR codebases are not the only ones which did not age well, I’ve seen quite a few React/NextJs legacy projects I would prefer not to touch at all. So I don’t think technology is the main culprit here.
I've seen marvels and disasters in every stack.
Please name "many more mature" frameworks. I am curious about how many web frameworks are still actively maintained today.
Please note for me, mature also includes age. So you have to state frameworks that are at least older than 2005 (I would also accept created in 2005).
Rails is based on Ruby, which is backend language, and Rails should stay more on backend.
That means
- session management
- routing and controllers
- many API options (REST, json-rpc, ...) + JSON object exporters
- ORM, Mailing, etc
- server template renders (ViewCells are still not part of Rails)
- tasks, logging and other helpers
In the same way Rails adopted rake gem as default task runner, without re-inventing it as "ActiveCliTasks", they could have created standardised connector layer that will exchange objects between backend and frontend.So no Stimulus, TurboLinks, HotWire and other stuff one HAS TO learn and re-learn between versions. Svelte, Vue and React should have been officially supported with thin connectors. Rails server render layer can easily be integrated in any existing frontend tech, as alternative to React server components insanity.
Also, there is no reason to have to have socket connection to pass HTML between server and client, good old RPC is just fine as 99% of big app scaling problems are Database problems, no need for another layers of complexity one has to ensure it works.
I think, in that way Rails could "shine" far into the future, using its strong points but adopting new frontend stuff on the way, not re-inventing it all the time.
Also, if trying to do lightweight Javascripty frontends within the framework is important, we might as well just move to Phoenix. Phoenix is arguably better already... it just requires a moderate jump to learn Elixir (which unfortunately looks very much like Ruby but requires a very different approach to writing).
What about all the gems Ruby has, does one really have all he needs inside Elixir/Erlang? More complex stuff like NokoGiri, Haml, etc., that works well and is maintained.