html


¿Son las apps una chapuza temporal?

mobile_appsSé que esto es tirar piedras contra mi propio tejado ya que yo me gano la vida gracias sobre todo a aplicaciones Android, pero no puedo dejar de pensar que el fenómeno de las apps móviles me recuerda a lo que pasaba hace 10 años en los ordenadores de escritorio, cuando teníamos que descargar una aplicación para Windows, otra para Mac… substitúyase esto por Android, iOS y Windows Phone… sí señor, aplicaciones de escritorio, ¿a que suena rancio?

¿Y por qué Google, que se supone tiene a los mayores expertos en web del mundo apoyó Android cuando tenía un sistema operativo basado en web como ChromeOS? Para mi la respuesta es que la web móvil no estaba preparada y los navegadores móviles no conseguían la suficiente potencia para simular una experiencia nativa. Y es que a día de hoy Android, mejor dicho, la máquina virtual java (JVM) Dalvik, sigue consiguiendo mejor rendimiento que los motores HTML5 móviles (que yo considero también máquinas virtuales), y aunque éstos mejoran día a día, debido a las limitaciones de Javascript (JS) es muy difícil que se aproximen al rendimiento de una JVM.

También podría ser que la mejora de las CPUs móviles haga que no importe el menor rendimiento de las aplicaciones web.

Y está el moviento extraño de Google con Dart. JS es malo, pero… ¿crearte un lenguaje nuevo tú sólo? ¿sin contar con ninguno de los otros actores? Google ya parece Microsoft en sus mejores tiempos ¿recordáis del malogrado VBScript para HTML? Puede ser que la gente de Google sí crea que el futuro está en la web, pero no con JavaScript.

Por otra parte estoy viendo decepcionado como Google se resiste a integrar la Chrome Webstore en Google Play, privándonos de poder publicar aplicaciones HTML5 para Android directamente (sin recurrir a chapuzas como PhoneGAP), también veo cómo Google y Apple siguen proporcionando WebViews del paleolítico capando APIs tan esenciales como WebGL ¿Y por qué? ¿Acaso abrir las puertas a las aplicaciones HTML5 es matar la gallina de los huevos de oro de las apps? Alguien en Cuppertino y en Mountain View debe pensar que sí.

Y aquí entra el, de momento fracasado, FirefoxOS. La gente de Mozilla sí ve claro el futuro en la web. FirefoxOS no es más que un Android al que le cambian la JVM Dalvik por el motor HTML5 Gecko. Tampoco me parece que FirefoxOS tenga mucho sentido ya que es más fácil instalar Firefox en cualquier dispositivo Android y se tiene igual acceso a todas las aplicaciones del Firefox Marketplace. Sin embargo, Firefox con su Marketplace es, en mi opinión, la mejor forma de distribuir y ejecutar aplicaciones HTML5 en un móvil. Pero Firefox está disponible sólo en Android, las políticas de Apple impiden explícitamente usar motores web que no sean el suyo, de nuevo… ¿miedo a las aplicaciones HTML5?

En los últimos 10 años hemos visto como las aplicaciones web substituían a muchas de las aplicaciones que usábamos cada día en nuestros equipos de escritorio, ¿sucederá esto con las apps móviles? Pues no lo sé, dejemos esto de adivinar el futuro para los programas nocturnos de las televisiones.

Puedes comentar este post en Google+.


Chromium Embedded Framework

chromiumHTML5 is a fantastic app framework, but there are many environments where you cannot rely on the features support of the browser (specially when dealing against Internet Explorer, old windows versions or environments where you cannot freely upgrade the browsers). Recently I found this problem trying to package Mobialia Chess 3D for Windows 8. Microsoft provides some tools to package HTML apps to native apps, but they will run with the Internet Explorer engine, lacking features like WebGL, WebRTC, etc.

Chromium Embedded Framework (CEF) is a library that allows to embed a Chromium webview in your native Windows or Mac desktop application. So you can convert any HTML5 to a traditional desktop app (and I bet some users to try guessing if Mobialia Chess 3D is an HTML5 app). You can also create a Windows/Mac installer to  distribute the app (I used InnoSetup, but this is another story…).

Using CEF requires a small knowledge about Windows/Mac desktop app development. I created a Windows app using Visual Studio Express, it was not very difficult, because CEF includes a “cefclient” sample project that you can use as a template to start your project development.

The main problem that I found was the size, embedding CEF will add 45Mb size to your installed application. I also found other minor problems like the lack of mp3 sound support (due to license problems) solved converting the sound files to ogg.

CEF is already used by great desktop applications like Steam, Evernote or Spotify, so it’s a great option to consider in your developments.


3D Chess Google+ Hangout Plugin

gplus-hangout-60x230-normalThose days I’m working in Mobialia Chess&Chess at ICC with a lot of bug fixes and some new features… and as a side project I developed a “Mobialia Chess 3D” Google+ Hangout Plugin to play 3D Chess inside a Hangout.

You can start a chess hangout pressing the “Hangout” button in http://chess.mobialia.com or directly with the image button in this post. All the participants in the hangout can move the pieces, so it can be used to play video-call chess games or to teach chess lessons.

Technically it wasn’t very hard, the Google+ Hangouts API offers a shared state and notifications when the state changes, you can get all the API information at https://developers.google.com/+/hangouts/

