Skip navigation


warning: Creating default object from empty value in /var/www/vhosts/ on line 33.

Look at this incredible thing Ian Baker created. Look at it!

The PHP hammer

What you're seeing is not Photoshopped. This is an actual photo of a real world, honest to God double-clawed hammer. Such a thing exists. Isn't that amazing? And also, perhaps, a little disturbing?

That wondrous hammer is a delightful real-world acknowledgement of the epic blog entry PHP: A Fractal of Bad Design.

I can’t even say what’s wrong with PHP, because – okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

Remember the immediate visceral reaction you had to the double-clawed hammer? That's exactly the reaction most sane programmers have to their first encounter with the web programming language PHP.

This has been going on for years. I published my contribution to the genre in 2008 with PHP Sucks, But It Doesn't Matter.

I'm no language elitist, but language design is hard. There's a reason that some of the most famous computer scientists in the world are also language designers. And it's a crying shame none of them ever had the opportunity to work on PHP. From what I've seen of it, PHP isn't so much a language as a random collection of arbitrary stuff, a virtual explosion at the keyword and function factory. Bear in mind this is coming from a guy who was weaned on BASIC, a language that gets about as much respect as Rodney Dangerfield. So I am not unfamiliar with the genre.

Except now it's 2012, and fellow programmers are still writing long screeds bemoaning the awfulness of PHP!

What's depressing is not that PHP is horribly designed. Does anyone even dispute that PHP is the worst designed mainstream "language" to blight our craft in decades? What's truly depressing is that so little has changed. Just one year ago, legendary hacker Jamie Zawinski had this to say about PHP:

I used to think that PHP was the biggest, stinkiest dump that the computer industry had taken on my life in a decade. Then I started needing to do things that could only be accomplished in AppleScript.

Is PHP so broken as to be unworkable? No. Clearly not. The great crime of PHP is its utter banality. Its continued propularity is living proof that quality is irrelevant; cheap and popular and everywhere always wins. PHP is the Nickelback of programming languages. And, yes, out of frustration with the status quo I may have recently referred to Rasmus Lerdorf, the father of PHP, as history's greatest monster. I've told myself a million times to stop exaggerating.

The hammer metaphor is apt, because at its core, this is about proper tooling. As presciently noted by Alex Papadimoulis:

A client has asked me to build and install a custom shelving system. I'm at the point where I need to nail it, but I'm not sure what to use to pound the nails in. Should I use an old shoe or a glass bottle?

How would you answer the question?

  1. It depends. If you are looking to pound a small (20lb) nail in something like drywall, you'll find it much easier to use the bottle, especially if the shoe is dirty. However, if you are trying to drive a heavy nail into some wood, go with the shoe: the bottle will shatter in your hand.
  2. There is something fundamentally wrong with the way you are building; you need to use real tools. Yes, it may involve a trip to the toolbox (or even to the hardware store), but doing it the right way is going to save a lot of time, money, and aggravation through the lifecycle of your product. You need to stop building things for money until you understand the basics of construction.

What we ought to be talking about is not how terrible PHP is – although its continued terribleness is a particularly damning indictment – but how we programmers can culturally displace a deeply flawed tool with a better one. How do we encourage new programmers to avoid picking up the double clawed hammer in favor of, well, a regular hammer?

This is not an abstract, academic concern to me. I'm starting a new open source web project with the goal of making the code as freely and easily runnable to the world as possible. Despite the serious problems with PHP, I was forced to consider it. If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option. If that doesn't scare you, then check your pulse, because you might be dead.

Everything goes with PHP sauce! Including crushing depression.

Therefore, I'd like to submit a humble suggestion to my fellow programmers. The next time you feel the urge to write Yet Another Epic Critique of PHP, consider that:

  1. We get it already. PHP is horrible, but it's used everywhere. Guess what? It was just as horrible in 2008. And 2005. And 2002. There's a pattern here, but it's subtle. You have to look very closely to see it. On second thought, never mind. You're probably not smart enough to figure it out.
  2. The best way to combat something as pervasively and institutionally awful as PHP is not to point out all its (many, many, many) faults, but to build compelling alternatives and make sure these alternatives are equally pervasive, as easy to set up and use as possible.

