Saturday, April 14, 2012

Dart Language in; JavaScript and Delphi out.

Dart Language Fills a Void

Dart Language may become my primary development language!

In a previous blog, I mentioned how Google's Dartium browser for Windows — essentially the Chromium "Chrome" browser with a Dart-Language Virtual Machine (VM) buit in — was made available to developers. Since then, I have been using the regularly-updated builds of Dartium to run my native Dart-language applications (HTML and SVG User-Interfaces with Dart for the business-logic), and I must say, I am absolutely thrilled with the productivity improvements I am seeing when developing with Dart (instead of JavaScript)! Words alone can hardly express the potential this language has for improving web-based software application development.

Dart Language: Web Pages are just the Beginning

Did you catch my use of the term "applications" a bit ago. Dynamic Web content (pages) is just the beginning of what I will be using Dart for. Sure, you can replace your JavaScript code with Dart, and realize the benefit of a much nicer OOP (Object-Oriented Programming) approach to web-development, and realize it NOW, but Dart holds more promise.

Dart's True Potential: Business Applications

I have read a quite a few anti-Dart articles recently, mostly from proponents of JavaScript (ranging from JS evangelists to simply average developers that have used JS for a long time). It has been argued that Dart cannot succeed for various reasons: e.g., concerns that Dart will simply not reach more than a certain percentage of users (if other browsers fail to adopt the Dart VM), that the current JS code base is just too big to migrate to Dart, etc. Although these points may have a bit of validity, the arguments make little sense for any business-internal applications where the browser-choice can be 100% guaranteed to include Chrome (if it remains the only browser to include Dart support). And, really, what is the big deal with installing multiple browsers IF it was needed?

There are millions of software applications that run only "internal" to a business, and many of these internal applications are either "browser-based" or are in need of a transition to "browser-based" form. And, if Dart makes developing such applications a more efficient — and perhaps all-importantly: less-costly — endeavor, then the choice to write applications in Dart will be a simple one. It is not like Dart is difficult to learn if you know JavaScript already; in fact, if you have any OOP background along with some JS experience, you are going to take to Dart Language very quickly, and find yourself incredibly productive compared to JS!

I can't emphasize this point enough: true software applications (not simply public customer-facing web pages) are perfect candidates for Dart. The productivity and re-use of object-oriented development, coupled with a Dart's wonderful core libraries (which are getting better all the time), are a huge leap forward for browser-based applications development. And, this is rather platform-agnostic development too — we're still dealing with a browser that will run on quite a few platforms. And, I have not even touched on the server-side potential (e.g., compared to the spaghetti-code mess of Node.js and 10-level-deep nested javascript closures -- eek!)

Dart: included Libraries = Huge Savings

Ah... the simplicity of instantiating a new List<> object to store references to instances of my custom classes and iterate through them! List is just one of the included Collection types. And, these collections include a nice set of methods for working with the items contained therein. The HTML library provides a somewhat nicer way to work with the DOM than standard JS method too. Overall, Dart is making my life so much simpler and more productive thanks to the language features and the libraries included.

Perhaps more important is how simple it is to create your own libraries. And, unlike JS, you should not worry about global-namespace-pollution; that should be a thing of the past. And when you start writing your libraries, you have all the benefits of a modern typed-language with solid OOP features.

Sure, JS has what is called "prototypical inheritance" and you can achieve *some* encapsulation with closures, but the fact is, for someone with C#, Java, Delphi, or C++ experience, Dart offers "real" inheritance and encapsulation in a much simpler way (i.e., REAL way). Did I mention how wonderful it is to be able to quickly test the Type of an object using "is" when I need to (class / interface testing)! And, you have polymorphic method/constructor signatures, optional parameters, etc. I am a long-time Delphi developer, and I am really taking to Dart in a hurry thanks to all these familiar OOP features.

My first Dart Library: Dart-Based SVG Widgets / Components

I had previously attempted to create a robust SVG (Scalable Vector Graphics) component library using JavaScript, and I got rather far along with it before I hit a wall thanks to JavaScript. JS was simply making my intended component-hierarchy nearly impossible to implement — surely impossible to implement as a formal, strongly-typed, class library as I had envisioned. But, using Dart, I have already surpassed (in little time) the functionality of my previous JavaScript-based SVG widgets and have seen my vision become reality. Dart has provided a much better OOP foundation for building a true software component set / library with!

I have written previously about my desire to replace desktop Embarcadero Delphi-based development with HTML5/CSS3, and I had tried to do so using JavaScript as the underlying language, but simply put: JavaScript sucks compared to Delphi (or C#). Now that I have Dart at my disposal, my transition from Delphi to HTML5/CSS3/Dart is well underway. I have that familiar high-productivity I am used to with Delphi (object Pascal), now nicely coupled with to browser UI technologies of choice (HTML5/CSS3/SVG), and I am moving forward quickly.

Stay tuned for some source-code and samples using Dart! I plan to release my Dart-language SVG Components / Widgets as open-source in the not too distant future. UPDATE: I have pushed an initial release of my Dart/SVG GUI Components to github — see my newer blog post about "Introducing dart-squid: Dart/SVG UI Controls" for details.  Those should demonstrate quite nicely what productivity can be achieved with regards to developing component sets that will run in a browser. And, perhaps people will find the SVG components useful for something I have not even imagined yet. In the meantime, check out Dartium and Dart: this is a language/framework you do not want to overlook.

Continue to read this Software Development and Technology Blog for computer programming articles (including useful free / OSS source-code and algorithms), software development insights, and technology Techniques, How-To's, Fixes, Reviews, and News — focused on Dart Language, SQL Server, Delphi, Nvidia CUDA, VMware, TypeScript, SVG, other technology tips and how-to's, plus my varied political and economic opinions.

No comments: