Import concerns revisited

Derek Parnell derek at nomail.afraid.org
Wed Jul 12 17:28:35 PDT 2006


On Wed, 12 Jul 2006 17:03:11 -0700, Walter Bright wrote:

> Derek Parnell wrote:
>> On Thu, 13 Jul 2006 05:05:22 +1000, Walter Bright 
>>> It's not always true, but languages that are less wordy in their 
>>> example code tend to be picked up faster. People's first projects in D 
>>> aren't going to be large, complex, professional products. They'll want 
>>> to just try it out on something simple. That bar should be as low as 
>>> reasonable.
>> 
>> I understand your desire to not 'frighten' new comers away. My concern 
>> is that your "low as reasonable" seems to encourage poor programming 
>> practices. Can you provide an example where the 'import' and 
>> 'visibility' ideas being brainstormed at the moment would force example 
>> code to look scary? At worst, someone might have to add 'public { ... }' 
>> somewhere.
> 
> Not exactly what you're after, but consider the Java hello world program:
> 
>    class HelloWorldApp {
>      public static void main(String[] args) {
>          System.out.println("Hello World!");
>      }
>    }
> 
> There's a reason for everything there, but it's a little off-putting. 
> Consider the D version:
> 
>    import std.stdio;
> 
>    void main() {
>       writefln("Hello World!");
>    }

Thank you! This is exactly what I had hoped for, because the changes
discussed recently would not alter this example one iota. In fact, the
changes only start to kick in when programs get more complex, and that's
exactly when you need to introduce such protection concepts to D newcomers.
 
> I can go straighter towards what I want to do, without detouring through 
> all the other requirements Java puts on things that seem, with such a 
> simple program, to be beside the point.
> 
> Just for fun, here's an Ada version:
> 
>    With STANDARD_IO;
>    Use STANDARD_IO;
>    Procedure HELLO_WORLD is begin
>      Put("Hello world!");
>    End HELLO_WORLD;
> 
> No thanks! <g>

Ouch! And I just remembered what it would look like in COBOL (oh the
horror!)

Here it is in Euphoria (one line) ...

  puts(1, "Hello world!")

but now we digress because Euphoria's import (include) system is almost as
problematic as D's. In that language one can have independent third party
libraries clashing with each other just because you decided to include both
of them into your application, even if you never reference the clashing
members.

But back on track, the sample code in the D tutorials will have zero
changes in nearly every case, and minor changes in the others to explain
how the protection system can work in the coder's favour.
-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
13/07/2006 10:17:13 AM



More information about the Digitalmars-d mailing list