Your SlideShare is downloading. ×
0
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
D lang
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

D lang

653

Published on

Why to use D programming? …

Why to use D programming?

Published in: Spiritual, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
653
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. .. .......... ...... ..................... ..................... ..................... ..... ..... . ..... .......... .
  • 2. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . . Walter Bright .. ...... If a language can capture 90% of the power of C++ with 10% of its complexity I argue that is a worthwhile tradeoff. Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 2 / 21
  • 3. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D Imperative .. 1 typedef unsigned long ulong; 2 3 ulong factorial (ulong n){ 4 if (n < 2) 5 return 1; 6 else 7 return n ∗ factorial (n − 1); 8 } .. 1 ulong factorial (ulong n){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 3 / 21
  • 4. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D Imperative and generics .. 1 template<class T> T factorial(T n){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } .. 1 T factorial (T n){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 4 / 21
  • 5. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D Imperative, generics and contract .. 1 template<class T> T factorial(T n){ 2 assert ( n >= 1 ); 3 if (n < 2) 4 return 1; 5 else 6 return n ∗ factorial (n − 1); 7 } .. 1 T factorial (T n) 2 in{ assert ( n >= 1 ); } 3 out{ assert ( n >= 1 ); } 4 body{ 5 if (n < 2) 6 return 1; 7 else 8 return n ∗ factorial (n − 1); 9 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 5 / 21
  • 6. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D Meta-programing .. 1 typedef unsigned long ulong; 2 3 template <ulong N> struct Factorial { 4 enum { value = N ∗ Factorial<N − 1>::value }; 5 }; 6 7 template <> struct Factorial<0> { 8 enum { value = 1 }; 9 }; 10 11 const ulong x = Factorial<4>::value; 12 const ulong y = Factorial<0>::value; .. 1 template Factorial (ulong n){ 2 static if (n < 2) 3 const Factorial = 1; 4 else 5 const Factorial = n ∗ Factorial !(n − 1); 6 } 7 8 immutable ulong x = Factorial !( 4 ); 9 immutable ulong y = Factorial !( 0 ); Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 6 / 21
  • 7. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D CTFE .. 1 typedef unsigned long ulong; 2 3 ulong factorial (ulong n){ 4 if (n < 2) 5 return 1; 6 else 7 return n ∗ factorial (n − 1); 8 } 9 10 enum ulong x = factorial ( 4 ); 11 enum ulong y = factorial ( 0 ); .. 1 ulong factorial (ulong n){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } 7 8 enum ulong x = factorial ( 4 ); 9 enum ulong y = factorial ( 0 ); Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 7 / 21
  • 8. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . . John Carmack .. ...... Using D for my daily work is not an option, but I applaud their inclusion of a pure attribute. Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 8 / 21
  • 9. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: C++ vs D functional .. 1 typedef unsigned long ulong; 2 3 ulong factorial (ulong n){ 4 if (n < 2) 5 return 1; 6 else 7 return n ∗ factorial (n − 1); 8 } .. 1 @safe pure nothrow 2 ulong factorial (immutable ulong n){ 3 if (n < 2) 4 return 1; 5 else 6 return n ∗ factorial (n − 1); 7 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 9 / 21
  • 10. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . .. Imperative. Generics . Contracts . Meta- programing . Functional . . . . . . . . . . . . . . . . . . . . . . . . . C++ D Python Java Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 10 / 21
  • 11. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Do you like it ? .. .Yes .. .No Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 11 / 21
  • 12. .. .. .continue .......... ...... ..................... ..................... ..................... ..... ..... . ..... .......... .
  • 13. .. .......... ...... ..................... ..................... ..................... ..... ..... . ..... .......... .
  • 14. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: Java vs D A language survey .. 1 public class Factorial { 2 public static int factorial ( int n ){ 3 if (n < 2) 4 return 1; 5 else 6 return n ∗ Factorial . factorial (n − 1); 7 } 8 } .. 1 pure ulong factorial ( immutable ulong n){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 14 / 21
  • 15. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Factorial number: Python vs D A language survey .. 1 def factorial ( n ): 2 if n < 2: 3 return 1 4 else : 5 return n ∗ factorial (n − 1) .. 1 pure ulong factorial ( immutable ulong n ){ 2 if (n < 2) 3 return 1; 4 else 5 return n ∗ factorial (n − 1); 6 } Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 15 / 21
  • 16. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Computing Factorial 50, 1 million time ..... java . C++ . D . Python .0 . 2 . 4 . 6 . 8 . 10 . 0.167 . 0.003 . 0.014 . 11.399 Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 16 / 21
  • 17. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Computing Factorial 50, 20 millions times ..... java . C++ . D . Python .0 . 50 . 100 . 150 . 200 . 1.692 . 0.002 . 0.006 . 228.815 Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 17 / 21
  • 18. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . Do you like it ? .. .Yes .. .No Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 18 / 21
  • 19. .. .. .continue .......... ...... ..................... ..................... ..................... ..... ..... . ..... .......... .
  • 20. .. .......... ...... ..................... ..................... ..................... ..... ..... . ..... .......... .
  • 21. .. ..... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . .... . .... . ..... . .... . ..... . .... . .... . . Andrei Alexandrescu .. ......D rox !!! Thanks Jonathan MERCIER aka bioinfornatics D Programing October 9, 2013 21 / 21

×