pierrespring.com

geek, punk, pussy …

Archive for the ‘Meta’ Category

Two Talks at Symfony Live 2011

I am thrilled to announce that I’ll be talking at the Paris edition of the Symfony Live Conference in a couple of weeks!

I have been introduced to symfony 1.4 a bit over a year ago and it was a revelation. I was about to jump over to Python in order to be able to use Django for my private projects when Jordi and Lukas basically force fed me symfony. It’s ease of use and the amazing documentation that came along made me forget all about Django. I spent several evenings going through the Jobeet tutorial and I was ready to bootstrap my first webapp in just a few hours.

Due to its amazing documentation, we got an entire team ready for productive work in under 2 days at Liip.

Symfony2

The next big thing will be Symfony2. Symfony2 is a complete rewrite of the framework that will give your next project a strong foundation. Dependency injection makes it completely testable and modular, it makes use of namespaces and supports http-cache and ESI. And there is much more!

Symfony2 is probably the one and only state of the art PHP framework you should consider these days. And if you want to learn more about it, join us at the Symfony Live 2011 in Paris.

I will be talking about frontend optimization and PHP security in Paris along with 29 of the most interesting people in the PHP world.

Don’t you think you should join us?

Monday, February 21st, 2011

TechZing Compilation – Bootstrapping

Justin Vincent from TechZing made a compilation of Podcasts around Bootstrapping a Web App Business.

I wanted to download all of these episodes to listen to them on my iPod later. This is why I created an RSS feed of the compilation to use with iTunes:

http://files.pierrespring.com/techzinglive_bootstrap.rss

Simply add the feed url to Advanced > Subscribe to Podcast… in iTunes and then click Get All as shown in the following image:

Friday, November 19th, 2010

My variable declaration got hoisted

I already talked about function scope in my last blogpost. Yet to fully understand how functions scope works, it might be good to look at the hoisting of variable declarations.

To non-native english speakers like me, the word hoisting itself presents a certain mystery. Here is what Wiktionary tells us:

Verb to hoist: To raise; to lift; to elevate; especially, to raise or lift to a desired elevation, by means of tackle or pulley, as a sail, a flag, a heavy package or weight.

This is precisely what JavaScript does with a variable declaration.

The var statement

var counter = 0;

gets split into two statements:

// A var statement in which the variable counter is declared and
// initialized to undefined.
var counter;

// An assignment statement which assigns the value 0 to the variable.
counter = 0;

When we say that the variable declaration gets hoisted, we mean that the declaration part of the var counter = 0; statement is put to the beginning of the function by the interpreter, meaning that the two following functions are equal:

var f1 = function () {
   // some code
   var counter = 0;
   // some more code
}

var f2 = function () {
   var counter; // initialized with undefined
   // some code
   counter = 0;
   // some more code
}

f1 gets actually transformed into f2.

Remember how we defined function scope: A variable declared anywhere in the function is visible everywhere in the function. The hoisting of variable declarations is the reason for this.

Hoisting of the variable declarations is also the reason we recommended to declare variables in the beginning of the function in JavaScript. This is different from most C like languages, in which it is recommended to declare variables where they are actually used.

Let’s look at an example to see why declaring the variables at the top of a function is important for a better understanding of the program:

// a global variable
var counter = 0;

var f = function (data) {
   counter++;
   // so something
   for (var counter = 0; counter < data.length; counter++) {
       // do something
   }
}
f([1,2,3]);
alert(counter); // -> 0

This seems wired, right. The increment of counter++ at the beginning of f() seems to be applied on the global counter variable. But due to the hoisting of the declaration within the for(;;) loop, the increment is applied to the counter declared in the loop.

That’s it. I think that I coverd all the basics of function scope and lexical scoping in the last two posts. In my next post, I’ll show how to rewrite f in order to be able to use a counter variable within the loop and still have access to the counter from the enclosing scope.

Thursday, May 20th, 2010

Hello world!

Here we go. After quite some time, I finally managed to go online with this blog. My plan is to write about the things I learn or discuss with my workmates, so it will most likely be about PHP, Javascript, HTML5, DBs and Servers. Anything we web app developers encounter daily.

I will try to write at least once a week. This should be more than enough, taken that I have a 100% job at Liip, that I record at least one podcast a week (either for entrefaces.ch or macvox.ch), that I organize the webmardi sessions once a month and that I try to be a somewhat present father of two and husband.

It seems a wee bit too much.

Anyway: Big thanks to Stefan Sicher for the design and David Aerne for helping me with CSS.

Saturday, April 10th, 2010