Monday, November 14, 2011

Future of Web Application Development - A journey to the ‘Dart’ side.


Finally it looks like all the big players fundamentally agree on the importance of having a unified development model to cater for different distribution channels like Web, Phones, Pads etc..
The dropping of ‘Flash’ from mobile devices by Adobe, The direction Microsoft seem to be taking with Windows 8 and the buzz around HTML 5 in th community all points in 1 direction. They all indicate that ‘Web’ could be the platform of choice for different kind of applications running on different devices like computers, phones and pads.  What this also means is that the benchmark of a web application has to rise to the level of native applications in order to maintain the same user experience a Phone or Pad user currently have with native apps. So how prepared are we in terms of achieving this goal?

HTML5 looks like a big contender to address the initial goal of having a common development model which cuts across different consumer devices. It’s rich specification and the pragmatic approach of formulating the specification (Bottom-up approach) makes it even more promising.  Along this path, it’s only a matter of time when we meet ‘javascript’, the de-facto programming language in the web.

Javascript is renowned for its inconsistency across browsers (platforms). Coupled with its highly dynamic behaviour (thus lack of tooling) its plain to see that it will have its work cut out. However during the past few years javascript community has risen up to the challenge collectively by inventing amazing techniques, libraries, practices and great literature to build confidence among loyalists as well as some critics.

However Google intends to intensify the pressure on Javascript, by introducing ‘Dart’ a new programming language, whose primary objective is to make web developers create applications with the same quality as native apps but without the huge costs currently associated with such an effort.

Google is in a unique position to do something of this nature, due to its capability to reach many consumer points via its chrome browser (PC) and Android platform (Mobile). This distinct advantage will be a great platform from both a technical and marketing point of view. (Story could have been different if Windows Phone was a success)

The biggest challenge will always be how Google manages to convince other  browser vendors to support Dart. The bottom up approach is to use Chrome -Android to create large enough community of web apps & developers based on dart which would eventually convince browser vendors to start supporting it. The other way is to ‘sweet talk’ vendors to start supporting it straight away and see how the community embrace it. The current approach however is to compile Dart to javascript. Here again Google is at an advantage due to its previous experience with GWT.

From a more technical point of view, Dart interested me due to following;

1. Better tooling than Javascript
2. Interesting principals like optional types and isolates.
3. A simplified DOM

It will definitely be useful for a web developer to get their hands dirty with Dart soon. Following are some of the best resources I found.

Dart Official Web Page - http://www.dartlang.org/ (Check out the Tech Spec)

Dart Online IDE - http://try.dartlang.org/
Dart Eclipse based Editor - http://www.dartexperience.com/en/2011/11/03/dart-editor-windows/

Dart Interview - http://channel9.msdn.com/Blogs/Charles/SPLASH-2011-Gilad-Bracha-Dart-Newspeak-and-More

Brendan Eich on Javascript Future (And Dart)
http://channel9.msdn.com/Blogs/Charles/SPLASH-2011-Brendan-Eich-JavaScript-Today-and-Tomorrow

Wednesday, June 29, 2011

Rediscovering JavaScript

I've recently grown an interest on javascript. Having working on a project which uses javascript a fair bit I daily hear my co-developers bitching about it. This is the second time I'm doing javascript after 4-5 years and what I've realized is that the attitude towards javascript by many developers hasn't changed much. But during these 5 years or so a lot of innovation has been happening around javascript.

One milestone of this elevation of javascript as a language is, Douglas Crockford discovering 'Good Parts' of Java Script, which elevated javascript status as a noteworthy language. Around the same time the development world started recognizing a new programming paradigm around dynamic languages and javascript also fit right in. Javascript is a truly dynamic language and its prototype based nature allows it to do some wonderful and wild things.

This realization of JavaScript powers has made javascript to become the target compilation language for several other mainstream languages. This is quite an interesting idea which on the surface protect developers from inherit pitfalls and inefficiens of developing with javascript. GWT which compiles from Java, Script # which 'tries' to compile from C# are two such attempts. GWT is quite mature and been used in main stream applications by Google. 

Google built a great browser, Chrome which relies heavily on a fresh javascript engine (V8) developed in-house to run web sites faster. This has stepped up the benchmark for javascript performance on the web and inspired others to innovate on both javascript engines as well as insanely live and active web applications. The debugging support in modern browsers like Chrome, Firefox and IE9 has helped a lot in this endeavor.
The interesting aspect of V8 is that it can be used independent of the browser inside other contexts as a javascript engine.

V8 and it's capability to live outside the browser has helped a great deal in the development of Node.js, a collection of libraries and a javascript runtime on top of V8. It's a radical way of server side development with javascript which utilizes the callback event model of javascript to write highly efficient server side code.  Currently the Node.js libraries are focused on Network and Filesystem. There's a lot of interest around Node.js and Microsoft is actively working with Joyent Software to release Node.js for Microsoft-Azure platform.

So looking at all these innovations and potential around javascript it's time we developers take it seriously and give it the respect that it deserves. A good way to go about this is to (re)learn it and I strongly suggest the work of David Crockford. Here's a good resource for Node.js.

Tuesday, May 31, 2011

Pickups - May

The best video I've seen on how Software (Big Software) is made. The chief release engineer (There's only 3 of them btw) of facebook talks about how they achieve releases of facebook to billions of users every single day.

Sunday, May 22, 2011

Secular SriLanka

Living outside Sri Lanka for over an year now, I'm beginning to appreciate aspects of secular governance in a country. 'Secular Sri Lanka' is a movement (mainly online driven) which attempts to drive the importance of 'Separating the constitution of Sri Lankan state (i.e governance) from religion'. It started quite recently and so far I've read some good articles by its activists. There are many many writings in the web for secularism related work internationally, although recently the focus seem to be more on atheism.

