views:

153

answers:

5

As far as I can see the key advantage of dynamic languages like Ruby or Python over Java/Scala/C# etc is "hot" applying of your changes to source code to the running application. What are the frameworks for JVM or .NET that support the same workflow - apply changes to configuration and source code on the fly? Can they also watch changes to custom configurations and notify application?

Note: Frameworks for dynamic languages on JVM/.NET like Grails or Compojure are out of scope here.

EDIT: I mean not only modification of a method body, but adding/deleting methods, fields and classes. What is average time between finishing of editing and observing changes in your browser?

NICE SOLUTIONS:

A: 

Any ASP.NET application running under IIS can be modified "on the fly". Current requests are served from the current AppDomain, while new requests will be consumed by the new AppDomain that represents the new code/binaries/configuration. You can modify to your heart's content on a live ASP.NET site.

andras
1. How long it takes to apply small modification to a large project? 2. I think, the state of the application will be discarded in this case, will it?
Alexey
andras
@Alexey: 1. As in other frameworks, it mostly depends on what code you run at startup. 2. As in other frameworks, global application state is lost unless you store the state separately, e.g. on a DB server.
andras
A: 

Apache's Tomcat server for Java servlets has a configuration option to "watch" resources. If a watched servlet or web application is changed (i.e., new code is uploaded to the server), Tomcat automagically reloads it.

From my experience, this feature is somewhat broken when mixed with other advanced features (e.g., user-dirs), but otherwise works as advertised.

Little Bobby Tables
1. For large enough project how long it will take between you ended editing of your Java/Scala code and you can observe applied changes in your browser (5 sec, 1 minute, 30 minites)? 2. can classes/fields/methods be added/removed? 3. will the state of the application be kept? 4. will my current session in browser continue?
Alexey
1. Obviously, it requires a refresh of the client. The reload time itself depend on the size of the update - From a single servlet to a whole application.2. We are talking about servlets - The client does not observe classes, fields, methods, etc. Any Java class can be replaced.3,4 - That depends on Tomcat, I'm not sure.
Little Bobby Tables
A: 

You don't need a framework for that. When you run a Java application from eclipse, and modify the source, eclipse will attempt to patch the new code into the running VM. This even works if the methods being replaced are currently executing (method execution will start over at the beginning of the method in such a case). Certain changes can not be hot-deployed, for instance deleting a public method, or changing subtype relationships.

Of course, if your application caches stuff (for instance, setting read during startup), those cache will not be recomputed, though you could probably invoke the parsing method manually in the debugger.

meriton
1. Does it support adding new class, adding field or method to an existing class? 2. For large project how long it takes between you finished editing of your code and you observe changes in your browser?
Alexey
+3  A: 

Great question! In the java world:

In all java frameworks, the JVM hotswap functionality allows your debugger to make some changes in place, however you are somewhat limited - e.g.: you cannot change class hierarchies, add methods, etc.

There is a commercial product, JRebel, which advertises itself as allowing you to make almost any code change dynamically - I have never been able to get it to work properly myself, but you may be have better luck.

Outside that, I know GWT's dev mode allows arbitrary changes without needing to recompile, I don't think GWT would be a viable competitor to directly writing javascript if it didn't have that feature. However, keep in mind that GWT isn't a traditional web framework, it all runs on the client side.

Finally, there is the Play framework, on the server side, which will also automatically reload java classes with arbitrary chages, when you refresh your browser.

Chi
Thanks! Today I came across Play framework and wondered if there any other with this feature.
Alexey
+1  A: 

I have used Lift with JRebel without problem. You just have to configure it correctly, start the web server in one terminal, and keep another terminal with maven scala::cc. That will recompile everything automatically (everything necessary if you use the configuration here), and JRebel will instantly make the changes available on the web server.

Daniel