Cyclone Programming Language Article Index for
Cyclone
Website Links For
Cyclone
 

Information About

Cyclone Programming Language




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.


LANGUAGE FEATURES

Cyclone attempts to avoid some of the common pitfalls of the C Programming Language , while still maintaining the look and performance of C. To this end, Cyclone places the following restrictions upon programs:

In order to maintain the tool set that C programmers are used to, Cyclone provides the following extensions:
  • Never-NULL pointers do not require NULL checks

  • "Fat" pointers support pointer arithmetic with run-time Bounds Checking

  • Growable regions support a form of safe manual memory management

  • Garbage Collection for heap-allocated values

  • Tagged Union s support type-varying arguments

  • Injections help automate the use of tagged unions for programmers

  • Polymorphism replaces some uses of void ---

  • varargs are implemented as fat pointers

  • Exceptions replace some uses of setjmp and longjmp


For a better high-level introduction to Cyclone, the reasoning behind Cyclone and the source of these lists, please see {Link without Title} .

Although Cyclone looks, in general, much like C , it should be thought of as a C-like language.


Pointer/reference types

Cyclone implements three kinds of Reference (following C terminology these are called pointers):
  • --- (the normal type)

  • @ (the never-NULL pointer), and

  • ? (the only type with Pointer Arithmetic allowed, "fat" pointers).

  • 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 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:

int foo(int @);

  • to @ saves the programmer from having to write NULL checks and the operating system from having to trap NULL pointer dereferences. This extra restriction, 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 Overflow s 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:


  • s)

  • {

int iter = 0;
if (s == NULL) return 0;

Dangling pointers and region analysis