dynamic classes and duck typing

retard re at tard.com.invalid
Tue Dec 1 01:49:17 PST 2009


Tue, 01 Dec 2009 01:08:11 -0800, Walter Bright wrote:

> grauzone wrote:
>> Walter Bright wrote:
>>> dsimcha wrote:
>>>> In Java, by going overboard on making the core language simple, you
>>>> end up pushing all the complexity into the APIs.
>>>
>>> Yup, and that's the underlying problem with "simple" languages.
>>> Complicated code.
>> 
>> I think users of scripting languages would disagree with you.
> 
> PHP?

Php is a terrible joke built by a novice http://tnx.nl/php.html. Fans of 
e.g. ruby, python etc. could argue that their language has less corner 
cases and more uniform features, which makes the development more of a 
joy to do and code less verbose. Instead of two variations, in many cases 
there is only one choice - e.g.

 - type known at runtime/compile time -> known at runtime
 - generic type / ordinary type -> runtime dynamic type
 - primitives/objects -> everything is an object
 - special set of built-in operators / normal methods -> everything is a 
message
 - static classes / objects -> objects (some are singletons but can 
inherit from interfaces etc. unlike statics in d)
 - free functions / methods / static methods -> methods (the modules are 
singleton objects -> free functions are module methods)
 - functions / delegates -> functions
 - special set of built-in control structures -> simple primitive (e.g. 
recursion & library defined structures)
 - statements / expressions -> everything is an expression (this unifies 
e.g. if-then-else and a ? b : c)
 - built-in AA, array, list etc. -> library defined collections
 - dozens of primitive number types -> fixed size int & float (e.g. 32bit 
int and 64bit float), arbitrary precision int & float (rational type)

Overall these simplifications don't remove any crucial high level 
language features, in fact they make the code simpler and shorter. For 
instance there isn't high level code that can only be written with 8-bit 
byte primitives, static methods or closures, but not with 32-bit generic 
ints, singletons, and generic higher order functions. The only thing you 
lose is some type safety and efficiency.



More information about the Digitalmars-d mailing list