root/trunk/docsrc/comparison.dd

Revision 1396, 12.1 kB (checked in by walter, 2 years ago)

update docs

  • Property svn:eol-style set to native
Line 
1 Ddoc
2
3 $(COMMUNITY $(D) vs Other Languages,
4
5     $(BLOCKQUOTE
6     To D, or not to D. -- Willeam NerdSpeare
7     )
8
9     $(P This table is a quick and rough list of various features of
10     $(D)
11     that can be used to compare with other languages.
12     While many capabilities are available with standard libraries, this
13     table is for features built in to the core language itself.
14     $(LINK2 builtin.html, Rationale).
15     )
16
17     <table border=2 cellpadding=4 cellspacing=0 class="comp">
18     <caption>D Language Feature Comparison Table</caption>
19
20     <thead>
21     $(TR
22     <th>Feature</th>
23     <th align="center"><a href="index.html" title="D Programming Language"  target="_top">$(D)</a></th>
24     )
25     </thead>
26
27     <tbody>
28
29     $(TR
30     $(TD <a href="#GarbageCollection">Garbage Collection</a>)
31     $(YES1 garbage.html)
32     )
33
34     $(TR
35     <th colspan="6" align="left"> Functions</th>
36     )
37
38     $(TR
39     $(TD Function delegates)
40     $(YES1 type.html#delegates)
41     )
42
43     $(TR
44     $(TD Function overloading)
45     $(YES1 function.html#overload)
46     )
47
48     $(TR
49     $(TD Out function parameters)
50     $(YES1 function.html#parameters)
51     )
52
53     $(TR
54     $(TD Nested functions)
55     $(YES1 function.html#nested)
56     )
57
58     $(TR
59     $(TD Function literals)
60     $(YES1 expression.html#FunctionLiteral)
61     )
62
63     $(TR
64     $(V1 $(TD Dynamic closures))
65     $(V2 $(TD Closures))
66     $(YES1 function.html#closures)
67     )
68
69     $(TR
70     $(TD Typesafe variadic arguments)
71     $(YES1 function.html#variadic)
72     )
73
74     $(TR
75     $(TD Lazy function argument evaluation)
76     $(YES1 lazy-evaluation.html)
77     )
78
79     $(TR
80     $(TD Compile time function evaluation)
81     $(YES1 function.html#interpretation)
82     )
83
84     $(TR
85     <th colspan="6" align="left"> Arrays</th>
86     )
87
88     $(TR
89     $(TD Lightweight arrays)
90     $(YES1 arrays.html)
91     )
92
93     $(TR
94     $(TD <a href="#ResizeableArrays">Resizeable arrays</a>)
95     $(YES1 arrays.html#resize)
96     )
97
98     $(TR
99     $(TD <a href="#BuiltinStrings">Built-in strings</a>)
100     $(YES1 arrays.html#strings)
101     )
102
103     $(TR
104     $(TD Array slicing)
105     $(YES1 arrays.html#slicing)
106     )
107
108     $(TR
109     $(TD Array bounds checking)
110     $(YES1 arrays.html#bounds)
111     )
112
113     $(TR
114     $(TD Array literals)
115     $(YES1 expression.html#ArrayLiteral)
116     )
117
118     $(TR
119     $(TD Associative arrays)
120     $(YES1 arrays.html#associative)
121     )
122
123     $(TR
124     $(TD <a href="#StrongTypedefs">Strong typedefs</a>)
125     $(YES1 declaration.html#typedef)
126     )
127
128     $(TR
129     $(TD String switches)
130     $(YES1 statement.html#SwitchStatement)
131     )
132
133     $(TR
134     $(TD Aliases)
135     $(YES1 declaration.html#alias)
136     )
137
138     $(TR
139     <th colspan="6" align="left"> OOP</th>
140     )
141
142     $(TR
143     $(TD <a href="#ObjectOriented">Object Oriented</a>)
144     $(YES)
145     )
146
147     $(TR
148     $(TD Multiple Inheritance)
149     $(NO)
150     )
151
152     $(TR
153     $(TD <a href="#Interfaces">Interfaces</a>)
154     $(YES1 interface.html)
155     )
156
157     $(TR
158     $(TD Operator overloading)
159     $(YES1 operatoroverloading.html)
160     )
161
162     $(TR
163     $(TD <a href="#Modules">Modules</a>)
164     $(YES1 module.html)
165     )
166
167     $(TR
168     $(TD Dynamic class loading)
169     $(NO)
170     )
171
172     $(TR
173     $(TD Nested classes</a>)
174     $(YES1 class.html#nested)
175     )
176
177     $(TR
178     $(TD <a href="#innerclasses">Inner (adaptor) classes</a>)
179     $(YES1 class.html#nested)
180     )
181
182     $(TR
183     $(TD Covariant return types)
184     $(YES1 function.html)
185     )
186
187     $(TR
188     $(TD Properties)
189     $(YES1 property.html#classproperties)
190     )
191
192     $(TR
193     <th colspan="6" align="left"> Performance</th>
194     )
195
196     $(TR
197     $(TD <a href="#InlineAssembler">Inline assembler</a>)
198     $(YES1 iasm.html)
199     )
200
201     $(TR
202     $(TD Direct access to hardware)
203     $(YES)
204     )
205
206     $(TR
207     $(TD Lightweight objects)
208     $(YES1 struct.html)
209     )
210
211     $(TR
212     $(TD Explicit memory allocation control)
213     $(YES1 memory.html)
214     )
215
216     $(TR
217     $(TD Independent of VM)
218     $(YES)
219     )
220
221     $(TR
222     $(TD  Direct native code gen)
223     $(YES)
224     )
225
226     $(TR
227     <th colspan="6" align="left"> Generic Programming</th>
228     )
229
230     $(TR
231     $(TD Class Templates)
232     $(YES1 template.html)
233     )
234
235     $(TR
236     $(TD Function Templates)
237     $(YES1 template.html)
238     )
239
240     $(TR
241     $(TD Implicit Function Template Instantiation)
242     $(YES1 template.html)
243     )
244
245     $(TR
246     $(TD Partial and Explicit Specialization)
247     $(YES1 template.html)
248     )
249
250     $(TR
251     $(TD Value Template Parameters)
252     $(YES1 template.html)
253     )
254
255     $(TR
256     $(TD Template Template Parameters)
257     $(YES1 template.html)
258     )
259
260     $(TR
261     $(TD Variadic Template Parameters)
262     $(YES1 template.html)
263     )
264 $(V2
265     $(TR
266     $(TD Template Constraints)
267     $(YES1 concepts.html)
268     )
269 )
270     $(TR
271     $(TD <a href="#mixins">Mixins</a>)
272     $(YES1 template-mixin.html)
273     )
274
275     $(TR
276     $(TD <a href="#staticif">static if</a>)
277     $(YES1 version.html#staticif)
278     )
279
280     $(TR
281     $(TD <a href="#isexpression">is expressions</a>)
282     $(YES1 expression.html#IsExpression)
283     )
284
285     $(TR
286     $(TD typeof)
287     $(YES1 declaration.html#Typeof)
288     )
289
290     $(TR
291     $(TD foreach)
292     $(YES1 statement.html#ForeachStatement)
293     )
294
295     $(TR
296     $(TD <a href="#ImplicitTypeInference">Implicit Type Inference</a>)
297     $(YES1 declaration.html#AutoDeclaration)
298     )
299
300     $(TR
301     <th colspan="6" align="left"> Reliability</th>
302     )
303
304     $(TR
305     $(TD <a href="#Contracts">Contract Programming</a>)
306     $(YES1 dbc.html)
307     )
308
309     $(TR
310     $(TD Unit testing)
311     $(YES1 unittest.html#unittest)
312     )
313
314     $(TR
315     $(TD Static construction order)
316     $(YES1 module.html#staticorder)
317     )
318
319     $(TR
320     $(TD Guaranteed initialization)
321     $(YES1 statement.html#DeclarationStatement)
322     )
323
324     $(TR
325     $(TD RAII (automatic destructors))
326     $(YES1 memory.html#raii)
327     )
328
329     $(TR
330     $(TD Exception handling)
331     $(YES1 statement.html#TryStatement)
332     )
333
334     $(TR
335     $(TD <a href="exception-safe.html">Scope guards</a>)
336     $(YES1 statement.html#ScopeGuardStatement)
337     )
338
339     $(TR
340     $(TD try-catch-finally blocks)
341     $(YES1 statement.html#TryStatement)
342     )
343
344     $(TR
345     $(TD Thread synchronization primitives)
346     $(YES1 statement.html#SynchronizedStatement)
347     )
348
349     $(TR
350     <th colspan="6" align="left"> Compatibility</th>
351     )
352
353     $(TR
354     $(TD C-style syntax)
355     $(YES)
356     )
357
358     $(TR
359     $(TD Enumerated types)
360     $(YES1 enum.html)
361     )
362
363     $(TR
364     $(TD <a href="#Ctypes">Support all C types</a>)
365     $(YES1 type.html)
366     )
367
368     $(TR
369     $(TD <a href="#LongDouble">80 bit floating point</a>)
370     $(YES1 type.html)
371     )
372
373     $(TR
374     $(TD Complex and Imaginary)
375     $(YES1 type.html)
376     )
377
378     $(TR
379     $(TD Direct access to C)
380     $(YES1 attribute.html#linkage)
381     )
382
383     $(TR
384     $(TD <a href="#debuggers">Use existing debuggers</a>)
385     $(YES)
386     )
387
388     $(TR
389     $(TD <a href="#StructMemberAlignmentControl">Struct member alignment control</a>)
390     $(YES1 attribute.html#align)
391     )
392
393     $(TR
394     $(TD Generates standard object files)
395     $(YES)
396     )
397
398     $(TR
399     $(TD Macro text preprocessor)
400     $(NO1 pretod.html)
401     )
402
403     $(TR
404     <th colspan="6" align="left"> Other</th>
405     )
406
407     $(TR
408     $(TD Conditional compilation)
409     $(YES1 version.html)
410     )
411
412     $(TR
413     $(TD Unicode source text)
414     $(YES1 lex.html)
415     )
416
417     $(TR
418     $(TD <a href="#DocComments">Documentation comments</a>)
419     $(YES1 ddoc.html)
420     )
421
422     </tbody>
423
424     </table>
425
426 $(SECTION2 Notes,
427
428     <dl>
429
430     <dt><a name="ObjectOriented">Object Oriented</a>
431     <dd>This means support for classes, member functions,
432     inheritance, and virtual function dispatch.
433     <p>
434
435     <dt><a name="InlineAssembler">Inline assembler</a>
436     <dd> Many C and C++ compilers support an inline assembler, but
437     this is not a standard part of the language, and implementations
438     vary widely in syntax and quality.
439     <p>
440
441     <dt><a name="Interfaces">Interfaces</a>
442     <dd> Support in C++ for interfaces is weak enough that an
443     IDL (Interface Description Language) was invented to compensate.
444     <p>
445
446     <dt><a name="Modules">Modules</a>
447     <dd> Many correctly argue that C++ doesn't really have modules.
448     But C++ namespaces coupled with header files share many features
449     with modules.
450     <p>
451
452     <dt><a name="GarbageCollection">Garbage Collection</a>
453     <dd> The Hans-Boehm garbage collector can be successfully used
454     with C and C++, but it is not a standard part of the language.
455     <p>
456
457     <dt><a name="ImplicitTypeInference">Implicit Type Inference</a>
458     <dd> This refers to the ability to pick up the type of a
459     declaration from its initializer.
460     <p>
461
462     <dt><a name="Contracts">Contract Programming</a>
463     <dd>The Digital Mars C++ compiler supports
464     <a href="http://www.digitalmars.com/ctg/contract.html">Contract Programming</a>
465     as an extension.
466     Compare some <a href="cppdbc.html">C++ techniques</a> for
467     doing Contract Programming with D.
468     <p>
469
470     <dt><a name="ResizeableArrays">Resizeable arrays</a>
471     <dd>Part of the standard library for C++ implements resizeable
472     arrays, however, they are not part of the core language.
473     A conforming freestanding implementation of C++ (C++98 17.4.1.3) does
474     not need to provide these libraries.
475     <p>
476
477     <dt><a name="BuiltinStrings">Built-in Strings</a>
478     <dd>Part of the standard library for C++ implements strings,
479     however, they are not part of the core language.
480     A conforming freestanding implementation of C++ (C++98 17.4.1.3) does
481     not need to provide these libraries.
482     Here's a <a href="cppstrings.html">comparison</a> of C++ strings
483     and D built-in strings.
484     <p>
485
486     <dt><a name="StrongTypedefs">Strong typedefs</a>
487     <dd>Strong typedefs can be emulated in C/C++ by wrapping a type
488     in a struct. Getting this to work right requires much tedious
489     programming, and so is considered as not supported.
490     <p>
491
492     <dt><a name="debuggers">Use existing debuggers</a>
493     <dd>By this is meant using common debuggers that can operate
494     using debug data in common formats embedded in the executable.
495     A specialized debugger useful only with that language is not required.
496     <p>
497
498     <dt><a name="StructMemberAlignmentControl">Struct member alignment control</a>
499     <dd>Although many C/C++ compilers contain pragmas to specify
500     struct alignment, these are nonstandard and incompatible from
501     compiler to compiler.<br>
502     The C# standard ECMA-334 25.5.8 says only this about struct member
503     alignment:
504     $(I "The order in which members are packed
505     into a struct is unspecified. For alignment purposes, there may be
506     unnamed padding at the beginning of a struct, within a struct, and at
507     the end of the struct. The contents of the bits used as padding are
508     indeterminate.")
509     Therefore, although Microsoft may
510     have extensions to support specific member alignment, they are not an
511     official part of standard C#.
512     <p>
513
514     <dt><a name="Ctypes">Support all C types</a>
515     <dd>C99 adds many new types not supported by C++.
516     <p>
517
518     <dt><a name="LongDouble">80 bit floating point</a>
519     <dd>While the standards for C and C++ specify long doubles, few
520     compilers (besides Digital Mars C/C++) actually implement
521     80 bit (or longer) floating point types.
522     <p>
523
524     <dt><a name="mixins">Mixins</a>
525     <dd>Mixins have many different meanings in different programming
526     languages. <a href="template-mixin.html">D mixins</a> mean taking an arbitrary
527     sequence of declarations
528     and inserting (mixing) them into the current scope. Mixins can be done
529     at the global, class, struct, or local level.
530     <p>
531
532     <dt><a name="cppmixins">C++ Mixins</a>
533     <dd>C++ mixins refer to a couple different techniques. The first
534     is analogous to D's interface classes. The second is to create
535     a template of the form:
536 $(CPPCODE
537 template &lt;class Base&gt; class Mixin : public Base
538 {
539     ... mixin body ...
540 }
541 )
542     D mixins are different.
543     <p>
544
545     <dt><a name="staticif">Static If</a>
546     <dd>The C and C++ preprocessor directive #if would appear to
547     be equivalent to the D static if. But there are major and crucial
548     differences - the #if does not have access to any of the constants,
549     types, or symbols of the program. It can only access preprocessor
550     macros.
551     See <a href="cpptod.html#metatemplates">this example</a>.
552     <p>
553
554     <dt><a name="isexpression">Is Expressions</a>
555     <dd>$(I Is expressions) enable conditional compilation based
556     on the characteristics of a type. This is done after a fashion in
557     C++ using template parameter pattern matching.
558     See <a href="cpptod.html#typetraits">this example</a>
559     for a comparison of the different approaches.
560     <p>
561
562     <dt>Comparison with Ada
563     <dd>James S. Rogers has written a
564     <a href="http://home.att.net/~jimmaureenrogers/AdaAdditionToDComparisonTable.htm">comparison chart with Ada</a>.
565     <p>
566
567     <dt><a name="innerclasses">Inner (adaptor) classes</a>
568     <dd>A $(I nested class) is one whose definition is within the scope
569     of another class. An $(I inner class) is a nested class that
570     can also reference the members and fields of the lexically
571     enclosing class; one can think of it as if it contained a 'this'
572     pointer to the enclosing class.
573     <p>
574
575     <dt><a name="DocComments">Documentation comments</a>
576     <dd>Documentation comments refer to a standardized way to produce
577     documentation from the source code file using specialized
578     comments.
579
580     </dl>
581 )
582
583 $(SECTION2 Errors,
584
585     $(P If I've made any errors in this table, please contact me so
586     I can correct them.
587     )
588 )
589
590 )
591
592 Macros:
593     TITLE=Comparison
594     WIKI=Comparison
595     NO=<td class="compNo">No</td>
596     NO1=<td class="compNo"><a href="$1">No</a></td>
597     YES=<td class="compYes">Yes</td>
598     YES1=<td class="compYes"><a href="$1">Yes</a></td>
Note: See TracBrowser for help on using the browser.