Which loop do you find the most useful?
Anonymous Poll
21%
while condition
17%
classic for, ranged for
13%
for each element in collection
21%
apply (Haskell's fmap, Python's map)
8%
while true, loop forever
8%
do until condition
12%
repeat n
First write the desired call, then implement its function.
First design the front-end, then develop the backend.
That way you already know what you're making will satisfy your needs.
First design the front-end, then develop the backend.
That way you already know what you're making will satisfy your needs.
The quadchotomy of SQL: DDL, DML, DCL, TCL
Data Definition
•
•
•
•
•
•
*Objects include:
Data Manipulation
•
•
•
•
Data Control
•
•
Transaction Control
•
•
•
•
Data Definition
•
CREATE to create an object*•
DROP to destroy an object in the database•
ALTER to modify the structure of the database•
TRUNCATE to clear all records and free the space•
COMMENT to add comments to the data dictionary•
RENAME to rename an existing object*Objects include:
DATABASE, TABLE, INDEX, VIEW, FUNCTION, PROCEDURE, TRIGGER, etc.Data Manipulation
•
SELECT to query, i.e. retrieve data•
INSERT to insert a record into a table•
DELETE to delete records from a table•
UPDATE to update some cell(s) of a recordData Control
•
GRANT to give privileges to a user•
REVOKE to withdraw privileges from a userTransaction Control
•
COMMIT to commit a transaction•
ROLLBACK to roll it back, in case an error occurs•
SAVEPOINT to set a savepoint in a transaction•
SET to set its characteristicsAs implemented, the maximum NTFS file size is 16 TB (16 × 1024^4 bytes) minus 64 KB (64 × 1024 bytes) or 17,592,185,978,880 bytes.
The file-size limit on FAT32 is (2^32)-1 bytes, or one byte less than a full 4GB.
Disregard tabular mentality in favor of nested structures.
In other words: ODBMS > RDBMS
In other words: ODBMS > RDBMS
The === operator
#Ruby
(1..5) === 3 # => true
(1..5) === 6 # => false
Integer === 42 # => true
Integer === 'fourtytwo' # => false
/ell/ === 'Hello' # => true
/ell/ === 'Foobar' # => false
#Ruby
Equivalence
- is a binary relation that is reflexive, symmetric and transitive; i.e. for any objects a, b, and c:
- is a binary relation that is reflexive, symmetric and transitive; i.e. for any objects a, b, and c:
a = a, reflexiveif a = b then b = a, symmetricif a = b and b = c then a = c, transitiveHistory of Windows
Windows 1.0, 2.0, and 3.11 were built as a simple 16-bit GUI layer over DOS. Microsoft began to remove dependencies on DOS in Windows 95, Windows 98, and Windows ME; though DOS was still present.
The separation was finally completely implemented, fully 32-bit, in Windows NT and 2000. Windows NT 4.0, Windows 2000, Windows XP, Windows Vista, Windows 7, and Windows Server are all based on the NT kernel.
New Technology
The NT Kernel is a collection of code that has an API consisting of thousands of (mostly undocumented) GUI functions. It also can emulate some DOS functionality. Microsoft also introduced many API wrappers, such as the MFCs (Microsoft Foundation Classes), COM (Component Object Model), and .NET technologies.
The most popular languages for use on Windows include Visual Basic/VB6 and C/C++, although C++ is quickly being replaced by the .NET platform, specifically C#.
Windows Architecture
The first layer: NTOSKRNL.EXE and HAL.DLL
The second layer: NTDLL.DLL and WIN32K.SYS
The third layer: Win32 API
Contains development libraries i.e. almost all the functions that a user will ever need to program in Windows. It is divided into 4 DLLs:
In addition to the 4 primary libraries in the Win32 API, there are a number of other important libraries that a Windows programmer should become familiar with:
Contains the standard Berkeley socket API for communicating on the internet.
📚 Summary of: Windows Programming » Windows System Architecture
Windows 1.0, 2.0, and 3.11 were built as a simple 16-bit GUI layer over DOS. Microsoft began to remove dependencies on DOS in Windows 95, Windows 98, and Windows ME; though DOS was still present.
The separation was finally completely implemented, fully 32-bit, in Windows NT and 2000. Windows NT 4.0, Windows 2000, Windows XP, Windows Vista, Windows 7, and Windows Server are all based on the NT kernel.
New Technology
The NT Kernel is a collection of code that has an API consisting of thousands of (mostly undocumented) GUI functions. It also can emulate some DOS functionality. Microsoft also introduced many API wrappers, such as the MFCs (Microsoft Foundation Classes), COM (Component Object Model), and .NET technologies.
The most popular languages for use on Windows include Visual Basic/VB6 and C/C++, although C++ is quickly being replaced by the .NET platform, specifically C#.
Windows Architecture
The first layer: NTOSKRNL.EXE and HAL.DLL
NTOSKRNL.EXE provides some of the basic functionality of Windows but relies heavily on HAL.DLL. HAL stands for "Hardware Abstraction Layer", and is the portion of code that allows low-level mechanisms such as interrupts and BIOS communication to be handled independently.The second layer: NTDLL.DLL and WIN32K.SYS
NTDLL.DLL contains a number of user-mode functions such as system call stubs and the RTL (run-time library) code collectively known as the (largely undocumented) "Native API". Much of the RTL code is shared between NTOSKRNL and NTDLL. WIN32K.SYS is a kernel-mode driver that implements the windowed GUI.The third layer: Win32 API
Contains development libraries i.e. almost all the functions that a user will ever need to program in Windows. It is divided into 4 DLLs:
kernel32.DLLContains wrappers around lower-level NTDLL functions, NLS (National Language Support) and console handling
advapi32.DLLContains functions for registry and service handling.
gdi32.DLLContains functions for basic drawing, bitmap display and manipulation.
user32.DLLContains familiar Windows GUI implementations e.g. message boxes. It uses system calls implemented by
WIN32K.SYS.In addition to the 4 primary libraries in the Win32 API, there are a number of other important libraries that a Windows programmer should become familiar with:
MSVCRT.DLLContains implementations for C stdlib functions defined in common headers such as
stdio.h, string.h, stdlib.h, etc.WS2_32.DLL - The Winsock2 libraryContains the standard Berkeley socket API for communicating on the internet.
📚 Summary of: Windows Programming » Windows System Architecture
User Mode versus Kernel Mode
In Windows (and most OSs), there is a distinction between code that is running in user mode, and code that is running in kernel mode, because if all programs ran in kernel mode, they would be able to overwrite each others' memory and possibly bring down the entire system when they crashed.
This distinction has roots in lower levels; for example Intel CPUs have modes of operation called rings which specify the type of instructions and memory available to the running code:
• Ring 0 (kernel mode) full access to every resource, used by the Windows kernel
• Rings 1 and 2: customized levels of access, generally used by VMs
• Ring 3 (user mode) restricted access to resources
Virtual Memory
Each process has its own "virtual" memory space and resources. Its memory is "virtual" because the process thinks it has a large range of contiguous addresses; but in reality this is implemented by dividing RAM into chunks called pages (4 KB on x86 systems) and having its active pages scattered around RAM and inactive pages stored on disk. The CPU has a transparent mechanism for translating virtual addresses to physical addresses through a page table which the OS sets up. Virtual memory is useful because:
• A process cannot access the memory of other processes
• Each page can have different protection settings (read-only, read-write, kernel-mode-only, etc.)
• Inactive pages can be paged out to disk and retrieved when needed. This is also done when the system is low on RAM.
User Mode
In this mode, programs cannot modify pages directly and so have no way of affecting other processes except through their API. Programs in thismode also cannot interfere with interrupts and context switching.
Kernel Mode
When Windows is first loaded, the Windows kernel is started. It runs in kernel mode and sets up paging, virtual memory, interrupt handlers. Except System which runs in kernel mode, every other process runs in user mode. The kernel then creates some system processes in user mode, but switches back to kernel mode when it is interrupted by interrupts (events such as timers, keyboard, hard disk I/O). Whenever an interrupt occurs, the CPU stops executing the currently running program, switches to kernel mode, and executes the interrupt handler. The handler saves the state of the CPU, performs some processing relevant to that event, and restores the state of the CPU (possibly switching back to user mode) so the CPU can resume execution of the program.
Interrupts
When a program calls a Windows API function, that itself calls a different API: the Native API. Then it either triggers an interrupt or executes instructions such as
Context Switching
Programs may let the OS to switch to another program because they are waiting for something (human input, hard disk). These programs are known as unrunnable programs, and since they make calls to the kernel to wait for something, the kernel knows to perform context switching to allow another program to run. This is done by:
1. saving the state of the current program (including registers)
2. deciding which program to run next
3. restoring the state of that program
Preemption
It is setting a timed interrupt that will invoke context switching so that if a process (or thread) runs for more than a certain period of time (a process time slice or thread quantum), the OS will switch the context to another program. The time slice that is used may be different for each process.
📚 Summary of: Windows Programming » User Mode versus Kernel Mode
#Windows #Windows_Programming
In Windows (and most OSs), there is a distinction between code that is running in user mode, and code that is running in kernel mode, because if all programs ran in kernel mode, they would be able to overwrite each others' memory and possibly bring down the entire system when they crashed.
This distinction has roots in lower levels; for example Intel CPUs have modes of operation called rings which specify the type of instructions and memory available to the running code:
• Ring 0 (kernel mode) full access to every resource, used by the Windows kernel
• Rings 1 and 2: customized levels of access, generally used by VMs
• Ring 3 (user mode) restricted access to resources
Virtual Memory
Each process has its own "virtual" memory space and resources. Its memory is "virtual" because the process thinks it has a large range of contiguous addresses; but in reality this is implemented by dividing RAM into chunks called pages (4 KB on x86 systems) and having its active pages scattered around RAM and inactive pages stored on disk. The CPU has a transparent mechanism for translating virtual addresses to physical addresses through a page table which the OS sets up. Virtual memory is useful because:
• A process cannot access the memory of other processes
• Each page can have different protection settings (read-only, read-write, kernel-mode-only, etc.)
• Inactive pages can be paged out to disk and retrieved when needed. This is also done when the system is low on RAM.
User Mode
In this mode, programs cannot modify pages directly and so have no way of affecting other processes except through their API. Programs in thismode also cannot interfere with interrupts and context switching.
Kernel Mode
When Windows is first loaded, the Windows kernel is started. It runs in kernel mode and sets up paging, virtual memory, interrupt handlers. Except System which runs in kernel mode, every other process runs in user mode. The kernel then creates some system processes in user mode, but switches back to kernel mode when it is interrupted by interrupts (events such as timers, keyboard, hard disk I/O). Whenever an interrupt occurs, the CPU stops executing the currently running program, switches to kernel mode, and executes the interrupt handler. The handler saves the state of the CPU, performs some processing relevant to that event, and restores the state of the CPU (possibly switching back to user mode) so the CPU can resume execution of the program.
Interrupts
When a program calls a Windows API function, that itself calls a different API: the Native API. Then it either triggers an interrupt or executes instructions such as
sysenter and sysexit (x86). Both cause the CPU to switch to ring 0 (kernel mode) and begin executing the desired API function which is the interrupt handler set up by the OS. When the API function has finished processing, it switches back to user mode and resumes execution of the program. This is because API functions like ReadProcessMemory cannot work in user mode; the program can't access other programs' memory. In kernel mode, however, the API function can read any memory region without restriction.Context Switching
Programs may let the OS to switch to another program because they are waiting for something (human input, hard disk). These programs are known as unrunnable programs, and since they make calls to the kernel to wait for something, the kernel knows to perform context switching to allow another program to run. This is done by:
1. saving the state of the current program (including registers)
2. deciding which program to run next
3. restoring the state of that program
Preemption
It is setting a timed interrupt that will invoke context switching so that if a process (or thread) runs for more than a certain period of time (a process time slice or thread quantum), the OS will switch the context to another program. The time slice that is used may be different for each process.
📚 Summary of: Windows Programming » User Mode versus Kernel Mode
#Windows #Windows_Programming
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
#programming_paradigms
Stream processing
- is a programming paradigm that simplifies parallelism by restricting the parallel computation that can be performed: programs may use multiple computational units, such as the floating point unit on a GPU or FPGA, without explicitly managing allocation, synchronization, or communication among those units. Given a sequence or "stream" of data, a series of kernel functions is applied to each element in that stream.
Kernel functions are usually pipelined, and optimal local on-chip memory reuse is attempted, in order to minimize the loss in bandwidth, accredited to external memory interaction. Uniform streaming, where one kernel function is applied to all elements in the stream, is typical. Since the kernel and stream abstractions expose data dependencies, compiler tools can fully automate and optimize on-chip management tasks. Stream processing hardware can use scoreboarding, for example, to initiate a direct memory access (DMA) when dependencies become known. The elimination of manual DMA management reduces software complexity, and an associated elimination for hardware cached I/O, reduces the data area expanse that has to be involved with service by specialized computational units such as ALUs.
Stream processing was explored within dataflow programming, during the 80s. An example is the language #SISAL.
Compute kernel a.k.a. Kernel function
- is a function compiled for high throughput accelerators, separate from but used by programs running on CPU. They roughly correspond to inner loops when implementing algorithms in traditional languages (though non-sequential), or to code passed to internal iterators. They may be specified by a separate programming language such as #OpenCL_C, or embedded directly in application code written in a high level language, as in the case of C++AMP.
#Stream_processing
Stream processing
- is a programming paradigm that simplifies parallelism by restricting the parallel computation that can be performed: programs may use multiple computational units, such as the floating point unit on a GPU or FPGA, without explicitly managing allocation, synchronization, or communication among those units. Given a sequence or "stream" of data, a series of kernel functions is applied to each element in that stream.
Kernel functions are usually pipelined, and optimal local on-chip memory reuse is attempted, in order to minimize the loss in bandwidth, accredited to external memory interaction. Uniform streaming, where one kernel function is applied to all elements in the stream, is typical. Since the kernel and stream abstractions expose data dependencies, compiler tools can fully automate and optimize on-chip management tasks. Stream processing hardware can use scoreboarding, for example, to initiate a direct memory access (DMA) when dependencies become known. The elimination of manual DMA management reduces software complexity, and an associated elimination for hardware cached I/O, reduces the data area expanse that has to be involved with service by specialized computational units such as ALUs.
Stream processing was explored within dataflow programming, during the 80s. An example is the language #SISAL.
Compute kernel a.k.a. Kernel function
- is a function compiled for high throughput accelerators, separate from but used by programs running on CPU. They roughly correspond to inner loops when implementing algorithms in traditional languages (though non-sequential), or to code passed to internal iterators. They may be specified by a separate programming language such as #OpenCL_C, or embedded directly in application code written in a high level language, as in the case of C++AMP.
#Stream_processing
Though impossible for them to yield false positives, natural memories do yield false negatives.
There is no importing involved. You just use whichever class you want and you're good to go. Each class has a universally unique name. No more importing giant libraries with tons of unused definitions.