I am not that great fan of Apple, but sometimes they have an idea of doing things correctly (like when they built the iPod). It’s when they start getting proprietary that everything hits the fan.
This is what they’ve said recently:
Standards matter. Before standards, every browser had its own play book. With standards, every browser’s on the same page. Great for developers, standards let them create sites that work on all browsers out of the box. Great for the browsing public, they ensure that you enjoy a great experience on every site you visit. And these technologies are free for anyone to use.
I am currently spending some time checking out HTML5 and CSS3. And from what I can see the browser world is now just as unsynchronized as it was in the first browser war.
My inspiration for checking the new features in HTML5 and CSS3 is the fact that so many people are saying that with HTML5 (and CSS3) Flash is dead.
Well.
The good thing about Flash is that it runs on all platforms, though really slow on iPads and iPhones – but that’s another issue. It is browser independent, which makes it look the same in all browsers. That’s what makes Flash a graphic designers choice instead of HTML5/CSS3.
An example I can use is this:
Let’s say there is a website wanting to show information about the players on the teams playing in the World Cup in South Africa (in 2010). The designer want some animation like flipping cards, sliding in/sliding out and so on. Let’s say the company creating this application wants to use HTML5. Well, he can’t:
- Internet Explorer (from 6 up to current build of IE) does not understand all the 3d-stuff in CSS3
- Firefox 3.6 (and most likely 3.7) does not understand all the 3d-stuff in CSS3
- Opera 10.5 (and most likely 10.6) does not understand all the 3d-stuff in CSS3
- Chrome 5 does not understand all the 3d-stuff in CSS3
So there is only Safari (with about 5% of the market) that understands the 3d-stuff in CSS3. Which is not so weird. Apple was one of the promoters of 3D-transformations in CSS.
Also: In Flash there is only one build. There are no specific style sheet for IE(6-X), Firefox, Webkit/Chrome/Safari or Opera. There are no need for [IF IE] in the HTML/CSS-code.
I do hope that the developers and the designers who works with CSS3 and HTML5 at Apple will become advocates of standards and that they will fight for this in their forums. I experienced the lasts browser war (which Microsoft claims it won… you don’t win wars, ok! and… look where it left us: With IE6 still being widely used in 2010!!!). I don’t want another one in 2010.
And I think there is only one way we can achieve a compliant standard that all browse vendors will follow: Start thinking of your users and the web developers. Stop creating HTML/CSS rendering engines. Standardize on one or two (Webkit and Mozilla, with the latter also being the one to disappear).
Sorry Microsoft. When you are nine years behind… although you did invent the XMLhttpRequest, most important part of AJAX, why not start contributing to an open source project instead?
And sorry Opera. Your market share is way to small, and I think you are better off using one of the other engines and start contributing to those instead. And: Three is one to many (or three is a crowd as the saying goes).
So what shall the vendors do when they cannot focus on their own engine?
- Contribute to the two standard engines (webkit/mozilla)
- Focus on making the best looking, fastest or functional browser out there.
PHP-Tip: Commenting your code
This really isn’t a PHP-tip, but more like a programming tip. But since I do most of my development in PHP (and some in C#, and some on VB) I put it up as a PHP-tip. So there.
This post is all about commenting. Some do it, some don’t. I tend to do it. Sometimes I even comment to much. But that’s sometimes better than not doing it at all.
Why should you comment your code:
I posted this on twitter and I got an answer from Frank W. Zammetti (fzammetti): “The person that wrote this is a grade A a**hole… oh wait, it was me!” I wrote that one once.
I just couldn’t stop laughing.
This is my style of commenting (example in PHP/C/C++/C#-style)
My first line in the file is always the name of the file. This is a habit I’ve grown to use. It is smart when you are editing code in e.g. VI where you not necessary get the name of the file in the titlebar.
// name-of-file.php
Next comes a general description of what the code in the file shall do:
/**
* This file is used to create and edit blog posts
*
Eclipse, Komodo-IDE and NetBeans (And probably other IDEs) supports @todo in the comment. By adding this "tag" you add tasks to your tasks list.
I tend to add tasks in the beginning of the file.
* @todo: This file need some work.
* @todo: Fix the code related to creating blog posts
In the same area I also write out bugs that I have fixed, or tasks that I have completed:
* FIXES:
* 01.01.2010: Fixed a bug related to updating a blogpost
* 17.05.2010: Translated all of the comments from Norwegian to English
*/
(note/suggestion) I wouldn't mind if the IDEs could have a @fixed element that I could add to the end of the line so that the IDE could mark out the task as completed.
Then in the code I can comment like this (note that PHP-example is just as an example here):
// Fixing the string so that it is ready for SQL-input
$string = mysql_real_escape_string($string);
// Creating a string for a dropdown-menu.
foreach ($this as $that) {
$string .= $that;
}
I also sometimes use comments to clear my head or to get a clear overview of the task at hand. This is especially important when you feel that the task is complicated.
An example could be:
/**
* In this section we shall create the tree-view.
* We must remember that all nodes starting with W shall be at the top
* And that we shall mark posts with pictures with a (p) or a small icon
* Also remember that no lines can be longer than 25 characters. Check the left syntax in mySQL...
*/
This is also good practice when you sometimes do not return to the code in a couple of days. An example could be:
/**
* continue here on Monday.
* The idea behind the following section is ... .... .. . . ..
*/
Hope this post regarding commenting your code is of any help for you. If you have any great examples of self criticism in your code, please do post them as comments... (No pun intended)