#C is not machine independent; but the thing is that everyone has to compile it for their own system, so no one notices it.
“The idea is that the configure script performs approximately 200 automated tests, so that the user is not burdened with configuring libtool manually. This is a horribly bad idea, already much criticized back in the 1980s when it appeared, as it allows source code to pretend to be portable behind the veneer of the configure script, rather than actually having the quality of portability to begin with. It is a travesty that the configure idea survived.”
— Poul-Henning Kamp, criticizing the GNU Build System
“The idea is that the configure script performs approximately 200 automated tests, so that the user is not burdened with configuring libtool manually. This is a horribly bad idea, already much criticized back in the 1980s when it appeared, as it allows source code to pretend to be portable behind the veneer of the configure script, rather than actually having the quality of portability to begin with. It is a travesty that the configure idea survived.”
— Poul-Henning Kamp, criticizing the GNU Build System
String
- is a composite, usually built-in, data type implemented as an array, or some other sequential data structure, of bytes.
Fixed-length versus variable-length strings
Although formal strings can have an arbitrary but finite length, the length of strings in real languages is often constrained to an artificial maximum. In general, there are two types of string datatypes: fixed-length strings, which have a fixed maximum length to be determined at compile time and which use the same amount of memory whether this maximum is needed or not, and variable-length strings, whose length is not arbitrarily fixed and which can use varying amounts of memory depending on the actual requirements at run time. Most strings in modern programming languages are variable-length strings.
Terminated versus length-field strings
The string length is either explicitly stored as a separate integer or implicitly through a termination character, usually the null character (NUL), which has all bits zero, a convention used and perpetuated by #C. In terminated strings, the terminating code is not an allowable character in any string; whereas strings with a length field do not have this limitation.
Length versus size
Representations of strings depend on character encoding. Older implementations use #ASCII, and modern implementations use Unicode. With certain encodings, a single logical character may take up more than one entry in the array. In these cases, the logical length of the string (number of characters) differs from the physical length of the array (number of bytes in use).
- is a composite, usually built-in, data type implemented as an array, or some other sequential data structure, of bytes.
Fixed-length versus variable-length strings
Although formal strings can have an arbitrary but finite length, the length of strings in real languages is often constrained to an artificial maximum. In general, there are two types of string datatypes: fixed-length strings, which have a fixed maximum length to be determined at compile time and which use the same amount of memory whether this maximum is needed or not, and variable-length strings, whose length is not arbitrarily fixed and which can use varying amounts of memory depending on the actual requirements at run time. Most strings in modern programming languages are variable-length strings.
Terminated versus length-field strings
The string length is either explicitly stored as a separate integer or implicitly through a termination character, usually the null character (NUL), which has all bits zero, a convention used and perpetuated by #C. In terminated strings, the terminating code is not an allowable character in any string; whereas strings with a length field do not have this limitation.
Length versus size
Representations of strings depend on character encoding. Older implementations use #ASCII, and modern implementations use Unicode. With certain encodings, a single logical character may take up more than one entry in the array. In these cases, the logical length of the string (number of characters) differs from the physical length of the array (number of bytes in use).
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
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
#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
OpenCL (Open Computing Language)
- is a parallelism framework for writing programs that execute across heterogeneous platforms consisting of one host CPU and any number of compute devices. These devices include GPUs, CPUs with SIMD instructions, FPGAs, Movidius Myriad 2, Adapteva epiphany and DSPs.
A compute device is broken down to several compute units, which themselves are broken down to multiple PEs (processing elements). A single function execution can run on any number of PEs in parallel. How a compute device is subdivided into compute units and PEs is up to the vendor.
It defines an API for programs running on the host to launch functions on compute devices and manage device memory. This API is defined for C and C++, as well as third-parties such as #Python, #Java, #Perl, #DotNET, etc. A more recent, higher-level model is SYCL; which is purely based on C++11. Programs in OpenCL are compiled at run-time therefore its applications are portable between various host devices.
A four-level memory hierarchy is defined for the compute device:
• global: shared by all PEs, high access latency
OpenCL C
- is the programming language used to write compute kernels. Though based on C99, it is adapted to fit the device model.
A memory buffer resides in a specific level and its pointer is annotated with a region qualifier:
• There is no
• There are no function pointers, bit fields or variable-length arrays
• Recursion is forbidden
• stdlib is replaced by a custom set of standard functions, geared toward math programming
• Scalar types such as
Features:
• Vector types available in fixed-lengths of 2, 3, 4, 8 and 16; and for various base types e.g.
• Operations for vector types
• Synchronization facilities
• Functions to work with work-items and work-groups
• More specialized types incl. 2D and 3D image types
#OpenCL #OpenCL_C
- is a parallelism framework for writing programs that execute across heterogeneous platforms consisting of one host CPU and any number of compute devices. These devices include GPUs, CPUs with SIMD instructions, FPGAs, Movidius Myriad 2, Adapteva epiphany and DSPs.
A compute device is broken down to several compute units, which themselves are broken down to multiple PEs (processing elements). A single function execution can run on any number of PEs in parallel. How a compute device is subdivided into compute units and PEs is up to the vendor.
It defines an API for programs running on the host to launch functions on compute devices and manage device memory. This API is defined for C and C++, as well as third-parties such as #Python, #Java, #Perl, #DotNET, etc. A more recent, higher-level model is SYCL; which is purely based on C++11. Programs in OpenCL are compiled at run-time therefore its applications are portable between various host devices.
A four-level memory hierarchy is defined for the compute device:
• global: shared by all PEs, high access latency
__global
• read-only: smaller, low latency, writable only by the host __constant
• local: shared by a group of PEs __local
• per-element private memory: device registers; __private
Not every device needs to implement each level of this hierarchy in hardware. Consistency between the various levels in the hierarchy is relaxed, and only enforced by explicit synchronization constructs, notably barriers. The host provides handles on device memory buffers and functions to transfer data back and forth.OpenCL C
- is the programming language used to write compute kernels. Though based on C99, it is adapted to fit the device model.
A memory buffer resides in a specific level and its pointer is annotated with a region qualifier:
__global, __local, __constant, and __private
Comparison with #C:• There is no
main; functions are marked __kernel to signal that they are entry points, and are to be called from programs running on the host• There are no function pointers, bit fields or variable-length arrays
• Recursion is forbidden
• stdlib is replaced by a custom set of standard functions, geared toward math programming
• Scalar types such as
float and double behave similarly to those of CFeatures:
• Vector types available in fixed-lengths of 2, 3, 4, 8 and 16; and for various base types e.g.
float4 (4-vector of single-precision floats)• Operations for vector types
• Synchronization facilities
• Functions to work with work-items and work-groups
• More specialized types incl. 2D and 3D image types
#OpenCL #OpenCL_C
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
"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
#C #Windows
“For those who care about such things: Many have asked whether Windows is written in C or C++. The answer is that – despite NT’s Object-Based design – like most OS’, Windows is almost entirely written in ‘C’. Why? C++ introduces a cost in terms of memory footprint, and code execution overhead. Even today, the hidden costs of code written in C++ can be surprising, but back in the late 1990’s, when memory cost ~$60/MB (yes … $60 per MEGABYTE!), the hidden memory cost of vtables etc. was significant. In addition, the cost of virtual-method call indirection and object-dereferencing could result in very significant performance & scale penalties for C++ code at that time. While one still needs to be careful, the performance overhead of modern C++ on modern computers is much less of a concern, and is often an acceptable trade-off considering its security, readability, and maintainability benefits … which is why we’re steadily upgrading the Console’s code to modern C++.”
— Inside the Windows Console
“For those who care about such things: Many have asked whether Windows is written in C or C++. The answer is that – despite NT’s Object-Based design – like most OS’, Windows is almost entirely written in ‘C’. Why? C++ introduces a cost in terms of memory footprint, and code execution overhead. Even today, the hidden costs of code written in C++ can be surprising, but back in the late 1990’s, when memory cost ~$60/MB (yes … $60 per MEGABYTE!), the hidden memory cost of vtables etc. was significant. In addition, the cost of virtual-method call indirection and object-dereferencing could result in very significant performance & scale penalties for C++ code at that time. While one still needs to be careful, the performance overhead of modern C++ on modern computers is much less of a concern, and is often an acceptable trade-off considering its security, readability, and maintainability benefits … which is why we’re steadily upgrading the Console’s code to modern C++.”
— Inside the Windows Console
#Windows
The Windows API
- is Microsoft's core set of APIs available in the Windows OS, designed for interactions between apps and the OS.
Though its exposed functions and data structures are described in #C, any compiler or assembler able to handle the low-level data structures and the prescribed calling conventions for calls and callbacks may use it.
The functions provided by the Windows API can be grouped into eight categories:
1. Services
Base Services:
• file systems
• devices
• processes and threads
• error handling
—
Advanced Services:
• the Windows registry
• shutdown/restart the system
• start/stop/create a Windows service
• manage user accounts
—
2. Graphics Device Interface
• to output graphics to monitors, printers, etc.
— user-mode:
— kernel-mode:
3. GUI
• to create and manage screen windows
• receive mouse and keyboard input
—
Common Dialog Box Library:
• to open and save files
• choose color
• choose font
• ...
—
Common Control Library:
• buttons
• scrollbars
• status bars
• progress bars
• toolbars
• tabs
• ...
—
4. Windows Shell
• access and manipulate functions provided by the shell —
• The Shell Lightweight Utility Functions —
5. Network Services
• NetBIOS
• Winsock
• NetDDE
• remote procedure call (RPC)
• ...
—
6. Web
Internet Explorer also exposes an API. IE has been included with the OS since Windows 95 OSR2 and has provided web-related services to apps since Windows 98.
• An embeddable web browser control
• ...
—
7. Multimedia
MCI:
• play sound files
• send/receive MIDI messages
• access joysticks
—
Media encoding and playback:
• DirectShow: builds and runs generic multimedia pipelines, used to render in-game videos and build media players, Windows Media Player was based on it, no longer recommended for game development
• Media Foundation: a newer digital media API intended to replace DirectShow
8. DirectX
• Direct2D: hardware-accelerated 2D vector graphics
• Direct3D: hardware-accelerated 3D graphics
• DirectSound: low-level hardware-accelerated sound card access
• DirectInput: communication with input devices such as joysticks and gamepads
• DirectPlay: a multiplayer gaming infrastructure, deprecated
• DirectDraw: for 2D graphics, deprecated and replaced with Direct2D
• WinG: 16-bit 2D graphics, deprecated
The Windows API
- is Microsoft's core set of APIs available in the Windows OS, designed for interactions between apps and the OS.
Though its exposed functions and data structures are described in #C, any compiler or assembler able to handle the low-level data structures and the prescribed calling conventions for calls and callbacks may use it.
The functions provided by the Windows API can be grouped into eight categories:
1. Services
Base Services:
• file systems
• devices
• processes and threads
• error handling
—
kernel32.dll, KernelBase.dllAdvanced Services:
• the Windows registry
• shutdown/restart the system
• start/stop/create a Windows service
• manage user accounts
—
advapi32.dll, advapires32.dll2. Graphics Device Interface
• to output graphics to monitors, printers, etc.
— user-mode:
gdi32.dll— kernel-mode:
win32k.sys (communicates directly with the graphics driver)3. GUI
• to create and manage screen windows
• receive mouse and keyboard input
—
user32.dllCommon Dialog Box Library:
• to open and save files
• choose color
• choose font
• ...
—
comdlg32.dllCommon Control Library:
• buttons
• scrollbars
• status bars
• progress bars
• toolbars
• tabs
• ...
—
comctl32.dll4. Windows Shell
• access and manipulate functions provided by the shell —
shell32.dll• The Shell Lightweight Utility Functions —
shlwapi.dll5. Network Services
• NetBIOS
• Winsock
• NetDDE
• remote procedure call (RPC)
• ...
—
netapi32.dll6. Web
Internet Explorer also exposes an API. IE has been included with the OS since Windows 95 OSR2 and has provided web-related services to apps since Windows 98.
• An embeddable web browser control
• ...
—
shdocvw.dll, mshtml.dll7. Multimedia
MCI:
• play sound files
• send/receive MIDI messages
• access joysticks
—
winmm.dllMedia encoding and playback:
• DirectShow: builds and runs generic multimedia pipelines, used to render in-game videos and build media players, Windows Media Player was based on it, no longer recommended for game development
• Media Foundation: a newer digital media API intended to replace DirectShow
8. DirectX
• Direct2D: hardware-accelerated 2D vector graphics
• Direct3D: hardware-accelerated 3D graphics
• DirectSound: low-level hardware-accelerated sound card access
• DirectInput: communication with input devices such as joysticks and gamepads
• DirectPlay: a multiplayer gaming infrastructure, deprecated
• DirectDraw: for 2D graphics, deprecated and replaced with Direct2D
• WinG: 16-bit 2D graphics, deprecated
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.
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.