[SP-pm] SaoPaulo-pm Digest, Vol 71, Issue 49

thiagoglauco at ticursos.net thiagoglauco at ticursos.net
Fri Aug 20 07:16:36 PDT 2010


Quoting Pinguim Azul <bluepenguin em gmail.com>:

> On Fri, Aug 20, 2010 at 10:03 AM,  <thiagoglauco em ticursos.net> wrote:
>>  Embora eu discorde da opinião do autor que Perl tenha uma sintaxe estranha,
>> que é o que estou tentando provar aqui... é muito mais fácil e rápido
>> programar em Perl por que a estrutura do Perl é mais próxima da estrutura de
>> um idioma real. Possui prefixos que indicam os tipos de token (@ $ %). Outra
>> coisa são os castings de tipo... a real pain in the nuts para iniciantes em
>> programação... Para iniciantes é muito mais simples usar uma linguagem que
>> faça isso automaticamente. Isto também aproxima mais a linguagem do nível
>> humano. Do contrário desenvolvimento em Perl não seria tão mais rápido que
>> em C ou Java!!!
>
> Sabia que, por esses argumentos, você está dizendo que MSX-BASIC é
> mais legível que C? MSX-BASIC também usa símbolos pra indicar os tipos
> de variáveis (A$=string, A%=inteiro, A#=float, etc).

Ter sufixos ou prefixos é um auxiliar para identificar do os assuntos  
tratam. Isso acontece com os idiomas humanos.

>
> Se o problema é legibilidade e aproximar o código da compreensão
> humana, então acho tanto os exemplos do Kernigham quanto os que você
> reescreveu bem ruinzinhos. Assim fica bem melhor:

Os meus exemplos foram ruins mesmo. Concordo plenamente. Por isso  
apoiei meu argumento no fato da velocidade do desenvolvimento. Parte  
dele se deve a estrutura da linguagem. Continuo achando uma ótima  
sacada.
>
> float convert_to_fahrenheit(int celsius) {
>   return 5.0*(celsius-32.0)/9.0;
> }
>
> void print_fahrenheit_table(int start, int end, int step) {
>   int celsius;
>   for (celsius = start; celsius <= end; celsius += step)
>     printf("%3d %6.1f\n", celsius, convert_to_fahrenheit(celsius);
> }
>
> int main() {
>   print_fahrenheit_table(0, 300, 20);
>   return 0;
> }
>
> Agora sim fica fácil pra qualquer um entender o que esse código faz, e
> você poderia fazer o mesmo em perl. O próximo passo é colocar uns unit
> tests pra garantir que isso funciona mesmo. (Ou, em outras palavras,
> legibilidade não depende da linguagem e sim do programador).

Fato verídico, maus programadores estragam o C e o Perl

>
> De curiosidade, quando eu estava em NY em 2007 eu passei na mesa do
> Kernigham pra tirar uma foto com ele, mas ele já tinha ido embora.

Que azar...

> Tudo que tinha na mesa era um pote de cup noodles que ele tinha comido
> antes de sair. Aí eu fiquei na dúvida: PEGO ou NÃO PEGO um pote de
> noodles comido pelo Kernigham pra trazer de souvenir?! Acabei não
> pegando, mas vontade não faltou :)

Tirou uma foto da mesa??? isso seria um souvenir legal!!!

como seriam as mesas do Larry Wall, Kernigham, Tanembaum...???

>
> --
> Ricardo Bittencourt
> http://www.ricbit.com
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>

Deixa eu recorrer ao prórpio Larry para reforçar meu argumento, já que  
meus exemplos não estão ajudando:

1.2. Natural and Artificial Languages

Languages were first invented by humans, for the benefit of humans. In  
the annals of computer science, this fact has occasionally been  
forgotten. Since Perl was designed (loosely speaking) by an occasional  
linguist, it was designed to work smoothly in the same ways that  
natural language works smoothly.

...

As in English, Perl's primary type distinction is between singular and  
plural data. Strings and numbers are singular pieces of data, while  
lists of strings or numbers are plural. (And when we get to  
object-oriented programming, you'll find that the typical object looks  
singular from the outside but plural from the inside, like a class of  
students.) We call a singular variable a scalar, and a plural variable  
an array. Since a string can be stored in a scalar variable, we might  
write a slightly longer (and commented) version of our first example  
like this:

$phrase = "Howdy, world!\n";          # Set a variable.
print $phrase;                        # Print the variable.

Note that we did not have to predefine what kind of variable $phrase  
is. The $ character tells Perl that phrase is a scalar variable, that  
is, one containing a singular value. An array variable, by contrast,  
would start with an @ character. (It may help you to remember that a $  
is a stylized "s", for "scalar", while @ is a stylized "a", for  
"array".)
...
Some language purists point to these funny characters as a reason to  
abhor Perl. This is superficial. These characters have many benefits,  
not least of which is that variables can be interpolated into strings  
with no additional syntax. Perl scripts are also easy to read (for  
people who have bothered to learn Perl!) because the nouns stand out  
from verbs. And new verbs can be added to the language without  
breaking old scripts. (We told you Perl was designed to evolve.) And  
the noun analogy is not frivolous?

ENFASE AQUI>>>>>
there is ample precedent in English and other languages for requiring  
grammatical noun markers. It's how we think! (We think.)
<<<<<<
...

Eu apenas concordo com isso. Todos são livres para discordar.





More information about the SaoPaulo-pm mailing list