| ▲ | psychoslave 2 days ago | |||||||
That’s basically what is done all the time in languages where monkey patching is accepted as idiomatic, notably Ruby. Ruby is not known for its speed-first mindset though. On the other side, having a type holding a closed set of applicable functions is somehow questioning. There are languages out there that allows to define arbitrary functions and then use them as a methods with dot notation on any variable matching the type of the first argument, including Nim (with macros), Scala (with implicit classes and type classes), Kotlin (with extension functions) and Rust (with traits). | ||||||||
| ▲ | pjmlp 2 days ago | parent | next [-] | |||||||
It is getting better, now that they finally got the Smalltalk lessons from 1984. "Efficient implementation of the smalltalk-80 system" | ||||||||
| ▲ | igouy 2 days ago | parent | prev | next [-] | |||||||
> Ruby is not known for its speed-first mindset though. https://benchmarksgame-team.pages.debian.net/benchmarksgame/... | ||||||||
| ▲ | IshKebab 2 days ago | parent | prev [-] | |||||||
> Ruby is not known for its speed-first mindset though. Or its maintainability, and this is one of the big reasons why. Methods and variables are dynamically generated at runtime which makes it impossible to even grep for them. If you have a large Ruby codebase (say Gitlab or Asciidoctor), it can be almost impossible to trace through code unless you are familiar with the entire codebase. Their "answer" is that you run the code and use the debugger, but that's clearly ridiculous. So I would say dynamically defined classes is not only bad for performance; it's just bad in general. | ||||||||
| ||||||||