all repos — h3rald @ 11da4fd310963777f60e444c6ae950e89125d11a

The sources of https://h3rald.com

Reviewed articles.
h3rald h3rald@h3rald.com
Sat, 16 Mar 2024 21:40:06 +0100
commit

11da4fd310963777f60e444c6ae950e89125d11a

parent

62bddb0614f0d79f890f114a721751d48b0802dd

M contents/articles/11-07-2009.htmlcontents/articles/11-07-2009.html

@@ -4,18 +4,6 @@ content-type: article

timestamp: 1248605640 tags: "wedding" ----- -<ul> - <li><a href="#prologue">Prologue</a></li> - <li><a href="#party">The wedding party</a></li> - <li><a href="#stag">The stag night</a></li> - <li><a href="#preparations">The preparations</a></li> - <li><a href="#ceremony">The ceremony</a></li> - <li><a href="#reception">The reception</a></li> - <li><a href="#honeymoon">The honeymoon</a></li> - <li><a href="#photos">Photos</a></li> - <li><a href="#trivia">Trivia</a></li> - <li><a href="#quotes">Famous quotes</a></li> -</ul> <h3 id="prologue">Prologue</h3> <p>Roxanne and I arrived in Ireland on the 3rd of July, just over a week before the wedding day. We thought a week would have been more than enough to finish organizing our big day, and we were right: we spent a few days enjoying our

@@ -194,7 +182,8 @@ have to walk slowly in front of the bride&#8221; &ndash; he said to Delia, the bridesmain &ndash; &#8220;and if you

<em>think</em> you're going slow while you're doing it, you're probably going <em>way too fast</em>&#8221;. But nobody noticed, really, and nobody cared: they were all too excited to mind that, and everyone's eyes were on Roxanne, anyway. She was really, really gorgeous and her dress was fabulous. It felt unreal, at times: we both felt - we were in one of those movies&#8230;</p> + we were in one of those movies&#8230; +</p> <p>The most peculiar thing about the whole ceremony was perhaps the different languages involved: English, Italian, Gaelic and Latin. I doubt there was a single person among us who could understand the entirety of the mass, but it was very evocatory. The whole mass was predominantly in English, with the following exceptions:</p>

@@ -226,12 +215,14 @@ <p>As soon as we got there, my best man was informed by the staff that he <em>had to</em> introduce the bride and groom.

<em>&#8220;What? No, wait! What do I say&#8230; how&#8230; what? Fabio, come back!&#8221;</em> he freaked out, but as soon as I wrote down the two lines he was supposed to say in English everything was OK. Not only did he introduce us properly, he also made a <em>terrific</em> speech: he obviously gave it a lot of thought and it sounded just - perfect.</p> + perfect. +</p> <p>After he spoke, it was my dad's turn. Now, my dad speaks perfect French but never got a chance to learn and practice English (yet), so not only he had to write down his entire speech, he also had to annotate the pronunciation of <em>every</em> word. He managed fine though. It felt a little bit long, but he said really wonderful and touching words about Roxanne and I, our respective families, and countries. I'll publish it soon on the Internet, for - posterity's sake.</p> + posterity's sake. +</p> <p>The last three speeches were Jim's (the father of the bride), who did great as always, without reading anything, right on the spot. And so did Roxanne and I: we basically just said a few words thanking all the guests for coming, and half of them for helping us with the wedding as well. Every speech (except mine and Roxanne's) was characterized
M contents/articles/cakephp-first-bite.htmlcontents/articles/cakephp-first-bite.html

@@ -4,4 +4,11 @@ content-type: article

timestamp: 1152842580 tags: "cakephp|tutorial|review" ----- -<p>According to a recent study, <span class="caps">PHP</span> is one of the most popular programming languages in the world. In spite of this, <span class="caps">PHP</span> is often criticized for its inconsistent naming conventions, its lack of important features as compared to other languages (like namespaces) and its inherent disorganization. Furthermore, <span class="caps">PHP</span> is very easy to learn, and this has often led to the common misconception that most <span class="caps">PHP</span> developers are inexperienced and that their code is therefore prone to security vulnerabilities and exploits.<a href="http://www.sitepoint.com/article/application-development-cakephp">Read the full article</a> on <a href="http://www.sitepoint.com/">SitePoint.com</a></p> +<p>According to a recent study, <span class="caps">PHP</span> is one of the most popular programming languages in the + world. In spite of this, <span class="caps">PHP</span> is often criticized for its inconsistent naming conventions, + its lack of important features as compared to other languages (like namespaces) and its inherent disorganization. + Furthermore, <span class="caps">PHP</span> is very easy to learn, and this has often led to the common misconception + that most <span class="caps">PHP</span> developers are inexperienced and that their code is therefore prone to + security vulnerabilities and exploits.<a + href="http://www.sitepoint.com/article/application-development-cakephp">Read the full article</a> on <a + href="http://www.sitepoint.com/">SitePoint.com</a></p>
M contents/articles/cakephp.htmlcontents/articles/cakephp.html

@@ -4,4 +4,802 @@ content-type: article

