Dynamic programming language: Difference between revisions

Content deleted Content added
mNo edit summary
 
(29 intermediate revisions by 24 users not shown)
Line 1:
{{Short description|Class of programmingProgramming languages which execute some behaviors atwith runtime instead of compilationextensibility}}
{{About|a class of programming languages|the method for reducing the running time of algorithms|Dynamic programming}}
{{Multiple issues|
{{disputed|date=March 2012}}
{{confusing|date=October 2009}}
}}
A '''dynamic programming language''' is a type of programming language that allows various operations to be determined and executed at runtime. This is different from the compilation phase. Key decisions about variables, method calls, or data types are made when the program is running, unlike in [[Static program analysis|static languages]], where the structure and types are fixed during compilation. Dynamic languages provide flexibility. This allows developers to write more adaptable and concise code.
 
For instance, in a dynamic language, a variable can start as an integer. It can later be reassigned to hold a string without explicit type declarations. This feature of dynamic typing enables more fluid and less restrictive coding. Developers can focus on the logic and functionality rather than the constraints of the language.
{{Programming paradigms}}
 
In [[computer science]], a '''dynamic programming language''' is a class of [[high-level programming language]]s, which at [[Runtime (program lifecycle phase)|runtime]] execute many common programming behaviours that [[Static program analysis|static programming language]]s perform during [[Compiler|compilation]]. These behaviors could include an extension of the program, by adding new [[Source code|code]], by extending [[Object (computer science)|objects]] and definitions, or by modifying the [[type system]]. Although similar behaviors can be emulated in nearly any language, with varying degrees of difficulty, complexity and performance costs, dynamic languages provide direct tools to make use of them. Many of these features were first implemented as native features in the [[Lisp (programming language)|Lisp]] programming language.
 
Most dynamic languages are also [[Dynamic typing|dynamically typed]], but not all are. Dynamic languages are frequently (but not always) referred to as [[scripting language]]s, although that term in its narrowest sense refers to languages specific to a given run-time environment.
 
==Implementation==
Line 16 ⟶ 12:
 
