tolf and detab
Pelle
pelle.mansson at gmail.com
Fri Oct 1 06:13:25 PDT 2010
On 10/01/2010 01:54 PM, bearophile wrote:
> Bruno Medeiros:
>
>> From my understanding, Scala is a "scalable language" in the sense
>> that it easy to add new language features, or something similar to that.
>
> I see. You may be right.
>
>
>> But I'm missing your point here, what does Ada have to do with this?
>
> Ada has essentially died for several reasons, but in my opinion one of them is the amount of code you have to write to do even small things. If you design a language that is not handy to write small programs, you have a higher risk of seeing your language die.
>
>
>> but I simply didn't see much language
>> changes that could have made my D more succint,
>
> Making a language more succint is easy, you may take a look at J or K languages. The hard thing is to design a succint language that is also readable and not bug-prone.
>
> Python has some features that make the code longer, like the obligatory "self." before class instance names and the optional usage of argument names at the calling point make the code longer. The ternary operator too in Python is longer, as the "and" operator, etc. Such things improve readability, etc.
>
> Several Python features help shorten the code, like sequence unpacking syntax and multiple return values:
>
>>>> def foo():
> ... return 1, 2
> ...
>>>> a, b = foo()
>>>> a
> 1
>>>> b
> 2
>
>
> List comprehensions help shorten the code, but I think they also reduce bug count a bit and allow you to think about your code at a bit higher level:
>
>>>> xs = [2,3,4,5,6,7,8,9,10,11,12,13]
>>>> ps = [x * x for x in xs if x % 2]
>>>> ps
> [9, 25, 49, 81, 121, 169]
>
>
> Python has some other features that help shorten the code, like the significant leading white space that avoids some bugs, avoids brace style wars, and removes both some noise and closing brace code lines.
>
>
>> barring crazy stuff like dynamic scoping)
>
> I don't know what dynamic scoping is, do you mean that crazy nice thing named dynamic typing? :-)
>
> Bye,
> bearophile
No, dynamic scoping is the crazy thing. Perl code:
#!/usr/bin/perl
$x = 1;
sub p {
print "$x\n"
}
sub a {
local $x = 2;
p;
}
p;
a;
p
results in:
pp ~/perl% perl wat.pl
1
2
1
Crazy. :-)
More information about the Digitalmars-d
mailing list