Monday, November 3, 2008

QWETTY keyboard in new MacBooks?




Yestetday I noticed something funny about a new MacBook I bought fot my mom. It featutes a new type of keyboatd layout: QWETTY. I am sute I head about this new featute Steve Jobs’ keynote.

Who needs stupid the stupid “R” anyway (you can always find it in the chatactet palette). At least that’s what I am telling to my mom.

Note: Thanks to the folks at Apple Stote. They changed the computet without ttouble, and we all had a fun time with the stoty.

Thursday, June 19, 2008

From Java to ActionScript 3 - Part 1

I have been a dedicated Java developer for over 5 years. Not only that, but I consider myself a Java enthusiast. For several reasons, however, I have decided to start a project in ActionScript 3 using Flex Builder 3.

I consider valuable to share my impressions on the transition between the languages. Therefore, in this series of posts I will be writing about my experience with ActionScript. I will also comment on the differences between the development tools for Java in Eclipse and Flex Builder, as they both use the Eclipse as an underlying technology.

Before I start, however, I should note that both Java and ActionScript 3 have their on strengths and weaknesses and I consider both of them amazing technologies. I will try to be as objective as possible to avoid sinking in "religious" arguments. Also, in this series of articles, I will refer just to ActionScript 3, not the previous versions of the language, as I have no experience using them. Therefore, whenever I refer to ActionScript (or AS) I will be talking about ActionScript 3.

In today's post I will refer to some impressions about the development environment. For ActionScript and Flex I am using Flex Builder 3. For Java, I am using Eclipse Ganymede.

Let's start.

FlexBuilder Performance

The compiler for Java in Eclipse if far faster and provides better feedback than the ActionsScript 3 compiler. For instance, in Java it underlines the syntax errors and provides quick fixes as you type. FlexBuilder, on the other hand, only compiles when you save a file and just indicate the line of the error and does not give any quick fixes. The most annoying thing, however, is the speed. With a medium size project, the saving can take several seconds in my machine (Mackbook pro with 1.5Gb of RAM) which is really bud. I seriously hope that adobe improves this in the future.

Refactoring

Refactoring for AS is still in diapers. Basically, the only tool that they offer is Rename. Java, on the other hand, has very sophisticated refactoring tools, making this process a pleasure.

Documentation

Documentation in AS is more enjoyable to use than Javadoc. The template of ASDoc looks better than Javadoc. But the differences goes beyond that. In the bottom of each documentation page, there is space for comments and examples. Furthermore, many AS examples contain flash apps embedded on them, showing the running code of the examples. This is very rare in Java, except in the applets tutorial, and they are too slow to load to make them practical.

Interface design

Design view It works amazingly. This, together with the binding capabilities, make the creation of UI a pleasure in Flex. You can drag and drop the elements and see the final result right away. The layout behaves just as you expect, so you don't have to struggle with the layout manager for hours as with Swing.

However, it is a shame that you don't get previews of custom components (unless you extend a normal component).

More to come..

In the next part of my review, I will talk about language features including how I began to love closures and how much I miss abstract classes. Stay tuned and don't forget to leave your comments!

Tuesday, June 17, 2008

Java Search box

Today I have added a new custom search box in my page that will automatically search for things related to Java. Give it a try. For example, if you type the name of a class, you will get the Javadoc documentation and other related content.

Happy search!

C. A.

Monday, June 16, 2008

Easily picking email addresses at webmail services

Do you have more than one email account at gmail, yahoo or any other mail web service? Most of us do. For instance, I have one account for my personal stuff and one for joining mailing lists. This is a good idea, since I don't want all the messages from mailing lists to clutter my personal inbox and occupy space in my account.

Occasionally, I open an account for an specific purpose, like a project. If you have tried this, you know that it is difficult to pick a new address that is available. Most of the time, you end up adding numbers to it, or putting funny names. This addresses become quite difficult to remember. So I came with a simple solution, borrowing ideas from the way DNS work.

