Wednesday, December 9, 2009

xargs == awesome

find . -name *.java | xargs -n1 -I@ touch -c @

For those times when commands like touch won't take stdin.

Wednesday, March 25, 2009

EclipseCon 2009 - Days 2 & 3

I've gone to quite a few sessions over the last two days. Cloud Computing, UI Showcase, Nebula, SOA... there's so much good stuff to see. Some are great, some are not so great. In most cases the speakers are rushing because they're running out of time. There's no time to ask questions during the sessions, which wouldn't be so horrible if I weren't myself rushing to the next session, not allowing me to catch them for a quick Q&A. Maybe these sessions were designed that way? :-)

About a third or the talks I've gone to are about e4. That's code for "Eclipse 4.0" for those of us who don't know the lingo. This is a really hard topic for me. Let's see, where do we start?

"Schizophrenia is a psychiatric diagnosis that describes a mental illness characterized by impairments in the perception or expression of reality, most commonly manifesting as auditory hallucinations, paranoid or bizarre delusions or disorganized speech and thinking in the context of significant social or occupational dysfunction."

Hmnn... "...impairments in the perception or expression of reality...". Given that definition, either the speakers have it or I have it. One minute I get it, thinking, "hey, you're bang on", and the next I'm thinking "what? are you insane?".

The Sane Side of Our Schizophrenia

I may not be on side with the approach to the problem, but the use cases driving the solution make sense - at least to me they do.

Java 6

A small point in the grand scheme of things but nevertheless worth mentioning. They're not stuck to Java 1.4 anymore. I've seen the code. It's undeniably not 1.4 compatible. Finally. Fantastic.

The Modeled UI - Declarative User Interfaces

I definitely like the idea. The model approach is trying to lower the bar when it comes to entering the world of Eclipse-based development. Build an EMF model, hook up a framework-supplied renderer, and off you go. It's how we should be building UI's anyway. The only reason we don't work this way today is because its an extremely hard problem to solve well. It's been tried before. This all feels very VisuageAge Smalltalk to me. I don't want to discourage the research, but let's not ignore those learning's or we;ll repeat the mistakes. What will most likely evolve out of e4 is a hybrid approach, where parts of your UI will made up of the EMF models plus renderers and parts will be made up of "do it the old way" code. When I try an visualize what that would look like, I find myself getting back to where I am today. Inconsistency come to mind. Isn't API inconsistency the root of this barrier-to-entry that this very solution is trying to break down? RCP development has a steep learning curve because it makes me learn 10 separate and inconsistent frameworks to do it well. Platform, SWT, JFace, GEF, Preferences, Memento... to name a few. I don't know - I'm just asking the question. Think about it... is this really going to make it easier? How am I going to build an EMF model that allows me to add that third-party widget library that's built on Swing and integrate its selection mechanism with the Workbench across two independent threads? I'll tell you how. It's not. But guess what? I do exactly that in my product today, which is built on the 3.x stack. It wasn't easy to be sure, but I'm able to do it. Please don't take that away from me.

Another key will be tool support. Dear e4 Committers: If you take away our refactoring tools, we won't use it. We've proven that in the past. Until the refactoring tools address the code in plugin.xml, then we're not going to put our stuff in plugin.xml. Luckily enough many of the PDE's refactorings do look in there today. Let's just maintain a good level of support for whatever new XML files are introduced.

In the end, the "model + renderer" approach makes a lot of sense to me. As developers we definitely spend too much time solving UI problems instead of business problems. This is a step in solving that problem. Saying that, I'm not betting my next business strategy on the Summer of 2010. I do see this working for the trivial CRUD applications out there, but not for the more complex. But you guys are smarter than me, so I look forward to it. There is value here if you can pull it off - a tonne of it. I'll be watching closely.

The "Not So Sane" Side

SWT Browser Edition

