miércoles, 27 de febrero de 2013

Questions and Answers

On May 30th 1832, the mathematician Évariste Galois[1][2] wasted all the courage that he was able to gather during his young life, dying that morning being only 20 years old. Since then, many of us have cried his lost.

During his short life, he was able to solve one of the long-standing problem of those days, finding the necessary and sufficient condition for a polynomial to be solvable by radicals.

But moreover, he taught me with the passion for the quest of σοφία, challenges and enigmas, stating which should be the contribution of the greatest minds: questions, not answers[3]:
C'est que malheureusement on ne se doute pas que le livre le plus précieux du plus savant serait celui où il dirait tout ce qu'il ne sait pas, c'est qu'on ne se doute pas qu'un auteur ne nuit jamais tant à ses lecteurs que quand il dissimule une difficulté.
Since that moment, I have loved the questions and the science ways which bring you to the unknown. My own Heart of Darkness.  By the way, nowadays, you have to seek deep before to find great questions. However, for those still aiming for fun, I hear that The Geometry of Biological Time, it is one of the greatest references using questions as argument.

And for that reason, I always have thought that having kids is the best way to innovate, to keeping oneself alive. And always coherent with my thoughts, I am the proud father of three; I am sure you agree with me that those are questions enough: children are also the gold mine of the questions.

Unfortunately, instead write down their questions, most of the time, parents and guardians jump directly to answer, the best, or to complain due to insistence of the wondering kids, the worse. We should mine them carefully, gathering each of their questions, tasting their learning, enjoying every of their wonders.

Knowledge is a matter of adults, and misknowledge a limitation of kids. Do know is so important that we lack the leaning process often, a critical skill in a dynamic society. Therefore, it was sad to find an orgy of answers in TheEdge: just one question per year, and many, too much, answers.

Hence we should honour Socrates, all times maieutics hero, searching for the questions.
Finally before to end, let me share with you one of the most beautiful questions I got, many time ago.

It was almost summer, and I was student in the Computer Science School. As part of my curricula there, I was learning about pseudorandom number generators, based on linear congruential generator, as a way to implement hash functions used by compilers to create symbol tables. I was following, the dragon´s book (Aho, Sethi and Ullman) one of the better references for the subject. And suddenly, it appeared in front of me: in order to avoid collision of the hash function, we should know:
What is the distribution of the primes numbers?
In spite of the interest of the answer, you should better believe me, finding the question was really great.

jueves, 21 de febrero de 2013

Fibonacci got a new BB10 smartphone

Last January, RIM introduced Blackberry 10, its new mobile operating system. Few days after, I was attending Blackberry Jam Europe 2013, in Amsterdam. During a couple of days, several hundreds of developers met at the conference, discovering new features, case studies and trends introduced with the new mobile platform.

Motivated with this new technology, I decided to program a simple application for the new operating system. This post explains a little bit about the experience, describing the application and some parts of the code. As always, you can find the source code in my GitHub account, released with Apache 2.0. The project was a simple game, called SmartSeq. The game challenges the user with a sequence of letters, letting the user to guess the intrinsic pattern.
As part of the game, I programmed three different sequences:
  • Natural sequence: abcdefghi.....
  • Even sequence: acegik....
  • Fibonacci sequence: aabceh....
Nonetheles it can be extended very easily with other mathematical sequences. In addition, to be more complete, the game should include offline storage of the scores, and some social integration. However, the initial release is enough to evaluate the development environment for BlackBerry 10.

Programming UI with Cascades

Cascades is a new framework, based on Native SDK and using Qt Libraries. The QNX Momentics IDE allows developers to create great user interfaces, highly integrated with C++ code. User Interfaces are programmed using QML, standing for Qt Modeling Language. Basic UI looks like this:

import bb.cascades 1.0 

// creates one page with a label 
Page {   
    // Binding with c++ code   
    property alias sequenceText: sequence.text 

    // Basic container declaration   
    Container{     
       layout: StackLayout {}
       horizontalAlignment: HorizontalAlignment.Fill     
       verticalAlignment: VerticalAlignment.Fill   
     } 
}

You can take a look of the whole code here. Basically, the user interface includes some labels for information output and two input fields: a text field and a button. You have an UI diagram below:


Only it is worth to mention the way Cascades binds QML objects with C++ code.  Fields are published in QML simply coding at the QML file:

property alias sequenceText: sequence.text 
property alias scoreText: score.text 
property alias clueText: clue.text 
property alias answerText: answer.text 
property alias answerEnable: answer.enabled

Then, you can read / write values from these fields from C++ simply coding: 

