From 556f4880874b09bccea99bbb3b7aa46159977fef Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 14 Dec 2014 11:29:27 +0100 Subject: more code snippets for the website --- tools/website.tmpl | 42 ++++++++++++++++++++++++++++++++++++------ web/assets/style.css | 16 ++++++++++++++++ web/community.txt | 4 ++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/tools/website.tmpl b/tools/website.tmpl index b16373c4f..6f7a216a5 100644 --- a/tools/website.tmpl +++ b/tools/website.tmpl @@ -52,7 +52,7 @@
-

nim looks like this..

+

Nim looks like this..

# compute average line length
 var
   sum = 0
@@ -81,17 +81,17 @@ echo("Average line length: ",
 p.greet() # or greet(p)
 
-
-
+
+

Why should I be excited?

- Nim the only language that leverages automated proof technology + Nim is the only language that leverages automated proof technology to perform a disjoint check for your parallel code. Working on disjoint data means no locking is required and yet data races are impossible:
 parallel:
-  var i = 0
+  var i = 0
   while i <= a.high:
     spawn f(a[i])
     spawn f(a[i+1])
@@ -100,10 +100,40 @@ p.greet() # or greet(p)
     i += 1
             
+
+
+

interfacing with C..

+
+proc unsafeScanf(f: File; s: cstring)
+  {.importc: "fscanf", 
+    header: "<stdio.h>", varargs.}
+
+var x: cint
+unsafeScanf(stdin, "%d", addr x)
+            
+ +
+

..and DSLs made easy

+
+import jester, asyncdispatch, htmlgen
+
+routes:
+  get "/":
+    resp h1("Hello world")
+
+runForever()
+

+Compile and run with:
+nim c -r example.nim
+View at: localhost:5000 +

+
+
+
# end