On Thursday, 27 February 2014 at 10:27:41 UTC, Timothee Cour
wrote:
A1)
Google's Dart (https://www.dartlang.org) looks like a very
promising
replacement for javascript. It can compile to javascript to
ensure
portability (but chromium runs it natively) but the language
itself reminds
more of D to a surprising extent. Dart language has features
such as:
static typing (but can also have dynamic typing, akin to
std.variant, with
better support/syntax than D)
ahead of time compilation
unicode support
built in serialization/deserialization via json
annotations
mixins (used to emulate multiple inheritance)
generics
vector/AA litterals
alias (called typedef in dart), is, assert
try/catch/finally
operator overloading
properties (same parenthesis-less caller syntax as in D)
delegates (called closures)
nesting functions, 1st class functions, lambda => syntax
DDOC (called dartdoc)
D-like syntax and nesting comments,
introspection (runtime only AFAIK)
A2)
Also features that would be nice to have in D or were better
designed than
in D:
* cascade operations: they perform a series of operations on
the members of
a single object:
foo.bar(1)..baz(3)
equivalent to:
foo.bar(1)
foo.baz(3)
* better way to define default constructors:
class Point {
num x;
num y;
num z;
// Syntactic sugar for setting z and x before the constructor
body runs.
Point(this.z, this.x){...}
}
This is more explicit and flexible than D's way for default
struct
constructors, which can only allow to set all fields in order,
without
skipping some, and doesn't allow to do anything else in the
ctor.
* named constructors
* distinguish integer divide (~/) vs divide (/), so that 5/2=2,
5~/2=2
* shorthand function declaration with => (used not just for
lambdas)
* for (var x in collection) //better syntax than
foreach(var;collection)
* better syntax for optional positional arguments:
void fun(int x, [int y, int z=3]){...}
Thinking of which, this would actually solve a long standing
problem in D,
that of specifying optional parameters AFTER a variadic
template:
void fun(T...)(T args, [string file=__FILE__,int
line=__LINE__]){...}
* export for libraries
* async/wait etc
* great IDE/debugger/package manager/static analyzer
also the following which I've previously proposed adding to D:
* string interpolation $variableName (or ${expression})
assert('foo. ${s.toUpperCase()} bar' == 'foo. STRING
INTERPOLATION bar');
* optional named parameters arguments (with simplest possible
syntax)
* import all except specified symbols:
import 'package:lib2/lib2.dart' hide foo; // Import all names
EXCEPT foo.
A3)
And then some design decisions which wouldn't work for D:
everything is an
object, no struct (just class), VM, etc.
A4)
there were may previous threads regarding using D on the web
via compiling
to javascript. In light of this it would seem a lot easier to
compile D to
dart.
I've hear that Microsoft's equivalent so-called TypeScript was
more successfully than Google's one, more people like much more
TypeScript syntax and features, like I do.