JavaFX 1.0 is a big disappointment
Posted by Sam
Sun Microsystems has been doing so much right lately that I had really high hopes for JavaFX. Maybe too high. JavaFX 1.0 was released this week and I'm not ashamed to say that I'd been looking forward to it for a really long time now. A couple of really great features for GUI development were included and I THOUGHT they were making the code simpler.
First off I'd like to mention a couple of features that I think are fantastic for GUI development. Mainly binding and triggers. They do just what they sound like. For example you could have a central set of variables, say for example a bunch of preferences. Then wherever you want to use those preferences you just bind to the variable. Presto - bango. Anytime that variable changes everybody that is bound to that variable changes. Saves a TON of coding. The second feature is triggers. That is when a variable changes you can act on the knowledge that it changed. It's like creating Listeners without all the coding. And lastly being able to create applets that live beyond the browser is pretty cool. A completely separate threading model and everything. Cool indeed.
So where was I disappointed? Primarily I feel like they took a HUGE step backwards with their JSON support. Originally the examples showed that you could just make a one line JSON request and turn it into a real object. Nice huh? Simple and concise. Just how that task SHOULD be. Have a look at the ridiculous examples of using JSON in the 1.0 release. They have like 30 lines of code that say if ("string" == "value") then variable.something = json.something. It's just ridiculous. This is a very Java way to do it and something that's driven me nuts for years. There are Ruby libraries that can create first class objects from JSON and XML. Flex can do it. Why can't JavaFX. It shouldn't require so much code to do something so simple. Especially when it was doing it that way to begin with.
I've been playing with Adobe AIR lately and it's highlighted a couple of other problems that exist with JavaFX and really Java in general. I know they can be worked around with Java but I don't know how they can be worked around in JavaFX. With AIR I get a real icon for my program. It also shows up in the task list with the name that I give it. This isn't the case with Java. If you've got multiple processes running it can be hard to know which one is which. It also reinforces the Java brand more than my brand. AIR in general just has much better integration with the host OS. There are work arounds for traditional Java programs but this really needs to be something that Sun builds into Java and especially JavaFX.
I had a program that I was looking forward to using JSON, bindings and triggers on but frankly after working with Ruby on Rails for so long I have zero tolerance for excessive, silly code. I really, really wanted to use JavaFX for this app but it looks like it's going to be done in Adobe AIR. **SIGH**
Images Belong in the Database
Posted by Sam
Logical Reasons
The more web programming and system administration I do the more I'm convinced that images and other forms of uploaded content belong in the database. I've pretty strongly suspected this for many a years but it's becoming more and more clear that this is just how things need to be. There are many reasons. Some are technical and some are logical, but all signs point to loading images in the database. Below are just a couple.
I'll start with the logical reason first and then get to the technical reasons. Logically all other forms of dynamic content will reside in the database yet programmer after programmer insists on putting images and other uploaded content on the filesystem. Now you've got some content in the database and it's tied to content on the filesystem. Suddenly the nice clean line is broken. You've blurred the lines on who does what and where it goes. What usually happens is programmers forget to clean up after themselves so files references are deleted in the database but still exist on the file system. You know why this happens? Because you shouldn't have put it there in the first place. Repeat after me - dynamic content in the database and application files in the filesystem. Got it?
Technical Reasons
So know that we've got the logical reasons behind us what are some of the technical reasons? For starters your database(s) will always be in sync. That's what they are meant to do. That's what they have to do. Your database(s) have to be synchronized. Your site depends on it. It doesn't matter if it's a simple site with a single database server or a huge site with a dozen database servers. You have to keep your database servers in sync. And databases are good at it. It's much much easier to scale out database servers than file servers. Having all your dynamic content in the database keeps everything in sync.
Some people will wrongly argue that having files in the database will cause slowdowns. To that I say....um maybe, but only if you're doing it wrong. Databases are very fast and have excellent caching but it's highly likely that multiple web servers can server images straight from disk faster than a database. Well that's great, but images still belong in the database. And in this case you can have your cake and eat it too. Check out this article about caching images on the file system with Rails. Hrm, one extra line of code lets you cache your image on the file system. Doesn't seem to bad to me. Elegant, simple and lightning fast.
The Reason for the Rant
Time after time I'm responsible for deploying other people's crappy software. They invariably come up with some stupid solution that lets them click the checkbox that says their product will work on a load balancer, but they neglect to tell you upfront what ridiculous hoops you have to jump through to get it work. The most recent product is called Ektron. I can't say what it's like to work with from a programming stand point but from an admin stand point it's a nightmare. Instead of loading the images in the database like they should they instead force you to share out files and do this dumb little virtual directory linking to the other servers. It's just annoying and not even close to elegant, but then I have yet to see a CMS system that is so I wasn't surprised. Thankfully the Ruby on Rails team understands what it takes to scale apps and they provide you with a nice foundation. If only the rest of the world would catch up.
Tags: rubyonrails web rant