timestamp: 1134057819 tags: "cakephp|review|frameworks|webdevelopment" ----- -Web developers can either love or hate PHP, and one of the criticisms of this easy-to-use programming language which is repeated over and over on IRC, forums and blogs is that "PHP is disorganized".<br />Is this really true? If so, is there any possible way to write a PHP application in a logical and clean way? Read on...Every web developer has certainly heard of PHP. Some people like it and consider it a powerful and easy-to-use way to create complex websites or web applications, while others are convinced that it is merely a bad copy of Perl. Opinions are certainly mixed on the matter.<br /><br />One thing to keep in mind when reading criticisms of PHP is its origins, as therein lies the crux of the matter. PHP was created as a form interpreter, initially offering only a <em>very limited</em> range of functionality. Its main purpose was to make life easier for web developers who wanted to do simple tasks, like manipulating form data.<br /><br />People liked the concept - PHP was free and it quickly became popular among developers. More functionality was added and continues to be added with each new release, and PHP is now one of the most popular and powerful programming languages available for web development.It is relatively easy to learn, compared to Perl, ASP, or JSP, and it can be used for almost anything[1].<br /><br />The sheer simplicity of the language was most likely the cause of the enormous amount of exploits discovered through the years which earned PHP the label "<em>too dangerous to use in 'proper' applications</em>". The danger, however, lies not in the language itself, but rather in the <em>way</em> developers make use of the language: PHP's simplicity makes writing bad or exploitable code extremely easy. Furthermore, PHP's ability to be placed within any HTML page with the greatest of ease tempted developers to write ever-increasing amounts of 'spaghetti code', which by its very nature is neither organized nor clean code, and certainly does not help a developer learn how to write organized or clean code.<br /><br />These problems, however, can be solved. There are many ways to go about doing this, but the easiest, most effective way is to create a framework[2]. <br /><br /><br /><strong>Bringing Order to Chaos</strong><br /><br />After learning some PHP myself, I remember noticing that my applications were growing in a disorganized and uncontrollable manner. Things tended to be added at the last minute, and bugs were fixed and patched 'on the fly' wherever they occurred. PHP lacked the structure that is present in most other programming languages. I remember reading the word <em>framework</em> for the first time not too long ago while I was downloading a Windows Update of the .NET framework[3]. That inspired me to start searching the Internet for a 'PHP framework'. That led me to an interesting blog entry[4] where a solution was proposed - a solution to <em>bring order to chaos</em>:<br /><br /><fieldset><blockquote><br />[...] The answer is simple: create our own class library, some kind of framework, the PHP framework. The similar in many ways to that one which is already well known to Java or .NET programmers. We could set the standards, structure and main guidelines. [...]<br /></blockquote></fieldset><br /><br />That blog post made me think about developing my own framework, until I noticed that there were many projects already in progress, and some in fact completed; the end result being a fully functional PHP framework. I read a lot about some of them[5], and abandoned the idea of developing my own, because as a good developer, I believe I should never re-invent the wheel. So I kept looking. I found Pear[6], although that's more a repository of PHP classes with a common standard than a framework, while I was looking for THE solution to developing many types of applications, not merely how to do one thing in particular.<br /><br />I came across a very promising project named Prado[7], which won the latest Zend contest, and was considered the best PHP5 application of the year. It is a masterpiece of coding and PHP5 usage, so I tried to learn it. I even developed a website with it.<br /><br />Prado lets the developer design the application without imposing any ready-made components, but I found its event-driven[8] approach neither easy to learn nor suitable for everyday web applications. I did not like the idea of having to code a reaction to every event (like a click on a button or different phases of page rendering): that is the approach that ASP takes, and at least in that respect, Prado seems to be inspired by the .NET framework. Event-driven programming is suitable for GUI development and desktop-based interfaces, but not for web applications.<br /><br />After trying Prado, I was still unsatisfied, so I once again began my search for a solution to improve my programming. My meanderings took me to Ruby on Rails[9], one of the most recent examples of technology hype on the Net. At the same time,to a certain extent, it is also a successful tool. <br /><br /><br /><strong>The Rails Phenomenon</strong><br /><br /><fieldset><blockquote><br />"Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less code than most frameworks spend doing XML sit-ups."<br /></blockquote></fieldset><br /><br />That sounded like what I was looking for, and I started reading more about it in the vast and varied help sections[10] available both on and off of the official site. The Rails team did an outstanding job promoting and marketing the framework, and also in providing comprehensive textual documentation (and even video tutorials) to help both beginners as well as experienced programmers get started with it.<br /><br />Briefly, Rails uses Ruby's object oriented programming, in conjunction with the MVC pattern and various automated scripts (generators), to help developers program their applications quickly and in a solid and organized way. However, as that is neither clear nor convincing, let's spend a few moments on the MVC Pattern[11], which will also be useful to understanding the following sections.<br /><br />MVC stands for <strong>M</strong>odel <strong>V</strong>iew <strong>C</strong>ontroller: these three words enclose - and this is just a personal opinion - all the wisdom and philosophy of web development, describing - once again, in my opinion - the three most logical parts a web application <em>should</em> be divided into to achieve code robustness, order and power, all at the same time. Let's look at what each of the component parts mean in detail:<br /><br /><ul><br /><li>Model: The model represents the very essence of the </li><em>information</em> and <em>content</em> of a web application. Imagine this as an object able to gather the information and content of your webpages from a particular resource, such as a database. The model is the only entity able to access resources.<br /><li>View: The view is an attempt to separate the most unstable part of an application: the user front-end. A view is only responsible for presenting the information that the Model gathered. A view does nothing but format the output, and can be compared to a template or report. In all MVC frameworks for web applications, only view files contain </li>(X)HTML code, and mostly only that. They can therefore be changed <em>at any time</em> without having to touch a single line of the business logic of your application.<br /><li>Controller: The controller is the 'brain' of the application. Consider it to be the only part of your program that can 'think' and manage the other parts. Controller files are the only ones able to </li><em>order</em> the Model to gather information and then pass the information obtained to the view for display. <br /></ul> <br /><br />Although the MVC seems to make things more complicated, that is part of the objective. Since one of the advantages (and weaknesses) of PHP was its simplicity, the MVC adds complexity to bring more order and logic to the design process. The three entities are separated for just that reason, and trying to put them together can result in potential disasters, since it causes the whole pattern to fail.<br /><br />Coming back to Rails, I was quite impressed by the features it offered, but there was a small problem: the Ruby programming language itself. I experienced some difficulties in setting up the environment properly, and I also discovered that most standard hosting companies do not offer Ruby hosting plans as standard. Hosting issues aside, I would have had to learn Ruby in order to master Rails, and I really did not have the time for that: I had to develop a website quickly and easily, preferably with languages I already knew.<br /><br />After deciding to abandon Rails (for the moment, anyway), I was amazed by the number of projects in other programming languages that try to emulate the famous Ruby framework, to the point of being considered <em>clones</em> or ports of it to another language. To my knowledge, the <em>Rails disease</em> contaminated the following programming languages:<br /><br /><ul><br /><li>PHP</li>[12]<br /><li>Python</li>[13]<br /><li>Java </li>[14]<br /><li>Perl </li>[15]<br /></ul><br /><br />I said <em>disease</em> because Rails developers think that Ruby on Rails was made in Ruby for a reason, namely that Ruby offered some unique features that were not available in other languages. I will not delve into that topic here; more information is available[16] for those who are interested. However, suffice it to say that there are some Rails ports in PHP that were immediately attacked because of the fact or legend that the creator of Rails originally wanted to develop his framework in PHP and then switched to Ruby. Let's examine one of those PHP frameworks in detail.<br /><br /><br /><strong>CakePHP: Just Another Rails Clone?</strong><br /><br />I chose to learn CakePHP (or "Cake")[17] mainly because it offered more features than the other two PHP alternatives. It also seemed to be a more original and actively developed project. In particular, I'd like to quote one of CakePHP's developers, from when he introduced the framework in a comment to a blog post[16]: <br /><br /><fieldset><blockquote><br />"While it's difficult to copy Rails in PHP, it's quite possible to write an equivalent system. I like the terseness of Ruby code, but I need the structure that Rails provides, how it makes me organize my code into something sustainable. That's why I'm ripping off Rails in Cake."<br /></blockquote></fieldset><br /><br />Cake's developers (bakers?) are developing their own framework which uses many principles of Ruby on Rails, revisited and re-proposed in an extremely flexible and easy to use PHP tool, rather than simply trying to port Rails to PHP. I also liked the fact that they bothered to choose an original name for their project, unlike others: there are too many "<insert language here>-on-Rails" frameworks, and while the whole "Rails" thing is innovative and catchy the first time, it loses its appeal quickly when people use the word everywhere just because it is "fashionable".<br /><br />Quoting from CakePHP's website:<br /><br /><fieldset><blockquote><br />"Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility." <br /></blockquote></fieldset><br /><br />That sounds like the Holy Grail for PHP developers, and I must admit I'm quite impressed myself after using it on various little projects, but is it really all true? What are Cake's features? Are there any limitations?<br /><br /><br /><strong>The Ingredients</strong><br /><br />So what is Cake? In the previous sections, I introduced some general concepts and ideas common to Ruby on Rails and CakePHP, but nothing in particular was said about the structure of the framework itself. Let's now turn to that and discuss it in some detail, particularly as it pertains to Cake.<br /><br />The first thing to understand about Cake (and Rails as well) is that one of their aims was to avoid editing long and complex configuration files in order to run the environment. The approach in this sense is to use <em>conventions</em> over <em>configuration</em>. This may sound terribly restrictive, but in reality it proved to make things much simpler. After all, I said I wanted to use a framework because I needed a solid structure to base my applications on, not that I needed to be able to create and personalize my own structure and system. Cake uses some simple rules in order to run properly, and the easiest way to explain them is through Cake's directory structure, which represents the skeleton of every CakePHP application.<br /><br />/<br />---app/<br />------config/<br />------controllers/<br />---------components/<br />------models/<br />------plugins/<br />------views/<br />---------elements/<br />---------errors/<br />---------helpers/<br />---------layouts/<br />---------pages/<br />------webroot/<br />---------css/<br />---------files/<br />---------img/<br />---------js/<br />---cake/<br />------config/<br />---------inflections/<br />------docs/<br />------libs/<br />---------controller/<br />---------generator/<br />---------model/<br />---------view/<br />------scripts/<br />---tmp/<br />------cache/<br />------distro/<br />------logs/<br />------tests/<br />---vendors/<br /><br />I expanded only the first three levels of the tree, although there are more levels in the <em>/cake/</em> directory. They won't be considered here simply because the <em>/cake/</em> directory contains CakePHP's internal libraries, which normally will not be modified when developing an application. The <em>/tmp/</em> directory also will not be elaborated upon either, because it is only used to store temporary files. However, the <em>/vendor/</em> directory should contain third party scripts and libraries that you may want to use in your application, but they are not normally integrated with Cake's framework. 95% of your application will reside within the <em>/app/</em> directory, which we therefore need to examine in greater detail.<br /><br /><span style="text-decoration:underline;"><em>/config/</em></span><br />When I said that Cake strives to use conventions over configuration, I really meant it. This directory does not contain thousands of configuration files, only five very small ones. They represent the only items which <em>might</em> need to be configured. <br /><br /><ul><br /><li>acl.ini.php: This file must be edited only if you plan to use Cake's default ACL </li>(access control list) system for your application. It sets permissions for the application, so it should be used to list every group, user, and their respective rights. This can be useful for small sites with a few well known users, but for anything else, you should develop your own ACL or authentication system that relies on a database. <br /><li>core.php: This file can be edited to change some default options, such as the level of the error messages and notices that the application will output. This comes in very handy while developing an application.</li><br /><li>database.php.default: This should be renamed to database.php and edited if you plan to use any databases with Cake. The settings are fairly straightforward, and include the type of database used </li>(mysql, postrgres, sqlite, or any other supported by the AdoDB library[18]), username, password and database name.<br /><li>paths.php: Unless you are very particular, you should leave this file alone. It tells Cake where to look for CSS files, images, controllers, etc. If you are planning to adopt Cake's directory structure - which is the most logical option - you can ignore this.</li><br /><li>routes.php: Following Rails' example, CakePHP features a "routing system" for user-friendly URLs. By default, your URLs will look like this: </li><em>http://sitename/controller-name/action-name/eventual/action/parameters</em>, which is a really nice way to organize a site, but you may want to change something if you have particular requirements. <br /></ul><br /><br /><br /><span style="text-decoration:underline;"><em>Controllers</em></span><br />As mentioned previously, a controller represents the "brain" of the MVC pattern, the part which controls what the other parts are doing. Imagine a controller like a section of your site: its name will be present on the address bar, and each of these sections will have a file named <something>_controller.php, and will also contain a class named SomethingController that extends the AppController class. This class will have some methods that correspond to some standard actions like <em>index</em> (the default action called when you access the <a href="http://sitename/controller/">http://sitename/controller/</a> page) or other user-defined ones like <em>add</em> or <em>list</em> or <em>admin</em>, depending on the application. As a general rule, you want to add any 'business logic' you want to implement in your application in controllers - for example, calculations or a database query that produces a result. <em>Then</em> once all the mess is done, the result (usually an array or a variable) is passed to the view (see <em>views</em> below). <br /> <br />If this is starting to sound too technical for you, I recommend reading a tutorial[19] available on the CakePHP website about creating a simple blog application. The tutorial will explain most of Cake's basics, including how to pass a variable from a Controller to the corresponding view <em>($this-set('variableNameInView', $variable))</em> and other useful things.<br /><br />Recently <em>Components</em> have been added to CakePHP, and quoting from the corresponding wiki page[20]:<br /><fieldset><blockquote><br />"Components are the preferred way to provide additional functionality to your controller. To make a component available you would add var $component = array('myComponent') inside of your controller's definition, add your file to the /app/controllers/components, name your class MyComponent, and create your methods."<br /></blockquote></fieldset><br /><br /><br /><span style="text-decoration:underline;"><em>Models</em></span><br />A model is an object able to access the database. In Cake's terms, that is any class extending the AppModel class. That class is directly under the <em>/cake/</em> directory (along with the previously mentioned AppController class), and can be moved to the <em>/app/</em> directory and modified if you want to add some particular site-wide behavior to it which will be inherited by all models extending it.<br /><br />In even simpler terms, you need to create a Model class for every table you're planning to use in your database. A convention in Cake says that database table names should be plural and that the corresponding model should be singular. If you use a table named 'mice', your model should be named 'mouse': Cake is smart enough to understand irregular plurals through an <em>Inflector</em> class.<br /><br />Creating a model class for basic use is trivial:<br /><br /><br />class Post extends AppModel<br />{<br /> var $name = 'Post';<br />}<br /><br /><br />Then you'll be able to access the model (and therefore the database) from a controller via simple instructions like $this->Post->findAll(). This instruction will query the database and return all records within the Posts table in your database. You can also perform more complex operations, and also specify SQL queries to execute, if you need to, but remeber that models can only be accessed through controllers! If you need some information stored in your database to be displayed on a view, execute the query from the controller and pass it to the view as per the MVC pattern. It can prevent you from cluttering views with business logic and thereby making code updates much harder.<br /><br /><br /><span style="text-decoration:underline;"><em>Views</em></span><br />Views are used to present information gathered with a model and a controller to the public. They are mostly HTML pages with some PHP tags in them, prints of variables and maybe some <em>foreach</em> loops. Nothing more than that should be used in a view!<br /><br />Views must be placed in this directory and obey the following conventions:<br /><br />1. They must be named after a controller's action to allow the controller to refer to a particular view automatically. The same view can be used by multiple controllers, but it must be either set manually or through a layout (see below).<br />2. Views referring to an action of a particular controller must be placed under a subfolder named after the controller.<br />3. All views must have a .thtml extension.<br /><br />Any site-wide view, like the site's template, must be placed under the <em>layouts</em> subfolder. In particular, the default.thtml file in the folder represents the global template for your application: page titles and specific pages (views) will be invoked automatically by using $title_for_layout and $content_for_layout respectively.<br /><br />Similarly to what was said about components, <em>helpers</em> can be used to extend views functionalities[20]:<br /><br /><fieldset><blockquote><br />"Helpers are all about the view. You know about the helpers in Cake, but you need a little bit more. You want to have your own methods to display formatted info. To achieve this, you need to add var $helpers = array('myHelper').<br /><br />Now, throw your myhelper.php file into the /app/views/helpers/, create the class MyHelper, and $myHelper is available in the view." <br /></blockquote></fieldset> <br /><br />Cake comes with some very useful default helpers to create links and HTML tags, import JavaScript, create forms, and use AJAX code easily. Unlike most other frameworks, Cake neither has nor uses a third party template engine (like Smarty[21]) for views, but helpers can be used to achieve similar results more quickly than an engine can.<br /><br /><br /><span style="text-decoration:underline;"><em>Plugins</em></span><br /><br />Plugins are user-developed enhancements for Cake. Unlike the files placed under the <em>vendor</em> directory, a plugin is an application specifically made to be used within the CakePHP environment. At the moment this feature is still under development.<br /><br /><span style="text-decoration:underline;"><em>Webroot</em></span><br /><br />If you read carefully what I wrote above about routes, you might be wondering if <em>every</em> page must have a controller and a view in order to be displayed properly. What about images, JavaScript and CSS files? The answer is this directory: everything you place here will not be seen as part of the MVC-based environment; CSS files can be stored in the <em>/css</em> folder, Javascript under <em>/js</em>, and so on. Additionally, some helpers can provide a easier way to access or display images, scripts, CSS, etc.<br /><br /><br /><span style="text-decoration:underline;"><em>Other Features</em></span><br />Cake offers even more than this; the latest releases have introduced a few more Rails-inspired features:<br /><br /><ul><br /><li>Scaffolding: Do you want to test your application without spending time writing all the CRUD </li>(Create, Read, Update, Delete) code? That's where the concept of scaffolding comes in: by setting a few variables in the right places[22], Cake will generate basic mechanisms to add, edit, list, and delete records in your database, along with all the associated view files. You won't have to code a single form, as everything will be generated automatically by the framework according to SQL field types.<br /><li>Bake: Another Rails-inspired feature revisited in PHP. Rails uses a set of scripts and in particular the </li><em>rake</em> utility to instantaneously create the foundation for a Rails application with scaffolds already in place. CakePHP offers the same functionality through the <em>bake</em> utility, which is currently available as either a batch file or a PHP script.<br /><li>ACL: As previously mentioned, Cake comes with a ready-made Access Control List </li>(ACL) system, which can be extended and used to restrict particular areas of a Cake application to certain users or user groups.<br /><li>Compatibility: CakePHP is fully compatible with both PHP and PHP5.</li><br /></ul><br /><br /><br /><strong>Meet the Bakers</strong><br /><br />After reading all these things about CakePHP and its framework, you may have some questions, or be curious about some aspect of the project. PHPNut and gwoo, two of CakePHP's creators and lead developers, offered to answer some questions exclusively for zZine readers. This interview took place on Oct. 26th, 2005, in #dev-cakephp on irc.freenode.org.<br /><br /><em><span style="text-decoration:underline;">h3rald</span>:</em> Thanks to both of you for allowing me to interview you about your project, CakePHP. Where did the name come from, anyway?<br /><br /><em>PHPnut:</em> The original project was started by Michal Tatarynowicz aka Pies (hence the name), and when I saw his release, last March, I decided to contact him. I told him that the company I own supports projects like Cake, and also that I was in the process of developing something along the same lines. <br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Is Cake released under the GPL? How many developers are helping out?<br /><br /><em>gwoo:</em> Cake is released under the MIT license, and the development team is composed of me and PHPnut, plus four other contributors. Then there's the Documentation Team, currently 3-5 people. Documentation has to follow the releases, so it usually lags behind a bit: we made so many modifications in the recent release that the Doc Team has a lot to catch up on, but it's getting there.<br /><br /><em>PHPnut:</em> With this release you will see that the docs are going to be much better. The code is very stable now, and hopefully very little changes on that.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Some people, at first glance, may think that Cake is a PHP port of Ruby on Rails. How true is that? What are the differences and similarities between these two frameworks?<br /><br /><em>PHPnut:</em> Cake started as a port, but has evolved into something more: we discussed using the concepts that RoR offered and including them in a framework for users of PHP. I have used PHP for a number of years, and I am comfortable with it; this is where my passion is, and I think people who use Cake have those same passions as we developers do.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> I read once that Rails was developed in Ruby because only Ruby can offer certain functionalities and features...<br /><br /><em>gwoo:</em> I would disagree, and I think that is proven in what we have done: sure RoR has a built in server and some other nice things, but PHP is everywhere.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Some developers, especially Perl programmers, tend to consider PHP an "inferior" language sometimes. What do you think of that?<br /><br /><em>PHPnut:</em> My name says what I think about them all.<br /><br /><em>gwoo:</em> PHP is a web programming language; that's what it was designed for, and that's what it does best: It all boils down to what you are comfortable with.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Did you try any other PHP frameworks, MVC-based (Mojavi, for example), or event-driven, like Prado? What do you think about them? In what ways can Cake be better or worse?<br /><br /><em>gwoo:</em> They are all so complex, in my opinion, and I tried nearly all of them. Cake breaks apart the MVC and handle the CRUD in a logical way, and Cake syntax is super easy to learn.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Ruby on Rails has been ported to various languages, including Java and Python. There are three PHP frameworks inspired by the famous Ruby project: Biscuit, PHP on Tracks and CakePHP. What do you think of that? Any chance of a merge? Did you have a look at them?<br /><br /><em>gwoo:</em> You forgot Symfony[27], a PHP5-only port: I tried it but it seems much harder to learn than Cake.<br /><br /><em>PHPnut:</em> I could be wrong, but I think these other projects are behind us in ease of use, in what the framework is capable of doing, and in features, not to mention community support.<br /><br /><em>gwoo:</em> I tried all of the PHP ports of Ruby on Rails and none of them has the features, the community,or a lexicon as good as Cake's.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Why don't you consider CakePHP a port? In what way is it evolving from Rails?<br /><br /><em>PHPnut:</em> Rails and CakePHP share a lot: MVC pattern, Active Record pattern...but we're not strictly following Rails, and we're able to think by ourselves. Recently we changed the directory structure, and in my opinion our is more functional than the Ruby on Rails one.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> What can Cake be used for? What kind of projects? Are there any limitations?<br /><br /><em>gwoo:</em> Personally I think that Cake is the most extensible framework out there for PHP: with components, helpers and vendor access you can do anything you want!<br /><br /><em>PHPnut:</em> We are limited only by what a web server (generally Apache, but IIS seems to work as well) and a database can do. We may be limited by PHP itself, but we twist that in our own little sick ways sometimes.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Any thought about AJAX? I saw some nice demos made with Cake. What do you think of this new trend in web development? Some people consider it the future, while others are concerned about compatibility, and still others are relatively indifferent to it. What about you?<br /><br /><em>gwoo:</em> AJAX can be very useful in creating an application, but should not be overused. People have become very comfortable with how the Web works:i f you start doing tons of drag and drop and no refreshes, users will feel lost in how to operate the site.<br /><br /><em><span style="text-decoration:underline;">h3raLd</span>:</em> Thank you very much for your time, both of you. Is there anything you'd like to add to this interview? Something you'd like to say to users interested in trying out Cake?<br /><br /><em>PHPnut:</em> Come and enjoy: we are here to help...<br /><br /><em>gwoo:</em> ...And plan to be here for a very long time!<br /><br /><br /><strong>Let's cook...</strong><br /><br />One of the most positive things about CakePHP is that even though it is a fairly new project (most of the code is 100% useable already,but they still consider the projectto be in the 'alpha' stage), it's maintained by many dedicated developers and PHP enthusiasts. I was amazed to see how the whole documentation evolves and is quite literally updatedon a daily basis. <br />Anybody can contribute to the framework or simply test it and share their experiences.<br /><br /><span style="text-decoration:underline;"><em>CakePHP Wiki</em></span><br /><br />Anybody can register an account for free and contribute tutorials and documentation to the new CakePHP Wiki[23]. This is currently the most up-to-date source for documentation files and tutorials.<br /><br /><span style="text-decoration:underline;"><em>CakePHP User Group</em></span><br /><br />If you need assistance or you want to contact the Cake developers or other Cake users, you can post a message on their Google User Group[24]: people will reply with useful comments, usually on the same day, and the developers <em>do</em> listen to user suggestions.<br /><br /><span style="text-decoration:underline;"><em>CakePHP IRC Channel</em></span><br /><br />If you want to offer (or receive) real-time assistance, feel free to join #cakephp on FreeNode (irc.freenode.org). I went there disguised as a total newbie (it wasn't much of a stretch) and they helped me a lot, explaining basic concepts of the framework and pointing me to the right documentation files.<br /><br /><span style="text-decoration:underline;"><em>CakePHP Development</em></span><br /><br />Experienced PHP developers are more than welcome to contribute to the project. People may be accepted to the core development team if they have sufficient knowledge and spare time, or alternatively,components or code can be submitted through the newly created CakeForge[24]. <br /><br /><br /><strong>...Or Just Eat</strong> <small><em> by Marc Abramowitz</em></small><br /><br />If you don't feel ready to contribute and you'd like to try out the framework first, it can be downloaded directly from the CakePHP site[25] as either a <em>release</em> or a <em>nightly</em> build: the zip file is less than 300KB.<br /><br />I wanted to include a <em>success story</em> written by Marc Abramowitz, an experienced PHP programmer who decided to adopt CakePHP as a framework to use in a production environment: he persuaded his colleagues to use it and they all seem happy with it. He writes:<br /><br /><em>For the past few years, I've done quite a bit of work in PHP, working on production code that runs on a very high traffic web site. PHP has served us well, as it is easy to write and read, quite efficient, and easy to integrate with existing C++ code as the site grew.<br /><br />Lately, there has been a lot of buzz in the web development community about Ruby on Rails. Like many others, I took some interest in Ruby on Rails because I was intrigued by the apparent power and elegance of Ruby and because I wondered if a Model/View/Controller (MVC) framework like Rails would help enforce a more consistent code structure that would make the code easier to understand and maintain. Additionally, I wondered if an MVC framework would enable very rapid prototyping.<br /><br />Some people are very wary of frameworks that impose structure, as they like to have the freedom to do things however they want. However, there is a tradeoff between structure and flexibility. If you're working on a small team or a relatively small project, then you may not find structure to be very helpful; you may even find that it gets in your way. <br /><br />However, as teams and projects get larger, structure becomes more and more valuable, as it enforces consistent patterns of how to do things and rather than being something that limits, it in fact liberates, because it abstracts away the small details and allows us to therefore concentrate on the larger problem. Think of the lines that are painted on our roadways - although they add structure, we don't find them to be limiting. On the contrary, they help us to drive without worrying about crashing into each other at every moment - they free us from being concerned with small details so that we can concentrate on getting where we're going.<br /><br />Rapid prototyping appeals to me, because I find it helps me to better present my ideas for new apps and features. A mockup can only go so far - there is no substitute for a working prototype. When clients get their hands on a functional prototype, they get a better idea of what is possible and it forces them to clarify their requirements for the product. This results in a better dialogue between the developer and the client, which leads to better upfront decisions, more stable requirements, less stress, and a better product.<br /><br />So, Rails appealed to me not only because of the potentially valuable structure that it could add, but also because it could enable rapid prototyping. However, I knew that there was no chance of Rails being used for production code in my organization, because we run some very high traffic web sites that require the utmost in efficiency. We are also by and large a PHP shop.<br /><br />However, when my manager approached me and asked me to develop a database-backed internal tool, I thought of Rails again. I then considered the fact that I would probably someday have to hand this app off to someone else, and that someone would probably know PHP but not Ruby. Heck, even I had several years of experience with PHP (including writing some PHP extensions) but I had only done a little bit of reading about Ruby, and I also had no practical experience with it.<br /><br />Furthermore, with PHP I had access to a large number of PHP extensions that wrapped various internal libraries. So PHP was the natural choice. Ideally, I wanted to use PHP with a Rails-like MVC framework that would facilitate rapid development, and this is what led me to CakePHP.<br /><br />I began by downloading CakePHP 0.9.2 and following the sample tutorial that walks you through creating a simple blog application (note that at the time of this writing, the current version of Cake is now 0.10.0.1076, so some of the details of using Cake have changed). I was pleased to find that the process was quite similar to the process for Rails. One difference that I noted was that Rails tutorials always emphasize using scripts to generate models, controller, and scaffolds, whereas the Cake tutorial walked me through explicitly writing out all the code. I noticed that the Cake download came with a script called "bake" which looked like something that could potentially do some of the code generation, but since it wasn't mentioned in the tutorial, I chose not to use it.<br /><br />The process of creating a first application using the tutorial was quite easy. Here are the steps in brief (consult the tutorial for more details):<br /><br />1. Create the database table. Cake requires tables to have some extra<br />fields:<br /> - id, an auto_increment primary key<br /> - created, a datetime<br /> - updated, a datetime<br />2. Configure Cake to access the database by editing the config/database.php file<br />3. Create a model class which extends AppModel (a Cake provided class)<br />4. Create a controller class which extends AppController (a Cake provided class) and write one or more controller methods<br />5. Create a view which is a PHP file with a .thtml extension and is meant to be mostly HTML with very little embedded PHP - typically just echoing of variables and some simple control structures like <em>foreach</em>.<br />Cake also provides some simple convenience methods that write out certain HTML constructs for you.<br /><br />That's it! That alone is enough to create a basic but functional application. The tutorial goes on to show you how to add additional functionality to the blogging app. After that there's a shorter, more advanced tutorial that shows you how to add a few more things to the blogging app.<br /><br />Once I had gotten comfortable with Cake by following the tutorial, I proceeded to write my own application. Getting started was easy - I followed the same steps as in the tutorial to create my first table, model, controller, and views, then my second table, model, controller, and views. Then my app got a bit more complicated. I needed to have many-to-many relations and more elaborate queries than the default ones that Cake provides. I began to worry that Cake would break down here. I had heard people grumble that MVC frameworks like Rails and Cake were great for little toy apps that only do CRUD (Create, Read, Update, Delete), but that they couldn't handle complex queries using joins and the like. I poked around in the Cake source code and was pleased to find that there were nice lower level methods that allowed me to bypass the Cake defaults and do whatever custom queries I liked. For example, I wrote something like this in one of my models:<br /><br />function index(){<br /> return $this-findBySql(<br /> "SELECT id, title, AVG(rating) avg_rating, MIN(rating) min_rating, MAX(rating) max_rating, COUNT(rating) num_ratings " .<br /> "FROM ideas LEFT JOIN ratings ON ideas.id =<br />ratings.skill_id " .<br /> "GROUP BY id " .<br /> "ORDER BY title");<br /> }<br /><br /><br />So what I have is a model that does <em>not</em> have a one-to-one mapping with a single table. It actually retrieves data from more than one table.<br /><br />Over time, I picked up a few more Cake concepts. For example, at some point we decided that every page of the app would have a similar look and feel with a particular masthead and logo, and all the pages in one section of the site would show tabs for all of the various views with the currently selected tab highlighted. At first, I just used the same code at the top of each of my views to display the masthead, logo, and tabs. This, of course, became a pain when I needed to change the layout, since I needed to make the same change in several different views.<br /><br />Then one day I realized that Cake had a concept of layouts, which are high level templates in <em>app/views/layouts</em> that define the basic structure of pages. The individual views are just content that gets embedded in these high level layout templates. So I took the common masthead and logo, put it in my default layout, and removed it from the individual views. Now when I wanted to change the look of the masthead, I only had to do it in one place. For the tabs, I discovered the concept of elements. I placed the code for my tabs in <em>apps/views/elements/tabs.thtml</em>. Then the tabs could be displayed in any template using:<br /><br /><?php echo $this-renderElement('tabs') ?<br /><br />Rather than stick the above statement in all of the many pages that were supposed to display tabs, I created a new layout in <em>apps/views/layouts/tabbed.thtml</em> (which uses renderElement to render the tabs). Then I used<br /><br />$this-layout = "tabbed"<br /><br />in the controller to tell it to use the tabbed layout rather than the default (non-tabbed) layout.<br /><br />After a couple of days of work on this application, it was time to demo it to the VP, who was very impressed with what I was able to accomplish in such a short period of time. It was brought up that before I took on the project they had asked some other folks how long it would take them to build it in Java and they had said that it would take on the order of months what I had built in a couple of days. Morals of the story:<br /><br />1. Cake is very lightweight and productive<br />2. Cake might be very beneficial to your career<br /><br />Eventually, I was assigned to another project and my manager wanted me to transition my Cake project to another engineer, who was experienced with PHP but not with Cake. I sat down with the new engineer and in about 20 or 30 minutes of explanation and walking him through the code,<br />he felt ready to code. Not only did he feel that he knew enough to start working with the application, I could tell from the smile on his face that he was very impressed by the power and succinctness of Cake, which was the same reaction that I initially had. After a couple of days, I checked back with him and he had made a remarkable amount of progress on the application - there were a ton of new pages and features.<br /><br />So you see, Cake is a very productive environment. For a very small investment in the initial learning curve, you can get a significant increase in productivity.<br /></em><br /><br /><strong>...And the icing?</strong><br /><br />So that's what CakePHP is about. The project may only have just entered alpha stage, but the code is already very stable and useable, as PHPnut, gwoo and Marc said. So what's going to be included in the beta and stable releases? I researched a bit and asked the developers, and here's how Cake will probably evolve in the following months:<br /><br /><ul><br /><li>Cake's built-in </li><strong>data-validation</strong> capabilities will be extended. A validator class - which already exists, by the way - will be extended to include more data types and expressions to be validated before being stored in a database. <br /><li>A new default </li><strong>ACL system</strong> will be included and will support database access and .ini files as well. <br /><li>The </li><strong>AJAX</strong> helper class and AJAX support will be enhanced, featuring unobtrusive JavaScript and ALA behavior[28].<br /><li>Multiple applications with the same core files. In the future developers will be able to create their own Cake application which could be placed in the app/plugins directory and be seamlessly integrated and auto-linked to other Cake applications.</li><br /></ul> <br /><br />After learning all this about Cake and after trying it out myself, I really think that I have found the solution to all of my PHP web development problems. CakePHP can really help PHP developers a lot if properly used and understood. Still not convinced? Just try it out then, will you?[17]<br /><br /><br /><strong>Notes and Related Resources</strong><br /><br />Special thanks to:<br /><br /><ul><br /><li>Larry E. Masters aka PhpNut and Garrett J. Woodworth </li><strong>gwoo</strong> for providing all the answers to my questions and contributing to create such a wonderful tool for the PHP community.<br /><li>Marc Abramowitz for sharing his experiences with the CakePHP framework and providing the content for the '...let's eat' section.</li><br /></ul><br /><br /><small><br />[1] PHP functions reference, <a href="http://www.php.net/manual/en/funcref.php">http://www.php.net/manual/en/funcref.php</a><br />[2] Framework, Wikipedia Page - <a href="http://en.wikipedia.org/wiki/Framework">http://en.wikipedia.org/wiki/Framework</a><br />[3] .NET framework overview - <a href="http://msdn.microsoft.com/netframework/technologyinfo/default.aspx">http://msdn.microsoft.com/netframework/technologyinfo/default.aspx</a><br />[4] "PHP Framework", delorian's blog, PHP Community - <a href="http://www.phpcommunity.org/node/100">http://www.phpcommunity.org/node/100</a><br />[5]Some popular PHP frameworks: Mojavi (<a href="http://www.mojavi.org/">http://www.mojavi.org/</a>), phpMVC (<a href="http://www.phpmvc.net/">http://www.phpmvc.net/</a>), BlueShoes (<a href="http://www.blueshoes.org/">http://www.blueshoes.org/</a>), Seagull (<a href="http://seagull.phpkitchen.com/">http://seagull.phpkitchen.com/</a>).<br />[6] PEAR - <a href="http://pear.php.net/">http://pear.php.net/</a><br />[7] Prado - PHP Rapid Application Development Object-Oriented, <a href="http://www.xisc.com/">http://www.xisc.com/</a><br />[8] Event Driven Programming, Wikipedia Page - <a href="http://en.wikipedia.org/w/index.php?title=Event_driven_programming">http://en.wikipedia.org/w/index.php?title=Event_driven_programming</a><br />[9] Ruby on Rails, Official Page - <a href="http://www.rubyonrails.org/">http://www.rubyonrails.org/</a><br />[10] Ruby on Rails, Doumentation - <a href="http://documentation.rubyonrails.com/">http://documentation.rubyonrails.com/</a><br />[11] Model View Controller, Wikipedia Page - <a href="http://en.wikipedia.org/w/index.php?title=Model-View-Controller">http://en.wikipedia.org/w/index.php?title=Model-View-Controller</a><br />[12] PHP frameworks inspired by Rails: <a href="http://phpontrax.com/">http://phpontrax.com/</a>, <a href="http://flinn.activeintra.net/biscuit/">http://flinn.activeintra.net/biscuit/</a>, <a href="http://www.cakephp.org/">http://www.cakephp.org/</a><br />[13]Python frameworks inspired by Rails: <a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a>, <a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a>, <a href="http://subway.python-hosting.com/">http://subway.python-hosting.com/</a><br />[14]Java framework inspired by Rails: <a href="https://trails.dev.java.net/">https://trails.dev.java.net/</a><br />[15]Perl frameworks inspired by Rails:<br /><a href="http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod">http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod</a>, <a href="http://perlonrails.org/index.php/Main_Page">http://perlonrails.org/index.php/Main_Page</a> <br />[16] "Rails Clones: Blood suckers or useful drones?", RedHanded - <a href="http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html">http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html</a><br />[17] CakePHP - Rails-inpired PHP framework, <a href="http://www.cakephp.org/">http://www.cakephp.org/</a><br />[18] AdoDB, PHP Database Abstraction Layer - <a href="http://adodb.sourceforge.net/">http://adodb.sourceforge.net/</a><br />[19] CakePHP blog tutorial - <a href="http://wiki.cakephp.org/tutorials:blog_tutorial_-_1">http://wiki.cakephp.org/tutorials:blog_tutorial_-_1</a><br />[20] Extending CakePHP - <a href="http://wiki.cakephp.org/tutorials:extending_cake">http://wiki.cakephp.org/tutorials:extending_cake</a><br />[21] Smarty, PHP Template Engine - <a href="http://smarty.php.net/">http://smarty.php.net/</a><br />[22] Scaffolding a Blog, CakePHP Wiki - <a href="http://wiki.cakephp.org/tutorials:scaffolding_a_blog">http://wiki.cakephp.org/tutorials:scaffolding_a_blog</a><br />[23] CakePHP Wiki - <a href="http://wiki.cakephp.org/">http://wiki.cakephp.org/</a><br />[24] CakePHP Google User Group - <a href="http://groups.google.com/group/cake-php">http://groups.google.com/group/cake-php</a><br />[25] CakeForge - <a href="http://cakeforge.org/">http://cakeforge.org/</a><br />[26] CakePHP Downloads Page - <a href="http://cakephp.org/downloads/">http://cakephp.org/downloads/</a><br />[27] Simfony, PHP5 framework - <a href="http://www.symfony-project.com/">http://www.symfony-project.com/</a><br />[28] ALA behavior - <a href="http://bennolan.com/behaviour/">http://bennolan.com/behaviour/</a><br /></small><br /> + +<p>Web developers can either love or hate PHP, and one of the criticisms of this easy-to-use programming language which + is repeated over and over on IRC, forums and blogs is that "PHP is disorganized".</p> +<p>Is this really true? If so, is there any possible way to write a PHP application in a logical and clean way? Read + on...Every web developer has certainly heard of PHP. Some people like it and consider it a powerful and easy-to-use + way to create complex websites or web applications, while others are convinced that it is merely a bad copy of Perl. + Opinions are certainly mixed on the matter.</p> +<p>One thing to keep in mind when reading criticisms of PHP is its origins, as therein lies the crux of the matter. PHP + was created as a form interpreter, initially offering only a <em>very limited</em> range of functionality. Its main + purpose was to make life easier for web developers who wanted to do simple tasks, like manipulating form data.</p> +<p>People liked the concept - PHP was free and it quickly became popular among developers. More functionality was added + and continues to be added with each new release, and PHP is now one of the most popular and powerful programming + languages available for web development.It is relatively easy to learn, compared to Perl, ASP, or JSP, and it can be + used for almost anything[1].</p> +<p>The sheer simplicity of the language was most likely the cause of the enormous amount of exploits discovered through + the years which earned PHP the label "<em>too dangerous to use in 'proper' applications</em>". The danger, however, + lies not in the language itself, but rather in the <em>way</em> developers make use of the language: PHP's + simplicity makes writing bad or exploitable code extremely easy. Furthermore, PHP's ability to be placed within any + HTML page with the greatest of ease tempted developers to write ever-increasing amounts of 'spaghetti code', which + by its very nature is neither organized nor clean code, and certainly does not help a developer learn how to write + organized or clean code.</p> +<p>These problems, however, can be solved. There are many ways to go about doing this, but the easiest, most effective + way is to create a framework[2].</p> + +<h3>Bringing Order to Chaos</h3> +<p>After learning some PHP myself, I remember noticing that my applications were growing in a disorganized and + uncontrollable manner. Things tended to be added at the last minute, and bugs were fixed and patched 'on the fly' + wherever they occurred. PHP lacked the structure that is present in most other programming languages. I remember + reading the word <em>framework</em> for the first time not too long ago while I was downloading a Windows Update of + the .NET framework[3]. That inspired me to start searching the Internet for a 'PHP framework'. That led me to an + interesting blog entry[4] where a solution was proposed - a solution to <em>bring order to chaos</em>:</p> + +<fieldset> + <blockquote> + <p>[...] The answer is simple: create our own class library, some kind of framework, the PHP framework. The + similar in many ways to that one which is already well known to Java or .NET programmers. We could set the + standards, structure and main guidelines. [...]</p> + </blockquote> +</fieldset> + +<p>That blog post made me think about developing my own framework, until I noticed that there were many projects already + in progress, and some in fact completed; the end result being a fully functional PHP framework. I read a lot about + some of them[5], and abandoned the idea of developing my own, because as a good developer, I believe I should never + re-invent the wheel. So I kept looking. I found Pear[6], although that's more a repository of PHP classes with a + common standard than a framework, while I was looking for THE solution to developing many types of applications, not + merely how to do one thing in particular.</p> + +<p>I came across a very promising project named Prado[7], which won the latest Zend contest, and was considered the best + PHP5 application of the year. It is a masterpiece of coding and PHP5 usage, so I tried to learn it. I even developed + a website with it.</p> + +<p>Prado lets the developer design the application without imposing any ready-made components, but I found its + event-driven[8] approach neither easy to learn nor suitable for everyday web applications. I did not like the idea + of having to code a reaction to every event (like a click on a button or different phases of page rendering): that + is the approach that ASP takes, and at least in that respect, Prado seems to be inspired by the .NET framework. + Event-driven programming is suitable for GUI development and desktop-based interfaces, but not for web applications. +</p> + +<p>After trying Prado, I was still unsatisfied, so I once again began my search for a solution to improve my + programming. My meanderings took me to Ruby on Rails[9], one of the most recent examples of technology hype on the + Net. At the same time,to a certain extent, it is also a successful tool.</p> + +<fieldset> + <blockquote> + <p>"Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and + less code than most frameworks spend doing XML sit-ups."</p> + </blockquote> +</fieldset> + +<p>That sounded like what I was looking for, and I started reading more about it in the vast and varied help + sections[10] available both on and off of the official site. The Rails team did an outstanding job promoting and + marketing the framework, and also in providing comprehensive textual documentation (and even video tutorials) to + help both beginners as well as experienced programmers get started with it.</p> + +<p>Briefly, Rails uses Ruby's object oriented programming, in conjunction with the MVC pattern and various automated + scripts (generators), to help developers program their applications quickly and in a solid and organized way. + However, as that is neither clear nor convincing, let's spend a few moments on the MVC Pattern[11], which will also + be useful to understanding the following sections.</p> + +<p>MVC stands for <strong>M</strong>odel <strong>V</strong>iew <strong>C</strong>ontroller: these three words enclose - + and this is just a personal opinion - all the wisdom and philosophy of web development, describing - once again, in + my opinion - the three most logical parts a web application <em>should</em> be divided into to achieve code + robustness, order and power, all at the same time. Let's look at what each of the component parts mean in detail: +</p> + +<ul> + <li> + <p>Model: The model represents the very essence of the information and content of a web application. Imagine + this as an object able to gather the information and content of your webpages from a particular resource, + such as a database. The model is the only entity able to access resources.</p> + </li> + <li> + <p>View: The view is an attempt to separate the most unstable part of an application: the user front-end. A view + is only responsible for presenting the information that the Model gathered. A view does nothing but format + the output, and can be compared to a template or report. In all MVC frameworks for web applications, only + view files contain (X)HTML code, and mostly only that. They can therefore be changed at any time without + having to touch a single line of the business logic of your application.</p> + </li> + <li> + <p>Controller: The controller is the 'brain' of the application. Consider it to be the only part of your program + that can 'think' and manage the other parts. Controller files are the only ones able to order the Model to + gather information and then pass the information obtained to the view for display.</p> + </li> +</ul> + + +<h3>Although the MVC seems to make things more complicated, that is part of the objective.</h3> +<p>Since one of the advantages (and weaknesses) of PHP was its simplicity, the MVC adds complexity to bring more order + and logic to the design process. The three entities are separated for just that reason, and trying to put them + together can result in potential disasters, since it causes the whole pattern to fail.</p> + +<p>Coming back to Rails, I was quite impressed by the features it offered, but there was a small problem: the Ruby + programming language itself. I experienced some difficulties in setting up the environment properly, and I also + discovered that most standard hosting companies do not offer Ruby hosting plans as standard. Hosting issues aside, I + would have had to learn Ruby in order to master Rails, and I really did not have the time for that: I had to develop + a website quickly and easily, preferably with languages I already knew.</p> + +<p>After deciding to abandon Rails (for the moment, anyway), I was amazed by the number of projects in other programming + languages that try to emulate the famous Ruby framework, to the point of being considered <em>clones</em> or ports + of it to another language. To my knowledge, the <em>Rails disease</em> contaminated the following programming + languages:</p> + +<ul> + <li>PHP</li>[12]<br /> + <li>Python</li>[13]<br /> + <li>Java </li>[14]<br /> + <li>Perl </li>[15]<br /> +</ul> + +<p>I said <em>disease</em> because Rails developers think that Ruby on Rails was made in Ruby for a reason, namely that + Ruby offered some unique features that were not available in other languages. I will not delve into that topic here; + more information is available[16] for those who are interested. However, suffice it to say that there are some Rails + ports in PHP that were immediately attacked because of the fact or legend that the creator of Rails originally + wanted to develop his framework in PHP and then switched to Ruby. Let's examine one of those PHP frameworks in + detail.</p> + +<h3>CakePHP: Just Another Rails Clone?</h3> + +<p>I chose to learn CakePHP (or "Cake")[17] mainly because it offered more features than the other two PHP alternatives. + It also seemed to be a more original and actively developed project. In particular, I'd like to quote one of + CakePHP's developers, from when he introduced the framework in a comment to a blog post[16]: </p> + +<fieldset> + <blockquote> + <p>"While it's difficult to copy Rails in PHP, it's quite possible to write an equivalent system. I like the + terseness of Ruby code, but I need the structure that Rails provides, how it makes me organize my code into + something sustainable. That's why I'm ripping off Rails in Cake."</p> + </blockquote> +</fieldset> + +<p>Cake's developers (bakers?) are developing their own framework which uses many principles of Ruby on Rails, revisited + and re-proposed in an extremely flexible and easy to use PHP tool, rather than simply trying to port Rails to PHP. I + also liked the fact that they bothered to choose an original name for their project, unlike others: there are too + many "<insert language here>-on-Rails" frameworks, and while the whole "Rails" thing is innovative and catchy the + first time, it loses its appeal quickly when people use the word everywhere just because it is "fashionable". +</p> + +<p>Quoting from CakePHP's website:</p> + +<fieldset> + <blockquote> + <p>"Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, + Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework + that enables PHP users at all levels to rapidly develop robust web applications, without any loss to + flexibility." </p> + </blockquote> +</fieldset> + +<p>That sounds like the Holy Grail for PHP developers, and I must admit I'm quite impressed myself after using it on + various little projects, but is it really all true? What are Cake's features? Are there any limitations?</p> + +<h3>The Ingredients</h3> +<p>So what is Cake? In the previous sections, + I introduced some general concepts and ideas common to Ruby on Rails and CakePHP, but nothing in particular was said + about the structure of the framework itself. Let's now turn to that and discuss it in some detail, particularly as + it pertains to Cake.</p> + +<p>The first thing to understand about Cake (and Rails as well) is that one of their + aims was to avoid editing long and complex configuration files in order to run the environment. The approach in this + sense is to use <em>conventions</em> over <em>configuration</em>. This may sound terribly restrictive, but in + reality it proved to make things much simpler. After all, I said I wanted to use a framework because I needed a + solid structure to base my applications on, not that I needed to be able to create and personalize my own structure + and system. Cake uses some simple rules in order to run properly, and the easiest way to explain them is through + Cake's directory structure, which represents the skeleton of every CakePHP + application.</p> + +<pre> +/ +---app/ +------config/ +------controllers/ +---------components/ +------models/ +------plugins/ +------views/ +---------elements/ +---------errors/ +---------helpers/ +---------layouts/ +---------pages/ +------webroot/ +---------css/ +---------files/ +---------img/ +---------js/ +---cake/ +------config/ +---------inflections/ +------docs/ +------libs/ +---------controller/ +---------generator/ +---------model/ +---------view/ +------scripts/ +---tmp/ +------cache/ +------distro/ +------logs/ +------tests/ +---vendors/ +</pre> + +<p>I + expanded only the first three levels of the tree, although there are more levels in the <em>/cake/</em> directory. + They won't be considered here simply because the <em>/cake/</em> directory contains CakePHP's internal libraries, + which normally will not be modified when developing an application. The <em>/tmp/</em> directory also will not be + elaborated upon either, because it is only used to store temporary files. However, the <em>/vendor/</em> directory + should contain third party scripts and libraries that you may want to use in your application, but they are not + normally integrated with Cake's framework. 95% of your application will reside within the <em>/app/</em> directory, + which we therefore need to examine in greater detail.</p> + +<h4><em>/config/</em></h4> +<p>When I said that Cake strives to use + conventions over configuration, I really meant it. This directory does not contain thousands of configuration files, + only five very small ones. They represent the only items which <em>might</em> need to be configured.</p> + +<ul> + <li> + <h4>acl.ini.php:</h4> This file must be edited only if you plan to use Cake's default ACL + (access control list) + system for your application. It sets permissions for the application, so it should be used to list every group, + user, and their respective rights. This can be useful for small sites with a few well known users, but for + anything else, you should develop your own ACL or authentication system that relies on a database. + </li> + <li> + <h4>core.php:</h4> This file can be edited to change some default options, such as the level of the error + messages + and notices that the application will output. This comes in very handy while developing an application. + </li> + <li> + <h4>database.php.default:</h4> This should be renamed to database.php and edited if you plan to use any + databases + with Cake. The settings are fairly straightforward, and include the type of database used + (mysql, + postrgres, sqlite, or any other supported by the AdoDB library[18]), username, password and database name. + </li> + <li> + <h4>paths.php:</h4> Unless you are very particular, you should leave this file alone. It tells Cake where to + look for + CSS files, images, controllers, etc. If you are planning to adopt Cake's directory structure - which is the + most logical option - you can ignore this. + </li> + <li> + <h4>routes.php:</h4> Following Rails' example, CakePHP features a "routing system" for user-friendly URLs. By + default, your URLs will look like this: + <em>http://sitename/controller-name/action-name/eventual/action/parameters</em>, which is a really nice way to + organize a site, but you may want to change something if you have particular requirements. + </li> +</ul> + + +<h4>Controllers</h4> +<p>As mentioned + previously, a controller represents the "brain" of the MVC pattern, the part which controls what the other parts are + doing. Imagine a controller like a section of your site: its name will be present on the address bar, and each of + these sections will have a file named <em>something</em>_controller.php, and will also contain a class named + SomethingController that extends the AppController class. This class will have some methods that correspond to + some standard actions like <em>index</em> (the default action called when you access the <a + href="http://sitename/controller/">http://sitename/controller/</a> page) or other user-defined ones like + <em>add</em> or <em>list</em> or <em>admin</em>, depending on the application. As a general rule, you want to + add any 'business logic' you want to implement in your application in controllers - for example, calculations or + a database query that produces a result. <em>Then</em> once all the mess is done, the result (usually an array + or a variable) is passed to the view (see <em>views</em> below). +</p> + +<p>If this is starting to sound too + technical for you, I recommend reading a tutorial[19] available on the CakePHP website about creating a simple + blog application. The tutorial will explain most of Cake's basics, including how to pass a variable from a + Controller to the corresponding view <em>($this-set('variableNameInView', $variable))</em> and other useful + things.</p> + +<p>Recently <em>Components</em> have been added to CakePHP, and quoting from the corresponding + wiki page[20]:</p> +<fieldset> + <blockquote><br />"Components are the preferred way to provide additional functionality to your controller. + To make a component available you would add var $component = array('myComponent') inside of your + controller's definition, add your file to the /app/controllers/components, name your class MyComponent, + and create your methods."<br /></blockquote> +</fieldset> + +<h4>Models</h4> +<p>A model is an + object able to access the database. In Cake's terms, that is any class extending the AppModel class. That class + is directly under the <em>/cake/</em> directory (along with the previously mentioned AppController class), and + can be moved to the <em>/app/</em> directory and modified if you want to add some particular site-wide behavior + to it which will be inherited by all models extending it.</p> + +<p>In even simpler terms, you need to create a + Model class for every table you're planning to use in your database. A convention in Cake says that database + table names should be plural and that the corresponding model should be singular. If you use a table named + 'mice', your model should be named 'mouse': Cake is smart enough to understand irregular plurals through an + <em>Inflector</em> class. +</p> + +<p>Creating a model class for basic use is trivial:</p> + +<pre> +class Post extends AppModel +{ + var $name = 'Post'; +} +</pre> + +<p>Then you'll be able to access the + model (and therefore the database) from a controller via simple instructions like $this->Post->findAll(). This + instruction will query the database and return all records within the Posts table in your database. You can also + perform more complex operations, and also specify SQL queries to execute, if you need to, but remeber that + models can only be accessed through controllers! If you need some information stored in your database to be + displayed on a view, execute the query from the controller and pass it to the view as per the MVC pattern. It + can prevent you from cluttering views with business logic and thereby making code updates much + harder.</p> + + +<h4>Views</h4> +<p>Views are used to + present information gathered with a model and a controller to the public. They are mostly HTML pages with some + PHP tags in them, prints of variables and maybe some <em>foreach</em> loops. Nothing more than that should be + used in a view!</p> +<p>Views must be placed in this directory and obey the following + conventions:</p> +<p>1. They must be named after a controller's action to allow the controller to refer to a + particular view automatically. The same view can be used by multiple controllers, but it must be either set + manually or through a layout (see below).</p> +<p>2. Views referring to an action of a particular controller must + be placed under a subfolder named after the controller.</p> +<p>3. All views must have a .thtml + extension.</p> +<p>Any site-wide view, like the site's template, must be placed under the <em>layouts</em> + subfolder. In particular, the default.thtml file in the folder represents the global template for your + application: page titles and specific pages (views) will be invoked automatically by using $title_for_layout and + $content_for_layout respectively.</p> +<p>Similarly to what was said about components, <em>helpers</em> can + be used to extend views functionalities[20]:</p> +<fieldset> + <blockquote> + <p>"Helpers are all about the view. You know about the helpers in Cake, but you need a little + bit more. You want to have your own methods to display formatted info. To achieve this, you need to add + var $helpers = array('myHelper').</p> + <p>Now, throw your myhelper.php file into the + /app/views/helpers/, create the class MyHelper, and $myHelper is available in the view."</p> + </blockquote> +</fieldset> +<p>Cake comes with some very useful default helpers to create links and HTML tags, import + JavaScript, create forms, and use AJAX code easily. Unlike most other frameworks, Cake neither has nor uses a + third party template engine (like Smarty[21]) for views, but helpers can be used to achieve similar results more + quickly than an engine can.</p> + +<h4>Plugins</h4> +<p>Plugins are user-developed + enhancements for Cake. Unlike the files placed under the <em>vendor</em> directory, a plugin is an application + specifically made to be used within the CakePHP environment. At the moment this feature is still under + development.</p> + +<h4>Webroot</h4> +<p>If you read + carefully what I wrote above about routes, you might be wondering if <em>every</em> page must have a controller + and a view in order to be displayed properly. What about images, JavaScript and CSS files? The answer is this + directory: everything you place here will not be seen as part of the MVC-based environment; CSS files can be + stored in the <em>/css</em> folder, Javascript under <em>/js</em>, and so on. Additionally, some helpers can + provide a easier way to access or display images, scripts, CSS, etc.</p> + +<h4>Other Features</h4> +<p>Cake offers even more than this; the + latest releases have introduced a few more Rails-inspired features:</p> +<ul> + <li>Scaffolding: Do you want to test your application without spending time writing all the CRUD + (Create, Read, Update, Delete) code? That's where the concept of scaffolding comes in: by setting a few + variables in the right places[22], Cake will generate basic mechanisms to add, edit, list, and delete + records in your database, along with all the associated view files. You won't have to code a single form, as + everything will be generated automatically by the framework according to SQL field types.</li> + <li>Bake: Another Rails-inspired feature revisited in PHP. Rails uses a set of scripts and in particular the + <em>rake</em> utility to instantaneously create the foundation for a Rails application with scaffolds + already in place. CakePHP offers the same functionality through the <em>bake</em> utility, which is + currently available as either a batch file or a PHP script. + </li> + <li>ACL: As previously mentioned, Cake comes with a ready-made Access Control List + (ACL) system, which can be extended and used to restrict particular areas of a Cake application to certain users + or user + groups.</li> + <li>Compatibility: CakePHP is fully compatible with both PHP and PHP5.</li> +</ul> + +<h3>Meet the Bakers</h3> +<p>After reading all these things about CakePHP + and its framework, you may have some questions, or be curious about some aspect of the project. PHPNut and gwoo, + two of CakePHP's creators and lead developers, offered to answer some questions exclusively for zZine readers. + This interview took place on Oct. 26th, 2005, in #dev-cakephp on irc.freenode.org.</p> +<em><strong>h3rald</strong>:</em> +<p> Thanks to both of you for allowing me to + interview you about your project, CakePHP. Where did the name come from, anyway?</p> +<em>PHPnut:</em> The +original project was started by Michal Tatarynowicz aka Pies (hence the name), and when I saw his release, last +March, I decided to contact him. I told him that the company I own supports projects like Cake, and also that I +was in the process of developing something along the same lines. </p> +<em><strong>h3raLd</strong>:</em> +<p> Is Cake released under the GPL? How many + developers are helping out?</p> +<em>gwoo:</em> Cake is released under the MIT license, and the +development team is composed of me and PHPnut, plus four other contributors. Then there's the Documentation +Team, currently 3-5 people. Documentation has to follow the releases, so it usually lags behind a bit: we made +so many modifications in the recent release that the Doc Team has a lot to catch up on, but it's getting +there.</p> +<em>PHPnut:</em> With this release you will see that the docs are going to be much better. The +code is very stable now, and hopefully very little changes on that.</p> +<em><strong>h3raLd</strong>:</em> +<p> Some people, at first glance, may think that Cake + is a PHP port of Ruby on Rails. How true is that? What are the differences and similarities between these two + frameworks?</p> +<em>PHPnut:</em> Cake started as a port, but has evolved into something more: we +discussed using the concepts that RoR offered and including them in a framework for users of PHP. I have used +PHP for a number of years, and I am comfortable with it; this is where my passion is, and I think people who use +Cake have those same passions as we developers do.</p> +<em><strong>h3raLd</strong>:</em> +<p> I read once that Rails was developed in Ruby + because only Ruby can offer certain functionalities and features...</p> +<em>gwoo:</em> I would disagree, +and I think that is proven in what we have done: sure RoR has a built in server and some other nice things, but +PHP is everywhere.</p> +<em><strong>h3raLd</strong>:</em> +<p> Some developers, especially Perl programmers, tend to consider PHP an "inferior" language sometimes. What do you + think of + that?</p> +<em>PHPnut:</em> My name says what I think about them all.</p> +<em>gwoo:</em> PHP is a +web programming language; that's what it was designed for, and that's what it does best: It all boils down to +what you are comfortable with.</p> +<em><strong>h3raLd</strong>:</em> +<p> Did + you try any other PHP frameworks, MVC-based (Mojavi, for example), or event-driven, like Prado? What do you + think about them? In what ways can Cake be better or worse?</p> +<em>gwoo:</em> They are all so complex, +in my opinion, and I tried nearly all of them. Cake breaks apart the MVC and handle the CRUD in a logical way, +and Cake syntax is super easy to learn.</p> +<em><strong>h3raLd</strong>:</em> +<p> Ruby + on Rails has been ported to various + languages, including Java and Python. There are three PHP frameworks inspired by the famous Ruby project: + Biscuit, PHP on Tracks and CakePHP. What do you think of that? Any chance of a merge? Did you have a look at + them?</p> +<em>gwoo:</em> You forgot Symfony[27], a PHP5-only port: I tried it but it seems much harder to +learn than Cake.</p> +<em>PHPnut:</em> I could be wrong, but I think these other projects are behind us in +ease of use, in what the framework is capable of doing, and in features, not to mention community +support.</p> +<em>gwoo:</em> I tried all of the PHP ports of Ruby on Rails and none of them has the +features, the community,or a lexicon as good as Cake's.</p> + + +<p><strong>h3raLd</strong>:</em> Why don't you consider CakePHP a port? In what way is it evolving from Rails?</p> +<p><em>PHPnut:</em> Rails and CakePHP share a lot: MVC pattern, Active Record pattern...but we're not strictly following + Rails, and we're able to think by ourselves. Recently we changed the directory structure, and in my opinion ours is + more functional than the Ruby on Rails one.</p> +<p><strong>h3raLd</strong>:</em> What can Cake be used for? What kind of projects? Are there any limitations?</p> +<p><em>gwoo:</em> Personally I think that Cake is the most extensible framework out there for PHP: with components, + helpers and vendor access you can do anything you want!</p> +<p><em>PHPnut:</em> We are limited only by what a web server (generally Apache, but IIS seems to work as well) and a + database can do. We may be limited by PHP itself, but we twist that in our own little sick ways sometimes.</p> +<p><strong>h3raLd</strong>:</em> Any thought about AJAX? I saw some nice demos made with Cake. What do you think of this + new trend in web development? Some people consider it the future, while others are concerned about compatibility, + and still others are relatively indifferent to it. What about you?</p> +<p><em>gwoo:</em> AJAX can be very useful in creating an application, but should not be overused. People have become + very comfortable with how the Web works: if you start doing tons of drag and drop and no refreshes, users will feel + lost in how to operate the site.</p> +<p><strong>h3raLd</strong>:</em> Thank you very much for your time, both of you. Is there anything you'd like to add to + this interview? Something you'd like to say to users interested in trying out Cake?</p> +<p><em>PHPnut:</em> Come and enjoy: we are here to help...</p> +<p><em>gwoo:</em> ...And plan to be here for a very long time!</p> + +<h3>Let's cook...</h3> +<p>One of the most positive things about CakePHP is that even though it is a fairly new project (most of the code is + 100% useable already, but they still consider the project to be in the 'alpha' stage), it's maintained by many + dedicated developers and PHP enthusiasts. I was amazed to see how the whole documentation evolves and is quite + literally updated on a daily basis.</p> +<p>Anybody can contribute to the framework or simply test it and share their experiences.</p> +<h4><em>CakePHP Wiki</em></h4> +<p>Anybody can register an account for free and contribute tutorials and documentation to the new CakePHP Wiki. This is + currently the most up-to-date source for documentation files and tutorials. [23]</p> +<h4><em>CakePHP User Group</em></h4> +<p>If you need assistance or you want to contact the Cake developers or other Cake users, you can post a message on + their Google User Group: people will reply with useful comments, usually on the same day, and the developers + <em>do</em> listen to user suggestions. [24] +</p> +<h4><em>CakePHP IRC Channel</em></h4> +<p>If you want to offer (or receive) real-time assistance, feel free to join #cakephp on FreeNode (irc.freenode.org). I + went there disguised as a total newbie (it wasn't much of a stretch) and they helped me a lot, explaining basic + concepts of the framework and pointing me to the right documentation files.</p> +<h4><em>CakePHP Development</em></h4> +<p>Experienced PHP developers are more than welcome to contribute to the project. People may be accepted to the core + development team if they have sufficient knowledge and spare time, or alternatively, components or code can be + submitted through the newly created CakeForge. [24]</p> + + + +<h3>...Or Just Eat</h3> <small><em> by Marc Abramowitz</em></small><br /><br /> +<p>If you don't feel ready to contribute and you'd like to try out the framework first, it can be downloaded directly + from the CakePHP site[25] as either a <em>release</em> or a <em>nightly</em> build: the zip file is less than 300KB. +</p> +<p>I wanted to include a <em>success story</em> written by Marc Abramowitz, an experienced PHP programmer who decided to + adopt CakePHP as a framework to use in a production environment: he persuaded his colleagues to use it and they all + seem happy with it. He writes:</p> +<em>For the past few years, I've done quite a bit of work in PHP, working on production code that runs on a very high + traffic web site. PHP has served us well, as it is easy to write and read, quite efficient, and easy to integrate + with existing C++ code as the site grew.</em><br /><br /> +<p>Lately, there has been a lot of buzz in the web development community about Ruby on Rails. Like many others, I took + some interest in Ruby on Rails because I was intrigued by the apparent power and elegance of Ruby and because I + wondered if a Model/View/Controller (MVC) framework like Rails would help enforce a more consistent code structure + that would make the code easier to understand and maintain. Additionally, I wondered if an MVC framework would + enable very rapid prototyping.</p><br /><br /> +<p>Some people are very wary of frameworks that impose structure, as they like to have the freedom to do things however + they want. However, there is a tradeoff between structure and flexibility. If you're working on a small team or a + relatively small project, then you may not find structure to be very helpful; you may even find that it gets in your + way.</p><br /><br /> +<p>However, as teams and projects get larger, structure becomes more and more valuable, as it enforces consistent + patterns of how to do things and rather than being something that limits, it in fact liberates, because it abstracts + away the small details and allows us to therefore concentrate on the larger problem. Think of the lines that are + painted on our roadways - although they add structure, we don't find them to be limiting. On the contrary, they help + us to drive without worrying about crashing into each other at every moment - they free us from being concerned with + small details so that we can concentrate on getting where we're going.</p><br /><br /> +<p>Rapid prototyping appeals to me, because I find it helps me to better present my ideas for new apps and features. A + mockup can only go so far - there is no substitute for a working prototype. When clients get their hands on a + functional prototype, they get a better idea of what is possible and it forces them to clarify their requirements + for the product. This results in a better dialogue between the developer and the client, which leads to better + upfront decisions, more stable requirements, less stress, and a better product.</p><br /><br /> +<p>So, Rails appealed to me not only because of the potentially valuable structure that it could add, but also because + it could enable rapid prototyping. However, I knew that there was no chance of Rails being used for production code + in my organization, because we run some very high traffic web sites that require the utmost in efficiency. We are + also by and large a PHP shop.</p><br /><br /> +<p>However, when my manager approached me and asked me to develop a database-backed internal tool, I thought of Rails + again. I then considered the fact that I would probably someday have to hand this app off to someone else, and that + someone would probably know PHP but not Ruby. Heck, even I had several years of experience with PHP (including + writing some PHP extensions) but I had only done a little bit of reading about Ruby, and I also had no practical + experience with it.</p><br /><br /> +<p>Furthermore, with PHP I had access to a large number of PHP extensions that wrapped various internal libraries. So + PHP was the natural choice. Ideally, I wanted to use PHP with a Rails-like MVC framework that would facilitate rapid + development, and this is what led me to CakePHP.</p><br /><br /> +<p>I began by downloading CakePHP 0.9.2 and following the sample tutorial that walks you through creating a simple blog + application (note that at the time of this writing, the current version of Cake is now 0.10.0.1076, so some of the + details of using Cake have changed). I was pleased to find that the process was quite similar to the process for + Rails. One difference that I noted was that Rails tutorials always emphasize using scripts to generate models, + controller, and scaffolds, whereas the Cake tutorial walked me through explicitly writing out all the code. I + noticed that the Cake download came with a script called "bake" which looked like something that could potentially + do some of the code generation, but since it wasn't mentioned in the tutorial, I chose not to use it.</p> + + +<p>The process of creating a first application using the tutorial was quite easy. Here are the steps in brief (consult + the tutorial for more details):</p> +<p>1. Create the database table. Cake requires tables to have some extra fields:</p> +<ul> + <li>id, an auto_increment primary key</li> + <li>created, a datetime</li> + <li>updated, a datetime</li> + <li>Configure Cake to access the database by editing the config/database.php file</li> + <li>Create a model class which extends AppModel (a Cake provided class)</li> + <li>Create a controller class which extends AppController (a Cake provided class) and write one or more controller + methods</li> + <li>Create a view which is a PHP file with a .thtml extension and is meant to be mostly HTML with very little + embedded + PHP - typically just echoing of variables and some simple control structures like <em>foreach</em>. Cake also + provides some simple convenience methods that write out certain HTML constructs for you.</li> +</ul> +<p>That's it! That alone is enough to create a basic but functional application. The tutorial goes on to show you how to + add additional functionality to the blogging app. After that there's a shorter, more advanced tutorial that shows + you how to add a few more things to the blogging app.</p> +<p>Once I had gotten comfortable with Cake by following the tutorial, I proceeded to write my own application. Getting + started was easy - I followed the same steps as in the tutorial to create my first table, model, controller, and + views, then my second table, model, controller, and views. Then my app got a bit more complicated. I needed to have + many-to-many relations and more elaborate queries than the default ones that Cake provides. I began to worry that + Cake would break down here. I had heard people grumble that MVC frameworks like Rails and Cake were great for little + toy apps that only do CRUD (Create, Read, Update, Delete), but that they couldn't handle complex queries using joins + and the like. I poked around in the Cake source code and was pleased to find that there were nice lower level + methods that allowed me to bypass the Cake defaults and do whatever custom queries I liked. For example, I wrote + something like this in one of my models:</p> +<pre><code class="php">function index(){ + return $this-findBySql( + "SELECT id, title, AVG(rating) avg_rating, MIN(rating) min_rating, MAX(rating) max_rating, COUNT(rating) num_ratings " . + "FROM ideas LEFT JOIN ratings ON ideas.id = ratings.skill_id " . + "GROUP BY id " . + "ORDER BY title"); + } + </code></pre> +<p>So what I have is a model that does <em>not</em> have a one-to-one mapping with a single table. It actually retrieves + data from more than one table.</p> +<p>Over time, I picked up a few more Cake concepts. For example, at some point we decided that every page of the app + would have a similar look and feel with a particular masthead and logo, and all the pages in one section of the site + would show tabs for all of the various views with the currently selected tab highlighted. At first, I just used the + same code at the top of each of my views to display the masthead, logo, and tabs. This, of course, became a pain + when I needed to change the layout, since I needed to make the same change in several different views.</p> +<p>Then one day I realized that Cake had a concept of layouts, which are high level templates in + <em>app/views/layouts</em> that define the basic structure of pages. The individual views are just content that gets + embedded in these high level layout templates. So I took the common masthead and logo, put it in my default layout, + and removed it from the individual views. Now when I wanted to change the look of the masthead, I only had to do it + in one place. For the tabs, I discovered the concept of elements. I placed the code for my tabs in + <em>apps/views/elements/tabs.thtml</em>. Then the tabs could be displayed in any template using: +</p> +<pre><code class="php">&lt;?php echo $this-renderElement('tabs') ? + </code></pre> + + +<p>Rather than stick the above statement in all of the many pages that were supposed to display tabs, I created a new + layout in <em>apps/views/layouts/tabbed.thtml</em> (which uses renderElement to render the tabs). Then I used</p> +<p>$this-layout = "tabbed"</p> +<p>in the controller to tell it to use the tabbed layout rather than the default (non-tabbed) layout.</p> +<p>After a couple of days of work on this application, it was time to demo it to the VP, who was very impressed with + what I was able to accomplish in such a short period of time. It was brought up that before I took on the project + they had asked some other folks how long it would take them to build it in Java and they had said that it would take + on the order of months what I had built in a couple of days. Morals of the story:</p> +<ol> + <li>Cake is very lightweight and productive</li> + <li>Cake might be very beneficial to your career</li> +</ol> +<p>Eventually, I was assigned to another project and my manager wanted me to transition my Cake project to another + engineer, who was experienced with PHP but not with Cake. I sat down with the new engineer and in about 20 or 30 + minutes of explanation and walking him through the code,</p> +<p>he felt ready to code. Not only did he feel that he knew enough to start working with the application, I could tell + from the smile on his face that he was very impressed by the power and succinctness of Cake, which was the same + reaction that I initially had. After a couple of days, I checked back with him and he had made a remarkable amount + of progress on the application - there were a ton of new pages and features.</p> +<p>So you see, Cake is a very productive environment. For a very small investment in the initial learning curve, you can + get a significant increase in productivity.</p> + + + + +<h3>...And the icing?</h3> + +<p>So that's what CakePHP is about. The project may only have just entered alpha stage, but the code is already very + stable and useable, as PHPnut, gwoo and Marc said. So what's going to be included in the beta and stable releases? I + researched a bit and asked the developers, and here's how Cake will probably evolve in the following months:</p> + +<ul> + <li>Cake's built-in <h3>data-validation</h3> capabilities will be extended. A validator class - which already + exists, by the way - will be extended to include more data types and expressions to be validated before being + stored in a database.</li> + <li>A new default <h3>ACL system</h3> will be included and will support database access and .ini files as well.</li> + <li>The <h3>AJAX</h3> helper class and AJAX support will be enhanced, featuring unobtrusive JavaScript and ALA + behavior[28].</li> + <li>Multiple applications with the same core files. In the future developers will be able to create their own Cake + application which could be placed in the app/plugins directory and be seamlessly integrated and auto-linked to + other Cake applications.</li> +</ul> + +<p>After learning all this about Cake and after trying it out myself, I really think that I have found the solution to + all of my PHP web development problems. CakePHP can really help PHP developers a lot if properly used and + understood. Still not convinced? Just try it out then, will you?[17]</p> + +<h3>Notes and Related + Resources</h3> + +<p>Special thanks to:</p> +<ul> + <li>Larry E. Masters aka PhpNut and Garrett J. Woodworth aka gwoo for providing all the answers to + my questions and contributing to create such a wonderful tool for the PHP community.</li> + <li>Marc Abramowitz for sharing his experiences with the CakePHP framework and providing the content for the + '...let's eat' section.</li> +</ul> + +<p>Notes:</p> +<ul> + <li> + [1] PHP functions reference, <a + href="http://www.php.net/manual/en/funcref.php">http://www.php.net/manual/en/funcref.php</a> + </li> + <li> + [2] Framework, Wikipedia Page - <a + href="http://en.wikipedia.org/wiki/Framework">http://en.wikipedia.org/wiki/Framework</a> + </li> + <li> + [3] .NET framework overview - <a + href="http://msdn.microsoft.com/netframework/technologyinfo/default.aspx">http://msdn.microsoft.com/netframework/technologyinfo/default.aspx</a> + </li> + <li> + [4] "PHP Framework", delorian's blog, PHP Community - <a + href="http://www.phpcommunity.org/node/100">http://www.phpcommunity.org/node/100</a> + </li> + <li> + [5] Some popular PHP frameworks: + <ul> + <li>Mojavi (<a href="http://www.mojavi.org/">http://www.mojavi.org/</a>)</li> + <li>phpMVC (<a href="http://www.phpmvc.net/">http://www.phpmvc.net/</a>)</li> + <li>BlueShoes (<a href="http://www.blueshoes.org/">http://www.blueshoes.org/</a>)</li> + <li>Seagull (<a href="http://seagull.phpkitchen.com/">http://seagull.phpkitchen.com/</a>)</li> + </ul> + </li> + <li> + [6] PEAR - <a href="http://pear.php.net/">http://pear.php.net/</a> + </li> + <li> + [7] Prado - PHP Rapid Application Development Object-Oriented, <a + href="http://www.xisc.com/">http://www.xisc.com/</a> + </li> + <li> + [8] Event Driven Programming, Wikipedia Page - <a + href="http://en.wikipedia.org/w/index.php?title=Event_driven_programming">http://en.wikipedia.org/w/index.php?title=Event_driven_programming</a> + </li> + <li> + [9] Ruby on Rails, Official Page - <a href="http://www.rubyonrails.org/">http://www.rubyonrails.org/</a> + </li> + <li> + [10] Ruby on Rails, Documentation - <a + href="http://documentation.rubyonrails.com/">http://documentation.rubyonrails.com/</a> + </li> + <li> + [11] Model View Controller, Wikipedia Page - <a + href="http://en.wikipedia.org/w/index.php?title=Model-View-Controller">http://en.wikipedia.org/w/index.php?title=Model-View-Controller</a> + </li> + <li> + [12] PHP frameworks inspired by Rails: + <ul> + <li><a href="http://phpontrax.com/">http://phpontrax.com/</a></li> + <li><a href="http://flinn.activeintra.net/biscuit/">http://flinn.activeintra.net/biscuit/</a></li> + <li><a href="http://www.cakephp.org/">http://www.cakephp.org/</a></li> + </ul> + </li> + <li> + [13] Python frameworks inspired by Rails: + <ul> + <li><a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a></li> + <li><a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a></li> + <li><a href="http://subway.python-hosting.com/">http://subway.python-hosting.com/</a></li> + </ul> + </li> + <li> + [14] Java framework inspired by Rails: <a href="https://trails.dev.java.net/">https://trails.dev.java.net/</a> + </li> + <li> + [15] Perl frameworks inspired by Rails: + <ul> + <li><a + href="http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod">http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod</a> + </li> + <li><a href="http://perlonrails.org/index.php/Main_Page">http://perlonrails.org/index.php/Main_Page</a></li> + </ul> + </li> + <li> + [16] "Rails Clones: Blood suckers or useful drones?", RedHanded - <a + href="http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html">http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html</a> + </li> + <li> + [17] CakePHP - Rails-inpired PHP framework, <a href="http://www.cakephp.org/">http://www.cakephp.org/</a> + </li> + <li> + [18] AdoDB, PHP Database Abstraction Layer - <a + href="http://adodb.sourceforge.net/">http://adodb.sourceforge.net/</a> + </li> + <li> + [19] CakePHP blog tutorial - <a + href="http://wiki.cakephp.org/tutorials:blog_tutorial_-_1">http://wiki.cakephp.org/tutorials:blog_tutorial_-_1</a> + </li> + <li> + [20] Extending CakePHP - <a + href="http://wiki.cakephp.org/tutorials:extending_cake">http://wiki.cakephp.org/tutorials:extending_cake</a> + </li> + <li> + [21] Smarty, PHP Template Engine - <a href="http://smarty.php.net/">http://smarty.php.net/</a> + </li> + <li> + [22] Scaffolding a Blog, CakePHP Wiki - <a + href="http://wiki.cakephp.org/tutorials:scaffolding_a_blog">http://wiki.cakephp.org/tutorials:scaffolding_a_blog</a> + </li> + <li> + [23] CakePHP Wiki - <a href="http://wiki.cakephp.org/">http://wiki.cakephp.org/</a> + </li> + <li> + [24] CakePHP Google User Group - <a + href="http://groups.google.com/group/cake-php">http://groups.google.com/group/cake-php</a> + </li> + <li> + [25] CakeForge - <a href="http://cakeforge.org/">http://cakeforge.org/</a> + </li> + <li> + [26] CakePHP Downloads Page - <a href="http://cakephp.org/downloads/">http://cakephp.org/downloads/</a> + </li> + + + <li>[27] Simfony, PHP5 framework - <a href="http://www.symfony-project.com/">http://www.symfony-project.com/</a> + </li> + <li>[28] ALA behavior - <a href="http://bennolan.com/behaviour/">http://bennolan.com/behaviour/</a></li> +</ul>
M contents/articles/from-firefox-to-deer-park.htmlcontents/articles/from-firefox-to-deer-park.html

