python: cabe no seu bolso, no seu micro, no seu cérebro

Post on 18-Dec-2014

1.135 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Versão apresentada na Unicamp em Agosto 2010. Presented at Unicamp in August 2010

TRANSCRIPT

Python:Cabe no seu bolso,

no seu micro,no seu cérebro

Rodrigo Dias Arruda SenraIC-UNICAMP / HI Tecnologia

Apenas um rapaz latino americano...

• Desenvolvedor e Projetista de Softwarena HI Tecnologia (desde 2008)

(no mercado desde 1996 )

• Engenheiro de Computação Graduação-MSc-(PhD em curso) IC-Unicamp

• Entusiasta de FLOSS(atuante na comunidade Python desde 1999)

2

Uma palavra dos patrocinadores...

Uma palavra dos patrocinadores...

Uma palavra dos patrocinadores...

Uma palavra dos patrocinadores...

Uma palavra dos patrocinadores...

Quem está aí ?

Quem está aí ?

• Estudantes ?

Quem está aí ?

• Estudantes ?

• Professores ?

Quem está aí ?

• Estudantes ?

• Professores ?

• conhecedores de Python ?

Quem está aí ?

• Estudantes ?

• Professores ?

• conhecedores de Python ?

• Membros de python-brasil@ ?

Quem está aí ?

• Estudantes ?

• Professores ?

• conhecedores de Python ?

• Membros de python-brasil@ ?

• Membros da APyB ?

Vamos falar do quê ?

• O Graal do desenvolvedor ?

• Escolhendo uma linguagem

• Contextualizando Python

• Vocabulário Ofidiglota

O Graal do Desenvolvedor

O Graal do Desenvolvedor

• Facilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade• Estabilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade• Estabilidade• Portabilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade• Estabilidade• Portabilidade• Interoperabilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade• Estabilidade• Portabilidade• Interoperabilidade• Extensibilidade

O Graal do Desenvolvedor

• Facilidade• Legibilidade• Estabilidade• Portabilidade• Interoperabilidade• Extensibilidade• Escalabilidade

O Graal do Desenvolvedor

• Rapidez no ciclo de Desenvolvimento

• Facilidade• Legibilidade

• Estabilidade

• Portabilidade

• Interoperabilidade

• Extensibilidade

• Customização

• Escalabilidade

• Segurança

O Graal do Desenvolvedor

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

50

FortranLISP

Harddisk

CircuitoIntegrado

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

50

FortranLISP

Harddisk

CircuitoIntegrado

60

COBOLSIMULABASICLOGO

ITSOS360

MULTICS

Mouse

InterrupçõesVirt.MemARPANET

RS-232

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

50

FortranLISP

Harddisk

CircuitoIntegrado

60

COBOLSIMULABASICLOGO

ITSOS360

MULTICS

Mouse

InterrupçõesVirt.MemARPANET

RS-232

70

PascalC

SmalltalkProlog

UNIXCP/MVMS

Floppy

Micro-processador

PONGTCP/IP

Ethernet

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

50

FortranLISP

Harddisk

CircuitoIntegrado

60

COBOLSIMULABASICLOGO

ITSOS360

MULTICS

Mouse

InterrupçõesVirt.MemARPANET

RS-232

70

PascalC

SmalltalkProlog

UNIXCP/MVMS

Floppy

Micro-processador

PONGTCP/IP

Ethernet

80

AdaC++PerlSQL

LISAMacintosh

UNIXMS-DOSWindows

1.0-2.0OS/2

MINIXAIX

HPUXSCOGNURISC

Go

2000

DC#

Mac OSXLinux

WindowsME

2000XP

Vista7

40

Plankalkü

Transistor

50

FortranLISP

Harddisk

CircuitoIntegrado

60

COBOLSIMULABASICLOGO

ITSOS360

MULTICS

Mouse

InterrupçõesVirt.MemARPANET

RS-232

70

PascalC

SmalltalkProlog

UNIXCP/MVMS

Floppy

Micro-processador

PONGTCP/IP

Ethernet

80

