Download Document 3410912
Document related concepts
no text concepts found
Transcript
LENGUAJES DE PROGRAMACIÓN: ¿POR QUÉ DEBEMOS SER POLÍGLOTAS EN LENGUAJES ARTIFICIALES? gtoscano@cinvestav.mx gtoscano@gmail.com Monday, August 29, 2011 ALGUNAS DEFINICIONES (RAE Y OTROS). Lexema 1. m. Ling. Unidad mínima con significado léxico que no presenta morfemas gramaticales. Léxico 2. m. Diccionario de una lengua. Sintáxis. 1. f. Gram. Parte de la gramática que enseña a coordinar y unir las palabras para formar las oraciones y expresar conceptos. 2. f. Inform. Conjunto de reglas que definen las secuencias correctas de los elementos de un lenguaje de programación. Monday, August 29, 2011 ALGUNAS DEFINICIONES (RAE Y OTROS) Gramática: 1. f. Ciencia que estudia los elementos de una lengua y sus combinaciones. Semántica: 2. f. Estudio del significado de los signos lingüísticos y de sus combinaciones, desde un punto de vista sincrónico o diacrónico. Lenguaje: Cualquier tipo de código semiótico estructurado, para el que existe un contexto de uso y ciertos principios combinatorios formales. Existen contextos tanto naturales como artificiales. Monday, August 29, 2011 ALGUNAS DEFINICIONES (RAE Y OTROS) El lenguaje humano se basa en la capacidad de los seres humanos para comunicarse por medio de signos. Principalmente lo hacemos utilizando el signo lingüístico. Los lenguajes formales son construcciones artificiales humanas, que se usan en matemática y otras disciplinas formales, incluyendo lenguajes de programación. Estas construcciones tienen estructuras internas que comparten con el lenguaje humano natural, por lo que pueden ser en parte analizados con los mismos conceptos que éste. Monday, August 29, 2011 CARLOS DE AUSTRIA, CARLOS I DE ESPAÑA O MEJOR CONOCIDO COMO CARLOS V "Hablo latín con Dios, italiano con los músicos, español con las damas, francés en la corte, alemán con los lacayos e inglés con mis caballos." "El hombre es tantas veces hombre cuanto es el número de lenguas que ha aprendido." Monday, August 29, 2011 CONCEPTUALIZACIÓN DEL MUNDO Muchas veces es más fácil explicar un concepto en lenguaje específico. Hay lenguajes más descriptivos (nieve) Lo busco y lo busco pero no lo busco. El concepto de prestar en Chiapas. Monday, August 29, 2011 ¿QUÉ ES UN LENGUAJE DE PROGRAMACIÓN? Es un lenguaje artificial diseñado para que a través de una serie de instrucciones escritas por un programador de acuerdo a un conjunto de reglas o convenciones (sintaxis) dada, pueda expresar computaciones que serán desempeñada por una máquina Monday, August 29, 2011 RAZONES PARA ESTUDIAR CONCEPTOS DE LENGUAJES DE PROGRAMACIÓN Incrementar la capacidad para expresar ideas. Mejorar el conocimiento para escoger el lenguaje apropiado. Incrementar la habilidad para aprender nuevos lenguajes. Mejorar el entendimiento del significado implementación. Mejorar conocimiento sobre computación. Monday, August 29, 2011 ¿Cuántos lenguajes de programación hay? Monday, August 29, 2011 HOPL: HISTORIA DE LOS LENGUAJES DE PROGRAMACIÓN (http://hopl.murdoch.edu.au/) Este sitio responde porqué las personas diseñan e implementan lenguajes y qué las influyó cuando lo hicieron (históricamente, filosóficamente, políticamente al igual que teoréticamente) Han sido desarrollados más de 1,720,000 descripciones sobre lenguajes de programación en los últimos 14 meses. El sitio lista 8512 lenguajes completos, con 17,783 registros bibliográficos. Monday, August 29, 2011 POR QUÉ ES IMPORTANTE CONOCER CONCEPTOS SOBRE LOS LENGUAJES DE PROGRAMACIÓN En 1976, en la conferencia de computación en los Alamos, Richard Hamming esbozó porqué deberíamos interesarnos en la historia de la computación: "deberíamos conocer qué pensaron cuando lo hicieron". Cuando los lenguajes fueron diseñados, ellos (los diseñadores) eligieron opciones específicas con las que tenemos que vivir. Monday, August 29, 2011 HOPL: HISTORIA Algunas veces la aparición de un nuevo lenguaje sucedió como el resultado del esfuerzo de una persona con el objetivo de buscar una solución: Forth, APL, Rexx, Perl, E, dBase son de este tipo. Algunas veces fue justo lo opuesto - se reunieron ciéntificos para deciri una solución - Algol 60 y 68, COBOL, PACT, Ada, CHILL, SQL son ejemplos de este tipo. En alguna parte en medio, se tuvieron equipos de diseñadores trabajando para un proyecto específico - FORTRAN, PL/I, Simula, R, CPL, SNOBOL, Logo, JOSS, MUMPS, BASIC. Algunos otros iniciaron del esfuerzo individual, pero fueron completados por equipos - C, POP, LISP, Smalltalk, Pascal, Javascript, GPSS, Simscript Monday, August 29, 2011 HOPL: HISTORIA Una vez que los lenguajes fueron implementados y están en uso, toman vida propia: los lenguajes no pueden ser cambiados fácilmente porque hay diversos programas que han sido escritos en dicho lenguaje. Los errores de diseño vienen a la luz tras el uso del lenguaje, y son rectificados - Niklaus Wirth lo llama agujeros-cíclicos del lenguaje. Monday, August 29, 2011 CUÁL ES TU LENGUAJE DE PROGRAMACIÓN? ES POPULAR? Se han desarrollado nuevos lenguajes de programación regularmente en los pasados 50 años. En 1954, salió a la luz Fortran, y en 1958 Algol y Lisp, en 1959 COBOL y en 1964 PL/I. Basic inició en 1965, BCPL y Simula en 1967 y Logo en 1968. B fue introducido en 1960, Pascal y Prolog en 1970, C en 1971, Smalltalk en 1972 y Scheme en 1975. Los 80s vieron nacer a Common LISP (1980), ADA (1983), C++ (1985), Objective-C, Objective Pascal e Eiffel (1986), Haskel (1987) y CLOS (1988). Java fue introducido en 1994, C# en 2002 y Go en 2009. Monday, August 29, 2011 TIOBE Tiobe es un sitio popular que jerarquiza lenguajes de programación basados en la disponibilidad mundial de ingenieros hábiles, cursos y manufactureros de software. Tiobe usa Google, MSN y Yahoo! para medir el impacto y popularidad de cada lenguaje. Debates sobre que lenguaje de programación es el más popular puede llegar a ser emocional o hasta una batalla casi religiosa. Monday, August 29, 2011 Hay un número de métricas para medir la popularidad de un lenguaje de programación: el número de nuevas aplicaciones, las aplicaciones actuales, los desarrolladores que lo usan como lenguaje principal, el número de búsquedas Web, la disponibidad de trabajos que requieren habilidades en dicho lenguaje, los lenguajes favoritos de los desarrolladores. Monday, August 29, 2011 TIOBE: TENDENCIAS Monday, August 29, 2011 Categoría Ratings Ago 2010 Delta Ago 2009 Lenguajes orientado-a-objetos 54.9% +0.6% Lenguajes procedurales 40.5% -1.0% Lenguajes funcionales 3.1% +0.2% Lenguajes lógicos 1.5% +0.2% Monday, August 29, 2011 POPULARIDAD Monday, August 29, 2011 POPULARIDAD Monday, August 29, 2011 POPULARIDAD En 1985, estaban en la lista sólamente 3 de los 10 lenguajes mejor posicionados en 2010. C era el número 1, C++ fue el número 10 y Visual BASIC ocupó el número 4. Monday, August 29, 2011 TENDENCIAS DE EMPLEO SEGÚN INDEED.COM Monday, August 29, 2011 LOS 10 LENGUAJES DE PROGRAMACIÓN QUE TE MANTENDRÁN EMPLEADO. Java PHP C# Objective-C C/C++ Perl JavaScript Python VisualBasic Ruby Monday, August 29, 2011 DOMINIOS DE PROGRAMACIÓN Aplicaciones científicas Primera computadora digital (1940s) Estructuras de datos simples Números grandes en puto flotante Ensamblador, Fortran, Algol 60, y sus descendienetes Aplicaciones de negocios 1950s Se desarrollaron computadoras especiales COBOL Inteligencia artificial Cómputo simbólico (nombres en lugar de números) Monday, August 29, 2011 Inteligencia artificial Listas ligadas en lugar de arreglos. LISP, Scheme, Prolog Programación de sistemas. 1960s y 1970s Software de sistema (Unix) Eficiencia (ejecución rápida) PL/I, ALGOL, C. Software Web Lenguajes de marcado. Lenguajes scrípticos HTML, PHP, Perl, JavaScript. 99 BOTTLES OF BEER (HTTP://99-BOTTLES-OF-BEER.NET) Este sitio Web mantiene una colección de la canción "99 Bottles of Beer" programado en diferentes lenguajes. La canción está representada en 1348 diferentes lenguajes de programación. La canción dice: Monday, August 29, 2011 Take one down and pass it around, 97 bottles of beer on the wall. .... 1 bottle of beer on the wall, 1 bottle of beer. 99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, no more bottles of beer on the wall. Take one down and pass it around, 98 bottles of beer on the wall. No more bottles of beer on the wall, no more bottles of beer. 98 bottles of beer on the wall, 98 bottles of beer. Go to the store and buy some more, 99 bottles of beer on the wall. AWK BEGIN { for(i = 99; i >= 0; i--) { print ubottle(i), "on the wall,", lbottle(i) "." print action(i), lbottle(inext(i)), "on the wall." print } } function ubottle(n) { return sprintf("%s bottle%s of beer", n ? n : "No more", n - 1 ? "s" : "") } function lbottle(n) { return sprintf("%s bottle%s of beer", n ? n : "no more", n - 1 ? "s" : "") } function action(n) { return sprintf("%s", n ? "Take one down and pass it around," : \ "Go to the store and buy some more,") } function inext(n) { return n ? n - 1 : 99 } Monday, August 29, 2011 PERL ''=~( .('`' .'==' ^'+') .';-' .('[' .'_\\{' ).(('`')| ).('['^'/') '\\"'.('['^ '{'^"\[").( ('{'^'[').( '`'|"\%").( '\\"\\}'.+( '+_,\\",'.( '`'|"\+").( '{'^"\[").( '[').("\["^ ')').("\["^ '.').("\`"| '+').("\!"^ '`'|('%')). Monday, August 29, 2011 '(?{' |'!') .('[' .'||' .'-'. ^'.') .'(\\$' '/').').' .('['^'/'). '#').'!!--' '`'|"\"").( '`'|"\/").( '{'^"\[").( '['^"\+").( '{'^('[')). '`'|"\%").( '`'|"\$").( '+').("\`"| '/').("\{"^ '.').("\`"| '+').'\\"'. '++\\$="})' .('`' .('`' ^'+') .(';' '\\$' .('`' .';=('. .'\\"'.+( ('`'|',').( .'\\$=.\\"' '`'|"\%").( '`'|"\.").( '['^"\,").( '['^"\)").( ('\\$;!').( '{'^"\[").( '`'|"\/").( '!').("\["^ '[').("\`"| '$')."\,".( ('['^',').( );$:=('.')^ |'%') |',') .('`' &'=') .'=;' |'"') '\\$=|' '{'^'['). '`'|('%')). .('{'^'['). '`'|"\%").( '{'^"\[").( '`'|"\!").( '`'|"\)").( '!'^"\+").( '`'|"\/").( '['^"\,").( '(').("\["^ '!').("\["^ '!'^('+')). '`'|"\(").( '~';$~='@'| .('[' .'"'. |'/') .(';' .('[' .('!' ."\|".( ('`'|'"') '\\".\\"'.( ('`'|'/').( '['^(')')). '['^"\/").( '`'|"\,").( '`'|"\.").( '{'^"\/").( '`'|"\.").( '`'|('.')). '(').("\{"^ ')').("\`"| '\\",_,\\"' '`'|"\)").( '(';$^=')'^ ^'-') '\\$' .('[' &'=') ^'(') ^'+') '`'^'.' .('`'|'/' '['^('(')). '`'|"\&").( '\\").\\"'. '`'|"\(").( '`'|(',')). '['^('/')). '`'|"\!").( '`'|"\%").( ','.(('{')^ '[').("\`"| '/').("\["^ .'!'.("\!"^ '`'|"\,").( '[';$/='`'; SCHEME (define bottles (lambda (n) (cond ((= n 0) (display "No more bottles")) ((= n 1) (display "One bottle")) (else (display n) (display " bottles"))) (display " of beer"))) (define beer (lambda (n) (if (> n 0) (begin (bottles n) (display " on the wall") (newline) (bottles n) (newline) (display "Take one down, pass it around") (newline) (bottles (- n 1)) (display " on the wall") (newline) (newline) (beer (- n 1)))))) (beer 99) Monday, August 29, 2011 SHAKESPEARE Romeo, a man who curses men and likes women, while taking up some space. Juliet, often the temporary affections of Romeo. The Ghost,holds his liquor. Hamlet, a man who is a bit jumpy. Oberon, o. Emilia, e. Titus, t. Ajax, n. Angelo, a. Shylock, s. Lennox, l. Bianca, b. The Abbot of Westminster, w. Desdemona, d. Robin, r. Capulet, ,. ! ! ! Act I: Where the action is. Scene I: Where the beginnings are located. [Enter Hamlet and The Ghost] Hamlet: ! Thou art as mighty as the sum of a proud rich trustworthy hero Monday, August 29, 2011 RUBY class Integer # The bottles def drink; self - 1; end end def sing(&step) puts "#{bottles.capitalize} of beer on the class << song = nil wall, #{bottles} of beer." attr_accessor :wall if @bottles.zero? print "Go to the store buy some more, " def bottles step = method :buy (@bottles.zero? ? "no more" : @bottles).to_s << else " bottle" << ("s" unless @bottles == 1).to_s print "Take one down and pass it around, " end end @bottles = step[@bottles] def of(bottles) puts "#{bottles} of beer on the wall." @bottles = bottles puts "" or wall.call unless step.kind_of? (class << self; self; end).module_eval do Method define_method(:buy) { bottles } end end self end end callcc { |song.wall| song.of(99) }.sing { |beer| beer.drink } Monday, August 29, 2011 PYTHON verse1 = lambda x: \ """%s of beer on the wall, %s of beer. Take one down, pass it around, %s of beer on the wall. """ % (bottle(x),bottle(x),bottle(x-1)) verse2 = \ """No more bottles of beer on the wall, no more bottles of beer. Go to the store, buy some more, 99 bottles of beer on the wall. """ def verse(x): if x==0: else: return verse2 return verse1(x) def bottle(x): if x==0: return "no more bottles" elif x==1: return str(x) + " bottle" else: return str(x) + " bottles" print "\n".join( [ verse(x) for x in range(99,-1,-1) ] ) Monday, August 29, 2011 PYTHON for quant in range(99, 0, -1): if quant > 1: print quant, "bottles of beer on the wall,", quant, "bottles of beer." if quant > 2: suffix = str(quant - 1) + " bottles of beer on the wall." else: suffix = "1 bottle of beer on the wall." elif quant == 1: print "1 bottle of beer on the wall, 1 bottle of beer." suffix = "no more beer on the wall!" print "Take one down, pass it around,", suffix print "--" Monday, August 29, 2011 ERLANG -module(beersong). -export([sing/0]). -define(TEMPLATE_0, "~s of beer on the wall, ~s of beer.~nGo to the store and buy some more, 99 bottles of beer on the wall.~n"). -define(TEMPLATE_N, "~s of beer on the wall, ~s of beer.~nTake one down and pass it around, ~s of beer on the wall.~n~n"). create_verse(0) -> {0, io_lib:format(?TEMPLATE_0, phrase(0))}; create_verse(Bottle) -> {Bottle, io_lib:format(? TEMPLATE_N, phrase(Bottle))}. phrase(0) -> ["No more bottles", "no more bottles"]; phrase(1) -> ["1 bottle", "1 bottle", "no more bottles"]; phrase(2) -> ["2 bottles", "2 bottles", "1 bottle"]; phrase(Bottle) -> lists:duplicate(2, integer_to_list (Bottle) ++ " bottles") ++ [integer_to_list(Bottle-1) ++ " bottles"]. bottles() -> lists:reverse(lists:seq(0,99)). sing() -> lists:foreach(fun spawn_singer/1, bottles()), sing_verse(99). Monday, August 29, 2011 spawn_singer(Bottle) -> Pid = self(), spawn(fun() -> Pid ! create_verse(Bottle) end). sing_verse(Bottle) -> receive ! {_, Verse} when Bottle == 0 -> ! io:format(Verse); ! {N, Verse} when Bottle == N -> ! io:format(Verse), ! sing_verse(Bottle-1) after ! 3000 -> ! io:format("Verse not received - re-starting singer~n"), ! spawn_singer(Bottle), ! sing_verse(Bottle) end. LUA function PrintBottleNumber(n) local bs if n == 0 then bs = "No more bottles" elseif n == 1 then bs = "One bottle" else bs = n .. " bottles" end return bs .. " of beer" end for bn = 99, 1, -1 do write(PrintBottleNumber(bn), " on the wall, \n") write(PrintBottleNumber(bn), "\n") write("Take one down and pass it around,\n") write(PrintBottleNumber(bn-1), " on the wall, \n\n") end write("No more bottles of beer on the wall,\nNo more bottles of beer\n") write("Go to the store, buy some more!\n") Monday, August 29, 2011 J bob =: ": , ' bottles of beer'"_ -. 1&= # 's'"_ bobw=: bob , ' on the wall'"_ beer=: bobw , ', '"_ , bob , '; take one down and pass it around, '"_ , bobw@<: beer"0 (- i.) 99 Monday, August 29, 2011 UN POCO DE J J es un lenguaje moderno derivado de APL, de propósito general con un fuerte énfasis en programación funcional y procesamiento de arreglos. J fue desarrollado por Ken Iverson y Roger Hui, e implementado por Iverson Software Inc (ISI). Monday, August 29, 2011 NO SÉ NI J DE J J se distingue por sus relgas simples y consistentes, un gran conjunto de funciones pre-construidas, poderosas faclidades para definir nuevos operadores y un tratamiento sistematizado y generalizado para menajar arreglos. Es ideal para trabajo analístico complejo, modelación y desarrollo rápido de aplicaciones. Si estás interesado en programar soluciones desafiando problemas de procesamiento de datos, entonces el tiempo que inviertas en aprender J, será bien gastado. Monday, August 29, 2011 PARA SABER ALGO MÁS QUE J DE J avg=: +/ % # avg 1 2 3 4 v=: ?. 20 $ 100 avg v 4 avg\ v m=: ?. 4 5 $ 50 avg"1 m quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#) */ 1 + i.5-1 Monday, August 29, 2011 OTROS EJEMPLOS Scheme Phython Go Monday, August 29, 2011 ALGUNAS PALABRAS DE ALAN KAY La mejor forma de predecir el futuro es inventarlo. Yo inventé el término "orientado a objetos", y te puedo asegurar que C++ no era en lo que estaba pensando. Java es lo más penoso que le ha ocurrido a la informática desde MS-DOS. Las personas que en realidad toman en serio el software, deben crear su propio hardware. Monday, August 29, 2011 “Hay dos formas de construir un diseño de software: El primero es hacerlo tan simple que no haya deficiencias obvias, y el segundo es hacerlo tan complicado que no haya deficiencias obvias. El primer método es por mucho el más difícil”. Tony Hoare. “Debemos olvidar las pequeñas deficiencias, se dice aproximadamente el 97% de las veces: Optimización prematura es la raíz de todos los males” por Donald Knuth Monday, August 29, 2011 Si no entienden intérpretes, podrás escribir programas; podrás ser un programador competente. Pero no podrás ser un maestro Hal abelson (Foreword of Essentials of Programming Languages) Monday, August 29, 2011 CONCLUSIONES Plática libre Monday, August 29, 2011
Related documents