Nim (programming language): Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
 
(8 intermediate revisions by 6 users not shown)
Line 5:
| name = Nim
| logo = Nim logo.svg
| logo size = 140px
| logo caption = The Nim crown logo
| screenshot = <!-- Filename only -->
Line 23 ⟶ 22:
| operating system = [[Cross-platform software|Cross-platform]]<ref>{{Cite web |url=https://nim-lang.org/install.html |title=Install Nim |access-date=2018-10-12}}</ref>
| license = {{wikidata|property|reference|edit|P275}}
| website = {{urlURL|https://nim-lang.org/}}
| file ext = .nim, .nims, .nimble
}}
 
'''Nim''' is a [[General-purpose programming language|general-purpose]], [[multi-paradigm programming language|multi-paradigm]], [[statically typed]], [[Compiled language|compiled]] [[High-level programming language|high-level]] [[System programming language|system]] [[programming language]],<ref name="drdobbs">{{cite web |url=http://www.drdobbs.com/open-source/nimrod-a-new-systems-programming-languag/240165321 |title=Nimrod: A new systems programming language |last=Rumpf |first=Andreas |website=[[Dr. Dobb's Journal]] |date=2014-02-11 |access-date=2014-07-20}}</ref> designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant",<ref name="nim-lang">{{cite web |url=http://nim-lang.org/ |title=The Nim Programming Language |website=Nim-lang.org |access-date=2014-07-20}}</ref> supporting [[metaprogramming]], [[functional programming|functional]], [[message passing]],<ref name="FAQ">{{cite web |url=https://nim-lang.org/faq.html |title=FAQ |website=nim-lang.org |access-date=2015-03-27}}</ref> [[Procedural programming|procedural]], and [[object-oriented programming]] styles by providing several features such as [[compile time]] code generation, [[algebraic data type]]s, a [[foreign function interface]] (FFI) with [[C (programming language)|C]], [[C++]], [[Objective-C]], and [[JavaScript]], and supporting compiling to those same languages as [[intermediate representation]]s.
 
Line 110 ⟶ 108:
| 2023-08-01
|-
| {{Version | co | 2.0.1416}}
| 20242025-1204-2422
|-
| rowspan="2" | 2.2
Line 117 ⟶ 115:
| 2024-10-02
|-
| {{Version | c | 2.2.24}}
| 2025-0204-0622
|-
| colspan="3" | {{Version | l | show=111100}}
Line 127 ⟶ 125:
Andreas Rumpf is the designer and original implementer of Nim. He received a diploma in computer science from the [[University of Kaiserslautern-Landau]], [[Germany]]. His research interests include hard realtime systems, embedded systems, compiler construction and artificial intelligence.<ref>{{Cite book |last=Andreas Rumpf |title=Mastering Nim: A complete guide to the programming language}}</ref>
 
[https://nim-lang.org Nim's] original website design by Dominik Picheta and Hugo Locurcio. Joseph Wecker created the Nim logo.
 
The Nim programming language is '''a concise, fast programming language''' that compiles to C, C++ and JavaScript. Nim's initial development was started in 2005 by Andreas Rumpf. It was originally named Nimrod when the project was made public in 2008.<ref name="NimAction">{{Cite book |last=Picheta |first=Dominik |year=2017 |title=Nim in Action |publisher=Manning Publications |isbn=978-1617293436}}</ref>{{rp|4–11}}<!-- Section 1.1: What is Nim? -->
 
The first version of the Nim [[compiler]] was written in [[Pascal (programming language)|Pascal]] using the [[Free Pascal]] compiler.<ref name="pas-sources">{{cite web |url=https://github.com/Araq/Nim/tree/ea1f1ec6d4d6c776eb0f81c2bebdd4cb4c817ebe/nim |title=Nim Pascal Sources |website=GitHub |access-date=2013-04-05}}</ref> In 2008, a version of the compiler written in Nim was released.<ref name="news">{{cite web |url=http://nim-lang.org:80/news.html |title=News |website=Nim-lang.org |access-date=2016-06-11 |url-status=live |archive-url=https://web.archive.org/web/20160626002904/http://nim-lang.org/news.html |archive-date=2016-06-26}}</ref> The compiler is [[free and open-source software]], and is being developed by a community of volunteers working with Andreas Rumpf.<ref name="contributors">{{cite web |url=https://github.com/Araq/Nim/contributors |title=Contributors |website=GitHub |access-date=2013-04-05}}</ref> The language was officially renamed from ''Nimrod'' to ''Nim'' with the release of version 0.10.2 in December 2014.<ref>{{cite web |url=https://nim-lang.org/blog/2014/12/29/version-0102-released.html |title=Version 0.10.2 released |date=2014-12-29 |first=Dominik |last=Picheta |website=Nim-lang.org |access-date=2018-10-17}}</ref> On September 23, 2019, version 1.0 of Nim was released, signifying the maturing of the language and its toolchain. On August 1, 2023, version 2.0 of Nim was released, signifying the completion, stabilization of, and switch to the ARC/ORC memory model.<ref name="Nim v2.0 released">{{Cite web |title=Nim v2.0 released |url=https://nim-lang.org/blog/2023/08/01/nim-v20-released.html |access-date=2023-08-17 |website=Nim Programming Language |language=en}}</ref>
Line 185 ⟶ 183:
*[[ParaSail (programming language)|ParaSail]]: pointer-free programming<ref name="parasail"/>
 
=== Uniform Functionfunction Callcall Syntaxsyntax ===
Nim supports [[Uniformuniform Functionfunction Callcall Syntaxsyntax]] (UFCS)<ref>{{Cite web |url=http://nim-lang.org/docs/manual.html#procedures-method-call-syntax |title=Nim Manual: Method call syntax |access-date=2018-10-12}}</ref> and identifier equality, which provides a large degree of flexibility in use.
 
For example, each of these lines print [["Hello, World!" program|"hello world"]], just with different syntax:
Line 484 ⟶ 482:
 
==== Function composition ====
[[Uniform Function Call Syntax|Uniform function call syntax]] allows for the [[Function composition (computer science)|chaining of arbitrary functions]], perhaps best exemplified with the <code>std/sequtils</code> library.<ref>{{Cite web |title=std/sequtils |url=https://nim-lang.org/docs/sequtils.html |access-date=2023-08-17 |website=nim-lang.org}}</ref><syntaxhighlight lang="nim">
import std/[sequtils, sugar]
 
Line 551 ⟶ 549:
 
==== Method calls and encapsulation ====
Nim's [[Uniform Function Call Syntax|uniform function call syntax]] enables calling ordinary functions with syntax similar to method call invocations in other programming languages. This is functional for "getters": and Nim also provides syntax for the creation of such "setters" as well. Objects may be made public on a per-field basis, providing for encapsulation.
<syntaxhighlight lang="nim">
type Socket* = ref object
host: int # private, lacks export marker
Line 755 ⟶ 754:
== See also ==
{{Portal|Computer programming}}
*[[C (programming language)]]
* [[C++|C++ (programming language)]]
* [[Crystal (programming language)]]
* [[D (programming language)]]
* [[Go (programming language)]]
* [[Rust (programming language)]]
* [[Fat pointer]]