AdaC++PerlSQL

LISAMacintosh

UNIXMS-DOSWindows

1.0-2.0OS/2

MINIXAIX

HPUXSCOGNURISC

90

JavascriptPython

JavaPHP

BeOSLinuxSolaris

Windows2.0 - 98

OpenBSD

ISAWWW

Go

A eterna busca pela ferramenta perfeita

A verdade dói...

# Edsger W.Dijkstra, 18 Junho 1975 http://www.cbi.umn.edu/inv/burros/ewd498.htm

A verdade dói...

# Edsger W.Dijkstra, 18 Junho 1975 http://www.cbi.umn.edu/inv/burros/ewd498.htm

FORTRAN --"the infantile disorder"--, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use

A verdade dói...

# Edsger W.Dijkstra, 18 Junho 1975 http://www.cbi.umn.edu/inv/burros/ewd498.htm

PL/1 --"the fatal disease"-- belongs more to the problem set than to the solution set

A verdade dói...

# Edsger W.Dijkstra, 18 Junho 1975 http://www.cbi.umn.edu/inv/burros/ewd498.htm

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration

A verdade dói...

# Edsger W.Dijkstra, 18 Junho 1975 http://www.cbi.umn.edu/inv/burros/ewd498.htm

The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence

Truth lies on statistics!

http://www.tiobe.com

http://www.tiobe.com

Top 10 - SourceForge

Top 10 - SourceForge

Top 10 - SourceForge

http://flossmole.org/category/queries/sourceforge - June 2009

Java

C++

PHPC

Python

C#

Javascript

x86 Ubuntu™ Intel® Q6600® one core - http://shootout.alioth.debian.org/ 

Segurança PHP JavaPerl Python

Fonte: http://nvd.nist.gov/nvd.cfm

Segurança

0

2.250

4.500

6.750

9.000

junho 2007 abril 2008

3828

1.7661.537

871735

8.121

6.690

CV

E -

Com

mon

Vul

nera

bilit

ies

and

Exp

osur

es

PHP JavaPerl Python

Fonte: http://nvd.nist.gov/nvd.cfm

Duelo de linguagens

Duelo de linguagens

Duelo de linguagens

