4 ms·
To be honest, I don't really understand Ruby either. It's like combination of performance of Python, compatibility of C, transparency of any mystery dependency
by oriolid 5y ago
To be honest, I don't really understand Ruby either. It's like combination of performance of Python, compatibility of C, transparency of any mystery dependency + build system and yet another syntax on top of it.
- cyberpunk 5y agoRuby is awesome, but it's insanely powerful. For example: I mean, you can monkeypatch anything (including _Object_) at runtime. You can use this to make 1 + 1 = 3, if you desired, or to add a method to all instances of any class currently instantiated. Want your database to respond to .fuckoff(), no problem.. This kind of stuff is also how rspec (used to?) actually run tests. It's cool, but also pretty insane. irb(main):001:0> class Object irb(main):002:1> def fuckoff irb(main):003:2> "lol" irb(main):004:2> end irb(main):005:1> end => :fuckoff irb(main):006:0> 5.fuckoff => "lol" irb(main):007:0> "Hello World".fuckoff => "lol" irb(main):008:0>
- ilyash 5y agoNext Generation Shell: "hold my beer" F fuckoff(x) "lol" echo(5.fuckoff()) echo("Hello World".fuckoff())
- Tainnor 5y agoYes, the nice thing is that you can use metaprogramming to create really powerful and readable DSLs. The bad thing is that this is often abused horribly, I blame the Rails ecosystem with its "just add this gem to the Gemfile and it will magically change your application" attitude.
- smrtinsert 5y agoToday's java killer is tomorrow's bad practice
- oriolid 5y ago"I have altered the API, pray that I don't alter it any further"?
- sceadu 5y agoMalcolm Tucker style
- gavinray 5y agoThis isn't that crazy IMO, both Kotlin and Scala 3 allow this with extension methods https://kotlinlang.org/docs/extensions.html https://kotlinlang.org/docs/extensions.html https://docs.scala-lang.org/scala3/book/ca-extension-methods.html https://docs.scala-lang.org/scala3/book/ca-extension-methods...
- Tainnor 5y agoAt least Kotlin (probably Scala too) requires you to explicitly import the corresponding method though. In Ruby, however, there is no concept of an import. You can require other files but this is transitive. So if something anywhere in your chain of dependencies is defining a new method on String, or Object, it's available everywhere. Plus, in Rails usually you don't even have to require anything, as the framework magic does that for you. The fact that there is no proper import/module system is easily one of my most disliked features about Ruby, it makes it incredibly hard to understand where things come from. Also, Ruby doesn't only allow you to add new behaviour to existing classes. It also allows overriding existing methods. And that suffers from the exact same problems, i.e. it could be in some transitive dependency, and suddenly your strings will be doing things you didn't expect them to do...
- pjmlp 5y agoWelcome to Smalltalk and Lisp worlds.
- AtlasBarfed 5y agoGroovy can do this on the jvm. But you get optional typing too for speed
- Tainnor 5y agoI'm a static typing covert, but as far as dynamically typed languages go, I still prefer Ruby to Python.