diff --git a/Nimrod-for-C-programmers.md b/Nimrod-for-C-programmers.md index 63110e7..3e120d2 100644 --- a/Nimrod-for-C-programmers.md +++ b/Nimrod-for-C-programmers.md @@ -18,17 +18,31 @@ http://nimrod-lang.org/manual.html ### At a glance - - - - - - - - - - -
FeatureCNimrod
Memory ManagementManual (GC w/ libraries or obj-C)Garbage-collected and manual
TypesStaticStatic
CompilationMachine codeMachine code via C
(other backends in progress/planned)
Meta-programmingC PreprocessorNimrod (const/when/template/macro)
Type inferenceNo (some w/ C++11)Yes (extensive support)
ClosuresNo (Yes w/ obj-C or C++11)Yes
Operator OverloadingNo (Yes w/ C++)Yes
Custom OperatorsNoYes
+Similarities and differences. + +Feature | C | Nimrod +---------------------|-----------------------------------|----------------------------------------- +Compilation | Machine code | Machine code via C* +Meta-programming | C Preprocessor | Nimrod (const/when/template/macro) +Memory Management | Manual (GC w/ libraries or obj-C) | Garbage-collected and manual +Types | Static | Static +Dependent types | No | Partial support +Generics | No (Templates w/ C++) | Yes +int8/16/32/64 types | Yes | Yes +Unsigned ints | Yes (by default) | Yes (not by default) +Arrays | Yes | Yes +Bounds-checking | No | Yes +Type inference | No (some w/ C++11) | Yes (extensive support) +Closures | No (Yes w/ obj-C or C++11) | Yes +Operator Overloading | No (Yes w/ C++) | Yes (on any types) +Custom Operators | No | Yes +Object-Oriented | No (Yes w/C++ or obj-C) | Minimalistic** +Methods | No (Yes w/C++) | Yes +Multi-Methods | No | Yes +Exceptions | No (Yes w/C++) | Yes + +*Other backends supported and/or planned +**See section below ### Philosophy @@ -81,6 +95,17 @@ Nimrod strongly discourages the use of unsigned integers, as it's considered unn *See: http://critical.eschertech.com/2010/04/07/danger-unsigned-types-used-here/ + +### Object-Orientation + +Objects in Nimrod have more features than structs in C, but behave quite differently from classes in C++. Objects support inheritance (not multiple inheritance). But otherwise most of the features that apply to objects simply apply to all types in Nimrod. + +You can call a proc on objects with the ```anObject.foobar()```, but you can do that on any type (e.g. ints and arrays) as well. You can have methods on object, but you can have methods on any types, and for all the arguments, not just the first (in C++, implicit) one. + +Nimrod does not have an implicit _this_/_self_. + +It is possible to implement object-orientation features from other languages (like C++,Java,etc. or Smalltalk,Obj-C,Ruby,etc.) through libraries, thanks to the extensive meta-programming features of Nimrod. These are at the moment mostly work-in-progress. + ### Structs - Tuples and Objects Tuples and Objects in Nimrod are kind of like structs in C, but not really.