Archive for November, 2006

Grey Line

Last year each and every AJAX article was mentioning Google maps application. I see a similar pattern with Flex, but this time I’m getting a little bit sick of photo/image viewer applications. Pikeo is a recent addition to the happy FFF-family (Flex-Flash-Flickr). While there is nothing wrong with any of these photo applications, the fact that industry analysts keep using them as good examples of Flex applications gives people the wrong perception that this is what Flash/Flex are for.

Flash enjoys 98% penetration, but if you ask 99% of people who have it installed, they’ll tell you that Flash is for playing animations. The irony is that my own son has been graduated this year majoring in traditional animation, and he uses Flash exactly for creating animations. Lots and lots of people keep thinking that Flash is a tool for creating flashy but annoying intro pages for Web sites.

I personally belong to a tiny group of enterprise developers who are lucky enough to make a living by working on enterprise applications using Flex. But where is the job market for Flex developers? After a year of drumbeat, go to Dice.com. How many job opening do you find for Adobe Flex in your area? Three? Five? A dozen? You know why? Because IT development managers are STILL under impression that Flex/Flash is for creating applications that can keep their family photo-albums in order.

Dear Adobe technical evangelists, please create a serious Web site that would list case studies of BUSINESS applications written in Flex. Let’s evolve from the phase “Flex is Cool” to “Flex is Real”.

Your truly,
Yakov Fain

Comments (9)

 

Grey Line

I wonder if Adobe knows that there are (still) CS students in the USA? I was pleased to learn about the Adobe Developer Olympiad in India, but what about our kids? I’m sure that leftovers of USA computer science convicts are capable of writing a Flex applications too. Let alone a 50000 rupees prize, which is about $1000USD! For this cash, an average American student can get 2000 cans of Budweiser (if purchased in one of these wholesale clubs in bulk quantities).

Earlier this year I was reading about Adobe’s ambassador program …in Canada.

Hello, Adobe! We are right here waiving with Star-Spangler Banner!

I spend one evening a week teaching Adobe Flex at New York University, and will run another class in April. I hope some other colleges have Flex in their programs too. Would love to hear from Adobe about their efforts on promoting Flex in American colleges.

Yakov Fain

Comments (7)

 

Grey Line

Flex compiler builds an swf file, with a default frame rate of 24 frames per second, unless another value is specified during the compilation. For example,

mxmlc -default-frame-rate=50 HelloWorld.mxml

This command will build the swf file with the frame rate of fifty frames per second. Display list rendering and the ActionScript execution take turns, hence the frame rate can affect your application performance.
Setting the frame rate to fifty does not mean that each frame will be displayed in exactly 20 milliseconds, as there is some OS/browser overhead. Besides, some browsers may impose restrictions on plugins to lower CPU utilization on the user’s machine.

To see how the compile time setting of the default-frame-rate option affects execution of the program let’s write a small application that on each enterFrame event performs a simple calculation of the actual frame rate.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”horizontal”
enterFrame=”enterFrameHandler()”>
<mx:Script>
var lastTime:int;
function enterFrameHandler():void {

trace(int(1000/(getTimer()-lastTime)));
lastTime=getTimer();
}
</mx:Script>
<mx:Button label=”Button”/>
<mx:TextInput/>
</mx:Application>
I ran this program on a Windows XP laptop with a single 1.8Ghz CPU in the Internet Explorer and FireFox browsers. Tables 1 and 2 show the difference between requested and actual frame rates and how hard the CPU works based on the frame rate settings.

default-frame-rate 10 24 50 100
Actual frame rate 9-10 18-26 35-52 50-110
CPU utilization 15-17% 15-20% 18-20% 26-28%

Table 1 Frame rates with Internet Explorer 6

default-frame-rate 10 24 50 100
Actual frame rate 9-10 16-22 41-50 70-100
CPU utilization 16-20% 18-20% 22-25% 30-33%

Table 2 Frame rates with FireFox 1.5

While results slightly vary, they are self explanatory – lower frame rates translate into lower CPU utilization. You should experiment with frame rate in your application to find the right balance between the GUI performance and CPU usage.

