Aldo is a student of Computer Engineering who enjoys app development. He is a developer for Mozilla Albania and has developed a couple of Firefox OS apps. In his free time, he practices C/C++, Java and web programming.

Aldo's articles

  1. Introducing the Nashorn JavaScript Engine

    Nashorn is a new JavaScript engine developed in the Java programming language by Oracle, released with Java 8. Nashorn’s goal is to implement a lightweight high-performance JavaScript runtime in Java with a native JVM. By making use of Nashorn, the developer can embed JavaScript in a Java application and also invoke Java methods and classes from the JavaScript code.

    Why Leave Rhino?

    Rhino is the predecessor of Nashorn. It began as a project in 1997 at NetScape and got released in 1998. Now, Rhino is the JavaScript engine that ships with Mozilla Firefox.

    There have been 16 years since the release of Rhino, and that JavaScript engine has lived its days. So the Java guys decided to have some fun by developing a new JavaScript engine from scratch instead of rewriting the existing one. This gave birth to Nashorn (fun fact: nashorn means rhino in German).

    Almost everyone here has been using JavaScript in the browser, and some have been using it on the server (like Node.js), but Nashorn is developed for another purpose. By using Nashorn the developer can perform the magic of:

    • Running JavaScript as native Desktop code.
    • Using JavaScript for shell scripting.
    • Call Java classes and methods from JavaScript code.

    The Goals of Nashorn

    When Nashorn was designed, the developers decided a set of goals for it:

    • It should be based on ECMAScript-262 Edition 5.1 language specification, and must pass the ECMAScript-262 compliance tests.
    • It should support the javax.script (JSR 223) API.
    • It should allow invoking Java from JavaScript and vice-versa.
    • It should define a command-line tool, jjs for evaluating JavaScript code in “shebang” scripts (that normally start with #!/bin/sh), here documents, and edit strings.
    • Its performance should be significantly better than Rhino.
    • It should have no security risks.

    Furthermore, no one decided that Nashorn will not include debugging and not support CSS and JavaScript libraries/frameworks. This means Nashorn can be implemented in a browser without being a nightmare.

    JavaScript in a (nut)Shell

    In order to use JavaScript in the shell by using Nashorn’s jjs tool, you should first install the JDK8, which you can download for free. To test its installation, execute:

  2. 5 of the Best Android ORMs

    If you are developing an Android application, you will likely need to store data somewhere. You may choose a Cloud service (in which case, using a SyncAdapter would be a good idea), or to store your data in the embedded SQLite database. If you take the second option, you will have to decide between writing SQL queries, using a Content Provider (useful if you want to share your data with other apps), or using an ORM.

    In this article, I will discuss some of the Android ORMs you may consider using in your application.

    OrmLite

    OrmLite is the first Android ORM that comes to my mind. However OrmLite is not an Android ORM, it’s a Java ORM with SQL databases support. It can be used anywhere Java is used, such as JDBC connections, Spring, and also Android.

    It makes heavy usage of annotations, such as @DatabaseTable for each class that defines a table, or @DatabaseField for each field in the class.

    A simple example of using OrmLite to define a table would be something like this:

  3. Native vs Hybrid App Development

    People enjoy using their smartphones because they can accomplish many things on the go. Such as reading e-mails, social networking, watching movies and plenty of other activities. We enjoy smartphones because they have many applications that make everyday activities easier.

    If you are thinking of developing for the mobile application market, an important decision is to decide between developing a native application or a hybrid one.

    It’s an age old question that refuses to go away, we thought it was time to revisit… Which is the best?

    Native over Hybrid

    Building native applications means using the native language of the platform, Objective-C on iOS, and Java on Android. The main advantage of native applications is their performance. Native apps are compiled into machine code (Dalvik byte code under Android), which gives the best performance you can get from the mobile phone.

    Best performance includes fast and fluid animations as well as full access to phone hardware, multi touch support and the latest APIs.

    Native development is far from easy. Despite the great number of resources that can be found, it may not be understandable to everyone. As code must be written specifically for each platform, the same code will have to largely be rewritten with little able to be shared. The logic may be the same, but the language, APIs and the development process is different. This process can be relatively long for complex applications.

    Going Native

    If you are new to mobile development and want to build performance-critical mobile apps and/or take advantage of native APIs, you would need a good resource on learning mobile native development.

  4. Firefox OS Game Development with the Ionic Framework, Part 2

    In the first part of this tutorial we created most of the User Interface. Now we will create its logic.

    Implementing functionality

    We want to know if the user entered the right name of the logo. In templates/logo.html view, delete the previous div that contained input field and the button, and replace it with this:

    [code language="html"]

    [/code]

    The UI won’t change, but this code makes sure that whatever the user types into the field passes to the function check() in the controller. So we now implement this function, by appending this code at the end of LogoCtrl controller:

    [code language="javascript"]
    //check if the logo name is found
    $scope.check = function(name) {
    if ( angular.isDefined(name)
    && name.toUpperCase() == $scope.logo.name.toUpperCase() )
    {
    localStorage[$scope.logo.name] = true;
    alert("Correct!");
    history.back(-1);
    }
    }
    [/code]

    Game Screenshot

    When the user enters the correct name of the logo, then a variable is stored into the Local Storage that allows us to check its value later.

    You may experience some issues with the on screen keyboard in the Firefox OS emulator. If so, try hitting backspace before typing, or if you’re lucky, get hold of a real device!

    When the user clicks a logo they’ve already played, we don’t want him to see the same ‘input logo name’ view. So we add the $location dependency to the LogoCtrl controller and this code right after img.attr('src',$scope.logo.img); at the end of $http.get():

    [code language="javascript"]//this logo has been seen before
    if (localStorage[$scope.logo.name]) {
    $location.path('/level/'+ $scope.lvl.id +'/logo-found/'+$scope.logo.id);
    }
    [/code]
  5. Firefox OS Game Development with the Ionic Framework

    I probably don’t need to talk much about Firefox OS, as many of you will know a lot about it already. If not, we have several great articles covering the topic on SitePoint, this is a good starting point.

    All you need to know for this tutorial is that Firefox OS applications are simply webapps, ergo programmed using HTML5, CSS and JavaScript.

    I am going to create a simple game, called YALG, Yet Another Logo Game.

    What do we need?

    Firstly, the Mozilla Firefox browser. Most of us don’t have a Firefox OS device, the Firefox OS emulator is a Firefox plug-in, you can find out how to install it here.

    I decided to use a framework called Ionic for this project.

    Why Ionic?

    • It is simple and has great documentation
    • It allows for cross platform development, using its Cordova-based CLI
    • It is based on AngularJS, one of the best Javascript frameworks
    • It is mobile oriented

    Starting the project

    Firstly install Ionic, you can do this by following our tutorial on Ionic. Then using Ionic CLI tool, execute:

    [code]ionic start YALG blank
    cd YALG
    ionic platform add firefoxos
    # You can add more platforms as required
    [/code]

    This creates a new Ionic blank Project with Firefox OS support (you may want to change some things in the config.xml file created by Cordova).

    Now execute:

    [code]cordova prepare firefoxos
    [/code]

    This makes your application ready to deploy to Firefox OS.

    To run the new application in the emulator, add products/firefox/www as a ‘packaged app’ and click the ‘Update’ button.

    Firefox OS setup

    You should see something like this running in the emulator:

    Ionic starter screenshot

    Now we will make some changes to the source code in the www folder.

  6. Introduction to the Firefox OS Command Line Interface

    Firefox OS (we’ll be referring to as FFOS) is a new Mobile Operating System full of potential and increasing in popularity with users and developers.

    After developing a couple of FFOS applications, I think the process could be more automated and less repetitive. There has to be a faster way to create a project than manually creating the whole directory tree and necessary files for every FFOS application.

    Inspired by Git, I decided to create a Command-Line Interface to automate the process and help other developers who like developing FFOS apps.

    What is ffos-cli?

    ffos-cli is a simple tool, developed in the C programming language. It helps you generate the entire directory tree needed for a FFOS app and more.

    It helps the developer:

    • Create a new project folder with the name of the application
    • Edit the manifest file from the command-line
    • Add source files to the project