Sunday, October 08, 2006

HAXE :: Web oriented universal language

Introduction

haXe is a high-level object-oriented programming language mainly focused on helping programers develop Websites and Web applications. haXe has been designed to be easily portable across several platforms. The haXe compiler supports the following platforms :

  • JavaScript : you can generate a single .js file from a set of haXe classes. You can access browser DHTML API as well as crossbrowser APIs such as Xml, Date or XmlHttpRequest... haXe is one of the best available languages to develop middle and large scale AJAX Web Applications.
  • Flash : haXe can compile a SWF file for Flash Players 6 to 9. The language has great features and is at the same time both strict and dynamic. Using haXe increases productivity compared to ActionScript. All the Flash APIs are available unchanged in haXe so you will quickly get used to the language, and porting your existing code to haXe will be easy.
  • Neko : haXe can compile bytecode that runs on the Neko Virtual Machine. An haXe program can then be run into the Apache web server (using mod_neko). This allows you to develop the server-side of your website using haXe. haXe has access to all Neko libraries such as filesystem, network, databases... and much more. Since it can easily be extended with additional libraries, haXe can be used to develop full-fledged desktop applications.

haXe Features

The haXe Syntax is similar to the one used in Java/JavaScript/ActionScript, so it’s very easy to learn and get used to haXe. haXe can also integrate easily in your favorite editor or IDE.

The haXe Type System is strictly typed, enabling the compiler to detect most errors at compile-time. At the same time, it’s very different from classic strictly typed languages since you don’t have to write types everywhere in your program, thanks to type inference. It makes you feel like you are programming in a dynamically typed language while you are getting the security of a strictly typed language. The best of both worlds.

The haXe Standard Library, including Date, XML, data structures... is specified to behave the same across all platforms. This enables you to share and reuse code logic between different platforms without needing to rewrite the same thing again and again.

haXe is easily Extensible : you can add additional libraries and wrappers for platform-specific features. Thanks to conditional compilation you can have different implementation for a given API depending on the platform you want to compile to.

haXe has a Remoting library that provides cross platform serialization and RPC, enabling you to directly call methods between platforms. For example calls may be made between the client and the server or between different client modules. Everything is handled transparently.

haXe can be used to develop portable Desktop applications by using SWHX.

haXe is Open Source software and has an active and enthusiastic Community which supports the language by developing content and additional libraries.

Conclusion

haXe is a Toolbox for the web developer. Since the compiler has support for several platforms you can choose the most suitable one to get your job done without having to learn and use a new language everytime. Although using haXe on both the client and server simplifies things thereby boosting productivity, haXe may be used exclusively on the client or the server. You can use haXe where it makes sense for you.

Want to learn more ?

Read the haXe Documentation and have a look at the Language Reference. If you have any questions or remarks, don’t hesitate to join the haXe Community.


from : http://www.haxe.org/intro

Wednesday, October 04, 2006

Google Web Toolkit

What is Google Web Toolkit?

Google Web Toolkit (GWT) is a Java development framework that lets you escape the matrix of technologies that make writing AJAX applications so difficult and error prone. With GWT, you can develop and debug AJAX applications in the Java language using the Java development tools of your choice. When you deploy your application to production, the GWT compiler to translates your Java application to browser-compliant JavaScript and HTML.

Here's the GWT development cycle:

  1. Use your favorite Java IDE to write and debug an application in the Java language, using as many (or as few) GWT libraries as you find useful.
  2. Use GWT's Java-to-JavaScript compiler to distill your application into a set of JavaScript and HTML files that you can serve with any web server.
  3. Confirm that your application works in each browser that you want to support, which usually takes no additional work.

Why Translate Java Code to JavaScript?

Java technologies offer a productive development plaform, and with GWT, they can instantly become the basis of your AJAX development platform as well. Here are some of the benefits of developing with GWT:

  • You can use all of your favorite Java development tools (Eclipse, IntelliJ, JProfiler, JUnit) for AJAX development.
  • Static type checking in the Java language boosts productivity while reducing errors.
  • Common JavaScript errors (typos, type mismatches) are easily caught at compile time rather than by users at runtime.
  • Code prompting/completion is widely available.
  • Automated Java refactoring is pretty snazzy these days.
  • Java-based OO designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation.

Using Google Web Toolkit

You can use GWT's set of UI components (called Widgets) to construct the UI elements that make up your AJAX application. Like traditional UI frameworks, Widgets are combined in Panels that determine the layout of the widgets contained within them. This is a complete GWT application that displays a button with a click handler:

