News for hackers. Stuff that matters.
Re:Where is Ruby Headed in 2021? by Buttons840 on Thursday November 18, 2021 @11:38PM (#29273896)
> I’ve tried python, but I end up having to deal with the mess of importing modules

Without those imports, how will people reading the code find the definitions? How will they track down the source code for all the methods being called?

If the answer is "with an IDE / tools", then can't those same tools be used to solve the "mess of importing modules"? If you're using a good IDE, imports and go-to-definition are both solved problems, no matter what language you're using.

If you're not using an IDE, that's a more interesting situation, and without an IDE I much prefer having the explicit imports so that I at least know where to start digging.

Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @01:04AM (#29274309)
The often impossibility of finding the definition of the methods I'm calling is the main thing that soured me on Rails. I think a more explicit style is more common nowadays, which is a good thing.
Re:Where is Ruby Headed in 2021? by grncdr on Friday November 19, 2021 @03:41AM (#29275085)
Maybe you already know it, but I find `something.method(:mystery_method).source_location` points me to the right place more often than not. I only mention it because I have noticed a lot of people work productively in Ruby without leveraging it's dynamic/reflective features[0], but little idioms like the above are absolute lifesavers for me.

[0]: A big disadvantage of the above is it's not statically resolvable, so you couldn't really build an IDE go-to-definition with it.

Re:Where is Ruby Headed in 2021? by Lio on Friday November 19, 2021 @04:38AM (#29275410)
The two tools I'd recommend for navigating ruby code in addition to #source_location are Solargraph[1] and, my favourite, good 'ol exuberant ctags[2].

Solargraph is an amazing project but ctags is still just so fast and low overhead that it's what I mostly use.

ctag support is available for most editors and is built into Vim. You need to first generate a tag file (or have an editor plugin do it for you[3]) and then press Ctrl-] to go to definition.

1. https://solargraph.org/

2. http://ctags.sourceforge.net/

3. https://github.com/tpope/gem-ctags

Re:Where is Ruby Headed in 2021? by nitrogen on Friday November 19, 2021 @06:17AM (#29276054)
And don't forget the option of just calling into pry at the line in question and typing ls and show-doc. Also ripgrep is incredibly useful for navigating new codebases.
Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @02:53PM (#29281500)
Yes, grep + debugger / pry were how I solved this when I was still writing lots of Ruby. I find it much more productive to be able to get these answers statically, but I was too strong when I said "impossible"; there's always some way to find the right code, or the VM wouldn't be able to run it :)
Re:Where is Ruby Headed in 2021? by Lio on Friday November 19, 2021 @10:36AM (#29278236)
Yes, you’re quite right! Thank you again, I must remember to use pry more.

With ruby 3.1 I think we’re getting a new default debug.rb gem.

It will be interesting to see if pry or the beat ideas from pry can be integrated with that.

Re:Where is Ruby Headed in 2021? by chenmike on Friday November 19, 2021 @03:02AM (#29274890)
This magic is delightful in small codebases I’m familiar with and absolute hell in large codebases I’m not familiar with
Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @02:54PM (#29281508)
Well put. Totally my view of it.
Re:Where is Ruby Headed in 2021? by rhizome31 on Friday November 19, 2021 @04:17AM (#29275289)
I've worked with Ruby in the past and I currently work with Python and Elixir. This is a caveat that Elixir inherited from Ruby. In Elixir there's the `only` option of `import`, but it doesn't seem idiomatic to use it. In Python there's `import *` but it's an actively discouraged practice whereas in Ruby and Elixir it's the norm. I like all three but on this particular point I think Python got it right.
Re:Where is Ruby Headed in 2021? by sodapopcan on Friday November 19, 2021 @08:08AM (#29276739)
I _much_ prefer Elixir’s way of not using imports much and prefixing most function calls with the module name. That way when I jump to a function definition, I often don’t need to do any further jumping around—I know exactly where everything is coming from right there. I especially hate when language idioms encourage using a shorthand name for the module when importing. Just be explicit!
Re:Where is Ruby Headed in 2021? by MrWiffles on Friday November 19, 2021 @09:16AM (#29277341)
> [...] I especially hate when language idioms encourage using a shorthand name for the module when importing. Just be explicit!

THIS. 100%!

I also think Python seems to do this better with the namespace pattern of `import x.y.z`. Never seen the `import *` pattern before, didn't know Python can do that (never done Python really though either, only browsed some code here or there).

But one addition to your statement I'd like to add: not just idioms, but documentation can spread this antipattern too.

Noobs come to a language, read the documentation for some tool, library, etc., and understandably come away thinking "Oh ok, this is how it's done" when in reality, while they're not doing anything wrong per se, they're being taught a bad habit right off the bat. And that makes the inevitable hard slap across the face that reality (or a co-worker) eventually hits you with all the more shocking, possibly even leading to resentment of others when this happens.

I myself had this problem many years ago; "why the hell do you need all these subclasses and so many layers of abstraction?!" I once asked. "Because those class/method names already exist within other classes loaded at runtime, or will likely be added in future external dependencies, and we don't want to accidentally overwrite those."

Well, I thought that was a stupid idea. In my (very limited at the time) experience, when I had that problem, I just insisted on finding a damn good descriptive name that wasn't going to be used for anything else, even if it was wicked long or a pain to type. Too long? Don't be lazy. Typos more probable with length? Learn to copy/paste. That was the approach I learned at some point from some documentation somewhere on the internet, and it always worked for me, so it was the "one true path" and all others were inferior, making proponents or users/adherents of any other way "wrong" and inferior to me and my superior, non-lazy intellect. You're telling me that you do it differently? You must be stupid or lazy, and I'm neither therefore I'm better than you; thus forcing me to adopt your inferior standard?! Preposterous! Insulting! Offensive! That's how I saw it.

God, was I dumbass.

I developed this attitude by learning my skills in a near total vacuum, other than documentation written by people on the internet back in the 90's. Not official company-published technical docs, mind you, but forum and BBS posts, mailing list discussions, and way too much IRC to be considered "healthy" by any stretch of the imagination.

Those who taught me did so in a way that was efficient and they did no wrong at all of course - this failure was entirely of my own making, from my own arrogance. But it's also true that had I been taught at the same time that "there are other ways in other languages that are totally valid; this is just for simplicity's sake" and then been shown, or better yet required to use other patterns in school/projects/etc., I might have been able to see the short-sightedness of my own arrogance sooner. Instead, it resulted in an antipattern that allowed me to become overconfident, arrogant, and more difficult to work with than I should've been.

----------

In case you're wondering, I can't remember what I read or where that came from so long ago. Sorry. Might have been C, C++, Java, DOS BASIC (non-GUI/non-Windows), Visual Basic (before .NET) or maybe even PHP 3.something, no idea - that was 20+ years ago. I was inexperienced, arrogant, and a fool; none of that was the author's fault whatsoever. We're all young and stupid at some point in life. I'm no longer young, but at least now I know I'm stupid! :-)

Re:Where is Ruby Headed in 2021? by MrWiffles on Friday November 19, 2021 @08:59AM (#29277150)
Yeah that's been a major pain in my ass more than once, totally get where you're coming from there. One tip for you, and anyone else who might be reading this from the future (hi! do we have flying cars yet? what about time machines? can you bring me one of each, in like, 10 minutes?): RubyMine, the IDE from JetBrains (commercial, Java-based desktop app but not nearly as bad/sluggish as you might expect, though not native fluidity) has a feature to show you where a given method ultimately comes from, going all the way up the chain of source code and abstractions to where it's really defined, including within Rails or other libraries/gems/imported files in a given project. It's a really killer feature for this particular pain point, in my opinion.

Short of that, assuming all your dependencies are unpacked under your project's directory (likely .gitignore'd but there nonetheless, instead of in somewhere like /opt/ or /usr/local/lib or something) you could also `grep -ir 'def method_name' | less` or something to try to figure that out, though it's nowhere near as smooth as RubyMine.

Other editors have Ruby and/or Rails plugins that may help ease this pain point as well, though personally I haven't done anything with that on the editor front in a very, very long time. Generally I'm outright militant about keeping my dependencies to an absolute minimum in a project, and doing everything the most "vanilla" (standard, accepted, most widely adopted patterns, naming conventions, etc.) way possible, and therefore I usually know what gem/lib is providing what particular method, so I don't really need that kind of utility most of the time because I can google up some API docs...when there are API docs anyway.

But in cases where you're having a legacy project/monolith dropped in your lap and nobody knows anything because "the business guy" fired the one developer who actually knew how everything worked and now that guy won't answer his calls because working for free is dumb? Yeah, in those cases, RubyMine or a real good editor plugin can be a lifesaver for this.

Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @02:56PM (#29281547)
If that RubyMine feature works well these days then that's great! In my day it was nice but hit or miss.
Re:Where is Ruby Headed in 2021? by inopinatus on Friday November 19, 2021 @01:32AM (#29274439)
It isn't a good thing. My first advice to all newbie Ruby programmers is to stop thinking about methods and start thinking about messages.
Re:Where is Ruby Headed in 2021? by saagarjha on Friday November 19, 2021 @01:35AM (#29274446)
I don’t see how this helps?
Re:Where is Ruby Headed in 2021? by inopinatus on Friday November 19, 2021 @01:38AM (#29274456)
Ruby's dispatch is Smalltalk-like, not Java-like; it is (very) late-bound. The consequences for interface design are dramatic, the natural style being one in which objects notify each other, rather than telling each other what to do, and the result is loose coupling and ease of composition.

People trying to write Java-like OO in Ruby end up confused and frustrated.

Re:Where is Ruby Headed in 2021? by discreteevent on Friday November 19, 2021 @05:59AM (#29275970)
There's a tradeoff between coupling and cohesion. All the books and talks are about decoupling because that's the interesting part. The problem is that in poor codebases you find everything has been decoupled and the complexity is a nightmare. As Adele Goldberg said: "“In Smalltalk, everything happens somewhere else.” It's better to have a system where you only decouple where and when you want to because you have decided that paying the cost is worth it.
Re:Where is Ruby Headed in 2021? by llamataboot on Friday November 19, 2021 @08:25AM (#29276883)
They used to pay me to turn monoliths into microservices, now they pay me to turn their microservices back into monoliths...
Re:Where is Ruby Headed in 2021? by rhizome31 on Friday November 19, 2021 @04:23AM (#29275328)
I've worked with Java, Ruby and Python but I don't get your point. Can you recommend any resource to help understand what you mean? Or maybe some short examples in Python and Ruby that would highlight how implicit imports allow solving problems in a way that explicit imports prevent?
Re:Where is Ruby Headed in 2021? by stepbeek on Friday November 19, 2021 @09:47AM (#29277679)
Not the parent, but I’ve found Sandi Metz conference talks to be an amazing resource for learning more about this message focused approach.
Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @05:25PM (#29283398)
But back to the original point, Sandi Metz wouldn't suggest that implicit imports are good.
Re:Where is Ruby Headed in 2021? by inopinatus on Friday November 19, 2021 @02:39PM (#29281332)
Sandi Metz's talks, and Avdi Grimm's MOOM course.
Re:Where is Ruby Headed in 2021? by saagarjha on Friday November 19, 2021 @01:45AM (#29274483)
Ok, but Objective-C also does messages and most of them are defined statically and can be easily searched for in a codebase. I’m not saying Ruby needs header files to send messages to something, but being able to figure out where the code for something is isn’t off the table for languages with dynamic dispatch and it can come in handy.
Re:Where is Ruby Headed in 2021? by inopinatus on Friday November 19, 2021 @01:53AM (#29274508)
For that, there's

    object.method(:name).source
    object.method(:name).source_location
but frankly this is still thinking in a rigid mindset that suits other languages better. Ruby isn't just "dynamic dispatch"; a typical metaprogramming technique handles all incoming calls without named methods, or by dynamically writing the code.

To put it bluntly, assuming there's a method on the other side of your message, is practically the antithesis of Ruby.

It's similar to the category error that leads folks to conflating type with class, and writing type checkers that look for class signatures.

Re:Where is Ruby Headed in 2021? by eximius on Friday November 19, 2021 @02:14AM (#29274624)
While freeing to write, that is horrifying to inherit.
Re:Where is Ruby Headed in 2021? by inopinatus on Sunday November 21, 2021 @05:03PM (#29300193)
That isn’t code you write in an application. The topic was how to find a method’s handler, this is how it’s done in the REPL.

Or if you mean, dynamically instantiated methods, those are found throughout Ruby and its ecosystem, and the reason it isn’t horrifying is that the language has terrific support at the REPL for developers needing reflection.

Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @05:32PM (#29283468)
Yeah this is pretty much why I decided I didn't want to write Ruby anymore. You may be right that this is the philosophy of the language, but if it introduces a speed bump or cognitive overhead when trying to understand what a snippet of code is doing (and I contend that "there might not even be a method there responding to your message" is a speed bump), then it's not a good thing, even if it's clever and somehow ideologically pure and interesting. I can appreciate programming languages as art pieces, but when I'm at work I want them to just be a tool.
Re:Where is Ruby Headed in 2021? by mypalmike on Friday November 19, 2021 @07:06AM (#29276372)
The best features about this bridge are that it's made out of soap bubbles and it doesn't necessarily span the river at any given time. This flexibility is wonderful.
Re:Where is Ruby Headed in 2021? by inopinatus on Friday November 19, 2021 @02:37PM (#29281311)
That is not a good metaphor for anything, really: no-one was enlightened; at best some reddit-grade snark was conveyed.
Re:Where is Ruby Headed in 2021? by mypalmike on Friday November 19, 2021 @05:20PM (#29283345)
I worked with Ruby for two years. The metaphor is apt when considering software development as an engineering discipline. It was certainly not meant as snark. You disagree, that's fine.
Re:Where is Ruby Headed in 2021? by inopinatus on Saturday November 20, 2021 @01:31PM (#29290594)
Not really sure what you think I disagree with, since the metaphor is so vague and wishy-washy it could apply to anything from theology to stamp collecting, but it sounds like trying to conflate late binding with some manner of bad coding style.

Well, since I have been privileged to work with several really great Ruby teams over the last couple of decades, whose large and well-structured code uses metaprogramming techniques yet remains easy to follow & comprehend (and debug and extend), and who remain splendidly productive to boot, I can say, if this bunch of guesses at the intended meaning of that "soap bubble" metaphor hold water, then yeah, I disagree.

Conversely, shitty code can be (and is) written in explicit import and early-bound languages. The enterprise world, for example, is riddled with massive hairballs of brittle, unmaintainable, boilerplate-heavy Java.

All of which only goes to show that people, not the programming language, are the problem.

Re:Where is Ruby Headed in 2021? by tomc1985 on Friday November 19, 2021 @10:44AM (#29278321)
I can't think of a single point in my RoR career where this has come up. How do you even do Java-like OO when classes are so loosey-goosey anyway?

Though having suffered in a Rails codebase written by Java engineers, I definitely agree that a light touch is needed with OO -- though composition has its own difficulties and together this forms one of my bigger criticisms of Rails.

Re:Where is Ruby Headed in 2021? by chespinoza on Friday November 19, 2021 @08:22AM (#29276854)
There's plenty of people writing java-like code in Python too, just check Amazon SDK for python or GCP SDK, it's a mess, I don't know if they get frustrated but they do get SDK users confused and frustrated.
Re:Where is Ruby Headed in 2021? by t0mbstone on Friday November 19, 2021 @06:48PM (#29284121)
You need to be using RubyMine. Simply command-click on ANYTHING to jump to the definition, even if it's nested deep in a gem that your project uses.

RubyMine, and the "jump to definition" feature in particular, is the primary thing that enabled me to really "get" Ruby and finally understand how everything worked together.

Re:Where is Ruby Headed in 2021? by devoutsalsa on Friday November 19, 2021 @01:08AM (#29274328)
“git grep” is pretty amazing for tracking things down.
Re:Where is Ruby Headed in 2021? by oblio on Friday November 19, 2021 @05:28AM (#29275722)
That's like someone asking for directions and you giving them a shovel and a introduction to archaeology manual.

If someone asks for directions you give them directions or a current map.

Re:Where is Ruby Headed in 2021? by hagbard_c on Friday November 19, 2021 @10:39AM (#29278269)
Well, no, not really. It is more of the equivalent of showing how to read (or where to find) maps instead of pointing out something on one. If the searcher is in a hurry the latter is more helpful, otherwise the former is preferable.
Re:Where is Ruby Headed in 2021? by oblio on Friday November 19, 2021 @11:16AM (#29278744)
Yeah, but you shouldn't need git grep to find out what something is.

I understand using to find out why it's there, but not what it is.

Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @05:36PM (#29283510)
Yeah the problem is that grep understands lines of text but not the structure of code. But code should be understandable by a computer program (by definition it has to be at some point) so you should be able to use a tool that understands the structure of the code it's reading rather than just seeing a bunch of lines of text.
Re:Where is Ruby Headed in 2021? by devoutsalsa on Friday November 19, 2021 @02:45PM (#29281406)
Personally I find it faster than using an IDE much of the time. It’s super fast and very powerful.
Re:Where is Ruby Headed in 2021? by rhizome31 on Friday November 19, 2021 @04:29AM (#29275364)
Of course that's what we end up doing in practice, using external tools (CLI or IDE) to work around a limitation in expressiveness of the language. This advice is a testimony that there's indeed a problem upfront :) And it comes short when searching from commonly used names...
Re:Where is Ruby Headed in 2021? by nitrogen on Friday November 19, 2021 @06:22AM (#29276082)
This advice is a testimony that there's indeed a problem upfront

Indeed, and the problem is that IDEs have encouraged developers to write convoluted code and to forget how to navigate a filesystem. Reading code and commit history is a much faster path to understanding a system than an IDE's autocomplete. I learned this from Ruby, and it serves me well in C, Kotlin, Scala, PL/SQL, Typescript, etc.

Re:Where is Ruby Headed in 2021? by maccard on Friday November 19, 2021 @08:41AM (#29277000)
> IDEs have encouraged developers to write convoluted code and to forget how to navigate a filesystem.

I would argue the exact opposite. Developers who force tools designed 30 years ago to dictate programming language best practices today are holding back the entire industry. There is no reason for my tooling to depend on my filesystem; imagine if my IDE integrated directly with vcs, and a language server provided both of those tools semantic information about my code, available on any device. Let's not kid ourselves either, utf-8 isn't human readable on disk, it's still a binary-like format.

Re:Where is Ruby Headed in 2021? by rhizome31 on Friday November 19, 2021 @09:48AM (#29277695)
You're right to remind that the filesystem is a metaphor, a model and not the reality of what's going on on the computer. The thing is it's still the common denominator between different IDEs and text editors. IDEs cannot be used in every situation so any professional developer who uses an IDE also knows his way around with a text editor. If we were to come up with a better abstraction than the file system, it would have to be shared between different IDEs for interoperability. My understanding is that Smalltalk was such an attempt but somehow that aspect of it didn't really spread. Are you aware of current progress being made in this area?
Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @05:33PM (#29283483)
I did that for many years, then I switched to languages with good static analysis and felt really silly about how many years I had wasted wandering around in darkness.
Re:Where is Ruby Headed in 2021? by Raphael on Friday November 19, 2021 @02:11AM (#29274606)
Would a Ruby IDE be able to figure it out?
Re:Where is Ruby Headed in 2021? by t-writescode on Friday November 19, 2021 @02:33AM (#29274739)
In my experience on a IntelliJ with Ruby extensions (so working like RubyMine), no.

Input and output parameters on a program with hundreds of thousands of lines becomes .. rough, to say the least. DryStruct has helped a lot; but several teams working on a single codebase with their own opinions of method calling patterns evolved over several generations all in a single codebase, and it’s … rough.

Re:Where is Ruby Headed in 2021? by sanderjd on Friday November 19, 2021 @05:38PM (#29283534)
RubyMine was impressive (because it's a hard problem) but still hit or miss when I was writing Ruby about 5 years ago. It may very well have improved a lot since then!
Re:Where is Ruby Headed in 2021? by prescriptivist on Friday November 19, 2021 @12:11AM (#29274037)
Those are fair points, but I just kind of hold the entire program space in my head. I work on a pretty large and complicated Rails app that does real world things (handle money, deal with people and companies, etc) and it's daunting at first but after a while it's sort of become one big system of objects interacting with other objects in a global objectspace and that's how it exists in my head.

I think for people that come to love Ruby it feels more natural to think about a program that way as opposed to thinking about a purely lexical context of a piece of code.

Re:Where is Ruby Headed in 2021? by valenterry on Friday November 19, 2021 @12:39AM (#29274186)
I think this is actually a very efficient way of programming. but it doesn't scale in project size and team size. Similar for Lisp. This is why these languages are really good for prototyping, but not as good anymore for big, longterm projects imho.

That's also why I don't think it's a great idea to add types etc. to programming languages like python or ruby. They are not made for this and they should focus on what they do well. Use the right tool for the job, don't try to make every tool being able to be used for the same task.

Re:Where is Ruby Headed in 2021? by chrischattin on Friday November 19, 2021 @05:51AM (#29275897)
This is just not true. There are several multi-Billion dollar public companies with millions of users and thousands of employees built on Rails.

In fact, the philosophy of convention over configuration et all makes Rails MORE scalable and easier to onboard new people than anything else out there that I’ve seen.

Re:Where is Ruby Headed in 2021? by jack_riminton on Friday November 19, 2021 @06:23AM (#29276086)
I agree, the convention means there are very straight-forwarded places to look for things

I recently worked on a Rails project for someone who didn't like to create scaffolds, models or controllers for small things, thinking that it would add to the bloat. But conceptually it makes everything 10x times easier and faster to find and understand

Re:Where is Ruby Headed in 2021? by oblio on Friday November 19, 2021 @07:26AM (#29276475)
Well, you'd better not check what happened to all those Rails apps when those companies grew.

There are soooo many blogs about migrating away from Ruby, adopting Go, Scala, whatever statically typed thing.

There's a reason even Ruby is getting a proper static type system.

Re:Where is Ruby Headed in 2021? by aantix on Friday November 19, 2021 @11:30AM (#29278958)
RoR is the most popular choice with Y-Combinator companies.

Its productivity is simply hard to beat.

Most of these companies are unicorns or public. https://spreecommerce.org/ruby-on-rails-most-popular-among-t...

Re:Where is Ruby Headed in 2021? by oblio on Friday November 19, 2021 @11:46AM (#29279175)
Dropbox literally hired Guido for a while and sponsored a performance oriented fork of Python.

I doubt they can be listed as a Rails success story.

Re:Where is Ruby Headed in 2021? by ksec on Friday November 19, 2021 @04:57PM (#29283112)
I dont think Dropbox even use Ruby. They have been a Python shop since day one?

Stripe doesn't use Rails either. That was a pretty bad article. And it is somehow from Spree.

Re:Where is Ruby Headed in 2021? by wavesplash on Friday November 19, 2021 @08:12AM (#29276765)
Um, really? Why are unicorns like Shopify or Github are still using Rails if that's the norm?
Re:Where is Ruby Headed in 2021? by golergka on Friday November 19, 2021 @10:46AM (#29278347)
The same reason Facebook uses php: that's what they started with and it's prohibitively complex, expensive and risky to change at their scale.
Re:Where is Ruby Headed in 2021? by joelbluminator on Saturday November 20, 2021 @08:11AM (#29287773)
Shopify is not a unicorn...sorry for nitpicking. Its a publicly traded company worth 210 billion dollars. It used to be a unicorn a long time ago.
Re:Where is Ruby Headed in 2021? by oblio on Saturday November 20, 2021 @03:27PM (#29291554)
Now that I think of it, are there any major startups launched post Rails glory days? Some time around and before Rails 4.0, so 2013.

Almost all the major former startups that I could find are from 2010 or earlier.

Re:Where is Ruby Headed in 2021? by montblanc on Sunday November 21, 2021 @09:37AM (#29296441)
Depends on your definition of major. For a company to become a unicorn it usually takes 7 years (not sure on the number but it keeps changing). So many companies formed in 2015,16...+ aren't there still. Looking in Linkedin for Rails jobs there are a lot, not all of them are old companies. Gitlab is a very famous name(2014) but it too IPO'ed so it's not a startup anymore.
Re:Where is Ruby Headed in 2021? by oblio on Tuesday November 23, 2021 @05:29AM (#29316303)
Gitlab definitely counts ;-)
Re:Where is Ruby Headed in 2021? by prescriptivist on Friday November 19, 2021 @12:18AM (#29274072)
Which isn't to say lexical scope isn't important in a ruby program -- it's paramount, especially for resolving constants -- it's just that after a while it's not that big of a deal that there is some ambiguity about where things come from. For me it's one of the most intuitive languages I've ever worked with but it requires a sense of intuition that is learned over time, as contradictory as that sounds.
Re:Where is Ruby Headed in 2021? by regularfry on Friday November 19, 2021 @09:10AM (#29277259)
It also requires a certain sense of confidence that whoever named that method you're calling gave it a good name. Fortunately (and not, I think, coincidentally) the ruby community has always tended towards good naming being really important.
Re:Where is Ruby Headed in 2021? by llamataboot on Friday November 19, 2021 @08:24AM (#29276874)
Explicit programming is more readable, but can result in a lot of boilerplate. "Magical" programming is much more intuitive once you know where the magic comes from but can be maddening to debug. Any framework large enough to be useful starts abstracting away implementation details.

I've found that people that gravitate towards Ruby enjoy meta-programming. The running joke is that you're not a Ruby programmer until you've decided that you should write a DSL. Like everything, clever programming has its tradeoffs.

These days no one reads the source code of every method they call until something is not working the way they expected it to.

Personally, I find the JS ecosystem that absolute worst for this because of the amount of imported code to layer basic functionality on top of the standard library.

If you've worked with rails long enough - well at that point things like Devise are probably in your mental model of how they work.

Personally I still find the large unbridgeable chasm between Python 2 and 3 to be a large friction point in the ecosystem. But if I worked in Python a smuch as I worked in Ruby, I may find Ruby more troublesome.

The simple fact is all languages are getting better. The best tool is not always the one that would be best for the job, sometimes it's just the one you know best. And the tradeoffs we make for ease of programming and abstraction can then turn around and mean we are pushing megabytes of JS over the wire when we don't need to, and now we are trying to solve that with more explicit inclusion and automatic tree-shaking in build pipelines etc.

It's all good. Every tool has two edges. I'm much happier to see people continue to engage with this edges are figure out how to make them more effective than to always argue about which edge is sharper.

Re:Where is Ruby Headed in 2021? by horsawlarway on Friday November 19, 2021 @11:12AM (#29278678)
Magic requires memorization.

Memorization is not consistent between teams/team-members.

Memorization is also the fastest skillset folks lose if they step away from the language/toolset for a while (it degrades rapidly)

Worst of all - The RoR ecosystem (6 versions in) requires memorization about which set of things you need to have memorized for this specific version of the framework.

I'll take some boilerplate code EVERY FUCKING TIME. The magic becomes a curse.

Re:Where is Ruby Headed in 2021? by joelbluminator on Saturday November 20, 2021 @08:15AM (#29287795)
What framework are you using then? Rails is pretty intuitive and easy...I am biased yes but nothing I saw from Spring or Django made me think they made more sense than Rails. The whole Bean thing is pretty crazy. Django is an over engineerd Rails from what I saw.
Re:Where is Ruby Headed in 2021? by epidemian on Friday November 19, 2021 @10:27AM (#29278134)
> Without those imports, how will people reading the code find the definitions? How will they track down the source code for all the methods being called?

I think in dynamic languages like Ruby and Python, there are two very different cases that we need to distinguish when thinking about this.

The first one is global references to modules/classes/functions. For example, in Python you may write:

  import my_module
  
  foo = my_module.Foo(some_arg)
So, if you wanted to find the definition of that my_module.Foo() reference, it's easy: go to the definition of my_module and search for the Foo class/function definition.

In Ruby, you may see instead something like:

  require 'my_module'
  
  foo = MyModule::Foo.new(some_arg)
Which looks very similar to Python, with the difference that the `require` method doesn't assign any local binding, but just executes the file my_module, which in turn will modify the global namespace directly and make `MyModule` available at runtime. The `require 'my_module'` might not even be present on the file that's then using `MyModule`: it might be indirectly required by another module that this file uses. Or, in the case of using Rails or any framework with auto-imports, the file might not have any `require` calls at all!

So, how is this resolved?

By convention, basically. If you see a reference like `MyModule::Foo` and want to see the definition of that, the convention is that that definition will live under my_module/foo.rb, so you can go to that file with some confidence that you'll find the the code for that class there.

So, if the convention is strong, and people follow it, this is basically a non-issue, and the go-to-definition can be done as easily as in Python, with or without an intelligent IDE.

---

The second case is when you have a dynamic reference to an object/function/whatever, like:

  def do_something(arg):
    arg.foobar()
In this case, neither Ruby nor Python (or any dynamic language in general) will help you much in trying to find the definition of the `foobar` method, as the type of the argument will only be known at runtime at the moment that this function will be called, and can even vary between calls.

There are different ways to make this go-to-definition somewhat more ergonomic than a global search for `def foobar`. But on the language level, i think both Python and Ruby are basically the same in this case: not very helpful. We then compensate by using good naming conventions, type annotations/comments, or using powerful IDEs that analyze the code to make good guesses about who is calling what.