We've got a long way to go. One of the explicit goals of my next project is to do whatever we can to buff up a … particular … open source language ecosystem such that it can truly compete with PHP in ease of installation and deployment.

From my perspective, the point of all these "PHP is broken" rants is not just to complain, but to help educate and potentially warn off new coders starting new codebases. Some fine, even historic work has been done in PHP despite the madness, unquestionably. But now we need to work together to fix what is broken. The best way to fix the PHP problem at this point is to make the alternatives so outstanding that the choice of the better hammer becomes obvious.

That's the PHP Singularity I'm hoping for. I'm trying like hell to do my part to make it happen. How about you?

[advertisement] How are you showing off your awesome? Create a Stack Overflow Careers profile and show off all of your hard work from Stack Overflow, Github, and virtually every other coding site. Who knows, you might even get recruited for a great new position!

Your rating: None

Much has already been said about Continuous Deployment. Etsy made it famous once and we integrated our own solution about two weeks ago.

The reason why I integrated it into our system was quite simple: the only person who could perform a deploy was me. This was hindering the rest of the team of course.

Our architecture allowed “hot” deployments already. That means users who were already using the Audiotool application did not notice a deploy happened at all. This is of course only possible as long as there are no new dependencies on the API.

The Audiotool startup process is a very important ingridient. We have a boot sequence which loads a configuration file upfront. In this configuration file is a version number. The version number is used to load all dependencies the application needs to start. We have put a repository server in place which serves SWF files based on this version and they get cached till the end of time.

If a user started Audiotool when version 1.1 was online and we update to 1.2 in the meantime the user would still load all audio plugins for version 1.1. There are some cases when a hot deployment is not possible (yet) and we call this a scheduled update.
This pushes a message into Audiotool, notifying users that they should save their song and restart the application. But this is not part of the blog post and a scheduled update is very rare. We did it twice last year, once this year.

When we did a deploy it was basically done like this:

  1. Make sure all changes are checked in.
  2. Update a default version key in some source files in case the boot sequence cannot load the configuration for whatever reason.
  3. Update the Nginx configuration so that some verison-less files like our embed player are routed correct.
  4. Create a tag for the repository.
  5. Create a clone of the tag.
  6. Execute mvn -Pdeploy-to-live deploy in the clone. This command already updates all plug-ins on and puts new metadata in place.
  7. Copy all SWF files form a local directory to S3.
  8. SSH into a server and update the configuration file Audiotool parses at startup.
  9. Reload the Nginx configuration.

A lot of steps. This means a lot can go wrong of course. And even though we had all those steps written down in an internal Wiki it is still hard to do all this. You need the appropriate SSH keys to log into some servers, uploading files to S3 requires a tool which is also configured and not everyone is comfortable with editing a Nginx configuration file on an Amazon server through the terminal.

There was only one deployment that happened without me. I was at FITC Amsterdam in 2010 at that time and it was a long phone call. Obviously something had to change.

The first step was to get rid of all the manual configuration hassle. The configuration file that one needed to change via SSH had to go so I made it a dynamically created file by the web server. The actual version is pulled from the database and this made our my life much easier already. But still this was not what I wanted. Of course nothing really changed. You still had to perform the S3 upload, SSH into a server and so on.

But since the configuration was already served via the web server I could start automating more things. Even better: with our last major update we dropped the version number from Audiotool. User’s would stop expecting to see big changes and a version number that increases. Instead we focus on being much more active and to push changes online as quick as possible.

Since I already wrote some shell scripts for myself to deploy various server applications with a single command I started doing the same for the whole Audiotool application.

The first step was to get rid of the default version in some of the ActionScript source files. I simply [Embed] a text file now which contains the version information. A single text file is so much easier to change.

