format internet:

…please wait (39% completed)…

Posts Tagged ‘javier ramirez’

Los problemas del desarrollo web en España resumidos en senado.es

Posted by javier ramirez on November 12, 2012

disclaimer: he escrito este artículo después de navegar quince minutos por la web del Senado. No pretende ser un análisis exhaustivo de sus deficiencias. La mayor parte de los desastres que describo se corresponden a la sección de la web y del buscador (responsabilidad de VASS y GFI). La parte del pequeño Senado correspondiente a Ibermatica está algo mejor resuelta, aunque también presenta deficiencias.

Vaya por delante que 500,000 euros para una web compleja no me parece un precio excesivo. Pagar alrededor de 100,000 euros anuales por desarrollador es algo que entra dentro de lo normal, por lo que una web compleja que necesite de cinco desarrolladores durante un año va a estar en ese rango de precio. Si además la web incluye mantenimiento o necesita de cosas sofisticadas como gestión de documentos o un canal de streaming de video, el coste es normal que suba. Si la oferta también incluye los gastos de alojamiento y mantenimiento, me puede llegar a parecer incluso un precio bastante ajustado.

¿He dicho más de 100,000 euros por desarrollador al año? Sí. Exactamente. Es lo que cuesta contratar un buen servicio. Unos 50 euros la hora. De hecho, es bastante habitual encontrar precios por encima de ese rango, aunque también es habitual encontrar precios bastante más baratos. No conozco a ninguna consultora de las grandes en España que cobre ese dinero por sus desarrolladores, sino que el rango está más bien alrededor de los 20 euros (siempre se colocan perfiles de “más nivel” como jefes de proyecto o arquitectos que sí se venden por 50 euros la hora o incluso más caros, pero el grueso del equipo se factura a precio de saldo).

Cuando haces las cuentas, le quitas la seguridad social, el beneficio de la empresa, una pequeña reserva por trabajador para posibles indemnizaciones e imprevistos… nos queda que un desarrollador web que trabaje en una consultora, difícilmente va a poder cobrar más de 20000-25000 euros. Y si quiere ganar más, tendrá que dejar de desarrollar software y dedicarse a hacer tareas de gestión (arquitecto, jefe de equipo…) o comerciales (preventa, evangelista…). No hay nada malo en hacer tareas de gestión o comerciales, pero sí hay un problema en dejar que la gente que está construyendo tu software sea gente con poca experiencia o con una motivación baja. Por muy buenos jefes que tengas, si los desarrolladores no entienden el contexto de lo que están haciendo, el resultado va a ser subóptimo en el mejor de los casos, o desastroso como en el caso de la web del Senado.

El problema en España es que pensamos que cualquiera puede hacer una web. Como pintar una página HTML es lo más sencillo del mundo, tiramos a lo más barato y nos ahorramos un dinero pensando lo listos que somos. Y como no queremos pagar el dinero que vale, cuando la gente ya ha aprendido y tiene experiencia, se pasa a puestos de gestión donde van a poder ganar más dinero que le permita lujos tales como independizarse o incluso tener un hijo, con lo que los desarrollos los acaban haciendo siempre o la gente que acaba de terminar la universidad o los refugiados de otras carreras que se meten en la informática porque les dan un curso y con eso ya pueden hacer una web.

Hay más problemas que ese, por supuesto. Como el hecho de que para presentar una oferta a una administración pública te pidan unas condiciones imposibles de cumplir para cualquier PYME, o que a las grandes consultoras no les duela a veces hacer ofertas aún perdiendo dinero porque saben que ellas se lo pueden permitir.

El resultado de todo esto, es que las Administraciones públicas y las empresas grandes en España, con honrosas excepciones, tienen unas webs que dan vergüenza porque el desarrollo se lo han hecho estas empresas en las que la gente que realmente sabe está en puestos de gestión, y los pobres a los que les toca hacer el desarrollo hacen lo que pueden con los plazos imposibles que les piden, la poca experiencia que tienen, y las condiciones laborales de risa que les ofrecen.

