Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

171–180 of 187 posts

Re: “Did you mean?” Experience in Ruby

#171

Earlier quoted context omitted.

I stick a 'binding.pry' (pry gem) in the body of the method I'm trying to write, and I trigger it with a test that has all the correct parameters (i.e. the happy path). I then write my code in the REPL. I can use 'ls' to look up available methods dynamically. Complex ActiveRecord queries are much easier to prototype. Finding the right method isn't usually too difficult. And pry supports prefix completion at the first…

I actually follow a very similar pattern when developing in both Ruby and Clojure. I particularly like it in Clojure because I can run `(doc function-name)` to get some documentation on the function I intend to use (I can never remember the order of arguments!!).

I do this a lot in the ipython REPL. You can type "method_name?" and see the docstring and some other basic info about the method (like args), its extremely helpful.

Re: “Did you mean?” Experience in Ruby

#172
post #170
post #167

Earlier quoted context omitted.

This is honestly an issue I don't experience, if I have a typo my test fails and the compiler tells me the line and method call that failed. I correct it, carry on. I can't think of a scenario where you would get stuck with this type of problem.

Compare this with an IDE highlighting this immediately when you write the offending line. In your workflow you have to run a test to identify this issue, then go back and fix it. It certainly doesn't leave you stuck but you are incurring additional overhead in that you actually have to run tests to discover there's a problem and then remediate it.

It's a marginal overhead and it also has the benefit of encouraging clear naming. Autocomplete is convenient but also removes some of the cost of poor naming. This is fine when you're writing code (the autocomplete just kicks in and you search for a method that seems about right) but it does nothing for the readability of your code.

Re: “Did you mean?” Experience in Ruby

#173

Blows my mind that IDEs and environments are not better at this. This is something that computers are good at, pattern recognition and scanning the whole file. Of course the it wouldn't work every time, an could make ridiculous suggestions, but I would love the computer to suggest something every time there is an issue. Even if it is wrong 90% of the time, if those guesses don't slow down the programmer the time save…

Java IDEs are better at this. JavaScript...well I saw NetBeans do it once and was amazed. Ruby...well it's impossible to do correctly as other posters have mentioned.

Re: “Did you mean?” Experience in Ruby

#174

Earlier quoted context omitted.

I stick a 'binding.pry' (pry gem) in the body of the method I'm trying to write, and I trigger it with a test that has all the correct parameters (i.e. the happy path). I then write my code in the REPL. I can use 'ls' to look up available methods dynamically. Complex ActiveRecord queries are much easier to prototype. Finding the right method isn't usually too difficult. And pry supports prefix completion at the first…

I actually follow a very similar pattern when developing in both Ruby and Clojure. I particularly like it in Clojure because I can run `(doc function-name)` to get some documentation on the function I intend to use (I can never remember the order of arguments!!).

The pry equivalents are show-doc and show-source.

They don't always work depending on configuration, but it's very nice when they do. They can even go far enough to show the C source for builtins.

Re: “Did you mean?” Experience in Ruby

#175
post #158
post #105

Earlier quoted context omitted.

"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.

Which is great, but that's almost not the main issue. In the ipython REPL I can work with my code and data at the same time. It's a huge disadvantage to not be be able to probe your data to create a working process.

The Java VM has hot code swapping builtin (IIRC limited to method bodies but the commercial JRebel drops that limitation).

Start your program in your IDE's debugger (or point it to your application server where your program is running) and you can change the code immediately, rerun your methods, change variables, inspect the objects, etc.

It's more than a simple REPL, it's a full-blown debugger and it comes really close to what you have in a SmallTalk image where your code, data, and environment is all the same.

Re: “Did you mean?” Experience in Ruby

#176
post #172
post #170

Earlier quoted context omitted.

Compare this with an IDE highlighting this immediately when you write the offending line. In your workflow you have to run a test to identify this issue, then go back and fix it. It certainly doesn't leave you stuck but you are incurring additional overhead in that you actually have to run tests to discover there's a problem and then remediate it.

It's a marginal overhead and it also has the benefit of encouraging clear naming. Autocomplete is convenient but also removes some of the cost of poor naming. This is fine when you're writing code (the autocomplete just kicks in and you search for a method that seems about right) but it does nothing for the readability of your code.

I would argue that readability and writability of class members are not the same. Many time verbosity will improve the readability but hurt the writability of the code, and auto-complete reduce the cost of this verbosity.

Re: “Did you mean?” Experience in Ruby

#177

Earlier quoted context omitted.

That has been tried before. Results were... poor. http://www.catb.org/~esr/jargon/html/D/DWIM.html

You are correct, but please don't refer to the bastardized version of the Jargon file. Wikipedia has a much better and more accurate article, with actual quotes and citations instead of unsourced politically motivated mythology attributed to "some victims": https://en.wikipedia.org/wiki/DWIM >Critics of DWIM claimed that it was "tuned to the particular typing mistakes to which Teitelman was prone, and no others" and…

That... makes me very sad. I remember the old ESR. Knew that I hadn't heard of him in a long time, did not know he went a bit nutty...

Re: “Did you mean?” Experience in Ruby

#178
post #61

Earlier quoted context omitted.

PyCharm's auto-complete is really nice. It seems to be the best Python editor going right now.

Really? I used Aptana, which includes the Pydev plugin. I notice everyone seems to give PyCharm lots of love, and have been tempted to try it. Autocomplete is one of the features I rely on heavily.

I used Eclispe/Aptana/PyDev at a previous job and it was pretty nice, but PyCharm is superior in my opinion. In addition to great completion and code navigation, it also gets Vim emulation mostly right. PyCharm is also a mostly out-of-the-box experience, whereas it took a while for me to get Eclipse set up just right.

Re: “Did you mean?” Experience in Ruby

#179

Obviously this is a useful tool, and all the power to the author for finding what looks to be an excellent solution, but this line bothers me: >>> Sometimes I wasted hours and hours just because there is one character difference. I hate it. This shouldn't happen. Ever. This should not be a problem anymore. These are the sort of errors that we can catch immediately and should be caught immediately. From looking at the…

A spelling error in http request can cost more hours if using IDE.

Re: “Did you mean?” Experience in Ruby

#180
post #22

Earlier quoted context omitted.

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 ;)

For those who are interested, I'm pretty sure this is what you're referring to https://github.com/ajalt/fuckitpy . It's worth looking into for the documentation alone.

YES! Thank you

    FuckIt.py uses state-of-the-art technology to make sure your Python 
    code runs whether it has any right to or not. Some code has an error? Fuck it.

    FuckIt.py uses a combination of dynamic compilation, Abstract Syntax Tree 
    rewriting, live call stack modification, and love to get rid of all those 
    pesky errors that make programming so hard.

    Still getting errors? Chain fuckit calls. This module is like violence: 
    if it doesn't work, you just need more of it.
Post reply on HN