#language #D
D
- is a system programming language first appeared in 2001. Though it originated as a re-engineering of C++, D is a distinct language, having redesigned some core C++ features while also taking inspiration from other languages, notably Java, Python, Ruby, C#, and Eiffel.
D attempts to combine the performance and safety of compiled languages with the expressive power of modern dynamic languages. Idiomatic D code is commonly as fast as equivalent C++ code, while being shorter and memory-safe. Type inference, automatic memory management and syntactic sugar for common types allow faster development, while bounds checking, design by contract features and a concurrency-aware type system help reduce the occurrence of bugs.
Paradigms: #imperative, #object_oriented, #metaprogramming, #functional and #concurrent (actor model)
Comparison with C
Despite their difference, D has been constrained in its design by the rule that any code that is legal in both C and D should behave in the same way.
Comparison with C++
Things D gained before C++:
• closures
• anonymous functions
• compile time function execution
Things D adds:
• design by contract
• unit testing
• true modules
• garbage collection
• first class arrays
• associative arrays
• dynamic arrays
• array slicing
• nested functions
• lazy evaluation
• built-in support for documentation comments, allowing automatic documentation generation
Things D replaces:
• multiple inheritance is replaced by Java-style single inheritance with interfaces and mixins.
• template syntax is re-engineered
Things they have in common:
• D's declaration, statement and expression syntax closely matches that of C++.
• D retains C++'s ability to perform low-level coding and to add inline assembler. The inline assembler typifies the differences between D and application languages like Java and C#. An inline assembler lets programmers enter machine-specific assembly code within standard D code, a method often used by system programmers to access the low-level features of the processor needed to run programs that interface directly with the underlying hardware, such as operating systems and device drivers.
Docs: https://dlang.org/spec/spec.html
D
- is a system programming language first appeared in 2001. Though it originated as a re-engineering of C++, D is a distinct language, having redesigned some core C++ features while also taking inspiration from other languages, notably Java, Python, Ruby, C#, and Eiffel.
D attempts to combine the performance and safety of compiled languages with the expressive power of modern dynamic languages. Idiomatic D code is commonly as fast as equivalent C++ code, while being shorter and memory-safe. Type inference, automatic memory management and syntactic sugar for common types allow faster development, while bounds checking, design by contract features and a concurrency-aware type system help reduce the occurrence of bugs.
Paradigms: #imperative, #object_oriented, #metaprogramming, #functional and #concurrent (actor model)
Comparison with C
Despite their difference, D has been constrained in its design by the rule that any code that is legal in both C and D should behave in the same way.
Comparison with C++
Things D gained before C++:
• closures
• anonymous functions
• compile time function execution
Things D adds:
• design by contract
• unit testing
• true modules
• garbage collection
• first class arrays
• associative arrays
• dynamic arrays
• array slicing
• nested functions
• lazy evaluation
• built-in support for documentation comments, allowing automatic documentation generation
Things D replaces:
• multiple inheritance is replaced by Java-style single inheritance with interfaces and mixins.
• template syntax is re-engineered
Things they have in common:
• D's declaration, statement and expression syntax closely matches that of C++.
• D retains C++'s ability to perform low-level coding and to add inline assembler. The inline assembler typifies the differences between D and application languages like Java and C#. An inline assembler lets programmers enter machine-specific assembly code within standard D code, a method often used by system programmers to access the low-level features of the processor needed to run programs that interface directly with the underlying hardware, such as operating systems and device drivers.
Docs: https://dlang.org/spec/spec.html
System software versus application software
System software is designed to operate and control the hardware, and to provide a platform for running application software; e.g. operating systems, utility software, device drivers, compilers, and linkers.
System programming languages, in contrast with application languages, typically offer more direct access to the physical hardware of the machine: an archetypical system programming language in this sense was BCPL.
System programming languages often lack built-in input/output (I/O) facilities because a system-software project usually develops its own I/O mechanisms or builds on top of basic monitor I/O or screen management facilities.
e.g. PL/I, #C, C++, #Ada, #D, Nim, #Rust, #Swift
System software is designed to operate and control the hardware, and to provide a platform for running application software; e.g. operating systems, utility software, device drivers, compilers, and linkers.
System programming languages, in contrast with application languages, typically offer more direct access to the physical hardware of the machine: an archetypical system programming language in this sense was BCPL.
System programming languages often lack built-in input/output (I/O) facilities because a system-software project usually develops its own I/O mechanisms or builds on top of basic monitor I/O or screen management facilities.
e.g. PL/I, #C, C++, #Ada, #D, Nim, #Rust, #Swift
Documentation generators
Here are some documentation generators, their language support, and output formats:
ROBODoc
By: Frans Slothouber, 1995
Supports: C, C++, Java, VB, VBScript, Delphi, Pascal, Ada, D, IDL, Fortran, PHP, Perl, Ruby, JavaScript, ActionScript, PL/SQL, Tcl
Outputs: HTML, RTF, LaTeX, man pages, DocBook
Doxygen
By: Dimitri van Heesch, 1997
Supports: C, C++, Java, C#, VB, VBScript, Delphi, Pascal, D, IDL, Fortran
Outputs: HTML, CHM, RTF, LaTeX, man pages, DocBook, XML
HeaderDoc
By: Apple Inc., 2000
Supports: C, C++, Java, Delphi, Pascal, IDL, PHP, Perl, Python, Ruby, JavaScript, Tcl, AppleScript, MIG, Bourne shell, C shell
Outputs: HTML, man pages, XML
Natural Docs
By: Greg Valure, 2003
Supports: C, C++, Java, C#, VB, VBScript, Delphi, Pascal, Ada, Fortran, PHP, Perl, Python, Ruby, JavaScript, ActionScript, PL/SQL, Tcl
Outputs: HTML
Sphinx
By: Georg Brandl, 2008
Supports: C, C++, Java, Ada, Fortran, PHP, Python, Ruby, JavaScript
Outputs: HTML, CHM, LaTeX, man pages, XML
Other
• D: Ddoc
• Python: Epydoc, pydoc
• Haskell: Haddock
• Java: Javadoc
• JavaScript: JSDoc, JsDoc Toolkit
• Perl: perldoc (pod)
• PHP: phpDocumentor
• Ruby: RDoc
Here are some documentation generators, their language support, and output formats:
ROBODoc
By: Frans Slothouber, 1995
Supports: C, C++, Java, VB, VBScript, Delphi, Pascal, Ada, D, IDL, Fortran, PHP, Perl, Ruby, JavaScript, ActionScript, PL/SQL, Tcl
Outputs: HTML, RTF, LaTeX, man pages, DocBook
Doxygen
By: Dimitri van Heesch, 1997
Supports: C, C++, Java, C#, VB, VBScript, Delphi, Pascal, D, IDL, Fortran
Outputs: HTML, CHM, RTF, LaTeX, man pages, DocBook, XML
HeaderDoc
By: Apple Inc., 2000
Supports: C, C++, Java, Delphi, Pascal, IDL, PHP, Perl, Python, Ruby, JavaScript, Tcl, AppleScript, MIG, Bourne shell, C shell
Outputs: HTML, man pages, XML
Natural Docs
By: Greg Valure, 2003
Supports: C, C++, Java, C#, VB, VBScript, Delphi, Pascal, Ada, Fortran, PHP, Perl, Python, Ruby, JavaScript, ActionScript, PL/SQL, Tcl
Outputs: HTML
Sphinx
By: Georg Brandl, 2008
Supports: C, C++, Java, Ada, Fortran, PHP, Python, Ruby, JavaScript
Outputs: HTML, CHM, LaTeX, man pages, XML
Other
• D: Ddoc
• Python: Epydoc, pydoc
• Haskell: Haddock
• Java: Javadoc
• JavaScript: JSDoc, JsDoc Toolkit
• Perl: perldoc (pod)
• PHP: phpDocumentor
• Ruby: RDoc
#mathematics
Type theory
A type theory is a system in which every "term" has a "type", and operations are restricted to terms of a certain type. A well-known type theory that can serve as a mathematical foundation is Alonzo Church's typed lambda calculus.
Typed lambda calculi
- use the lambda-symbol to denote anonymous function abstraction. They are the base of typed functional programming languages such as ML and #Haskell. Routines of strongly typed languages closely correspond to typed lambda expressions.
kinds:
• Simply typed
• System T
• System F
• System F<:
• System F-omega
• System U and U-minus
“The fundamental problem addressed by a type theory is to ensure that programs have meaning. The fundamental problem caused by a type theory is that meaningful programs may not have meanings ascribed to them. The quest for richer type systems results from this tension.”
― Mark Manasse
Type theory is closely related to, and may overlap with, type systems, which are a feature of programming languages.
Type theory
A type theory is a system in which every "term" has a "type", and operations are restricted to terms of a certain type. A well-known type theory that can serve as a mathematical foundation is Alonzo Church's typed lambda calculus.
Typed lambda calculi
- use the lambda-symbol to denote anonymous function abstraction. They are the base of typed functional programming languages such as ML and #Haskell. Routines of strongly typed languages closely correspond to typed lambda expressions.
kinds:
• Simply typed
• System T
• System F
• System F<:
• System F-omega
• System U and U-minus
“The fundamental problem addressed by a type theory is to ensure that programs have meaning. The fundamental problem caused by a type theory is that meaningful programs may not have meanings ascribed to them. The quest for richer type systems results from this tension.”
― Mark Manasse
Type theory is closely related to, and may overlap with, type systems, which are a feature of programming languages.
Flynn's taxonomy
- is a classification of computer architectures, proposed by Michael J. Flynn in 1966. The classification system has stuck, and has been used as a tool in design of modern processors and their functionalities.
Classifications are based upon the number of concurrent instruction (or control) streams and data streams available in the architecture.
• SISD: one operation at a time, e.g. very old PCs
• SIMD: can be achieved by pipelining, multiple functional units, or vertor processors
• MISD: uncommon, e.g. Space Shuttle flight control computer
• MIMD: e.g. most of the TOP500 supercomputers
The names are each short for a variation of "single/multiple instruction streams single/multiple data streams".
- is a classification of computer architectures, proposed by Michael J. Flynn in 1966. The classification system has stuck, and has been used as a tool in design of modern processors and their functionalities.
Classifications are based upon the number of concurrent instruction (or control) streams and data streams available in the architecture.
• SISD: one operation at a time, e.g. very old PCs
• SIMD: can be achieved by pipelining, multiple functional units, or vertor processors
• MISD: uncommon, e.g. Space Shuttle flight control computer
• MIMD: e.g. most of the TOP500 supercomputers
The names are each short for a variation of "single/multiple instruction streams single/multiple data streams".
Data layout
- is how multidimensional arrays are stored in a linear storage such as RAM. It is critical for:
• correctly passing arrays between programs written in different programming languages
• performance when traversing an array because modern CPUs, due to caching, process sequential data more efficiently than non-sequential data
• contiguous access makes it possible to use SIMD instructions that operate on vectors of data
Row-major versus column-major order
The difference between the orders lies in which elements of an array are contiguous in memory. In a row-major order, the consecutive elements of a row reside next to each other, whereas the same holds true for consecutive elements of a column in a column-major order. While the terms allude to the rows and columns of a two-dimensional array, the orders can be generalized to arrays of any dimension.
Transposition
As exchanging the indices of an array is the essence of array transposition, an array stored as row-major but read as column-major (or vice versa) will appear transposed. As actually performing this rearrangement in memory is typically an expensive operation, some systems provide options to specify individual matrices as being stored transposed.
Languages support
• Row-major: #C/C++/Objective-C (for C-style arrays), PL/I, #Pascal, Speakeasy, SAS, and Rasdaman
• Column-major: #Fortran, #MATLAB, GNU Octave, S-Plus, #R, #Julia, and Scilab.
• Neither (for less dense arrays):
• Iliffe vectors: #Java, #Scala, #Swift. #Ruby, #Perl, #PHP, #JavaScript, Visual Basic .NET
• Lists of lists: #Python, Wolfram Language of Wolfram Mathematica
• Tables of tables: #Lua
- is how multidimensional arrays are stored in a linear storage such as RAM. It is critical for:
• correctly passing arrays between programs written in different programming languages
• performance when traversing an array because modern CPUs, due to caching, process sequential data more efficiently than non-sequential data
• contiguous access makes it possible to use SIMD instructions that operate on vectors of data
Row-major versus column-major order
The difference between the orders lies in which elements of an array are contiguous in memory. In a row-major order, the consecutive elements of a row reside next to each other, whereas the same holds true for consecutive elements of a column in a column-major order. While the terms allude to the rows and columns of a two-dimensional array, the orders can be generalized to arrays of any dimension.
Transposition
As exchanging the indices of an array is the essence of array transposition, an array stored as row-major but read as column-major (or vice versa) will appear transposed. As actually performing this rearrangement in memory is typically an expensive operation, some systems provide options to specify individual matrices as being stored transposed.
Languages support
• Row-major: #C/C++/Objective-C (for C-style arrays), PL/I, #Pascal, Speakeasy, SAS, and Rasdaman
• Column-major: #Fortran, #MATLAB, GNU Octave, S-Plus, #R, #Julia, and Scilab.
• Neither (for less dense arrays):
• Iliffe vectors: #Java, #Scala, #Swift. #Ruby, #Perl, #PHP, #JavaScript, Visual Basic .NET
• Lists of lists: #Python, Wolfram Language of Wolfram Mathematica
• Tables of tables: #Lua
Iliffe vector
-, a.k.a. a display, is a data structure used to implement multi-dimensional arrays. It stores elements in the same row contiguously (like row-major order); but not the rows themselves, their pointers. They are often used to avoid the need for expensive multiplication operations when performing address calculation on an array element. They can also be used to implement jagged arrays and other kinds of irregularly shaped arrays.
Jagged array
- is an array of arrays of which the member arrays can be of different sizes. Visualization of its rows produce jagged edges, hence the "jagged". They are commonly implemented as Iliffe vectors.
-, a.k.a. a display, is a data structure used to implement multi-dimensional arrays. It stores elements in the same row contiguously (like row-major order); but not the rows themselves, their pointers. They are often used to avoid the need for expensive multiplication operations when performing address calculation on an array element. They can also be used to implement jagged arrays and other kinds of irregularly shaped arrays.
Jagged array
- is an array of arrays of which the member arrays can be of different sizes. Visualization of its rows produce jagged edges, hence the "jagged". They are commonly implemented as Iliffe vectors.
#language #R
R
- is a programming language and software environment for statistical computing and graphics. The language is widely used among statisticians and data miners for developing statistical software and data analysis. Polls, data mining surveys and studies of scholarly literature databases, show substantial increases in popularity in recent years.
Paradigms: #object_oriented, #imperative
First appeared: 1993
Influenced by: #Lisp, S, Scheme
Influenced: #Julia
#TIOBE rank: 18 (as of 2018)
Source code for the R software environment is written primarily in #C, #Fortran and R itself. The project was conceived in 1992, with an initial version released in 1995 and a stable beta version in 2000.
Syntax
• Assignment
The generally preferred assignment operator is an arrow made from two characters
• Vectors
The scalar data type was never a data structure of R; instead, a scalar is represented as a vector with length one. Data structures include vectors, matrices, arrays, data frames (similar to tables in a relational database) and lists.
Features:
• supports matrix arithmetic
• supports regression analysis, time-series analysis, spatial analysis
• has generic functions (which act differently depending on the classes of arguments passed to them i.e. dispatch the function/method specific to that class of object; e.g.
• arrays are stored in column-major order
RStudio
The most commonly used graphical integrated development environment for R is RStudio. It is written in Java, C++ (the Qt framework for its GUI) and JavaScript. Work on RStudio started around December 2010, and the first public beta version was officially announced in February 2011. Version 1.0 was released on 1 November 2016.
www.rstudio.com
R
- is a programming language and software environment for statistical computing and graphics. The language is widely used among statisticians and data miners for developing statistical software and data analysis. Polls, data mining surveys and studies of scholarly literature databases, show substantial increases in popularity in recent years.
Paradigms: #object_oriented, #imperative
First appeared: 1993
Influenced by: #Lisp, S, Scheme
Influenced: #Julia
#TIOBE rank: 18 (as of 2018)
Source code for the R software environment is written primarily in #C, #Fortran and R itself. The project was conceived in 1992, with an initial version released in 1995 and a stable beta version in 2000.
Syntax
• Assignment
The generally preferred assignment operator is an arrow made from two characters
<-, although = can usually be used instead.• Vectors
> x <- 1:6 # Create vector.• Functions
> y <- x^2 # Create vector by formula.
> print(y) # Print the vector’s contents.
[1] 1 4 9 16 25 36
f <- function(x, y) {
z <- 3 * x + 4 * y
return(z)
}
SemanticsThe scalar data type was never a data structure of R; instead, a scalar is represented as a vector with length one. Data structures include vectors, matrices, arrays, data frames (similar to tables in a relational database) and lists.
Features:
• supports matrix arithmetic
• supports regression analysis, time-series analysis, spatial analysis
• has generic functions (which act differently depending on the classes of arguments passed to them i.e. dispatch the function/method specific to that class of object; e.g.
print)• arrays are stored in column-major order
RStudio
The most commonly used graphical integrated development environment for R is RStudio. It is written in Java, C++ (the Qt framework for its GUI) and JavaScript. Work on RStudio started around December 2010, and the first public beta version was officially announced in February 2011. Version 1.0 was released on 1 November 2016.
www.rstudio.com
#Nile
Object orientation
Types have qualifications
Every Object has one parent and any number of children
Types are Objects (?), and "inherit" (mixin style) qualifications from their parent
Object orientation
Types have qualifications
Every Object has one parent and any number of children
Types are Objects (?), and "inherit" (mixin style) qualifications from their parent
#Python
Iterables versus iterators
An iterable is something with an
An iterator is the result of calling
All iterators can only be iterated over once, not just those produced by generator functions.
Generators
When you call a function that contains a
Iterables versus iterators
An iterable is something with an
__iter__ method;An iterator is the result of calling
iter() on an iterable.All iterators can only be iterated over once, not just those produced by generator functions.
Generators
When you call a function that contains a
yield statement, you get a generator object, but no code runs. Then each time you extract an object from the generator, Python executes code in the function until it comes to a yield statement, then pauses and delivers the object. When you extract another object, your code will continue from where it left off i.e. it resumes just after the yield and continues until it reaches another yield (often the same one, but one iteration later). This continues until the function runs off the end, at which point the generator is deemed exhausted.#Python
The
The
filter function takes an iterable and an predicate, i.e. a function that returns a boolean, and removes items that don't match that predicate i.e. return False.#mathematics
Prime number theorem
Prime number theorem
pi(n) is the number of prime numbers smaller than or equal to n.pi(n) ~ n/log(n)