HOME

TheInfoList



OR:

Chicken (stylized as CHICKEN) is a
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming l ...
, specifically a
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
and interpreter which implement a
dialect The term dialect (from Latin , , from the Ancient Greek word , 'discourse', from , 'through' and , 'I speak') can refer to either of two distinctly different types of linguistic phenomena: One usage refers to a variety of a language that ...
of the programming language Scheme, and which compiles Scheme
source code In computing, source code, or simply code, is any collection of code, with or without comment (computer programming), comments, written using a human-readable programming language, usually as plain text. The source code of a Computer program, p ...
to standard C. It is mostly R5RS compliant and offers many extensions to the standard. The newer R7RS standard is supported through an extension
library A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
. Chicken is
free and open-source software Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
available under a
BSD license BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. The original BSD li ...
. It is implemented mostly in Scheme, with some parts in C for performance or to make embedding into C programs easier.


Focus

Chicken's focus is quickly clear from its slogan: "''A practical and portable Scheme system''". Chicken's main focus is the practical application of Scheme for writing real-world software. Scheme is well known for its use in
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
curricula and programming language experimentation, but it has seen little use in business and industry. Chicken's community has produced a large set of
libraries A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
to perform a variety of tasks. The Chicken wiki (the software running it is also a Chicken program) also contains a list of software that has been written in Chicken. Chicken's other goal is to be portable. By compiling to an
intermediate representation An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good ...
, in this case portable C (as do Gambit and Bigloo), programs written in Chicken can be compiled for common popular
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s such as
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
,
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, other
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
systems,
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
,
Haiku is a type of short form poetry originally from Japan. Traditional Japanese haiku consist of three phrases that contain a ''kireji'', or "cutting word", 17 ''On (Japanese prosody), on'' (phonetic units similar to syllables) in a 5, 7, 5 pattern, ...
, and mobile platforms iOS and
Android Android may refer to: Science and technology * Android (robot), a humanoid robot or synthetic organism designed to imitate a human * Android (operating system), Google's mobile operating system ** Bugdroid, a Google mascot sometimes referred to ...
. It also has built-in support for cross-compiling programs and extensions, which allows it to be used on various
embedded system An embedded system is a computer system—a combination of a computer processor, computer memory, and input/output peripheral devices—that has a dedicated function within a larger mechanical or electronic system. It is ''embedded'' ...
platforms.


Design

Like many Scheme compilers, Chicken uses standard C as an
intermediate representation An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive to further processing, such as optimization and translation. A "good ...
. A Scheme program is translated into C by the Chicken compiler, and then a C compiler translates the C program into machine code for the target
computer architecture In computer engineering, computer architecture is a description of the structure of a computer system made from component parts. It can sometimes be a high-level description that ignores details of the implementation. At a more detailed level, the ...
, producing an executable program. The universal availability of C makes it useful for this purpose. Chicken's design was inspired by a 1994 paper by Henry Baker that outlined an innovative strategy to compile Scheme into C. A Scheme program is compiled into C functions. These C functions never reach the ''return'' statement; instead, they call a new
continuation In computer science, a continuation is an abstract representation of the control state of a computer program. A continuation implements ( reifies) the program control state, i.e. the continuation is a data structure that represents the computat ...
when complete. These continuations are C functions and are passed on as extra arguments to other C functions. They are calculated by the compiler. So far, this is the essence of
continuation-passing style In functional programming, continuation-passing style (CPS) is a style of programming in which control is passed explicitly in the form of a continuation. This is contrasted with direct style, which is the usual style of programming. Gerald Jay Su ...
. Baker's novel idea is to use the C
call stack In computer science, a call stack is a stack data structure that stores information about the active subroutines of a computer program. This kind of stack is also known as an execution stack, program stack, control stack, run-time stack, or mach ...
for the Scheme heap. Hence, normal C stack operations such as automatic variable creation, variable-sized array allocation, and so on can be used. When the stack fills up (that is, the stack pointer reaches the top of the stack), a garbage collection can be initiated. The design used is a copying garbage collector originally devised by C. J. Cheney, which copies all live continuations and other live objects to the heap. Despite this, the C code does not copy C stack frames, only Scheme objects, so it does not require knowledge of the C implementation. In full, the Scheme heap consists of the C stack as the ''nursery'' together with the two heaps required by the generational garbage collector. This approach gives the speed of the C stack for many operations, and it allows the use of continuations as simple calls to C functions. Further, Baker's solution guarantees
asymptotic In analytic geometry, an asymptote () of a curve is a line such that the distance between the curve and the line approaches zero as one or both of the ''x'' or ''y'' coordinates tends to infinity. In projective geometry and related contexts, ...
tail recursive behavior, as required by the Scheme language standard. The implementation in the Chicken Scheme compiler is even asymptotically ''safe for space''.


Limitations and deviations from the standard

Chicken Scheme is mostly R5RS-compliant, with a few notable limitations and deviations. R7RS compatibility is supplied as an extension library. The core system has basic support for
UTF-8 UTF-8 is a variable-length character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode'' (or ''Universal Coded Character Set'') ''Transformation Format 8-bit''. UTF-8 is capable of ...
characters, however the string indexing and manipulation procedures are not UTF-8 aware. An extension library exists which adds support for full UTF-8 awareness.