Remember, your users may be running several programs at the same time, and you do not want to put their CPU on its knees just because you’ve enjoyed super smooth graphics rendering. If you are not creating a movie, keep the frame rate as low as you can.

Yakov

Comments

 

Grey Line

As much as I like Flex, its five-hundred dollars tool has a LOT of room for improvements. I’m sure, Flash developers who did not see any better are happy with Flex Builder, but I came from Java World where excellent and free compilers and IDEs are the norm of life.

My main complain is that it’s extremely slow. Just to be fair, I need to acknowledge the fact that Flex compilers have to work much harder than their Java peers, because they need to perform additional duties like conversion of MXML to ActionScript, generation of the event listeners MXML components, binding support… But still, I want it to work faster.

How good is an incremental compilation if a recompile of a pretty simple application after changing the width of a label takes 20 seconds (I use 1.6Ghz laptop with 1.25Gb of RAM)? You call this incremental? Please…
I was hoping that adding -incremental=true as an additional compile option would help. No difference, and documentation helpfully explains that this option is already turned on by default in Flex Builder.

I’ve been using Eclipse with my Java programs for years and I did not know that I have to close projects that are not used at the moment. Now I know that if I won’t do this, Flex Builder will be even slower than it is now.

I never knew before that I may need to play with the heap size parameters and request more memory (xMs and xMx) for this memory addict.

mxmlc compiler is written in Java and comes as mxmlc.jar, which implies that you have to have Java Runtime Environment installed…and Adobe provides a four years old JRE of version 1.4. I guess they did not know that Java 5.0 was released more than two years ago. But it’s not that bad, you can install the fresher JRE on your own and reconfigure Flex Builder on your own to use it. But why ship a product in 2006 with an old JRE in the first place?
What about code refactoring that existed in Eclipse for years?

Oh, well you can’t get blood from a stone. If someone would ask me, “Name the most important improvement that Flex 2 needs badly”, I’d say, “Take care of Flex Builder. Now.”

Yours truly,

Yakov Fain

Comments (25)

 

Grey Line

Last year I started a column at Java Developers Journal about a Java programmer who bought a gas station and is trying to find the best tools for automation of this small business. In the sixth article of this series I introduce Adobe Flex for writing a GUI part of my Java application. Below are the links to all these articles.

gas station 1- Small Business Solutions, July 2005
gas station 2 – Dealing with Open Source Software, September 2005
gas station 3 – Web Frameworks and IDE in Java, October 2005
gas station 4 – Hangover thoughts about Web and Ajax, December 2005
gas station 5 – Look mom, no applications servers, look MOM!,April 2006
gas station 6 – Creating a flashy monitoring application, November 2006

Yours truly,
Yakov, a proud gas station owner

Comments

 

Grey Line

Below is a short comparison table of major elements/concepts of these two languages for a quick reference.

You can read this table either left-to-right or right-to-left, depending on what’s your primary programming language is today.

This list is not complete, and your input is appreciated.

Concept/Language Construct

Java 5.0

ActionScript 3.0

Class library packaging

.jar

.swc

Inheritance

class Employee extends Person{…}

class Employee extends Person{…}

Variable declaration and initialization

String firstName=”John”;

Date shipDate=new Date();

int i;

int a, b=10;

double salary;

var firstName:String=”John”;

var shipDate:Date=new Date();

var i:int;

var a:int, b:int=10;

var salary:Number;

Undeclared variables

n/a

It’s an equivalent to the wild card type notation *. If you declare a variable but do not specify its type, the * type will apply.

A default value: undefined

var myVar:*;

Variable scopes

block: declared within curly braces,
local: declared within a method or a block

member: declared on the class level

no global variables

No block scope: the minimal scope is a function

local: declared within a function

member: declared on the class level

If a variable is declared outside of any function or class definition, it has global scope.

Strings

Immutable, store sequences of two-byte Unicode characters

Immutable, store sequences of two-byte Unicode characters

Terminating statements with semicolons

