I’d forgotten what a lame pile J2EE is

October 5th, 2008

I’d kind of sworn off doing Java a few years ago but a little contract fell into my lap that seemed like it would be some quick cash for not too much work. I already had a lot of code in the can that would help me do it quickly. Also, I still have IntelliJ 6, which can make Java almost tolerable.

Unfortunately, part of the system required a servlet to handle http requests (using http as an RPC mechanism). I’ve used Jetty in the past with good results so I downloaded it. Despite the existence of a “plugin” for IDEA to work with it, the debugger never worked.

So I moved on to Tomcat. I finally got IDEA configured to use Tomcat, the debugger worked, but the servlet was ignored every time without any kind of error message being logged. Did it fail to link or something (it used a lot of external libs I had to bring in). No clue. I simplified the servlet to just printing “Hi there” and still it refused to load.

This resulted in a refamiliarization with web.xml files and all the rest of it. In disgust I switched back to Jetty. Jetty at least logged the errors to the console and I fixed all the link issues, but still no debug. Back to Tomcat but it still wouldn’t load my servlet at the url I wanted. Eventually, I found the invoker servlet settings, turned that on, and the servlet began to work.

The bottom line is that the entire J2EE architecture, the servlet containers, the zillion xml files specifying garbage I never want to change anyhow, all of it is MUCH TOO FRIGGIN COMPLICATED FOR WHAT IT DOES. Too many descriptors. Too much config. Too much cargo cult xml.

Compare to PHP where I just drop a file in a folder under document root and I’m good to go. Or rails, which is pretty much the same deal – just putting the file in the folder ought to be all that’s required to make the thing work.

I think this will be my last foray into Java hell. At least for a few years until I forget how stupid it all is again.

BaseTen Rocks!

October 3rd, 2008

Like a lot of long time Cocoa developers, I’ve long lamented the loss of EOF for doing database applications. CoreData is lame, too complicated and fiddly for document based development, too light weight for multi-user.

OTOH, EOF wasn’t perfect either. Having been doing Rails, I find I really like ActiveRecord. It strikes just the right balance between SQL and objects and I like its use of the database schema as the primary meta model.

So I was excited to learn about BaseTen. Right now it is PostgreSQL only, but that’s fine – I like PG. It allows for use of controllers and bindings like CoreData, but it is designed for multi-user use and it doesn’t have a separate model file – you just design the schema along with foreign key constraints and start using it. It really is kind of the best of all worlds. Bonus is it wires the database for notifications so applications stay in sync. In autocommit mode – all objects are hot sync’d. Usually this is exactly what you want for small business apps (think less than a dozen simultaneous users).

Definitely makes development of small business database backed apps easy.

Summer of Rails

September 21st, 2008

I’ve now worked on three different Rails applications. One of them was from scratch, the other two I took over from someone else. The thing I like most about Rails is Active Record – it just works and it is easy to use – even for existing databases (although it takes a bit more work to specify the mappings).

I have a project coming up that would probably be a great Seaside candidate. The database has to be postgresql (according to the client). There is a native cocoa component – I’ll probably give BaseTen a try. For the web component, the obvious candidates are Rails (although I don’t know the state of Rails with PG – only mysql), and Seaside/Glorp – but I need to use Glorp to work like Active Record since the DB will be the master source of record for the schema.

Sadly, it doesn’t look like Glorp’s ActiveRecord on Squeak is ready for prime time, I might have to kind of finish that implementation.

JambaLaya development at WWDC

June 13th, 2008

So far WWDC has been very useful. I came with a checklist of about 10 items I wanted to add to JambaLaya but was having trouble with and I got them all more or less knocked out. Among those:

Custom font bundling – there’s some black art here and it took two days to find the guy who knows how that works. It is possible that people downloading JambaLaya have been getting it rendered with really ugly fonts. If you’ve downloaded it and it doesn’t look like the picture, I’d like know because I think I’ve been getting fooled by system installed fonts. Fixed.

JambaLaya Screen

Key indicator highlighting on key range mapping. I couldn’t get this to draw reliably due to threading issues. Fixed. Makes it much easier to see where your keys are because hitting a key on the keyboard animates it in the mapper.

Adding side chain routing to audio unit views – since these are often carbon views (ICK) adding UI is kind of nasty – but someone suggested I stick a drawer on the bottom – cool. It was kind of tricky to get working with carbon window but we made it work in the end. Expect side chaining and other custom add-ons to appear in audio unit views.

