Category Archives: Java

GWT v.s. Java2Script SWT

Google has released Google Web Toolkit (GWT), ….

Aha, google is doing the same thing as me: Java2Script Pacemaker.

The same pattern: Java-to-JavaScript compiler, provide general java.lang.* and java.util.*, and an extra UI widget library.
In Google Web Toolkit, the UI widgets is GWT, while in Java2Script Pacemaker, it is Eclipse’s Standard Widget Toolkit (SWT).It seems GWT is a much lighter library than SWT. Currently Java2Script’s SWT is growing to about 400k of *.js files for about 80%+ API support. After compression the file size is about 250k. 250k v.s. 100k. Hoho it seems J2S’ SWT need more works.

Some more comparisions of GWT and Java2Script:

  • Now GWT has no IDEs support but can be developed within Eclipse, while Java2Script Pacemaker is a plugin extending Eclipse JDT plugin, so its UI is Eclipse SDK. Java2Script is not a standalone application.
  • GWT’s UI may not be reused on desktop, while J2S’ SWT is another implementation of SWT’s API. That is to say, it’s SWT on Browser besides SWT on Win32, SWT on GTK, SWT on PPC, … So SWT applications developing for desktop can be reused or directly exported to web browser.
  • GWT’s UI is for web, and SWT is for both deskop and web. And J2S’ SWT looks more similar to desktop application.
  • GWT has been integrated with Java EE, while Java2Script is still not (Planned but not yet implemented).
  • For license, GWT is on its own license, J2S is licensed under the much well-known Eclipse Public License 1.0.
  • About releases, GWT is now 1.0.20, while Java2Script is before 1.0.0 M2 besides its ealier 0.1.0 to 0.5.0 and 1.0.0 M1.

Aha, Java2Script Pacemaker welcomes you.

/js (*_*)

Posted in Java, Java2Script News, JavaScript, Uncategorized | 11 Comments

Will JavaScript 2 be the Future of the Web?

In “Brendan Eich: JavaScript 2 and the Future of the Web”, it says:

We were lucky enough to have Brendan Eich, creator of JavaScript, give a keynote at The Ajax Experience.

We have placed the presentation online so everyone can read up on some of the thoughts and discussion on JavaScript 2 and more.

Here we got to hear from the mouth of someone deep into the ECMA process about what we are going to see in JavaScript 2 and importantly why:

So I begin to think that: will the time interval 2006-2010 (4 years) be somewhat too long?

Are there useful tools to speed migration?
* A JS2 to JS offline translator, for example
* Write your web app using JS2 exclusively
* Run the translator over all of your JS2 code
* Serve the translated files to old browsers

The project Java2Script, which I am working on, is providing a Java to JavaScript convertor. To develop web applications, it recommends the way of writing JavaScript in Java Syntax (Actually writing Java totally by IDE and then converting Java to JavaScript).
But some comments sound

“Don’t turn it into Java!�?

These comments do bewilder me and make me think further.
From the above Brendan’s presentation, we can see a lot of syntax improvements, which are popular in Java, C++, Python or Ruby. Maybe we could call them syntax sugars. Sugars won’t be enough. Robust IDEs are needed to help writing or managing those scripts.
So I am thinking: Will JavaScript 2 be on a way of being another language if it is not adopted widely and quickly by Browsers and IDEs while JavaScript 1 keeps being popular? If such things happen, a maybe JS2 to JS converter will always be used. Then JavaScript 2 will be similar to other languages like Java, Python, as those languages also can be converted into JavaScript by convertors. Then a question: why wait 2~4 years or longer for JavaScript 2 syntax sugars? Why not having the syntax sugars of Python, Ruby, Java or C++ right now by convertors?

PS: It seems that I am being affected by Java2Script too deep to make such comments on JavaScript 2.

Posted in Java, JavaScript | Comments Off on Will JavaScript 2 be the Future of the Web?

Java2Script 1.0.0 M1 with support of Java 5.0

Bugs and Fixes

When running j2sui.jar an error message box about “Failed to load Main-Class manifest attribute from …” popups. And this is a bug when packing j2sui.jar. I realized this bug until these days. And another fixed packed are here:

http://prdownloads.sourceforge.net/j2s/j2s-1.0.0-m1-eclipse-3.1-fixed.zip?download

or make downloads from the updated download page .

News: Java2Script 1.0.0 M1 with support of Java 5.0 (March 18, 2006)

New and Noteworthy
==============
Java2Script Core
—————-

  • Java 5.0 features, includes generic, enums, static imports, enhanced loops, are supported
  • Split a small (less than 8K) Object Oriented JavaScript core libraries (See: J2S Clazz)
  • Optimization on speed of loading J2S application and size of generated JavaScript codes

Java2Script SWT
—————

  • Support resizing of Shell
  • More widgets supported: Slider, Spinner, ToolBar, MessageBox
  • Modal dialog
Posted in Java, Java2Script News | 7 Comments

Object Oriented Programming in JavaScript by Java2Script

Summary

It’s well-known that JavaScript is a prototype based or object based scripting language not a complete Object Oriented Programming (OOP) language as Java, which is a well-known and most-succeeded OOP language. As AJAX applications boosting, lots of JavaScript inheritance systems are developing to make codes more readable, more manageable and more developer-friendly. However, polymorphism and super method calling, which are two most important features for OOP, are not implemented or not fully implemented. In this article, a new library will be introduced for JavaScript to simulate a complete Object Oriented Programming. And a new Eclipse JDT plugin, named “Java2Script Pacemaker”, will also be introduced to help developers in converting Java codes into Object Oriented JavaScript codes directly.

For more, please read the OOP in JavaScript by J2S(Draft) .

Posted in Java, JavaScript | 2 Comments

Simple RSS Reader by J2S SWT and AJAX

News: Feb 16, 2006
J2S provides two more tutorials:

Here, take a look at the RSS Reader
http://idwhiz.vicp.net/examples/net.sf.j2s.examples.RSSReader.html.
May need patience for the loading…

Posted in Java, Java2Script News, JavaScript | 1 Comment

Asynchronous Programming

Just keep the comment back from Youngpup’s Managing complexity in asynchronous GUIs – Words
Comment URL:http://youngpup.net/2006/20060128022344/comments#c2089

I also thinking about asynchronous programming these days not only for JavaScript but also for Java.

These days, I dedicated in open source project Java2Script Pacemaker at Sourceforge.net. It will provide tookit to transform existed Java codes into JavaScript codes, including the possible UI widgets (Eclipse’ SWT). But one problem must to be solved is blocking and threads. AJAX, the essential part is “A” which is asynchronous programming. But what about asynchronous programming is brought into the Java’s object-oriented programming?

Already, Java programmer can use system native semaphoro or thread to implement blocking. For example, Java programmer will open a dialog and wait for response result:


1
2
3
4
5
6
Dialog dialog = new Dialog(...);
int result = dialog.open();
if (result == OK) {
String name = dialog.getUserName();
....
}

But in the asynchronous programming, it would be something like this:


1
2
3
4
5
6
7
8
9
10
11
final Dialog dialog = new Dialog(...);
dialog.register(new Runnable() {
public void run() {
int result = dialog.open();
if (result == OK) {
String name = dialog.getUserName();
....
}
}
}
// return here!

Once the Java codes is asynchronous-oriented, I think the Java codes can be exported into JavaScript codes directly by Java2Script Pacemaker.

But in fact, asynchronous programming or refactoring existed synchronous programmed libraries into asynchronous-oriented libraries will require times.

Posted in Java, JavaScript | Leave a comment