Main

Topics

Links

The D Language

E-Mail

This page is dedicated topics relating to the D language developed by Walter Bright at Digital Mars (TM). D has it's syntactic roots in C and it's object oriented features are similar to Java. While C++ has become a a very powerful language it's overall complexity has become nearly untenable. D seeks to retain much of the power of C++ while throwing away a lot of things make C++ such a difficult language to learn and implement. Please take a look at the language specification at Digital Mars and see for yourself.

D Language
February 25, 2003 : D Closures D Language STL

Move over STL algorithms, D is in the house!

As of Alpha 0.57 the D compiler can do dynamic functional closures and anonymous functions. D's syntax I think leads to much more elegant way for defining generic programming algorithms. Take a look at the following example. The key line is:

  PersonSort(people,
        delegate bit(Person a, Person b) { return a.name < b.name; } );
You can see that a simple comparison function is defined inline in the call to the sort routine.



template SortTemplate(Type)
{
  void insertionSort(Type array[], bit delegate(Type a,Type b) lessThan)
  {
    for (int i=1; i < array.length; i++)
    {
      Type index = array[i];
      int j = i;
      while ((j > 0) && lessThan(index,array[j-1]))
      {
        array[j] = array[j-1];
        j = j - 1;
      }
      array[j] = index;
    }
  }
}


class Person
{
  this(char[] n, int a)
  {
    name = n;
    age = a;
  }

  char[] name;
  int    age;
}


alias instance SortTemplate(Person).insertionSort PersonSort;


void PrintByName(Person[] people)
{  
  PersonSort(people,
        delegate bit(Person a, Person b) { return a.name < b.name; } );

  printf("\nPeople by sorted by name\n========================\n");
  for(int i = 0; i < people.length; ++i)
    printf("%.*s,%d\n",people[i].name,people[i].age);
}


void PrintByAge(Person[] people)
{  
  PersonSort(people,
        delegate bit(Person a, Person b) { return a.age < b.age; } );

  printf("\nPeople by sorted by age\n========================\n");
  for(int i = 0; i < people.length; ++i)
    printf("%.*s,%d\n",people[i].name,people[i].age);
}



void main(char[][] argv)
{
  Person people[];

  people ~= new Person("Zeb",27);
  people ~= new Person("Betty",22);
  people ~= new Person("Casy",15);
  people ~= new Person("Mike",50);
  people ~= new Person("Linda",12);
  people ~= new Person("Freda",33);
  people ~= new Person("Rudy",45);
  people ~= new Person("Holly",18);

  PrintByName(people);
  PrintByAge(people);
}
February 01, 2003 : Glud 0.04 D Language Glud Download

Here is a new GLUD download. Not much new in this version. There is the beginning of a OpenGL canvas as well as Tab controls. DMD 0.51 allowed me to fix some template problems I had.

GLUD v0.04 works with DMD v0.51
New screenshots
December 07, 2002 : Glud 0.03 D Language Glud Download

I'm am very interested in doing application development for Windows using D. There are a couple of GUI library development projects going on for D. Due to my own particular ideas I am currently handcrafting my own too.

I have put together a base framework for this system but it is as yet quite immature, Current development is an event driven process where I work on an particular application un till I need some new GUI feature from the library. At which point I add it. As a consequence there are and will continue to be for some time large undeveloped gaps in functionality.

Even though it's not very complete I am offing the source for download. I think there are good reasons for doing this. One is that D is a new language and there few programming examples out there. Another is that it can provide someone with a jump start on their own D GUI projects. However in it's current state it's not something that the uninitiated in Windows programming can pick up and use.

So download it if you like. There is a copyright notice on the source. It basically says you can do what ever you want with it without fee. I frankly don't even really care if you credit me or not if you use it.

Do to limitations on my own time it's unsupported right now. I welcome comments but I may not be able to respond to suggestions or bugs in a timely fashion. Remember also that the D compiler is currently under development too. Changes in the language specification can and have in the past have broken my code.

GLUD v0.03 works with DMD v0.50
New screenshot
November 05, 2002 : Glud D Language Glud

Compiler bugs all fixed. Back to work. Currently plodding away at splitter window layouts.

October 21, 2002 : Glud D Language Glud

It's been a while but I haven't abandoned the D windows library. Right now I'm holding development until a few compiler bugs are fixed. After that I'll start work again. Unfortunately, the latest version for download probably doesn't work with DMD v0.45 due to some issues with interfaces.

I am also going to start calling it Glud for GUI library using D.


Archive Index by Month