Skip navigation.
Home

Delight: D with Python syntax

Ever wondered what D would be like if its syntax was inspired by Python instead of C? I had to find out, and the result is Delight.

I find the code easier to read without all the extra braces and parenthesis. Delight inherits all the D goodness: classes, interfaces, templates, exceptions, dynamic bounds-checked arrays, etc. Compared to Python, you get speed and static type checking.

I couldn't resist throwing in a few random changes of my own: built-in logging and a modified type system that checks for null pointers statically. I also removed all global state (static variables), and various other things I don't approve of.

All highly experimental, of course. Get it while it's hot...

reddited

Thanks! For a language which

Thanks! For a language which mostly prints Hello World in interesting ways, it seems to be well received ;-)

Yeah, well the reddit crowd

Yeah, well the reddit crowd really likes to bash/praise new languages. I find the tabs vs spaces arguments depressing however. Also, the 'OMG no globals/statics!' people seem to have never heard of functional programming, yet every other reddit programming article seems to be about haskell, ocaml, erlang or some other functional language. /shrug

Anyway, it sounds pretty cool. Especially the LLVM ideas. I wonder if/when LLVM-based tools will eclipse GCC.

One question

Why invent yet another language when there are good languages out there: O'Caml, Haskell, Smalltalk, Scheme? Why invent another language when all innovations it brings is just a shiny new syntax?

For fun?

Because it's fun?

Besides, it's more about collecting together existing innovations (D language, Python syntax, Nice type checking, dependency injection).

I can't really imagine people writing ROX applications in the languages you suggest. Haskell is very nice, but pretty slow. O'Caml is fast but ugly. Both are tricky for people unused to functional programming. Smalltalk and Scheme don't seem to give much over Python, IMO.

At the moment, we've basically got a choice of Python (nice, but heavy-weight) or C/C++ (fast, but ugly and easy to crash), sometimes even for the same app (e.g. two versions of ROX-Session, one in Python and one in C).

But mainly because it's just fun ;-)

But Haskell is pure fun

>I can't really imagine people writing ROX applications in the languages you suggest.

Uhmm... why not? I believe coding in Haskell is fun :) Pure fun. ;)

>Haskell is very nice, but pretty slow.

This is not true. Generally, Haskell's standard IO is really slow (laziness...), but ByteString and Binary give the necessary boost.

>At the moment, we've basically got a choice of Python (nice, but heavy-weight) or C/C++

Haskell and O'Caml both have GTK bindings. So... you're not bound to either Python or C++. :)

>But mainly because it's just fun ;-)

Would you mind if I suggest some features? :)

  • type inference all around (as far as D supports it)
  • optional type signature for functions
  • free standing functions (so you don't have to mess with Managers, Dispatchers, Executors whose sole purpose lies in a single run() method)

It already has most of that.

It already has most of that. e.g. type interence:

int y = (function(int x): x + 1)(5)

(return type is inferred as "int")

or

auto layout = new SomeLongClassName()

However, you would lose a lot of the speed advantages if it couldn't tell the type (this is why PyRex can't do much with normal Python code). And I rather prefer having the types explicit.

You can use & to take the address of a function and pass it around (unlike in Java). e.g.

import dlt.io

class Main:
	in string[] args
	in Printer stdout

	void printIt(string msg):
		stdout.formatln("Argument: {}", msg)

	void main():
		xargs(args, &printIt)

void xargs(string[] args, void delegate(string arg) callback):
	for x in args:
		callback(x)

Delight 0.2

Delight 0.2 release announcement

Main (huge!) change is that it's now based on D2, not D1.

I've added a mailing list, so I'll announce any new versions there rather than here in future, unless it's relevant to ROX.

Delight 0.3

Now with (limited) GTK support.

Release announcement

Syndicate content