Category Archives: programming

JavaFX – a GUI DSL

Having mastered JavaScript (OK master is too strong a word – having become comfortable with both its syntax and usage patterns) my next port of call is JavaFX the recently announced Flash/Silverlight competitor. What led me to JavaFX Script was not its role in this Flash/AJAX alternative platform (which unless  Sun improves the JRE download experience is dead in the water they may have a chance with the promised consumer JRE ) but its status as the 2nd scripting language to be supported by the Java 6 ScriptEngineManager – the first being JavaScript. Although the JavaFX platform is still in alpha, the important elements of the scripting language appear to be usable.

Why do I need another scripting language? Well JavaFX Script is a DSL (domain-specific language) and the domain in question is the GUI and as a GUI DSL, JavaFX is impressive.

In my quest for a micro ETL environment the lack of a fast and powerful GUI tool has been a problem. Admittedly, in my Excel/Sqlite xLite suite GUI generation is not a problem as VBA forms are both fast to develop in and feature rich, but the other two options (Java and Ruby) both lack a cost-effective GUI tool (I know there’s Swing and Tk but for somebody who’s used to the speed of development of tools such as VB forms or Oracle’s Application Express, neither appealed). JavaFX changes all that, it’s elegant, powerful, fast to develop in and portable. Further pushes me down the road of using Talend generated Java as my micro-ETL environment of choice.

It’s easy to dismiss JavaFX as hype but the technology behind the hype looks sound. The language borrows powerful features from other languages, object literals from JavaScript, list-comprehensions from Python/Erland/Haskell and first-class functions from JavaScript/Lisp all combined with the full power and glory of Java. The end result:

..is a declarative and statically typed programming language. It has first-class functions, declarative syntax, list-comprehensions, and incremental dependency-based evaluation. The JavaFX Script language makes intensive use of the Java2D swing GUI components and allows for easy creation of GUIs.

Go the community page for FAQs, tutorials and reference information. Timothy O’Brien has a good first pass at calling JavaFX from a Java program and this article by John Smart explains the basics of using ScriptEngineManager to call JavaScript.

JavaScript 101

In a previous post I explained why I had decided to improve my JavaScript skills. The problem was finding a decent reference book as the ones I had looked at where amongst the worst technical books I had ever encountered; then I found this series of lectures by Douglas Crawford. Not only are the presentations excellent but he also recommends a decent reference book, JavaScript: The Definitive Guide by David Flanagan.

More Douglas Crawford JavaScript/DOM related presentations can be found here.

The feature that impressed me most about JavaScript is its functional programming and closure support, a good introduction to the functional programming capabilities of JavaScript can be found here.

VBA & JavaScript – glue languages

What have Javascript and VBA in common? Not much on the surface and their respective user bases rarely if ever overlap. What they do share are their roles as the imperative (the-if-then-else-loop-etc) programming languages of the “I’m not a programmer” programmers, the great unwashed, the “normal” people out there who are just trying to get something done. VBA adds that “something special” to millions of Excel spreadsheets and MS Access databases. JavaScript does likewise for millions of web pages. Most of the code is copied from existing examples or generated by macro recorders. Often the code is not pretty, not well structured, not adequately tested but it is usually “good enough”.

Both languages can also transcend their “ugly duckling” status. If you want to take VBA development to a new level have a look at Professional Excel Development by Bullen et al. GMail, Google Docs & Spreadsheets and the other AJAX powered applications of Web2.0 show the power of JavaScript. Both languages are now starting to move beyond their original home bases, particularly in the case of JavaScript.

VBA has been used in the past as the scripting language for corporate applications such as Siebel; now in an inspired move, Proto opted to use VBA as the scripting environment in their corporate focused mashup tool.

JavaScript is however showing the real expansionist streak. Along side its traditional client-side role in web page DOM manipulation, Mozilla Firefox extensions, widgets and within Flash applications under its ActionScript implementation, it can now be found providing the imperative flourish to many client and server side declarative tools (e.g. Kettle ETL, OpenLaszlo and Grazr). You can even use JavaScript to provide the complete server-side logic for a web application/service by using Zimki.(deadpool)

My decision to spend time to improve my JavaScript skills was as a result of my experience with Zimki. I initially created a web service to sign requests for uploading files to my Amazon S3 account; allowing me to give clients a small executable (developed in VBA’s big brother VB6) with which to securely upload data to S3 without the need to expose my Amazon account credentials. This turned out to be so simple and elegant with Zimki’s Rhino based JavaScript environment that I decided this language deserved some quality time. I had I guess, like many others, confused the mess that is the browser-wars scared DOM with JavaScript (or more correctly, EMACScript) the language. Having looked further, I’ve discovered an elegant,simple yet powerful language that I’m tempted to think may become the universal glue-language.

UPDATE:

As Tom from Fotango (the Canon Europe company behind Zimki also in deadpool) points out, Zimki uses Mozilla’s C implementation of JavaScript, SpiderMonkey rather than Rhino.

UPDATE: Sep 2007

Cannon Europe are to close the Zimki service on Dec 24th, 2007

UPDATE: June 2010

See how I combined VBA and JavaScript, to make JavaScript an Excel scripting language http://blog.gobansaor.com/2010/06/04/javascript-as-an-excel-scripting-language-via-jsdb/

Tables Vs. XML; the data lingua franca debate.

Okay I’m exaggerating, there’s no debate, those using tables (mainly business-orientated techies/power-users) are blissfully unaware of the charms of XML; while those whose only answer to every data exchange problem is XML (or its Javascript cousin JSON) think tables are something people used to design HTML web sites before they discovered the delights of CSS – or worse, the things that DBAs (those killjoys of the development world) are always going on about.

Tables, aka datasets, aka datagrids, aka CSV or TSV files and the peoples favourite, the Excel Range, are alive and well and continue to drive most IT based business processes.

Look at this recent comparison of mashup tools over on TechCrunch, if you look at the comparison table only one product uses tables (datagrids) as its “pipe transport protocol” (Input/Output feeds) the rest are all XML variations. The product in question is Proto which is significant as it’s the only mashup tool I know (other than RSSBus which wasn’t on the Techcrunch list) that deals with the current reality of Excel/”behind-the-firewall data sources” while also looking to the near-future where more and more (but not all) data migrates to the cloud.

I not saying that XML is always the wrong choice; RSS, OPML, MicroFormats and the unloved but powerful HTML <table> tag are here to stay and more and more tools offer out-of-the-box parsing for these standards (did you know that Excel can parse a HTML table?). Likewise for formal robust interfaces between systems a bespoke XML protocol can be useful for professional developers. But if a mashup product ignores tables as an input/output format, that product is ignoring the most common business focused data format there is (and the skills of those who day-in day-out manipulate such datasets).

One other line on the TechCrunch table (see how useful tables are) that intrigued me was the assigned level of Advanced to the skill level required to use Proto. There are at least 2 million VBA users out there without any formal programming training who construct corporate internal “mashups” everyday, for that constituency Proto would be by far the easiest tool to use.

Inventory Management for Developers

The excellent Alistair Cockburn discuses why software development is remarkably like manufacturing and how we can learn from modern manufacturing theory to better structure our software delivery processes (or indeed any business process where the internal inventory item is the ‘yet-to-be-validated decision’).

XScream Programming