Hablar es gratis, me diréis.. queremos pruebas.. no hay problema. Con la chapuza de web del Senado que se ha lanzado hoy veréis muy fácilmente de lo que os hablo. Independientemente de que el precio no me parece desorbitado, la web me parece desastrosa.

A simple vista, es una página web que funciona. El diseño no es ni mejor ni peor que el de muchas otras webs que hay por ahí. A mí personalmente se me antoja algo viejo para una web moderna, y el tamaño de letra me parece minúsculo, considerando especialmente que la web se autoproclama accesible, pero no soy experto en usabilidad así que no me quiero meter en esa guerra. En la guerra que sí me voy a meter es en la de las cosas que en un vistazo rápido están mal, aunque a simple vista un no profesional no se daría cuenta.

Cómo llegar hasta la página

Básicamente hay cuatro formas de llegar a una web. O le das a un enlace que alguien te ha pasado (facebook, twitter…), o escribes directamente la dirección de la web en tu browser, o la buscas en google (una gran parte de la gente siempre navega usando el buscador, no entienden que existe la barra de navegación del browser) o vas por un bookmark.

De esas cuatro opciones, TRES están rotas en este preciso momento. Si uno quiere escribir “senado.es” en su navegador, verá cómo le dice “página no encontrada” en lugar de mostrarle la home. Para poderla ver, es necesario escribir www.senado.es. Este problema es de primero de web, y es muy simple de resolver. Pero da una primera impresión de las prisas o la falta de cariño en este desarrollo.

Un problema mucho más grave. A día de hoy (aunque no por mucho tiempo) hay más de dos millones de páginas indexadas en google para el sitio del senado. Esto es bueno, de hecho es muy bueno. El problema es que esos dos millones son para la versión antigua de la web. En la versión nueva se ha cambiado el esquema de URLs, con lo que ahora todos los resultados que da google, excepto la home, han dejado de existir. Así como te lo cuento. El excelente trabajo de indexación de más de dos millones de páginas que YA existían en google, han desaparecido de la noche a la mañana porque a nadie se le ha ocurrido hacer un módulo que convierta de las URLs antiguas a las nuevas. Yo esto lo he programado antes en unos cuantos sitios y es un trabajo de unas pocas horas. El impacto es brutal.

Si alguien quiere probarlo es bien fácil. Ejecutas en google la búsqueda

site:senado.es

Y pinchas en cualquier resultado (excepto la home). Página no encontrada. Ajá.. bien. Por cierto, ya que hemos llegado a “página no encontrada”, intenta usar cualquiera de los enlaces del menú superior (cambio de idioma, contactar…) o del pie de página. ¿No puedes? Ya, ni yo. Otro detalle de primero de web que también se les ha pasado.

Obviamente si tenías un bookmark a la web, tampoco te va a funcionar por el mismo problema. Han cambiado las URLs, pero nadie se ha ocupado de redigirir las antiguas. Todo muy útil para la gente que, como yo, a veces se guarda enlaces a documentos para poderlos consultar más adelante sin buscarlos de nuevo.

Calidad del código de la página

Una vez llegamos a la página, lo primero que he hecho ha sido pasar el validador del w3c. Es una cosa que me gusta hacer siempre en las páginas porque me da una cierta medida de la calidad. Ojo, hay que tomarse los validadores como lo que son y no ser demasiado estrictos. Algunos problemas de validación son menos graves que otros y en algunos casos es imposible no tener algún error poco grave, como por ejemplo atributos extras.

En el caso de la web del senado, hay 88 errores y 44 avisos en la home. De esos errores unos cuantos son graves, como que hay input fields en zonas no permitidas (que puede hacer que algunos browsers no puedan usar los formularios) o que hay IDs duplicados (que puede complicar el desarrollo en el futuro, ya que cualquier desarrollador cuando programa una web espera que los IDs sean únicos, tal y como manda el estándar).