I consider my email address as a base prefix. Lets suppose that my address in name@somemail.com (this is an address I just made up, by the way, so don't send spam to it...). Now, lets suppose that I want to create an account for my mailing lists as a developer. Then, I will open an account name.developer@somemail.com. Later, if I want another addres for a project, I can create name.projectblah@somemail.com.

Most people don't use dots in their addresses, so it is very unlikely that this addresses are taken. The addresses are also easy to remember as they all share my base address as a prefix.

You can also take the concept a little bit farther and add even further levels for your account name. For instance, for managing bugs in the project, I could create name.projectblah.bugs@somemail.com, but this is probably too much.

This is a simple idea that anyone can apply.

See you next time,

C.A.

Saturday, May 3, 2008

JavaFX curly brace overdose

Have you seen code examples from JavaFX script? The language is very interesting. It contains many new features that may revolutionize the way people create user interfaces in Swing, such as triggers and binding. But one thing that always bothers me about the code examples that I have seen is the insane amount of curly braces that they have to use. Check out this example taken from James Weaver's Java FX blog:


/*
*  TetrisMain.fx - The main program for a compiled JavaFX Script Tetris game
*
*  Developed 2008 by James L. Weaver (jim.weaver at lat-inc.com)
*  to serve as a compiled JavaFX Script example.
*/
package tetris_ui;

import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;
import tetris_model.*;

Frame {
  var model = TetrisModel {}
  var canvas:Canvas
  width: 350
  height: 500
  title: "TetrisJFX"
  background: Color.LIGHTGREY
  content:
    StackPanel {
      content: [
        Canvas {
          content: [
            ImageView {
              image:
                Image {
                  url: "{__DIR__}images/background.jpg"
                }
            },
            Text {
              transform: bind [
                Translate.translate(30, 350),
                Rotate.rotate(290, 0, 0),
              ]
              content: "Game Over"
              fill: Color.WHITE
              opacity: bind if (model.timeline.running) 0
                            else 1
              font:
                Font {
                  face: FontFace.SANSSERIF
                  size: 60
                  style: FontStyle.BOLD
                }
            }
          ]
        },
        BorderPanel {
          center:
            FlowPanel {
              alignment: Alignment.LEADING
              vgap: 10
              hgap: 10
              content: [
                Canvas {
                  content:
                    TetrisPlayingField {
                      model: model
                    }
                }
              ]
            }
          right:
            GridPanel {
            var sansSerif24 =
              Font {
                face: FontFace.SANSSERIF
                size: 24
                style: FontStyle.BOLD
              }
              rows: 2
              columns: 1
              cells: [
                BorderPanel {
                  top:
                    FlowPanel {
                      vgap: 10
                      alignment: Alignment.LEADING
                      content:
                        Label {
                          foreground: Color.LIGHTBLUE
                          text: "NEXT:"
                          font: sansSerif24
                        }
                    }
                  center: 
                    Canvas {
                      content:
                        TetrisNextShapeNode {
                          model: model
                        }
                    }
                },
                BorderPanel {
                  top:
                    Label {
                      foreground: Color.LIGHTBLUE
                      text: "SCORE:"
                      font: sansSerif24
                    }
                  center:
                    FlowPanel {
                      alignment: Alignment.TRAILING
                      content:
                        Label {
                          foreground: Color.LIGHTBLUE
                          text: bind "{model.score}"
                          font: sansSerif24
                        }
                    }
                }
              ]
            }
          bottom:
            FlowPanel {
              alignment: Alignment.CENTER
              content: [
                Button {
                  text: bind
                    if (model.timeline.running)
                      "Stop"
                    else
                      "Play"
                  action:
                    function():Void {
                      if (model.timeline.running) {
                        model.stopGame();
                      }
                      else {
                        model.startGame();
                      }
                    }
                },
                Button {
                  text: "Rotate"
                  enabled: bind not model.stopDropping
                  action:
                    function():Void {
                      model.rotate90();
                    }
                },
                Button {
                  text: "Left"
                  enabled: bind not model.stopDropping
                  action:
                    function():Void {
                      model.moveLeft();
                    }
                },
                Button {
                  text: "Right"
                  enabled: bind not model.stopDropping
                  action:
                    function():Void {
                      model.moveRight();
                    }
                }
              ]
            }
        }
      ]
    }
  visible: true
  onClose:
    function():Void {
      System.exit(0);
    }
}


Wow... that code looks like a tower. So here goes a crazy idea: what if JavaFX Script used the same strategy as python: use the indentation to avoid the need of curly braces. Also, perhaps a different indentation scheme can help.

What do you think about the looks of JavaFX?

Thursday, May 1, 2008

Java 6: compile once, run nowhere?

Java's strength is supposed to be "compile once, run everywhere". This  claim is true in most of Java 1.4 and 5.0 applications. But what about Java 6? Is Java loosing it's most important property? 

Java used to be the prime choice for creating applications that can run in any platform. But if you want to take advantage of the latest additions in the Java 6.0 release of the platform, you will probably face a big disappointment at distribution time.  The main problem is that most users don't have the correct version of Java in their system. In a word, it is a big pain for most users to update the Java Runtime Environment. In the case of Windows, whenever you update Java, it will add a new version to the machine, so after a while, a user will find 4 or 5 different versions of the JRE in their systems. Each download is big and slow. I am not familiar with the case of linux, but for the distributions I have tried, Java 5 is installed by default. Finally, just this week Apple announced the availability of Java 6.0 for MacOS X Leopard with support for just 64 bit Intel processors. 

Are we stuck with Java 5.0 to be sure we can deliver an application that any user can use? I would love to hear your opinion.

Like this post? Digg it!