Porqué no debe escribir código en español

by Pablo Matamoros - 26 Marzo 2008

TranslationDebe pensar que me he vuelto loco. Hablar de no escribir código en español en Codespanish.com!

En realidad recomiendo el traducir su software al español y a otros idiomas. Cuando digo que no debería codificar en español me refiero a no utilizar español o ninguna otra lengua que no sea inglés en nombres de variables, archivos, funciones, etc. Los lenguajes de programación, scripting, comandos del sistema operativo, etc., están basados en la lengua inglesa. Entonces, ¿por qué no hacer lo mismo con su código?

Tomemos a modo de ejemplo el siguiente código en PHP del post “Crear un foro en PHP y Mysql”.


<?php
require(‘funciones.php’);
$id = $_GET["id"];
$citar = $_GET["citar"];
$row = array(“id” => $id);
if($citar==1)
{
require(‘configuracion.php’);
$sql = “SELECT titulo, mensaje, identificador AS id “;
$sql.= “FROM foro WHERE id=’$id’”;
$rs = mysql_query($sql, $con);
if(mysql_num_rows($rs)==1) $row = mysql_fetch_assoc($rs);
$row["titulo"] = “Re: “.$row["titulo"];
$row["mensaje"] = “[citar]“.$row["mensaje"].”[/citar]“;
if($row["id"]==0) $row["id"]=$id;
}
$template = implode(“”, file(‘formulario.html’));
include(‘header.html’);
mostrarTemplate($template, $row);
include(‘footer.html’);
?>

Puede que algunos angloparlantes sean familiares con varias de las palabras usadas, ya que se escriben en forma similar en inglés, por ejemplo: configuracion es configuration, ¿pero qué pasa con mostrarTemplate? Inclusive formulario (form en inglés) dará dolores de cabeza a más de un programador que no sepa español.

También hay que considerar que muchos programadores ni siquiera saben inglés. Puede ser que hablen idiomas sin raíz alguna en el latín, para ellos es suficientemente complicado interpretar funciones en inglés como require, echo, etc. ¿Imagine a un programador chino tratando de entender su código en español? Escribir código en inglés es crítico cuando se trabaja en proyectos open source.

Mi opinión es que se debe codificar en inglés: nombres de variables, funciones, clases, campos de datos…Cuando digo código, también hablo de bases de datos. Hay excepciones; objetos nombrados en inglés podrían ser un problema si el usuario final tiene libre acceso a la generación de listados, exportación de datos, etc.


No es difícil escribir su código en inglés. Use un diccionario español/inglés (le recomiendo www.wordreference.com). No se asuste, no se trata de escribir como Shakespeare, no se necesita tener buena gramática. Por ejemplo, en el código adjunto, mostrarTemplate podría cambiarse fácilmente por showTemplate.

Aunque usted no piense en tercerizar, compartir o vender su código, mezclar funciones en español con funciones nativas de un lenguaje de programación en particular es una mala práctica que puede conducir a confusión y duplicación de código. Por ejemplo, alguien podría escribir una función obtenerVariable cuando ya existe una función llamada getVariable (get significa obtener) incluida en la librería de su lenguaje de programación. Si usted hubiese escrito su código en inglés y por error duplicase la función getVariable, es muy probable que el compilador o el intérprete del código le advierta de este error. Esto es poco probable que suceda si se mezclan distintos idiomas en su código.

¿Qué hacer con los comentarios dentro del código? Aunque puede que sea difícil para aquellos sin conocimientos de inglés, la realidad es que normalmente la mayoría de los comentarios constan de una o dos oraciones. Como mencione anteriormente, no se trata de escribir en perfecto inglés. Hay varias herramientas que pueden ayudarle a traducir oraciones simples. Freetranslation.com es una de mis favoritas. Nótese que estas herramientas no son 100% exactas, todavía no hay nada que supere a la traducción humana. Si usted necesita traducir un manual, el contenido de su website o los mensajes que su software muestra al usuario, por favor emplee un traductor profesional.

