{"id":257337,"date":"2015-05-17T13:44:02","date_gmt":"2015-05-17T09:44:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=257337"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=257337","title":{"rendered":"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0433\u043e \u0432 Nim?"},"content":{"rendered":"\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"\/\/habrastorage.org\/files\/616\/55b\/6ee\/61655b6ee8f6472d96d54e2184a0917d.png\"\/><\/div>\n<p>  \u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"http:\/\/nim-lang.org\/\">Nim<\/a> (\u0440\u0430\u043d\u0435\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0441\u044f Nimrod) \u2014 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439! \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <a href=\"http:\/\/nim-lang.org\/docs\/tut1.html\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/a> \u043f\u043b\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u044f\u0437\u044b\u043a\u043e\u043c, \u044f \u0445\u043e\u0447\u0443 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 Nim, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445.<\/p>\n<p>  \u042f \u043e\u0442\u043a\u0440\u044b\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f Nim, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u0430\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u0433\u0440\u044b, HoorRace, \u043f\u0440\u0435\u0435\u043c\u043d\u0438\u043a \u043c\u043e\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 DDNet \u0438\u0433\u0440\u044b\/\u043c\u043e\u0434\u0430 Teeworlds.<\/p>\n<p>  <i>(\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. \u041d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 Nim \u0438\u043c\u0435\u043b\u0438 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 Modula 3, Delphi, Ada, C++, Python, Lisp, Oberon.)<\/i><\/p>\n<h1>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c!<\/h1>\n<p>  \u0414\u0430, \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430:<\/p>\n<pre><code class=\"ruby\">for i in 0..10:   echo &quot;Hello World&quot;[0..i] <\/code><\/pre>\n<p><a name=\"habracut\"><\/a><\/p>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f <a href=\"http:\/\/nim-lang.org\/download.html\">\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 Nim<\/a> (\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. \u0432 ArchLinux, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0430\u043a\u0435\u0442 \u0435\u0441\u0442\u044c <code>community\/nim<\/code>). \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0432 \u0444\u0430\u0439\u043b hello.nim, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>nim c hello.nim<\/code>, \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b <code>.\/hello<\/code>. \u0418\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>nim -r c hello.nim<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>nim -d:release c hello.nim<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u044b\u0432\u043e\u0434 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<pre><code>H He Hel Hell Hello Hello  Hello W Hello Wo Hello Wor Hello Worl Hello World <\/code><\/pre>\n<h1>\u0418\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u0434 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438<\/h1>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b CRC32 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0435\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0435\u0451 \u0432 \u043a\u043e\u0434\u0435 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0446\u0438\u0444\u0440 \u0432 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435 \u0441\u0435\u0439\u0447\u0430\u0441):<\/p>\n<pre><code class=\"ruby\">import unsigned, strutils  type CRC32* = uint32 const initCRC32* = CRC32(-1)  proc createCRCTable(): array[256, CRC32] =   for i in 0..255:     var rem = CRC32(i)     for j in 0..7:       if (rem and 1) &gt; 0: rem = (rem shr 1) xor CRC32(0xedb88320)       else: rem = rem shr 1     result[i] = rem  # Table created at runtime var crc32table = createCRCTable()  proc crc32(s): CRC32 =   result = initCRC32   for c in s:     result = (result shr 8) xor crc32table[(result and 0xff) xor ord(c)]   result = not result  # String conversion proc $, automatically called by echo proc `$`(c: CRC32): string = int64(c).toHex(8)  echo crc32(&quot;The quick brown fox jumps over the lazy dog&quot;) <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e! \u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <code>414FA339<\/code>. \u041e\u0434\u043d\u0430\u043a\u043e, \u0431\u044b\u043b\u043e \u0431\u044b \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c CRC \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0418 \u0432 Nim \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0435\u043c crc32table \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"ruby\"># Table created at compile time const crc32table = createCRCTable() <\/code><\/pre>\n<p>  \u0414\u0430, \u0432\u0435\u0440\u043d\u043e, \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c <code>var<\/code> \u043d\u0430 <code>const<\/code>. \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e, \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438? \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043a\u0430\u043a \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0442\u0430\u043a \u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h1>\u0420\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c \u044f\u0437\u044b\u043a<\/h1>\n<p>  \u0428\u0430\u0431\u043b\u043e\u043d\u044b \u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u0438\u0437\u0431\u0435\u0433\u0430\u043d\u0438\u044f \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043b\u0430\u043f\u0448\u0438 \u0432 \u043a\u043e\u0434\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u0422\u0435\u043c\u043f\u043b\u0435\u0439\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0432\u044b\u0437\u043e\u0432\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0446\u0438\u043a\u043b\u044b \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"ruby\">template times(x: expr, y: stmt): stmt =   for i in 1..x:     y  10.times:   echo &quot;Hello World&quot; <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 <code>times<\/code> \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b:<\/p>\n<pre><code class=\"ruby\">for i in 1..10:   echo &quot;Hello World&quot; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>10.times<\/code>, \u0442\u043e \u0437\u043d\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 <code>times<\/code> \u0441 \u043f\u0435\u0440\u0432\u044b\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c <code>10<\/code> \u0438 \u0431\u043b\u043e\u043a\u043e\u043c \u043a\u043e\u0434\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u0412\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c: <code>times(10):<\/code>, \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043e Unified Call Syntax \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u0418\u043b\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u043d\u044b) \u0443\u0434\u043e\u0431\u043d\u0435\u0435:<\/p>\n<pre><code class=\"ruby\">template newSeqWith(len: int, init: expr): expr =   var result = newSeq[type(init)](len)   for i in 0 .. &lt;len:     result[i] = init   result  # Create a 2-dimensional sequence of size 20,10 var seq2D = newSeqWith(20, newSeq[bool](10))  import math randomize() # Create a sequence of 20 random integers smaller than 10 var seqRand = newSeqWith(20, random(10)) echo seqRand <\/code><\/pre>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441 \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0449\u0430\u0433 \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c AST. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 Nim \u043d\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BF%D0%B8%D1%81%D0%BA%D0%BE%D0%B2%D0%BE%D0%B5_%D0%B2%D0%BA%D0%BB%D1%8E%D1%87%D0%B5%D0%BD%D0%B8%D0%B5\">\u0441\u043f\u0438\u0441\u043a\u043e\u0432\u044b\u0445 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439<\/a> (\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. list comprehensions), \u043d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u044f\u0437\u044b\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0430\u043a\u0440\u043e\u0441\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u043c\u0435\u0441\u0442\u043e:<\/p>\n<pre><code class=\"ruby\">var res: seq[int] = @[] for x in 1..10:   if x mod 2 == 0:     res.add(x) echo res  const n = 20 var result: seq[tuple[a,b,c: int]] = @[] for x in 1..n:   for y in x..n:     for z in y..n:       if x*x + y*y == z*z:         result.add((x,y,z)) echo result <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c <code>future<\/code> \u0438 \u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<pre><code class=\"ruby\">import future echo lc[x | (x &lt;- 1..10, x mod 2 == 0), int] const n = 20 echo lc[(x,y,z) | (x &lt;- 1..n, y &lt;- x..n, z &lt;- y..n,                    x*x + y*y == z*z), tuple[a,b,c: int]] <\/code><\/pre>\n<h1>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<\/h1>\n<p>  \u0412\u043c\u0435\u0441\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u043b\u0438 \u0431\u044b \u0432\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0443\u043c\u043d\u0435\u0435? \u0412 Nim \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e!<\/p>\n<pre><code class=\"ruby\">var x: int for i in 1..1_000_000_000:   x += 2 * i echo x <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 (\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439) \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0441\u043a\u043e\u0440\u0435\u043d \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u0432\u0443\u043c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c:<\/p>\n<pre><code class=\"ruby\">template optMul{`*`(a,2)}(a: int): int =   let x = a   x + x  template canonMul{`*`(a,b)}(a: int{lit}, b: int): int =   b * a <\/code><\/pre>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e <code>a * 2<\/code> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u043e \u043d\u0430 <code>a + a<\/code>. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u0435 \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0447\u0442\u043e <code>int<\/code>-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u043d\u044b \u043c\u0435\u0441\u0442\u0430\u043c\u0438, \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0433\u0440\u0443\u043c\u0435\u043d\u0442 \u2014 \u0447\u0438\u0441\u043b\u043e-\u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d.<\/p>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u0443\u043b\u0435\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438:<\/p>\n<pre><code class=\"ruby\">template optLog1{a and a}(a): auto = a template optLog2{a and (b or (not b))}(a,b): auto = a template optLog3{a and not a}(a: int): auto = 0  var   x = 12   s = x and x   # Hint: optLog1(x) --&gt; \u2019x\u2019 [Pattern]    r = (x and x) and ((s or s) or (not (s or s)))   # Hint: optLog2(x and x, s or s) --&gt; \u2019x and x\u2019 [Pattern]   # Hint: optLog1(x) --&gt; \u2019x\u2019 [Pattern]    q = (s and not x) and not (s and not x)   # Hint: optLog3(s and not x) --&gt; \u20190\u2019 [Pattern] <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c <code>s<\/code> \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e <code>x<\/code>, <code>r<\/code> \u0442\u043e\u0436\u0435 \u043e\u043f\u0442\u0438\u0437\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e <code>x<\/code>, \u0438 <code>q<\/code> \u0441\u0440\u0430\u0437\u0443 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u0451\u043c.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0434\u043b\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f <code>bigint<\/code>, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0439\u0441\u044f \u0441 <code>opt<\/code> \u0432 <a href=\"https:\/\/github.com\/def-\/nim-bigints\/blob\/master\/src\/bigints.nim\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 biginsts.nim<\/a>:<\/p>\n<pre><code class=\"ruby\">import bigints  var i = 0.initBigInt while true:   i += 1   echo i <\/code><\/pre>\n<h1>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0438 C-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h1>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a Nim \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 C (C++\/Obj-C), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:<\/p>\n<pre><code class=\"ruby\">proc printf(formatstr: cstring)   {.header: &quot;&lt;stdio.h&gt;&quot;, varargs.} printf(&quot;%s %d\\n&quot;, &quot;foo&quot;, 5) <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 C:<\/p>\n<pre><code>void hi(char* name) {   printf(&quot;awesome %s\\n&quot;, name); } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"ruby\">{.compile: &quot;hi.c&quot;.} proc hi*(name: cstring) {.importc.} hi &quot;from Nim&quot; <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u043b\u044e\u0431\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0436\u0435\u043b\u0430\u0435\u0442\u0435, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 c2nim:<\/p>\n<pre><code class=\"ruby\">proc set_default_dpi*(dpi: cdouble) {.cdecl,   importc: &quot;rsvg_set_default_dpi&quot;,   dynlib: &quot;librsvg-2.so&quot;.} <\/code><\/pre>\n<h1>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u043e\u043c \u043c\u0443\u0441\u043e\u0440\u0430<\/h1>\n<p>  \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u00absoft realtime\u00bb, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0443 \u043c\u0443\u0441\u043e\u0440\u0430 \u043a\u043e\u0433\u0434\u0430 \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0438\u0433\u0440\u044b \u0441 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u0431\u043e\u0440\u0449\u0438\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 Nim \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"ruby\">gcDisable() while true:   gameLogic()   renderFrame()   gcStep(us = leftTime)   sleep(restTime) <\/code><\/pre>\n<h1>\u0422\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438 enum<\/h1>\n<p>  \u0427\u0430\u0441\u0442\u043e \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e \u0442\u0438\u043f\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c:<\/p>\n<pre><code class=\"ruby\">type FakeTune = enum   freeze, solo, noJump, noColl, noHook, jetpack  var x: set[FakeTune]  x.incl freeze x.incl solo x.excl solo  echo x + {noColl, noHook}  if freeze in x:   echo &quot;Here be freeze&quot;  var y = {solo, noHook} y.incl 0 # Error: type mismatch <\/code><\/pre>\n<p>  \u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0431\u0438\u0442\u043e\u0432\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440.<\/p>\n<p>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0438 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0439\u0442\u0435 \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e enum.<\/p>\n<pre><code class=\"ruby\">var a: array[FakeTune, int] a[freeze] = 100 echo a[freeze] <\/code><\/pre>\n<h1>Unified Call Syntax<\/h1>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u0430\u0445\u0430\u0440, \u043d\u043e \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e (\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u044d\u0442\u043e \u0443\u0436\u0430\u0441\u043d\u044b\u043c!). \u0412 Python \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u0431\u044b\u0432\u0430\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>len<\/code> \u0438 <code>append<\/code> \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438. \u0412 Nim \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e. Nim \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Unified Call Syntax (\u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0443\u043d\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d \u0432 C++ \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0430\u043c\u0438 Herb Sutter \u0438 Bjarne Stroustrup.<\/p>\n<pre><code class=\"ruby\">var xs = @[1,2,3]  # Procedure call syntax add(xs, 4_000_000) echo len(xs)  # Method call syntax xs.add(0b0101_0000_0000) echo xs.len()  # Command invocation syntax xs.add 0x06_FF_FF_FF echo xs.len <\/code><\/pre>\n<h1>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h1>\n<p>  (\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u00ab\u0443\u0441\u0442\u0430\u0440\u0435\u043b\u00bb, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <a href=\"https:\/\/github.com\/logicchains\/LPATHBench\/blob\/master\/writeup.md\">\u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0439 benchmark<\/a> \u0438 <a href=\"http:\/\/hookrace.net\/blog\/what-is-special-about-nim\/#good-performance\">benchmark, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438<\/a>)<\/p>\n<p>  \u041e\u0442 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430:<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e Nim \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u0430\u043a \u0436\u0435 \u0431\u044b\u0441\u0442\u0440, \u043a\u0430\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c C\/C++. Nim \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 C\/C++\/Obj-C (\u0430 \u043d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u0432 JS) \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e gcc\/clang\/llvm_gcc\/MS-vcc\/Intel-icc. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u043d \u0431\u044b\u0441\u0442\u0440\u0435\u0435 Go, Rust, Crystal, Java \u0438 \u043c\u043d\u043e\u0433\u0438\u0445 \u0434\u0440\u0443\u0433\u0438\u0445.<\/p>\n<h1>\u0422\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u043c \u0432 JavaScript<\/h1>\n<p>  Nim \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c Nim \u043a\u043e\u0434 \u0432 JavaScript. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439, \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Nim. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u0435\u0439. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0448 client.nim:<\/p>\n<pre><code class=\"ruby\">import htmlgen, dom  type Data = object   visitors {.importc.}: int   uniques {.importc.}: int   ip {.importc.}: cstring  proc printInfo(data: Data) {.exportc.} =   var infoDiv = document.getElementById(&quot;info&quot;)   infoDiv.innerHTML = p(&quot;You're visitor number &quot;, $data.visitors,     &quot;, unique visitor number &quot;, $data.uniques,     &quot; today. Your IP is &quot;, $data.ip, &quot;.&quot;) <\/code><\/pre>\n<p>  \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f <code>Data<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0443. \u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 <code>printInfo<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u0430 \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 <code>nim js client<\/code>. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d \u0432 <code>nimcache\/client.js<\/code>.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043f\u0430\u043a\u0435\u0442\u043d\u044b\u0439 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 Nimble, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <a href=\"https:\/\/github.com\/dom96\/jester\">Jester<\/a> (sinatra-\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 web framework \u0434\u043b\u044f Nim). \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c Jester: <code>nimble install jester<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 server.nim:<\/p>\n<pre><code class=\"ruby\">import jester, asyncdispatch, json, strutils, times, sets, htmlgen, strtabs  var   visitors = 0   uniques = initSet[string]()   time: TimeInfo  routes:   get &quot;\/&quot;:     resp body(       `div`(id=&quot;info&quot;),       script(src=&quot;\/client.js&quot;, `type`=&quot;text\/javascript&quot;),       script(src=&quot;\/visitors&quot;, `type`=&quot;text\/javascript&quot;))    get &quot;\/client.js&quot;:     const result = staticExec &quot;nim -d:release js client&quot;     const clientJS = staticRead &quot;nimcache\/client.js&quot;     resp clientJS    get &quot;\/visitors&quot;:     let newTime = getTime().getLocalTime     if newTime.monthDay != time.monthDay:       visitors = 0       init uniques       time = newTime      inc visitors     let ip =       if request.headers.hasKey &quot;X-Forwarded-For&quot;:         request.headers[&quot;X-Forwarded-For&quot;]       else:         request.ip     uniques.incl ip      let json = %{&quot;visitors&quot;: %visitors,                  &quot;uniques&quot;: %uniques.len,                  &quot;ip&quot;: %ip}     resp &quot;printInfo($#)&quot;.format(json)  runForever() <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 <a href=\"http:\/\/localhost:5000\/\">http:\/\/localhost:5000\/<\/a> \u0441\u0435\u0440\u0432\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u00ab\u043f\u0443\u0441\u0442\u0443\u044e\u00bb \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c\u0438 <code>\/client.js<\/code> \u0438 <code>\/visitors<\/code>. <code>\/client.js<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0447\u0435\u0440\u0435\u0437 <code>nim js client<\/code>, \u0430 <code>\/visitors<\/code> \u0431\u0443\u0434\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c JS \u043a\u043e\u0434 \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c <code>printInfo(JSON)<\/code>.<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c <a href=\"http:\/\/visitors.hookrace.net\/\">\u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 Jester \u0441\u0430\u0439\u0442 \u043e\u043d\u043b\u0430\u0439\u043d<\/a>, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code>You're visitor number 11, unique visitor number 11 today. Your IP is 134.90.126.175. <\/code><\/pre>\n<h1>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u044f \u0441\u043c\u043e\u0433 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0442\u044c \u044f\u0437\u044b\u043a\u043e\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Nim.<br \/>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u044f\u0437\u044b\u043a \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u0442\u0430\u0431\u0438\u043b\u0435\u043d. \u041e\u0434\u043d\u0430\u043a\u043e, Nim 1.0 \u0443\u0436\u0435 \u043d\u0435 \u0437\u0430 \u0433\u043e\u0440\u0430\u043c\u0438. \u0422\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 Nim!<br \/>  \u0411\u043e\u043d\u0443\u0441: \u0442\u0430\u043a \u043a\u0430\u043a Nim \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 C \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 C, \u0432\u0430\u0448 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u0437\u0434\u0435.   \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/258119\/\"> http:\/\/habrahabr.ru\/post\/258119\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div style=\"text-align:center;\"><img decoding=\"async\"  src=\"\/\/habrastorage.org\/files\/616\/55b\/6ee\/61655b6ee8f6472d96d54e2184a0917d.png\"\/><\/div>\n<p>  \u042f\u0437\u044b\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"http:\/\/nim-lang.org\/\">Nim<\/a> (\u0440\u0430\u043d\u0435\u0435 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043b\u0441\u044f Nimrod) \u2014 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u0439! \u0412 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a <a href=\"http:\/\/nim-lang.org\/docs\/tut1.html\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/a> \u043f\u043b\u0430\u0432\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442 \u0441 \u044f\u0437\u044b\u043a\u043e\u043c, \u044f \u0445\u043e\u0447\u0443 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 Nim, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0442\u0440\u0443\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445.<\/p>\n<p>  \u042f \u043e\u0442\u043a\u0440\u044b\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f Nim, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u043a\u0430\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438\u0433\u0440\u044b, HoorRace, \u043f\u0440\u0435\u0435\u043c\u043d\u0438\u043a \u043c\u043e\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 DDNet \u0438\u0433\u0440\u044b\/\u043c\u043e\u0434\u0430 Teeworlds.<\/p>\n<p>  <i>(\u043f\u0440\u0438\u043c. \u043f\u0435\u0440. \u041d\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 Nim \u0438\u043c\u0435\u043b\u0438 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 Modula 3, Delphi, Ada, C++, Python, Lisp, Oberon.)<\/i><\/p>\n<h1>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c!<\/h1>\n<p>  \u0414\u0430, \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0435 \u0437\u0430\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u0435 \u0437\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430:<\/p>\n<pre><code class=\"ruby\">for i in 0..10:   echo &quot;Hello World&quot;[0..i] <\/code><\/pre>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-257337","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/257337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=257337"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/257337\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=257337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=257337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=257337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}