import java.io.*;import java.util.*;import java.text.*;public class sumcol {public static void main(String[] args) { int count = 0; String line; try { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); while ((line = in.readLine()) != null) { count = count + Integer.parseInt(line); } } catch (IOException e) { } System.out.println(Integer.toString(count));

Java

import java.io.*;import java.util.*;import java.text.*;public class sumcol {public static void main(String[] args) { int count = 0; String line; try { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); while ((line = in.readLine()) != null) { count = count + Integer.parseInt(line); } } catch (IOException e) { } System.out.println(Integer.toString(count));

Javausing System;class App {public static int Main(String[] args) { int count = 0; for (String line = Console.In.ReadLine(); line != null; line = Console.In.ReadLine()) { count += System.Convert.ToInt32(line); } Console.WriteLine(count.ToString()); return(0); }

C#

import java.io.*;import java.util.*;import java.text.*;public class sumcol {public static void main(String[] args) { int count = 0; String line; try { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); while ((line = in.readLine()) != null) { count = count + Integer.parseInt(line); } } catch (IOException e) { } System.out.println(Integer.toString(count));

Javausing System;class App {public static int Main(String[] args) { int count = 0; for (String line = Console.In.ReadLine(); line != null; line = Console.In.ReadLine()) { count += System.Convert.ToInt32(line); } Console.WriteLine(count.ToString()); return(0); }

C#import syscount = 0while 1: line = sys.stdin.readline().strip() if not line: break count += int(line)print count

Python

import java.io.*;import java.util.*;import java.text.*;public class sumcol {public static void main(String[] args) { int count = 0; String line; try { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); while ((line = in.readLine()) != null) { count = count + Integer.parseInt(line); } } catch (IOException e) { } System.out.println(Integer.toString(count));

Javausing System;class App {public static int Main(String[] args) { int count = 0; for (String line = Console.In.ReadLine(); line != null; line = Console.In.ReadLine()) { count += System.Convert.ToInt32(line); } Console.WriteLine(count.ToString()); return(0); }

C#import syscount = 0while 1: line = sys.stdin.readline().strip() if not line: break count += int(line)print count

Pythonimport sys, itertoolsprint sum(itertools.imap(int, sys.stdin))

Python

Who is using Python ?

Who is using Python ?

Who is using Python ?

Who is using Python ?

Who is using Python ?

Python é ...

• propósito geral

• foco em produtividade do desenvolvedor

• multi-plataforma e multi-paradigma

• pilhas incluídas

• floss software

• fácil de extender e embutir

• madura (criada em1989, liberada ao público 1991)

Interoperabiilidade

✴ Jython (Python implementado em Java)

✴ CPython (onde existir compilador C ISO/IEC 9899:1990)

✴ IronPython (implementado em C# pela M$)

✴ PyPy (Python implementado em... Python)

✴ Python for .NET [Brian Lloyd]

✴ Win32all [Mark Hammond] (adeus VBA!)

✴ PyObjC (Mac OSX middleware)

✴ Python for Delphi [Morgan Marat]

✴ LunaticPython [Gustavo Niemeyer]

✴ Ruby/Python (importar módulos Python em Ruby)

✴ Python + Fortran

Hora da Demo

Dá tempo de vero Python em ação ?

É possível ?Seria pedir muito ?

Pygame

Python no celular S60

Bancos de Dados

from psycopg import *o = connect(“ dbname=teste user=fulano” )c = o.cursor()c.execute(“ SELECT * FROM nome_da_tabela” )row = c.fetchone()print rowx = [ ('valor_1', 'fulano', 0), ('valor_2', 'beltrano', 5), ('valor_3', 'ciclano', 15)]c.executemany(" " " INSERT INTO outra_tabela VALUES (%s, %s, %s)""", x)c.commit()

Networkingfrom twisted.internet.protocol import Protocol, Factoryfrom twisted.internet import reactorfrom time import asctime

class TimeServer(Protocol): def dataReceived(self, data): self.transport.write(asctime())

def main(): f = Factory() f.protocol = TimeServer

reactor.listenTCP(8000, f)reactor.run()main()

Web Services

from SOAPpy import SOAPProxyfrom SOAPpy import Types

google = SOAPProxy( 'http://api.google.com/search/beta2', 'urn:GoogleSearch')results = google.doGetCachedPage('Pd6ke...ArQoX' , 'www.owls.org')

of = open('cached_page_response.html', 'w')of.write(results)of.close()

SciPy

import viewfrom Numeric import *x = arange(-3, 6, .04)y = arange(-12, 12, .08)y = sin(y)*exp(-y*y/18.0)z = x * y[:,NewAxis]view.view(z)

Apps

Referências

Mergulhando no Python: Mark Pilgrim (Alta Books) Python in a Nutshell: Alex Martelli (O'Reilly) Python Cookbook: Alex Martelli, David Ascher (O'Reilly) Python Programming on Win32: Mark Hammond (O'Reilly) Jython Essential: Noel Rappin, Samuele Pedroni (O'Reilly) Foundations of Python Network Programming: John

Goerzen (Apress)

Conclusão

• Ágil, madura e moderna

• Fácil aprendizado

• Comunidade Ativa

• Fartura de documentação

• Divertida ;o)

Não tenha medo, experimente Python!

Não tenha medo, experimente Python!

Obrigado a todos pela atenção.

Rodrigo Dias Arruda Senrahttp://rodrigo.senra.nom.br

rsenra@acm.org

As opiniões e conclusões expressas nesta apresentação são de exclusiva responsabilidade de Rodrigo Senra.

Não é necessário requisitar permissão do autor para o uso de partes ou do todo desta apresentação, desde que não sejam feitas alterações no conteúdo reutilizado e que esta nota esteja presente na íntegra no material resultante.

Imagens e referências para outros trabalhos nesta apresentação permanecem propriedade daqueles que detêm seus direitos de copyright.

top related