And like I said above while you might be able to recreate some of Rails' functionality in other languages, you wouldn't be able to replicate all of it with the same fluidity and readability that you have in Rails
134 karma · joined October 16, 2022
And like I said above while you might be able to recreate some of Rails' functionality in other languages, you wouldn't be able to replicate all of it with the same fluidity and readability that you have in Rails
The same is true for defining associations between models. Consider the following model:
class User < ApplicationRecord
belongs_to :organization
scope :active, -> { where(active: true) }
end
You mentioned that DSLs aren't important, but the DSL for defining associations is extremely convenient. Adding the belongs_to line defines numerous methods on the User class, allowing you to do things like User.last.organization. The scope line dynamically defines the active method, allowing you to call User.active, which executes the code in the provided block. There are also DSLs for defining routes and migrations, which are extremely important when using Rails.Ruby's metaprogramming is also utilized in Rails controllers to load the correct code. For example, the index method in the UsersController knows to look for the views/users/index.html file because it can reflect on the method and the class to determine where to load the correct code using Rails' autoloader, Zeitwerk.
Ruby's open classes and monkey patching (something that should be done with extreme caution) allow ActiveSupport to add extremely useful methods to Ruby's base classes. This enables conveniences such as Date.today - 10.days or DateTime.now.beginning_of_day.
These are just a few examples that I can think of off the top of my head, but nearly every major convenience in Rails relies on the flexibility provided by Ruby. While it might be possible to reproduce many aspects of Rails in JavaScript, I don't believe you could replicate all of it with the same readability and intuitiveness that Rails offers.
So a method like this would be defined as something like:
def has_many(model_name, dependent:)
puts model_name.to_s
puts dependent.to_s
end
Which you could then call as: has_many(:players, dependent: :destroy_async)
or has_many :players, dependent: :destroy_async
Since you don't need to put parenthesis around method arguments in ruby.All the talks are being released in the next week or so, you should take a look when it's out, it was very interesting.
"Twitter moved off rails and I was always really curious about that story. Here's a testimony from someone who actually worked at Twitter when they moved off. Yeah they moved off because they had a badly designed Rails app, that happens. Okay and then they moved into what they thought was better a constellation of java microservices and then nothing fucking happened for 10 years. They poured concrete over the application and hired thousands of people to make no progress at all."
You can watch the whole talk here, the quote starts around the 15 min mark:
So no. Or why not measure productivity in an ephemeral way.
https://www.theguardian.com/money/2023/may/10/plans-abolish-...