No More Redeploys!

One of DukeScript’s motto is “JavaScript as it was meant to be!” - i.e. our vision is to use the benefits of Java to create something more productive than JavaScript. JavaScript developers are used to an edit/reload/try workflow. The iterative nature of that style of development is very additive and productive. It is so comfortable that people may believe it is perfect. Well, it is not: DukeScript can do even better!

Yes, with DukeScript you can avoid the need to reload and moreover thanks to the structural nature of the used language (Java) also avoid the loss of memory state during “reload”.

No Redeploys via Command Line

Let’s start by creating sample skeletal project from our Maven Archetypes and execute it:

$ mvn archetype:generate \
  -DarchetypeGroupId=com.dukescript.archetype \
  -DarchetypeArtifactId=knockout4j-archetype 
  -DarchetypeVersion=0.11 \ # or more recent version when available
  -DgroupId=com.dukescript.test \
  -DartifactId=no-redeploys \
  -Dversion=1.0-SNAPSHOT
$ cd no-redeploys
$ mvn install
$ cd client
$ mvn exec:exec

Your application is running and you can play with it. For example change the Hello World message and see how it is changing throughout the page (more about the structure of the application in getting started tutorial). However we are not here to analyse the structure of the application, but to see the benefit of the re-deploys. Leave the application running and locate the DataModel.java file in your application. In the words method find the line that splits the Message String and change it to convert all characters to lowercase:

$ find src/ | grep DataModel.java 
src/main/java/com/dukescript/test/DataModel.java

# the following command prints the line we want to change
$ grep split src/main/java/com/dukescript/test/DataModel.java
        String[] words = message == null ? new String[0] : message.split(" ", 6);

# use your favorite editor here
$ sed -i s/message[^=]*split/message.toLowerCase\(\).split/ src/main/java/com/dukescript/test/DataModel.java

# verify the line is really changed
$ grep split src/main/java/com/dukescript/test/DataModel.java
        String[] words = message == null ? new String[0] : message.toLowerCase().split(" ", 6);

# perform the re-deploy
$ mvn process-classes

Now return back to your application and type a character into Hello World message field. This invokes the modified code and you can see that all words are now in lower case. If you want, you can now switch to upper case:

$ sed -i s/message[^=]*split/message.toUpperCase\(\).split/ src/main/java/com/dukescript/test/DataModel.java
$ mvn process-classes

See the productivity boost!? No more re-deploys! Just change your code and immediately see the changes.

Please note that the system is better than page reload in JavaScript - the text in the message field is kept even the code is reloaded. This is possible because Java is a structured language - we know what a class is, what are its methods and their code. This is clearly separated from object instances, so when there is a code change, we can just change the code in classes, but we can leave the object instances in memory untouched.

No Redeploys from an IDE

Some may object that JavaScript is still more productive, as it avoids the process-classes step. True, if you are working from a command line, however if you switch to some reasonable development environment, like NetBeans, you can avoid this step alltogether.

Open the client project in NetBeans 8.x. Press F6 to execute it. Play with the application as usual. Press Ctrl-O and to open the DataModel class. Change the line as in the above example. Press Ctrl-S to save the file and change something in the Hello World input field in your running application - the change is immediately visible.

No more re-deploys with DukeScript!