This makes me feel like we're trying to commercialize some mad scientist's experiment in human cloning. Just because you can doesn't mean you should. It's definitely interesting to build a cross-compiler from Java to ActionScript, but I need someone to help me with the use case. Everyone is talking about bringing the IDE to the web. What for? I don't get it. Please someone, give me one use case that isn't simply about some wow factor. There was a lot of "Oooohhhh.. ahhhhhhhh" when the RCP Photo application demo was shown running inside the Adobe-powered browser. I too think that's very cool. But show that same demo to your boss see if you get the same reaction. I'm not sure you will. Is the desktop deployment model really that broken? Why does everyone want to run their friggin applications in their browser? Or do they?

CSS Styling

This was also introduced as a "someone had some time on their hands and thought it'd be cool if..." kinda thing. This gets a "thumbs down" because every time I look at a CSS file I quickly turn away in fear of turning to stone. Maybe I'm just scared that someday I'm going to wake up and my "to do" list is going to have a "fix screen layout" and its all in CSS. What do I do know? The Idiots Guide to Assember - here we come.

In my not-so-humble opinion, CSS is as bad an implementation of a good idea as I've seen.

At least its optional.

There's So Much More

I've clearly just scratched the surface. The first preview release is coming out in July. I think it'll be fun to see where it is at that point. I'm going to spend my time going a deeper dive, which will hopefully answer some of my own questions and undoubtedly uncover many more.

Heading to a Scala talk today plus a few others. See you tomorrow.

Tuesday, March 24, 2009

EclipseCon 2009 - Day 1

It was definitely time to visit EclipseCon. I've been using Eclipse RCP for almost four years now, so I feel like if I'm going to visit a technical conference this year, this is the one. Well... now that I think about it, there are probably others I'd like to visit too, but I'm here now so I'll write about this one.

This Place Just Oozes Passion

I spent a lot of time here eight years ago, commuting between San Mateo and Calgary on a weekly basis for over a year. It's nice to come back to the seems-like-recession-proof Bay Area for technical inspiration. It, like no other place I know of, absolutely oozes passion for technology - primarily software technology. There was a breakfast/registration this morning and it seemed like everyone was giddily running around like a bunch of crazed schoolgirls waiting in line for the premier of Twilight. Honestly? I'd like to take some of that passion home with me and spread it around.

Ya-Who?

As I walk down the street, within one hour I inadvertently find the homes of many of the technology companies we've come to love and hate. Cisco, Citrix, AMD, Intel, WebEx, Oracle, Sun... err... IBM, Yahoo, etc. Seems like they're all here... all within a few square kilometers. Speaking of Yahoo, their campus still has an incredibly large footprint. It seems to go on and on. Blocks and blocks of buildings, floral gardens, manicured courtyards, etc. I bet they hire three gardeners for every programmer. Every second car in the parking lot is BMW - although maybe they're 1999 vintage, purchased when the now 30-somethings where hired as up-and-coming 20-somethings looking to take over the world. Who knows. What the hell does Yahoo do anyway? I thought they disappeared when Google came along. I stopped using them - didn't you? Guess not.

Mac's Everywhere

Another thing I'm noticing is the disproportionate number of MacBook versus Windowz machines. I'd say it's at least 2:1 in favour of the Mac's. The table I'm sitting at now is 4:1. There's the odd Linux guy back there, but from what I can tell you're only using a PC because you didn't have to pay for it. What's interesting to me is that a lot of the committers are using OSX too. Maybe now that 3.5 runs native on OSX, everyone feels like the the Mac is now ready for Eclipse. Not sure. As a more-than-casual Mac user myself, I can tell you that Eclipse runs great on Windows and okay on OSX. Saying that, I haven't been using 3.5 for very long and the SWT folks spent basically all of 3.5 porting the Carbon code to Cocoa. Maybe I'm in for a pleasant surprise.

Morning Session - Binding, Commands & Common Navigator Framework

Binding - The Better of Two Evils