@@ -4,4 +4,95 @@ content-type: article

timestamp: 1132509930 tags: "firefox|browsers|review" ----- -On May 31st 2005 the Mozilla Foundation silently released the Deer Park browser... no, it's not another name change for Firefox, but the codename they gave to the long-awaited 1.1 release of the free, famous, award-winning browser. Actually what we have for now is just a non-feature complete developer preview release of the new milestone, the first alpha release, in other words. The alpha release nevertheless seems to be fully functional and already useable.ETAs for the actual stable version are not given as usual, but we should expect another alpha candidate soon hopefully (They wrote "June" on the <a href="http://www.mozilla.org/projects/firefox/">roadmap</a>, and we're already in July). Anyhow, this developer-oriented preview release can be <a href="http://www.mozilla.org/projects/firefox/">downloaded</a> and installed on Windows, Linux, and Mac OS X systems plus eventually, <a href="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/deerpark/alpha1/contrib/">Solaris and others</a>. The decision of using the codename Deer Park instead of naming the release Firefox 1.1 alpha 1 or something of the like was made to avoid the havoc which occurred before the official release of Firefox 1.0 (which was codenamed "Phoenix" by the way,) when some websites offered a late preview release as the actual new version to download.<br />This time when you install and run the program the Firefox name has been substituted with Deer Park Alpha 1, so for example Deer Park is used in the browser's title bar and in the "About Deer Park Alpha 1" menu under "Help". The icon they used for this testing release is not even the usual firefox icon - it represents a plain blueish globe with no fox whatsoever. They have definitely put in effort this time to avoid confusion.<br /><br />Furthermore, when the browser is installed it does not overwrite your existing firefox installation, simply because (on windows) it's installed under a directory named "Deer Park Alpha 1". As a side note, the process is "firefox.exe", so you cannot run Firefox and Deer Park at the same time: you'll just open another window of the browser which is already running. Having said this, let us now examine what is new in this developer's release.<br /><br /><strong>Fixed bugs</strong><br />Like any other Firefox Release, Deer Park comes with several <a href="http://www.squarefree.com/burningedge/releases/1.1a1.html">Bug Fixes</a>. On the official changelog there are many bugs reported to be fixed, sometimes they are hardly noticeable but I experienced some of them when browsing some websites and also when creating applications myself:<br /><br />- <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=103638">103638</a> - Targets with same name in different windows open in wrong window with javascript.<br />- <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=97283">97283</a> - Mouse wheel scrolling does not work for elements such as div using overflow - auto or scroll.<br />- <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=251986">251986</a> - Keyboard scrolling does not work for elements such as div using overflow - auto or scroll.<br />- <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=245829">245829</a> - Download manager progress and title do not update correctly, wrong number of files and percentage after finishing or cancelling a download.<br /><br />These are in my opinion the most notable of the notable bugs which have been fixed in this release. I was particularly relieved when I noticed that all the issues regarding scrolling divs or similar elements had been resolved. Also, it must be noted that Deer Park seems overall slightly faster than Firefox 1.0.4 (Note: I also have a Pentium II, that is why I could notice that probably). The speed increase is most probably caused by the base for Deer Park being the Mozilla 1.8 Beta 2 code, which is almost 1 year newer than what used for Firefox 1.0.<br /><br /><br /><strong>New Features</strong><br />Although announced as a non-feature complete release, it comes with some new and useful features. The new feature list includes nothing too extraordinary for now and they are all somehow minor changes but they really do represent some improvements. Perhaps the two most obvious features introduced with this release are the <em><strong>Sanitize Deer Park</strong></em> and the <em><strong>Report Broken Sites</strong></em> functions. The first one is accessible through the Tools menu and basically allows you to delete the Browsing History, Saved Form Information, Saved Passwords, Download History, Cookies and Cache. Actually you can accomplish the same feat via Options->privacy, but with Sanitize you need just one click. Convenience I suppose?<br /><br />The Report Broken Sites feature is reachable via the Help menu and basically starts a short wizard that you can use when you notice something wrong with a website. You just have to provide the url of the website, the problem you experienced (Browser not supported, cannot login, plugin not installed, other content missing, odd behaviou, odd appearence, etc.) and an optional description and email and then the report will be submitted to the Mozilla Deleopers.<br /><br />Additional features included are also <em>Image thumbnails as Tab icons</em>, used when viewing a single image with firefox, not a shocking feature really but it's just a little (tiny) bit of eyecandy I guess. Furthermore, when you try accessing an FTP server anonymously and that server doesn't allow anonymous access, you are prompted to provide appropriate credentials (before it just didn't let you in)... another little improvement, which probably will not change your life, but it's nice to know that it's there.<br /><br />Another more notable feature only for linux and mac users though allows changes made in the Preferences menu to be applied immediately without restarting your system. Using Windows on the other hand, they improved the option interface with a more extensive use of tabbed interfaces, and also additional options concerning tabbed browsing (BUT in my opinion the <a href="https://addons.mozilla.org/extensions/moreinfo.php?id=158&application=firefox">tabbrowser preferences</a> extension is still necessary to achieve certain behaviours).<br /><br />Regarding something more technical, among the so-called developers features there are various improvements regarding CSS support, in particular CSS2's <a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes nesting</a> and even some new CSS3 (!) features, like <a href="http://www.w3.org/TR/css3-multicol/">Multi-column layouts</a> the :only-child selector, overflow-x and overflow-y properties and even various new <a href="http://www.w3.org/TR/css3-ui/#cursor">cursors names</a>.<br />Even more news from Mozilla suggests that Deer Park already supports some functions for resolution-independent scalable vector graphics (SVG 1.1), but it's obviously just experimental, and even scriptable bitmap drawing surface (<a href="http://developer-test.mozilla.org/docs/Drawing_Graphics_with_Canvas">Canvas</a>). Last but not least, even support for <a href="http://www.w3.org/MarkUp/Forms/">Xforms</a> is already possible in Deer Park through a <a href="http://www.mozilla.org/projects/xforms/">related project/extension</a>. <br /><br /><br /><strong>Final Thoughs</strong><br />Again the Mozilla Foundation - with this fully functional but yet incomplete preview release,- seem to be always improving their foundations, and always offering support for new technologies and features before others. This release has certainly seen some great improvements, on the other hand hardly anything changes for website developers with this release. It is without a doube that websites are viewed better with Deer Park than with Firefox 1.0.4 or IE or any other browser for that matter. But it is impossible to even start planning at this stage for the development of a publicly accessible site using for example SVG graphics and Xforms, as visitors using other browsers will not be able to see any "magic" in them, or perhaps even view them at all.<br /><br />It's always the same paradox of web-development: where on one side of the coin there are new and better products are available, a website/online application should be accessible by at least 90-95% of visitors. Unfortunately, for now though 90-95% of all internet users seem to use <em>some other product</em> instead of Firefox or Deer Park... But that's another story!<br /> + +<p>On May 31st 2005 the Mozilla Foundation silently released the Deer Park browser...</p> +<p>no, it's not another name change for Firefox, but the codename they gave to the long-awaited 1.1 release of the free, + famous, award-winning browser. Actually what we have for now is just a non-feature complete developer preview + release of the new milestone, the first alpha release, in other words. The alpha release nevertheless seems to be + fully functional and already useable.ETAs for the actual stable version are not given as usual, but we should expect + another alpha candidate soon hopefully (They wrote "June" on the <a + href="http://www.mozilla.org/projects/firefox/">roadmap</a>, and we're already in July). Anyhow, this + developer-oriented preview release can be <a href="http://www.mozilla.org/projects/firefox/">downloaded</a> and + installed on Windows, Linux, and Mac OS X systems plus eventually, <a + href="http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/deerpark/alpha1/contrib/">Solaris and others</a>. + The decision of using the codename Deer Park instead of naming the release Firefox 1.1 alpha 1 or something of the + like was made to avoid the havoc which occurred before the official release of Firefox 1.0 (which was codenamed + "Phoenix" by the way,) when some websites offered a late preview release as the actual new version to download.</p> +<p>This time when you install and run the program the Firefox name has been substituted with Deer Park Alpha 1, so for + example Deer Park is used in the browser's title bar and in the "About Deer Park Alpha 1" menu under "Help". The + icon they used for this testing release is not even the usual firefox icon - it represents a plain blueish globe + with no fox whatsoever. They have definitely put in effort this time to avoid confusion.</p> +<p>Furthermore, when the browser is installed it does not overwrite your existing firefox installation, simply because + (on windows) it's installed under a directory named "Deer Park Alpha 1". As a side note, the process is + "firefox.exe", so you cannot run Firefox and Deer Park at the same time: you'll just open another window of the + browser which is already running. Having said this, let us now examine what is new in this developer's release.</p> + +<h3>Fixed bugs</h3> +<p>Like any other Firefox Release, Deer Park comes with several <a + href="http://www.squarefree.com/burningedge/releases/1.1a1.html">Bug Fixes</a>. On the official changelog there + are many bugs reported to be fixed, sometimes they are hardly noticeable but I experienced some of them when + browsing some websites and also when creating applications myself:</p> +<ul> + <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=103638">103638</a> - Targets with same name in different + windows open in wrong window with javascript.</li> + <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=97283">97283</a> - Mouse wheel scrolling does not work for + elements such as div using overflow - auto or scroll.</li> + <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=251986">251986</a> - Keyboard scrolling does not work for + elements such as div using overflow - auto or scroll.</li> + <li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=245829">245829</a> - Download manager progress and title + do not update correctly, wrong number of files and percentage after finishing or cancelling a download.</li> +</ul> +<p>These are in my opinion the most notable of the notable bugs which have been fixed in this release. I was + particularly relieved when I noticed that all the issues regarding scrolling divs or similar elements had been + resolved. Also, it must be noted that Deer Park seems overall slightly faster than Firefox 1.0.4 (Note: I also have + a Pentium II, that is why I could notice that probably). The speed increase is most probably caused by the base for + Deer Park being the Mozilla 1.8 Beta 2 code, which is almost 1 year newer than what used for Firefox 1.0.</p> + + +<h3>New Features</h3> +<p>Although announced as a non-feature complete release, it comes with some new and useful features. The new feature + list includes nothing too extraordinary for now and they are all somehow minor changes but they really do represent + some improvements. Perhaps the two most obvious features introduced with this release are the <em><strong>Sanitize + Deer Park</strong></em> and the <em><strong>Report Broken Sites</strong></em> functions. The first one is + accessible through the Tools menu and basically allows you to delete the Browsing History, Saved Form Information, + Saved Passwords, Download History, Cookies and Cache. Actually you can accomplish the same feat via + Options-&gt;privacy, but with Sanitize you need just one click. Convenience I suppose?</p> +<p>The Report Broken Sites feature is reachable via the Help menu and basically starts a short wizard that you can use + when you notice something wrong with a website. You just have to provide the url of the website, the problem you + experienced (Browser not supported, cannot login, plugin not installed, other content missing, odd behaviou, odd + appearence, etc.) and an optional description and email and then the report will be submitted to the Mozilla + Deleopers.</p> +<p>Additional features included are also <em>Image thumbnails as Tab icons</em>, used when viewing a single image with + firefox, not a shocking feature really but it's just a little (tiny) bit of eyecandy I guess. Furthermore, when you + try accessing an FTP server anonymously and that server doesn't allow anonymous access, you are prompted to provide + appropriate credentials (before it just didn't let you in)... another little improvement, which probably will not + change your life, but it's nice to know that it's there.</p> +<p>Another more notable feature only for linux and mac users though allows changes made in the Preferences menu to be + applied immediately without restarting your system. Using Windows on the other hand, they improved the option + interface with a more extensive use of tabbed interfaces, and also additional options concerning tabbed browsing + (BUT in my opinion the <a + href="https://addons.mozilla.org/extensions/moreinfo.php?id=158&application=firefox">tabbrowser preferences</a> + extension is still necessary to achieve certain behaviours).</p> +<p>Regarding something more technical, among the so-called developers features there are various improvements regarding + CSS support, in particular CSS2's <a href="http://www.w3.org/TR/CSS21/generate.html#quotes-specify">quotes + nesting</a> and even some new CSS3 (!) features, like <a href="http://www.w3.org/TR/css3-multicol/">Multi-column + layouts</a> the :only-child selector, overflow-x and overflow-y properties and even various new <a + href="http://www.w3.org/TR/css3-ui/#cursor">cursors names</a>.</p> +<p>Even more news from Mozilla suggests that Deer Park already supports some functions for resolution-independent + scalable vector graphics (SVG 1.1), but it's obviously just experimental, and even scriptable bitmap drawing surface + (<a href="http://developer-test.mozilla.org/docs/Drawing_Graphics_with_Canvas">Canvas</a>). Last but not least, even + support for <a href="http://www.w3.org/MarkUp/Forms/">Xforms</a> is already possible in Deer Park through a <a + href="http://www.mozilla.org/projects/xforms/">related project/extension</a>.</p> + +<h3>Final Thoughs</h3> +<p>Again the Mozilla Foundation - with this fully functional but yet incomplete preview release,- seem to be always + improving their foundations, and always offering support for new technologies and features before others. This + release has certainly seen some great improvements, on the other hand hardly anything changes for website developers + with this release. It is without a doube that websites are viewed better with Deer Park than with Firefox 1.0.4 or + IE or any other browser for that matter. But it is impossible to even start planning at this stage for the + development of a publicly accessible site using for example SVG graphics and Xforms, as visitors using other + browsers will not be able to see any "magic" in them, or perhaps even view them at all.</p> +<p>It's always the same paradox of web-development: where on one side of the coin there are new and better products are + available, a website/online application should be accessible by at least 90-95% of visitors. Unfortunately, for now + though 90-95% of all internet users seem to use <em>some other product</em> instead of Firefox or Deer Park... But + that's another story!</p>
M contents/articles/perfect-browser.htmlcontents/articles/perfect-browser.html

@@ -4,4 +4,401 @@ content-type: article

timestamp: 1134135061 tags: "" ----- -So you finally decided to say goodbye to Internet Explorer, but now you feel lost in a multitude of browsers that all claim to be faster, more customizable, safer, or simply better than IE. Are they telling the truth? If so, which one is the perfect browser?<strong>Point of view, clarifications and scope of this article</strong><br /><br />So you're reading this article hoping to find out which is the <em>best</em> browser ever made? Well, you're wasting your time. There's no such thing as <em>The Perfect Browser</em>, despite the various attempts made by Mozilla Foundation, Opera, Microsoft and others. After trying out nearly all of the major browsers currently available, I came to this conclusion: the perfect browser is a relative term, dependent on the particular person you ask, if it exists at all. Contrary to popular belief, I myself am not a 100% Firefox freak, and I do not consider myself biased to the point of going around shouting that Firefox is the <em>"best browser ever made."</em> Granted, I do do that sometimes, but let's put my personal bias into some sort of perspective:<br /><br />Mozilla Firefox represents the most remarkable effort to create a <em>perfect browser</em>, but in some cases, and for some particular tasks, it may not be considered optimal by <em>some people</em>.<br /><br />Having said this, I hope I can convince you that I'm not <em>that</em> biased toward Mozilla's leading product, even if, as a matter of fact, nearly all the programs mentioned in this article are based on the Mozilla ('Gecko'? No, not quite... [1]) engine or a derivative. <br /><br />Originally, I was going to write a comparative review of Opera and Firefox, but in the end, I chose to broaden the scope a bit to include other products as well. There are already many articles and blog posts which have compared the two, either favoring Opera [2] or Firefox [3]. I also decided not to review browsers for platforms other than Windows, so there won't be any mention of Konqueror, Galeon, Safari, Camino, etc., which, although they are all interesting alternatives, go beyond the purpose of this article, which is to offer <em>Windows users</em> a small selection of alternative browsers.<br /><br /><br /><strong>Alternative Browsers</strong><br /><br />There are literally dozens of <em>alternative</em> browsers around. There are lists available online, and perhaps the most famous one is on Evolt.org [4], which can be considered comprehensive and accurate. Various statistics are available for objective comparisons of all the major browsers, for regarding for example speed [5] and overall performance and functionality [6], but even if such analyses are accurate, they are often not enough to fully evaluate a browser.<br /><br />In the following sections, we'll examine the following four free browsers, which are considered to be the most obvious alternatives to Internet Explorer. <br /><br />- Firefox<br />- Opera <br />- K-meleon<br />- Netscape<br /><br />I deliberately chose not to spend time on Slim Browser [7], Maxthon [8] (previously known as MyIE), or AvantBrowser [9], which are basically extensions built on top of Internet Explorer to add functionality to it. I also left out Mozilla's SeaMonkey [10], partly because of its alpha status, and partly because it is being marketed as an Internet Suite rather than just a web browser.<br /><br /><br /><strong>Why IE is 'bad'</strong><br /><br />'IE is crap', 'you MUST NOT use Internet Explorer', 'Internet Explorer is for n00bs'... how many times have you heard or read this? Some people tend to degrade Internet Explorer all the time, and the funny thing is, if one were to ask 'Why so?', approximately 40% would be unable to give a reply any more concrete than 'because Firefox is simply better' or 'because Opera owns!' or '[insert browser name here] simply can't be compared to IE!'.<br /><br />Now, all this may be true to a certain extent, but it certainly will not convince a person to switch browsers, and may even have the opposite effect: people will keep using IE no matter what! This is bad for the alternative browser market in general. It still looks like IE is used by 90% of people on the Internet and this will not change simply by telling all those people that they are "dumb" for using IE. There are sites whose only purpose is to make people abandon IE [11], but they discuss objective fact instead of opinionated propaganda. <br /><br />Personally, I decided not to use IE anymore because:<br /><br />- It's slow on my computer (which is old, as some of you may know)<br />- It's less secure than other browsers, and more vulnerable to malicious software and attacks, simply because it's used by the most people - that makes the BEST option for those who actually enjoy exploiting vulnerabilities, because it's not frequently patched [12].<br />- It's not very customizable<br />- It doesn't have (or support) additional features<br />- It deliberately breaks web standards or creates its own, which makes things difficult for web developers<br />- It's normally behind the supported technologies<br />- I hate the idea of using a proprietary browser imposed by Microsoft<br /><br />I could discuss each one of these reasons in more detail, but that would be an article in and of itself.<br /><br /><br /><strong>Firefox</strong><br /><br />The famous and multi-awarded Firefox [13] browser is now approaching the 1.5 release, and it's constantly improving both in security and features. Firefox quickly became Mozilla's leading product, ahead of the Mozilla Suite (which includes a browser, HTML editor, email client and address book), which is now being rebranded as <em>SeaMonkey</em> [10].<br /><br />On the other hand, Firefox is simply a web browser, and doesn't offer an email client or html editor anymore, which was obviously a choice made to improve the performance of the application and engine, which was normally quite bulky, especially on old hardware. This was a wise decision, and Mozilla/Netscape enthusiasts quite liked the idea of having a lightweight browser rather than a slow-performing suite of applications. However, someone who uses both Firefox and ThunderBird (Mozilla's standalone email client) will end up using nearly twice the amount of memory used by SeaMonkey alone: this is because you now have two separate applications, so you have to load the rendering engine <em>twice</em>.<br /><br />With Firefox, the Mozilla Foundation aimed to create a browser which would satisfy web developers by supporting the latest web standards and technologies, while at the same time offering new and interesting functionalities to end users.<br /><br />The Fox is not ideal for all types of users, but a constantly growing community of enthusiasts [14] is trying literally every way possible to promote it by targeting virtually all kind of audiences. <br /><br />In addition, its design makes it mostly secure; even if a few bugs slip by, they are not design flaws, merely implementation issues. When a bug is found, the Firefox development community works quickly to fix it, and usually has an excellent track record regarding that. However, the most important aspect of Firefox's security (on Windows, that is), is that it is not integrated into the system like IE is. Remote attacks on a Windows PC are mostly executed through IE, and the insecure design causes it to have unfixed critical bugs after five years of non-development, because Microsoft tends to shove bugs under the carpet whenever possible; half year, one year or even older unfixed bugs are not unheard of.<br /><br />To make it more readily apparent, statistics [12] [15] say that the maximum time IE is <em>not</em> in danger from to an unpatched vulnerability is 7 days, while for Firefox, it is well over 200.<br /><br />Another of Firefox's strong points is the ability to add various <em>extensions</em> and <em>themes</em> for all kind of necessities: improving web searches, getting localized weather forecasts, playing music, blocking adverts, tweaking webpages, composing webpages, etc.<br />Firefox is <em>extremely</em> customizable, and extensions don't affect the overall browser performance, as the actual overhead is minimal - this has been tested on a Pentium 2, so you can believe me.<br /><br />This is all very well and good, but the ability to customize a browser is not considered a good thing by all. This is because it tends to become a necessity - if Firefox didn't have extensions, it would still be better than IE for security and some features, but not amazingly so. Opera users found that Firefox without extensions could not match up to the features in Opera.<br /><br />After asking some IE users, it seems that Firefox can appear too <em>geeky</em> for the average user who only wants to surf the Net and doesn't really care about web standards and browser customization. After all, a lot of people may decide that they don't want to spend their time tweaking and personalizing a program to make it fit their needs, as they find it annoying.<br /><br />Finally, a slightly unpleasant thing about extensions is that almost every time a major update to the browser comes out, some of the installed extensions become unusable until their developers update them. In order to solve this problem, Mozilla Development Team is releasing public alphas and betas of every major milestone, to allow third party extension developers update their extensions in time for the stable release. As a consequence, to avoid trouble with extensions, I suggest non-developers stick with the stable releases and avoid updating to alpha or beta versions.<br /><br />Anyhow, all those people who don't like having to play around with extensions should just use Opera.<br /><br /><br /><strong>Opera</strong><br /><br />A few years ago I came across Opera's site [16], and I downloaded their <em>free</em> browser to try it out. At the time, Firefox wasn't a big thing, and the Mozilla/Netscape suites were too bulky for my liking, so I was looking for something lightweight and fast. That's the reason why the Opera team has always used the slogan <em>'the fastest browser on Earth'</em> to describe their product, and they seem to be right[5]. <br /><br />I actually didn't like it at first, because - at the time - it didn't offer anything better than IE <em>and</em> the company was more or less silently asking people to <em>pay</em> them to get rid of the annoying ads the browser displayed on the interface. Browsers are nothing but software, however, and I think the reason why they are (nearly) all free is because IE comes free with every Windows installation. <br /><br />Finally, Opera agreed with that same philosophy: while celebrating their 10 years of existence, Opera Software ASA decided initially to give away license codes to get rid of the ads, and then to finally stop annoying their users with ad banners and cut their licensing fee altogether [17]. Obviously, at that point, I was really tempted to give Opera another chance.<br /><br />I was impressed, indeed. Opera is actually a nice piece of software. It's really fast in rendering pages, it displays them correctly, respects web standards (they improved this quite a bit over the years), and it's fast even when pressing the Back and Forward buttons. Its interface is probably the best and cleanest ever made; it's easy to use even for novices even if some things (like keyboard shortcuts) are different.<br /><br />Speaking of features, it offers: <br /><br />- Tabbed browsing and integrated search like Firefox (and IE7)<br />- A truly remarkable technology able to make <em>any webpage</em> fit a window by zooming images in and out automatically<br />- A complete and fully working mail client<br />- An address book<br />- The ability to save browsing sessions<br />- Easily re-open closed tabs<br />- Skins<br />- A <em>magic wand</em> to fill in forms and logins automatically<br />- A built-in scratchpad/notepad<br />- Voice integration (yes, you can even speak to your browser now, imagine that!)<br />- SVG support - not that it really matters for now, but it's a cool thing to say nowadays<br /><br />All of this is included in an application which is - to my eyes - more lightweight than Firefox. But it's not perfect yet. Why? The reason is simple. It allows a certain degree of customization, but doesn't have 'extensions'. One thing is true though, as someone pointed out [18]: in most cases, for 'average use', Opera doesn't need extensions, because it already offers quite a lot of functionality that doesn't need to be extended. <br /><br />It also happens that the features listed above are the most commonly requested by the majority of users, and that was, in my opinion, a clever marketing move. <br /><br />There are still two things about Opera that put me off from using it, however. One is the lack of a built in <em>"I'm feeling lucky"</em> feature in the taskbar - even though there is a workaround [19]. The other is more serious, and it concerns compatibility. Even though the people at Opera Software are struggling more than ever to make it compatible with every site and technology - full Gmail support has recently been added - Opera cannot render some sites correctly. The most blatant example is Writely.com [20], which is a site offering a free ajax-based online word processor. It seems that Opera doesn't like Ajax too much for now.<br /><br /><br /><strong>K-meleon</strong><br /><br />Now let's talk about a piece of software which appears to have been forgotten by the majority of people in the world: K-meleon [21], a Windows-only, Mozilla-based browser. It is a prime example of how good software can be ignored by the masses, for three main reasons:<br /><br />- It wasn't conceived with the <em>average user</em> in mind<br />- There's another browser using the same technology which is considered to be better<br />- It apparently doesn't offer anything new or stimulating<br /><br />I would define it as a browser for true geeks. To unlock its secrets you need to play around with configuration files, hundreds of hidden settings, macros, and menus. However, it can be very gratifying for people who enjoy this sort of thing. There's just one little problem with it: people who enjoy tweaking an application as much as K-meleon needs to be tweaked normally prefer a more customizable operating system altogether, but the browser is strictly <em>Windows only</em>.<br /><br />I like it even if I don't have the time to play around with it as much as I would like to, and I think it is useful for some specific tasks. In particular, I found myself using it to upload pictures when updating one of my sites, and similarly repetitive jobs where all you need is a browser able to render a page quickly without using too much memory or CPU cycles. <br />K-meleon is built for Windows, and is therefore optimized for it, perhaps even more so than Firefox, and it's arguably nearly as fast as Opera. As far as I'm concerned, it's more lightweight than Opera and this makes it ideal as a <em>secondary browser</em> to run together with Firefox or Opera. Why would you want to do that? Well, suppose you have to check two different GMail accounts and reply to emails here and there: using a secondary browser to keep you logged in to another Google account is better than having to login and logout repeatedly.<br /><br />Something amusing (or maybe not) about K-meleon: it seems to have no security advisories [22] on Secunia as only one was submitted and quickly patched in 2004, and that was all. The impression is that the browser is just not very popular.<br /><br /><br /><strong>Netscape</strong><br /><br />Netscape [23] is perhaps one of the oldest browsers that is still alive. It used to be a full-on web suite (basically a rebrand of the Mozilla Suite), and thus featured a web browser (Netscape Navigator), a WYSIWYG HTML editor, a mail client, and an address book. It was never lightweight (due to all the applications bundled together), but it was a true all-in-one Internet suite, at the time.<br /><br />Nowadays people prefer having a separate email client or check their email online. They rarely need an address book, since email addresses and contact details are normally stored automatically by the mail client/web application. The average user probably won't use the HTML editor, and the web developer will choose a more professional/optimal solution than Netscape/Mozilla Composer.<br /><br />Furthermore, Mozilla <em>suddenly</em> started changing its roadmap, heavily marketing a standalone browser rather than an application suite, so people at Netscape thought it was the right time to do the same. Netscape now offers only a browser. It is based on Firefox, but has a lot of additional features. <br /><br />When the Netscape browser was launched in May 2005, it was supposed to represent a <em>new standard</em> for online security, but various vulnerabilities[24] were found just after release, which caused it to gain the totally opposite reputation. Everything was fixed quickly enough, but people weren't impressed by that (myself included). Furthermore, another incident occurred a few days later. Microsoft advised its customers to uninstall Netscape 8 from their system [25], because after installing it on Windows, Internet Explorer inexplicably became unable to render XML pages, displaying a blank page instead!<br /><br />Apart from these odd events - which indeed half ruined Netscape's reputation - the application itself isn't that bad; it's based on Firefox, after all.<br /><br />Differences from Mozilla's browser are obvious immediately after installation: Netscape opted for a sort of online install, in the sense that the installer, which is downloadable from the official site, starts the download of the actual components and then installs them. In the meantime, slides specially tailored for end users appear on the screen, introducing the main browser features. These slides provide entertaining and informative viewing for the user. <br /><br />The browser is shipped with two default themes, and the interface itself is rearranged: search bar on the left, four weird buttons on the right, and a magic <em>multibar</em> underneath. The multibar addresses a common issue with Firefox and IE - if you keep installing extensions and toolbars, the window used to display the page eventually becomes smaller. This new feature allows users to choose up to 10 different bars which can be selected in rotation with a single click.<br /><br />The real innovation, however, is the Security Center. It seems that these two magic words are now heavily used everywhere, as if they have some mystical power to reassure users and make them feel protected. In reality, the security center only tells you whether or not you can trust a site, based on Netscape's list of trusted sites or your preferences, and it automatically adjusts the browser security settings accordingly.<br /><br /><em>But isn't Netscape a Firefox based browser?</em><br /><br />Yes and no. Netscape can render using either Mozilla's engine or Internet Explorer's! Good or bad? Well, probably good in some cases, but rather annoying sometimes as it's <em>too smart</em>: I tried visiting Microsoft.com and without doing anything the rendering engine switched to IE automatically! It basically tries to guess which browser is better to render certain pages, and this can be problematic, especially if it renders as IE any page which uses ActiveX technology. This short term gain - <em>total</em> compatibility - is achieved by surrendering to IE flaws and maybe even giving no incentive for developers to abandon an IE-oriented web development: <em>'If Netscape can use an IE engine, why should I code using web standards?'</em> <br /><br />Fortunately, despite the effort made by the developers and marketing experts at Netscape Corp., the new browser is not convincing enough. It is also clearly heavier on resources than Firefox; while I was just surfing it started claiming more than 70MB of RAM, while Firefox normally uses half the amount. Personally, I think it's an interesting attempt to create a <em>perfect</em> browser, and it enriches Firefox with some new features which either are normally not available or require extensions, but it's not for me.<br /><br /><br /><strong>Summing up</strong><br /><br />As I said at the beginning (ruining all the suspense), there's no perfect browser; there's nothing universally accepted by everyone because everyone does different things. Personally, I'd advise using Firefox for general use, because it offers excellent compatibility, security and features. <br /><br />On the other hand, if you don't like extensions and you just need something to browse the Internet quickly, without the hassle of having to download additional components, go for Opera, although there are still some compatibility issues with it that need to be fixed. <br /><br />For Windows-based geeks, I'd recommend K-meleon: it's fast, simple, effective, and gives you plenty of things to play with to tweak almost every part of the browser. The project is not dead; a community of people are using it and providing patches, even if the leading developer is not able to do so.<br /><br />Netscape still needs some work, but it could be useful for quickly viewing a site on Firefox and IE, for example. It's also a little more user-friendly than Firefox. Those who are already accustomed to Firefox, however, are more likely to stick with it.<br /><br />Again, depending on what you do, what your needs are, and even your mood, one browser can be better than others. Personally, I use a variety of browsers: Firefox mostly, but K-meleon and Opera as well, and I like this combination as my <em>perfect browser</em>. What about you? <br /><br /><br /><strong>Credits</strong><br />Thanks to comet for providing appropriate thoughts and opinions regarding the browsers' security. <br /><br /><strong>Notes and Resources</strong><br /><small><br />[1] Clarification about the 'Gecko' engine: <a href="http://www.mozilla.org/newlayout/gecko.html">http://www.mozilla.org/newlayout/gecko.html</a><br />[2] 'One Week with Firefox, its Extensions and Opera', OsNews.com, by Mart'n Marconcini <a href="http://www.osnews.com/story.php?news_id=7562">http://www.osnews.com/story.php?news_id=7562</a><br />[3] 'Firefox 1.5 vs Opera 8.5', SonSpring Journal, 09/22/2005 - <a href="http://sonspring.com/journal/firefox-15-vs-opera-85">http://sonspring.com/journal/firefox-15-vs-opera-85</a><br />[4] Evolt.com, Browser list - <a href="http://browsers.evolt.org/">http://browsers.evolt.org/</a><br />[5] HowToCreate.com - Browser Speed Analysis -<a href="http://www.howtocreate.co.uk/browserSpeed.html#winspeed">http://www.howtocreate.co.uk/browserSpeed.html#winspeed</a><br />[6] 'Comparison of web browsers', Wikipedia page - <a href="http://en.wikipedia.org/wiki/Comparison_of_web_browsers">http://en.wikipedia.org/wiki/Comparison_of_web_browsers</a><br />[7] Slim Browser, Home Page - <a href="http://www.flashpeak.com/sbrowser/">http://www.flashpeak.com/sbrowser/</a><br />[8] Maxthon, Home Page - <a href="http://www.maxthon.com/">http://www.maxthon.com/</a><br />[9] AvantBrowser, Home Page - <a href="http://www.avantbrowser.com/">http://www.avantbrowser.com/</a><br />[10] SeaMonkey Project, Hope Page - <a href="http://www.mozilla.org/projects/seamonkey/">http://www.mozilla.org/projects/seamonkey/</a><br />[11] StopIE.com - <a href="http://www.stopie.com/">http://www.stopie.com/</a>, BrowseHappy.com - <a href="http://browsehappy.com/">http://browsehappy.com/</a><br />[12] Secunia vulnerabilities, Internet Explorer - <a href="http://secunia.com/product/11/">http://secunia.com/product/11/</a><br />[13] Firefox Home Page - <a href="http://www.mozilla.org/products/firefox/">http://www.mozilla.org/products/firefox/</a><br />[14] Spread Firefox website - <a href="http://www.spreadfirefox.com/">http://www.spreadfirefox.com/</a><br />[15] Secunia vulnerabilities, Mozilla Firefox - <a href="http://secunia.com/product/4227/">http://secunia.com/product/4227/</a><br />[16] Opera Browser, Official Website - <a href="http://www.opera.com/">http://www.opera.com/</a><br />[17] Opera becomes free, webpage - <a href="http://www.opera.com/free">http://www.opera.com/free</a><br />[18] Opera and Firefox extensions - <a href="http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions">http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions</a><br />[19] How to add 'I'm feeling lucky' to Opera - <a href="http://my.opera.com/community/forums/topic.dml?id=63620">http://my.opera.com/community/forums/topic.dml?id=63620</a><br />[20] Writely.com, free online word processor - <a href="http://www.writely.com/">http://www.writely.com/</a><br />[21] K-meleon Project, Sourceforge - <a href="http://kmeleon.sourceforge.net/">http://kmeleon.sourceforge.net/</a><br />[22] Secunia vulnerabilities, K-meleon - <a href="http://secunia.com/product/3684/">http://secunia.com/product/3684/</a><br />[23] Netscape Browser, Home Page - <a href="http://browser.netscape.com/ns8/">http://browser.netscape.com/ns8/</a><br />[24] 'Netscape fixes holes in 'security' browser', Zdnet - <a href="http://www.zdnet.com.au/news/security/0,2000061744,39192767,00.htm">http://www.zdnet.com.au/news/security/0,2000061744,39192767,00.htm</a><br />[25] Netscape 8 'breaks' IE, Zdnet - <a href="http://news.zdnet.co.uk/software/applications/0,39020384,39200178,00.htm">http://news.zdnet.co.uk/software/applications/0,39020384,39200178,00.htm</a><br /></small><br /> + + +<p>So you finally decided to say goodbye to Internet Explorer, but now you feel lost in a multitude of browsers that all + claim to be faster, more customizable, safer, or simply better than IE. Are they telling the truth? If so, which one + is the perfect browser?</p> +<h3>Point of view, clarifications and scope of this article</h3> +<p>So you're reading this article hoping to find out which is the <em>best</em> browser ever made? Well, you're wasting + your time. There's no such thing as <em>The Perfect Browser</em>, despite the various attempts made by Mozilla + Foundation, Opera, Microsoft and others. After trying out nearly all of the major browsers currently available, I + came to this conclusion: the perfect browser is a relative term, dependent on the particular person you ask, if it + exists at all. Contrary to popular belief, I myself am not a 100% Firefox freak, and I do not consider myself biased + to the point of going around shouting that Firefox is the <em>"best browser ever made."</em> Granted, I do do that + sometimes, but let's put my personal bias into some sort of perspective:</p> +<p>Mozilla Firefox represents the most remarkable effort to create a <em>perfect browser</em>, but in some cases, and + for some particular tasks, it may not be considered optimal by <em>some people</em>.</p> +<p>Having said this, I hope I can convince you that I'm not <em>that</em> biased toward Mozilla's leading product, even + if, as a matter of fact, nearly all the programs mentioned in this article are based on the Mozilla ('Gecko'? No, + not quite... [1]) engine or a derivative.</p> +<p>Originally, I was going to write a comparative review of Opera and Firefox, but in the end, I chose to broaden the + scope a bit to include other products as well. There are already many articles and blog posts which have compared + the two, either favoring Opera [2] or Firefox [3]. I also decided not to review browsers for platforms other than + Windows, so there won't be any mention of Konqueror, Galeon, Safari, Camino, etc., which, although they are all + interesting alternatives, go beyond the purpose of this article, which is to offer <em>Windows users</em> a small + selection of alternative browsers.</p> +<h3>Alternative Browsers</h3> +<p>There are literally dozens of <em>alternative</em> browsers around. There are lists available online, and perhaps the + most famous one is on Evolt.org [4], which can be considered comprehensive and accurate. Various statistics are + available for objective comparisons of all the major browsers, for regarding for example speed [5] and overall + performance and functionality [6], but even if such analyses are accurate, they are often not enough to fully + evaluate a browser.</p> +<p>In the following sections, we'll examine the following four free browsers, which are considered to be the most + obvious alternatives to Internet Explorer.</p> +<ul> + <li>Firefox</li> + <li>Opera</li> + <li>K-meleon</li> + <li>Netscape</li> +</ul> +<p>I deliberately chose not to spend time on Slim Browser [7], Maxthon [8] (previously known as MyIE), or AvantBrowser + [9], which are basically extensions built on top of Internet Explorer to add functionality to it. I also left out + Mozilla's SeaMonkey [10], partly because of its alpha status, and partly because it is being marketed as an Internet + Suite rather than just a web browser.</p> +<h3>Why IE is 'bad'</h3> +<p>'IE is crap', 'you MUST NOT use Internet Explorer', 'Internet Explorer is for n00bs'... how many times have you heard + or read this? Some people tend to degrade Internet Explorer all the time, and the funny thing is, if one were to ask + 'Why so?', approximately 40% would be unable to give a reply any more concrete than 'because Firefox is simply + better' or 'because Opera owns!' or '[insert browser name here] simply can't be compared to IE!'</p> +<p>Now, all this may be true to a certain extent, but it certainly will not convince a person to switch browsers, and + may even have the opposite effect: people will keep using IE no matter what! This is bad for the alternative browser + market in general. It still looks like IE is used by 90% of people on the Internet and this will not change simply + by telling all those people that they are "dumb" for using IE. There are sites whose only purpose is to make people + abandon IE [11], but they discuss objective fact instead of opinionated propaganda.</p> +<p>Personally, I decided not to use IE anymore because:</p> +<ul> + <li>It's slow on my computer (which is old, as some of you may know)</li> + <li>It's less secure than other browsers, and more vulnerable to malicious software and attacks, simply because it's + used by the most people - that makes the BEST option for those who actually enjoy exploiting vulnerabilities, + because it's not frequently patched [12].</li> + <li>It's not very customizable</li> + <li>It doesn't have (or support) additional features</li> + <li>It deliberately breaks web standards or creates its own, which makes things difficult for web developers</li> + <li>It's normally behind the supported technologies</li> + <li>I hate the idea of using a proprietary browser imposed by Microsoft</li> +</ul> +<p>I could discuss each one of these reasons in more detail, but that would be an article in and of itself.</p> + + + + +<h3>Firefox</h3> +<p>The famous and multi-awarded Firefox [13] browser is now approaching the 1.5 release, and it's constantly improving + both in security and features. Firefox quickly became Mozilla's leading product, ahead of the Mozilla Suite (which + includes a browser, HTML editor, email client and address book), which is now being rebranded as <em>SeaMonkey</em> + [10].</p> + +<p>On the other hand, Firefox is simply a web browser, and doesn't offer an email client or html editor anymore, which + was obviously a choice made to improve the performance of the application and engine, which was normally quite + bulky, especially on old hardware. This was a wise decision, and Mozilla/Netscape enthusiasts quite liked the idea + of having a lightweight browser rather than a slow-performing suite of applications. However, someone who uses both + Firefox and ThunderBird (Mozilla's standalone email client) will end up using nearly twice the amount of memory used + by SeaMonkey alone: this is because you now have two separate applications, so you have to load the rendering engine + <em>twice</em>. +</p> + +<p>With Firefox, the Mozilla Foundation aimed to create a browser which would satisfy web developers by supporting the + latest web standards and technologies, while at the same time offering new and interesting functionalities to end + users.</p> + +<p>The Fox is not ideal for all types of users, but a constantly growing community of enthusiasts [14] is trying + literally every way possible to promote it by targeting virtually all kind of audiences.</p> + +<p>In addition, its design makes it mostly secure; even if a few bugs slip by, they are not design flaws, merely + implementation issues. When a bug is found, the Firefox development community works quickly to fix it, and usually + has an excellent track record regarding that. However, the most important aspect of Firefox's security (on Windows, + that is), is that it is not integrated into the system like IE is. Remote attacks on a Windows PC are mostly + executed through IE, and the insecure design causes it to have unfixed critical bugs after five years of + non-development, because Microsoft tends to shove bugs under the carpet whenever possible; half year, one year or + even older unfixed bugs are not unheard of.</p> + +<p>To make it more readily apparent, statistics [12] [15] say that the maximum time IE is <em>not</em> in danger from to + an unpatched vulnerability is 7 days, while for Firefox, it is well over 200.</p> + +<p>Another of Firefox's strong points is the ability to add various <em>extensions</em> and <em>themes</em> for all kind + of necessities: improving web searches, getting localized weather forecasts, playing music, blocking adverts, + tweaking webpages, composing webpages, etc.<br />Firefox is <em>extremely</em> customizable, and extensions don't + affect the overall browser performance, as the actual overhead is minimal - this has been tested on a Pentium 2, so + you can believe me.</p> + +<p>This is all very well and good, but the ability to customize a browser is not considered a good thing by all. This is + because it tends to become a necessity - if Firefox didn't have extensions, it would still be better than IE for + security and some features, but not amazingly so. Opera users found that Firefox without extensions could not match + up to the features in Opera.</p> + +<p>After asking some IE users, it seems that Firefox can appear too <em>geeky</em> for the average user who only wants + to surf the Net and doesn't really care about web standards and browser customization. After all, a lot of people + may decide that they don't want to spend their time tweaking and personalizing a program to make it fit their needs, + as they find it annoying.</p> + +<p>Finally, a slightly unpleasant thing about extensions is that almost every time a major update to the browser comes + out, some of the installed extensions become unusable until their developers update them. In order to solve this + problem, Mozilla Development Team is releasing public alphas and betas of every major milestone, to allow third + party extension developers update their extensions in time for the stable release. As a consequence, to avoid + trouble with extensions, I suggest non-developers stick with the stable releases and avoid updating to alpha or beta + versions.</p> + +<p>Anyhow, all those people who don't like having to play around with extensions should just use + Opera.</p> + + + +<h3>Opera</h3> +<p>A few years ago I came across Opera's site [16], and I downloaded their <em>free</em> browser to try it out. At the + time, Firefox wasn't a big thing, and the Mozilla/Netscape suites were too bulky for my liking, so I was looking for + something lightweight and fast. That's the reason why the Opera team has always used the slogan <em>'the fastest + browser on Earth'</em> to describe their product, and they seem to be right[5].</p> + +<p>I actually didn't like it at first, because - at the time - it didn't offer anything better than IE <em>and</em> the + company was more or less silently asking people to <em>pay</em> them to get rid of the annoying ads the browser + displayed on the interface. Browsers are nothing but software, however, and I think the reason why they are (nearly) + all free is because IE comes free with every Windows installation.</p> + +<p>Finally, Opera agreed with that same philosophy: while celebrating their 10 years of existence, Opera Software ASA + decided initially to give away license codes to get rid of the ads, and then to finally stop annoying their users + with ad banners and cut their licensing fee altogether [17]. Obviously, at that point, I was really tempted to give + Opera another chance.</p> + +<p>I was impressed, indeed. Opera is actually a nice piece of software. It's really fast in rendering pages, it displays + them correctly, respects web standards (they improved this quite a bit over the years), and it's fast even when + pressing the Back and Forward buttons. Its interface is probably the best and cleanest ever made; it's easy to use + even for novices even if some things (like keyboard shortcuts) are different.</p> + +<p>Speaking of features, it offers:</p> +<ul> + <li>Tabbed browsing and integrated search like Firefox (and IE7)</li> + <li>A truly remarkable technology able to make <em>any webpage</em> fit a window by zooming images in and out + automatically</li> + <li>A complete and fully working mail client</li> + <li>An address book</li> + <li>The ability to save browsing sessions</li> + <li>Easily re-open closed tabs</li> + <li>Skins</li> + <li>A <em>magic wand</em> to fill in forms and logins automatically</li> + <li>A built-in scratchpad/notepad</li> + <li>Voice integration (yes, you can even speak to your browser now, imagine that!)</li> + <li>SVG support - not that it really matters for now, but it's a cool thing to say nowadays</li> +</ul> + +<p>All of this is included in an application which is - to my eyes - more lightweight than Firefox. But it's not perfect + yet. Why? The reason is simple. It allows a certain degree of customization, but doesn't have 'extensions'. One + thing is true though, as someone pointed out [18]: in most cases, for 'average use', Opera doesn't need extensions, + because it already offers quite a lot of functionality that doesn't need to be extended.</p> + +<p>It also happens that the features listed above are the most commonly requested by the majority of users, and that + was, in my opinion, a clever marketing move.</p> + +<p>There are still two things about Opera that put me off from using it, however. One is the lack of a built in <em>"I'm + feeling lucky"</em> feature in the taskbar - even though there is a workaround [19]. The other is more serious, + and it concerns compatibility. Even though the people at Opera Software are struggling more than ever to make it + compatible with every site and technology - full Gmail support has recently been added - Opera cannot render some + sites correctly. The most blatant example is Writely.com [20], which is a site offering a free ajax-based online + word processor. It seems that Opera doesn't like Ajax too much for now.</p> + + + +<h3>K-meleon</h3> +<p>Now let's talk about a piece of software + which appears to have been forgotten by the majority of people in the world: K-meleon [21], a Windows-only, + Mozilla-based browser. It is a prime example of how good software can be ignored by the masses, for three main + reasons:</p> +<li> It wasn't conceived with the <em>average user</em> in mind</li> +<li>There's another browser using + the same technology which is considered to be better</li> +<li>It apparently doesn't offer anything new or + stimulating</li> +<p>I would define it as a browser for true geeks. To unlock its secrets you need to play around with + configuration files, hundreds of hidden settings, macros, and menus. However, it can be very gratifying for people + who + enjoy this sort of thing. There's just one little problem with it: people who enjoy tweaking an application as much + as + K-meleon needs to be tweaked normally prefer a more customizable operating system altogether, but the browser is + strictly <em>Windows only</em>.</p> +<p>I like it even if I don't have the time to play around with it as much as I + would like to, and I think it is useful for some specific tasks. In particular, I found myself using it to upload + pictures when updating one of my sites, and similarly repetitive jobs where all you need is a browser able to render + a + page quickly without using too much memory or CPU cycles. </p> +<p>K-meleon is built for Windows, and is therefore + optimized for it, perhaps even more so than Firefox, and it's arguably nearly as fast as Opera. As far as I'm + concerned, + it's more lightweight than Opera and this makes it ideal as a <em>secondary browser</em> to run together with + Firefox or + Opera. Why would you want to do that? Well, suppose you have to check two different GMail accounts and reply to + emails + here and there: using a secondary browser to keep you logged in to another Google account is better than having to + login + and logout repeatedly.</p> +<p>Something amusing (or maybe not) about K-meleon: it seems to have no security + advisories [22] on Secunia as only one was submitted and quickly patched in 2004, and that was all. The impression + is + that the browser is just not very popular.</p> + + + +<h3>Netscape</h3> +<p>Netscape [23] is perhaps one of the oldest browsers that is still alive. It used to be a full-on web suite (basically + a rebrand of the Mozilla Suite), and thus featured a web browser (Netscape Navigator), a WYSIWYG HTML editor, a mail + client, and an address book. It was never lightweight (due to all the applications bundled together), but it was a + true all-in-one Internet suite, at the time.</p> +<p>Nowadays people prefer having a separate email client or check their email online. They rarely need an address book, + since email addresses and contact details are normally stored automatically by the mail client/web application. The + average user probably won't use the HTML editor, and the web developer will choose a more professional/optimal + solution than Netscape/Mozilla Composer.</p> +<p>Furthermore, Mozilla <em>suddenly</em> started changing its roadmap, heavily marketing a standalone browser rather + than an application suite, so people at Netscape thought it was the right time to do the same. Netscape now offers + only a browser. It is based on Firefox, but has a lot of additional features.</p> +<p>When the Netscape browser was launched in May 2005, it was supposed to represent a <em>new standard</em> for online + security, but various vulnerabilities[24] were found just after release, which caused it to gain the totally + opposite reputation. Everything was fixed quickly enough, but people weren't impressed by that (myself included). + Furthermore, another incident occurred a few days later. Microsoft advised its customers to uninstall Netscape 8 + from their system [25], because after installing it on Windows, Internet Explorer inexplicably became unable to + render XML pages, displaying a blank page instead!</p> +<p>Apart from these odd events - which indeed half ruined Netscape's reputation - the application itself isn't that bad; + it's based on Firefox, after all.</p> +<p>Differences from Mozilla's browser are obvious immediately after installation: Netscape opted for a sort of online + install, in the sense that the installer, which is downloadable from the official site, starts the download of the + actual components and then installs them. In the meantime, slides specially tailored for end users appear on the + screen, introducing the main browser features. These slides provide entertaining and informative viewing for the + user.</p> +<p>The browser is shipped with two default themes, and the interface itself is rearranged: search bar on the left, four + weird buttons on the right, and a magic <em>multibar</em> underneath. The multibar addresses a common issue with + Firefox and IE - if you keep installing extensions and toolbars, the window used to display the page eventually + becomes smaller. This new feature allows users to choose up to 10 different bars which can be selected in rotation + with a single click.</p> +<p>The real innovation, however, is the Security Center. It seems that these two magic words are now heavily used + everywhere, as if they have some mystical power to reassure users and make them feel protected. In reality, the + security center only tells you whether or not you can trust a site, based on Netscape's list of trusted sites or + your preferences, and it automatically adjusts the browser security settings accordingly.</p> +<p><em>But isn't Netscape a Firefox based browser?</em></p> +<p>Yes and no. Netscape can render using either Mozilla's engine or Internet Explorer's! Good or bad? Well, probably + good in some cases, but rather annoying sometimes as it's <em>too smart</em>: I tried visiting Microsoft.com and + without doing anything the rendering engine switched to IE automatically! It basically tries to guess which browser + is better to render certain pages, and this can be problematic, especially if it renders as IE any page which uses + ActiveX technology. This short term gain - <em>total</em> compatibility - is achieved by surrendering to IE flaws + and maybe even giving no incentive for developers to abandon an IE-oriented web development: <em>'If Netscape can + use an IE engine, why should I code using web standards?'</em></p> +<p>Fortunately, despite the effort made by the developers and marketing experts at Netscape Corp., the new browser is + not convincing enough. It is also clearly heavier on resources than Firefox; while I was just surfing it started + claiming more than 70MB of RAM, while Firefox normally uses half the amount. Personally, I think it's an interesting + attempt to create a <em>perfect</em> browser, and it enriches Firefox with some new features which either are + normally not available or require extensions, but it's not for me.</p> + + + +<strong>Summing + up</strong><br /><br />As I said at the beginning (ruining all the suspense), there's no perfect browser; there's +nothing universally accepted by everyone because everyone does different things. Personally, I'd advise using Firefox +for general use, because it offers excellent compatibility, security and features. <br /><br />On the other hand, if you +don't like extensions and you just need something to browse the Internet quickly, without the hassle of having to +download additional components, go for Opera, although there are still some compatibility issues with it that need to be +fixed. <br /><br />For Windows-based geeks, I'd recommend K-meleon: it's fast, simple, effective, and gives you plenty +of things to play with to tweak almost every part of the browser. The project is not dead; a community of people are +using it and providing patches, even if the leading developer is not able to do so.<br /><br />Netscape still needs some +work, but it could be useful for quickly viewing a site on Firefox and IE, for example. It's also a little more +user-friendly than Firefox. Those who are already accustomed to Firefox, however, are more likely to stick with +it.<br /><br />Again, depending on what you do, what your needs are, and even your mood, one browser can be better than +others. Personally, I use a variety of browsers: Firefox mostly, but K-meleon and Opera as well, and I like this +combination as my <em>perfect browser</em>. What about you? <br /><br /><br /> + +<strong>Credits</strong><br />Thanks to +comet for providing appropriate thoughts and opinions regarding the browsers' security. <br /><br /><strong>Notes and + Resources</strong><br /><small><br />[1] Clarification about the 'Gecko' engine: <a + href="http://www.mozilla.org/newlayout/gecko.html">http://www.mozilla.org/newlayout/gecko.html</a><br />[2] 'One + Week with Firefox, its Extensions and Opera', OsNews.com, by Mart'n Marconcini <a + href="http://www.osnews.com/story.php?news_id=7562">http://www.osnews.com/story.php?news_id=7562</a><br />[3] + 'Firefox 1.5 vs Opera 8.5', SonSpring Journal, 09/22/2005 - <a + href="http://sonspring.com/journal/firefox-15-vs-opera-85">http://sonspring.com/journal/firefox-15-vs-opera-85</a><br />[4] + Evolt.com, Browser list - <a href="http://browsers.evolt.org/">http://browsers.evolt.org/</a><br />[5] + HowToCreate.com - Browser Speed Analysis -<a + href="http://www.howtocreate.co.uk/browserSpeed.html#winspeed">http://www.howtocreate.co.uk/browserSpeed.html#winspeed</a><br />[6] + 'Comparison of web browsers', Wikipedia page - <a + href="http://en.wikipedia.org/wiki/Comparison_of_web_browsers">http://en.wikipedia.org/wiki/Comparison_of_web_browsers</a><br />[7] + Slim Browser, Home Page - <a + href="http://www.flashpeak.com/sbrowser/">http://www.flashpeak.com/sbrowser/</a><br />[8] Maxthon, Home Page - + <a href="http://www.maxthon.com/">http://www.maxthon.com/</a><br />[9] AvantBrowser, Home Page - <a + href="http://www.avantbrowser.com/">http://www.avantbrowser.com/</a><br />[10] SeaMonkey Project, Hope Page - <a + href="http://www.mozilla.org/projects/seamonkey/">http://www.mozilla.org/projects/seamonkey/</a><br />[11] + StopIE.com - <a href="http://www.stopie.com/">http://www.stopie.com/</a>, BrowseHappy.com - <a + href="http://browsehappy.com/">http://browsehappy.com/</a><br />[12] Secunia vulnerabilities, Internet Explorer + - <a href="http://secunia.com/product/11/">http://secunia.com/product/11/</a><br />[13] Firefox Home Page - <a + href="http://www.mozilla.org/products/firefox/">http://www.mozilla.org/products/firefox/</a><br />[14] Spread + Firefox website - <a href="http://www.spreadfirefox.com/">http://www.spreadfirefox.com/</a><br />[15] Secunia + vulnerabilities, Mozilla Firefox - <a + href="http://secunia.com/product/4227/">http://secunia.com/product/4227/</a><br />[16] Opera Browser, Official + Website - <a href="http://www.opera.com/">http://www.opera.com/</a><br />[17] Opera becomes free, webpage - <a + href="http://www.opera.com/free">http://www.opera.com/free</a><br />[18] Opera and Firefox extensions - <a + href="http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions">http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions</a><br />[19] + How to add 'I'm feeling lucky' to Opera - <a + href="http://my.opera.com/community/forums/topic.dml?id=63620">http://my.opera.com/community/forums/topic.dml?id=63620</a><br />[20] + Writely.com, free online word processor - <a href="http://www.writely.com/">http://www.writely.com/</a><br />[21] + K-meleon Project, Sourceforge - <a + href="http://kmeleon.sourceforge.net/">http://kmeleon.sourceforge.net/</a><br />[22] Secunia vulnerabilities, + K-meleon - <a href="http://secunia.com/product/3684/">http://secunia.com/product/3684/</a><br />[23] Netscape + Browser, Home Page - <a href="http://browser.netscape.com/ns8/">http://browser.netscape.com/ns8/</a><br />[24] + 'Netscape fixes holes in 'security' browser', Zdnet - <a + href="http://www.zdnet.com.au/news/security/0,2000061744,39192767,00.htm">http://www.zdnet.com.au/news/security/0,2000061744,39192767,00.htm</a><br />[25] + Netscape 8 'breaks' IE, Zdnet - <a + href="http://news.zdnet.co.uk/software/applications/0,39020384,39200178,00.htm">http://news.zdnet.co.uk/software/applications/0,39020384,39200178,00.htm</a><br /></small><br /> + +<h3>Summing up</h3> +<p>As I said at the beginning (ruining all the suspense), there's no perfect browser; there's nothing universally + accepted by everyone because everyone does different things. Personally, I'd advise using Firefox for general use, + because it offers excellent compatibility, security and features.</p> +<p>On the other hand, if you don't like extensions and you just need something to browse the Internet quickly, without + the hassle of having to download additional components, go for Opera, although there are still some compatibility + issues with it that need to be fixed.</p> +<p>For Windows-based geeks, I'd recommend K-meleon: it's fast, simple, effective, and gives you plenty of things to play + with to tweak almost every part of the browser. The project is not dead; a community of people are using it and + providing patches, even if the leading developer is not able to do so.</p> +<p>Netscape still needs some work, but it could be useful for quickly viewing a site on Firefox and IE, for example. + It's also a little more user-friendly than Firefox. Those who are already accustomed to Firefox, however, are more + likely to stick with it.</p> +<p>Again, depending on what you do, what your needs are, and even your mood, one browser can be better than others. + Personally, I use a variety of browsers: Firefox mostly, but K-meleon and Opera as well, and I like this combination + as my <em>perfect browser</em>. What about you?</p> + +<h3>Credits</h3> +<p>Thanks to comet for providing appropriate thoughts and opinions regarding the browsers' security.</p> + +<h3>Notes and Resources</h3> +<small> + <li>[1] Clarification about the 'Gecko' engine: <a + href="http://www.mozilla.org/newlayout/gecko.html">http://www.mozilla.org/newlayout/gecko.html</a></li> + <li>[2] 'One Week with Firefox, its Extensions and Opera', OsNews.com, by Mart'n Marconcini <a + href="http://www.osnews.com/story.php?news_id=7562">http://www.osnews.com/story.php?news_id=7562</a></li> + <li>[3] 'Firefox 1.5 vs Opera 8.5', SonSpring Journal, 09/22/2005 - <a + href="http://sonspring.com/journal/firefox-15-vs-opera-85">http://sonspring.com/journal/firefox-15-vs-opera-85</a> + </li> + <li>[4] Evolt.com, Browser list - <a href="http://browsers.evolt.org/">http://browsers.evolt.org/</a></li> + <li>[5] HowToCreate.com - Browser Speed Analysis -<a + href="http://www.howtocreate.co.uk/browserSpeed.html#winspeed">http://www.howtocreate.co.uk/browserSpeed.html#winspeed</a> + </li> + <li>[6] 'Comparison of web browsers', Wikipedia page - <a + href="http://en.wikipedia.org/wiki/Comparison_of_web_browsers">http://en.wikipedia.org/wiki/Comparison_of_web_browsers</a> + </li> + <li>[7] Slim Browser, Home Page - <a + href="http://www.flashpeak.com/sbrowser/">http://www.flashpeak.com/sbrowser/</a></li> + <li>[8] Maxthon, Home Page - <a href="http://www.maxthon.com/">http://www.maxthon.com/</a></li> + <li>[9] AvantBrowser, Home Page - <a href="http://www.avantbrowser.com/">http://www.avantbrowser.com/</a></li> + <li>[10] SeaMonkey Project, Hope Page - <a + href="http://www.mozilla.org/projects/seamonkey/">http://www.mozilla.org/projects/seamonkey/</a></li> + <li>[11] StopIE.com - <a href="http://www.stopie.com/">http://www.stopie.com/</a>, BrowseHappy.com - <a + href="http://browsehappy.com/">http://browsehappy.com/</a></li> + <li>[12] Secunia vulnerabilities, Internet Explorer - <a + href="http://secunia.com/product/11/">http://secunia.com/product/11/</a></li> + <li>[13] Firefox Home Page - <a + href="http://www.mozilla.org/products/firefox/">http://www.mozilla.org/products/firefox/</a></li> + <li>[14] Spread Firefox website - <a href="http://www.spreadfirefox.com/">http://www.spreadfirefox.com/</a></li> + <li>[15] Secunia vulnerabilities, Mozilla Firefox - <a + href="http://secunia.com/product/4227/">http://secunia.com/product/4227/</a></li> + <li>[16] Opera Browser, Official Website - <a href="http://www.opera.com/">http://www.opera.com/</a></li> + <li>[17] Opera becomes free, webpage - <a href="http://www.opera.com/free">http://www.opera.com/free</a></li> + <li>[18] Opera and Firefox extensions - <a + href="http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions">http://virtuelvis.com/archives/2005/01/opera-and-firefox-extensions</a> + </li> + <li>[19] How to add 'I'm feeling lucky' to Opera - <a + href="http://my.opera.com/community/forums/topic.dml?id=63620">http://my.opera.com/community/forums/topic.dml?id=63620</a> + </li> + <li>[20] Writely.com, free online word processor - <a href="http://www.writely.com/">http://www.writely.com/</a> + </li> + <li>[21] K-meleon Project, Sourceforge - <a + href="http://kmeleon.sourceforge.net/">http://kmeleon.sourceforge.net/</a></li> + <li>[22] Secunia vulnerabilities, K-meleon - <a + href="http://secunia.com/product/3684/">http://secunia.com/product/3684/</a></li> + <li>[23] Netscape Browser, Home Page - <a + href="http://browser.netscape.com/ns8/">http://browser.netscape.com/ns8/</a></li> + <li>[24] 'Netscape fixes holes in 'security' browser', Zdnet - <a + href="http://www.zdnet.com.au/news/security/0,200">http://www.zdnet.com.au/news/security/0,200</a></li> +</small>
M contents/articles/quick-overview-of-sqlite.htmlcontents/articles/quick-overview-of-sqlite.html

@@ -4,4 +4,67 @@ content-type: article

timestamp: 1132937558 tags: "review|databases" ----- -A few months ago, my old hosting company started having problems with their servers. The servers would go down unexpectedly for 5-10 minutes on a relatively frequent basis, but for some weird reason... the MySQL databases were unusable for a couple of hours afterwards every time. "We had problems with MySQL, BUT the server was up, so we're still within the 99% uptime guarantee"... At the time I was thinking: "If only MySQL databases behaved like plain files..." <br /><br /><strong>What is SQLite?</strong><br /><br />When PHP5 was first released, I discovered SQLite: <em>"...a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine"</em> (as quoted from the <a href="http://www.sqlite.org">official site</a>). PHP5 offers native support to this little wonder, whose development actually started long before PHP5 was released, and can be used with many, many other programming languages.<br /> <br />SQLite organizes each database in a .db file, and implements most of the SQL 92 standards, to access the databases with no need of a server process running at the same time. Access is accomplished through standard reading/writing file operations.<br /><br />Let's examine the pros and cons of using SQLite in your web applications.<br /><br /><strong>Features</strong><br /><br />- SQLite is FREE &quot;for any purpose&quot;, <a href="http://www.sqlite.org/copyright.html">they say</a>.<br />- It doesn't rely on a server process to run<br />- You don't need to spend time configuring your installation, because there's nothing to configure!<br />- As there's no client-server negotiation, accesses to the database are much faster (2-3 times faster than a MySQL database)<br /><br />As a consequence of all this, there's actually no concept of &quot;users&quot; allowed to access the database; as I said, the actual data of each database is stored into a single file, and as such, it has permissions which regulate access. If a script has read or write access to the file, a read/write sql instruction can be executed on the database. You can therefore simply protect your databases as you would protect any other file on your server.<br /><br />- SQLite is small: the library is just 250KB, and takes care of everything, you don't need any other library or program to use it.<br />- SQLite can handle files up to 2 terabytes in size.<br />- SQLite implements most of the SQL 92 standard. This means you can usually use standard and well known queries to access it (with some exceptions, discussed in the next section).<br />- SQLite does not enforce datatype constraints. Is this a feature or a bug? Well, they call it a feature, but others may not agree. As a matter of fact, you can put a string into a field marked &quot;integer&quot; and vice versa, and furthermore, the string can be as big as you like! There's one exception to this rule, though. Columns marked as PRIMARY KEY must be of integer type. <br /><br /><br /><strong>Limitations</strong><br />Now that you have read all of the preceding material, and know that PHP5 supports SQLite natively, you might be thinking about putting MySQL in the bin and using SQLite for everything instead: it's smaller, faster, portable, simpler, and headache-free... it's love at first sight. Right?<br /><br />Well, the developers themselves decided to devote <a href="http://www.sqlite.org/whentouse.html">a page</a> to discuss when you should use SQLite and where you'd be better off sticking with your &quot;old&quot; database engine. Furthermore, being such a small and powerful piece of code, SQLite comes with some limitations which should be considered before starting to use it in a project:<br /><br />- Not all SQL queries and syntax are supported. For a full list, have a look <a href="http://www.sqlite.org/omitted.html">here</a>. The most notable things you'll miss in SQLite are: the inability (for now) to &quot;ALTER TABLE&quot; (you do this, they say, by creating a new modified table and deleting the old one), no VIEW, and no CHECK or FOREIGN KEY constraints (they are &quot;parsed but not enforced&quot;).<br /><br />- Syntax can be different sometimes. I noticed that, for example, in a JOIN between two or more tables, when accessing columns you ALWAYS have to specify &lt;table&gt;.&lt;column&gt;, whereas MySQL doesn't complain if there's ambiguity.<br /><br />- SQLite is not suitable for projects which requires a lot of semi-simultaneous writing operations. SQLite uses reader/writer locks: if there's someone reading from the database, writing to it is not allowed. This basically mean that multiple simultaneous read operations (SELECT x FROM ...) have higher priority than write operations (INSERT, UPDATE, ...), which are therefore delayed. <br /><br />- Do not use SQLite for big databases. Even though I said that (theoretically) databases up to 2 terabytes are supported, when your database is more than 1 GB, SQLite requires too much memory to run (256 bytes of RAM for each MB of database space, they say).<br /><br />- Generally, if your website gets lots of traffic, SQLite shouldn't be your primary database engine, for the issues mentioned above. php.net uses SQLite for its site, but only on certain parts of it. If you get fewer than 100,000 hits/day, SQLite should work fine - they say. So basically I can use for any site I make...<br /><br /><br /><strong>Conclusions</strong><br />Considering all features and limitations, SQLite is an excellent solution for small or medium websites, embedded applications, programs which only need a small database to function and shouldn't be bound to a server, temporary databases, testing, and the like. Always keep in mind that you're working with files, so keep them protected wherever you put them in your server (a connection is established simply by specifying the path to the file).<br /><br />Last but not least, if you're used to phpMyAdmin for administering your MySQL databases, there are similar tools for SQLite, such as <a href="http://www.sqlitemanager.org">sqlitemanager</a>.<br /> +<p>A few months ago, my old hosting company started having problems with their servers. The servers would go down + unexpectedly for 5-10 minutes on a relatively frequent basis, but for some weird reason... the MySQL databases were + unusable for a couple of hours afterwards every time. "We had problems with MySQL, BUT the server was up, so we're + still within the 99% uptime guarantee"... At the time I was thinking: "If only MySQL databases behaved like plain + files..."</p> +<h3>What is SQLite?</h3> +<p>When PHP5 was first released, I discovered SQLite: <em>"...a small C library that implements a self-contained, + embeddable, zero-configuration SQL database engine"</em> (as quoted from the <a + href="http://www.sqlite.org">official site</a>). PHP5 offers native support to this little wonder, whose + development actually started long before PHP5 was released, and can be used with many, many other programming + languages.</p> +<p>SQLite organizes each database in a .db file, and implements most of the SQL 92 standards, to access the databases + with no need of a server process running at the same time. Access is accomplished through standard reading/writing + file operations.</p> +<p>Let's examine the pros and cons of using SQLite in your web applications.</p> +<h3>Features</h3> +<p>- SQLite is FREE &quot;for any purpose&quot;, <a href="http://www.sqlite.org/copyright.html">they say</a>.<br />- It + doesn't rely on a server process to run<br />- You don't need to spend time configuring your installation, because + there's nothing to configure!<br />- As there's no client-server negotiation, accesses to the database are much + faster (2-3 times faster than a MySQL database)</p> +<p>As a consequence of all this, there's actually no concept of &quot;users&quot; allowed to access the database; as I + said, the actual data of each database is stored into a single file, and as such, it has permissions which regulate + access. If a script has read or write access to the file, a read/write sql instruction can be executed on the + database. You can therefore simply protect your databases as you would protect any other file on your server.</p> +<p>- SQLite is small: the library is just 250KB, and takes care of everything, you don't need any other library or + program to use it.<br />- SQLite can handle files up to 2 terabytes in size.<br />- SQLite implements most of the + SQL 92 standard. This means you can usually use standard and well known queries to access it (with some exceptions, + discussed in the next section).</p> +<p>- SQLite does not enforce datatype constraints. Is this a feature or a bug? Well, they call it a feature, but others + may not agree. As a matter of fact, you can put a string into a field marked &quot;integer&quot; and vice versa, and + furthermore, the string can be as big as you like! There's one exception to this rule, though. Columns marked as + PRIMARY KEY must be of integer type.</p> +<h3>Limitations</h3> +<p>Now that you have read all of the preceding material, and know that PHP5 supports SQLite natively, you might be + thinking about putting MySQL in the bin and using SQLite for everything instead: it's smaller, faster, portable, + simpler, and headache-free... it's love at first sight. Right?</p> +<p>Well, the developers themselves decided to devote <a href="http://www.sqlite.org/whentouse.html">a page</a> to + discuss when you should use SQLite and where you'd be better off sticking with your &quot;old&quot; database engine. + Furthermore, being such a small and powerful piece of code, SQLite comes with some limitations which should be + considered before starting to use it in a project:</p> +<p>- Not all SQL queries and syntax are supported. For a full list, have a look <a + href="http://www.sqlite.org/omitted.html">here</a>. The most notable things you'll miss in SQLite are: the + inability (for now) to &quot;ALTER TABLE&quot; (you do this, they say, by creating a new modified table and deleting + the old one), no VIEW, and no CHECK or FOREIGN KEY constraints (they are &quot;parsed but not enforced&quot;).</p> +<p>- Syntax can be different sometimes. I noticed that, for example, in a JOIN between two or more tables, when + accessing columns you ALWAYS have to specify &lt;table&gt;.&lt;column&gt;, whereas MySQL doesn't complain if there's + ambiguity.</p> +<p>- SQLite is not suitable for projects which require a lot of semi-simultaneous writing operations. SQLite uses + reader/writer locks: if there's someone reading from the database, writing to it is not allowed. This basically + means that multiple simultaneous read operations (SELECT x FROM ...) have higher priority than write operations + (INSERT, UPDATE, ...), which are therefore delayed.</p> +<p>- Do not use SQLite for big databases. Even though I said that (theoretically) databases up to 2 terabytes are + supported, when your database is more than 1 GB, SQLite requires too much memory to run (256 bytes of RAM for each + MB of database space, they say).</p> +<p>- Generally, if your website gets lots of traffic, SQLite shouldn't be your primary database engine, for the issues + mentioned above. php.net uses SQLite for its site, but only on certain parts of it. If you get fewer than 100,000 + hits/day, SQLite should work fine - they say. So basically I can use for any site I make...</p> +<h3>Conclusions</h3> +<p>Considering all features and limitations, SQLite is an excellent solution for small or medium websites, embedded + applications, programs which only need a small database to function and shouldn't be bound to a server, temporary + databases, testing, and the like. Always keep in mind that you're working with files, so keep them protected + wherever you put them in your server (a connection is established simply by specifying the path to the file).</p> +<p>Last but not least, if you're used to phpMyAdmin for administering your MySQL databases, there are similar tools for + SQLite, such as <a href="http://www.sqlitemanager.org">sqlitemanager</a>.</p>
M contents/articles/the-rails3-way-review.htmlcontents/articles/the-rails3-way-review.html

@@ -29,7 +29,7 @@

<section class="section"> <header> - <h1 id="h_1" class="toc">What's New</h1> + <h3 id="h_1" class="toc">What's New</h3> </header> <figure style="float:left;"><img src="/images/pictures/books/rails3way/compare.jpg" /> <figcaption>The Rails Way vs. The Rails 3 Way</figcaption>

@@ -55,7 +55,7 @@

</section> <section class="section"> <header> - <h1 id="h_2" class="toc">Contents</h1> + <h3 id="h_2" class="toc">Contents</h3> </header> <figure style="float:right;"><img src="/images/pictures/books/rails3way/sections.jpg" /> <figcaption>Active Record makes up for over 24% of the book</figcaption>

@@ -104,7 +104,7 @@

</section> <section class="section"> <header> - <h1 id="h_3" class="toc">Organization and Writing Style</h1> + <h3 id="h_3" class="toc">Organization and Writing Style</h3> </header> <figure style="float:right;"><img src="/images/pictures/books/rails3way/flick.jpg" /> <figcaption>Yes, it's a long book. But you don't<br />have to read it from start to finish!

@@ -136,7 +136,7 @@

</section> <section class="section"> <header> - <h1 id="h_4" class="toc">Conclusion</h1> + <h3 id="h_4" class="toc">Conclusion</h3> </header> <p><em>The Rails 3 Way</em> remains the <em>de facto</em> reference book for Rails. I was quite pleased to see that Obie improved it so much, compared to the first edition. Sure, it cannot be recommended to absolute
M contents/articles/twenty-years.mdcontents/articles/twenty-years.md

@@ -47,6 +47,7 @@

But luckily some things were built to last: - [AJAX](/articles/what-is-ajax) may not be called that anymore (and we may have most definitely dropped the XML part), but it laid the foundation of modern JavaScript. +- [REST](/articles/to-rest-or-not-to-rest) is alive and well. - [Git](/articles/git-for-the-locals) is now the de-facto version control system. - [SQLite](/articles/quick-overview-of-sqlite) is very widely-used and respected.
M contents/articles/what-is-ajax.htmlcontents/articles/what-is-ajax.html

@@ -4,4 +4,241 @@ content-type: article

timestamp: 1137047408 tags: "internet|web20|ajax|webdevelopment" ----- -<em>"The Web is changing. The 30-year-old terminal-like technology it was originally is gradually giving way to new ways of doing things. The power of AJAX allows for rich user interaction without the trouble that has bugged traditional web applications."</em>This is the introduction to the script.aculo.us[1] website, and regardless your opinion about the so-called AJAX <em>programming technique</em>, they are fundamentally right: the web is changing. AJAX is at least one way to do things in a different way, enhancing - although arguably, in some cases - users' browsing experience.<br /><br /><strong>Application examples</strong><br />What is AJAX then? Nothing too new, but not too old either. I'd define AJAX as the <em>rebirth of Javascript</em>, for example, it's not only Javascript we're talking about. The acronym stands for Asynchronous Javascript And XML and it already gives an idea of the fundamentals of the technology: something build on <em>asynchronous server requests and responses </em>. This may be clear to coders, but the best way to try explaining this to everyday internet users is showing some famous applications:<br /><br /><em>Gmail[2]</em>: The first example? The most famous? The most used? Perhaps. Google aimed to impress both end users and geeks with it's free, long awaited email service. What's so unusual in this webmail application?<br /><ul><br /><li>An innovative and intuitive interface, more similar to a desktop application than a traditional webpage.</li><br /><li>Rich formatting through an effective, easy-to-use editor.</li><br /><li>Online spell checker.</li><br /><li>Instant </li>(one click) email tagging, labels, contact groups etc.<br /><li>Email auto save.</li><br /></ul><br /><br /><em>Kiko[3]</em>: This is a very neat online calendar, free to use and customizable. Features include:<br /><ul><br /><li>Multiple user/contacts/events administration.</li><br /><li>Personalization of the right click menu </li>(it overrides your browser's default behavior).<br /><li>Drag and drop events across the calendar.</li><br /><li>Easily switch through different calendar views without any page refresh.</li><br />- </ul><br /><br /><em>Writely[4]</em>: An online word processor. Although it is not as advanced as its desktop's cousins, this is a truly admirable effort to port a desktop application to the web. The service is free for now and it allows users to create, edit, share and export text documents. Among its features there are:<br /><ul><br /><li>High degree of document formatting - modify font size, style, colors, alignment, insert images and links etc.</li><br /><li>Enhanced exporting options - it can create html documents, Word documents, zip files etc.</li><br /><li>Online spell-checker.</li><br /><li>Ability to easily share and publish your work.</li><br /></ul><br /><br />This list can continue[5], as new "AJAX-powered" applications are created nearly every day. <br /><fieldset><blockquote>AJAX provides the web developer the ability to create web applications that look and feel like applications that run on the desktop. It does this by solving the 'partial update' problem. AJAX makes it possible for a web application to request data from the server (usually in response to a button click or other java script 'event') and change a part of the current page to reflect the result of the query. Prior to AJAX, if the web developer wanted to retrieve any information from the server a full page update was required. This may mean a full page load when the user clicks a help icon, spell checks a document or performs a drag and drop operation that changes data on the server. AJAX solves this problem and opens the door for a host of AJAX-powered web applications<br />There were some unconventional solutions to this problem prior to AJAX. I have ignored them for the purpose of this article as they were hacky or relied on a feature in a particular browser </blockquote></fieldset><br /><br /><strong>How does it work?</strong><br />Ajax[7] is fundamentally the union of various technologies - not something new by itself:<br /><ul><br /><li> </li>(X)HTML, CSS, etc., used as presentation layer and format the information retrieved by the server: nothing special here.<br /><li>The XMLHttpRequest</li>[8] object, which allows data exchange between client and server "silently", in an asynchronous way, without the need of refreshing and reloading a whole web page<br /><li>The Dom Object Model </li>(DOM)[9], a Object-Oriented way to represent and access HTML or XML.<br /><li>XML and XSLT used for data interchange and manipulation</li><br /></ul><br /><br />The magic is undoubtedly in the XMLHttpRequest object, originally invented by Microsoft as an ActiveX object and then made available as a standard Javascript class by Mozilla-based browsers. At least something which <em>seems</em> to be compatible with <em>most</em> browsers then.<br /><br />A necessary step in any Javascript script using the XMLHttpRequest object would be something like:<br /><br /><code><br />if (window.XMLHttpRequest) { // Mozilla, Safari, ...<br /> http_request = new XMLHttpRequest();<br />} else if (window.ActiveXObject) { // IE<br /> http_request = new ActiveXObject("Microsoft.XMLHTTP");<br />}<br /></code><br /><br />In order to have an http_request object to use later on which is independent from the browser type.<br /><br />Let's now examine an example of elementary Ajax application[10]. The following code is broken into different parts and commented, the uncommented source and a demo is available on degraeve.com[10].<br /><br />For this simple example we need to create a simple server-side script which will be called by our Ajax application. The script can be in any language, this one is in Perl.<br /><br /><code><br />#!/usr/bin/perl -w<br />use CGI;<br /><br />$query = new CGI;<br /><br />$secretword = $query-param('w');<br />$remotehost = $query-remote_host();<br /><br />print $query-header;<br />print "<p>The secret word is <b>$secretword</b> and your IP is <b>$remotehost</b>.<br /> </code><br /><br />Basically it creates a new CGI object named $query, used to access the parameter which will be passed by our submission form, "w", and get the user's IP address.<br />The script will then print a the page header and a phrase containing the word entered in our form and the user's IP address.<br /><br />And here's the simple Ajax application:<br /><br /><code><br /><html><br /><head><br /><title>Simple Ajax Example</title><br /><br /><script language="Javascript"><br /></code><br /><br /><em>Comment: Just the first HTML tags of the page, and the beginning of the script</em><br /><br /><code><br />function xmlhttpPost(strURL) {<br /> var xmlHttpReq = false;<br /> var self = this;<br /> // Mozilla/Safari<br /> if (window.XMLHttpRequest) {<br /> self.xmlHttpReq = new XMLHttpRequest();<br /> }<br /> // IE<br /> else if (window.ActiveXObject) {<br /> self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");<br /> }<br /></code><br /><br /><em>Comment: First of all we create a function named xmlhttpPost, which takes the parameter strURL, i.e. the web address of the script we created earlier. In the first part of the function, we create the HTMLHttpRequest object independently of the browser, which in this case is called self.xmlHttpReq. </em><br /><code><br /> <br /> self.xmlHttpReq.open('POST', strURL, true);<br /><br /> self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');<br /></code><br /><br /><em>Comment: with the method open we initialize the connection, specifying that we want to send a POST request to the page "strURL" and that the connection is asynchronous (true). The third parameter is actually true by default and could have been omitted in this case. <br />As we want to use the POST method, we need to set the content-type header for our request, in this case "application/x-www-form-urlencoded". </em><br /><br /><code><br /> self.xmlHttpReq.onreadystatechange = function() {<br /> if (self.xmlHttpReq.readyState == 4) {<br /> updatepage(self.xmlHttpReq.responseText);<br /> }<br /> }<br /> self.xmlHttpReq.send(getquerystring());<br />}<br /></code><br /><br /><br /><em>Comment: This is the crucial part, as we need to send the request and also define the behavior of our application once the response is received. The request is sent using the "send" method, which sends a properly formatted query string (see below), but before that we need to setup a "listener" to monitor what happens to our request.<br />The readyState variables is updated according to the status of the connection, and can assume the following values:<br /><ul><br /><li>0 - Uninitialised</li><br /><li>1 - Loading</li><br /><li>2 - Loaded</li><br /><li>3 - Interactive</li><br /><li>4 - Completed</li><br /></ul><br /><br />We want to update our page once we are sure that the connection with the script has been established, therefore we setup a listener (onreadystatechange) to update the page via the function update page defined below only if the connection's state is "Completed" (self.xmlHttpReq.readyState == 4). The self.xmlHttpReq.responseText variable which is sent to the update page function contains the response generated by our CGI script. </em><br /><br /><code><br />function getquerystring() {<br /> var form = document.forms['f1'];<br /> var word = form.word.value;<br /> qstr = 'w=' + escape(word); // NOTE: no '?' before querystring<br /> return qstr;<br />}<br /></code><br /><br /><em>Comment: This function simply formats the parameter sent to the script as "w=typedword" where "typedword" is the word typed in the form of our application. </em><br /><br /><code><br />function updatepage(str){<br /> document.getElementById("result").innerHTML = str;<br />}<br /></code><br /><br /><em>Comment: Finally, this function inserts the response we got from the CGI script into an HTML element with id=result, through the method innerHTML. </em><br /><br /><code><br /></script><br /></head><br /><br /><form name="f1"><br /> <pword: <input name="word" type="text" ><br /> <input value="Go" type="button" >onclick='JavaScript:xmlhttpPost("/cgi-bin/simple-ajax-example.cgi")'</p><br /> <div id="result"></div><br /></form><br /></body><br /></html><br /></code><br /><br /><em>Comment: This is the final part of the application, which defines our form containing a text field and a submit button. Note that our xmlhttpPost function is called once the button is clicked, through the on click attribute. </em><br /><br />That's it. <br />The first reaction after reading so far would probably be "Ajax is not easy at all", well, I never said it was. To create a simple application which just prints something on the screen we had to go through a lot of code, and we could have done something similar with much less hassle. This was just a trivial example, very different from those large scale applications available online.<br /><br />There's good news though, there are plenty of frameworks and toolkits which makes life easier for developers interested in using this programming technique. There are in particular various libraries built upon the Prototype[11] framework such as the already mentioned Script.aculo.us[1] and Rico[12] for examples, and various frameworks which integrate Ajax in some way in any server side language, like Ruby on Rails[13] or CakePHP[14], for example.<br /><br /><strong>Conclusion</strong><br />Undoubtedly Ajax can be used to create really powerful and innovative applications, but it shouldn't be abused or mis-used. There are a few things to keep in mind, when developing an Ajax application:<br /><ul><br /><li>It requires Javascript to be enable on the client browser, and the developer obviously can't control that</li><br /><li>The application may not compatible with all browsers, in particular older browsers will definitely not be able to access it.</li><br /><li>It can be too much of a surprise for the user who never used an Ajax application before: it may experience delays in responses, some basic functionalities like the "Back" button might not work as expected etc.</li><br /></ul><br /><br />There are actually many more things to consider [15] before even start planning to develop an application, and can basically be summarized as follows:<br /><br /><em>"Do not use Ajax in your web application unless you know what you're doing"</em><br /><br />Luckily, there are a lot of articles and resources[16] out there, waiting for you.<br /><br /><br /><strong>Notes and Resources</strong><br /><small><br />[1] Script.aculo.us AJAX toolkit: <a href="http://www.script.aculo.us ">http://www.script.aculo.us </a><br />[2] Gmail - Google's online webmail: <a href="http://mail.google.com/mail">http://mail.google.com/mail</a><br />[3] Kiko - Online calendar: <a href="http://www.kiko.com/">http://www.kiko.com/</a><br />[4] Writely - Online word processor: <a href="http://www.writely.com/">http://www.writely.com/</a> <br />[5] A venture forth Blog - Top 10 Ajax applications: <a href="http://www.aventureforth.com/?p=13">http://www.aventureforth.com/?p=13</a><br />[6] HTTP - Webopedia entry: <a href="http://www.webopedia.com/TERM/H/HTTP.html">http://www.webopedia.com/TERM/H/HTTP.html</a><br />[7] AJAX - Wikipedia Page: <a href="http://en.wikipedia.org/wiki/AJAX">http://en.wikipedia.org/wiki/AJAX</a><br />[8] XMLHTTP Wikipedia Page: <a href="http://en.wikipedia.org/wiki/XMLHTTP">http://en.wikipedia.org/wiki/XMLHTTP</a><br /><br />[9] Dom Object Model - Wikipedia Page: <a href="http://en.wikipedia.org/wiki/Document_Object_Model">http://en.wikipedia.org/wiki/Document_Object_Model</a><br />[10] degraeve.com - Simple Ajax Example: <a href="http://www.degraeve.com/reference/simple-ajax-example.php">http://www.degraeve.com/reference/simple-ajax-example.php</a><br />[11] Prototype Javascript Framework: <a href="http://prototype.conio.net/">http://prototype.conio.net/</a><br />[12] Rico open-source Javascript library: <a href="http://openrico.org/">http://openrico.org/</a><br />[13] Ruby on Rails: <a href="http://www.rubyonrails.org">http://www.rubyonrails.org</a><br />[14] CakePHP framework: <a href="http://www.cakephp.org">http://www.cakephp.org</a><br />[15] Alex Bosworth's Weblog: Ajax Mistakes: <a href="http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html">http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html</a><br />[16] AjaxMatters.com: <a href="http://www.ajaxmatters.com/r/welcome">http://www.ajaxmatters.com/r/welcome</a><br /></small><br /> +<em>"The Web is changing. The 30-year-old terminal-like technology it was originally is gradually giving way to new ways + of doing things. The power of AJAX allows for rich user interaction without the trouble that has bugged traditional + web applications."</em> +<p>This is the introduction to the <a href="http://www.script.aculo.us">script.aculo.us</a> website, and regardless your + opinion about + the so-called AJAX <em>programming technique</em>, they are fundamentally right: the web is changing. AJAX is at + least + one way to do things in a different way, enhancing - although arguably, in some cases - users' browsing + experience.</p> + +<h3>Application examples</h3> +<p>What is AJAX then? Nothing too new, but not too old + either. I'd define AJAX as the <em>rebirth of Javascript</em>, for example, it's not only Javascript we're talking + about. The acronym stands for Asynchronous Javascript And XML and it already gives an idea of the fundamentals of + the + technology: something build on <em>asynchronous server requests and responses</em>. This may be clear to coders, but + the best way to try explaining this to everyday internet users is showing some famous + applications:</p> + +<em>Gmail</em>: The first example? The most famous? The most used? Perhaps. Google aimed to +impress both end users and geeks with its free, long-awaited email service. What's so unusual in this webmail +application? +<ul> + <li>An innovative and intuitive interface, more similar to a desktop application than a traditional webpage.</li> + <li>Rich formatting through an effective, easy-to-use editor.</li> + <li>Online spell checker.</li> + <li>Instant (one click) email tagging, labels, contact groups etc.</li> + <li>Email auto save.</li> +</ul> + +<em>Kiko</em>: This is a very neat online calendar, free to use and customizable. Features include: +<ul> + <li>Multiple user/contacts/events administration.</li> + <li>Personalization of the right click menu (it overrides your browser's default behavior).</li> + <li>Drag and drop events across the calendar.</li> + <li>Easily switch through different calendar views without any page refresh.</li> +</ul> + +<em>Writely</em>: An online word processor. Although it is not as advanced as its desktop cousins, +this is a truly admirable effort to port a desktop application to the web. The service is free for now and it allows +users to create, edit, share, and export text documents. Among its features there are: +<ul> + <li>High degree of document formatting - modify font size, style, colors, alignment, insert images and links etc. + </li> + <li>Enhanced exporting options - it can create HTML documents, Word documents, zip files etc.</li> + <li>Online spell-checker.</li> + <li>Ability to easily share and publish your work.</li> +</ul> + +<p>This list can continue, as new "AJAX-powered" applications are created nearly every day.</p> + +<blockquote> + AJAX provides the web developer the ability to create web applications that look and feel like + applications that run on the desktop. It does this by solving the 'partial update' problem. AJAX makes it + possible for a web application to request data from the server (usually in response to a button click or other + javascript 'event') and change a part of the current page to reflect the result of the query. Prior to AJAX, if + the web developer wanted to retrieve any information from the server, a full page update was required. This may + mean a full page load when the user clicks a help icon, spell checks a document, or performs a drag and drop + operation that changes data on the server. AJAX solves this problem and opens the door for a host of + AJAX-powered web applications. + <br /> + There were some unconventional solutions to this problem prior to AJAX. I + have ignored them for the purpose of this article as they were hacky or relied on a feature in a particular + browser +</blockquote> + +<h3>How does it work?</h3> +<p>Ajax is fundamentally the union of various technologies - not something new by itself:</p> +<ul> + <li>(X)HTML, CSS, etc., used as presentation layer and format the information retrieved by the server: nothing + special here.</li> + <li>The XMLHttpRequest object, which allows data exchange between client and server "silently", in an + asynchronous way, without the need of refreshing and reloading a whole web page.</li> + <li>The DOM Object Model (DOM), an Object-Oriented way to represent and access HTML or XML.</li> + <li>XML and XSLT used for data interchange and manipulation.</li> +</ul> + +<p>The magic is undoubtedly in the XMLHttpRequest object, originally invented by Microsoft as an ActiveX + object and then made available as a standard JavaScript class by Mozilla-based browsers. At least something which + <em>seems</em> to be compatible with <em>most</em> browsers then. +</p> + +<p>A necessary step in any JavaScript script using the XMLHttpRequest object would be something + like:</p> + +<pre><code class="javascript"> +if (window.XMLHttpRequest) { // Mozilla, Safari, ... + http_request = new XMLHttpRequest(); +} else if (window.ActiveXObject) { // IE + http_request = new ActiveXObject("Microsoft.XMLHTTP"); +} +</code></pre> + +<p>In order to have an http_request object to use later on which is independent from the browser type.</p> + +<p>Let's now examine an example of elementary Ajax application. The following code is broken into different parts and + commented, + the uncommented source and a demo is available on <a + href="http://www.degraeve.com/reference/simple-ajax-example.php">degraeve.com</a>.</p> + +<p>For this simple example, we need to create + a simple server-side script which will be called by our Ajax application. The script can be in any language, this + one is + in Perl.</p> + +<pre><code class="perl"> +#!/usr/bin/perl -w +use CGI; + +$query = new CGI; + +$secretword = $query->param('w'); +$remotehost = $query->remote_host; + +print $query->header; +print "<p>The secret word is <b>$secretword</b> and your IP is <b>$remotehost</b>.</p>"; +</code></pre> + +<p>Basically, it creates a new CGI object named $query, used to access the parameter which will be passed by our + submission form, "w", + and get the user's IP address. The script will then print the page header and a phrase containing the word + entered in our form and the user's IP address.</p> + +And here's the simple Ajax application: + +<pre><code class="html"> +<html> +<head> +<title>Simple Ajax Example</title> +<!-- Just the first HTML tags of the page, and the beginning of the script --> +<script language="Javascript"> + function xmlhttpPost(strURL) { + var xmlHttpReq = false; + var self = this; + // Mozilla/Safari + if (window.XMLHttpRequest) { + self.xmlHttpReq = new XMLHttpRequest(); + } + // IE + else if (window.ActiveXObject) { + self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); + } + + self.xmlHttpReq.open('POST', strURL, true); + + self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + <!-- with the method open we initialize the connection, specifying that we want to send a POST request to the page + "strURL" and that the connection is asynchronous (true). The third parameter is actually true by default and could + have been omitted in this case. As we want to use the POST method, we need to set the content-type header for + our request, in this case "application/x-www-form-urlencoded". --> + + self.xmlHttpReq.onreadystatechange = function () { + if (self.xmlHttpReq.readyState == 4) { + updatepage(self.xmlHttpReq.responseText); + } + } + self.xmlHttpReq.send(getquerystring()); + } + + function getquerystring() { + var form = document.forms['f1']; + var word = form.word.value; + qstr = 'w=' + escape(word); // NOTE: no '?' before querystring + return qstr; + } + + function updatepage(str) { + document.getElementById("result").innerHTML = str; + } + +</script> +</head> + +<body> +<form name="f1"> + <p>Word: <input name="word" type="text" ></p> + <input value="Go" type="button" onclick='JavaScript:xmlhttpPost("/cgi-bin/simple-ajax-example.cgi")'> + <div id="result"></div> +</form> +</body> +</html> +</code></pre> + +<!-- This is the final part of the application, which defines our form containing a text field and a submit button. Note + that our xmlhttpPost function is called once the button is clicked, through the onclick attribute. --> + +<p>That's it.</p> + +<p>The first reaction after reading so far would probably be "Ajax is not easy at all", well, I never said it was. To + create a simple application which just prints something on the screen we had to go through a lot of code, and we + could have done something similar with much less hassle. This was just a trivial example, very different from those + large scale applications available online.</p> +<p>There's good news though, there are plenty of frameworks and toolkits which makes life easier for developers + interested in using this programming technique. There are in particular various libraries built upon the Prototype + framework such as the already mentioned Script.aculo.us and Rico for examples, and various frameworks which + integrate Ajax in some way in any server side language, like Ruby on Rails or CakePHP, for example.</p> +<h3>Conclusion</h3> +<p>Undoubtedly Ajax can be used to create really powerful and innovative applications, but it shouldn't be abused or + mis-used. There are a few things to keep in mind, when developing an Ajax application:</p> +<ul> + <li>It requires Javascript to be enable on the client browser, and the developer obviously can't control that</li> + <li>The application may not compatible with all browsers, in particular older browsers will definitely not be able + to access it.</li> + <li>It can be too much of a surprise for the user who never used an Ajax application before: it may experience + delays in responses, some basic functionalities like the "Back" button might not work as expected etc.</li> +</ul> +<p>There are actually many more things to consider before even start planning to develop an application, and can + basically be summarized as follows:</p> +<p><em>"Do not use Ajax in your web application unless you know what you're doing"</em></p> +<p>Luckily, there are a lot of articles and resources out there, waiting for you.</p> +<h3>Notes and Resources</h3> +<small> + <p>[1] Script.aculo.us AJAX toolkit: <a href="http://www.script.aculo.us ">http://www.script.aculo.us </a></p> + <p>[2] Gmail - Google's online webmail: <a href="http://mail.google.com/mail">http://mail.google.com/mail</a></p> + <p>[3] Kiko - Online calendar: <a href="http://www.kiko.com/">http://www.kiko.com/</a></p> + <p>[4] Writely - Online word processor: <a href="http://www.writely.com/">http://www.writely.com/</a></p> + <p>[5] A venture forth Blog - Top 10 Ajax applications: <a + href="http://www.aventureforth.com/?p=13">http://www.aventureforth.com/?p=13</a></p> + <p>[6] HTTP - Webopedia entry: <a + href="http://www.webopedia.com/TERM/H/HTTP.html">http://www.webopedia.com/TERM/H/HTTP.html</a></p> + <p>[7] AJAX - Wikipedia Page: <a href="http://en.wikipedia.org/wiki/AJAX">http://en.wikipedia.org/wiki/AJAX</a></p> + <p>[8] XMLHTTP Wikipedia Page: <a + href="http://en.wikipedia.org/wiki/XMLHTTP">http://en.wikipedia.org/wiki/XMLHTTP</a></p> + <p>[9] Dom Object Model - Wikipedia Page: <a + href="http://en.wikipedia.org/wiki/Document_Object_Model">http://en.wikipedia.org/wiki/Document_Object_Model</a> + </p> + <p>[10] degraeve.com - Simple Ajax Example: <a + href="http://www.degraeve.com/reference/simple-ajax-example.php">http://www.degraeve.com/reference/simple-ajax-example.php</a> + </p> + <p>[11] Prototype Javascript Framework: <a href="http://prototype.conio.net/">http://prototype.conio.net/</a></p> + <p>[12] Rico open-source Javascript library: <a href="http://openrico.org/">http://openrico.org/</a></p> + <p>[13] Ruby on Rails: <a href="http://www.rubyonrails.org">http://www.rubyonrails.org</a></p> + <p>[14] CakePHP framework: <a href="http://www.cakephp.org">http://www.cakephp.org</a></p> + <p>[15] Alex Bosworth's Weblog: Ajax Mistakes: <a + href="http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html">http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html</a> + </p> + <p>[16] AjaxMatters.com: <a href="http://www.ajaxmatters.com/r/welcome">http://www.ajaxmatters.com/r/welcome</a></p> +</small>