Si examinamos con más detalle el código fuente de la web, vemos que no se han tomado demasiadas precauciones para reducir el número de peticiones que hace la página, incluyendo al menos 12 ficheros en la cabecera. Cuando se programa un sitio en el que se espera mucho tráfico, esto debería estar mucho mejor resuelto. Además, si realmente va a haber mucho tráfico esperaría usar un CDN o cuando menos un dominio separado para los ficheros estáticos, de manera que no tenga que malgastar tráfico enviando las cookies para cada petición separada. Ya que estamos, utilizar varios subdominios estáticos me ayuda a enviar más peticiones en paralelo, haciendo que la página cargue más rápida.

Además, siguiendo con el código fuente de la página, en muchas de las páginas internas aparece javascript y css mezclado con el código HTML, lo que hace que las páginas ocupen más de lo que deberían (es decir, malgastan tráfico), hace que vayan más lentas y complica enormemente el mantenimiento en el futuro y la posibilidad de reusar código en otras partes de la web. Para ser justos, esta parte de código mezclado la he visto solo en el buscador, que es responsabilidad de GFI. Los desaguisados anteriores eran de la parte correspondiente a VASS.

Indexación en buscadores

Una parte importantísima del tráfico de un sitio llega por los buscadores. Cuando yo quiero informarme sobre algo, normalmente le pregunto a google, y luego sigo los enlaces. Me parece vital que una web en la que hay mucho contenido esté bien construída para que esos contenidos aparezcan indexados en Google/Bing y similares.

Ya hemos visto que el trabajo de indexación hecho hasta ahora con la web antigua se ha roto por completo con la nueva versión, pero ¿Está preparada para indexar bien los nuevos contenidos?

Para que una web indexe bien ha de tener estas consideraciones:

  • El código debe ser válido
  • Debe hacer buen uso de los elementos “title”, “description” y “h1”
  • La estructura ha de ser lo más semántica posible, añadiendo meta información extendida en los casos en los que se pueda (por ejemplo en el caso de las comparecencias, se puede añadir información del evento, o en el de los senadores información sobre la persona)
  • Los enlaces, las imágenes y los videos han de tener su “anchor text” o su “alt” bien definido pensando en los usuarios y, por tanto, en indexar bien
  • En un sitio multi idioma, hay que diferenciar a nivel de URL los diferentes idiomas y hay que proporcionar los enlaces canonical y alternate adecuados, para que cuando un usuario busca una página le aparezca en su buscador en el idioma más relevante para él
  • Si el sitio tiene mucho contenido, hay que proporcionar un fichero de sitemap en el que se le indica al buscador qué páginas lo componen
  • La estructura de las URLs debe ser clara

De todas estas consideraciones, la web del senado no cumple NI UNA SOLA. No solamente eso, sino que en su fichero robots.txt a día de hoy aparece una directiva en la que explícitamente se le pide a todos los buscadores que no indexen ninguna página del site, Ninguna en absoluto. Esto significa que cualquiera que busque información sobre el Senado en google va a encontrar cero referencias.

Móvil

En un mundo en el que la gente comparte enlaces via twitter/facebook/email y en el que cada vez más estos tres medios se leen en un móvil o en una tableta, me parece razonable pedir que al menos las páginas de aterrizaje estén optimizadas para estos dispositivos. No hablo de que el sitio completo sea usable por móvil, porque eso puede añadir un coste considerable, pero sí que las páginas susceptibles de ser enlazadas lo contemplen.

De hecho, Chus Pastor, la directora de Administración Pública de VASS, comentó que la web se vería en cualquier dispositivo.

Chus, ¿Has probado a verla en un móvil? Mírala tú, que a mí me da la risa.

Conclusión

Hacer una web es mucho más que saber escribir HTML y ponerle colores. Obviamente esas dos cosas son básicas, pero hay muchísimo más que has de tener en cuenta si tienes que hacerla, y aprender todo eso requiere tiempo y mucha experiencia.