Then I added an API call which allows me to change the version information online. That way a new version can be released easily without any human interaction. With the API call in place and a text file containing all important configuration parameters the last issue was the Nginx configuration. But a small script on the server should do the job.

So I started writing a little script which performs all the necessary tasks:

  1. Create a clone of the repository.
  2. Get the id of the current revision.
  3. Create a tag for the revision like YYYY-MM-DD_REVISION.
  4. Replace the default version with the revision.
  5. Execute the Maven command to deploy some metadata and build all SWF files.
  6. Upload all SWF files to S3.
  7. curl our API with the revision information.
  8. SSH into a server at Amazon to update Nginx.
  9. Cleanup.

That’s all there was to it. Since I do not have that much experience with shell scripting the most annoying part was to figure out a way to replace the text in a file. After looking through all examples of possible/impossible sed and awk options I got lucky with sed -i "/@build.version@/ s//${HG_VERSION}/g" ${HG_CLONE}/default.version.txt. This basically replaces @build.version@ with the content of ${HG_VERSION}. I know, magic. I just want to write it down here so Future-Joa can Google this and come back in five years getting a quick answer.

With the shell script at our disposal we simply had to hook it into TeamCity, a fantastic continuous integration solution by the way. After configuring some command line tools on the CI server we were ready to go.

The results speak for themselves. We made already twenty deployments during the last two weeks. That is about as many deployments as we did since we started Audiotool. Because deployments become less scary and everyone can trigger them we are able to iterate quicker and get rid of a lots of bugs. In fact it makes it also much easier to reason about your program. If you push hundreds of new features and get a null pointer exception: good luck. However if you just changed one little thing and get loads of bug reports it is quite easy to identify what could be the possible culprit. Of course this is only a Flash problem since there are no stack traces in the release player. But I guess if you build a JavaScript application you would have similar problems.

I can only recommend doing the same. Especially for your own sanity. 100% automated deployments are really cool and stress free! It is also much easier to setup than you might expect.

Your rating: None

I am no longer committed to supporting any Flash related open-source projects.

Here is why. When I started using the Flash Player it was quite easy to reach its limits. However you were able to get around those limitations with clever hacks and debatable optimization techniques. I was always keen to share my knowledge with the community and to explore all possible options to achieve best performance.

The Flash Player has been hibernating for half a decade now. The only glimpse of performance was finally a set of specialized op-codes which allow you to modify an array of bytes. In layman’s terms this means it was finally possible to do a[b] = c with an acceptable performance. So I wrote a tool which allows you to do just that and many other things. I have spent a good time of my free time trying to improve the performance of the Flash Player and contributing all my code to the community.

As a reminder: I showed some drastic performance improvements at Flash on the Beach in 2009. That was three years ago. It was not necessary to modify the Flash Player and it was not necessary to modify the ActionScript language.

The Adobe roadmap for the Flash runtimes states that Flash Player “Dolores”

  • will support ActionScript Workers
  • comes with improved performance for Apple iOS
  • and ActionScript 3 APIs to access the fast-memory op-codes

This player should be released in the second half of 2012. The “Next” Flash Player will finally include

  • modernizing the core of the Flash runtime
  • work on the VM
  • updates to the ActionScript language

This is planned for 2013 apparently. And what can we expect? Type inference, static typing as a default, and hardware-oriented numeric types. Hooray, so it will be finally possible in 2013 to write a[b] = c without having to use some weird fast-memory op-codes. If we look back to the year 2009 this makes me really sad.

With the introduction of the speed tax you will now have to license your application. No matter if you make money out of it or not. Now I think that 9% is a decent number and I can understand Adobe’s position on this. In fact it is much more friendly than the 30% Google or Apple take. However the AppStore was an invention. What is the invention here? Squeezing money out of an already existing feature, and suddenly making it unavailable after people have been relying on it for years to push the boundaries of the platform and actually innovate?

But for the hell of it, a[b] = c is not a premium feature. Nor are hardware accelerated graphics. That is what I would expect from any decent runtime.

