other-languages

mauricio.szabo 2024-03-27T14:20:55.270509Z

It's amazing now, working with Ruby, how needlessly complicated the language is. You have objects. And you have methods. So you declare these methods on the class of that Object. But then you have the reflection API. And now you need .instance_method, that captures an UnboundMethod from the class, or .method which captures a Method from the instance Sure, but classes can have methods (they are called static methods in Java). So you declare them... in classes. But the class is the instance. So you now have a .singleton_class methods that lazily creates a "class" for the "class" of an "object". Also, inside the class but outside a method is a valid place to run code - so you can define an API that dynamically declares methods too, and they can be bound to a different class than the one you're running now... Finally, there are at least two ways of declaring methods - both declare new scopes, but one is also a closure, which keeps variables from outside your method declaration. Good luck finding reason around that...

😅 4
Yehonathan Sharvit 2024-03-27T17:33:03.165209Z

Ruby is a write-only language

mauricio.szabo 2024-03-27T17:45:42.808189Z

Well, although I tend to agree at some point, Clojure can be worse. My last experiences with it were kinda like I was working on a meta-language written over Clojure, to the point that Ruby is feeling way better honestly... I still prefer Clojure the language, but I am not sure about working with it (unless I am sure I won't find weird stuff)

Cora (she/her) 2024-03-28T01:16:42.725389Z

don't forget about modules and how those apply to the class hierarchy!

Cora (she/her) 2024-03-28T01:17:07.245749Z

include, extend, prepend, please_make_it_stop

Cora (she/her) 2024-03-28T01:18:27.197909Z

and dynamically created modules made with Module.new that have methods added to them then the module is prepended so you don't have to pollute the class directly and the user can override the method and just call super to call into the dynamic module's methods

Cora (she/her) 2024-03-28T01:18:55.727829Z

🍌 🍌 🍌

mauricio.szabo 2024-03-28T01:56:51.697279Z

Also remember that extend can be applied to instances too ðŸ˜ą

Cora (she/her) 2024-03-28T02:20:24.038839Z

and you can include and extend and prepend on singleton classes ðŸĪŠ