Designed by | AT&T Labs |
---|---|
First appeared | 2006 |
Last release |
1.0 / May 8, 2006
|
Website | cyclone |
Influenced by | |
C | |
Influenced | |
Rust |
The Cyclone programming language is intended to be a safe dialect of the C language. Cyclone is designed to avoid buffer overflows and other vulnerabilities that are endemic in C programs, without losing the power and convenience of C as a tool for system programming.
Cyclone development was started as a joint project of AT&T Labs Research and Greg Morrisett's group at Cornell in 2001. Version 1.0 was released on May 8, 2006.
Cyclone attempts to avoid some of the common pitfalls of C, while still maintaining its look and performance. To this end, Cyclone places the following limits on programs:
To maintain the tool set that C programmers are used to, Cyclone provides the following extensions:
For a better high-level introduction to Cyclone, the reasoning behind Cyclone and the source of these lists, see this paper.
Cyclone looks, in general, much like C, but it should be viewed as a C-like language.
Cyclone implements three kinds of pointer:
The purpose of introducing these new pointer types is to avoid common problems when using pointers. Take for instance a function, called foo
that takes a pointer to an int:
Although the person who wrote the function foo
could have inserted NULL
checks, let us assume that for performance reasons they did not. Calling foo(NULL);
will result in undefined behavior (typically, although not necessarily, a SIGSEGV signal being sent to the application). To avoid such problems, Cyclone introduces the @
pointer type, which can never be NULL
. Thus, the "safe" version of foo
would be:
This tells the Cyclone compiler that the argument to foo
should never be NULL
, avoiding the aforementioned undefined behavior. The simple change of *
to @
saves the programmer from having to write NULL
checks and the operating system from having to trap NULL
pointer dereferences. This extra limit, however, can be a rather large stumbling block for most C programmers, who are used to being able to manipulate their pointers directly with arithmetic. Although this is desirable, it can lead to buffer overflows and other "off-by-one"-style mistakes. To avoid this, the ?
pointer type is delimited by a known bound, the size of the array. Although this adds overhead due to the extra information stored about the pointer, it improves safety and security. Take for instance a simple (and naïve) strlen
function, written in C: