www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Samples directory

reply Brad Roberts <braddr puremagic.com> writes:
Would anyone be interested in taking on the task of looking at the existing
samples and modernizing them?  Some should likely be junked as not terribly
educational examples.  Likely more should be added to illustrate other best
practices.

They can be found here:

  http://www.dsource.org/projects/phobos/browser/samples/d

Arguably they need to be versioned along with each branch of the language, so
assume they'll be moved to:

  http://www.dsource.org/projects/phobos/browser/branches/phobos-1.x/samples

and

  http://www.dsource.org/projects/phobos/browser/trunk/samples

I see no good reason to keep the 'd' part of the directory name, it's not like
the dmd .zip files are going to suddenly start shipping other languages.

See also:
 http://d.puremagic.com/issues/show_bug.cgi?id=2613

- Brad
May 17 2010
next sibling parent reply Piotrek <starpit tlen.pl> writes:
W dniu 18.05.2010 06:50, Brad Roberts pisze:
 Would anyone be interested in taking on the task of looking at the existing
 samples and modernizing them?  Some should likely be junked as not terribly
 educational examples.  Likely more should be added to illustrate other best
 practices.

 They can be found here:

    http://www.dsource.org/projects/phobos/browser/samples/d

 Arguably they need to be versioned along with each branch of the language, so
 assume they'll be moved to:

    http://www.dsource.org/projects/phobos/browser/branches/phobos-1.x/samples

 and

    http://www.dsource.org/projects/phobos/browser/trunk/samples

 I see no good reason to keep the 'd' part of the directory name, it's not like
 the dmd .zip files are going to suddenly start shipping other languages.

 See also:
   http://d.puremagic.com/issues/show_bug.cgi?id=2613

 - Brad
Hi Brad, I'm interested. Although I'm not so much experienced in D it would be great opportunity to stay in line with latest D 2.0 features. I even have some mist ideas about architecture of the whole business . (Keepin in mind that D should be a system and scripting language in one - the first one in computer history) Every module from std should have its coresponding imports within samples (let say 2-5 at least). There should be comparable example in but it's far from Windows and Dots slavery). Comparison should be done int three dimensions. - speed - bytes of code - memory usage (yes, all this is like quasi shootout project). (I would be nice for D to get all pole positions - however overall win is enough) I would set-up a project on some git host (github) , automate all things and publish results. It will take some time and as you can see a risk of failure is rather high. However I thought about contributing to D and you bring up a good idea. I will stay away from the official repository to not break anything. I'm starting work right now (with existing examples) but don't expect too much from it. If anyone has some a good argument for me to stop I'm listing. Cheers Piotrek
May 18 2010
parent reply Brad Roberts <braddr puremagic.com> writes:
On 5/18/2010 11:33 AM, Piotrek wrote:
 W dniu 18.05.2010 06:50, Brad Roberts pisze:
 Would anyone be interested in taking on the task of looking at the
 existing
 samples and modernizing them?  Some should likely be junked as not
 terribly
 educational examples.  Likely more should be added to illustrate other
 best
 practices.

 They can be found here:

    http://www.dsource.org/projects/phobos/browser/samples/d

 Arguably they need to be versioned along with each branch of the
 language, so
 assume they'll be moved to:

   
 http://www.dsource.org/projects/phobos/browser/branches/phobos-1.x/samples


 and

    http://www.dsource.org/projects/phobos/browser/trunk/samples

 I see no good reason to keep the 'd' part of the directory name, it's
 not like
 the dmd .zip files are going to suddenly start shipping other languages.

 See also:
   http://d.puremagic.com/issues/show_bug.cgi?id=2613

 - Brad
