Greg Kluthe Consulting

Greg's Resume
Southern California (760) 598-0136 Northern California (408) 738-3934
  • Home
  • About Us
  • Areas of Expertise
  • People by Area
  • Contact Us

    JavaScript Here, There, and Everywhere

    While not being a real fan of Javascript in my browser (you won't find much on my own site), there are times that its loosely typed, relaxed nature makes it the fastest way to develop software.

    Rapid prototyping is a place where JavaScript excels. I had the good fortune of working with a fabulous professor during my years in college (Dr. Ziaul Hasan) who pointed out the interpreted nature of our BASIC computer language enabled us to work faster. We could compile it later for higher performance.

    JavaScript: The Definitive Guide, 4th Edition from O'Reilly

    There are two places I've used JavaScript with a bit of success (both times to take advantage of the rapid prototyping it can provide). The first was using Apache's Jakarta ANT tool for building software. We needed to add some custom tasks to ANT but weren't familiar with some of the interfaces within ANT. ANT provides an optional script task that allows you to drop in JavaScript. The way this particular implementation works is that it allows you to call any Java interface that ANT can see. Since ANT is a Java based tool, you get all of ANT plus anything else you want to put in your CLASSPATH variable.

    If you develop custom ANT tasks with Java, you have to at least compile them with the Java compiler (you could also package them into .jar files, but the Java program [which is what ANT runs on] is fine with a list of directories in the CLASSPATH). In addition, Java is a strongly typed language, so you have to get the variables and the interface (method) calls typed right or your code won't even compile. In JavaScript all you need most of the time is the name of the API and what arguments to pass. If your variables can be cast into the right type, JavaScript takes care of that automagically using a Java feature called introspection (it's also called reflection).

    Once you have a working JavaScript implementation, you do the research to figure out what types all the variables and interfaces are.

    The second place I've used JavaScript is doing development in the J2EE framework integrating the ILOG JRules product with BEA WebLogic.

    Even with today's integrated development environments (IDE's) that automatically (for the most part) deploy code to the J2EE application server of your choice, deployment takes quite awhile (three to five minutes for a small J2EE application). When you're trying small incremental changes, you're limited to about ten of them per hour.

    However, if you bring JavaScript into the picture and process JavaScript code typed onto a form processed by the Web Server in this J2EE framework, you can still invoke all the Java interfaces in the framework, but you don't deploy anything once you have your form developed and integrated with JavaScript on the server side. A form submission takes on the order of ten to twenty seconds to complete its processing. That's easily ten times faster than deploying to an application server. In addition, since JavaScript uses introspection for data types, you spend less time researching the interface documentation to find out what types to use.

    I use the Mozilla open source Rhino JavaScript code for my environments. It's free and the documentation is pretty good. Visit for more information on Rhino from Mozilla. If you want a great book about Rhino get JavaScript: The Definitive Guide, 4th Edition from O'Reilly (Actually it's a great book about all the dialects of JavaScript including the ones that run in various browsers).

  • Business Partners
  • Customers
    Search this site
  • CRM and Personalization
  • JavaScript Here, There, and Everywhere
  • Style Guides: What are they?
  • The Bad Dog
  • What is a Transaction?

    ©2003 Greg Kluthe
    Site Design by Greg Kluthe Consulting