===Eval===
Some dynamic languages offer an ''[[eval]]'' function. This function takes a string or [[abstract syntax tree]] containing code in the language and executes it. If this code stands for an expression, the resulting value is returned. [[Erik Meijer (computer scientist)|Erik Meijer]] and Peter Drayton distinguish the [[runtime code generation]] offered by eval from the [[dynamic loading]] offered by [[shared libraries]], and warn that in many cases eval is used merely to implement [[higher-order function]]s (by passing functions as strings) or [[deserialization]].<ref>{{Citation | citeseerx = 10.1.1.69.5966 | title=Static Typing Where Possible, Dynamic Typing When Needed: The End of the Cold War Between Programming Languages | author=[[Erik Meijer (computer scientist)|Meijer, Erik]] and Peter Drayton | year=2005 | publisher=[[Microsoft]] Corporation|url=https://people.dsv.su.se/~beatrice/DYPL/meijer_drayton.pdf}}</ref>
 
===Object runtime alteration===
A type or object system can typically be modified during runtime in a dynamic language. This can mean generating new objects from a runtime definition or based on [[mixin]]s of existing types or objects. This can also refer to changing the [[Inheritance (computerobject-oriented scienceprogramming)|inheritance]] or type tree, and thus altering the way that existing types behave (especially with respect to the invocation of [[Method (computer science)|methods]]).
 
===Type inference===
Line 34 ⟶ 30:
 
[[Assembly language|Assembly]], [[C (programming language)|C]], [[C++]], early [[Java (programming language)|Java]], and [[Fortran]] do not generally fit into this category.{{clarify|date=September 2016}}
 
The earliest dynamic programming language is considered to be Lisp (McCarthy, 1965) which continued to influence the design of programming languages to the present day.<ref>{{cite book| last=Harper| first=Robert | title=Practical Foundations for Programming languages | page=195 | year=2016 |publisher=Cambridge University Press| ___location=New York| isbn=9-781107-150300}}</ref>
 
==Example code==
Line 107 ⟶ 105:
#<PERSON Eva Luator age: 25>
</syntaxhighlight>
let foo = 42; // foo is now a number
foo = "bar"; // foo is now a string
foo = true; // foo is now a boolean
 
===Assembling of code at runtime based on the class of instances===
Line 169 ⟶ 170:
* [[ActionScript]]
* [[BeanShell]]<ref>[http://static.springsource.org/spring/docs/2.0.x/reference/dynamic-language.html Chapter 24. Dynamic language support]. Static.springsource.org. Retrieved on 2013-07-17.</ref>
* [[C Sharp (programming language)|C#]] (using Reflectionreflection)]]
* [[Clojure]]
* [[CobolScript]]
Line 178 ⟶ 179:
* [[Elixir (programming language)|Elixir]]
* [[Erlang (programming language)|Erlang]]
* [[Forth (programming language)|FORTHForth]]
* [[Gambas]]
* [[GDScript]]
Line 188 ⟶ 189:
* [[MATLAB]] / [[GNU Octave|Octave]]
* [[Objective-C]]
* [[Object REXX|ooRexx]]
* [[Perl]]
* [[PHP]]
Line 196 ⟶ 198:
* [[Raku (programming language)|Raku]]
* [[Rebol]]
* [[Ring (programming language)|Ring]]
* [[Ruby (programming language)|Ruby]]
* [[Smalltalk]]
Line 220 ⟶ 223:
* {{cite speech |author-link1=Larry Wall |last1=Wall |first1=Larry |date=2007-12-06 |df=mdy |url=https://www.perl.com/pub/2007/12/06/soto-11.html/ |title=Programming is Hard, Let's Go Scripting... |event=[[Perl#State of the Onion|State of the Onion]] 11 |work=Perl.com |access-date=2020-07-27}}
* {{cite web |last1=Roth |first1=Gregor |date=2007-11-20 |df=mdy |url=https://www.infoworld.com/article/2077792/scripting-on-the-java-platform.html |title=Scripting on the Java platform |work=[[JavaWorld]] |access-date=2020-07-27}}
* {{cite magazine |author-link1=John Ousterhout |last1=Ousterhout |first1=John K. |date=March 1998 |df=mdy |url=http://www.stanfordlibrary.us/~ouster/cgi-bin/papers/scripting.pdf |title=Scripting: Higher-Level Programming for the 21st Century |magazine=[[Computer (magazine)|Computer]] |volume=31 |issue=3 |pages=23–30 |issn=0018-9162 |doi=10.1109/2.660187 |access-date=2020-07-27 |archive-date=2020-07-27 |archive-url=https://web.archive.org/web/20200727185732/http://www.stanfordlibrary.us/~ouster/cgi-bin/papers/scripting.pdf |url-status=dead }}
* {{cite news |date=2004-07-26 |df=mdy |url=https://www.activestate.com/company/press/press-releases/activestate-announces-focus-dynamic-languages/ |title=ActiveState Announces Focus on Dynamic Languages |publisher=[[ActiveState]] |access-date=2020-07-27}}
** {{cite web |last1=Ascher |first1=David |date=2004-07-27 |df=mdy |url=https://www.activestate.com/Corporate/Publications/ActiveState_Dynamic_Languages.pdf |title=Dynamic Languages — ready for the next challenges, by design |department=Whitepapers |publisher=[[ActiveState]] |archive-url=https://web.archive.org/web/20081118035341/https://www.activestate.com/Corporate/Publications/ActiveState_Dynamic_Languages.pdf |archive-date=2008-11-18}}
** {{cite web |last1=Ascher |first1=David |date=2004-07-27 |df=mdy |url=http://www.activestate.com/company/newsroom/whitepapers_ADL.plex |title=Dynamic Languages — ready for the next challenges, by design |department=Whitepapers |publisher=[[ActiveState]] |archive-url=https://web.archive.org/web/20081208121835/http://www.activestate.com/company/newsroom/whitepapers_ADL.plex |archive-date=2008-12-08}}
 
{{Types of programming languages}}