Anything to get rid of that boilerplate we have to write just to get our models in sync with our UI. It's such a trivial problem that just begs for a declarative solution. I must say, I think the Eclipse guys are going down the right path. I find the same two problems, over and over, with most declarative solutions in this UI binding space. Firstly, most solutions take away control when it comes to the timing/event that drives the binding. You lose to fine grained control you need in rich-client UI's. Secondly, bindings only work with a specific handful of widgets. I'm happy to say that there's a decent answer to both of these problems.

For problem #1, the framework allows us to specify the event.

DataBindingContext dbc = new DataBindingContext();
ISWTObservableValue ui = SWTObservables.observeText(myTextWidget, SWT.Modify);
IObservableValue model = BeansObservables.observeDetailValue(myModel, "body", String.class);
dbc.bindValue(ui, model);

Most of you are going to look at this code and cringe. At least I hope you will. I'll give you the benefit of the doubt and assume you're going to say that this is a terrible way to express a binding because reflecting into a Bean to get its property value exposes you to a bunch of runtime errors where an alternative solution would allow compile-time error checking. Well you're partly right. The problem is not the framework, it's Java. I don't see my way clear to an alternative solution. If you do, please share. Now if this were Scala, where I'm allowed to pass methods as parameters for example, I see a completely different approach that is both declarative and type safe. But that's another topic for another day. That day is probably right around the corner because its been bugging me for a while.

For problem #2, just roll your own. The binding is pure API, supported by a bunch of helpers all over the place. There are built-in solutions for the most common elements: fields (text, date, boolean, etc), lists, tables and trees. They even provide a solution to the common Master-Details problem. But, if your use case calls for a new UI component that isn't covered, just write your own. I haven't tried this yet, but look forward to do so.

Update Strategies & Validation - Arghhhh... Java - You Suck!!!

Good idea, bad implementation. To be fair to the guys, they're handcuffed here. Friggin' Eclipse is still hanging on to Java 1.4. I mean really... we're on 6. Does anyone really still use 1.4? I think this topic deserves its own post, because if I see another snippet of code that looks like this I'm going to apply for one of those "Yahoo Gardener" gigs.