_root->setProperty("clueText",_clue_format.arg(initialSeq)); _root->setProperty("sequenceText",_sequence); _root->setProperty("scoreText",QString("%1 pts").arg(_score)); Do publish

variables/objects in C++ code is simple. That makes them accessible from QML. You only have to code:

// create scene document from main.qml asset 
// set parent to created document to ensure it exists for the whole application lifetime 
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); 

// create root object for the UI 
_root = qml->createRootObject(); 
qml->setContextProperty("SmartSeq",this);

Logic with pure C++

Regarding underlying logic,  all is C++ code. In the case of our game, it is pretty simple. You can find all the declaration at SmarSeq.hpp file. The class diagram is below:

Finally, the three methods from SmartSeq.cpp
  • SmartSeq::startGame
  • SmartSeq::updateGame
  • SmartSeq::resetGUI
implement the dynamic behavior of the game. As you can see, if you would like to extend the game, only have to implement the virtual class Game with another funny sequence.

Conclusions

Honestly, I have found the new framework very interesting. I have to say that my mother programming language is C++, so there are many common ideas which are part of my developer bagage. However, for most of the mobile developers, coming mainly from existing platforms and web programming, this new languages and frameworks can mean high entry barriers. Luckily, they have alternative ways to take advantage of their knowledge in HTML5, Java or Android.

In any case, the documentation, code snippets and IDE (an Eclipse customised) are very appealing. In addition, QNX is a real operating system, without many of the limitation you can find in other customized mobile platforms. My feelings are that all of this could help Blackberry to engage an even bigger developer community.

My only concern is that you will need to pay a VMware Fusion license to use the BB10 simulator. Even though it is a cheap software, it could introduce an unnecessary entry barrier. However, maybe that is precisely what Blackberry is looking for: developers who are willing to pay.

So congrats Blackberry team.

You have done a very good job. 
 

viernes, 15 de febrero de 2013

Book Review: jQuery Mobile

jQuery Mobile
This is one of those books where you can find an easy way to start with a new technology. They have to be easy enough, settling the base for the new playground. At the same time, they should include bread crumbs which bring you to more challenging projects.

jQuery is the one most successful programming frameworks for the web, becoming a facto standard. Its mobile release, jQuery Mobile, is helping thousand of web developers in a seamless migration to mobile programming. HTML5-based and supporting many mobile browsers, jQuery Mobile allows developers to program nice and effective user interfaces.

Concerning the book, the first two chapters, The mobile platform and Starting with the framework are the basic for those developers new to jQuery. In any case, both can be read very fast, and you can find always interesting details even if you have experience programming. Nonetheless you have also a fast track starting at chapter 3, UI Components. Altogether with chapter 4, List, and chapter 5, Form components, they forms the core of the user interface programming with jQuery Mobile. If you are familiar with HTML5 programming, web apps and Javascript, these chapters is all what you need to know about fundamentals of jQuery Mobile. Those interested on event handling and more advanced features should read also chapter 6, The Framework and JavaScript, chapter 7, Creating Themes, and chapter 10, Extending the Framework.

Finally, the book contains also a bunch of interesting chapters completing all what you need to create, deploy and distribute your own webapp. This useful information can be found in chapters 8, Installation and Offline Access, chapter 9, A complete WebApp, and chapter 11, Packaging for Stores.

Therefore, despite its basic approach, I found the book highly recommendable for new programmers or jQuery newbies. As part of my reading, I was playing, programming some code which can be found in my Github account. You can reuse it following Apache 2.0 license.

Disclaimer: I know Maximiliano Firtman since 2011, when I was speaking about BlueVia in the conference Adobe en Vivo Buenos Aires. From then, we are been collaborating in other projects, and his advice and experience about developers communities in LATAM, and deep knowledge about mobile and web technologies, has been always very useful.



sábado, 2 de febrero de 2013

Book review: In Praise of Slow

In Praise of Slow
Well, I am not sure about who, but someone recommended this book.

And, unfortunately, I decided to start to read it a couple of weeks ago. Maybe I was looking for a peaceful experience or some deep thoughts, but the truth is that I was unable to find more that a bunch of non connected anecdotes. Making the things even worse, the book seems to try to feed the reader's fears,.. Therefore I realized very fast that the book was not worth.

From my point of view, even though the topic would be very interesting, I think it deserves better treatment, maybe more formal... Finally sometimes, a boring book contains at least good references, though, this is not the case either.

Therefore, you should not waste your time reading this book, even if you are not in a hurry. Just relax reading better books.