FACTOID # 176: Nauru is the world's smallest independent republic.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > K (programming language)
K
Paradigm: array,functional
Appeared in: 1993
Designed by: Arthur Whitney
Developer: Kx Systems
Typing discipline: dynamic,strong
Influenced by: A+, APL, Scheme

K is a proprietary array processing language developed by Arthur Whitney and commercialized by Kx Systems. The language serves as the foundation for KDB, an in memory, column based database, and other related financial products. The language, originally developed in 1993, is a variant of APL and contains elements of Scheme. Advocates of the language emphasize its speed, facility for handling arrays and its expressive syntax. A programming paradigm is a paradigmatic style of programming (compare with a methodology, which is a paradigmatic style of doing software engineering). ... Array programming languages (also known as vector or multidimensional languages) generalize operations on scalars to apply transparently to vectors, matrices, and higher dimensional arrays. ... Functional programming is a programming paradigm that conceives computation as the evaluation of mathematical functions and avoids state and mutable data. ... 1993 (MCMXCIII) was a common year starting on Friday of the Gregorian calendar and marked the Beginning of the International Decade to Combat Racism and Racial Discrimination (1993-2003). ... Arthur Whitney is a computer scientist most notable for developing the K programming language. ... A software developer is a person who is concerned with one or more facets of the software development process, a somewhat broader scope of computer programming or a specialty of project managing. ... In computer science, a type system defines how a programming language classifies values and expressions into types, how it can manipulate those types and how they interact. ... It has been suggested that Hunt and peck typing be merged into this article or section. ... In computing, strongly-typed, when applied to a programming language, is used to describe how the language handles datatypes. ... A+ is a powerful and efficient array programming language written at Morgan Stanley. ... APL (for A Programming Language) is an array programming language based on a notation invented in 1957 by Kenneth E. Iverson while at Harvard University. ... The Scheme programming language is a functional programming language and a dialect of Lisp. ... Arthur Whitney is a computer scientist most notable for developing the K programming language. ... In computing , a database can be defined as a structured collection of records or data that is stored in a computer so that a program can consult it to answer queries. ... APL (for A Programming Language) is an array programming language based on a notation invented in 1957 by Kenneth E. Iverson while at Harvard University. ... The Scheme programming language is a functional programming language and a dialect of Lisp. ...

Contents

History

Before developing K, Arthur Whitney had worked extensively with APL, first at I. P. Sharp Associates alongside Ken Iverson and Roger Hui, and later at Morgan Stanley developing financial applications. At Morgan Stanley, Whitney developed A+, a variant of APL, to facilitate the migration of APL applications from IBM mainframes to a network of Sun workstations. A+ had a smaller set of primitive functions and was designed for speed and to handle large sets of time series data. I. P. Sharp Associates, IPSA for short, was a major Canadian computer time sharing, consulting and services firm of the 1970s and 80s. ... Kenneth E. Iverson (17 December 1920, Camrose, Alberta/Canada –October 19, 2004,Toronto, Ontario/Canada) was a computer scientist most notable for developing the APL programming language. ... Roger Hui was co-developer of the J Programming Language. ...


In 1993, Arthur Whitney left Morgan Stanley and developed the first version of the K language. At the same time he formed Kx Systems to commercialize the product and signed an exclusive contract with Union Bank of Switzerland (UBS). For the next four years he developed various financial and trading applications using the k language for UBS. Union Bank of Switzerland was located in Switzerland. ...


The contract ended in 1997 when UBS merged with Swiss Bank. In 1998 Kx Systems came out with KDB, a database built on K. Since then a number of financial products have been developed with K and KDB. KDB/tick and KDB/taq were developed in 2001. KDB+ a 64 bit version of KDB was brought out in 2003 and KDB+/tick and KDB+/taq were brought out the following year. Swiss Bank Corporation (German: Schweizerischer Bankverein (SBV), French: Société de Banque Suisse (SBS), Italian:Società di Banca Svizzera) The history of the Swiss Bank Corporation (SBC) dates to 1854 and the consitution of Bankverein by which six Private Banking-houses: Bischoff zu St Alban, Ehinger & Cie. ...


Overview

K shares key features with APL. They are both interpreted, interactive languages noted for concise and expressive syntax. They have simple rules of precedence based on right to left evaluation. The languages contains a rich set of primitive functions designed for processing arrays. These primitive functions include mathematical operations that work on arrays as whole data objects, and array operations, such as sorting or reversing the order of an array. In addition, the language contains special operators that combine with primitive functions to perform types of iteration and recursion. As a result, complex and extended transformations of a dataset can be expressed as a chain of sub-expressions with each link performing a segment of the calculation and passing the results to the next link in the chain.


Like APL, the primitive functions and operators are represented by single or double characters; however unlike APL, K restricts itself to the ASCII character set, (a feature it shares with J, another variant of APL). To allow for this, the set of primitive functions for K is smaller and heavily overloaded, with each of the ASCII symbols representing two or more distinct functions or operations. In a given expression the actual function referenced is determined by the context. As a result K expressions can be opaque and difficult to parse. For example in the following contrived expression the exclamation point “!” refers to three distinct functions:

 2!!7!4 

Reading from right to left the first ! is modulo division that is performed on 7 and 4 resulting in 3. The next ! is enumeration and lists the integers less than 3, resulting in the list 0 1 2. The final ! is rotation where the list on the right is rotated two times to the left producing the final result of 2 0 1.


