[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ::scr Touchy Feely?



On Tue, Oct 29, 2002 at 10:26:27AM +0000, Piers Cawley wrote:
> Mark Hulme-Jones <ture@xxxxxxxx> writes:
> >>From the perspective of someone who, until recently, wrote mainly in
> > dynamic languages (Perl and Ruby), but now works with a staticly typed
> > language (Java), I can't say that I've found the transition too
> > painful.  Yes, there's a lot of extra a bit more to type (or rather,
> > to get my editor to complete for me), but the type information is put
> > to great use by Intellij IDEA when it comes to refactoring,
> > code-completion and syntax-checking.  Before I saw what's possible
> > with this, I dismissed typing information as a waste of space.  I'd
> > love to see implement the same sorts of features in an editor for a
> > dynamic language, if only just to see if its possible. 
> 
> Well, I know that the 'extract method' refactoring is possible in Perl
> because I've done it (but only to proof of concept level, not to the
> point where I've written a UI for it) in Perl. And the original
> Refactoring Browser was written in and for Smalltalk, which is
> splendidly dynamic. 

Yeah, I've seen the RB in Smalltalk, and was suitably impressed.  The
type information might make it easier to implement the refactoring
stuff, but the sort of thing I can't imagine being possible without
out it would be some of the code completion stuff.  eg.

void foo(SomeClass obj) {
    obj.<Press completion key>

Then you get given a list of the methods in the SomeClass class to
choose from.

Or if you had:

int i = obj.get<Press completion key>

It's able to return a list of all the methods that start with 'get'
and which return an integer.  Very, very useful indeed.

IDEA also uses the type information to show you syntax errors before
you even get to the compilation phase.  It'll squiggly-red-underline
any calls to non-existent methods, any parameter type problems,
incorrect number of arguments, non-existent class and variable names,
and probably a few more that I can't remember.  This has meant that,
99% of the time, my code is syntactically correct before I even get to
compiling it.  This removes one of my principal objections to type
checking, namely that a big compile can result in a lot of irritating
type-checking errors, often forcing you to go through tens of
edit->compile attempts.  It's amazingly nice to be able to get
everything compiling first time around.

IDEA was also the first non-Smalltalk IDE/editor I've seen that does a
proper 'Find usages' search on methods and so on, another thing that
makes refactoring tremendously easy. (I confess I haven't looked at
too many other editors though, since I basically live in Emacs the
entire time I'm not using IDEA).

On the other hand, it's probably worth noting that some of the
refactorings that IDEA needs to implement are *because* of parameter
typing (eg. Change Method Signature).

> > I have to agree that there's too much repetition though, and all
> > those type casts in Java are foul...
> 
> There's too much repetition in my language of choice (Perl) too. But
> I'm hoping that'll get fixed in Perl 6. 

Not having proper function signatures never helped Perl, IMHO, but
that at least is being resolved.

> I keep coming back and looking at Smalltalk and thinking 'this is
> just *right*!' I guess I need to find myself a nice, substantial but
> 'closed' project to do in Smalltalk to try and really get the hang
> of the tools.

Smalltalk is a really lovely language, it's true.  I spent several
months playing with it last year, but ultimately never really got
anything done with it.  It's wonderfully easy to get lost playing away
browsing through all the classes, perhaps too much so...  As I said
elsewhere, the editor/single image problem really put me off, though
perhaps the biggest problem is its age.  Lacking things like regular
expression and standard socket libraries is a pain, and support for
writing web applications is largely dependent on how much you're
prepared to pay one of the vendors (Squeak aside that is).  I also
need a Smalltalk project before I discard it forever though...

-- 
Mark Hulme-Jones < ture@xxxxxxxx >