News for hackers. Stuff that matters.
Re:Sorbet and 100% cov makes Ruby refactoring possible by afandian on Monday April 25, 2022 @04:41PM (#31160324)
I've not written Ruby since about 2006 except with a stint in a Rails codebase which did nothing to give me any faith. How do you go about e.g. extracting a group of fields and renaming them? Or reorder function arguments? Is there a static tool that can do this, or do you have to do some kind of text search and hope you got them all?
Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Monday April 25, 2022 @04:46PM (#31160373)
There's basically no tool for doing that, aside from relying on tests to tell you a callsite is now incorrect. "find and replace" is... okay, up to a point, but obviously that has its limitations (especially once you start metaprogramming).

That being said, I still love Ruby. I have all sorts of little tools written in it that would have been a pain to do in another language.

Re:Sorbet and 100% cov makes Ruby refactoring possible by afandian on Monday April 25, 2022 @05:23PM (#31160815)
Coming from a Clojure background which is … different. But I understand the enthusiasm around similar language features.

But to borrow words from another comment I find Kotlin “ruthlessly productive”. Apart from the lambdas, functions, data classes and immutably, it’s the ability to quickly and correctly refactor that makes me feel like I can work at speed and try stuff out.

Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Monday April 25, 2022 @07:43PM (#31162308)
I wish I could find Kotlin as ruthlessly productive as Ruby, but... I'm having a hard time doing so. It's got nothing to do with the language itself - at work, I really enjoy Kotlin.

Here's where Ruby shines for me: when I'm whipping up a script, I can toss a `Bundler.setup(:default)` at the top of the script, `vim mything.rb`, `$> ruby mything.rb` (or `./mything.rb` if I hashbang at the top), and I'm off to the races.

With Kotlin, it feels like I need to set up a project in IntelliJ, `$> ./gradlew run`, wait 10 seconds for the whole thing to compile, and finally my thing is running.

Is there a streamlined way to run a Kotlin script without building a whole jar, from the command line? I know this is generally not as easy with compiled languages. The D programming language is a notable example that has a "D script" mode (hashbang with `rdmd`), which quickly compiles+runs in a single step.

Re:Sorbet and 100% cov makes Ruby refactoring possible by lbhdc on Monday April 25, 2022 @08:03PM (#31162456)
kotlin has support for being run like a standalone script. I believe the convention is giving them the `.kts` extension.

Here is an example with a shebang https://github.com/Kotlin/kotlin-script-examples/blob/master...

Re:Sorbet and 100% cov makes Ruby refactoring possible by dymk on Tuesday April 26, 2022 @12:22PM (#31169417)
Thank you! The syntax for specifying dependencies was the bit of the missing puzzle piece for me.
Re:Sorbet and 100% cov makes Ruby refactoring possible by Gigachad on Monday April 25, 2022 @07:20PM (#31162120)
The ruby way is you just don’t do that. Or you use named arguments which are unordered.

In most ruby code I have worked with, most non trivial methods use named arguments.

Re:Sorbet and 100% cov makes Ruby refactoring possible by sparker72678 on Monday April 25, 2022 @11:42PM (#31163705)
There are IDEs with this kind of functionality. RubyMine has a fairly robust refactoring tool, for example.