Limiting the capabilities of a runtime — by defaulting back to software rendering for instance — will make it less attractive to use it in the first place. You are probably not interested to go through a signing progress for a small demo. So your performance might be crap, people will complain about the Flash Player taking 100% CPU because its using software rendering (YEY! 2013!), laptop fans will start to dance and you will look like a bad developer because that other guy got the same thing running with hardware acceleration. Or you could use a different technology.

Why is this bad? Because apparently this signing with a $50k threshold targets the enterprise and small developers seem to be acceptable collateral damage. However thinking about the next five to ten years: who is going to write ActionScript code if it is no longer attractive to play around with it in the first place?

We still rely on the Flash Player at I am still developing for it and we will probably have to use it as long as there is no alternative. Me no longer supporting open-source tools is just me no longer spending my personal time for a platform that I would not use for private stuff. Work is of course not always about fun. But fortunately I am able to spend 90% of my time writing Scala code.

I will finish this blog post with some bad karma:

It’s also worth noting that the new Adobe license will prohibit scenarios where you’d have the first level of a game in the Flash Player, and the full experience inside the Unity Web Player. Alas, this is something you’ll need to be aware of if you were considering such a route.

You will not only pay for the features. You are also welcome to cede some of your rights.

flattr this!

Your rating: None

Adobe has published its roadmap for its Flash browser plugin and its AIR desktop application counterpart. More releases, more features, and more performance, are all planned, but on fewer platforms: Adobe is giving up entirely on supporting smartphone browsers, sticking to the core desktop platforms for its plugin—and with a big question mark when it comes to Windows 8.

The company sees Flash as having two main markets that will resist the onslaught of HTML5: game development, and premium (read: encrypted) video. To that end, the features it has planned for future updates focus on making Flash faster, with greater hardware acceleration and improved script performance, and more application-like, with keyboard input in full-screen applications, and support for middle- and right-mouse buttons.

Read the rest of this article...

Read the comments on this post

Your rating: None

You load an external SWF file at runtime using Loader.load() method. You extract the file via
Loader.content, cast it to MovieClip, and store in a MovieClip variable.
You add a listener to mouse clicks to your loaded MovieClip only to discover
that it does not respond to clicks. Isn't Loader.content in the case of loading an SWF file
a MovieClip? We discuss the issue and give examples. Flash and AS3 source files included.

Your rating: None

Welcome to the preview release of codename "Alchemy." Alchemy is a research project that allows users to compile C and C++ code that is targeted to run on the open source ActionScript Virtual Machine (AVM2). The purpose of this preview is to assess the level of community interest in reusing existing C and C++ libraries in Web applications that run on Adobe® Flash® Player and Adobe AIR®.

With Alchemy, Web application developers can now reuse hundreds of millions of lines of existing open source C and C++ client or server-side code on the Flash Platform.  Alchemy brings the power of high performance C and C++ libraries to Web applications with minimal degradation on AVM2.  The C/C++ code is compiled to ActionScript 3.0 as a SWF or SWC that runs on Adobe Flash Player 10 or Adobe AIR 1.5.

Alchemy is primarily intended to be used with C/C++ libraries that have few operating system dependencies. Ideally suited for computation-intensive use cases, such as audio/video transcoding, data manipulation, XML parsing, cryptographic functions or physics simulation, performance can be considerably faster than ActionScript 3.0 and anywhere from 2-10x slower than native C/C++ code. Alchemy is not intended for general development of SWF applications using C/C++.

Download and Discuss

With Alchemy, it is easy bridge between C/C++ and ActionScript 3.0 to expand the capabilities of applications on the Flash Platform, while ensuring that the generated SWCs and SWFs cannot bypass existing Flash Player security protections.

Adobe is providing some example libraries, and developers are encouraged to share their ported libraries.

Your rating: None

I just posted my thoughts on the Flash Player team blog, about the recent announcements we have made regarding Flash Player support on mobile browsers.

