Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

131–140 of 187 posts

Re: “Did you mean?” Experience in Ruby

#131
post #76

Earlier quoted context omitted.

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! :|

PHP5 has real type hinting in the language, so you don't need to write any more than you would in Java.

And soon it'll even have return typing, should that RFC pass.

Re: “Did you mean?” Experience in Ruby

#132
post #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 changed my life for Rails development. Before it I was still using IRB and attempting to just log things to the terminal constantly to figure out what I could do. Pry has made me 2x as fast (if not more) as a Ruby developer.

Re: “Did you mean?” Experience in Ruby

#133
post #64

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…

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

I do something similar with JavaScript and code functions in a REPL and then move the code into my actual file as soon as I get it working. Usually I do this with Google Dev tools console.

Re: “Did you mean?” Experience in Ruby

#134
post #87

Earlier quoted context omitted.

PHP5 has real type hinting in the language, so you don't need to write any more than you would in Java.

phpdoc handles much more than just typing function parameters.

By far the most common usage is parameters and return values. Even moreso than comments.

Re: “Did you mean?” Experience in Ruby

#135
post #95
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…

Is it possible that when you try and recreate your image from scratch, the code you have pasted into your editor is not sufficient to recreate the image? Maybe you pasted some things in the wrong order, or maybe you redefined a function, but some data that was created using the old version of the function is still in the image. If this is possible in your programming environment, then maybe the dead code is not worth…

Yes. Smalltalk environments export an image that's a snapshot of the entire state of the VM. It's like a reloadable core dump of the VM. It's a binary though, not plaintext. But there is also a sophisticated distributed versioning system for Smalltalk code, which can save versioned snapshots of slices of your code and state that can be imported into different images: http://wiresong.ca/monticello/

Re: “Did you mean?” Experience in Ruby

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

Just for you! https://github.com/Shervanator/feeling_lucky

Re: “Did you mean?” Experience in Ruby

#138
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…

Yeah, I can't help but think we've reinvented the wheel. Modern dynamic languages like Ruby, Python, JS, Clojure, are just now catching up to the state-of-the-art that Smalltalk achieved in the 1980s.
Post reply on HN