question.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ===========================================
  2. Questions and Answers
  3. ===========================================
  4. General FAQ
  5. ===========
  6. .. container:: standout
  7. What is Nim?
  8. ------------
  9. Nim (formerly known as "Nimrod") is a statically typed, imperative programming
  10. language that tries to give the programmer ultimate power without compromises
  11. on runtime efficiency.
  12. This means it focuses on compile-time mechanisms in all their
  13. various forms. Beneath a nice infix/indentation based syntax with a
  14. powerful (AST based, hygienic) macro system lies a semantic model that supports
  15. a soft realtime GC on thread local heaps. Asynchronous message passing is used
  16. between threads, so no "stop the world" mechanism is necessary. An unsafe
  17. shared memory heap is also provided for the increased efficiency that results
  18. from that model.
  19. .. .. container:: standout
  20. .. Why should I use Nim?
  21. .. ---------------------
  22. .. It's a conservative language in a sense that we stick to features that have
  23. .. proven themselves for larger scale programming. But it's revolutionary by
  24. .. the features which have been laid on top.
  25. .. One of Nim's goals is to increase developer productivity without sacrificing
  26. .. the produced software's stability. The way that this is done is by providing
  27. .. Depending on your use case.
  28. .. Nim is one of the few programming languages in the world which allows you to
  29. .. The language inventor describes it as the ultimate programming language
  30. .. with features which make it perfect for just about any problem.
  31. .. container:: standout
  32. Why yet another programming language?
  33. -------------------------------------
  34. Nim is one of the very few *programmable* statically typed languages, and
  35. one of the even fewer that produces native binaries that require no
  36. runtime or interpreter.
  37. .. container:: standout
  38. What have been the major influences in the language's design?
  39. -------------------------------------------------------------
  40. The language borrows heavily from (in order of impact): Modula 3, Delphi, Ada,
  41. C++, Python, Lisp, Oberon.
  42. .. container:: standout
  43. What is Nim's take on concurrency?
  44. ----------------------------------
  45. Nim primarily focusses on thread local (and garbage collected) heaps and
  46. message passing between threads. Each thread has its own GC, so no
  47. "stop the world" mechanism is necessary. An unsafe shared memory heap is also
  48. provided.
  49. Future versions will additionally include a GC "per thread group"
  50. and Nim's type system will be enhanced to accurately model this shared
  51. memory heap.
  52. .. container:: standout
  53. How is Nim licensed?
  54. --------------------
  55. The Nim compiler and the library are MIT licensed.
  56. This means that you can use any license for your own programs developed with
  57. Nim.
  58. .. container:: standout
  59. How stable is Nim?
  60. ------------------
  61. The compiler is in development and some important features are still missing.
  62. However, the compiler is quite stable already: It is able to compile itself
  63. and a substantial body of other code. Until version 1.0.0 is released,
  64. minor incompatibilities with older versions of the compiler will be introduced.
  65. .. container:: standout
  66. How fast is Nim?
  67. ----------------
  68. Benchmarks show it to be comparable to C. Some language features (methods,
  69. closures, message passing) are not yet as optimized as they could and will be.
  70. The only overhead Nim has over C is the GC which has been tuned
  71. for years but still needs some work.
  72. .. container:: standout
  73. What about JVM/CLR backends?
  74. ----------------------------
  75. JVM/CLR support is not in the nearest plans. However, since these VMs support FFI to C
  76. it should be possible to create native Nim bridges, that transparenlty generate all the
  77. glue code thanks to powerful metaprogramming capabilities of Nim.
  78. .. container:: standout
  79. What about editor support?
  80. --------------------------
  81. - Native Nim Editor: https://github.com/nim-lang/Aporia
  82. - Visual Studio Code: https://marketplace.visualstudio.com/items?itemName=kosz78.nim
  83. - Emacs: https://github.com/nim-lang/nim-mode
  84. - Vim: https://github.com/zah/nimrod.vim/
  85. - Scite: Included
  86. - Gedit: The `Aporia .lang file <https://github.com/nim-lang/Aporia/blob/master/share/gtksourceview-2.0/language-specs/nim.lang>`_
  87. - jEdit: https://github.com/exhu/nimrod-misc/tree/master/jedit
  88. - TextMate: Available in bundle installer (`Repository <https://github.com/textmate/nim.tmbundle>`_)
  89. - Sublime Text: Available via Package Control (`Repository <https://github.com/Varriount/NimLime>`_)
  90. - LiClipse: http://www.liclipse.com/ (Eclipse based plugin)
  91. - Howl: Included
  92. - Notepad++: Available via `plugin <https://github.com/jangko/nppnim/releases>`_
  93. .. container:: standout
  94. Why is it named ``proc``?
  95. -------------------------
  96. *Procedure* used to be the common term as opposed to a *function* which is a
  97. mathematical entity that has no side effects. It is planned to have ``func``
  98. as syntactic sugar for ``proc {.noSideEffect.}`` and ``func`` is already a
  99. keyword. Naming it ``def`` would not make sense because Nim also provides a
  100. ``iterator`` and ``method`` keywords, whereas ``def`` stands for ``define``.
  101. Compilation FAQ
  102. ===============
  103. .. container:: standout
  104. Which option to use for the fastest executable?
  105. -----------------------------------------------
  106. For the standard configuration file, ``-d:release`` does the trick.
  107. .. container:: standout
  108. Which option to use for the smallest executable?
  109. ------------------------------------------------
  110. For the standard configuration file, ``-d:quick --opt:size`` does the trick.
  111. .. container:: standout
  112. How do I use a different C compiler than the default one?
  113. ---------------------------------------------------------
  114. Edit the ``config/nim.cfg`` file.
  115. Change the value of the ``cc`` variable to one of the following:
  116. ================ ============================================
  117. **Abbreviation** **C/C++ Compiler**
  118. ================ ============================================
  119. ``vcc`` Microsoft's Visual C++
  120. ``gcc`` Gnu C
  121. ``llvm_gcc`` LLVM-GCC compiler
  122. ``icc`` Intel C++ compiler
  123. ``clang`` Clang compiler
  124. ``ucc`` Generic UNIX C compiler
  125. ================ ============================================
  126. Other C compilers are not officially supported, but might work too.
  127. If your C compiler is not in the above list, try using the
  128. *generic UNIX C compiler* (``ucc``). If the C compiler needs
  129. different command line arguments try the ``--passc`` and ``--passl`` switches.