sábado, 15 de mayo de 2010

NaCl: El Silverlight/Flash de Google?

En mi continuo transitar por las novedades tecnol�gicas (no s� a que hora visito tanto sitio�) Me encontr� con que Google de una manera bastante discreta estaba lanzando una tecnolog�a abreviada como la sal: NaCl. Acr�nimo de Native Client.

NaCl = Sal

Native Client es una idea supernovedosa

Con la cual de acuerdo a lo que encontramos en el sitio del proyecto, tenemos un fabuloso SDK que permitir� al browser ejecutar c�digo nativo para construir aplicaciones web de alta respuesta e interactividad� (no les suena esto familiar?)

Lo cual, me parece bastante curioso, dado todo lo que Google ha dicho acerca de su firme apoyo a HTML 5, que pretende solucionar el mismo tipo de problema.

Dijo el vice presidente de ingenier�a Vic Gundotra en el Google I/O de 2009: �HTML 5, will be the future of the web�.

Y si es as�? Para qu� desgastarse tratando de implementar toda una tecnolog�a para correr c�digo nativo desde el browser? Sobretodo cuando se ha criticado al mismo tipo de tecnolog�as ya implementadas como Silverlight y Flash?

Ser� que en el fondo no creen mucho en HTML5? O ser� que en el fondo creen mucho en tecnolog�as Silverlifght/Flash?

NaCl tiene un SDK que funciona en Windows, Linux y Mac� Genial! Y lo mejor de todo, es que las aplicaciones las programar�amos en una suerte de sancocho (l�ase mescolanza o MIX para los m�s modernos) de CSS, HTML, Javascript y s�, el amigable C/C++! Todo para lograr que la aplicaci�n no se vea como un frame embebido dentro del HTML, sino como puro HTML.

Este C/C++ nos permitir� crear de una forma bastante sencilla gr�ficos en 2D/3D, ejecutar audio y responder a eventos del mouse y teclado!

Pero�

Cu�l es el AS bajo la manga de Google que aventajar� a Silverlight y Flash?

Pues que no se requerir� plugin! No habr� que instalar nada!!!
Bueno, excepto el propio browser de Google (Chromium). Entonces ha de ser que para ellos no existen m�s browsers :

�all without requiring users to install a plugin. These web apps run in recent versions of Chromium with the --enable-nacl flag.�

Bueno; pero pongamos esas des-virtudes a un lado y d�mosle una oportunidad de prueba; observemos c�mo ser�a la programaci�n. Primero, veamos c�mo ser�a la p�gina web que hospedar�a la sal; digo, NaCl:

   1:  DOCTYPE html>




   2:  <html>




   3:    




   8:  <head>




   9:    <title>Hello, World!title>




  10:   




  11:    <script type="text/javascript">




  12:      hello_world = null;  // Global application object.




  13:      status_text = 'NO-STATUS';




  14:   




  15:      function moduleDidLoad() {




  16:        hello_world = document.getElementById('hello_world');




  17:        updateStatus('SUCCESS');




  18:      }




  19:   




  20:      // If the page loads before the Native Client module loads, then set the




  21:      // status message indicating that the module is still loading.  Otherwise,




  22:      // do not change the status message.




  23:      function pageDidLoad() {




  24:        if (hello_world == null) {




  25:          updateStatus('LOADING...');




  26:        } else {




  27:          // It's possible that the Native Client module onload event fired




  28:          // before the page's onload event.  In this case, the status message




  29:          // will reflect 'SUCCESS', but won't be displayed.  This call will




  30:          // display the current message.




  31:          updateStatus();




  32:        }




  33:      }




  34:   




  35:      function fortytwo() {




  36:        try {




  37:          alert(hello_world.fortytwo());




  38:        } catch(e) {




  39:          alert(e.message);




  40:        }




  41:      }




  42:   




  43:      function helloworld() {




  44:        try {




  45:          alert(hello_world.helloworld());




  46:        } catch(e) {




  47:          alert(e.message);




  48:        }




  49:      }




  50:   




  51:      // Set the global status message.  If the element with id 'status_field'




  52:      // exists, then set its HTML to the status message as well.




  53:      // opt_message The message test.  If this is null or undefined, then




  54:      //     attempt to set the element with id 'status_field' to the value of




  55:      //     |status_text|.




  56:      function updateStatus(opt_message) {




  57:        if (opt_message)




  58:          status_text = opt_message;




  59:        var status_field = document.getElementById('status_field');




  60:        if (status_field) {




  61:          status_field.innerHTML = status_text;




  62:        }




  63:      }




  64:    script>




  65:  




  66:  "pageDidLoad()">




  67:   




  68:  

Native Client Simple Module





  69:  





  70:    




  71:    




  72:   




  73:    




  76:    
"nacl_helloworld_content">




  77: