Google Dash: JavaScript replacement

Stumbled upon an interesting newsletter on Google plans to replace JavaScript in future by its more sophisticated language – Dash that will be aiming same goals but in bigger scales:

Future of Javascript State of affairs Building delightful applications on
the web today is far too difficult. The cyclone of innovation is
increasingly moving off the web onto iOS and other closed platforms.
Javascript has been a part of the web platform since its infancy, but the
web has begun to outgrown it. The web development community has been
backed into using large amounts of JS largely to work around the
deficiencies in the platform. Complex web apps–the kind that Google
specializes in–are struggling against the platform and working with a
language that cannot be tooled and has inherent performance problems. Even
smaller-scale apps written by hobbyist developers have to navigate a
confusing labyrinth of frameworks and incompatible design patterns.

That will be interesting to check. The launch of Go language found its niche in developers’ community. If Dash will be as good as they’re planning – it will solve bunch of issues with client-side development.

JavaScript: Private and Public methods in Namespaces

JavaScript is a fascinating language. The lack of built-in OOP concepts and chaotic structure (from the first sight), allows a big degree of flexibility that allows programmers to mimic almost any OOP pattern and achieve common OOP practices.

The absence of “public” and “private” scopes can be substituted with closure functions and namespaces.

Here’s a small example of a closure function that emulates public and private scope:

var NM = {}; //basic namespace

NM = (function(){
  var _foo = 2; //private variable within namespace

  //private method accessible within namespace only
  var _add = function(b) {
     _foo += b;
  };

  //public scope is an anonymous object returned
  return {
     addition : function(a) {
       _add(a); //calling private method within public
     }
  };
})(NM);
NM.addition(2); //works
NM._add(3); //doesn't work

It allows to clean up code base, dealing with heavy load of client-side programming. Program-wise it becomes easier to separate code into sub-namespaces and distinguish all programming logic between its areas of implementation. Futhermore, keeping code clean and structured this way allows avoiding various bugs and compile JS in lighter versions with Closure JS Compiler or any other.

 

 

E-Track yet another upgrade

E-Track finally got another version increase, with some major DOM clean-ups. Now, less code for more functionality. A fight with w3c was successful, and now we get beautiful code, following w3c standards.

It seems that not many products in our sector (IT/Shipping Industry) care about “not making evil” while creating products.

Of course, classical issues are the lack of time, corporate standards, and so on and so forth. But it takes only one web-browser to spoil the attitude towards the product. That’s why the recent releases are cross-compatible checked. Thankfully users can use the browsers of their choice.

 

e-track VMS browser statistics

 

Javascript namespace development useful links

The time has come to optimization of Client-Side of our work projects.

For the last 1.5 years, it’s been tones of JS written, re-written, optimized. The architecture is going to be revised and re-arranged under most of the projects, due to following reasons:

  • Just plugging in “Yet another jQuery plugin” is not working any more.
  • Heavy reliance of projects on Client-Side functionality and absence of structure in it – root of all evil!
  • There’s a need of building a middle layer client-side functionality that will be easily adjustable for any upgrades of frameworks underneath it.
After surfing some web on the matter, here’s a number of good articles on JS scoping:
Later, I’ll publish some information on JS Unit Testing Frameworks that simplify JS development in godzillion times! ;)

Mobile wars: end of WebOS

On the 18th of August, HP announce  on the end of development and support of WebOS line of products:

The list of things that HP has failed to execute on with webOS since the acquisition is a mile long. The company has failed to use HP’s vaunted “scale” to grow the webOS Global Business Unit (GBU) enough so the division could create products to match HP’s ambition. It failed to release compelling hardware, instead using Palm’s old and tired designs for the Veer and Pre 3. HP released the Veer but failed to convince consumers that small phones could be cool again

The mobile market is left with main players: iOS, Android, Windows Phone OS, and some minor players from Bada and MeeGo.

Who’s next: Bada or MeeGo?

Firefox: access local files via Javascript

