ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
XML
data
<emptyTag/>
<tag> data </tag>
<tag attribute="value"> data </tag>

Lisp
(data)
(emptyTag)
(tag data)
(tag ((attribute value)) data)

JSON
"data"
{}
{"tag": "data"}
{"tag": [{"attribute": "value"}, "data"]}

NON
"data"
{}
{tag = "data"}
{tag = {{attribute = "value"}, "data"}}

#XML #Lisp #JSON #Nile
list = '(', ( list | [+-]?['0'-'9']+ | ['A'-'Z''a'-'z'].* )*, ')'
#Lisp, #eBNF
Symbolic programming
- is a paradigm that describes programs able to manipulate formulas and program components as data. Programs can thus effectively modify themselves, and appear to "learn", making them suited for applications such as artificial intelligence, expert systems, natural-language processing and computer games. Languages that support this paradigm include #Lisp and #Prolog.
The diamond problem
- is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C?

For example, in the context of GUI software development, a class Button may inherit from both classes Rectangle (for appearance) and Clickable (for functionality/input handling), and classes Rectangle and Clickable both inherit from the Object class. Now if the equals method is called for a Button object and there is no such method in the Button class but there is an overridden equals method in Rectangle or Clickable (or both), which method should be eventually called?

How different languages deal with it:
• Common #Lisp: by order "...in the order in which parent classes are named in the subclass definition"
• Curl: "and the secondary constructor will be invoked for all other subclasses."
• Eiffel: "Eiffel will automatically join features together, if they have the same name and implementation."
• Go: compile-time error
#Java: compile-time error
#OCaml: by order "...are inherited in the same order, with each newly inherited method overriding any existing methods."
#Perl: by order "...from as an ordered list. The compiler uses the first method it finds..."
#Python: by order
#Ruby: by order "...as rightmost depth first resolution."
#Scala: by order "allows multiple instantiation of traits, which allows for multiple inheritance by adding a distinction between the class hierarchy and the trait hierarchy. A class can only inherit from a single class, but can mix-in as many traits as desired." This approach is the most similar to #Nile's; traits being qualifications.
• Tcl: by order "the order of specification in the class declaration affects the name resolution for members..."

Languages that allow only single inheritance, where a class can only derive from one base class, do not have the diamond problem.

Moreover, languages such as #Ada, Objective-C, #CSharp, #Delphi/Free #Pascal, Java, #Swift and PHP allow multiple-inheritance of interfaces (called protocols in Objective-C and Swift). Interfaces are like abstract base classes that specify method signatures without implementing any behavior.

When several interfaces declare the same method signature, as soon as that method is implemented (defined) anywhere in the inheritance chain, it overrides any implementation of that method in the chain above it (in its superclasses). Hence, at any given level in the inheritance chain, there can be at most one implementation of any method. Thus, single-inheritance method implementation does not exhibit the Diamond Problem even with multiple-inheritance of interfaces.
Blocks
- are lexical structures that allow many statements to be treated as one. A language that allows blocks and nested blocks, is called block-structured. Blocks are fundamental to #structured programming.

As scopes
Depending on the language, certain distinguished blocks may be treated as lexical scopes; otherwise, identifiers assigned in outer blocks are visible inside inner blocks, unless shadowed.

Syntax
• Free-form
Whitespace only delimits tokens and has no other significance
begin ... end: #ALGOL, #Pascal
{ ... }: #C, #Perl, #JS, #Nile
( keyword ... ): #Lisp

• Off-side rule
Indentation groups blocks of code
e.g. #Python, #Haskell, #Cobra, #CoffeeScript

Limitations
In some languages blocks do not fully support all declarations; for instance many C-derived languages do not permit nested functions.
#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 <-, although = can usually be used instead.

• Vectors
> x <- 1:6  # Create vector.
> y <- x^2 # Create vector by formula.
> print(y) # Print the vector’s contents.
[1] 1 4 9 16 25 36

• Functions
f <- function(x, y) {
z <- 3 * x + 4 * y
return(z)
}

Semantics
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. 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