08.28.07

idea for programming tool

Posted in Hacking, programmer productivity, Technology trends at 10:36 am by ducky

As I work, I find myself asking a question over and over “how do I get information from point A to point B?”. For example, “How do I get the position of the active editor from EditorSashContainer into TabBehaviourAutoPin?”

It seems like there is probably room for a tool that figures out a path from point A to point B.

This might also make the code more maintainable — instead of me going and making new methods in the chain from A to B through six intermediate methods, maybe the tool can find a path that goes through only two classes.

I can imagine the tool giving me the shortest path through public methods, and (if it exists) the shortest path that requires private variables or methods. Maybe it would find that there is a private variable that, if I made a public getter, I could use.

UPDATE: my supervisor (“advisor” in the US) pointed me at a paper describing a system (Prospector) to do just that. Alas, I haven’t been able to find any code for it. The code is at here, and there is also a web interface (which knows about J2SE 1.4, Eclipse 3.0, and Eclipse GEF source). The plugin also unfortunately seems to be too downrev for me. 🙁

There is also a tool called Strathcona which does something sort of similar — it finds examples of existing code that goes from A to B. I don’t think that would have helped me with the specific things I was looking for, because I don’t think there was any existing code anywhere that did all of what I wanted to do. It might have helped me get from A to C and then from C to A, however.

08.21.07

meme: non-Indo-European programming languages

Posted in Hacking, Random thoughts at 1:30 pm by ducky

I had a very interesting lunch yesterday with Dan Delorey, who is a PhD student at Brigham Young University and interning at Google Kirkland.  While we covered a wide range of topics, there was one meme of his that stuck with me through most of the (four-hour) drive home:  Almost all of the programming languages today were developed by men whose native tongues were Indo-European languages.  (Obvious exception:  Ruby, by Yukihiro Matsumoto.)

What would a language developed by someone with a non-Indo-European background look like?

What would a language developed by someone whose mother “tongue” was sign language?

I was reminded of something I saw ten years ago: a woman commented that if a woman had invented the WIMP interface,  there would have been two cursors.

08.17.07

robobait: difficulties setting up Eclipse for plug-in development

Posted in Eclipse, Hacking, robobait at 10:40 am by ducky

It took me way longer than it should have to get setup for my current project. I need to change some very fundamental behaviours of Eclipse. There is a plugin that does 80% of what I want, so I need to modify it.

I checked the plugin out of Eclipse’s CVS, but I couldn’t get at the Eclipse source (e.g. when I tried to do F3 or control-click on a class or method). I tried downloading the entire Eclipse source, but

  • I got tons of errors because the projects weren’t set up right to refer to each other, and setting them up by hand would have been a nightmare.
  • Everything got dog-slow.

SOLUTION

It turns out that I needed to first download the plugin from CVS, then convert it to a plug-in project. (Right-click on the project, then select PDE Tools, then select Convert Projects to Plug-in Projects.)

That gave me access to a lot of source, but not all of what I needed. To get other source, I needed to do

File -> Import -> Plugin&Fragments -> Project with source folder

then select the packages that I wanted the source for, Add, and then Finish.

Keywords: eclipse development, all eclipse source, attach source eclipse

08.14.07

semi-robobait: macros in Eclipse

Posted in Eclipse, Hacking, programmer productivity, robobait at 3:26 pm by ducky

Cool! Eclipse has keyboard macros! Eclipse calls them “Editor Templates”, and has a bunch of them predefined. For example, if you type

sysout Cntl-SPACE

it converts that into

System.out.println();

with the cursor in the middle of the parens. Similarly, if you type

for Cntl-SPACE

you’ll get a short menu of options; selecting the first one (“iterate over array”) magically converts into

for (int i = 0; i < array.length; i++) {

}

with the first “i” selected If you type in “fooIndex”, then all the “i”s in the line change to “fooIndex”. Pressing tab takes you to the “array”, where you can then type in the name of the array. Press return, and then you are sent to the middle of the curly braces.

Whoa!

My old housemate, Chris Beekhuis, once set up macros like this and said that it made his coding significantly faster. I’m very much looking forward to using Editor Templates, and am a little puzzled as to why their existence isn’t being shouted from the rooftops. (Or was it? Did I have my headphones in at the time?)

(To see all of the pre-defined macros — or to define your own — go to Window->Preferences->Java->Editor->Templates. Or press Control-3, type “template”, and Editor Templates will be one of the options.)

