Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

101–110 of 187 posts

Re: “Did you mean?” Experience in Ruby

#101
post #97
post #64

Earlier quoted context omitted.

When I code in Python I always have ipython console handy to try snippets of code and to autocomplete methods and fields.

I also work that way. I use the autoreload feature of ipython so that any code I change in my editor is instantly replicated in my ipython objects. I've really never been more productive in development in my life. Contrast with some Java I was doing recently (granted, without a Java IDE) and I found the whole cycle painfully slow. Even things the compiler picked up were a magnitude slower to find than when I was in i…

Would you mind making a little screencast demo of your workflow? (Or do you know of any?) That sounds so cool.

Re: “Did you mean?” Experience in Ruby

#102
post #22
post #8

I would love it if instead of quitting my program with an error, it just went ahead and called the method it thinks I'm referring to. This would remove a lot of unneeded friction from web development.

There is actually a python module that does something like that. It goes to the extreme to keep the program running no matter the error you make, arithmetic error are replaced with random results, missing functions skipped, exceptions silently swallowed etc etc. It is obviously a joke but they could benefit greatly from this feature ;)

Sounds like the Python equivalent of Visual BASIC's "On Error Resume Next" atrocity.

Except you can find "On Error Resume Next" in "production" code. If I ever consider taking contracts doing Visual Basic, the contract will specify that any occurrence of "On Error Resume Next" automatically doubles my daily rate.

Re: “Did you mean?” Experience in Ruby

#103

I've been pairing with ruby / rails developers since 2010 and coming from statically typed languages, it's unbelievable how much time gets spent playing "guess the method name". Even in rich IDEs like RubyMine, the utter lack of context in any given file in rails leaves programmers typing their best guess of a method name, running the tests, rinse, repeat. This solution, while creative and laudable, solves a problem…

I personally also find ruby to have uniquely poor naming - lots of similar methods with overlapping functionality, no consistent style, etc.

That's not to say it's a bad language per se, but as someone who works in lots of different languages, I find ruby to be the one where I'm most likely to fail to guess correctly and have to spend time looking up the method I want.

Re: “Did you mean?” Experience in Ruby

#104
post #97

Earlier quoted context omitted.

I also work that way. I use the autoreload feature of ipython so that any code I change in my editor is instantly replicated in my ipython objects. I've really never been more productive in development in my life. Contrast with some Java I was doing recently (granted, without a Java IDE) and I found the whole cycle painfully slow. Even things the compiler picked up were a magnitude slower to find than when I was in i…

Would you mind making a little screencast demo of your workflow? (Or do you know of any?) That sounds so cool.

Sure. I'm not near my machine for a couple of days but I'll post something when I get the chance. I see your contact info is in your profile so will ping an email when done.

Re: “Did you mean?” Experience in Ruby

#105
post #97
post #64

Earlier quoted context omitted.

When I code in Python I always have ipython console handy to try snippets of code and to autocomplete methods and fields.

I also work that way. I use the autoreload feature of ipython so that any code I change in my editor is instantly replicated in my ipython objects. I've really never been more productive in development in my life. Contrast with some Java I was doing recently (granted, without a Java IDE) and I found the whole cycle painfully slow. Even things the compiler picked up were a magnitude slower to find than when I was in i…

"without a Java IDE"

This was your problem. Programming Java without an IDE that recompiles your changes on the fly is just so arcane and really slows you down as you noticed.

Re: “Did you mean?” Experience in Ruby

#106

I've been pairing with ruby / rails developers since 2010 and coming from statically typed languages, it's unbelievable how much time gets spent playing "guess the method name". Even in rich IDEs like RubyMine, the utter lack of context in any given file in rails leaves programmers typing their best guess of a method name, running the tests, rinse, repeat. This solution, while creative and laudable, solves a problem…

It's not a problem that can be solved for a language like ruby without adding type hinting (and probably interfaces) to the language. FWIW php actually does support this.

You don't need (static) type hinting, you can do the same with running a dynamic environment and querying it. That's how it's done in Smalltalk (see Pharo), some Lisps and so on.

Re: “Did you mean?” Experience in Ruby

#107

I hope somebody forks this and creates a version that automatically corrects the method for you at runtime. Why even show an error or throw an exception? Bonus if the corrections are cached for performance.

What a horrible idea - what if the suggested method wasn't the intended one?

Re: “Did you mean?” Experience in Ruby

#108
post #36
post #35

Earlier quoted context omitted.

Seriously. Is there a good list of tools that provide it? In Python, the only one I've managed to love is PyDev. Supposedly Atom does it with the "script" package?

For Python I use jedi.el for Emacs ( http://tkf.github.io/emacs-jedi/latest/ ). There's also anaconda-mode ( https://github.com/proofit404/anaconda-mode ).

Jedi is really good. There are plugins for Vim (of course) too.

Personally I believe that things like Jedi - external static code analysers in form of a library - are what we should be doing. It's not good for IDE writers - it lessens vendor lock-in - but for the users it's a win. Having the same, very good, completions in both Vim and Emacs made my life much simpler.

Re: “Did you mean?” Experience in Ruby

#109
post #93

I've been pairing with ruby / rails developers since 2010 and coming from statically typed languages, it's unbelievable how much time gets spent playing "guess the method name". Even in rich IDEs like RubyMine, the utter lack of context in any given file in rails leaves programmers typing their best guess of a method name, running the tests, rinse, repeat. This solution, while creative and laudable, solves a problem…

It's a hard problem to solve. In general inferring which methods are valid on any given variable or expression is undecidable. So you have to make an approximation, which is hard and the end results usually still disappointing. Here's a little test case: def foo(x): return x a = foo("hello") b = foo(34) To infer the methods that you can call on `a` and `b` you have to trace through the `foo` function. You can't just…

> In general inferring which methods are valid on any given variable or expression is undecidable.

And yet, Hindley-Milner can do it. In general.

I've been working with dynamic and nontyped and weak typed and duck typed languages for over half of my life and you know what, it's getting ridiculous. They were never meant to support the team and project sizes we're forcing them into now.

Re: “Did you mean?” Experience in Ruby

#110

Earlier quoted context omitted.

It's not a problem that can be solved for a language like ruby without adding type hinting (and probably interfaces) to the language. FWIW php actually does support this.

You don't need (static) type hinting, you can do the same with running a dynamic environment and querying it. That's how it's done in Smalltalk (see Pharo), some Lisps and so on.

You could guess, but it wouldn't work in cases where, for example methods are added to a class dynamically and non deterministically as a side effect of some other operation.
Post reply on HN