Add-on software

Chicken has a large
software repository A software repository, or repo for short, is a storage location for software packages. Often a table of contents is also stored, along with metadata. A software repository is typically managed by source control or repository managers. Package ...
of added libraries and programs, termed ''eggs''. This system is very similar to
RubyGems RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gem ...
. Initially, these eggs were developed in one central svn repository, in which creating a tag would automatically cause a new version of the extension to become available for download. Currently, eggs can be developed anywhere and under any
version control system In software engineering, version control (also known as revision control, source control, or source code management) is a class of systems responsible for managing changes to computer programs, documents, large web sites, or other collections o ...
, while still maintaining ''semi-automatic'' release management when using most of the popular code hosting sites. This release method is VCS-agnostic in the sense that the user does not need to have these VCSes installed. The developer is free to host anywhere they choose, and can even choose to avoid public version control and distribute only plain tarballs. For all released eggs, the latest version is tested automatically as part of a continuous integration process. A canonical test server exists, where the core system and all eggs are tested daily against the most recent development version (to catch regressive bugs), and the most recent stable version (to ensure that everything works for users of the stable system). Also, anyone can volunteer to supply further testing capacity, on different: hardware, operating systems, or core releases.


Features

Chicken supports most of R5RS standard Scheme, but it also adds a few nonstandard features which are not available in all Scheme implementations.


Foreign function interface

Chicken compiling to C makes it possible to ''inject'' custom C code into the compiled result, which eases integrating with C libraries. Its foreign function interface supports converting back and forth between most built-in C types and corresponding Scheme objects. Also, extension libraries exist for interfacing to Python,
Lua Lua or LUA may refer to: Science and technology * Lua (programming language) * Latvia University of Agriculture * Last universal ancestor, in evolution Ethnicity and language * Lua people, of Laos * Lawa people, of Thailand sometimes referred t ...
, and
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
, via
Java Native Interface In software design, the Java Native Interface (JNI) is a foreign function interface programming framework that enables Java code running in a Java virtual machine (JVM) to call and be called by native applications (programs specific to a hardwa ...
(JNI) or a bridge.


Cross-compiling

It is relatively easy to cross-compile Scheme code to another platform (for example for embedded use on a device). To make cross-compiling possible for Scheme code, Chicken imposes a model of separate compiling: A compiled module consists of two
shared libraries In computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and su ...
. One library contains the actual code which will be used at runtime (compiled for the target platform), and the other is an ''import module'', which will be used to load the code which runs at compile-time (on the host platform), such as procedural macro code. The Chicken compiler can also be easily cross-compiled. After translation to C has been achieved, one can simply use a C compiler which is set up to build for another platform.


Modules and macros

Since version 4, Chicken has a built-in module system and support for low-level hygienic macros through ''explicit renaming'' macros (before version 4, this was available through an add-on library). Standard ''syntax-rules'' macros are also supported, and ''implicit renaming'' macros, which is basically a ''reversed'' version of explicit renaming. This mechanism trades performance for convenience. Each identifier not explicitly ''injected'' as unhygienic will be automatically renamed to avoid name capture. The performance cost occurs because ''implicit'' renaming requires the macro-expander to retraverse the expressions two more times. This cost is paid at expansion time, so a macro author must consider if longer compiling times are acceptable.


Remote debugger

Since version 4.11, Chicken comes shipped with a debugger named ''Feathers''. When Scheme code is compiled with the needed debugging option, ''debugging events'' are injected at specific points in the code. These are implemented as calls to a C function, which is relatively low-overhead when not actually debugging the code. When debugging, it will try to make a TCP connection to a Feathers server process, possibly on a different machine. The process is halted, the user may set breakpoints and start the program. Then, when the breakpoint is hit, the client (process being debugged) enters a command loop, which allows interrogation of the client, to read out variables, or mutate them.


Limited static type analysis

Chicken supports local flow analysis. This allows the compiler to catch variable type errors at compile-time, and perform type specialisation. This specialisation makes it possible to remove several safety checks for type detection at runtime when the type can be deduced at compile-time. This results in improved run-time performance. This ''scrutinizer'' does not allow cross-module flow analysis, so it can only be used to optimize code that's part of one compiling unit (or module).


See also

*
Tail recursion In computer science, a tail call is a subroutine call performed as the final action of a procedure. If the target of a tail is the same subroutine, the subroutine is said to be tail recursive, which is a special case of direct recursion. Tail recur ...
* Cheney's algorithm * "
M.T.A. (song) "M.T.A.", often called "The MTA Song", is a 1949 song by Jacqueline Steiner and Bess Lomax Hawes. Known informally as "Charlie on the MTA", the song's lyrics tell an absurd tale of a man named Charlie trapped on Boston's subway system, which was th ...
", a song reference in Baker's 1994 paper * Gambit (Scheme implementation) *
Stalin (Scheme implementation) In computing, Stalin (STAtic Language ImplementatioN) is a programming language, an aggressive Optimizing compiler, optimizing batch Interprocedural optimization, whole-program Scheme (programming language), Scheme compiler written by Jeffrey Mar ...


References


External links

* * {{DEFAULTSORT:Chicken Scheme (programming language) compilers Scheme (programming language) interpreters Scheme (programming language) implementations Free compilers and interpreters Software using the BSD license