Clock and Tempo. For working with things like Stylus RMX adding ways to communicate song tempo and beat clock. JambaLaya will also get the ability to both supply timing or sync to external timing and will get transport controls.

Some other goodies I’m not talking about yet. :-)

Expect 1.1.0 early with all the bugs fixed by next week. New features as I get time.

In other WWDC news, iPhone app development is HOT HOT HOT. I confess to developing iPhone envy looking at how much use people get.

Rails is Magic

May 22nd, 2008

And I hate magic. First, I confess that I probably still don’t have a full command of all ruby’s features – I’m just getting the hang of mixins and some of the wacky compositional capabilities.

I’ve just deployed my first soup to nuts rails application. Well, nearly. It certainly starts fast. Generate ActiveRecord classes for your tables using scripts and you’re off and doing basic CRUD.

However, its the little things that made the experience less than satisfactory. First – the changes in behavior moving from development to deployment were nerve wracking. I have rails running under apache on my laptop, no problem. On my production server, I cannot get byte one to come out of rails. Webrick works fine. Mongrel works. Rails cgi produces no errors, and no output. Even apache logs are totally silent. I don’t get it. For now it is running under mongrel – but I’ll have to put that behind apache and front it using modproxy. Irritating as hell.

Second, I set up memcachedкомпютри втора употреба on the advice of friends and was going to use it for my session cache. But it turns out that objects don’t get saved in the memcached – apparently you can only store plist kinds of structures. Objects get dropped. I spent several hours beating my head against this using the usual hammer for this nail – require_dependency. However, after listing every blessed model class as a dependency, it was still dropping a collection of objects. Back to the file based session cache.

Another thing that drove me nuts is all the magic values you can’t use for attribute names. I inherited this database and admittedly a bunch of columns and tables are stupidly named – however I kept running into problems with collisions with ActiveRecord extensions.

Another thing – camel vs underbar lowercase. You generally specify relationships as lower case names, that ActiveRecord uses to infer a class name. For instance, you specify the relationship as purchase_order and it figures you have a class PurchaseOrder that keeps its data in a table called purchase_orders with a foreign key purchase_order_id. This can all be overridden, but understanding which form to use where got pretty trying.

Reciprocal relationships – at some level of circularity, ActiveRecord falls over with stack level too deep on save. It isn’t even a very complex graph that does it in. It became necessary to remove a bunch of back references to get a save to work properly.

Overall, I’d say towards the end I spent more time debugging magic gone awry than I did building application functionality. So I have to chalk it up as a real learning experience, but not one I’m looking to repeat anytime soon. The lack of decent debugging facilities was really crippling – especially coming from seaside. ActiveRecord is cool, but it isn’t trouble free. Doing basic inheritance was a huge exercise in wackiness I’m not eager to repeat. If I hadn’t had a big old mysql database to build on top of, I probably would have used seaside instead.

So enough slamming – its not all bad. One thing that helped a LOT was the discovery of ActiveScaffold AS is AMAZING! I was able to throw together a coherent admin interface with it very quickly – its customization options are very powerful, and in the end I think the back office app will be about 80% AS and 20% task oriented workflow. That’s brilliant. A data driven sensible ajax interface almost instantly. Very cool.

I may do more ruby apps, there are some seriously powerful go-fast kinds of technologies, but much of the time savings this go-round was lost to flukey behavior that changed from environment to environment, and really lame debugging tools.

Rails is definitely a very mixed bag.

Quick Ruby Thoughts

April 29th, 2008

I have to say I’m liking a lot about Rails. Ruby, not so much. Probably the most annoying thing about Ruby is the syntax. It is MUCH too complicated and after working with it for awhile, I still don’t quite understand all the rules. Things that puzzle me:

dot notation vs non-dot notation. When to use which?

collection.select {| x | x > 5 }

vs

collection select {|x | x > 5}

they both seem to work. Also, use of parens around argument lists – also seems to be optional. Two different block definition syntaxes is also annoying.

Less syntax would be most welcome.

Hoppin’ on the Rails

April 4th, 2008

I’ve got two new clients – on is taking over expansion of an existing Ruby on Rails application. The other is the replacement of the application I wrote in the previous article. I want to stick a new codebase on the existing database. Since rails excels at CRUD and I’m short on bandwidth and hand-off-ability is a concern with the new development, I’m going to use rails for that one too.

