http://techtalks.nsu.ru
Видеозапись: http://www.youtube.com/watch?v=sfBrMhAxvFk
5 ноября 2013. DLang: возможности языка и его применение(Николай Толстокулаков, Ixtens)
"Николай Толстокулаков (Ixtens) рассказывает об истории, синтаксисе и фичах языка D."
Лекция прочитана в рамках проекта Tech Talks @NSU – серии открытых лекций о разработке ПО и карьере в IT, проводимых в Новосибирском государственном университете.
Подробности: http://techtalks.nsu.ru
3. Authors
Andrei Alexandrescu
● Modern C++ Design: Generic
Programming and Design Patterns
Applied
● C++ Coding Standards: 101 Rules,
Guidelines, and Best Practices.
● The D Programming Language.
Walter Bright
● C and C++ compilers:
○ Digital Mars C++
○ Symantec C++
○ Zortech C++ (the first native
C++ compiler)
4. Dlang.org
D is a language with C-like syntax and static typing. It
pragmatically combines efficiency, control, and modeling
power, with safety and programmer productivity.
● Convenience - minimal boilerplate, automatic memory management,
slices, ranges
● Power - polymorphism, value semantics, functional style, generics,
generative programming, contract programming, ... Innovative approach to
concurrency
● Efficiency - native code, native pointers, type casts, access to any C
function, and even inline assembly code
5. TIOBE Programming Community Index for
October 2013
21 R 0.553% 31 ABAP 0.394% 41 JavaFX Script 0.297%
22 SAS 0.543% 32 C shell 0.382% 42 Tcl 0.294%
23 Ada 0.510% 33 Common Lisp 0.380% 43 Erlang 0.292%
24 F# 0.499% 34 NXT-G 0.366% 44 Max/MSP 0.276%
25 Fortran 0.474% 35 Scheme 0.360% 45 Scratch 0.270%
26 Assembly 0.471% 36 Scala0.345% 46 Haskell 0.245%
27 Bash 0.470% 37 D 0.337% 47 ML 0.245%
28 Ladder Logic 0.457% 38 Prolog 0.328% 48 PL/I 0.240%
29 Logo 0.433% 39 RPG (OS/400) 0.319% 49 ActionScript 0.215%
30 Lua 0.413% 40 PostScript 0.312% 50 Emacs Lisp 0.210%
6. DLang
● It is complex (more 100 keywords vs 50 in Java)
● Syntactic sugar & features
○ slices, auto, powerful foreach, final switch, ...
○ unit tests, contract programming
○ compile time intersection
○ lamda, delegate
○ scope
○ ranges
○ anti-hijacking
○ ………
● Powerful metaprogramming
7. The sope statement (Java, C#)
(action)
try{
(next)
}catch(Exception e){
(rollback)
throw e
}finally{
(cleanup)
}
9. Built-in array
bool binarySearch(T)(T[] input, T value) {
if (input.empty) return false;
auto i = input.length / 2;
auto mid = input[i];
if (mid > value) return binarySearch(input[0 .. i]);
if (mid < value) return binarySearch(input[i + 1 .. $]);
return true;
}
10. Ranges
InputRange:
● front - get the first element of the range
● popFront - remove the first element of the range
● empty - are there more elements in the range?
InputRange
↑
ForwardRange
↗ ↖
BidirectionalRange RandomAccessRange (infinite)
↑
RandomAccessRange (finite)