08.13.07

semi-robobait: way cool Eclipse keyboard shortcuts

Posted in Eclipse, Hacking, programmer productivity, robobait at 12:07 pm by ducky

I found two really cool Eclipse keyboard shortcuts today.

  • Quick Access (Control-3): This brings up a dialog box. Start typing, and it will present a selection list of windows whose title contains the text you just typed. Thus, if you type “expl”, it will present “Package Explorer”, “CVS Package Explorer”, “Project Explorer”, and so on. You can also type the names of the files that you have open, e.g. “foo” to get “Foo.java” as a selection option. (It does not take you to method names or classes, just window names.) Way cool. I think I’m never touching the mouse again. Ever.
  • Word Completion (Alt-/), aka “hippy completion”: When you are editingcode, you can type a few letters, then Alt-/, and Eclipse will fill in the rest of the word with a guess as to what you meant. For example, if I type “Fo”+Alt-/, it might present “FooFactory” first, then “FooTemplate”, then “ForeignFilmDatabase”, etc. When it reaches imagination failure, goes back to the first one. It is case-aware, so it would not present “for” or “format” or “foo”. It seems to be pretty clever about its guesses, too.

08.12.07

robobait: gd library bug – horizontal lines

Posted in Hacking, Maps, robobait at 11:12 pm by ducky

I had had a problem with horizontal lines in my census maps mashups for a long time.  Note the line at the bottom left.

Horizontal line bug

I was sure it was a bug in my code because the graphics library that I used, gd, was extremely mature and heavily-used.  (Way back in 1994 or 1995, my then-office partner Carlos Pero was using gd for Carlos’ Coloring Book!)

It turned out to be a bug in the gd polygon fill code. The fix turned out to be a very small number of lines of code, so if you are having problems with horizontal lines occasionally appearing in your images, look there.

More keywords: libgd, gdlib gd lib, flat, fill polygon, colored polygon, horizontal line, missing line, extra line, flat line, sideways line

census maps mapplets

Posted in Hacking, Maps at 10:53 pm by ducky

James Macgill prodded me to turn my census maps into a mapplet, and so I finally made a census mapplet.

Most of you are probably wondering what a mapplet is. A mapplet is a Google map that has been encapsulated in a way that makes it easy to combine with other mashups. To see them, go to maps.google.com and select the My Maps tab. You’ll see a list of mapplets next to checkboxes.

I’ve been enjoying playing with combining my demographics maps with other mapplets, like

  • population density + sea level rise
  • various demographics + real estate listings
  • % black + Chcago Transit Authority lines

08.01.07

robobait: Prefuse histograms

Posted in Hacking, robobait at 2:02 pm by ducky

I’ve recently been working on showing histograms using the Prefuse framework. I released five files today to help with that:

  • BarRenderer.java — renders x,y coordinates as a bar that goes from x,0 to x,y
  • HistogramTable.java — a Decorator that takes a Prefuse Table object and creates another Table (as a subclass) that has two columns for every column of the source: one column to define the range of a bin and one that says how many objects are in that range.
  • HistogramGraph.java — a JComponent subclass which displays a graph for a bin/count pair of a HistogramTable.
  • HistogramFrame.java — a JFrame subclass which lets you switch between all the data columns in a histogram and also lets you reset the bin count on the fly.
  • HistogramTableTest.java — JUnit4 tests for HistogramTable.

Known bugs:

  • There is a bug somewhere that manifests itself in HistogramGraph. If you select “Species Name” and then “Petal Width”, the first two x-axis labels are species names instead of numbers. I’ve looked at this enough to decide that it is quite possibly a Prefuse bug, and that it was not worth my time to try to fix it.
  • I only recognize two types of column, numeric and string. I don’t distinguish between ints, floats, and doubles. Everything else is a string.
  • I haven’t tested with boolean columns. I suspect that it will treat them as strings, and so it might just happen to do the right thing.
  • I haven’t tested with derived columns. It might accidentally work, but I don’t know.

I encourage people to give me feedback on these. While I’ve done a lot of coding, I am relatively new to Java, so am quite willing to believe that I did something in a suboptimal way.

Administrative note: I’ve made a new category “robobait” for postings whose purpose is primarily to alert search engines to the existence of some other page.  These are likely to be less interesting to human beings.

I’m also going to put “robobait” at the beginning of posting titles for robobait postings.