A must

If you write one statement per line you can omit it.

Strict equality operator

n/a

===

for strict non-equality use

!==

Constant qualifier

The keyword final

final int STATE=”NY”;

The keyword const

const STATE:int =”NY”;

Type checking

Static (checked at compile time)

Dynamic (checked at run-time) and static (it’s so called ‘strict mode’, which is default in Flex Builder)

Type check operator

instanceof

is – checks data type, i.e. if (myVar is String){…}

The is operator is a replacement of older instanceof

The as operator

n/a

Similar to is operator, but returns not Boolean, but the result of expression:

var orderId:String=”123”;

var orderIdN:Number=orderId as Number;

trace(orderIdN);//prints 123

Primitives

byte, int, long, float, double,short, boolean, char

all primitives in ActionScript are objects.
Boolean, int, uint, Number, String

The following lines are equivalent;

var age:int = 25;

var age:int = new int(25);

Complex types

n/a

Array, Date, Error, Function, RegExp, XML, and XMLList

Array declaration and instantiation

int quarterResults[];

quarterResults =
new int[4];

int quarterResults[]={25,33,56,84};

var quarterResults:Array
=new Array();

or

var quarterResults:Array=[];

var quarterResults:Array=
[25, 33, 56, 84];

AS3 also has associative arrays that uses named elements instead of numeric indexes (similar to Hashtable).

The top class in the inheritance tree

Object

Object

Casting syntax: cast the class Object to Person:

Person p=(Person) myObject;

var p:Person= Person(myObject);

or

var p:Person= myObject as Person;

upcasting

class Xyz extends Abc{}

Abc myObj = new Xyz();

class Xyz extends Abc{}

var myObj:Abc=new Xyz();

Un-typed variable

n/a

var myObject:*

var myObject:

packages

package com.xyz;

class myClass {…}

package com.xyz{

class myClass{…}

}

ActionScript packages can include not only classes, but separate functions as well

Class access levels

public, private, protected

if none is specified, classes have package access level

public, private, protected

if none is specified, classes have internal access level (similar to package access level in Java)

Custom access levels: namespaces

n/a

Similar to XML namespaces.

namespace abc;

abc function myCalc(){}

or

abc::myCalc(){}

use namespace abc ;

Console output

System.out.println();

// in debug mode only

trace();

imports

import com.abc.*;

import com.abc.MyClass;

import com.abc.*;

import com.abc.MyClass;

packages must be imported even if the class names are fully qualified in the code.

Unordered key-value pairs

Hashtable, Map

Hashtable friends = new Hashtable();

friends.put(“good”,
“Mary”);

friends.put(“best”,
“Bill”);

friends.put(“bad”,
“Masha”);

String bestFriend= friends.get(“best”);

// bestFriend is Bill

Associative Arrays

Allows referencing its elements by names instead of indexes.

var friends:Array=new Array();
friends["good"]=”Mary”;

friends["best"]=”Bill”;

friends["bad"]=”Masha”;

var bestFriend:String= friends[“best”]

friends.best=”Alex”;

Another syntax:

var car:Object = {make:”Toyota”, model:”Camry”};

trace (car["make"], car.model);

// Output: Toyota Camry

Hoisting

n/a

Compiler moves all variable declarations to the top of the function, so you can use a variable name even before it’s been explicitly declared in the code.

Instantiation objects from classes

Customer cmr = new Customer();

Class cls = Class.forName(“Customer”);

Object myObj= cls.newInstance();

var cmr:Customer = new Customer();

var cls:Class = flash.util.getClassByName(“Customer”);
var myObj:Object = new cls();

Private classes

private class myClass{…}

There is no private classes in AS3.

Private constructors

Supported. Typical use: singleton classes.

Not available. Implementation of private constructors is postponed as they are not the part of the ECMAScript standard yet.

To create a Singleton, use public static getInstance(), which sets a private flag instanceExists after the first instantiation. Check this flag in the public constructor, and if instanceExists==true, throw an error.

Class and file names

A file can have multiple class declarations, but only one of them can be public, and the file must have the same name as this class.