The second core distinction of K is that functions are first-class objects, a concept borrowed from Scheme. First-class functions can be used in the same contexts where a data value can be used. Functions can be specified as anonymous expressions and used directly with other expressions. Function expressions are specified in K using curly brackets. For example in the following expression a quadratic expression is defined as a function and applied to the values 0 1 2 and 3:

 {(3*x^2)+(2*x)+1}'!4 

In K named functions are simply function expressions stored to a variable, in the same way any data value is stored to a variable.

 x:25 f:{(x^2)-1} 

In addition functions can be passed as an argument to another function or returned as a result from a function.


Examples

K is an interpreter, evaluating each expression entered and returning the results. As a result the hello world program is trivial:

 "Hello World!" 

The following expression sorts a list of strings by their lengths:

 x@>#:'x 

The expression is evaluated from right to left as follows:

  1. #:'x returns the length of each word in the list x.
  2. > returns the indices that would sort a list of values in descending order.
  3. @ use the integer values on the left to index into the original list of strings.

A function to determine if a number is prime can be written as:

 {&/x!/:2_!x} 

The function is evaluated from right to left:

  1.  !x enumerate the positive integers less than x.
  2. 2_ drops the first two elements of the enumeration (0 and 1).
  3. x!/: performs modulo division between the original integer and each value in the truncated list.
  4. &/ find the minimum value of the list of modulo result.

If x is not prime then one of the values returned by the modulo operation will be 0 and consequently the minimal value of the list. If x is prime then the minimal value will be 1 because x mod 2 is 1 for any prime greater than 2.


The above function can be used to list all of the prime numbers between 1 and R with:

 (!R)@&{&/x!/:2_!x}'!R 

The expression is evaluated from right to left

  1.  !R enumerate the integers less than R.
  2. ' apply each value of the enumeration to the prime number function on the left. This will return a list of 0's and 1's.
  3. & return the indices of the list where the value is 1.
  4. @ use the integer values listed on the right to index into the list on the left.
  5. (!R) A list of integers less than R.

Performance characteristics

The performance of modern CPUs is improving at a much faster rate than their memory subsystems. The small size of the interpreter and compact syntax of the language makes it possible for K applications to fit entirely within the level 1 cache of the processor. Vector processing makes efficient use of the cache row fetching mechanism and posted writes without introducing bubbles into the pipeline by creating a dependency between consecutive instructions. These characteristics, combined with a highly optimized implementation, tend to make interpreted K programs significantly faster than hand-coded C/C++.[citation needed]


GUI

The GUI library included in K is based on that of A+, but it takes advantage of many features unique to K. K's GUI is declarative and data-driven, as opposed to most GUIs which are imperative. A window and the things in a window are contained in a normal data structure, usually a dictionary on the K Tree, and displayed with the $ operator (which doubles as a formatting operator and a casting operator, too). Information about a widget is kept in the variable's attributes. Every data type in K can function as a widget--just not necessarily very well. “PUI” redirects here. ... A widget (or control) is an interface component that a computer user interacts with, such as a window or a text box. ...


But in K, the GUI library is so terse and easy to use that even for prototyping, developers often use a GUI interface rather than a command line. A minimal, not very pretty GUI hello world in K is

 `show$"Hello world" 

The latest version of the K programming language, known as "K4", no longer has a built-in GUI library.


K financial products

K is the foundation for a family of financial products. Kdb is an in memory, column based database with much of the same functionality of a relational database management system. The database supports SQL (sql92) and ksql, a query language with a syntax similar to SQL and designed for column based queries and array analysis. A relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by Edgar F. Codd. ... Structured Query Language (SQL) is the most popular computer language used to create, retrieve, update and delete data from relational database management systems. ...


kdb is available for Solaris, Linux, and Windows (32-bit or 64-bit). Solaris is a computer operating system developed by Sun Microsystems. ... Linux (IPA pronunciation: ) is a Unix-like computer operating system family. ... Microsoft Windows is the name of several families of proprietary software operating systems by Microsoft. ...


See also

  • APL, the first array language
  • J, another APL-inspired language

APL (for A Programming Language) is an array programming language based on a notation invented in 1957 by Kenneth E. Iverson while at Harvard University. ... The J programming language, developed in the early 90s by Ken Iverson and Roger Hui, is a synthesis of APL (also by Iverson) and the FP and FL functional programming languages created by John Backus (of FORTRAN, ALGOL, and BNF fame). ...

References

External links


  Results from FactBites:
 
Programming Language - MSN Encarta (580 words)
Programming Language, in computer science, artificial language used to write a sequence of instructions (a computer program) that can be run by a computer.
For instance, programming languages such as Fortran and COBOL were written to solve certain general types of programming problems—Fortran for scientific applications, and COBOL for business applications.
Assembly languages are intermediate languages that are very close to machine language and do not have the level of linguistic sophistication exhibited by other high-level languages, but must still be translated into machine language.
C programming language (2572 words)
C is a programming language, designed by Dennis Ritchie during the early 1970s, for writing the UNIX operating system.
C is a high level language, meaning that the source code of a program can be written without detailed knowledge of the computer's CPU type.
By 1973, the C language had became powerful enough that most of the kernel of the Unix operating system was reimplemented in C. This was the first time that the kernel of an operating system had been implemented in a high level language.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.