views:

953

answers:

8

I am interested to create a drag-and-drop layout designer using only JavaScript, HTML and CSS. The designer will allow the user to drag the page elements from one place to another (something like Blogger's layout designer) to create a site layout. But I don't want to hand code everything in JavaScript, I would prefer to write my application in .NET (preferably) or Java and rely on a compiler to compile it to JavaScript and HTML.

What are the .NET or Java to JavaScript compilers that you have used and can recommend? For Java to JavaScript I know GWT is available. What about .NET to JavaScript? Microsoft did come out with Volta, but the project seems to be no longer available.

+7  A: 

Look no further, you already mentioned GWT pick that!

It has a very good API and many good applications have use them.

Even JavaScript frameworks like http://extjs.com/ have GWT support.

I use it for an small JavaScript calendar recently.

To be honest, I don't really like JavaScript that much. Most of the times the errors are hard to track (specially for a non JavaScript guy as me) and the workarounds included some plug-ins for the explorer just to get exactly what a compiler should do. Catch silly error early.

In the other hand I'm very familiar with the Java Programming language, and many of the libraries (if not the most important) such as java.lang and java.util have been ported to GWT.

Plus, the guy who wrote relevant parts of java.util is the same behind GWT (google Joshua Bloch.)

OscarRyz
GWT *could* be a pain in the ass, depending on how the serverside is to be implemented. But it is getting heaps better now in its current iteration.
Chii
ExtGWT is a separate project to ExtJS and it's *awful*. For one, the guy has absolutely no clue when it comes to generics. Run away.
cletus
+3  A: 

Check out Nikhil Khotari's Script# project. It allows you to write C# code and compiles it to JavaScript.

Franci Penov
+1  A: 

Also for Java there is J2S.

Java2Script (J2S) Pacemaker provides an Eclipse Java to JavaScript compiler plugin and an implementation of JavaScript version of Eclipse Standard Widget Toolkit (SWT) with other common utilities, such as java.lang.* and java.util.*. You can convert your SWT-base Rich Client Platform (RCP) into Rich Internet Application (RIA) by Java2Script Pacemaker.

This means that if you use the SWT IDE (drag and drop) you can then convert the generated code to JS + HTML.

Paulo Lopes
+1  A: 

I wouldn't hand write any Javascript for UI. This can lead to maintenance disaster. jQuery is what I am using but I still wouldn't use it to write full UI Javascript code. ExtJS is also another good option if you plan to write in Javascript. In general what I am saying here is that it's so much easier to main in Java/C# than Javascript. Check out cappuccino framework and Atlas. Never used GWT. Script# is similar to GWT but for ASP.NET framework. Also depends on the requirement, if your site is public facing then RIA isn't a good option. It's all about which extreme end you pursuit (hand written and web standard, or RAD or libraries like jQuery/ExtJS as the middle option).

Jeffrey C
+2  A: 

My issues with Script# (a known issue) is it doesn't support jQuery yet. However it comes with a very lightweight library to tie in with the .NET framework, in Nikhil's sscorlib.js file and ssfx.core.js files. And also has support for lots of other Javascript APIs (mostly Microsoft, seeing as he is in the ASP.NET team).

I'd love to see a Script# extension for jQuery (I'm thinking about writing it if it's easy enough). As it stands, most don't provide full compilation yet but they're certainly getting there.

Update: I wrote a small extension to enable JQuery support Script# a few months ago. The project can be found here.

Chris S
Last time I went to the Script# site, I saw that jQuery is on the roadmap for the next release of Script# (due some time in 2009).
Nosredna
+1  A: 

Check out Axial, a .NET to JavaScript converter that works well in ASP.NET. It supports WebForms, jQuery and canvas. It's not very mature, but it's worth a look.

Dan Goldstein
+1  A: 

I'm going to second the use of GWT. I've used it for several projects and, when used in combination with a modern editor like Eclipse or IDEA, it really makes the mess manageable.

It's important to note that not only does it allow you to write in Java and have that transformed into optimized and obfuscated Javascript it also comes with a substantial subset of the core Java API. In addition to this they provide lots of additional classes for doing things like parsing and working with JSON and XML and communicating with a server via asynchronous HTTP. You can check out the docs to get an idea of what else they offer.

Another feature that might be of special interest to you for implementing drag and drop functionality is it's integration with javascript libraries like Ext and scriptaculous. Either through pre-built interfaces or via JSNI

Waylon Flinn
+1  A: 

http://jsc.sourceforge.net/ is a C# to JavaScript, Java, Flash and PHP compiler.

mcintyre321