Friday, February 27, 2009

Compiling GWT in GWT?

Um, just wondered today if it would be possible to use GWT's Java-to-JS compiler to compile the GWT compiler itself? Maybe the result would be too huge anyway, but if it worked you could easily push Java compiling into the browser itself. Could be great for Java tutorials, among other things.

Thursday, February 26, 2009

Hacking Up Statistics for Fun and Profit

The more I'm learning about inference and learning, the more I'm convinced that statistics is the "correct" way. My subject goes beyond statistics, too. For example, if you want to maximize something, you take the derivative and set it to 0 (and look at the second derivative to be sure you have a max and not a min or saddle point).

In contrast to this, some machine learning is full of hacks that seemed like good ideas at the time: neural networks, decision trees, and so on. Many algorithms seem ad hoc. Now I'm being someone over-the-top in my assessment. Lots of those folks have been more formal than I ever really want to be. But it's also so removed from traditional techniques at times.

Well, my current conjecture is that if there is a "right" way to do something (and that's a strong statement in algorithms), you should still be able to see how well your "hack" approximates to it. And meanwhile, it might be fun. And, you might still do well enough but be faster or have other desirable properties absent from the right way.

Well, I'm speaking from ignorance anyway. Just some thoughts on my mind.

Friday, February 20, 2009

Can Has Build ... Again

Well, since javablogs.com was broken, and I'm not sure how to get them to push my entry through, and I actually want people to read this entry (looking to get others thinking about it if at all possible), here's another post just to link to my Can Has Build system description.

Summary, the idea is to beat out Maven for easy conventions and to beat Ant for reliability and low dependencies. As in, win each of those categories big time.

I could have missed it, but I haven't heard of any other Java build systems that work like this one.

So like, here's the link again. Please read and comment (and make it for me?) if you have the time. Thanks much.

Thursday, February 19, 2009

Can Has Build for Java

While not sleeping this morning, I thought through some ideas I'd had in the past on build systems. Ant is too manual, and coding in XML is a pain. Maven is too unreliable, and it sure requires a lot of configuration and magical incantations for a convention-based system. I want minimal dependencies, real convention-over-configuration, and a sane way to extend.

For the moment, I'm affectionately calling my (hypothetical) system "Can Has Build". Here's what a basic project directory structure looks like:

project-name/
build.jar <-- the Can Has Build main jar (which is very small and executable)
lib/ <-- jars needed for build and at runtime go here
src/ <-- source folder for which the class files will go in your jar
test/ <-- source folder for unit tests


After running the build (which by default does a clean build all, since your IDE is probably doing incremental compiling for play-as-you-go anyway; I think build systems are primarily for making a final product, so it's all right to be slow):

project-name/
build.jar
lib/
out/ <-- not 100% sure what to call this ("test" and "target" both start with "t")
project-name.jar <-- or maybe project-name-SNAPSHOT.jar
test-results/
...
src/
test/


All you need for this to work is a JDK and "java -jar build.jar". Can Has figures out everything else on its own.

Say you want to specify a version number? Then add a "project.xml" under your project dir:

project-name/
project.xml
... all else as before ...


Why XML? Because I know XML better than properties files, and I think most other devs do, too, and it allows for hierarchical data if needed, but to give an idea of what I think would go in here at first, here's an example:

<project
name="Can Has Build"
jar-name="build"
version="0.0.0.0.0.0.1-SNAPSHOT"
version-jar-name="false"
main="canhas.build.Builder"
/>


I mean, is that so bad? I can imagine JRE version requirements and so on, too.

So, say I want custom tools in my build such as Test Tool X or Parser Generator Z or Class Bundler/Renamer Q? Or my own custom script? I envision a "build" subdir:

project-name/
build/
lib/ <-- jars needed just at build time
src/ <-- source code for custom build scripts
tools/ <-- auto-registered tools that can filter the automatic build process
... all else as before ...


Or something like that. Again, this is convention-over-configuration. These custom tools should get picked up automatically by "java -jar build.jar".

I've also considered conventions for grouping related projects and easy specification of dependencies between them, but I'll forgo commenting on that right now. In any case, all 3rd-party libraries would need added manually. That's the reliability thing.

So, the summary, Can Has (which doesn't exist, so feel free to make it) has the following features:
  • No dependence on someone else's server being up.
  • No configuration needed for basic builds.
  • No dependencies except a JDK (or just JRE if you bundle your own compiler under "build/").

Saturday, February 14, 2009

Finally Translucent Scrollbars

I'm so happy that Mozilla's Bespin has translucent scrollbars. Maybe been around before (other than in prototype ideas of my own in the past), but it sure hasn't been common, at least.

Maybe it will take a lot of use to see if it's a good idea for sure, but I'm still so happy that someone put it in a (sure to be) high profile project.

USB Microcontroller Programmers on Linux without Sudo

I was doing some microcontroller programming for the first time this week. Found out I had to 'sudo' to use 'avrdude' to write to the programmer on the USB port. Lame. After a couple hours of study learning about udev (and other worse alternatives), I put this in a file I named '/etc/udev/rules.d/85-avr.rules':

ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2104", MODE="0666"

Specifically, that's for the AVR ISP mk II (also called stk500v2).

My question is, why would I ever not want write permission to a USB device attached to my computer? Is that ever a security risk?

Wednesday, February 11, 2009

Don't use System.exit()!

Just a quick comment/plea about the evils of System.exit() (or whatever other equivalents in other languages if they are anything like Java). Really, 'exit' is like a global variable. You think you want to kill the program, but you really don't. The moment you use it anywhere, you've set up a trap that makes your software unusable by third parties. Consider these alternatives instead:
  • Throw an exception.
  • End your thread, but this is a deep subject of itself which is beyond my current scope.
  • For real newbies (or others) working in main() alone, just use 'return'.
Really, please, and based on real-world pain, leave exit() alone unless that's really really really really really really really what you want. The status code might be one reason, but Java really isn't so often used for writing traditional processes. If you do need that, make sure you have your "traditional process" nicely distinct from the rest of your code.

Thursday, February 5, 2009

Reinforcement Learning Competition

Looks like some great problems (ranging from "Infinite Mario" to a helicopter simulator) to work on for this 2009 reinforcement learning competition. If you have experience or want experience programming AI, this could be a bunch of fun. I'm too busy with a mountain of other things, or else I'd probably look at that octopus problem. I just love high-dimensional action spaces.

Side note, looks like they use Java in their software, but not exclusively. I haven't dug deep enough to see everything going on.