Nim (programming language): Difference between revisions

Content deleted Content added
Nim version 2.0.8 released
Cut obsolete parameter. WP:LINKs: update-standardizes, add. Small WP:COPYEDITs WP:EoS: WP:TERSE, clarify.
Line 12:
| paradigms = [[Multi-paradigm programming language|Multi-paradigm]]: [[Compiled language|compiled]], [[Concurrent programming|concurrent]], [[Procedural programming|procedural]], [[Imperative programming|imperative]], [[Functional programming|functional]], [[Object-oriented programming|object-oriented]], [[Metaprogramming|meta]]
| designer = Andreas Rumpf<!-- Do not WP:LINK to late German classical archaeologist. -->
| developer = Nim Lang Team<ref>{{cite web |url = https://github.com/nim-lang/Nim/graphs/contributors |title = Contributors to nim-lang/Nim |website = [[GitHub]] |access-date = 23 March 2022}}</ref>
| released = {{Start date and age|2008}}
| latest release version = {{wikidata|property|reference|edit|P348}}
Line 18:
| typing = [[Static typing|Static]],<ref name="nimbyex">{{cite web |url=https://nim-by-example.github.io/ |title=Nim by example |website=[[GitHub]] |access-date=2014-07-20}}</ref> [[Strong and weak typing|strong]],<ref name="nimrodbg">{{cite conference |url=https://ibob.github.io/slides/nimrodbg/#/ |language=bg |title=Метапрограмиране с Nimrod |last1=Караджов |first1=Захари |last2=Станимиров |first2=Борислав |year=2014 |conference=VarnaConf |conference-url=http://varnaconf.com/ |access-date=2014-07-27}}</ref> [[Type inference|inferred]], [[Structural type system|structural]]
| scope = [[Scope (computer science)|Lexical]]
| programming language = [[Pascal (programming language)|Pascal]] (2005–2008)<br/>Nim (2008–present, self-hosted)
| programming_language = Nim (self-hosted)
| dialects =
| influenced by = [[Ada (programming language)|Ada]], [[Modula-3]], [[Lisp (programming language)|Lisp]], [[C++]], [[Object Pascal]], [[Python (programming language)|Python]], [[Oberon (programming language)|Oberon]], [[Rust (programming language)|Rust]], [[ParaSail (programming language)|ParaSail]]<ref name = "parasail">{{cite web |url= https://nim-lang.org/araq/destructors.html |title=Nim without GC |first=Andreas |last=Rumpf |website=Araq's Musings |date=2017-10-19 |access-date=2020-09-01}}</ref>
| platform = [[IA-32]], [[x86-64]], [[ARM architecture|ARM]], [[Aarch64]], [[RISC-V]], [[PowerPC]] ...<ref>{{Cite web |url = https://nim-lang.org/docs/packaging.html |title = Packaging Nim |access-date = 23 March 2022}}</ref>
| 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 = {{URL|nim-lang.org}}
| forum = {{URL|forum.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 programmingCompiled language|compiled]] [[highHigh-level programming language|high-level]] [[systemsSystem 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.
 
== Description ==
Line 422 ⟶ 421:
 
=== Functional programming ===
[[Functional programming]] is supported in Nim through [[first-class function]]s and code without [[Side effect (computer science)|side effects]] via the <code>noSideEffect</code> pragma or the <code>func</code> keyword.<ref>{{Cite web|title=Nim Manual|url=https://nim-lang.org/docs/manual.html#procedures-func|access-date=2021-07-10|website=nim-lang.org}}</ref> Nim will perform [[Side effect (computer science)|side effect]] analysis and raise compilationcompiling errors for code that does not obey the contract of producing no [[Side effect (computer science)|side effects]] when compiled with the experimental feature <code>strictFuncs</code>, planned to become the default in later versions.<ref>{{Cite web |title=Nim Forum: Update on strict funcs |url=https://forum.nim-lang.org/t/9716 |access-date=2023-08-17 |website=forum.nim-lang.org}}</ref>
 
Contrary to purely [[functional programming]] languages, Nim is a [[Programming paradigm#Support for multiple paradigms|multi-paradigm]] programming language, so [[functional programming]] restrictions are opt-in on a function-by-function basis.
Line 656 ⟶ 655:
In this code the <code>printf</code> function is imported into Nim and then used.
 
Basic example using 'console.log' directly for the [[JavaScript]] compilationcompiling target:
 
<syntaxhighlight lang="nim">