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

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
#Programming_paradigms : Declarative versus Imperative

#Declarative
All about relations.

Does not state the order in which operations execute.

Focuses on what the program should accomplish without specifying how the program should achieve the result.
Expresses the logic of a computation without describing its control flow.

Common declarative languages include those of database query languages (e.g. #SQL, #XQuery), regular expressions (#Regex), logic programming, functional programming, and configuration management systems.

e.g. #Haskell, #Kanren (a dialect of #Scheme), #Prolog, #Wolfram_Language

#Imperative
Uses statements that change a program's state.
1. they state the order in which operations occur, with constructs that explicitly control that order

Allows side effects, in which state can be modified within one unit of code, and then read inside a different unit of code.

Imperative programming focuses on describing how a program operates.
an imperative program consists of commands for the computer to perform.
Many imperative programming languages (such as #Fortran, #BASIC, and #C) are abstractions of assembly language.
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
#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
SISAL
"Streams and Iteration in a Single Assignment Language" is a general-purpose single assignment functional programming language with strict semantics, implicit parallelism, and efficient array handling. It was derived from VAL (Value-oriented Algorithmic Language by Jack Dennis), and adds recursion and finite streams.

By: James McGraw
First appeared: 1983
First compiled implementation: 1986
Paradigms: #functional, #dataflow
Syntax: #Pascal -like
Performance: superior to #C and rivals #Fortran

SISAL is more than just a dataflow and fine-grain language; it is a set of tools that convert a textual human readable dataflow language into a graph format (named IF1 - Intermediary Form 1). Part of the SISAL project also involved converting this graph format into runable C code.

In 2010 SISAL saw a brief resurgence when a group of undergraduates at Worcester Polytechnic Institute investigated implementing a fine-grain parallelism backend for the SISAL language.

In 2018 SISAL got modernized with ident-based syntax, first-class functions, lambdas, closures and lazy semantics within project SISAL-IS.

#SISAL
Birth of C

Mid-1960s: Bell Labs, MIT and General Electric were jointly developing an experimental time-sharing OS called Multics which was written in #PL_I and assembly language.

Late-1960s: Though Multics featured many innovations, it also presented severe problems, which frustrated researchers at Bell Labs until they gradually withdrew from the project.

1969: A team led by Ken Thompson and Dennis Ritchie, who were among the last to leave, decided to re-implement their experiences in a new, smaller project. They implemented a hierarchical file system, the concept of processes and device files, a command-line interpreter, and some small utility programs, modeled on the corresponding features in Multics, but simplified. The resulting system was much smaller and simpler than Multics.

August 1969: “Ken Thompson's wife took their son on a trip to California. As a temporary bachelor, Ken had time to work. [He told me] 'I allocated a week each to the operating system, the shell, the editor and the assembler … during the month she was gone, it was totally rewritten in a form that looked like an operating system'” – Peter Salus

Thompson needed a language to make utilities for Unix. At first, he tried #Fortran, but soon gave up and made a new language: #B, a simplified #BCPL.

1970: Multics was short for Multiplexed Information and Computer Services. Because the new unnamed OS was a single-tasking one, Brian Kernighan coined Uniplexed Information and Computing Service which spelled Unics, and was later spelled "Unix".

1972: Ritchie started to improve B, which was too slow and could not take full advantage of specific hardware, and ended up creating a new language, #C, which was then used to make utilities running on Unix.

1973: The Unix kernel, which was originally written in assembly language, was then re-implemented in C. By this time, C had acquired powerful features, such as struct types.

1977: Ritchie and Stephen C. Johnson made further changes to the language to facilitate portability of Unix. Johnson's Portable C Compiler served as the basis for several implementations of C on new platforms.