A file can have multiple class declarations, but only one of them can be placed inside the package declaration, and the file must have the same name as this class.

What can be placed in a package

Classes and interfaces

Classes, interfaces, variables, functions, namespaces, and executable statements.

Dynamic classes (define an object that can be altered at runtime by adding or changing properties and methods).

n/a

dynamic class Person {

var name:String;

}

//Dynamically add a variable // and a function

var p:Person = new Person();

p.name=”Joe”;

p.age=25;

p.printMe = function () {

trace (p.name, p.age);

}

p.printMe(); // Joe 25

function closures

n/a. Closure is a proposed addition to Java 7.

myButton.addEventListener(“click”, myMethod);

A closure is an object that represents a snapshot of a function with its lexical context (variable’s values, objects in the scope). A function closure can be passed as an argument and executed without being a part of any object

Abstract classes

supported

n/a

Function overriding

supported

Supported. You must use the override qualifier

Function overloading

supported

Not supported.

Interfaces

class A implements B{…}

interfaces can contain method declarations and final variables.

class A implements B{…}

interfaces can contain only function declarations.

Exception handling

Keywords: try, catch, throw, finally, throws

Uncaught exceptions are propagated to the calling method.

Keywords: try, catch, throw, finally

A method does not have to declare exceptions.

Can throw not only Error objects, but also numbers:

throw 25.3;

Flash Player terminates the script in case of uncaught exception.

Regular expressions

Supported

Supported

Thanks,

Yakov Fain

Comments (19)

 

Grey Line

As any software developer I enjoy working with cool components, and Flex is definitely cool. I also know that Adobe is not a philanthropy firm – they need to make money to stay in business.

Most of Adobe presenters never forget to remind that Flash is ubiquitous (I did not hear this word before applied to any software). There is another ubiquitous product – Microsoft Windows. From the business point of view, the difference between the two is that MS sells Windows, while Flash Player is free, which is great for everyone but Adobe.

There is another company, Sun Microsystems that has ubiquitous free software called Java. While Sun earns its revenues from installing Java in mobile devices, the rest of Java is primarily used to sell servers for free JVMs to run. This does not apply to Flex as Adobe does not sell hardware. It does sell professional services. So I assume Flex can bring more consulting gigs to Adobe, but lots of other independent vendors will compete in this space as well.

Almost forgot about yet another ubiquitous free software: Google search. But these guys sell advertisements.

What would you feel if a couple of guys took the free tool that you’ve created and in no time made $1.65B? You do not have to answer. Adobe can be proud of Flash Player… Recently, four senior people including the primary co-creators and architects of Flash Player and ActionScript left Adobe and created a startup… Why? Adobe is a profitable company, Flex is cool, Flash Player 9 is hot, Apollo is coming soon. I can only guess that they also want to capitalize on these great free tools, and it’s easier to do outside of the firm. CFO of the company resigns. For the same reason?
Selling Flex Data Services licenses and professional services will bring in some cash, you can add some peanuts from Charting components, Flex Builder and training. Adobe has excellent software engineers in Flex team. But it’s an open market, and in a year or sooner, other firms will come up with open source or cheaper alternatives to FDS, charting or Flex IDE. What’s left? The mobile devices.
So does ubiquity spells cash? Flash Lite to the rescue!
Yakov

Comments (12)

 

Grey Line

I have been watching browser statistics on our company sites lately – they were quite accurate of being able to predict the browser usage for 1.5 years ahead of time for general population – and Mozilla accounts for about of 55% of the hits.

That is the time the FLexzilla suppose to be released in the wild. Also, within 9 month, Apollo have to be released with similar functionality – joining Web and Flash functionality in a single, small network application platform. Compatibility will be crucial , with an ability to run the same code base, with or without Apollo extension (disconnected mode, pocket server, etc.).  If done right, performance would further drive adoption rate for Mozilla. And Flash as XUL platform will give Mozilla necessary advatage in terms of richness and performance. That is all for greater good of humans.

What does it mean for developers like you and me?

