Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

71–80 of 187 posts

Re: “Did you mean?” Experience in Ruby

#71

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 have exactly this frustration as a person coming from static languages (mostly C++) to web dev. Anybody can recommend something more comfortable? I like the concept of Vaadin, but I'd prefer something non-Java.

Re: “Did you mean?” Experience in Ruby

#72
post #20

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

C++ and Java are statically typed. If you're referring to dynamic polymorphism , then yes, it can be a pain in the ass.

I'm aware they are statically typed, I meant it in reference to people who hate static typing based on their opinions of Java and its relatives.

Re: “Did you mean?” Experience in Ruby

#73
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.

I'm pretty sure this line of thinking led to us having horribly misguided features like ASI (automatic semicolon insertion) in javascript today

Re: “Did you mean?” Experience in Ruby

#74
post #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 b…

I like this approach, and I think that we're not doing it enough. Does anyone know an effective way to do this in the browser, with JavaScript?

I do this a lot in the JavaScript console. If I need DOM interaction, I'll usually just mock-up some HTML and access it via the file:// protocol.

Re: “Did you mean?” Experience in Ruby

#75
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.

So, you want programming to be more like writing html in the Quirks Era

Re: “Did you mean?” Experience in Ruby

#76

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.

Which becomes ironic because you end up writing way more text into the file for phpdoc then you would have if it were a static language to begin with; and you end up treating the variables as static type anyway! :|

Re: “Did you mean?” Experience in Ruby

#77
post #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 b…

And with Ruby, especially since you mention Smalltalk, we have a tool that is getting closer to the kind of live introspection and modification that Smalltalk is famous for: Pry [1].

Pry lets you call "binding.pry" anywhere in your program to dump you into a shell within that context, with full access to local variables etc.. And tab-completion and plenty of introspection features. I frequently find myself triggering Pry in the middle of handling http requests if something doesn't work, for example. Letting me inspect the environment, modify stuff, and when I exit the request is completed.

It can also do things (with some limitations) like bring up an editor to where the current method was defined, and let you edit and reload the code.

And you can attach to it remotely using Drb in case the app in question doesn't run attached to a terminal.

At this point it's almost criminal to do Ruby development without Pry.

[1] http://pryrepl.org/

Re: “Did you mean?” Experience in Ruby

#78
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.

Admittedly I haven't tried every editor, but it seems nicer than most.

Re: “Did you mean?” Experience in Ruby

#79
post #58
post #53

Earlier quoted context omitted.

Funny that you mention Smalltalk, because of its image model, completion usually works quite well. I remember using it on my Smalltalk days at the university in 1996.

It works great if either A. The IDE lives inside the same live image the project being developed is loaded in; or B. there exists some sort of network/RPC-exposed "code server" running within the live image, which you can ask to do these sorts of completions. Of non-Smalltalk languages, the only one I can think of with anything like that is Erlang. You could easily enough build a code server in Ruby, but you'd have t…

> You could easily enough build a code server in Ruby, but you'd have to explicitly include the library that implements it in your project, and start up a server thread to expose it to an IDE that wanted to talk to it, etc.

Take a look at Pry's remote sessions: https://github.com/pry/pry/wiki/Remote-sessions

Re: “Did you mean?” Experience in Ruby

#80
post #71

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 have exactly this frustration as a person coming from static languages (mostly C++) to web dev. Anybody can recommend something more comfortable? I like the concept of Vaadin, but I'd prefer something non-Java.

Scala is a wonderful language for web dev, particularly if you've found a JVM library you like (the interop is very good). The conciseness and readability (if you stick to the right libraries) of Python with the safety and IDE support of Java. (Can't speak to Vaadin, I'm a big Wicket fan myself)
Post reply on HN