As a long time Flash developer who loves Flash, I can tell you that what is happening right now is a good thing.

First, we are making bold moves like stopping the development of the browser plug-in on mobile browsers in favor of investing further in Flash-based apps packaged with AIR. Playing existing content sounds like a great idea on paper, but we know it doesn't always work that way -- you need to author for mobile and think for mobile, but from talking to customers and looking at content today, we realize that very few people are targeting the plug-in on mobile browsers.

Flash developers have always created some of the most stunning, immersive, emotional experiences on the web. They've always pushed the cutting edge, with few restrictions. But mobile is different, and developers need to adapt to different constraints and affordances. Flash lets you do that, whether you are taking advantage of efficient hardware accelerated video playback or native support for features like multitouch and accelerometers. But it's costly to create beautiful experiences optimized for mobile browsers — a cost that doesn't make sense if people using one of the most popular mobile platforms can't see the content you create.

Existing content for desktops didn't always look as magical on phones as people were used to seeing with Flash Player on their desktops. Content optimized for desktops with big screens and beefy processors can’t look as good on a phone or a tablet it was never designed for. This really had an impact on the trust that people had in Flash, and this perception made it hard to start new projects optimized for mobile browsers. There was just no appetite to even try doing this.

In contrast, you guys create super nice Flash-based apps packaged with AIR and delivering them to app stores across iOS, Android, and BlackBerry devices – by the end of this year, you will be able to reach over 350 million tablets and smartphones. Have you seen an article from a journalist saying that MachinariumComb over Charlie, or TweetHunt are horrible ? No, people love those games. Your work fits the trend the entire industry is seeing: even as we're excited about improvements in mobile browsers, the most compelling, immersive experiences for mobile devices are delivered through apps, optimized from the ground up for mobile. We're helping you guys leverage your talent – the same skills in ActionScript and tooling – to reach that huge, growing market of smartphone and tablet users with amazing apps. Flash makes it possible for developers who craft beautiful desktop experiences to deliver great mobile app experiences. We are going to really focus on that, creating the best solution to build stunning interactive content, games, and video apps across all screens.

Flash Player on the desktop continues to show a path for the consistent, super duper experiences that are impossible to deliver to over a billion people with any other technology. For example, Flash Player 11 was released only a month ago, and it now enables fluid, cinematic hardware accelerated 2D and 3D visuals for more people on the web than any other technology. Flash Player uniquely does for the desktop what apps do for phones and tablets: it helps ensure that what you imagine is exactly what your users will see. Flash Player remains the best technology for delivering premium experiences on the desktop, period. Focusing helps us make sure that we continue to drive that continued innovation.

We are not stepping out of the mobile space with Flash, we are just focusing on what makes sense and where Flash looks great, standalone apps with AIR.

In the long term, we're actively working on an ambitious future for Flash. The implementation details may change, as we've been talking about today. We believe that the DNA of Flash doesn't reside in those implementation details, but in our promise to make it easy to create and deliver the most amazing experiences everywhere. We're focusing on fulfilling that promise, and we’re excited to see what the future – and our community – will bring.

Your rating: None

The Opposable Thumbs blog covers a 48-hour-long "game jam" at the Queensland University of Technology in Australia. Twenty teams of game developers — 16 indie and four professional — compete over a weekend to build a functional game based on a few deliberately vague keywords. This article documents the brainstorming sessions and the early prototyping work. Quoting:
"The teams become less talkative as midnight draws near and the individual team members all settle down into their jobs. Everybody seems determined to not let sleep take over just yet. I take a tour of some of the other teams. Badgers are being animated, leg movements first with static bodies above them. Other teams have no art yet and just use colored rectangles as they get the mechanics down. Others are still sketching beautiful concept art and coding level editors.'To move around the room is to hear random snippets of creativity and math. 'If we move the z-axis, too, we can do this thing' or 'what if we procedurally generated that object.' In this one spot, sixteen games are coming into being that weren't even concepts eight hours ago."

Read more of this story at Slashdot.

Your rating: None