¿Empezamos a ver por qué no es bueno que tu web la haga gente a la que le pagas poco dinero y, que por lo tanto, tiene poca experiencia? Ellos hacen lo mejor que saben, pero desafortunadamente no es suficiente para un sitio complejo.

Si quieres hacer una buena web, no solamente algo que “dé el pego” cuando la muestras en el browser, entonces necesitas gente que sepa lo que está haciendo. Y la informática tal cual se entiende en España provoca que esa gente abandone su carrera como desarrollador porque los sueldos y las condiciones son incompatibles con una vida digna.

Afortunadamente, hay vida más allá de las grandes consultoras donde el mundo es diferente y donde la gente se siente orgullosa de lo que hace. El reto ahora es que los grandes clientes se den cuenta de que les están timando y de que deberían exigir mucho más por su dinero. Y eso solo se conseguirá en la medida de que haya más sensibilidad hacia el trabajo de programador y más conocimiento de lo que aporta en un proyecto.

¿Son 500,000 euros muchos para hacer la web del Senado? No lo creo. Pero para el resultado obtenido, me parece un robo a mano armada.

Posted in development, internet, javier ramirez, SEO | Tagged: , , , , | 143 Comments »

Installing a Rails plugin from a github branch

Posted by javier ramirez on October 13, 2010

Today I wanted to install a plugin from github into a rails project. So far so good, you would think. You only need to run script/plugin install and start coding right away.

Unfortunately, the branch of the plugin I need is not the master one, because this applications runs on rails 2.3.x and the master branch has been adapted to rails 3 already.

I could just download the tar file from github, or I could make a git clone and checkout the branch I wanted.. but it turns out I don’t need to do any of those, because old good script/plugin has an option to checkout a specific branch

script/plugin install http://github.com/rails/exception_notification.git -r 2-3-stable

And I can start coding right away.. and that’s exactly what I’m going to do after publishing this post.

Posted in development, javier ramirez, madrid, ruby on rails | Tagged: , , , , | 7 Comments »

Happy 4th birthday ASPgems

Posted by javier ramirez on June 6, 2010

Four years ago I thought I was at the top of my career. The company I had co-founded was starting to look much like a nine to five job and I decided to resign and accept a great position as a post-sales engineer in FatWire, where I would have the chance to improve their content server solution, which in my opinion was the best of the market by then. Things were looking sweet: new challenges, smart jobmates, important clients, interesting salary… and then I got an IM from Ana Isabel that changed it all (you gotta love it was not a phone call, mind you)

She told me about this brand new tiny company she was starting up together with Agustin Cuenca and some other folks I didn’t know by then, and who resulted to be brilliant. The idea was to be an Application Server Provider and offer products in the later so-called cloud to help small and medium size companies manage their businesses. They would also develop web applications for third parties. And they would do it all using this new toy called Rails, after a successful proof of concept for a real client by Xavier Noria. Regarding project management, they didn’t want to use a traditional approach, but going down the Agile road and use Scrum. The name of the company was ASPgems, where ASP stands for Application Server Provider and “gems” was something related to this Rails thing.

I was very reluctant to join them. Apart from having just landed into a great job position, I had a lot of doubts about the new company. They didn’t have any money, so I would have to cut down my salary and trust the company would eventually make it; they were working remotely, so I thought nothing would get really done; they didn’t have any big clients, and I came from the banking/public sector/corporate world; and to top it all they were using this Ruby on Rails framework and these requirementless agile methodologies.

My first experience with Ruby, some years before, was painful. I had to make some kind of automatic web crawler and I found libraries for doing it both with Ruby and Jython. I didn’t knew any of them so I tried them both. Right now I don’t remember why I didn’t choose the Jython library, but I know why I didn’t choose Ruby. After half a day trying, it was impossible to make the thing work on my windows machine, and all the documentation was in Japanese, so good luck with it. I finally coded my own crawling solution in good old Java and XML.

