Current Flow

Endeavours into the world of programming and electronics


Conclusions From The Microsoft Surface Keynote

I’m watching the Microsoft keynote at the same time as I write this, so if I commit any error just put it in the comments.

List of problems with the Microsoft Surface:

  • 16:9 aspect ratio
  • Confusing products (ARM and Intel)
  • No pricing confirmed

The 16:9 aspect ratio for a 10" tablet is the worst one you could ever use and still Android manufactures and Microsoft thinks it’s a great thing. It’s just impossible to feel comfortable with a 10" 16:9 tablet in your hands while in portrait and the same happens for landscape. Every time I get my ASUS Eee Pad Slider to do something I immediately want to go back to my iPad.

Having the same name for completely different products that look exactly the same is the worst thing Microsoft could ever do. They made a professional tablet, using a Intel chip, running Windows 8 Pro (another terrible name) that “might be capable” of running all those those so called “classic” applications. And another tablet that looks just the same but with a ARM chip and running Windows RT, and won’t be capable of running “classic” applications, which I’ve already discussed how it will be a nightmare on a past article.

The last thing that wasn’t presented and also haven’t talked about is the availability. I’m almost sure it won’t be available on developing nations like Brazil neither countries that don’t have Microsoft Stores.

Anyway I won’t be buying one of these because I seriously don’t care about Windows anymore, it’s boring since Windows Vista and it’s still boring, but now it will be a lot worst with all the fragmentation problems that are going to come with the release of Windows 8 and Windows RT.

Some interesting quotes I selected:

We believe that any intersection between human and machine can be made better when hardware and software are considered together.

Looks a lot like the Apple approach huh?

Take the mouse. Windows needed one, so we built one. Early reviews were not very positive — in fact, it was so new that Canadian customs quarantined it.

I won’t comment on this one.

“I say perfect a lot — it’s part of our team culture.”

I still remember Windows Vista.. Also that’s not part of your team, it’s more part of the Apple team.

We took the time to get Surface and Windows 8 right. To do something that was really different and really special. We’re proud of the Surface like we’re proud of Windows 8. Because of Windows 8, the Surface is a PC, it is a tablet… it’s something new.

Looks like a Transformer Prime running Windows 8 for me…


Using bbUI's onscreenready and ondomready to Dynamically Change Your HTML

I started playing a bit with BlackBerry development these days and since I’m not the best at Java (also hate how it’s difficult to do simple things with it) I choose their awesome framework for HTML5 native web development called WebWorks. I really loved it because it’s like PhoneGap, but a lot easier to build plugins (extensions on WebWorks) for it to make your native WebApp feel a lot more native.

Another great thing that RIM did to make the life of WebWorks developers easier and create apps that are exactly like native ones is a Javascript framework called bbUI.js, which is like jQuery Mobile, but seriously, it’s a lot more than just a UI framework. It makes it a lot easier to interact with the OS, override the back button for example, and makes your development cycle look a lot with native development by using screens. On this post I’ll teach you how to dynamically manipulate the screen’s HTML before it’s processed by the bbUI library.

One of the first things that you’ll notice after you start working with bbUI is that it’s not just a collection Javascript functions and CSS stylings, it actually reformat and customize your screen’s HTML before it’s shown to the user. As an example, this simple image-list item declaration in your screen HTML source looks like this:

After it’s processed by the library and shown to the user it will look like this:

Hopefully we can easily manipulate our screen elements and other things before and after it’s processed by bbUI. This is done with the bb.init() function (you can always read more at their documentation). This will be called when the application starts and can be used to listen to events like when a screen is loaded. The main ones are onscreenready and ondomready.

onscreenready: This event will be fired before the sources get processed by the library, so here is where you should manipulate, add or remove things from your HTML source using Javascript, so after it’s done the code will be passed to bbUI to be processed.

ondomready: This event will be fired when the screen finished loading and it has been already processed by bbUI and shown to the user. Here you can put things like alerts and other things that will be used to interact with the user, also some little editing to the screen’s source like renaming a field grabbing some information from a field and etc.

Here is a example of a bb.init() call:

bb.init({
  onscreenready: function (element, id) {
    if (id == "main") {
      // code to be executed before the "main" screen is loaded.
    } else if (id == "add") {
      // code to be executed before the "add" screen is loaded.
    }
  },
  ondomready: function (element, id) {
    if (id == "main") {
      // code to be executed after the "main" screen is loaded.
    } else if (id == "add") {
      // code to be executed after the "add" screen is loaded.
    }
  }
});

The code is almost self-explanatory. The id is the name, second argument, you gave to a screen when you call it to be processed, for example bb.pushScreen(“screen/main.html”, “main”). And element is the screen source code, which is used to be manipulated before the screen is loaded.

A little problem that some developers might come across while using bbUI for the first time is that when you want to append or change the HTML of the screen before it’s processed by bbUI you might write your code like if the HTML was already loaded onto the screen, but it’s not. Here is an example of a code that won’t work, used to populate a image-list and then show a button that was hidden (using jQuery):