public class Hello implements EntryPoint {
public void onModuleLoad() {
Button b = new Button("Click me", new ClickListener() {
public void onClick(Widget sender) {
Window.alert("Hello, AJAX");
}
});
RootPanel.get().add(b);
}
}

GWT supports a variety of built-in Widgets that are useful for AJAX applications, including hierachical trees, tab bars, menu bars, and modal dialog boxes. GWT also has built-in support for remote procedure calls and other more sophisticated web application features. See the complete list of features for more information.

Debugging and Deploying GWT Applications

GWT applications can be run in two modes:

  • Hosted mode - In hosted mode, your application is run as Java bytecode within the Java Virtual Machine (JVM). You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java's debugging facilities and remain within an IDE like Eclipse.
  • Web mode - In web mode, your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to-JavaScript compiler. When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application.

To support hosted mode, GWT ships with a special web browser with hooks into the JVM. See the GWT architecture diagram below for more information.

For a step-by-step installation and usage guide, please see the Getting Started Guide.

Google Web Toolkit Architecture

GWT has four major components: a Java-to-JavaScript compiler, a "hosted" web browser, and two Java class libraries:

Google Web Toolkit (GWT) architecture

The components, from bottom to top, are:

  • GWT Java-to-JavaScript Compiler
    The GWT Java-to-JavaScript compiler translates the Java programming language to the JavaScript programming language. You use the GWT compiler to run your GWT applications in web mode.
  • GWT Hosted Web Browser
    The GWT Hosted Web Browser lets you run and execute your GWT applications in hosted mode, where your code runs as Java in the Java Virtual Machine without compiling to JavaScript. To accomplish this, the GWT browser embeds a special browser control (an Internet Explorer control on Windows or a Gecko/Mozilla control on Linux) with hooks into the JVM.
  • JRE emulation library
    GWT contains JavaScript implementations of the most widely used classes in the Java standard class library, including most of the java.lang package classes and a subset of the java.util package classes. The rest of the Java standard library isn't supported natively within GWT. For example, packages like java.io don't apply to web applications since they access the network and local file system.
  • GWT Web UI class library
    The GWT web UI class library is a set of custom interfaces and classes that let your create web browser "widgets," like buttons, text boxes, images, and text. This is the core user interface library used to create GWT applications. GWT ships with the complete source code for the library under an open source license.

For a step-by-step installation and usage guide, please see the Getting Started Guide.

How Well Does It Work?

We're biased, but we think it works pretty darn well. The primary metrics we use to evaluate GWT's effectiveness relative to traditional AJAX development are:

  • Compiler-generated JavaScript size
    A typical, full-featured GWT application will require the user to download about 100K of cacheable JavaScript, which is in line with most hand-written AJAX applications.
  • End-user performance
    GWT applications are almost always as fast as hand-written JavaScript. The GWT compiler avoids adding any wrappers around any functionality that is implemented natively in the browser.
  • Development time
    With so little time spent debugging problems in individual web browsers, you can spend much more of your time on application functionality. Development time efficiency is our favorite part of GWT.

Try it out for yourself, and let us know what you think.

Google Web Toolkit Features

  • Create a Widget by compositing other Widgets. Lay out Widgets automatically in Panels. Send your Widget to other developers in a JAR file.
  • To communicate from your web application to your web server, you just need to define serializable Java classes for your request and response. In production, GWT automatically serializes the request and deserializes the response from the server. GWT's RPC mechanism can even handle polymorphic class hierarchies, and you can throw exceptions across the wire.
  • No, AJAX applications don't need to break the browser's back button. GWT lets you make your site more usable by easily adding state to the browser's back button history.
  • In production, your code is compiled to JavaScript, but at development time it runs in the Java virtual machine. That means when your code performs an action like handling a mouse event, you get full-featured Java debugging, with exceptions and the advanced debugging features of IDEs like Eclipse.
  • Your GWT applications automatically support IE, Firefox, Mozilla, Safari, and Opera with no browser detection or special-casing within your code in most cases.
  • GWT's direct integration with JUnit lets you unit test both in a debugger and in a browser...and you can even unit test asynchronous RPCs.
  • Easily create efficient internationalized applications and libraries.
  • If GWT's class library doesn't meet your needs, you can mix handwritten JavaScript in your Java source code using our JavaScript Native Interface (JSNI).

For a step-by-step installation and usage guide, please see the Getting Started Guide.



from: http://code.google.com/webtoolkit/overview.html

Monday, October 02, 2006

Ruby

Wondering why Ruby is so popular? Its fans call it a beautiful, artful language. And yet, they say it’s handy and practical. What gives?

The Ideals of Ruby’s Creator

Ruby is a language of careful balance. Its creator, Yukihiro “matz” Matsumoto, blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming.

