News for hackers. Stuff that matters.
Re:Building GitHub with Ruby on Rails by drdaeman on Friday April 07, 2023 @12:27PM (#35483480)
One thing I just cannot wrap my head around is Ruby/Rails metaprogramming and attribution of things (as in "where this method/class/macro comes from?"), especially with so many authors trying to do something to the pre-existing stuff, including the standard library bits.

Like, a lot of times I see some baz.foobarify() I have really hard time understanding where the heck that comes from. RubyMine makes wonders and control-clicking gets me there about half of time, but the rest of it it's either "search in all files, hoping that `def foobarify` is unique enough" or "this is crazy, but I'm gonna set a breakpoint, run it and see where this rabbit hole goes".

It feels kinda like Scala (or, to lesser degree, Haskell) magic operators problem, but worse.

I consider myself proficient with a decent number of languages and frameworks, but Ruby/Rails is one arcane mystery that just never clicked. So I really wonder what's the trick to make metaprogramming shenanigans manageable at this scale?

Re:Building GitHub with Ruby on Rails by ptoomey3 on Friday April 07, 2023 @04:45PM (#35486737)
https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debugger... is ruby gold for this kind of stuff. As a Ruby developer, probably one of the most impactful "quick tips" I've ever picked up is this:

  foo.method(:bar).source_location 
That is wildly useful when debugging/figuring out where the actual code for some method is at runtime.
Re:Building GitHub with Ruby on Rails by throwaway445232 on Saturday April 08, 2023 @03:27AM (#35491328)
you can't click on it and jump to source? is this the power of ruby metaprogramming?