please leave a comment so that i know what not to write about


Sunday, June 17, 2012

Its a Dynamic(javascript) world

I thought we are living in a world which looked like this
||(or) mayb this LOL

being a web developer i was working with javascript and also at the same time i always preferred to work with something else... Silverlight, Flash mayb.. till recently.. i actually saw what JAVASCRIPT is || has become in the time i worked on ASP.Net MVC.

Javascript evolved from a dynamic sort of functional language that was differently implemented by nearly every browser(and yes that was for you IE6) and every one hated him and i thought it still is that ulgy thing. till i just stumbled upon THIS

This is an old video.. someone was just trying to bring the Javascript to server side. so now same developer /*Who a Javascript developer?*/ can work on both the sides.. client as well as web. and thought that things like these shouldn't be allowed on internet maybe because its a hour long video and now has around 233,492 views just consider the amount ot developer hours wasted here.
but now with the advancement to HTML5 javascript now can have worker threads(working in multiple threads!!) surely a nice thing making use of multiple cores of processors we have.. then i just searched around a little more and i found out that the world belongs to this language.. and im saying this because now

  • As the popularity of javascript has grown data transfer and serializing mechanism have surely shifted from XML to JSON.
  • with the advancement to HTML and JAVASCRIPT more and more client side coding is being done in Javascript and proof of that is death of FLASH.
  • javascript now supports workers (//multithreading!!) and yes thats a thing that was needed.
  • Windows 8 will support programming windows application in HTML and Javascript. so Javascript will actually be used to program actual desktop based applications.
  • Phone aplications /*for godz sake*/ are now being developed in Javascript thanks to Phone Gap. this also means that as a developer you develop once using the language you know and it will work across different phone platforms..WOW. 
          Also there is a trend now days to deliver sort of installed app experience in websites and there leader is Sencha Touch and Ext JS. i love both but yes documentation and tutorials needs to be a lot better. Looking at these two platforms was also good because they tend to make working in javascript a lot easier by trying to make it object oriented. There are other platforms also that work on MVC and are Good like Backbone.js and a free alternative to Extjs, DOJO.. go give them a try.
  • Sockets - Yes ladies and gentlemen. Why go for web based communication model(Request and Response). When you are developing desktop applicatons just Use SOCKETS.
  • Databases-NOSql movement is growing and these databases basically are more performance oriented and less relational.So you cannot make relations in data like we have been doing in Sql and while going through one of the demo videos of MongoDB i found out that it Uses JSON to store data!! So Javascript is also present in databases. Also these databases can transfer data over simple rest based model.. so now a developer can entirely code an application with Javascript without even having a server side thing(what is it anyways?)..

After going all through this i couldnt think of a language which is more powerful than this giant.. a Language that allows

  1. desktop applications //windows will support it
  2. phone applications //nearly all major platforms
  3. Access to databases
  4. A light weight data transfer and storage mechanism.
  5. Server side Applications //for web based applications
  6. Client side Applications //for web based applications.

Last but not the least what about writing javascript code? it is surely a little painful and lack of good IDE's for Javascript is a known thing and here things like CoffeeScript comes to rescue.
Idea of coding in a language whos output is a code in another language can completely blow out anyone but still it is present and if we believe what we hear it is here to stay. || or who knows one day CoffeeScript might take the place of Javascript completely. :)

Friday, April 13, 2012

Dynaminism in .Net 4.0

few dayz ago came across THIS question.
the solution to this can easily be figured out by the new dynamic features introduced in .Net 4.0.
i have made a project to demonstrate this.
the main code in the project goes like this

public static dynamic[] GetDynamicObject(DataTable dt, Dictionary<stringstring> mapping)
            List<dynamic> returnList = new List<dynamic>();
            foreach (DataRow row in dt.Rows)
                dynamic obj = new ExpandoObject();
                var objectDic = (IDictionary<stringobject>)obj;
                foreach (DataColumn column in dt.Columns)
                    objectDic.Add(mapping!=null?mapping.ContainsKey(column.ColumnName) ? mapping[column.ColumnName] : column.ColumnName:column.ColumnName,row[column]);
            return returnList.ToArray();
The static method here named "GetDynamicObject" simply takes a data table(which can be populated by the data in the database) and a dictionary of <string,object> as the mapping. 
then for each row in the DataTable the method makes a dynamic Object of type ExpandoObject which was introduced for the sole purpose of adding and consuming the propertiese at runtime. more info about expando object can be got from here(MSDN link).

The full project i made is available here(Sky Drive link).
There was an error in this gadget