So you can imagine I was skeptical about Ruby. Then I started to read about Ruby and Rails and I panicked: no static type check, lack of hosting options, poor windows support, opinionated instead of configurable, with a certain disdain for the database layer… my Java instincts were alerting me with a lot of red signals. And then I made “the mistake” of having lunch with Ana and Agustin. They were really excited about the company, they saw a world full of possibilities, and the sense of adventure was just too strong for me to resist. Besides Agustin had been the guy who started Qarana, the best company I had worked for until then. It was just natural for me to join ASPgems.

By adopting Rails as her development framework, ASPgems was making a statement: We don’t care what other people are doing, we want to use the best tools available with or without the support of the rest of the industry. Living up to that statement takes a lot of work. First you have to be sure you are using the best tools available, so you have to be scanning the surroundings all the time to see when it’s time to move to the new best thing. Besides, you have to keep up to date on all the changes and on the new libraries available. And of course in many occasions you will have to be the one building those libraries, because getting there first means no one did the work for you yet. This living on the edge thing can be really time consuming, but things get much easier when you find a friendly community sharing your passion. And in Ruby/Rails we are really lucky on that issue.

Today is ASPgems’ fourth birthday and I’ve been a part of the company almost from the first month. If I have to judge in terms of personal development, I can say without any doubts this is the best company I’ve worked for, and I guess that’s why I’ve stayed here longer than in any other place before.

Below are some of the things I have done in the last four years. Had I stayed in my safe Java corporate world, I’m not sure I wouldn’t have done some of these things, but I’m sure ASPgems inspired me to do most of them.

I have..

..attended more conferences (and camps, and other events) in the last four years than in the previous 10+ since I started working on IT.
..organized and presented talks in both national and international conferences
..co-started a local ruby group
..curated an extensive online presence: blog, personal page, vimeo, slideshare, mailing lists, communities…
..greatly improved my google ranking, making my conventional CV irrelevant
..written a book

..learnt how to better manage web projects
..seen clients really happy to see their projects going live on time
..shared my knowledge with both clients and competition
..launched more web applications than I can remember

..taught ruby on rails
..introduced some friends to the Ruby on Rails/Agile world
..developed a taste for being an early adopter on new technologies
..adopted ruby on rails for my personal and freelance projects
..switched to linux
..bought several domains and rented my own VPS

..learnt about SEO and Analytics
..made websites scale, and learnt a lot during the process
..learnt a lot about IT (web servers, process monitoring, system set up and configuration…)
..improved vastly my skills on client-side web developent
..been wrong many times, and happy to learn from those mistakes

..helped to build one of the most solid development teams I have seen
..worked together with the commercial department, and not against it

..kept in contact with brilliant developers from all over the world
..started repositories in github and rubyforge
..collaborated in several open source projects

..realized money is just a secondary motivation

Happy birthday ASPgems, and thank you.

p.s. By the way, remember how skeptical I was about Ruby? I was wrong, and happy to be. Go try it by yourself!

Posted in aspgems, javier ramirez, madrid | Tagged: , , , | 7 Comments »

SEO for developers

Posted by javier ramirez on March 10, 2010

As a web developer, my work involves much more than just coding; many times I find myself covering topics such as user experience, scalability, reliability of the system, or metrics and analytics to track the acceptance of a site.

SEO is left many times on the hands of the marketing team, but there are many technical aspects that are important in order to make a site appealing both for visitors and searchbots. Since web technologies (and search engines) evolve quickly, if you want to have a good site you need to keep posted about the latest developments. Sadly, there are a lots of materials based on outdated information and there are many myths and legends around the topic

I have been following closely the status of web crawling and indexing for some years, and we have been applying with success many of the practices I’ve learned to improve the sites of some clients. None of these practices involved links from external sites or bought traffic, just a better structure and changes of the contents and the sites’ internals.

Since we want to follow these practices in all the projects we are taking, I decided to prepare an internal training session for the ASPgems’ development team.

Here are the slides for my presentation. Even if they are not as good without the explanation (sorry, no video this time), I hope you’ll find them useful. UPDATE: video -in Spanish- has been uploaded to the media page of my blog.

This material is published under a Creative Commons NonCommercial-Attribution-ShareAlike license 2.5

