142 points · by jacques_chirac · 11y ago · 125 comments
Niklaus Wirth did write many of his compilers in the original language (kind of).
He would write down on paper the code, using the bootstrap version 0 code style, as it was supposed to be.
Then he would manually translate that code into Assembly.
So when the compiler for the basic language was working, he could use the same code again, without additional efforts and relying on third party languages.
Specially important back in the day where each computer system had its own systems programming language or dialect of an existing one.
In addition, the D authors are generally opposed to disciplined approaches, e.g. type classes, region-based memory management, which are being added to C++. Especially regarding the former, while "design by introspection" may have its merits (Andrei Alexandrescu's presentation on allocator is worth watching[2]), I think many still prefer explicit interfaces over implicit ones, so I don't see D take off in the near future, at least until the wanted features are added to the language.
[1] http://forum.dlang.org/thread/htmkdnmlqyvkidkrsmri@forum.dla...
Implicit numeric casts that lose bits are not allowed anymore.
> exception unsafety
??
That's good to hear, but I want implicit conversion to be forbidden unconditionally (even int * float -> float). I've been bitten by even widening conversions, so I just want to let them go away. It might be great if such an option could be applied to module level.
> ??
Sorry if my understandings or my words were wrong, but I got the impression that D also suffers from destructors that throw. (double-throw) Is this not the case in D? If so, could you elaborate how it achieves that?
I'm personally rather fond of purging exceptions from the language level completely, like Go did(Of course panics are technically exceptions, but their usage is culturally discouraged). Of course, this is just my personal opinion, but I would be happy if D had a story on this problem.
I don't think I'd want web and mail servers straight into the standard library out of the box. Those are way too specific. For example, there's already vibe.d for web servers and its doing an excellent job. They even have compile-time HTML templates!
As for IDEs, on Windows I've recently used VisualD and it did a good job. It's not yet as complete as the C# integration of Visual Studio (especially when taking ReSharper into account), but it definitely feels like an IDE. It already has improved hugely over when I last used it last year.
/bin/bash: line 1: 82501 Segmentation fault: 11 ./main
while I try to call a method on a null variable, which is not that friendly to newcomers.Sample code:
import std.stdio;
void main()
{
Greetings g = null;
g.hola();
} ~/temp_code » ./greetings
Traceback (most recent call last)
greetings.nim(9) greetings
greetings.nim(6) hola
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
For the code: type
Greetings = ref object
name: string
proc hola(g: Greetings) =
echo g.name
var g: Greetings
g.hola() $ cat main.d
import std.stdio;
class Greetings {
void hello() {
writeln("hello");
}
}
void main()
{
Greetings g = null;
g.hello();
}
$ dmd -g main.d && ./main
Segmentation fault: 11
$ uname -a
Darwin Johan-Ride-Mac.local 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
$ dmd --version
DMD64 D Compiler v2.069.0
Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
(EDIT: added osx and dmd versions) $ dmd -g main.d && ./main
Segmentation fault: 11
is there anything else I can try?I'm OSX El Capitan 10.11.1
import etc.linux.memoryerror;
shared static this() {
static if (is(typeof(registerMemoryErrorHandler)))
registerMemoryErrorHandler();
}2) Spanish ?
Only exception I promote is writing compilers in ML (esp Ocaml) because it's so good at doing that correctly. A concentration of compiler writers on such a great tool can only lead to an ecosystem whose quality C or C++ compilers will have trouble matching. Rewriting and testing the LLVM system at the least would be a good thing.
That said, D's compatibility with C++ is a big plus.
Well, not really. Higher-kinded type parameters are something that requires a kind (typeclass) system in the first place, which D intentionally doesn't have (as D's authors are opposed in principle).
I'm curious about this, although I don't think this is the first time I've heard D described as having a script-y feel to it. It sounds along the same lines as people describing Go as almost a scripting language, or comparing it to them. Neither Go nor D seem especially dynamic, both have compilers for reference implementations, both look more like C than Python. (To my eyes at least; I've never tried either one. Thus this question.)
Is it primarily the speed of the compilers? Both DMD and g6/g7/g8 boast very fast compiles, and Go uses somewhat script-y tools... but #!/usr/local/bin/tcc -run hasn't changed C's reputation. Fast compiling and memory safety, maybe?
In Rust you still can do "clever" things with generics to make them feel like C++, but the rest of the language is still closer to C: errors returned rather than thrown, no inheritance (but the "flat" OO and enums map well to what OO-like C programs do with "handles"), no constructors, etc.
This is a quite important part of Rust (IMHO) because it gives the language a performance profile closer to C than C++ in many instances.
Rust is marketed as a "general-purpose, multi-paradigm, compiled programming language" and D "originated as a re-engineering of C++", so may be I'm biased by my interpretation of the goals from both language designers.
In any case, congratulations.
I wonder if the C++ to D translator could be used in other codebases, like Fltk for example.
However you can write gc free code regions by marking them as @nogc and the compiler will make sure you only call code that is @nogc compatible.
Additionally, there is some ongoing discussion how to improve the language to depend less on the GC.
The C++ core guidelines are great, and me being a C++ fan even with its warts, welcome them and all the work the C++ community is doing.
However them being opt-in, relying on static analysis and the quality of the code I usually see at companies, which tends to be C with Classes from developers that don't even know what CppCon is, I am not sure how the adoption will be like.