3 ms·
Wonder if it would be possible/useful to have the Ruby interpreter itself identify eligible functions and "crystalize" them automatically
by bhaney 3y ago
Wonder if it would be possible/useful to have the Ruby interpreter itself identify eligible functions and "crystalize" them automatically
- freedomben 3y agoIt would definitely be possible, but I would really hate to see coupling like that added to ruby. I also worry that it would make it too magical and difficult to figure out what code is running, where and when. Debugging an issue deep in the bowels of that is a scary thought.
- mdaniel 3y ago> to ruby. I also worry that it would make it too magical and difficult to figure out what code is running, where and when Coming from both python and statically-typed languages, your description 100% squares up with every experience I've had with ruby Folks are free to throw stones at the Spring Framework similarly, it's not out of bounds, but ruby seems to embrace the monkeypatch
- celdon25 3y ago> ruby seems to embrace the monkeypatch How recent were your experiences with this? In recent years I've seen monkeypatching treated as more of an antipattern. If you are on a project where people are doing that without very good reasons, that says more about the team than the language.
- aardvark179 3y agoIt is still prevalent enough that when developing Ruby JITs it can be worthwhile delaying compilation until the framework has started up and finished invalidating all your method lookups, or changing your invalidation strategy to handle new methods being defined on Object without invalidating all your inline caches.
- jbverschoor 3y agoI think that’s a misconception of people who don’t understand the underlying language/framework (yet). How much magic is really going on, especially compared to for example JPA/Hiberbate, or any of the aspect orient projects?
- kayodelycaon 3y agoMonkeypatching was common a decade ago. Now it’s more limited to things that try to be language or framework extensions, like ActiveSupport or gems extending ActiveRecord. The whole point of those is to deeply integrate. Metaprogramming like looping over an array to dynamic create methods is far less common. It definitely makes me cranky when I can’t find a method definition. ORMs are one of a few exceptions where the utility justifies it.
- Lio 3y agoConceptually, isn’t that what a JIT compiler does? Crystalruby ia really interesting though. This has got me wondering: 1. How this compares to Sorbet Compiler in terms of performance? 2. If you could use Sorbet or RBS type annotations to drive crystalruby? 3. How would YJIT perform if it was fed with type annotations? 4. Could crystalruby type signatures be used by Sorbet-lsp, ruby-lsp, etc in to improve developer experience? I really wish we had a single standard for inline types in ruby. I wish that was an inline RBS type annotation but I guess I’d take anything that works.
- colonelpopcorn 3y agoThat's a very Ruby idea.