Live data from Hacker News

“Did you mean?” Experience in Ruby

yukinishijima.net

91–100 of 187 posts

Re: “Did you mean?” Experience in Ruby

#91
post #48

I think this is an amazing gem. And I'm eager to use it on my Rails projects. On a side note, am I the only one who feels that autocomplete tend to get in the way when I'm coding?

The trick is to actually use it. If you auto complete then your coding should be typing 2-3 characters, hit enter, 2-3 characters, enter and so on. It should feel like you're entering hotkeys not typing.

Only real typing should be defining variables and methods.

Your coding speed can go way up depending on how good the autocomplete is.

Re: “Did you mean?” Experience in Ruby

#92
post #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

Except for in for loops semicolons don't really do anything though. The job of the semicolon could easily be replaced by just a white space character.

Re: “Did you mean?” Experience in Ruby

#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 run `foo` because what if the input is unknown or what if `foo` contains a loop or is recursive?

    def foo(x, i):
       if i == 0: return x
       else: return foo(x, i-1)
    
    i = int(read_input())
    a = foo("hello",i)
    b = foo(34,i)
It gets even worse when you have a huge codebase, monkey patching, eval, and other features like that (which Rails uses in copious amounts).

Re: “Did you mean?” Experience in Ruby

#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 keeping around, and we should only retain the live image.

In which case we need tools to version and diff and branch a live image.

Does a programming environment like that exist I wonder? Or do image based environments like Smalltalk let you export an image as text, like a DB can dump all the SQL required to recreate it?

Re: “Did you mean?” Experience in Ruby

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

Ah, the mentality of the web: "I don't have time to get it right, just keep spewing code!"

Re: “Did you mean?” Experience in Ruby

#97
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 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 ipython. And then there were plenty of things the compiler wouldn't get, which could take a good minute for me to discover from the time I made the edit. It's insane to me that people don't work in a REPL.

Re: “Did you mean?” Experience in Ruby

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

This gem does just that:

https://github.com/markburns/fuzzy

Re: “Did you mean?” Experience in Ruby

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

You should implement a `yolo` gem to support this.

https://github.com/markburns/fuzzy

Re: “Did you mean?” Experience in Ruby

#100
post #71

Earlier quoted context omitted.

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.

Try Go. It is a lot like C and compiles to concurrent machine code. It is also very easy to learn and use.

Go has some potential (I'm still waiting for Gen/censored/ics :)). Also, I'm particularly interested in components based web frameworks, and there seems to be none so far - last time I found GWT like library for Go, but it is undeveloped/dead I think.
Post reply on HN