If you find it interesting or if you are going to use it for any purposes, I’d appreciate an e-mail to jramirez@formatinternet.com

Posted in development, internet, javier ramirez, SEO, sites | Tagged: , , , , , | 10 Comments »

Slides and video for my talk “La herramienta de desarrollo definitiva” in conferencia rails 2009

Posted by javier ramirez on February 28, 2010

I just realized I still hadn’t published in my blog the slides and video of my talk “La herramienta de desarrollo definitiva” in conferencia rails 2009, back in november.

My talk was a reflection about web development and the relative importance of the development tools. I was defending the idea of the individual with good practices being much more important than the choice of a tool or another. I was also talking about why Ruby on Rails is very appealing for such an individual and why it’s still relatively hard to find companies using modern techniques in development.

I talked about which were the best practices I consider an “ultimate developer” should embrace, linking it to concepts found in geek literature such as The Mythical Man Month, The Cluetrain Manifesto, Microserfs o The Soul of a New Machine.

This material is published under a Creative Commons NonCommercial-Attribution-ShareAlike license 2.5



The video is divided in two parts:

Posted in conferences, conferenciarails, conferenciarails2009, javier ramirez, ruby, ruby on rails | Tagged: , , , , , | 3 Comments »

IE cache for Ajax requests

Posted by javier ramirez on January 14, 2010

A few days ago I ran into an issue that is now obvious but took me a while to figure out. I was programming a chat client and everything was working fine in Firefox and Chrome, but when I tested it on IE (6 and 8) things were not looking so good.

This chat is following the polling pattern, issuing an Ajax call every three seconds to check for any updates and receiving a JSON array with the pending messages, if any. Using prototype.js the code to call the javascript function every three seconds is this

new PeriodicalExecuter(Aspchat.chatRemotePoll, 3);

On IE the chat was initialized properly, the first call to the remote server was working fine, but the periodical poller was not issuing any further calls. At first I thought the problem was on PeriodicalExecuter, but after a bit of debugging I could see “Aspchat.chatRemotePoll” was being called, but the Ajax call inside was apparently ignored.

To make things more interesting, I could see some other Ajax requests were working fine (for example, the one to send messages or to update the user list).

Comparing the requests that were successfully sent with the ones that were ignored, I could see the difference. In the working requests I was using POST (the default when using prototype) but in the ignored calls I was using GET.

Once I saw this, it was easy to diagnose what the problem was. IE was caching the GET requests, even when using AJAX. To be honest, this time I will not even blame IE, since I understand a GET request is subject to cache. In this case, I would even say I prefer the IE behaviour over that of Firefox and Chrome.

There are basically three things you can do to prevent this kind of behaviour:

  • The easy way out would be to convert my GET request to a POST one. Alas, I didn’t want to do it because in this case I was being RESTful and I was using the same URL for two different actions. When calling “/aspchat/messages” via GET I’m asking for new messages, but when calling via POST I’m sending a new message to the channel.
  • Set HTTP headers to control client cache
  • Make the request unique by adding a timestamp (or similar) to the URL

The solution I like the best is the one with HTTP headers, so I just went to my poller action (which by the way is managed via a Rails metal middleware) and added the Cache-Control: no-cache header. Just to be really sure, I also added the timestamp for extra security.

The prototype for the Ajax call with the timestamp looks like this

new Ajax.Request('/aspchat/messages', {
           parameters: {timestamp:new Date().getTime()}, //we need this to avoid IE caching of the AJAX get
           method: 'get',
           onSuccess: function(transport){
               Aspchat.displayChatMessages(eval(transport.responseText));  //pass the JSON array to displayChatMessages
                         }
       });

As an extra ball, you can see how I’m using the onSuccess callback to interpret the JSON I’m receiving from the server.

Now you cannot say you didn’t know your AJAX requests could be cached. Let’s be careful out there.

Posted in 1771, development, internet, javier ramirez, ruby on rails | Tagged: , , , , , | 14 Comments »

