My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.
Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Sunday, October 11, 2009

ES5 and function default scope

This is just a quick one. One of the worst decision about ES5, after the one to remove arguments.callee when "use strict" is present, is the missed default reference to the global object. Probably the most secure trick to retrieve the native window in JavaScript is this one:

// wherever we are
var global = function(){return this}();

// while window, could be simply a variable
// assigned somewhere else in this scope


I have already talked about this, and I am still against some ES5 "feature" which aim is probably the one to make JavaScript as fast as possible, regardless all code that will break if "use strict" is present in the generic scope.

Another non-sense is to allow a this in a context where there is no this. Rather than an error, ES5 will point refer this to undefined.
Are you kidding me? this is a special keywords related to the context and you are telling me a context is undefined? so I guess open(), as example, should throw an error there, since window cannot be implicit in an undefined context, isn't it? ... anyway, fortunately the whole problem could be quickly solved in this way:

// ES5 problem
(function(){
"use strict";

this === undefined; // true ... LOL!!!

})();


// WebReflection QAD solution
(function(){
"use strict";

this === window; // true ... yeah baby!

}).call(this);

This simple modification could avoid lots of headaches plus could avoid scope resolution for every window variable.

It's probably quite obvious but I can already imagine lots of people changing the whole function body rather than add a call at the end :D

The trick to retrieve the global context won't work in any case for nested functions, unless we are not sure that this points to window, but being the trick goal the one to make window resolution quick and safe, there is not window,self,top, whatever check that could solve the problem (unless [].sort() will be still buggy ...)

As summary, the day JavaScript will be that fast thanks to removed dynamic and run-time features, it won't be JavaScript anymore but another language a la ActionScript 2 when ActionScript 1 was enough, and the problem was the player rather than the language, which indeed has been replaced by ActionScript 3 even if the problem is still the player and not the language, since it can be compilable into old versions.

Thursday, October 01, 2009

Randomly Speaking ...

These days have been a bit chaotic, lots of news, good and bad, unfortunately somebody decided a day has only 24 hours and somebody else decided sometimes we need to sleep, so from 24 we pass to 18 ... this is a quick random post about changes and thoughts

I Am One Of The Ajaxians!

Thanks to Dion Almaer, or if you prefer "it's Dion fault!!!", I am glad to be one of those guys there talking about everything Web related, development, techniques, news, mobiles, whatever, as long as it makes sense and will keep us updated with the latest kill app.

Formaldehyde Has Been Updated

My simple Ajax / PHP debugger has slightly changed to solve a couple of annoying bugs. One was a typo, another one a new XHR feature (or better, limit) so theoretically, Formaldehyde should not caouse problems anymore.

The Real Problem Is Not IE6 But Windows 2000, 98, Me

Google Chrome Frame demonstrated that people want a better browser but there are still so many companies stuck in deprecated operating systems.
The most interesting analysis I could do is thanks to this reply in Frame ml:

Our company uses ALMOST 100% Windows 2000 OSes ... in our business, we always use a web application that uses a LOT of javascript, IE6 is Slow and always gets a javascript Error and needed the browser to restart.. the employees productivity
is continually monitored, this browser failures are a big problem.

Please let me summarize with a reply ...

Dear Companies

If your business is mainly based over a web/network architecture, the only one that will fall down day after day will be simply your business. An upgrade does not cost anything, and old PCs could install without any problems whatever free Operating System without slowing down your productivity making you, and your business, updated, 'cause the rest of the world and everything that works behind a browser is moving forward, so you are simply deciding to stay behind without a valid reason.
How can you justify slow productivity? How much this slow productivity, missed IE6 features, and an old, deprecated, application based over IE6, can mean for your incomes? Think!

The London JavaScript Group Should Survive!

This is the bloody Europe financial capital and one of the main IT center and nobody is interested into the programming language of the past, the present, and the future? This is unacceptable, is often thanks to JavaScript ignorance that our business is not that interesting as USA one ... with all those new thingy that "must be Flash or Silverlight!" while nowadays, 70% of the time, it is simply JavaScript!!! If I could have produced some silly stuff like the Liquid FX, guess how much JavaScript skills and knowledge could bring inside your on-line applications. Be interested, and do not follow Jurassic patterns a la "server side developer and just a web designer with jQuery knowledge", this is not enough for whatever start-up or whatever web based service.

