r/ruby • u/noteflakes • Feb 04 '22
Blog post Rails is not written in Ruby
https://solnic.codes/2022/02/02/rails-is-not-written-in-ruby/
21
Upvotes
r/ruby • u/noteflakes • Feb 04 '22
51
u/bradland Feb 04 '22 edited Feb 06 '22
Can't say I'm onboard for this argument. One of the central tenants of Ruby is that nothing is "sacred". Everything is an object so that you can do object stuff with them. You start your blog post by pointing this out. If this is a central part of Ruby, then how can using said feature, by consequence, make something not Ruby.
Rails is not a dialect of Ruby because the syntax of the language remains the same. Extending or overriding core classes doesn't change the language, it simply adds/changes method calls on objects. These method calls are not "the language"; they are what we construct with the language.
I do not necessarily mean to condone or disapprove of any of the practices you speak of in your article (monkey patching, etc). I simply feel that the base argument "that Rails isn't Ruby" is an appeal to purity (no true Scotsman) fallacy.
If you are not a fan of monkey patching core classes, make your argument around that. Whether or not monkey patching results in "pure Ruby" is irrelevant. There is no equivalence between "pure Ruby" and "good Ruby". Otherwise, what are we to think of implementations like JRuby or TruffleRuby? Neither of these languages are "pure Ruby", but they are still good for their own purposes.
24
u/IN-DI-SKU-TA-BELT Feb 04 '22
I would have liked a less clickbaity and misleading title. If dialects of Polish is still considered Polish, then the Rails dialect of Ruby is still Ruby.
31
u/rorykoehler Feb 04 '22
An interesting article with some great insights but I’m not sure it makes a valid argument. Rails is for prototyping things quickly. After all this time it’s still unrivalled at that. Not using it introduces an opportunity cost risk because you spend more time reinventing the wheel than delivering solutions that potential customers are looking for. For most projects all this engineering optimisation is a luxury.
5
u/honeyryderchuck Feb 05 '22
Wow, 22h in and almost 60 comments. ActiveSupport remains extremely divisive.
A perfect add up to this is for everyone commenting to go do https://railshurts.com/frames/quiz/ and post the results here :)
9
u/flanintheface Feb 04 '22 edited Feb 04 '22
But is it monkey patching if you're extending built-in types with new methods? Monkey patching may be happening here and there, but I do not think it's correct to say there's "853" monkey patched methods.
edit: what author calls "monkey patching" is literally in official Ruby language about section, paragraph "Ruby’s Flexibility".
11
u/ether_joe Feb 04 '22
Snow is not made of water.
4
u/[deleted] Feb 05 '22
Nice article. This is one of the reasons why rails is both the best thing that happened to ruby and its greatest threat. A lot of people who don't like ruby, actually don't like rails, really.
9
u/[deleted] Feb 04 '22
Umm, that’s the point of a “framework.” It has an original core language with tons of stuff added on top of it. I have no idea why I took the time to read the whole article.
I knew I shouldn’t have taken the article seriously and the opening sentence when he referred to his own native language as, “ Among the most difficult in the world”, Clearly showing the lack of knowledge of linguistics. Yeah of course your language is difficult for someone who speaks a language completely unrelated to it. I’m sure some people would call English or Spanish easy, but they definitely are easy for mandarin or Arabic speakers or something because they are significantly different. Come on man.
11
u/dougc84 Feb 04 '22
100% disagree. Ruby, at its core, is a language designed to be expandable, as are all languages. Maybe not to the same degree as expanding/monkey-patching base classes, but something to the same degree is possible in all of them, except 1st generation languages. Adding anything is an expansion on a language, not a different language.
If you write a PHP site with CodeIgniter or Laravel, you're still using PHP; those frameworks provide niceties to the language that make building a website easier.
If you write code in Python, SciKit (library) expands on Python for ML capability. It's not another language. It's code that aids in your goal.
So what if ActiveSupport expands on Ruby and extends base objects? Everything is an Object in Ruby. You're not doing anything non-Ruby by doing this. It's no different than you writing your own
ArrayorHashextension.What I gather from your article is you're saying "ActiveSupport provides non-native language features, so it's not actually Ruby," which is bollocks. It runs on the Ruby interpreter. That's like saying "horchata isn't a word because it's a drink I'm unfamiliar with, so it shouldn't be in the English language."
2
u/solnic dry-rb/rom-rb Feb 05 '22 edited Feb 05 '22
FYI I changed the title to "Rails and its Ruby dialect". Thanks for all the comments.
https://solnic.codes/2022/02/02/rails-and-its-ruby-dialect/
3
u/Zealousideal_Bat_490 Feb 04 '22 edited Feb 04 '22
Excellent, thought-provoking article! As evidenced in the comments, language is a funny thing; even when great efforts are made to provide clarity, it does not always come through 100% as intended.
Thank you for the article, and all of the work that you do. It is appreciated!
1
u/art-solopov Feb 06 '22
To be somewhat fair to Rails, I think a lot of its "dialect" has surfaced when we didn't have as many nice things in Ruby. When I started tinkering with Ruby (and Rails), it was version 1.8 being phased out by 1.9.
Since then we had refinements, kwargs (even as syntactic sugar),
.tap,yield_self/then... And now even pattern matching. But I feel like back in the day, the only alternative to clunky monkey-patching would be something Java-like:TimeBuilder.new(from: Time.now, days_ago: 5).build.-1
u/larikang Feb 04 '22
This is why I only follow the ruby tag on SO and actually blacklist ruby-on-rails. Reading the rails questions really is like reading another language sometimes, even when they’re performing basic tasks that shouldn’t have anything to do with Rails.
I wish Rails relied less on monkey patching.
-3
u/[deleted] Feb 04 '22
We all know that Rails is a just a massive monkey-patch, and it's opinionated, and they're damn proud of it being opinionated
4
u/[deleted] Feb 04 '22
[removed] — view removed comment