Ruby on Rails on unofficial Chrome OS

Posted by javier ramirez on September 29, 2009

update: I thought this Chrome OS distribution was THE google distro. I was wrong. It’s just someone who used SUSE Studio to make a customized version of Open SUSE around the Chromium theme. With the site being on a google site and the code on a google code repository, I thought this was it, but no.. this distro is totally unrelated to google.

Chrome OS is by now just a bit more than a curiosity. In the meanwhile, you can go and download a non-official distribution mimicking what it could be, but be warned, all you are going to get is an Open Suse distribution with Chromium installed and a blue theme with a cute logo. Hopefully the real ChromeOS will be much lighter and more user-friendly.

Starting the virtual appliance from VirtualBox is easy. You create a new virtual media with the virtual media manager and then a virtual machine using this new media. That should be it. If you leave the default options (64MB) you’ll end up with a really slow boot. I set the base memory to 512K and things are much better.

What will you find in this distribution apart from Chromium? Zip, Zero, Null.. or if you are into ruby, nil.

Truth is, this distribution is a bit too rough around the edges (when it comes to internationalization, even if it ask you for the keyboard settings, it will just ignore them), but being a SUSE, you can install whatever you want. The only thing you’ll need is the root password. Since I’m such a hacker it took me almost no time to realize the root password was “root” (my other options being “sergei”, “larry” and “640Koughttobeenough”.

Once you have root access, you can use Yast for installing anything you might need. Just for fun I installed ruby, rubygems and sqlite3 via Yast, and then rails using gem. I had to run a gem update –system so I could use rails 2.3.4 and I generated a scaffold to see if everything was fine. Well, it was :)

ruby on rails running on google chrome os

ruby on rails running on google chrome os

Well, even if it was utterly useless, at least I found a cool way of making customized SUSE distros in an easy way ;)

Posted in 1771, development, javier ramirez, ruby, ruby on rails | Tagged: , , , , , , , | 1 Comment »

Multiple rubygems versions, GEM_HOME and GEM_PATH

Posted by javier ramirez on September 28, 2009

Installing rubygems is failrly easy and it’s great to have a package manager so you can forget about manually installing and upgrading the components you use. After installing a gem, you can require it from any ruby script and use it hassle-free. Well, given your ruby interpreter can find it.

When you install rubygems, a lot of default configuration is done behind the scenes. If you must see to believe, you can run

gem environment

do you believe me now?

Unless you are on windows, you have probably experienced already that gems can get installed in different locations. If using a superuser account, the global configuration will be used, but with a regular account gems install under your home directory.

If you are not careful about how you install your gems, or if you are using rake gems:install from regular accounts, you might end up installing the same version of a gem twice. That’s not only WET (not DRY, bear with me here) but it eats up your poor HD.

Things can get a lot worse than that. Suppose you are working with both JRuby and Ruby MRI. When you use rubygems from JRuby, it will try to use a different gem location by default. So, depending on how you are installing gems, you could have up to three different copies of exactly the same version.

And if you are on ubuntu and you upgrade from an old version of rubygems to the latest one —you will have to if you install Rails 2.3.4; if you are having problems you can read right here how to update it— you might be surprised that your gems are being installed *again*. The reason is under older versions the default location was “/var/lib/gems” and the latest one defaults to “/usr/lib/ruby/gems”.

Well, four different copies of ActiveRecord 2.3.4 are three and a half more copies than I wanted, mind you.

So.. how can we stop this gem install frenzy? Easy. Don’t use the defaults. Each of your installations is using default values, but they can be easily overridden with command line parameters or much more conveniently with environment variables.

Remember the title of this post? Can you see anything there that would make a good candidate for environment variables? That’s right, all the rubygems versions honor the GEM_HOME and GEM_PATH variables, so if they are set they will be used.

Depending on your OS, you can set these variables in different places. I’m on ubuntu and a bit lazy, so I chose the easiest, which is by adding this to my .bashrc file.