I mean, I can only learn so many frameworks at once. So here we go – working through Agile Web Development with Ruby on Rails.

Software Design Tip: Minimize Number of Languages

April 1st, 2008

I was recently asked about taking over support for an existing application. I’ll leave out what it does – suffice it to say it is web based, has a simple 3-5 page UI for the public to buy something, and about a 15-20 page set of back end interfaces for trained customer service and admin people to use. So less than 30 screens overall mKay?

The application was said to be written in Java. I know Java – I don’t like it, but I know it. If its small, I could be persuaded to pick up the maintenance.

However, I got a source drop and I was totally appalled. First, it suffers from the usual Java framework-itus.

Its J2EE – so we got Jetty container. They used Hibernate – so we have generated Java code based on some XML schema files. There’s also a mysql database – which duplicates the information in the Hibernate XML schema files. It uses cocoon – cocoon make use of xml and xsl to define navigation and transformations. There is also reporting that uses xsl. Workflows use flow – more xml only they used the Javascript extension so the workflows are actually defined using server side javascript.

Got all that? We have Spring, Coccon, Flow for Javascript (flowscript), Hibernate, Jetty, Javascript, Html, CSS, SQL, XSL and god knows how many dozens of distinct flavors of XML. For a 25 page web app. Wait, did you notice I didn’t mention Java? There is Java – the Hibernate generated classes are used – but indirectly – they may as well not exist at all since all the application code is some fractured XML or Javascript fragment stashed who knows where.

It seems we’ve lost track of something here. “Locality of Reference” In general, all the stuff that deals with the product selection page ought to be visible by looking into the file representing that page, then maybe drilling into components. The problem here is that, everytime I have to drill down, I have to switch languages. And context switches are bad for programmer productivity – mKay?

I’ve turned down the job. I don’t have time to learn all that junk for this little app. The client needs a new installation – for 25 pages that do mostly CRUD to mysql. If I do it, I’m thinking plain old PHP with an ORM. If I can find an ORM for PHP.

So far I’ve looked at Doctrine (not yet ready for production but it looks cool), Propel – and some others. The really off-putting bit is their slavish insistence on creating the xml mapping file – just like Hibernate. Of course, I have an existing database. The XML file they want is in the db. It just isn’t XML. Still, all the information is available for query – so why are they bothering me with this junk? Read the damn schema and make me some classes. I’ll eliminate the many to many mappings by hand. Sheesh. No wonder there’s a software crisis.

Hey framework people, stop making me write monkey code – figure out how to eliminate extra work – not make it. One meta model is enough.

Who do ya gotta do at Google

March 25th, 2008

Google wouldn’t know harmful content if it sucked them off for $50.

Google! Fix this stopbadware flagging nonsense!

They are totally unresponsive despite repeated requests for review. They don’t even mention what they object to – I’ve read their guidelines – I see no problems. As far as I can see – Google IS the badware.

Google boycott starts now. Because this is evil.

Mike Arrington, Software Pirate

March 24th, 2008

The ever clueless and abrasive Mike Arrington says something even more ridiculous than usual. I can see both sides of the Bebo thing and frankly, social networking makes me yawn. I have no patience or interest in it. Seems like a phenomenal waste of bits to me. Musicians uploaded their music without expectation of compensation. So sure, they’re probably not ‘entitled’ to a payout. OTOH, Bragg’s point is well taken – the musicians made them successful and it would be a nice gesture to give back. But I wouldn’t hold my breath on that. They’re internet entrepreneurs. Thus greedy bastards by definition.

OTOH, the thing that really ticks me off is this little comment by Arrington.

…it costs exactly the same to produce one copy of the song (the first one) as 10 million copies. Simple economics takes over. Free.

Which, if true, implies that Microsoft ought to be giving away Vista, Office, and everything else. Because Music is Software. It costs as much to develop as software, it takes every bit as much time, talent, and skill.

Just because you can make a second copy for a buck, doesn’t mean that’s all it is worth. If it costs $30k to record a song (which is kind of typical these days), and we are expecting to sell 100 copies, then this song needs to make $300 per copy to break even. If its 10 copies, then its $3000 a copy. The same economics apply as software. Just like there is free software, shareware, and commercial software, there are many business models around music. No single model is right all of the time.

Arrington should stick to his little blog about the shiny things – he obviously knows fuck all about the economics of creation.