The Artima Developer Community
Sponsored Link

PHP Buzz Forum
interesting languages - D

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Alan Knowles

Posts: 390
Nickname: alank
Registered: Sep, 2004

Alan Knowles is Freelance Developer, works on PHP extensions and PEAR.
interesting languages - D Posted: Feb 17, 2006 9:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Alan Knowles.
Original Post: interesting languages - D
Feed Title: Smoking toooo much PHP
Feed URL: http://www.akbkhome.com/blog.php/RSS.xml
Feed Description: More than just a blog :)
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Alan Knowles
Latest Posts From Smoking toooo much PHP

Advertisement
It's either Continuing Professional Development, or just getting so bored that learning something new is the only cure. But I finally sat down this week a dug into D.

D, for the uninformed, is billed by it's author as a successor to C++, (and to some respect C). The website is a little tricky to understand (the 4 links on the left are the key navigation - Language = Overview of language, and Phebos = core library docs). The Documentation is clear, and reasonably well expressed with quite a few examples. (although it could probably do with PHP's comment system.)

There is also a PEAR/CPAN style site, dsource.org, which has a few projects written in D. including wrappers around common C libraries (which make them more OO like - even though you can directly access C calls in the language without wrappers.).

What makes this language interesting is quite a few key points
  • It compiles into .exe/binary/.so/.dll etc.
  • The core library is tiny ~1Mb (500K striped) compared with the classic java/C# frameworks
  • memory management (autofreeing at the end of each function) - so you dont need to splatter the code with malloc)(/free()
  • The core library is small and limited (so I dont have to learn 1000's of classes/packages to understand code)..
  • The code syntax is similar to PHP/Java/C# etc. for class construction / definition,
  • native Arrays and Associative Array's, just like PHP!.
  • No need for .h header files
  • It's pretty damn fast! - beat's gcc in benchmarks (well even considering you always take them with a pinch of salt)
  • It just works....
A simple D Code... (It's LGPL'ed from the DUI distribution)
/* See original for copyright - I've removed for the example) */

// give this file a module name (bit like namespaces)
module hw.HelloWorld;

// private imports so that any code importing this,
// doesnt import these as well.
// so you dont flood the global namespace too much..
private import dui.MainWindow;
private import dui.DUI;

public:
class HelloWorld : MainWindow // it extends MainWindow..
{
private import dui.Label; // imports can go here as well..

char[char[]] testarray = [ // yah - native array's in prop. def's
"one": "1",
"two": "2"
];

this() // yeap that's the constructor..
{
super("DUI Hello World"); // like parent::_construct()
this.setBorderWidth(10); // you dont need this. , but
// I think it add's clarity.

this.add(new Label("Hello World" ~ testarray["one"]));
// string concat with the ~
// operator.
this.show();
}
}

void main(char[][] args)
{
DUI dui = DUI.dui(args); // pass parameters to Gtk+
new HelloWorld();
dui.go(); // start the main event loop
}

Click on the more bit for the full story..

Read: interesting languages - D

Topic: In defence of PHP* Previous Topic   Next Topic Topic: New Developments

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use