Last update July 28, 2009

Coming From /

Porting is covered in JavaToD

What D and Java have in common:

  • Have a syntax heavily influenced by C/C++.
  • Use garbage collection.
  • The "." operator is always used (instead of -> or :: operators)
  • Include null as a keyword.
  • Values are initialized before they're used.
  • Feature error handling using try-catch-finally.
How D is different:
  • There is no VM in D. Everything is compiled to machine code.
  • D allows pointers (not that their use is encouraged).
  • In D 'private' member data can be accessed from anywhere in the same module (file)
  • D has a goto command (if you need it it's there).
  • D has conditional compilation (with version/debug statements)
  • In D, one can use integers to govern if statements.
  • Java has the boolean type, but in D, it's bool
  • Java has a String class, D has char[] (since 1.016/2.000 there's a string type alias)
  • D has dynamic arrays and hashes built-in (they are classes in Java)
  • D has unittests and contracts built-in (they are libraries in Java)
  • D's modules are similar to packages, but symbols can be imported into the global scope.
  • You can use inline assembly in D. (if the D compiler supports it)
  • D doesn't have an 'instanceof' operator, because casting checks for the validity of the cast and returns null if it isn't valid. Ex: With Cat cat = cast(Cat) dog;, cat would be null if dog can't be cast to a Cat.
  • D has extensive support for static metaprogramming (Java only supports generics)
More information:


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: July 28, 2009 1:26 (diff))