Accessing local files via ActiveXObject is quite easy, but using Firefox browser got me stuck with “undefined” errors and lead to Mozilla workarounds.

Following JS script accesses local file content and prints out to FireBug console:

function readFile(srcfile) {
    try {
        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
    } catch (e) {
        alert("Permission to read file was denied.");
    } 

    var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
    file.initWithPath( srcfile ); 

    if ( file.exists() == false ) {
        alert("File does not exist");
    } 

    var is = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance( Components.interfaces.nsIFileInputStream ); 

    is.init( file,0x01, 00004, null);
    var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance( Components.interfaces.nsIScriptableInputStream ); 

    sis.init( is );
    var output = sis.read( sis.available() ); 

   console.log(output);
} 



Note, that Firefox will prompt the user whether it’s allowed to execute any local operations via JavaScript.

Read File

 

Firefox new release cycle critics

The major problem is testing. Many corporations have in-house Web applications—both custom and third-party—that they access through their Web browsers, and before any new browser upgrade can be deployed to users, it must be tested to verify that it works correctly and doesn’t cause any trouble with business-critical applications. With Mozilla’s new policy, this kind of testing and validation is essentially impossible: version 5 may contain critical security fixes not found in version 4, and with version 4 end-of-lifed, the only way to deploy those fixes is to upgrade to version 5. (c)

Rephrasing this paragraph, I’d say: “Stop developing for IE6 and get yourself a life..”

GIMP: Color replacement for sprites

Recently, I had to modify some icon-sprites. There was no Photoshop next to me, so I had to google a bit for color replacement tutorials for Gimp.

It appeared to be quite easy, although I still prefer using Photoshop for doing basic image manipulations, filtering and stuff.

replace colors in gimp step 1

replace color 1

 

In major window choose “Select” -> “By Color”.

replace colors in gimp step 2

replace color 2

 

 

Use the wand to get desired color you want to replace (use Control and Shift to increase/decrease replacement color regions). After you’re done with replacement area, navigate to “Colors” -> “Colorify…” and replace selected color.

 

Done! ;)

Fedora 15, Gnome 3 impressions

It’s been 2 days since the upgrade of my laptop to Fedora 15. And one of the major updates in this version was dedicated to Gnome 3 environment, that brought the usability on a new level of interaction.

Of course, with such a drastic update, not all of the things are stable and fully functioning, but it’s the matter of few weeks, once the developers community will polish present Gnome environment.

 

Gnome Activities

From the first sight, it was a bit weird using new interface layout after some many years on Gnome2.x as default desktop manager:

  • “Run Application” (Alt+F2) works slower then search bar in “Activities” window, and that’s a bit annoying once you got used to Alt+F2.
  • Customization of the desktop moved to gnome-shell with “gsettings” which moved from simple GUI applets – you have to RTFM a bit more to tune the desktop
  • Spontaneous fails of rhythmbox and audio drivers (Azario RC780) is a classical issue with my Pavilion laptop. Had to fix it on Fedora 12 and now Fedora 15.
  • Slow indexing of applications in “Activities -> Applications” tab. Still search works faster there.
  • Bottom bar pop-up on bottom-right corner is a bit annoying as well.
  • Status bar that shows all the applications running on current workspace – the thing I miss
  • Google Chrome pop-up windows (applets,etc) are not separated in different application running as you do “Alt-Tab” on current workspace.
  • In order to shutdown the laptop, the user has to log out first – weeeird!

In Gnome2.x, I got used to using the mouse at minimum, while in Gnome 3 I’m forced to use it a bit more.

Good parts of Gnome3:

  • Extensions for new environment with JavaScript support made easy. Some of GitHub users already made some nice widgets.
  • Interface design is more aesthetic
  • Activities tab encapsulates all needed interface panels: left-side icons, right-side workspace manager.
  • Easy to customize and tune Activities panels with gnome-shell parameters and CSS.

Hopefully, with the upcoming month, Gnome developers will polish the environment more, to make it more stable, but meanwhile there’s still a list of alternatives as Xfce, KDE, LXDE, etc.