66< section class ="main jumbotron ">
77 < section class ="content ">
88 < div class ="pure-g ">
9+ < div class ="pure-u-1 main-block ">
10+ < h1 > Efficient, expressive, elegant</ h1 >
11+ </ div >
912 < div class ="pure-u-1 pure-u-md-3-5 main-block ">
10- < h1 > Efficient and expressive programming</ h1 >
1113 < h2 >
12- Nim is a statically typed compiled systems programming language
13- with a design that focuses on efficiency, expressiveness, and elegance.
14+ Nim is a statically typed compiled systems programming language.
15+ It combines successful concepts from mature languages like Python,
16+ Ada and Modula.
1417 </ h2 >
1518 < h3 > Efficient</ h3 >
1619 < ul >
17- < li > Native code generation, not dependent on a virtual machine:
18- Nim produces < b > small executables without dependencies</ b > for easy redistribution.</ li >
19- < li > The Nim Compiler runs on Windows, Linux, BSD and Mac OS X. Porting to other platforms is easy.</ li >
20- < li > Compiles to C, C++ or JavaScript.</ li >
21- < li > Fast deferred reference counting memory management that supports soft real-time systems (like games).</ li >
22- < li > Ability to manage your own memory and access the hardware directly.</ li >
23- < li > Pointers to garbage collected memory are distinguished from pointers to manually managed memory.</ li >
24- < li > Zero-overhead iterators.</ li >
25- < li > Cross-module inlining.</ li >
26- < li > Compile time evaluation of user-defined functions.</ li >
27- < li > Whole program dead code elimination: Only used functions are included in the executable.</ li >
28- < li > Value-based datatypes: For instance, objects and arrays are allocated on the stack.</ li >
20+ < li > Nim generates native dependency-free executables, not dependent on a virtual machine,
21+ which are small and allow easy redistribution.</ li >
22+ < li > The Nim compiler and the generated executables support all major platforms like
23+ Windows, Linux, BSD and Mac OS X.</ li >
24+ < li > Nim supports a number of memory management strategies to best fit your application:
25+ garbage collection, reference counting, or full manual control.</ li >
26+ < li > Modern concepts like zero-overhead iterators and compile time evaluation
27+ of user-defined functions, in combination with the preference of value-based
28+ datatypes allocated on the stack, lead to extremely performant code.</ li >
29+ < li > Support for various backends: it compiles to C, C++ or JavaScript so that Nim
30+ can be used for all backend and frontend needs.</ li >
2931 </ ul >
3032 < h3 > Expressive</ h3 >
3133 < ul >
32- < li > The Nim compiler and all of the standard library are < b > implemented in Nim.</ b > </ li >
33- < li > User-definable operators: code with new operators is often easier to read
34- than code which overloads built-in operators.</ li >
35- < li > Powerful AST-based hygienic macro system.</ li >
36- < li > Macros can use the imperative paradigm to construct parse trees.</ li >
34+ < li > Nim is self contained: the compiler and all of the standard library are implemented in Nim.</ li >
35+ < li > Nim has a powerful macro system which allows direct manipulation of the AST,
36+ offering nearly unlimited opportunities.</ li >
3737 </ ul >
3838 < h3 > Elegant</ h3 >
3939 < ul >
40- < li > Macros cannot change Nim's syntax because there is no need for it.
41- Nim's syntax is flexible enough.</ li >
42- < li > Built-in high level datatypes: strings, sets, sequences, etc.</ li >
43- < li > Nim does not require a different coding style for meta programming.</ li >
40+ < li > Macros cannot change Nim's syntax because there is no need for it —
41+ the syntax is flexible enough.</ li >
4442 < li > Modern type system with local type inference, tuples, variants, generics, etc.</ li >
4543 < li > Statements are grouped by indentation but can span multiple lines.</ li >
4644 </ ul >
@@ -53,19 +51,23 @@ <h3>Elegant</h3>
5351
5452 < div class ="pure-u-1 pure-u-md-2-5 ">
5553 {% highlight nim %}
56- # Compute average line length
57- var
58- sum = 0
59- count = 0
54+ import strformat
6055
61- for line in stdin.lines:
62- sum += line.len
63- count += 1
56+ type
57+ Person = object
58+ name: string
59+ age: Natural # ensures the age is positive
6460
65- echo("Average line length: ",
66- if count > 0: sum / count else: 0)
67- {% endhighlight %}
61+ let people = [
62+ Person(name: "John", age: 45),
63+ Person(name: "Kate", age: 30)
64+ ]
6865
66+ for person in people:
67+ # Type-safe string interpolation,
68+ # evaluated at compile time.
69+ echo(fmt"{person.name} is {person.age} years old")
70+ {% endhighlight %}
6971
7072 {% highlight nim %}
7173# Thanks to Nim's 'iterator' and 'yield' constructs,
@@ -82,25 +84,6 @@ <h3>Elegant</h3>
8284{% endhighlight %}
8385
8486
85- {% highlight nim %}
86- import strformat
87-
88- type
89- Person = object
90- name: string
91- age: Natural # ensures the age is positive
92-
93- let people = [
94- Person(name: "John", age: 45),
95- Person(name: "Kate", age: 30)
96- ]
97-
98- for person in people:
99- # Type-safe string interpolation,
100- # evaluated at compile time.
101- echo(fmt"{person.name} is {person.age} years old")
102- {% endhighlight %}
103-
10487 {% highlight nim %}
10588# Use Nim 's macro system to tranform a dense
10689# data-centric description of x86 instructions
0 commit comments