TechHub Is Getting Started

This IS what I was expecting from this city when I moved here almost 2 years ago and not a dead JavaScript group ... ThechHub, finally some fresh air outside deprecated development models so loved in most of those companies fell down during the credit crunch ... Innovation is the key, everything that let us survive is wrong, everything that let us grow up, is good ... even in latter case, we could grow up even more, doing right steps, Think!

That's it, told'ya it was random ... have a nice week end if I won't have time to post again.

Thursday, September 03, 2009

JScript Console - A Simple One

After I've read Ajaxian post about JavaScript as a command line scripting language I thought it could be interesting to know how to create the first Windows console.

The console.js File


function print(text){
WScript.StdOut.WriteLine(text);
};
function quit(){
WScript.quit(1);
};
while(!WScript.StdIn.AtEndOfStream){
try{
eval(WScript.StdIn.ReadLine());
}catch(e){
print(e.message);
};
};
WScript.StdOut.WriteLine("bye!" + "\r\n");


The console.bat Launcher


@echo off
cscript console.js

A double click in latter file, and that's it, the most basic native JScript console ever has landed in your PCs - enjoy :)

Saturday, January 24, 2009

PAMPA 1.0 - Jaxer included!

Update - Windows Home Fixed!
Version 1.0b contains hot fixes for Window$ Home Edition plus some little change to make PAMPA more robust than before during process managment.
If you already downloaded version 1.0 you can download only the Tray executable and rename it as PAMPA.exe

Please tell me if you have still problems, hoping this b version will be the final 'till 1.1 ;-)

Update
Final Version 1.0 now served via Google Code ;-)



I am proud to announce the first Release Candidate final 1.0 release of my tiny precious PAMPA, jumped from version 0.7 to 1.0 and rewrote from the scratch considering every suggestion its users gave me during these years (project born in 2006 and completely revisited for version 1.0)

What is PAMPA-J


PAMPA means Portable Apache, MySQL, and PHP Application, in this release with Aptana Jaxer included!
(shell I consider PAMPA-J a portable Aptana Cloud?)

What does it mean: Portable


PAMPA is the first customizable and portable WAMP environment that includes Jaxer and that is completely free (but of course donations are always appreciated).
You can launch PAMPA from an USB driver, a CD-ROM (without native database write capabilities), an external Hard Disk, your Hard Disk itself, configuring MySQL data folders, session folders via php.ini, Apache folders, Jaxer folders, and reading logs, changing configuration, in a truly simple way.

Where is it?


For some reason Google Code policy is to ask sourceforge about projects with the same name, so in Google Code I had to change PAMPA project name into PAMPA-J, considering that somebody created an empty PAMPA project in sourceforge 1 year ago, while PAMPA exists at least since February 2006 ... anyway, the link I provided already should not show the RC release yet, while this one, directly from the svn, is the unofficial Release Candidate 1 Direct Download

How does it work?


All you need to do is to choose a folder to decompress PAMPA and then launch PAMPA.exe from that folder, wherever it is.
The result, by default, should be a fully configured Apache, MySQL, PHP, and Jaxer environment for your Window$ 2000/XP/Vista/7 Operating System.
I am working to create a better "splash page" to introduce PAMPA, but right now the Release Candidate shows simply the Document Root with links for some file, Jaxer public folder included ;-)

What's in



  • Apache 2.2.11

  • MySQL 5.1.30-community

  • PHP 5.3.0 alpha 3 (RC1)

  • Jaxer 1.0.2.4347

  • phpMyAdmin 3.1.2



Why all this effort for a Release Candidate?
Because I am looking forward for your feedback, in order to release the first portable WAMP plus Jaxer environment with all you need to develop for your own or for distributions your applications and with all you need (in a reasonable way :D)


PAMPA-J is out, have fun! 8-)