First things that really scares me: JavaScript and ActionScript are not that compatible. The main difference – interpreted vs compiled really affects the way you code.

It took me 6 month to get used to missing eval() – and in the end in our Flex apps we have an ability to send arbitrary ActionScript to server, compile it and execute it on the client – within subsecond.

It takes a lot of discipline to use strongly typed variables. Put JavaScript, Flash and Flex developer together  and ask them what is typeof x where var x = new Date();  You are going to hear Object, Number and Date – and all of them are right. You keep asking ” is x + 1 a valid expression” and will hear Yes from JavaScript person and No from ActionScript3 one.

In terms of programming style – you can not live without dynamic closures in JavaScript, I am still to see compatible implementation in the ActionScript.   In the end of the day some changes and sacrifices will be made and we will get truly rich dynamic language out of ActionScript. I believe there are some lessons in obscure PowerScript syntax that can be applied here – but I am sure Adobe is looking into it already.

On the bright side, with release of AS parser, bytecode and minimal code generator it is probably a matter of little time till we would have evals compiler written completely in ActionScript. We would probably revisit the project I mentioned above and see the cost of full client-side implementation along with bytecode generation (interestingly enough, we started  our pre-compiler JavaScript grammar and worked it up to ActionScript one – so we pretty much saw most of the underwater issues there). Anyone interested in participating in opensource implementation of that please contact me offline.

It’s going to be another fun year and a half, with a lot of opportunities and new ideas.

Sincerely,

Anatole Tartakovsky

Š

Comments (1)

 

Grey Line

We earn our living at Farata Systems by selling Flex/Java consulting services and training. While doing this, every now and then we create reusable components, and so far we are giving them away for free. Some pathetic bloggers call this ‘giving back to the community’. We look at it simple: if we do not have time to productionize a component, we donate it.

These days some people are trying to sell Flex item renderers: they create a list-based control with a custom renderer and immediately put a price tag on it. I wish them good luck in selling these toys.

But I’m talking about real stuff here. For example, we’ve created an open source component called DAOFlex. Just enter “Select * from customers”, provide parameters of the Java EE data source, and go and make yourself a cup of coffee… if you can do it in 20 seconds. Because this is how long it takes DAOFlex to create all artifacts in Java, MXML, ActionScript and XML required for deployment of a FLex DataGrid with complete CRUD functionality.

Very proud of ourselves, we’ve uploaded this DAOFlex to Flex components exchange, and it quickly became one of the most downloadable Flex open source components…and then we started receiving lots of emails asking for tech support. Yes, we’ve provided instructions on how to install it. Yes, we’ve written an article about this component. Our upcoming Flex book has a chapter explainin how to create such components. All this is not enough – people need tech support. Some of them do not bother reading instructions – for them it’s easier to send an email asking for help.

Then, we’ve given away our logger component for free.

Now we have another one – we call it a supergrid, or a reporting component FlexBI. If you want to see a real power of DataGrid, do us a favor and spend 30 minutes watching this WebCast based in our recent presentation at MAX 2006. If there are PowerBuilder developers in the audience, think DataWindow-like reporting.
Just watch the webcast now….I’ll wait. Is it cool or what?

You can create a complex report populated with the data from a database in less than a minute. Then an end user can manipulate the data using drag-an-drop interface, create grouping, filters, write formulas on the fly… Raise your hand if you know how to write a program in any language that allows an end-user write and execute dynamic formulas (I’m not talking about selecting from a predefined list of sum, min, max and the like). Want to export the data to MS Excel? No problem.
The funny thing is that we are afraid of giving away FlexBI for free. We do not have enough resources to answer tech support questions. We are still debating if we should charge for FlexBI, which saves A LOT of time to any developer who needs to create ad hoc reports for business users. Actually, power users can create their reports themselves with FlexBI.

FlexBI

Anyway, if you’ll see a price tag on FlexBI, it means that we’ve hired a tech support person, and someone has to pay his/her salary. We need to move on – Apollo is looming, and we have lots of new ideas.

Yakov

Comments (24)