bb.init({
  onscreenready: function (element, id) {
    if (id == "main") {
      var item = document.createElement('div');
      item.setAttribute('data-bb-type','item');
      item.setAttribute('data-bb-title','my title');
      item.innerHTML = 'my description';
      item.setAttribute('data-bb-img','foo.png');

      document.getElementById('mylist').appendItem(item);

      $("#button").css("display", "block");
    }
  }
});

The main problem here is that it’s using document as the source to be manipulated. Since bbUI still hasn’t appended the screen into the document it will give you an error. In order to correct this you should replace document with element, that is passed by the onscreenready event. If you have any jQuery code, just add element as a context argument as shown below in the corrected code:

bb.init({
  onscreenready: function (element, id) {
    if (id == "main") {
      var item = element.createElement('div');
      item.setAttribute('data-bb-type','item');
      item.setAttribute('data-bb-title','my title');
      item.innerHTML = 'my description';
      item.setAttribute('data-bb-img','foo.png');

      element.getElementById('mylist').appendItem(item);

      $("#button", element).css("display", "block");
    }
  }
});

That’s it! Now you know how to use the onscreenready and ondomready events to dynamically insert or modify your bbUI screen’s. Any questions or suggestions just leave a comment and I’ll reply as soon as possible.


Stephen King and eBooks

“I love crime, I love mysteries, and I love ghosts, I also loved the paperbacks I grew up with as a kid, and for that reason, we’re going to hold off on e-publishing this one for the time being. Joyland will be coming out in paperback, and folks who want to read it will have to buy the actual book.”

After Stephen King made that announced all the news sites when crazy to report it. I got the news pretty fast since my Twitter feed got flooded with the news coming from the most varied sources. When I started reading the articles about it I got shocked, how someone can do such thing in the middle of the eBook revolution? A lot of people, like me, prefer to read on eReaders than on the actual book, also there are a lot of people that prefer because it’s easier and more convenient to buy and digest the content of the eBooks.

I know that Mr. King (and Mrs. Rowling in the past too) is extremely famous and has the power to decide such thing, but letting a entire segment of the market, which was already used to your eBooks, without your new piece is just unfair. Many authors make this move because of disagreements with online stores, but those usually don’t affect well-known authors, usually just the small ones that really need to generate some revenue from their eBook sales.

eBooks seriously revolutionized the 600 years old industry. For the first time in the history we can buy books on affordable prices and with extreme comfort, this made the reading habits of many grow, which contributes to this generation to have more access to culture. Denying or delaying too much the release of an eBook is an act of denying knowledge and culture. The eBook revolution is future and in the future there is no place for paper.

Sources (to read more about the news): The Verge, BBC, LitReactor, Revolução eBook


Why You Should Start Dart'ing Right Now

With this article I hope you understand more about the Dart idea and how you can become more productive and happier as a developer of web applications by using it as your main language.

First of all here are some words, from the official site, for you to understand what Dart is:

With the Dart platform, you can write code that runs on servers and in modern web browsers. Dart compiles to JavaScript, so your Dart web apps will work in multiple browsers (not just ours).

The Dart platform includes a language, libraries, an editor, a virtual machine (VM) for both servers and browsers, and a compiler to JavaScript.

The Community is Awesome
One of the biggest advantages of Dart is the vibrating community. Since it’s still under development the developer base is very helpful and shareful too. If you’re on Google+ you’ll know almost every new project that is done using Dart, this way you have more attention on your project.

Libraries are Needed
Because it’s on it’s early stages Dart needs libraries to fulfill developers, this way you have a lot of libraries you can create, from scratch or porting from Javascript. This way you’ll be learning more, helping the community and earning respect from the community.

It’s Incredibly Easy to Create Web Applications
Since it was built by Google for web applications from scratch, it’s the perfect language for web application development. You’re not having to adapt a old language for the web revolution, you’re using a language that was built for the web revolution.

Weekly Updates
The language is under active development. Almost every single week a new build of the language, or the tools (Dart Editor and Dartium), is released. This way you can feel something that any other language can provide you today, the feel that it’s mutable and is evolving. It’s awesome when I open my Google Reader application and there is a new update on the Dart feed. I quickly download and test what’s new.

Organized Syntax
As a node.js developer I know that as you dive deeply into a complex part of your web application the code becomes a hell to understand. With the Dart syntax this is a bit more difficult, your code becomes more readable and a lot more maintainable. Also the Dart team published an awesome style guide to make your code even better for your eyes and brain.

Easy to Learn
Dart is incredibly easy to learn. There are three ways of learning Dart. If you’re already a Javascript you can learn by reading the awesome Translations from Javascript table which will show everything you must know about Dart comparing to Javascript. The second way of learning is by reading their lengthy Language Tour which will give you an in-depth look at every single aspect of the language. The third way is to learn by practicing and looking at the previous links when you don’t know how to do something or the compiler is giving you a strange error.

Those, in my opinion, are some of the key features of the awesome Dart language. I hope you give it a try and have lots of fun with it. Don’t forget to comment about your experience with Dart and your opinion about it.