Tech Per

08 Jun

What Is The Big Deal With Flex?

Are you a Java developer with the thought: “What the f*** is up with all the flex hype here in the Java camp? Is flex not just the same old closed flash world like always?”. If so, then this post is for you.

In my recent post Flex Leads to Clash Between Java and Flex Communities, I wrote that many Java enterprise developers are looking into and actually taking flex into their fold of tools and frameworks. Why is that? How has Adobe come to convince us, that flash is a good thing for websites?

Well, here is my short list of reasons for liking it.

Flex Development Is Not Like Traditional Flash Development

You do not need a closed IDE, which operates with concepts like scenes and timelines. You work with UI components and containers as you now it. Like Button, CheckBox, TextInput and Box, Form, Panel, Canvas. These are all understandable concepts, for us Java programmers. In addition to this, you define the layout in a open, easily readable and editable xml file, like this little example:


<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:ComboBox>
    <mx:dataProvider>
      <mx:ArrayCollection>
        <mx:String>AK</mx:String>
        <mx:String>AL</mx:String>
        <mx:String>AR</mx:String>
      </mx:ArrayCollection>
    </mx:dataProvider>
  </mx:ComboBox>
</mx:Application>

Working with mxml like the above, to declaratively define the UI is a nice thing. One can do it dynamically in ActionScript3 though. And what is ActionScript3 know? Well, to me, it is Javascript but coming close to a “real language” :-) in that I can add in type information, and get all kinds of nice compile time type-checks. Here is a small example of some AS3 code:


package net.techper {

  import mx.core.Container;
  import mx.controls.Button;
  import mx.events.*;

  public class MyButton extends Button {
    public function MyButton() {
      super();
    }
  }
}

Looks awfully familiar to a long time Java programmer, doesn’t it?

And did I mention. It is still just plain text files, with xml and as3 source in it. No binary, closed format, project files neccessary.

And what about building then. Adobe push Flex Builder hard, but you can do nice without it. The free SDK compiles nicely and there are several maven plugins for it too. Personally, I edit the sources with IDEA (which have basic flex support now, and getting better in the upcoming version 8), compile with maven and I like it.

You Can Apply It At The View Only

Flash shines at the client in the browser and not many other places. Adobe push their server-side framework Flex Data Services, but I see that mostly as a way for non Java enterprise developers to get started. A good Java enterprise developer eat architectures like FDS for breakfast, and as a consequence of this, can integrate their existing server-side architectures with a flex/flash frontend in no time.

After all, you can let the flex client call web-services, simple http calls, amf and even hessian services. The options are many and open.

The Output Looks Nice…Everywhere

You can do some cool stuff with the flashplayer. No doubt about it. And without doing much, the default output from flex looks nice too. If that is not enough for you, you can apply styles or complete skins, to change appearance. If that is not enough, you can inherit the Canvas component, and do you own drawing of the UI.

What is nice about this is, that it will look the same on all flash enabled platforms. And there are many flash enabled platforms.

Approachability Is Good

And with “approachability” I mean how easy it is to get started with. You download it, unpack, set your flex home, write your first example, and their you have it, your first RIA application running on flash.

Go play!

13 Responses to “What Is The Big Deal With Flex?”

  1. 1
    christian Says:

    I think comparing AS3 with JavaScript is totally wrong and it sounds as if you don’t really like it. Fair enough.

    I admit that using the flex IDE it makes it a bit difficult to design good applications. It is just too easy to just hack in something without really having to care about the code you write.

    FDS.. It is called BlazeDS now (I think..) and it makes it easy to provide remote access to your services and IMHO more important to your messaging infrastructure. Sending around some JMS messages really is fun and IMHO in modern software design all those overengineered enterprise solutions don’t really make sense (see why Spring is so spreaded).

  2. 2
    Alexander Zagniotov Says:

    Yeah. I agree with you here: Flex is a really cool thingy… At my company we chose Flex framework to create UI for our product, and I have to say it looks damn nice and the development is really easy. We use eclipse to edit the source and ant for compilation. :)

  3. 3
    polesen Says:

    @christian: Why do you think it is wrong to compare Javascript and ActionScript3? I know they are different, but they are also very much alike, isn’t they?

    By the way: It was certainly not my intention to sound like I don’t like AS3. I do! It is a nice language. Especially a nice one to do client ui in.

  4. 4
    Jacek Says:

    Well, this all looks nice and easy until you have to integrate with some nice Java server-side backend. I hear that despite BlazeDS there are a lot of integration issues, e.g. for JPA entity classes or any other Java objects that are instrumented at runtime (and most server frameworks do it in one form or another).

  5. 5
    polesen Says:

    @Jacek: Yes, this does actually look nice and easy, … because it is :-)

    There are absolutely no problems in integrating with a nice Java server-side backend. You can choose blazeds, if you want, or go without, as I have done so far, without any trouble in that. The flex client and the backed are very decoupled.

    Only thing I can think of, that could couple them a bit tighter, is if you choose to use AMF as comm protocol. Simply use web-services instead.

  6. 6
    Espresso Says:

    @christian: The comparison between AS3 and JavaScript is actually justified, since both are based on the ECMA standard. The next version of JavaScript that comes out will look very similar to AS3.

  7. 7
    christian Says:

    Personally I wouldn’t compare AS3 with JS. Sorry, I didn’t mean to attack you by this.. :) But I think they are not similar at all. Of course you can compare them, but then you must allow me to say JS and Java is also very similar, you see where I’m pointing to? ;-)

  8. 8
    polesen Says:

    @christian: “…you see where I’m pointing to?”

    Yes and no. I know Java and JS has some similarities, mostly in syntax though. So of course, I wouldn’t set them alike. One is dynamic, the other is not, for instance.

    But JS and AS3 are very alike, both in syntax and semantics, I think. I know JS has a bad name, and that was what I wanted to say in my post: That AS3 does not deserve that bad name. Though, you can still do some “shitty code” in AS3, if you omit the type-safety and use all the possibilities of the language. But that is another story.

  9. 9
    drew Says:

    It is not at all unreasonable to compare AS and JavaScript. Both are based on the same ECMA standards. In essence, they’re both implementations of that standard. So I don’t see how anyone could be considered “bashing” by pointing out the similarities.

  10. 10
    Darren Says:

    @Jacek: BlazeDS is the open-source version of the enterprise-level LiveCycleES. It’s not a replacement, but rather a cut-down free version. I’m not aware of any integration issues with either but if it’s really a problem for you, you can always use the free WebORB for Java (http://www.themidnightcoders.com/weborb/java/) to do much the same thing. Straight web services are handy but two-way communication of typed objects between Flex/Java and data-push capability is a step-up in terms of functionality.

  11. 11
    Chamo Says:

    Well for me ActionScript and JavaScript are different but still close. The only big difference is the way to use types.

    For exemple in AS you write :

    var myVar:String = new String();

    in java it would look like :

    String myVar = new String();

  12. 12
    Guy Mac Says:

    AS3 is a candidate for JS2, so they may soon end up being one and the same language.

  13. 13
    DZone weekly links #2 | Sergi Castillo Says:

    [...] What is the big Deal with Flex? [...]

Leave a Reply

© 2008 Tech Per | Entries (RSS) and Comments (RSS)

GPS Reviews and news from GPS Gazettewordpress logo