He has often said that he is “trying to make Ruby natural, not simple,” in a way that mirrors life.

Building on this, he adds:

Ruby is simple in appearance, but is very complex inside, just like our human body1.

About Ruby’s Growth

Since its public release in 1995, Ruby has drawn devoted coders worldwide. In 2006, Ruby achieved mass acceptance. With active user groups formed in the world’s major cities and Ruby-related conferences filled to capacity.

Graph courtesy of Gmane.

Ruby-Talk, the primary mailing list for discussion of the Ruby language has climbed to an average of 200 messages per day.

The TIOBE index, which measures the growth of programming languages, ranks Ruby as #13 among programming languages worldwide. Citing its growth, they predict, “Chances are that Ruby will enter the top 10 within half a year.” Much of the growth is attributed to the popularity of software written in Ruby, particularly the Ruby on Rails web framework2.

Ruby is also totally free. Not only free of charge, but also free to use, copy, modify, and distribute.

Seeing Everything as an Object

Initially, Matz looked at other languages to find an ideal syntax. Recalling his search, he said, “I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python3.”

In Ruby, everything is an object. Every bit of information and code can be given their own properties and actions. Object-oriented programming calls properties by the name instance variables and actions are known as methods. Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of code which applies an action to a number.

5.times { print "We *love* Ruby -- it's outrageous!" }

In many languages, numbers and other primitive types are not objects. Ruby follows the influence of the Smalltalk language by giving methods and instance variables to all of its types. This eases one’s use of Ruby, since rules applying to objects apply to all of Ruby.

Ruby’s Flexibility

Ruby is seen as a flexible language, since it allows its users to freely alter its parts. Essential parts of Ruby can be removed or redefined, at will. Existing parts can be added upon. Ruby tries not to restrict the coder.

For example, addition is performed with the plus (+) operator. But, if you’d rather use the readable word plus, you could add such a method to Ruby’s builtin Numeric class.

class Numeric
def plus(x)
self.+(x)
end
end

y = 5.plus 6
# y is now equal to 11

Ruby’s operators are syntactic sugar for methods. You can redefine them as well.

Blocks, a Truly Expressive Feature

Ruby’s block are also seen as a source of great flexibility. A programmer can attach a closure to any method, describing how that method should act. The closure is called a block and has become one of the most popular features for newcomers to Ruby from other imperative languages like PHP or Visual Basic.

Blocks are insipired by functional languages. Matz said, “in Ruby closures, I wanted to respect the Lisp culture4.”

search_engines =
%w[Google Yahoo MSN].map do |engine|
"http://www." + engine.downcase + ".com"
end

In the above code, the block is described inside the do ... end construct. The map method applies the block to the provided list of words. Many other methods in Ruby leave a hole open for a coder to write their own block to fill in the details of what that method should do.

Ruby and the Mixin

Unlike many object-oriented languages, Ruby features single inheritance only, on purpose. But Ruby knows the concept of modules (called Categories in Objective-C). Modules are collections of methods.

Classes can mixin a module and receive all its methods for free. For example, any class which implements the each method can mixin the Enumerable module, which adds a pile of methods that use each for looping.

class MyArray
include Enumerable
end

Generally, Rubyists see this as a much clearer way than multiple inheritance, which is complex and can be too restrictive.

Ruby’s Visual Appearance

While Ruby often uses very limited punctuation and usually prefers English keywords, some punctuation is used to decorate Ruby. Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables.

  • var could be a local variable.
  • @var is an instance variable.
  • $var is a global variable.

These sigils enhance readability by allowing the programmer to easily identify the roles of each variable. It also becomes unnecessary to use a tiresome self. prepended to every instance member.

Beyond the Basics

Ruby has a wealth of other features, among which are the following:

  • Ruby has exception handling features, like Java or Python, to make it easy to handle errors.
  • Ruby features a true mark-and-sweep garbage collector for all Ruby objects. No need to maintain reference counts in extension libraries. As Matz says, “This is better for your health.”
  • Writing C extensions in Ruby is easier than in Perl or Python, with a very elegant API for calling Ruby from C. This includes calls for embedding Ruby in software, for use as a scripting language. A SWIG interface is also available.
  • Ruby can load extension libraries dynamically if an OS allows.
  • Ruby features OS independent threading. Thus, for all platforms on which Ruby runs, you also have multithreading, regardless of if the OS supports it or not, even on MS-DOS!
  • Ruby is highly portable: it is developed mostly on GNU/Linux, but works on many types of UNIX, Mac OS X, Windows 95/98/Me/NT/2000/XP, DOS, BeOS, OS/2, etc.


from: http://www.ruby-lang.org/en/about/