export GEM_HOME=/var/lib/gems/1.8
export GEM_PATH=/var/lib/gems/1.8

And now, no matter what I’m using: Ruby MRI, JRuby, or the latest rubygems, my already installed gems will be used, and the new ones will be put in the same place.

Saving the world is a hard job, but someone has to do it.

Posted in 1771, development, jruby, ruby, ruby, ruby on rails, ruby on rails | Tagged: , , , , , , | 6 Comments »

it’s not the framework, it’s you

Posted by javier ramirez on July 21, 2009

I’m getting tired already of the hype about Ruby on Rails and how it is better than any other framework past, present or future.

Sure Rails is a cute piece of software, and Ruby is a gorgeous language (supposing you are into programming languages, that is), but if you take a critical look at Rails, you could just say it’s another MVC framework.. Big deal.. And with some coupling issues between the layers too, which are fortunately being targeted on Rails 3.

Moreover, if you take a look at some of its components they could frankly be better. ActiveRecord, for example, is a wrapper ORM, which is implicitly tying you to the physical database layer, with one class per table, as opposed to a mapper ORM such as DataMapper or Hibernate. And the principle of least surprise is kind of a joke when it comes to some of the ActionView helpers and the parameters you have to pass along.

Still, as we like to say around here “Ruby on Rails mola infinito”, and it’s right now my favourite framework for non trivial web applications.

So.. what makes this framework so special? Is it only the absence of configuration and the sensible defaults? Would we sell ourselves for a couple of parlor tricks like those? Surely not.. specially with so many frameworks providing already sensible defaults. Come on, even in Java you can kind of forget about writing so much XML code if you make proper use of annotations and the like. No, it has to be something else.

Ruby on Rails has something that transcends the framework itself. It has you. The Mighty Developer. The Early Adopter. The Status Quo Challenger. The so-called Community —whatever that means.

Bottom line is, when I get together with people working with Rails, they are always in search of the holy grail of web development —or the nearest tavern, whatever comes first.. you have to love that kind of pragmatism. We like to break our assumptions, to learn new things and forget about the ones we already know.

We embrace Rails *today* but we are willing to embrace any other tool as long as we like it better. Do you remember the months before the Merb-Rails love affair? Half the Rails developers I know were already making eyes at Merb without the slightest hint of shame.

And by challenging the system, we are obliged to keep learning… and to find new ways to build the web. And instead of trying to make a carbon copy of what we did before, we like to start anew, because that’s where the fun is.

Sure you can argue this attitude is not the exclusive property of the Rails community. And I would second you on that based on theory.. but in practice, I have seen other some other communities lack this need of challenging. Maybe it’s because they have maturity models and certifications and black belts and whatnot…. And maybe having so many constraints is killing creativity; but fact is in some environments trying to take a step forward is seen as something odd, not desirable.

Rails will pass —or not— but as long as we keep alive the spirit of embracing change, we are entitled to be on the fun side of web development.

So, if you ask me, that’s the secret ingredient of Rails. Sure the language and the framework are cool, but the real power of Ruby on Rails is you.. and me.

update: please read the comments, since I was a bit ambiguous in the post and some points needed further explanation :)

Posted in internet, javier ramirez, madrid, ruby, ruby on rails | Tagged: , , , , , | 10 Comments »

it’s the end of the e-world as we know it

Posted by javier ramirez on July 7, 2009

Five years

I’ve been working for companies that didn’t last for so long. I’ve never been working in a company for so long come to think of it ;). I had best friends that didn’t last for so long either and I’ve seen plenty of marriages finishing much earlier than that.

Living on the world we live, it’s hard to remember exactly how it was five years ago. I’d say I was still using a landline for internet access. And I was sharing the 54K connection using a proxy.. how uncool is that? ;)

A bit over five years ago, gmail was launched.. More than five years later, gmail is finally removing the “beta” tag.

http://googleblog.blogspot.com/2009/07/google-apps-is-out-of-beta-yes-really.html

And I feel fine

Posted in internet, javier ramirez | Tagged: , , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.