Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

31–40 of 187 posts

Re: “Did you mean?” Experience in Ruby

#31
post #24
post #3

This sort of stuff should, at least in the 'easy' case be done at the editor level. Doesn't ruby have linter tooling for this? Still, props for the work.

Ruby has a linters, but this sort of problem is hard to solve with a linter in a dynamically typed language. It's even harder in a Rails environment since Rails adds many methods to your classes at run time.

Yeah, since it's a dynamically typed lang with inheritance and late binding, doesn't performing static analysis on Ruby code to determine whether a method is defined or not, basically require a solution to the halting problem?

I'm under the impression that you have to actually execute Ruby code to find out with certainty where the methods it calls are defined.

Re: “Did you mean?” Experience in Ruby

#32

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 kind of silly, the major benefit of using Ruby (or JavaScript nowadays) is to iterate quickly. But then, some of their users spend months turning a text editor into an IDE just to waste precious hours on spelling errors.

Re: “Did you mean?” Experience in Ruby

#33

The value of static typing is more and more apparent. Recently I've played with ocaml and F# and it felt great compared to Java or C++.

... until you start trying to make your app testable. (I say this as a developer of primarily statically typed languages.)

Could you elaborate?

Re: “Did you mean?” Experience in Ruby

#34
Some years back I put this feature in both the Digital Mars C/C++ compiler and the D language compiler. It's turned out to be popular and very useful.

Compiler error messages are steadily improving from mere statements of what is wrong to suggestions for corrective action.

Re: “Did you mean?” Experience in Ruby

#35

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…

Context sensitive auto-complete is a godsend.

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?

Re: “Did you mean?” Experience in Ruby

#36
post #35

Earlier quoted context omitted.

Context sensitive auto-complete is a godsend.

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

Re: “Did you mean?” Experience in Ruby

#37
post #35

Earlier quoted context omitted.

Context sensitive auto-complete is a godsend.

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?

I've been working with PyCharm [1] a lot lately and I've come to like it a lot. Probably the best context awareness I've seen for any dynamic language - it (almost) feels like working in something more tool-friendly like Java in that regard.

[1]: https://www.jetbrains.com/pycharm/

Re: “Did you mean?” Experience in Ruby

#38
post #19

The value of static typing is more and more apparent. Recently I've played with ocaml and F# and it felt great compared to Java or C++.

Aren't Java and C++ statically-typed as well?

> Aren't Java and C++ statically-typed as well?

Yeah, but not so you'd notice, coming from an ML or Haskell background. /sarcasm

More seriously, Java and C++ (and C and Algol before them) fell into the trap of defining "data size specifications" as types: The discontinuity between "long long int" and "int" is one, as is the discontinuity between "float" and "double".

The real type difference is between things which are semantically different, like "numeric value used to represent age in years, rounded to integral value", "numeric value used to represent age in days, rounded to integral value", and "numeric value used to represent weight in pounds, rounded to nearest hundredth". Foogol (Algol-derived) languages largely only got this when they embraced Smalltalk-style OO, and they kept their size specification pseudo-types, just to muddy the issue.

Size specifications are useful when defining a wire protocol where the overhead of reading and writing an ASCII format with non-trivial syntax would kill your application, such that you need network-header style bits-on-the-wire protocol, and in file formats with similar constraints, but they're ultimately a low-level implementation detail.

The way this interacts with tooling like editor autocomplete is that editors can do more for you when they know what kind of data you're passing around, as opposed to just how big it is and other trivialities.

Re: “Did you mean?” Experience in Ruby

#39

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.

Re: “Did you mean?” Experience in Ruby

#40
A lot of people are recommending IDE-like tooling--but in truly dynamic language (one with a "living image" with path-dependent monkey-patched behavior that can't be replicated during static analysis, like Smalltalk--or, sometimes, Ruby) there's a more idiomatic way.

In a dynamic language, if you're at all unsure of what code you need to write, then you don't write it in your editor in the first place. Instead, you build the expression you need, interactively, at the REPL—and then, once it works, you paste that into your editor.

In dynamic languages, the "dead" code in modules is effectively a coagulation of previously "live" REPL incantations; to trust code that was written "dead" to work correctly "live" is madness (or just a recipe for really long iterations involving unit tests.)

If you take this approach far enough, though, you do get a sort of IDE—something that manages your expression experiments and the context harnesses they need, and re-runs experiments when you edit their dependent formulae. I am, of course, talking about "notebook" interfaces like IPython's.

Post reply on HN