No me malinterprete, soy un fuerte defensor de mi lengua materna, el español, pero no soy tonto. En el mundo de hoy, en cualquier momento una compañía extranjera podría hacerle una oferta por los derechos de su producto. Por ejemplo, el año pasado Google compró Panoramio, un proyecto creado por el español Eduardo Manchón. Si su código no es fácil de entender para aquellos programadores que no sepan español, será más difícil su mantenimiento (se estaría limitado a la contratación de programadores hispanos). Este último punto podía ser tema de discusión con inversionistas internacionales.

Le guste o no, inglés es el esperanto de la tecnología y los negocios de estos tiempos. Usted debería escribir su código en inglés.

14 Comments on “Porqué no debe escribir código en español”

  1. TecnoSiervo Says:

    Lo primero, muy bueno el artículo, y lo segundo, que si hicieramos el codigo en español, muchos programadores que no fueran españoles se romperian la cabeza no? y en el codigo en inglés (el actual) yo también me rompo la cabeza para poder medio-entender el código en ingles…

  2. JohnPo Says:

    Interesante artículo pero antes de escribir sobre traducciones procura utilizar bien tú también las palabras traducidas del inglés: “library” significa “biblioteca” al igual que “command” significa “órden” y no comando……..los comandos son los del ejército. Por muy internacionalizados que estén estos términos TODOS sabemos que están mal dichos/traducidos y que su utilización es INCORRECTA.

    Un saludo.

  3. Pablo Matamoros Says:

    TecnoSiervo:

    “si hicieramos el codigo en español, muchos programadores que no fueran españoles se romperian la cabeza no?”

    Entiendo tu punto, y se que no es fácil para alguien que no sepa inglés. Todo depende de que pretendas hacer con tu código. Si estas 100% seguro que solamente programadores hispanos van a ver tu código, obviamente no te preocupes por escribir tu código en inglés.

    Pero te diría que hoy en día, en un 80% (número caprichoso, nada científico en esto) de los casos, tu código va a terminar en manos de cualquier programador del mundo. En mi experiencia, escribí código para sistemas usados únicamente en Argentina que terminaron en manos de gente de Canadá y Bélgica.

  4. Pablo Matamoros Says:

    JhonPo,

    Lo que dices es cierto a medias. Yo trato de escribir en un español “internacional” (si es que existe). En Argentina (donde estudié) la mayoría de los libros de informática son traducidos en Méjico o Argentina, con lo cual hay terminologías que pueden diferir de la traducción española.

    En particular, el término librería es correcto, al igual que biblioteca. Se pueden usar indistintamente según la REA. Fijate en estos links:
    http://es.wikipedia.org/wiki/Librer%C3%ADa
    http://es.wikipedia.org/wiki/Biblioteca_(programaci%C3%B3n)
    http://209.85.173.104/search?q=cache:kYorUjnZapAJ:es.wikipedia.org/wiki/Biblioteca_(programaci%C3%B3n)+libreria+de+programacion&hl=en&ct=clnk&cd=2

    En cuanto a comandos, deriva de la línea de comandos (comand line) de los sistemas operativos. Otro link para que leas:
    http://es.wikipedia.org/wiki/Comando_%28inform%C3%A1tica%29

    Se que las referencias son de Wikipedia, puede que no sean 100% correctas. De todos modos mi idea es crear un foro en el próximo mes, para discutir temas relacionados a la traducción de textos informáticos. Además, para quien quiera contactar programadores hispanos viviendo en otros países, etc.

  5. Pablo Matamoros Says:

    TecnoSiervo , JohnPo:

    Gracias por sus comentarios constructivos.

  6. Pablo Rigazzi Says:

    Pablo, cómo estás?

    Como verás, soy el autor original del artículo “crear un Foro en PHP y MySql” que luego fue republicado en MaestroDelWeb gracias a mi amigo Christian Van Der Henst. Y tengo un muy buen motivo para haber elegido el castellano en la programación de este proyecto:

    “Es una aplicación para que la gente aprenda a programar”.

    Tan simple como eso. No pretendía que el código fuera lanzado como OpenSource, o que se hiciera un Fork, o que se volviera utilizado (algo que igualmente sucedió). Mi intención tan solo residía en que alguien pudiera leer el código, y hacer el mínimo esfuerzo para entender el funcionamiento.

    Luego, para cualquier tipo de proyecto, soy el principal y más ferviente promotor de la utilización de estándares y convenciones de programación, y entre una de ellas es la de escribir código en inglés (esto más que nada porque mis clientes son en su mayoría angloparlantes).

    Solo quería dejarte este comentario para que no malinterpretes mis intenciones: sigo creyendo que a la hora de escribir un tutorial o una aplicación que enseñe una metodología o que se de como ejemplo, utilizar el lenguaje principal del programador es fundamental para limitar la barrera de entrada.

    Saludos.

  7. Pablo Matamoros Says:

    #Pablo

    Gracias por tu comentario.

    Voy a modificar mi artículo para reflejar lo que me has dicho o cambiar el código por otro diferente (de mi autoría). La intención no era hacer un ataque personal a tú código o a tu persona, era simplemente porque estaba trabajando a la par en ambos textos y tenía tú código a mano.

    Respecto a reutilizar tu texto, pedí autorización a Christian y a Stephanie para republicar artículos de Maestros. Sinceramente no recuerdo porqué no te envié un correo a ti también, suelo hacerlo.

    Te pido mil disculpas si te he ofendido u ocasionado algún inconveniente

  8. paan Says:

    “Even formulario (meaning form in Spanish) will give a headache to more than one programmer who doesn’t speak Spanish.”

    Apparently reading comments in spanish also leaves me in the same state of headache-ness :D

  9. Pablo Matamoros Says:

    #paan

    You are right. Unfortunately at the moment it is not worthy for me to filter the comments depending on the language. I don’t have enough comments in my website :(

    However, it is definitely in my “to do list”

  10. fluminis Says:

    Interesting point.

    This is true not only for spanish developers of course.

    I am used to write code in full english even my comments in all of my projects. But I started a new job one month ago : variable name, class and comments have to be in french ! It’s a bit dificult to understand… and I am French !

  11. Felipe Sarro Says:

    This makes no sense at all. This idea must only come from a system developer, and not a linguist. The only reason why you should code in English (and not in the language of your own country) is if you work in a transnational company (or if you are writing open-source software), and your code is supposed to be read by several people from different countries.

    You won’t get any duplicated code if you pre-set patterns with your team. The problem with obtenerVariable and getVariable is not a matter of language itself, but a lack of patterns.

    The suggestion of using on-line dictionaries is simply stupid. Each language has its own subtleties that only a native speaker can deal with. On-line dictionaries make much more mistakes than exact translations. And what we get? A code full of imprecise terms. Will this imprecise code be easier to understand than the non-English precise version? Clearly not. In both cases you have words whose real meaning you don’t know.

    Another problem that happens frequently is that the “English level” of all developers differs from each other. As a result, we have a code written in English, with imprecise, bad pronounced terms, that may often be misunderstood. It has become a commonplace to say lots of unnecessary neologisms in English, only because one day someone had the stupid idea that saying the word in English is better than in Portuguese (as I’m a Brazilian developer, I code in Portuguese).
    Not to mention how ridiculous it is to say a complete sentence in Portuguese with few nouns in English (imagine you are doing pair programming…), only for a matter of… code.

    How long will people keep working for money and companies, instead of working for… people? Why sacrifice the well-being of the workers for the cool sake of business? English is not (and has never been) a kind of Esperanto. Esperanto is a much fairer language, if we intend it to be used by everyone in the world. No nation speaks Esperanto. It’s simple and has no idiomatic expressions. Esperanto should be the international language, but unfortunately it’s not. In fact, English will not remain much time as an international language. If one day the USA loose its place as ‘center of the world’, the international language will not be English anymore. Maybe Chinese, due to its economic potentials? Then our code written in imprecise English will be less valuable than that written in Spanish.

    I’m no linguist.
    But I’m against any kind of undervaluation of any true human interest. And this is clearly an undervaluation of one’s culture, and even one’s well-being at working.

  12. Pablo Matamoros Says:

    #Felipe

    I don’t think you got my point. I am not underrating my language or any other language. In fact, if you explore this website you will understand that my purpose is quite the opposite. I am actually promoting the work of Hispanic developers (Profiles section, tutorials, etc.) and my culture (the store section features Hispanic movies). However, it is a fact that English is a universal technical language. I don’t know for how long, but at the moment it is. After all, Latin was a universal language in the Roman times until the empire was dissolved.

    In regards to the use of online dictionaries, I am actually writing an article about when you should use them. In summary:

    - translations of single words are very accurate (in particular in Spanish).
    - translations of simple sentences have some mistakes.
    - translations of complex structures are awful.

    If you include very long descriptions of the logic of your programs inside the code, you
    are mistaken. Your project documentation is the place for a detailed description of the logic and data structure. The documentation can (must) be written in your native language (preferably by a technical writer). If it is necessary to translate to other languages, this task should be done by native speakers of those languages with technical background (I don’t trust on the translations of average professional translators).

    “The only reason why you should code in English (and not in the language of your own country) is if you work in a transnational company (or if you are writing open-source software), and your code is supposed to be read by several people from different countries.”

    Precisely, that is my point. Open Source applications are becoming more and more popular and Outsourcing is one of the biggest businesses. Most ICT Latinamerican companies are growing due to Outsourcing (mainly from the US).

    Now, if you are going to develop webapps for your local video store or a proprietary application for a local business and you don’t feel comfortable with English, go ahead and write your code in your native language.

    I am not a linguistic either. I am actually a software developer. What I wrote is based on personal experience.

  13. henk Says:

    I absolutely agree with the author. Coding in any other language than English is just plain stupid. Now you may cry that currently you only operate in Spain, but who knows what the future brings. Perhaps your business will boom tomorrow and you’ll expand to Italy.

    Also, don’t forget that at least Europe has a more or less completely open internal market for its workforce. As a Spanish company, you can hire Dutch, German or French programmers. Given the current scarcity of good programmers this sometimes may be your only option. How on earth are you going to let a Dutch programmer work with your Spanish source code?

    Next to that, thing about possibilities of selling your code. No German company is -ever- going to buy Spanish source code. Most likely not even a large Spanish company will buy your code, as most large companies (that operate internationally and/or have a multi-lingual workforce) have already established code conventions that say English is the default language.

    Furthermore, when asking questions on forums for which you have to copy paste fragments of your source, you constantly have to rename all your variables. No one is going to look into your code fragment if it uses Spanish variable names or comments (unless it’s a pure Spanish forum of course, but even then…)

  14. Felipe Sarro Says:

    IT IS a matter of depreciation native languages. It may not be your intention, but it is the consequence.

    instead of ‘seriar’ (in Portuguese), people are saying ‘seriALIZar’, due to the English word ‘serialize’
    instead of ‘iniciar’, people are saying ‘iniciALIZar’, due to ‘initialize’
    instead of ‘cifrar’, people are saying ‘criptografar’, due to ‘cryptography’
    instead of ‘devolver’, prople are saying ‘retornar’, due to ‘return’

    it’s difficult to find someone who says ‘servidor’ (Portuguese), instead of ‘server’, and ‘núcleo’ instead of ‘kernel’. And these people do not even pronounce correctly (most Brazilians have difficulties pronouncing SERVER and KERNEL).

    people make imprecise translations into English, pronounce them wrongly, and mixture them in a sentence in Portuguese, with unnecessary neologisms.

Leave a Reply