I was thinking to use this API since I saw some hangout API demos by +Paul Kinlan at the BCN DevFest 2011, and recently  I had the final idea watching a Quobis WebRTC webinar.

I had only problems accessing frames from different domains, (prohibited to avoid Cross-Site-Scripting, XSS, attacks) because the hangout is hosted in a Google domain and the chess app in a different one.

To bypass those problems I used the HTML5 window.postMessage() API to send and receive messages between frames. You can send messages to frames in other domains passing two parameters to postMessage(): the message and the domain of the receiving frame:

<script type="text/javascript">
var message = "";
document.getElementById('iframeid').contentWindow.postMessage(message, "http://www.domain.com");
</script>
<iframe id="iframeid" height="100%" width="100%" src="http://www.domain.com/iframe.html"></iframe>

and in the receiving frame you must set a message listener:

window.addEventListener("message", function messageReceived(evt) {
    console.log("Receiving message from " + evt.origin + " : " + evt.data);
    //...
}

Note that you receive the origin domain, crucial because the domain of the hangout is different each time.


Google Chrome Frame

Recently I’m hearing that Internet Explorer 10 (IE) is great, etc. but IE continues lacking some standards like WebGL. I’m working with WebGL in some HTML5 projects like:

and I couldn’t make the IEWebGL plugin work (it requires a different initialization). But Google has a great solution: the Chrome Frame, it’s an Internet Explorer plugin that runs an embedded Chrome, making possible for some advanced web apps to run into IE. Not great enough? It works with IE 6,7, 8 and 9!

Using it in a web page is extremely easy: Adding this header to your web page, IE will use Google Chrome Frame if installed:

<meta http-equiv="X-UA-Compatible" content="chrome=1">

And you can also add this javascript code asking the user to install Chrome Frame if it isn’t available:

<!--[if IE]>
  <script type="text/javascript"
      src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js">
  </script>

  <div id="prompt">
  </div>

  <script>
    window.attachEvent("onload", function() {
    CFInstall.check({
      mode: "overlay",
      node: "prompt"
    });
  });
  </script>
<![endif]-->

More Google Chrome Frame resources:


DevFest-X BCN 2012

For those who don’t follow me in the social networks, I’m now a co-organizator of the GDG Vigo (Google Developers Group), founded by Reinaldo Aguilera. In this group we are organizating a lot of interesting (and free!) Android and HTML5 activities (speechs, codelabs…) near Vigo, Galicia. Join to our Google Group and stay tuned!

This year I also went to the Barcelona DevFest, but as GDG Vigo we tried to help with the organization.

We participated in a Three.js codelab with Ricardo Cabello (Mr.Doob) showing how to make a very simple WebGL game in some simple steps. Slides are available at:

http://www.alonsoruibal.com/slides/codelab_three.js/

and source code is hosted in github: https://github.com/albertoruibal/codelab_three.js/

In another session I also told my experience migrating some Mobialia apps from Android to HTML5 with GWT, those slides are at http://www.alonsoruibal.com/slides/android2gwt/

Thanks Google, GDG Barcelona and GDG Tarrragona for the organization of such great event!


Google DevFest 2011 BCN 1

This week I assisted to the Google DevFest 2011 Barcelona. This year it was celebrated on a great “garage” located on an industrial area of Barcelona. I will tell the more interesting things that I found on the different sessions:

NEW IN HTML

As usual, this session presented by Paul Kinlan showed us the future of HTML5. I love the x-webkit-speech Chrome feature to make voice inputs that we already could see on the Madrid DevFest 2010. Paul made also some demos of WebIntents  a great idea to make something similar to Android intents on the web. Finally we could see that HTML5 is advancing very fast trying to implement many APIS that will make Flash obsolete, like window.navigator.getUserMedia() ot the Web Audio API.

GLSL

This session was presented by Mr. doob aka. Ricardo Cabello, a guy from the demoscene. He made a introduction of how 3D works in the browser and showed us how to use the GLSL language to make great effects on web pages. He has those GLSL demos on his blog.

GOOGLE+ SESSIONS

There were two Google+ sessions driven by Ade Oshineye, one presenting the new social network (also announcing the Google+ Pages) and other with more technical details for developers. One thing that you can do easily is adding the +1 button to your site. Other very interesting tools that we could see were the Google APIs Console and the Google APIs Explorer.

ANDROID SESSIONS

Bruno Oliveira is replacing Reto Meier as our “Android Developer Relations”.  On the first session he made a great review of the Android platform evolution since 2.1 to 4.0. On the second session he gave us great tips to improve UX experience on Android. This guy is a showman!

MAKING A BUSSINESS OUT OF APPS

This session was presented by Paul Kinlan and Bruno Oliveira, showing us that monetization tips are valid for both web and Android apps: Lazy registration, try before you buy, easy payment, in-app payments… Bruno also presented the new multilingual “Guide to the App Galaxy” http://www.guidetotheappgalaxy.com/.

GOOGLE SHOPPING API

Daniel Hermes showed us the Google Shopping API and many integration samples.

CHROME DEV TOOLS

Finally Sam Dutton made a review of the Google Chrome development tools. This tools replaced my FireBug many years ago! He also made his slides available.

APP COMPETITION

This year Google also organized and Appcircus-style app competition. Those were the apps and sites presented:

I won the app competition, but all were great apps. Our presentation and some photos of the app competition are available at our Mobialia Blog.