Hi Brad, I'm interested. Although I'm not so much experienced in D it would be great opportunity to stay in line with latest D 2.0 features. I even have some mist ideas about architecture of the whole business . (Keepin in mind that D should be a system and scripting language in one - the first one in computer history) Every module from std should have its corresponding imports within samples (let say 2-5 at least). There should be comparable example in but it's far from Windows and Dots slavery).
While not a bad goal, probably well beyond what is really needed for a 'samples' directory.
 Comparison should be done int three dimensions.
 - speed
 - bytes of code
 - memory usage
 
 (yes, all this is like quasi shootout project).
 
 (I would be nice for D to get all pole positions - however overall win
 is enough)
This part I actively disagree with. Samples don't need to be benchmarks. Some showing how to do some benchmarking of ones code, sure. But the point of sample code is to help a new person get their feet wet with the language, the compiler, the tools, etc. Not that there's not value in benchmarking, there certainly is. But that's not what I expect from the samples packaged with the compiler to be.
 I would set-up a project on some git host (github) , automate all things
 and publish results.
 
 It will take some time and as you can see a risk of failure is rather
 high. However I thought about contributing to D and you bring up a good
 idea. I will stay away from the official repository to not break anything.
 
 I'm starting work right now (with existing examples) but don't expect
 too much from it.
 If anyone has some a good argument for me to stop I'm listing.
I don't want to stop you.. but maybe redirect the enthusiasm a little?
 Cheers
 Piotrek
 
May 18 2010
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
I often find non-working samples in other languages/tools. For example, the
Python source code comes with a sample folder. And there's a script called
ss1.py, which raises an exception with the message "This code is not secure in
Python 2.2 and later". Python 2.2 was released in 2001, so I assume the samples
directory is not really maintained anymore. There are many more examples like
this, and in other languages/tools as well.

But how many people generally know of or would check the samples directory?

Personally, I tend to get my examples from either the documentation or from a
google search, tutorials found on the internet, etc. The internet is probably
the best place to store the samples to (e.g. a wiki), it can be maintained,
which means people could always get the most up-to-date samples. 

Compare this with having a sample file in the zipped DMD archive that you later
realize has some code that is not really safe. You will end up having to
re-pack and redistribute the entire archive. So imo, if there are any samples
in the archive they have to be kept simple and clean.

Thoughts?
May 19 2010
parent Jacob Carlborg <doob me.com> writes:
On 5/19/10 15:28, Andrej Mitrovic wrote:
 I often find non-working samples in other languages/tools. For example, the
Python source code comes with a sample folder. And there's a script called
ss1.py, which raises an exception with the message "This code is not secure in
Python 2.2 and later". Python 2.2 was released in 2001, so I assume the samples
directory is not really maintained anymore. There are many more examples like
this, and in other languages/tools as well.

 But how many people generally know of or would check the samples directory?

 Personally, I tend to get my examples from either the documentation or from a
google search, tutorials found on the internet, etc. The internet is probably
the best place to store the samples to (e.g. a wiki), it can be maintained,
which means people could always get the most up-to-date samples.

 Compare this with having a sample file in the zipped DMD archive that you
later realize has some code that is not really safe. You will end up having to
re-pack and redistribute the entire archive. So imo, if there are any samples
in the archive they have to be kept simple and clean.

 Thoughts?
How about http://www.dsource.org/projects/tutorials/wiki ?
May 19 2010
prev sibling parent Piotrek <starpit tlen.pl> writes:
W dniu 19.05.2010 04:51, Brad Roberts pisze:
 I'm starting work right now (with existing examples) but don't expect
 too much from it.
 If anyone has some a good argument for me to stop I'm listing.
I don't want to stop you.. but maybe redirect the enthusiasm a little?
OK. You did convince me. I will refine samples. I will spend some days (actually hours since I have a hard, regular work) in hiding and share results with you after that. Cheers Piotrek
May 19 2010
prev sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Brad Roberts wrote:
 Would anyone be interested in taking on the task of looking at the existing
 samples and modernizing them?  Some should likely be junked as not terribly
 educational examples.  Likely more should be added to illustrate other best
 practices.
I agree that the samples given are mostly crap. They could all be replaced/improved.
May 18 2010