CoffeeScript or JavaScript?

Recently I played with CoffeeScript a bit. Friends were talking about CoffeeScript and also I read couple of interesting blog posts. Based on my limited experience with it here is my understanding of what is cool and not so cool.

Cool:

  1. It is much more compact than JavaScript. This translates to up to 1/3 less lines of code than the equivalent JavaScript
  2. Offers the concept of classes – something that is familiar for people coming from the Java world
  3. Insulates you from JavaScript pitfalls like global scope
  4. Some times you can get a performance boost – hard to tell when and by how much
  5. Some compile-time error checking, which helps you to write code with fewer bugs right off the bat

Not so cool:

  1. Hard to debug. You have to debug the generated JavaScript code and from there you have to trace back to the CoffeeScript code
  2. Writing less code can actually be something bad. Anyone remember Perl? And how hard it can be to read Perl code?
  3. Adds another layer of abstraction on top of the browser stack. Adding to this jQuery or other frameworks and you can easily be in a situation where you can put together reasonably complex apps but you have no idea of what is happening under the hood nor how to fix a bug that originates from the frameworks you used
  4. While I understand from why is done the way it was, I still think it would have been nice to have optional data typing

Maybe not so surprisingly , I’ve seen people coming from OOP languages (Java or C#) that totally love CoffeeScript and this is their preferred way to write JavaScript apps.

As I said, I just played with it. So if I misunderstood something or completely missed a point please let me know.

Tour de Flex is available for iPad now

My colleagues from the Enterprise team were busy updating the Tour de Flex application to Flex 4.6 and they have published it to Android Market and the Apple App Store.

What’s cool about this project is that it is a three-in-one type of product: you can learn how to use Flex, you can experience the performance of the Flex framework on mobile devices firsthand, and you can check the source code and learn how to build awesome mobile projects. Here is the project home page and you can get the source code from here (you’ll need Flash Builder 4.6 to import the project).

And if you’re looking for the app on the stores search fom “Game of Flex” and not Tour de Flex!

Steps to deploy a Flex and PHP application

I’ve been receiving a number of emails on this topic lately. It seems there is little information out there about how to move from development to production with a Flex and PHP application. Here is a simple checklist that could help you, especially if you are doing this for the first time. Please note that I presume you used the Data Services (wizards) to connect the Flex client to PHP services.

  1. Make sure you have Zend Framework on your server. If you don’t, install it
  2. Make sure you change MySQL credentials and server IP/name used by your PHP scripts to connect to the database
  3. Copy the PHP services folder to your server. Then test these services. If they don’t work check the MySQL credentials or look for dependencies (maybe your PHP services use other PHP classes that you forgot to copy to your server)
  4. Edit the amy_config.ini file and make sure the path to the Zend Framework is OK and set production to true
  5. Edit the Flex services to point to your live server gateway.php. In the services folder of your Flex project you will find _Super_something.as files. In the constructor you will find a line like this:

    _serviceControl.endpoint = “http://localhost:10088/MobileFlexPHP-PHP/public/gateway.php”;
    Copy that line and then open the class that extends this _Super class and paste the line in the constructor. Then change the URL to reflect your server setup

  6. Copy the bin-release/ folder to your server (you should choose the export release for your project; this will create a SWF file smaller than the debug version)

That’s it! If I missed something please drop a comment!

Switch to our mobile site