Secularism is an important step in the progress of a nation as can be seen the world around. Starting from European nations like Scandinavian based countries to Asian countries like China and even India have achieved different levels of secularism in their states. On the other hand countries like the USA has diverted from its secular roots and moved more towards a Christian nation thus locking horns with other extreme Muslim nations. This discussion is specially relevant in Sri Lanka with the revamped march towards a religious state in recent times. Also there are several articles in Sinhalese which is a positive in itself.

Secularism enhances objective decision making at a state level and encourages every citizen in the country to work together regardless of their individual beliefs.

I'd like to point to some interesting articles I read recently from 'Secular Sri Lanka' facebook group for interested readers.




The links to the website, blog and the facebook group of Secular Sri Lanka can be found here, here and here .

Thursday, March 24, 2011

Auto Mapper

One of the most repeaterseted tasks of programming against a 3-tier design is the need to convert objects at each layer.

Persistence Layer → Business Logic Layer → Presentation Layer
Entities → Domain Objects → (Model - View Model)

In a typical Microsoft technologies based design techniques the Entities → Domain Objects transformation can be automated by an ORM technique like NHibernate.

This leaves us with the tedious manual conversion of Domain Objects to View Models. While the Domain Object design is driven by how we envision the business domain, the view models are generally govern by the User Interface. Pretty much all the time there’s a gap between the two class structures. This is where a tool like AutoMapper comes in handy.

With AutoMapper you can pre-create maps (mappings properties of destination class to source class) between two classes and then when a conversion is needed just pass the source object and the mapping to the AuroMapper to receive the resultant object. This technique has couple of advantages.
1. All the transformation logic is central. Maintenance of the transformation with time (when domain objects evolve) is easy and error free since you know you have to change it in only 1 place.
2. The transformation code it self is terse as AutoMapper abstracts most conversions.

Examples - Creating Maps:
1. Destination is a flat object with matching property names.


Mapper.CreateMap<SourceObject, DestObject>(); 


2. Same kind of transformation but for a list of items


Mapper.CreateMap<List<SourceObject>, List<DestObject>>();


3. Destination object structure is not totally aligned with the source
Source


Class Student {
string FirstName;
string LastName;
DateTime BirthDate;
}


Destination


Class StudentModel {
string FullName;
string BirthYear;
}

Mapping


Mapper.CreateMap<>()
.ForMember(dest=> dest.FullName, opt => opt.MapFrom(src=> src.FirstName + src.LastName))
.ForMember(dest=> dest.BirthYear, opt=> opt.MapFrom(src=> src.BirthDate.Year)

4. Polymorphic Mapping.
Sources


Class ParentSource {
string parentValue;
}
Class ChildSource {
string childValue;
}

Destinations


Class ParentDest {
string parentDest;
}

Class ChildDest {
string childDest;
}

Creating the map (IncludeMap clause)


Mapper.CreateMap<ParentSource, ParentChild>().Include<ChildSource, ChildDest>();
Mapper.CreateMap<ChildSource,ChildDest>();

It's also important to be sure that your mappings do not break over time. One way to keep firm track of them is to have a unit test verifying all your mappings. This can be done using the 

public void AutoMapperTest()
{
      AutoMapperConfiguration.Configure();
      Mapper.AssertConfigurationIsValid();
}

Tuesday, March 01, 2011

Wednesday, February 23, 2011

Forecast : 'Cloudy'

Cloud computing is gaining a lot of hype these days. Beside the hype, lately there were some real world success stories of large scale cloud implementations as well. One instance is when the catastrophic floods hit Queensland, the state government together with couple of private IT organizations was able to put up a relief management web site (based on Windows Azure) within 4 days to cater millions of relief requests. This capability to scale up and down quickly is one of the nicest features I see on Cloud. Another success story is from a company which handles sporting event ticket sales. This is again an excellent domain for flexible up-scaling where ticket sales will be very high the day tickets are issued.

But as usual with any new technology the reservations are still there. This is the time when the tech-heads needs to justify to their managers the potential and benefits of the Cloud. Listed below are some common questions that can be asked by your manager.

1. Are we loosing control?
It will freak many CTOs to understand that the data centre of their whole system is someone else's responsibility.
- Lack of control over Availability
This is a myth. Your chances of scaling up to increase availability in extremely agile fashion is infact one essential feature of the Cloud. What this means to the business is that your costs could be more operational (rather than one-off), just like utilities-Electricity. So availability and the cost of availlability is one of the last things the CTO should be concerned about.

- Hard(er) Disaster Recovery
Since the cloud is essentially geographically distributed it will stand a better chance of being up and running in the wake of a disaster. Also the vendors running cloud infrastructure are much more experienced in running data centres than most of the companies who are running their own data centre.

It would be interesting to study the SLAs of cloud vendors in light of availability and disaster recovery.

2. How secure is our data?
Many institutes do not like their data to be out of their walls. Many government institutes and financial institutes are popular examples. There are couple of answers to this. One answer is private clouds where you control the cloud. The other more desirable option is to understand that your applications comprises of both data (both sensitive and insensitive-public) and application logic. It is very much possible to distribute the application such that most computation and public data resides in cloud while the sensitive data still continue to reside inhouse.

3. Can we be sued?
The advances in IT continue to outpace the law and regulations. This result is a situation where most of the regulations around IT/Systems are severely outdated. Most of the time we are uncertain to say the least. Again most of the regulatory anyway focuses on data less than computational power. Thus a hybrid cloud approach has a higher potential for success in this context.
At this moment it would be wise to discuss with your legal specialists for specific pit-falls.

It will be very interesting to see how much of the hype surrounding the Cloud would turn out to be real.