120 points · by ingve · 11y ago · 67 comments
I'm not asking whether or not their approaches are different, but whether or not they're trying to solve the same problem(s). I get the sense that this is the case; they're both trying to be a "safe C(++)".
Can you elaborate as to other ways Rust has worse performance?
Could've sworn I've read somewhere the Rust maintainers stated that Rust will never have a switch to disable bounds checking. Has this changed?
> Can you elaborate as to other ways Rust has worse performance?
I don't know of any other specifics, but benchmarks usually show D outperform Rust (and often enough, everything else), e.g.:
https://togototo.wordpress.com/2013/07/23/benchmarking-level...
Being pragmatic is a very questionable claim. Its exact meaning varies from time to time, and a property that a certain people consider to be pragmatic can be considered to be not pragmatic by another people. It's mostly meaningless.
For example, for embedded devices D is a no-go from the beginning. I'm not just saying the reliance on GC. D has a few ridiculous behavior that may cost significantly on the low resource devices, such as http://forum.dlang.org/thread/mr6bl7$26f5$1@digitalmars.com D is never pragmatic in this area. But of course, D may be pragmatic in other areas.
> expressive
D and Rust have different kinds of expressiveness. While D has much better compile-time metaprogramming, how do you express affine type in D? In Rust affine type is very fundamental and we can utilize it to define the exact meaning of our programs.
> and generally has better performance (e.g. bounds checking is optional).
What? How can a GC'ed language be faster than a non-GC'ed language? Besides simple numeric evaluation, D is generally more heap-allocation-heavy than Rust, so it can never beat Rust. After all, there's no point in Rust if it's slower than a GC'ed language. The benchmarks you linked are questionable too, as their results say D is faster than C. Are you really sure D can outperform C in general cases?
Why should a GC'ed language be slower than a non-GC'ed language?
The evidence [0,1,2] seems more like: Given enough memory, GC is faster.
Non-GC means explicit deterministic free at specific points in the source code. A garbage collector has the freedom to delay the free, which means potential for optimization.
[0] https://people.cs.umass.edu/~emery/pubs/gcvsmalloc.pdf [1] http://www.cs.princeton.edu/~appel/papers/cmljava.html [2] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.1...
I disagree that it is meaningless. It's simply subjective. I've used D since 2006 and tried most new programming languages that appeared since, and it seems like they all tried to solve a specific problem (e.g. Go - concurrency, Rust - memory safety) while giving less attention to everything else.
> For example, for embedded devices D is a no-go from the beginning.
Existing D projects contradict that. They simply don't use the standard D runtime when it's not appropriate. Alternative runtimes exist. Rust users do the same thing: http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-...
> D and Rust have different kinds of expressiveness. While D has much better compile-time metaprogramming, how do you express affine type in D? In Rust affine type is very fundamental and we can utilize it to define the exact meaning of our programs.
Can you provide a good example of affine types and how they help with expressiveness?
My view of expressiveness in D does not stop at compile-time metaprogramming. For example, here's an excerpt from one of my programs:
http://dump.thecybershadow.net/fb6c5a080c7a42ecd8d1f062b58a5...
> How can a GC'ed language be faster than a non-GC'ed language?
It is entirely plausible. For example, deallocation/destruction can run in a background thread, heap compaction removes heap fragmentation and improves cache locality, and of course throwing away all memory after the program is done executing is very practical if the program would otherwise do little deallocating overall.
> Are you really sure D can outperform C in general cases?
I don't know what's going on there, but "higher-level" languages outperforming C is not that uncommon, for example due to stricter aliasing rules or SIMD array vector operations, or simply due to language or standard library facilities being readily available (e.g. STL or associative arrays) which would be cumbersome or impractical to write/maintain in C versions.
I would be interested in benchmarks showing that. Do you have any?
I'm just repeating a critique that I read, I haven't evaluated them against one another.
Having a GC excludes you from some programming domains -- well controlled latency, bootstrapping/operating systems.
- The language has the @nogc attribute to ensure at compile time that the GC is not used in a function or an entire module.
- The number of standard library functions that have the @nogc attribute is increasing by the minute. :)
- There is some effort to port Sociomantic's proprietary multi-threaded GC to D (theirs was written for D1).
Even without the GC, D is still a good "better-C" language. The GC didn't stop people writing bare-metal / operating system kernels in D:
https://github.com/JinShil/D_Runtime_ARM_Cortex-M_study/wiki/1.1---Hello,-World!
https://github.com/xomboverlord/xombOberon, Modula-3, Singularity designers don't share the same opinion
Note that the safety benefits must of course be weighed against the number of moving parts in the type system you desire for your project.
Of course D is interested in those concepts, simply not to the extent that Rust is. For example, D has:
- pure functions
- opt-in strict memory safety (@safe)
- sealed references (http://wiki.dlang.org/DIP25)
- transitive immutability
- shared types
Ali
Ali
Can you give us us some godo area when dlang can be used?
Can we use dlang to build IOS/Android apps?
What is the advances of this language over go, python, java, ruby, rust?
I used to frequent C and C++ forums on Turkish web sites and was aware of the need for up-to-date software documentation. I saw D as an opportunity to ensure that for once, Turkish documentation would not be behind the English ones. I started writing HTML pages without any idea that they would become a book later on.
Then I've decided to use the tool Prince XML (free for personal use) to see the pages in book form. I made that PDF version available as well.
I had never thought that my work would be valuable for an English-speaking audience. Then, Andrei and others convinced me that it would be a good idea to translate the book to English as well. I did that, added many more chapters, edited heavily (mostly by Luís Marques), and it worked!
As far as I know, the book is the first software documentation that was translated from Turkish to English, as opposed to the other direction.
D is a general purpose language. I don't know the status on the IOS/Android front. gdc, the D compiler using GCC back-end; and ldc, the D compiler using LLVM back-end can produce code for the platforms that those compilers support. However, don't take my word on that. I would expect issues.
D is a compiled language that is as low as C (and of course inline assembly) and as high as Python and others. One benefit over Go is the fact that D's template support is the best that I know of. When compared to D's C++'s templates are almost unusable; very clumsy.
Ali
Go: Generic type-safe highly efficient code. Can go lower-level like inline assembly. Can go higher-level because more meta programming.
Python: Faster. Static typing.
Ruby: See Python.
Java: Less boilerplate. More control over memory management. More meta programming. Natively compiled.
Rust: Easier. Garbage collection makes programming just as safe and is easier to use. Looks and feels more like C/C++/Java, if you already know them. More meta programming.
(of course, downsides of D are omitted ;)
OpenJDK is only the reference implementation. There are plenty of commercial implementations with AOT compilers.
Edit: did not write != properly
It's a work in progress, but simple things are possible.
https://github.com/smolt/ldc-iphone-dev http://wiki.dlang.org/GDC/Installation/Android
FWIW, I installed Debian on my Android phone, on which I installed GDC. Building and running D programs just worked.
I like the syntax of D instead of rust, because it is much more like c++. The syntax of rust is weird to me.
D has a nice framework for servers (vibed.org), so you can write webservices (REST,JSON,etc). There is no great full-stack web framework like Rails or Django though.
GUI stuff works in theory, but I don't know any non-toy project. Games (OpenGL,SDL) are possible, but no serious project, yet.
Android/iOS does not really work, yet. Same with embedded, standalone, kernel stuff. ARM in general needs more work. For HPC it really depends on the use case (see dlangscience.github.io). Vector support and GPU integration is lacking. I don't know any image, video, or audio processing stuff in D.
I also suspect, that C++ is more of a result of design-by-commitee, whereas D is - to a substantial degree - the brain-child of a single person.
tl;dr: With D you use whatever is best for you.