Introduction to Zinc

This site is for people looking for information on zinc, the programming language of Code Browser.

Zinc is a programming language comparable to C with a syntax somewhat similar to Ruby.

Main Features

Low Level

Every operations are explicits, there is no implicit operations such as conversions or calls to destructors.

All data types manipulated can be handled in a machine register: integers, chars or pointers. It is not possible to pass structures in arguments or return them from functions, they must be passed by pointer.

On the other hand, the language provides higher abstractions than C: iterators, automatic type detections or inheritance of structures.

Identifiers Can Have Blanks

The most important feature and the most unusual.

If you consider that an identifier follows this regular expression [_A-Za-z][_A-Za-z0-9]*,then just consider that a zinc identifier can be a sequence of one or more identifiers separated by blanks. The grammar of zinc permit this.


open window with attributes (...)

More information here.


Iterators are a simplified version of the smalltalk blocks. In fact, it is more similar to ruby's. They allow to enumerates sequence's elements without knowing the implementation. It also reduces the code: an enumeration is done with one operation instead of three (initialization, test end of iteration, advance to next element).

An iterator can invoke a block using the yield statement. This is a simple example, it should remind ruby users of something.

equ loop (start: int, limit: int)
  def i = start
  def n = limit
  while i <= n
    yield (i)

def sum = 0
loop (1, 10) ? x
  sum += x
printf ("%d\n", sum)

Since zinc is a low level language, this feature is implemented with enhanced macro expansion.

Reduces the Need of Explicit Type Definition

The compiler requires to know the type of every expressions but when it can be guessed automatically, it is not necessary to specify it. This applies to:

This feature helps refactoring: changing the type of data requires less change in source code.