Is D so powerfull ??

ZombineDev via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 7 06:24:59 PST 2015


On Saturday, 7 November 2015 at 12:49:18 UTC, BSaidus wrote:
> Hello!
> I've heard about Dlang 2 years ago, and I discovered it about 3 
> days.
> So
>   * I wonder if it is so powerfull as C ?
>   * Is it portable (crosse plateform) ?
>   * Can I do anything with it ?
> Excuse me for for these questionsn i'm a begginer.
>   It seems that I begin like it so, reconforte me please !!
>
> Thanks.

D is very well supported on the major desktop platforms (Windows, 
Linux, OSX, FreeBSD) and there's currently work in progress to 
bring D to mobile (iOS and Android). Apart from the reference DMD 
compiler, there are two other compilers that share the same 
frontend, but use GCC's and LLVM's backend (GDC and LDC 
respectively). There is work being done on those compilers to 
extend D's reach to the support of their C++ counterparts (e.g. 
embedded ARM, MIPS, etc.).

Because D's builtin types have fixed size (unlike the varying 
size of e.g. C's int and long on various platforms), its ABI is 
more easier to work with. D's very strong support for conditional 
compilation makes abstracting platform specific code easier than 
in C++.

You can do in D anything that you can in C, so D is at least as 
powerful as C is.
Actually, the D is much more powerful than C, because the support 
for this style of programming is only a small part of D.

C procedural system programming (pointer arithmetic, void*, 
function pointers, malloc, realloc, alloca, free, unions, 
alignment control, static and dynamic linking with C programs and 
libraries, system calls, etc.) Using these features, some 
assembly bootstrap and a linker script you can make a bare-bones 
micro kernel.

Java/C# style object-oriented programming (interfaces, classes 
(reference types), polymorphism, encapsulation, run-time type 
information, nested/inner classes, anonymous classes, exceptions, 
GC, etc.) Using these features you can develop any library or 
application that would typically be written in Java / C#.

C++ style programming (structs (value types), RAII, operator 
overloading, low-perf cost thin abstractions, const, templates, 
containers, allocators, smart pointers, similar to STL 
algorithms, nothrow, nogc, etc)

Functional programming (immutability, purity, 
lambda/anonymous/nested functions, tuples, lazy algorithms, 
function pipelining with UFCS, etc)
http://klickverbot.at/blog/2012/05/purity-in-d/
http://dlang.org/phobos/std_functional.html
http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/
http://wiki.dlang.org/Component_programming_with_ranges
http://www.mmartins.me/view/2015/09/27/vector-swizzle-in-d

Design by contract: http://dlang.org/contracts.html

Metaprogramming, Compile-time function execution (CTFE): I don't 
know if there's a definite tutorial specifically on one D's 
strongest features, but here's some links to check:
dlang.org/phobos/std_traits
dlang.org/phobos/std_typecons
https://www.youtube.com/watch?v=mCrVYYlFTrA - Desing by 
introspection
https://www.youtube.com/watch?v=SqeOPLB2xAM - Declarative 
programming in D
https://www.youtube.com/watch?v=xpImt14KTdc - Simplifying Code 
With Compile-Time Reflection

If you are looking for a more complete overview of D's features, 
you can check this feature comparison page: 
http://dlang.org/comparison.html

What standard C does not provide and D does: calling C++ free 
functions nested in namespaces, creating objects of C++ classes 
(with single inheritance)



More information about the Digitalmars-d mailing list