new UpdateValueStrategy().setConverter(new IConverter(){

public Object getToType() {
return Date.class;
}

public Object getFromType() {
return String.class;
}

public Object convert(Object from) {
// convert your String to a Date
}

};


Are you kidding me? That would never pass a code review anywhere I've worked. Let me see, can we make this a little better?


new UpdateValueStrategy().setConverter(new IConverter<String, Date>(){

public Date convert(String from) throws UnconvertableFormatException {
// convert your String to a Date
// because it's any string, I'll make you handle the exception
}

};

Please tell me that its clear to the decisions makers over at Eclipse Headquarters that the lack of generics support in the Eclipse framework really creates a major problem when it relates to technology adoption. Anytime I'm writing code that integrates my models with an Eclipse UI, I feel like I might as well be writing all this stuff in Ruby. I might as well turn off incremental compilation because I'm passing a bunch of Object references around. Once the Eclipse frameworks get a hold of me, all my types have been lost. To get them back, I'm casting all over the friggin' place. Discussions with a couple of the committers indicates that they're also frustrated with these handcuffs. Rumors seem to point to e4, but I'm going to hunt for a definitive answer while I'm here.

Commands - It's All About Scale and Extension

I'll just say a couple of things about the declarative Command framework. First of all, for those of you looking for an 'undo' solution, this is not it. Not that it can't be used for that use case, but that's not what it was developed for. Secondly, there seems to be a bit of a bad smell around 'best practices'. The guys running the session didn't get into the value proposition. They started with "here's how you do this" and "here's how you do that". Nobody wanted to talk about "why do I want to do this?". When I asked the question, the answer was weak to say the least. Don't get me wrong, I absolutely see the value proposition. It's about extension and scale. If I want my business application to also play the role of platform, i.e. host for extension, then I want the extender to have options too. Perfectly valid. But if I'm just building a small application on top of the RCP stack then I don't see why I'd want to declare my commands outside. There's definitely an overhead I have to pay in terms of development and tool support.

Assuming I want this capability, the Command declaration gives my application a way to show my commands in a menu without loading the class, which is all possible because of Equinox. At-the-end-of-the-day, the Command framework is simply further UI decoupling of the legacy ActionSet strategy. Again a step in the right direction.

Common Navigator Framework (CNF) - Platform Navigation

CNF is about providing a solution for a common integration/extension use case. "Let me put my stuff in your tree view". One plugin can show Projects, another plugin can show Tasks. CNF allows you to do this without binding the two plugins. It does so in such a way that the user doesn't have to use two separate navigation views. Nice.

Afternoon Session - Advanced RCP

First things first - it's not that advanced. We were presented with "best practices in RCP" using a sample MP3 application. All-in-all, I liked the session because it brought everything together. The funny thing about it is that while it brought together many of the frameworks, it did uncover many inconsistencies. For example:

Best Practice #1 - Use Adapter Factories

"Use adapter factories (IAdapterFactory) to adapt your models to the binding context needed at the time". For example, if you want your model to show up in a tree, do it this way.


treeViewer = new TreeViewer(parent, SWT.BORDER| SWT.MULTI| SWT.V_SCROLL);
IAdapterFactory adapterFactory = new AdapterFactory();
Platform.getAdapterManager().registerAdapters(adapterFactory, Mp3File.class);
treeViewer.setLabelProvider(new WorkbenchLabelProvider());
treeViewer.setContentProvider(new BaseWorkbenchContentProvider());


Simple. Register your adapter and the BaseWorkbenchContentProvider will find the adaption in the factory. We don't need to get into the adapter code here - it's not the point. The point is that I don't have to use any content provider other than the one provided by the workbench. That begs the question, "why are you making me specify it then?", but I'm not going to chase that down right now. Anyway, not a big deal. It works. I get it. Great. Sure. Whatever. Now for Best Practice #2.

Best Practice #2 - Use Virtual Tables

"When you have large datasets, only load what you need". Ya, no kidding. Sounds like a plan.


TableViewertableViewer = new TableViewer(parent, SWT.VIRTUAL|SWT.BORDER|SWT.V_SCROLL);
// skipping the noise
tableViewer.setItemCount(100000);
tableViewer.setContentProvider(new LazyContentProvider());
tableViewer.setLabelProvider(new TableLabelProvider());
tableViewer.setUseHashlookup(true);
tableViewer.setInput(null);


What? LazyContentProvider? Didn't you tell me less than 10 minutes ago that I'm to adapt via an IAdapterFactory and use the BaseWorkbenchContentProvider?. Make up your mind! Turns out that #1 and #2 are not only incompatible, but they're mutually exclusive. Awesome. NOT!!!

Enough About Day #1

In the end, I don't want to be hard on the guys. They're pumping out some good stuff and the Eclipse ecosystem is such a huge machine that it's almost impossible to keep it all together. It's evolving in the right direction. For the rants I do have I should probably put all this blogging energy into contributing to Eclipse.

Looking forward to the e4 sessions tomorrow afternoon.

Monday, January 14, 2008

Everything Looks Like a Nail

I've heard it before here and there, but it exactly describes how I feel working with Java for the last few years.

"If all you have is a hammer, then everything looks like a nail."

I've been writing code for over 20 years now; C, C++, Smalltalk, Java, C#, Python, Ruby, etc. When I went to school, we were taught Pascal, C, Cobol (now that sure dates me) because the school I went to wanted to get me ready for the "real world" and that world was using those languages at the time. Admittedly, I didn't learn much in school. I didn't learn much about computer science. I learned plenty about how to build simple CRUD applications using imperative programming languages. Sure, we all used SQL, but didn't spend much time understanding it. Think about programmers today, most know enough SQL to get the job done. How many times have you seen SQL stored-procedure code written... well... procedurally? I bet more than a few. Did you even notice? Did you care? I didn't. I should have.

Java Sucks

I'm not going to sit here and tell you that Java sucks, but... well... Java sucks. Why? Because there's no evolution of the language. Imperative only. Cruft everywhere. Powerless scoping rules. And, most importantly, it's limited my ability to think about problems in different ways. I naturally think procedural - give me Lisp, Haskell... forget it. I've inadvertently trained myself to only see nails.

Java is Powerful

Huge community. Many tested frameworks. I want to leverage that community, those frameworks. I want to make them better. I sure as hell don't want to start again. I'm not going to rewrite Hibernate. I don't want to rewrite Wicket. I don't want to rewrite JScience.

Why Not Ruby?

I was there for a while, but I can't stay. I really love the language. It' has almost everything I need. It has a large community. So why not? I don't want to invest my time into a toy. Sorry Ruby people, I only have enough bandwidth for one, and I see too many fundamental problems. No compiler. Not type-safe. (dodging bullets) No concurrency. Hey, I was in that community and put up with all those problems because I couldn't take Java anymore. Now I don't have to.


Scala

Scala, introduced to me by a colleague who's always on the lookout for a better way, seems to really impress. It's multi-paradigm; object-oriented, functional, concurrent. It's type-safe! Yeah! Powerful generics! Yeah! Closures! Yeah! Type-safe mix-ins! Yeah! Oh... did I mention... (cue the drum roll) it's Java! Can you imagine trying to write cross-cutting mix-ins in Java? Scala generates .class files that run in the standard Java 5 virtual machine. You want to leverage your favorite Java framework? Go ahead. No problem. What? You want your Java team to leverage a library you wrote in Scala? No problem. One drawback, and not really a language drawback, is the learning curve for all of us that see only nails.

Some of you are thinking "what the hell is he talking about?". "What's wrong with doing it the traditional way? 99% of the software we use today is built using imperative programming and they work just fine". Well yes, back some 2000 years ago, 99% or homes were built using straw and clay. They were just fine then too. Since then, homes have evolved because people wanted more. Today, people are smarter, tools are better. We want more.

Tools

Ouch. Scala isn't there. Getting better, yes, but it needs some time. Unless the tools get there, the masses won't come for the longer term. I won't come for the long term if the tools don't evolve. I've invested in Eclipse as a tool and a platform. For me, it's as important as the language - especially if the language is cumbersome. I'm not going back to vi and print statements. Forget it. I don't care how great the language is. Thankfully, Scala has an Eclipse plugin that at least gives me the critical stuff, i.e. debugger, syntax highlighting, etc. It's getting there. It just needs some time.

Give it a try.

Tuesday, September 25, 2007

Getting Real... Now That's What I'm Talking About

I've recently been thinking philosophically about the best way to build software, when I stumbled upon 37signals' Getting Real book. I decided to pick up a copy here because reading online for an extended period sucks.

I'm not going to sit here and tell you it's the Holy Grail but it's the Holy Grail. For the right type of business. Sure, this book is specific to 37signals' business, or shall I say companies who make a living selling service-based software for the masses. Regardless, take these points and interpret them for your business and you'll be better for it.

The following points, directly from the book, are "bang-on". I don't care what kind of software you're creating. These points make a helluva-lot of sense to me, because I've either lived either this side and experienced the joy or that side and experienced the pain. I'm not saying that I don't agree with the others points in the book, it's just that these are the ones that really shine for me.

Note: These are in the order as taken from the book

There are a couple of points of my own I'd like to add that may arguably disagree with a couple of points in the book.

Stay The Course

Be cautious about changing your mind. Being flexible is not the same as being schizophrenic. Embrace change when you know, not when you think. See out the decisions you've made. Test them on your market. If you hire the right customer, you'll find this won't be a problem for you.

Don't Be Lazy

Agreed, you won't get it right the first time, but don't let that be an excuse to being lazy. See the big picture when you're building an application and pay attention to what you're doing. Don't let the race to running software get in the way of quality.