The Hyper Programming Language

Introduction

Hyper is an object-oriented programming language, kind of like C++ or Java. Like C++, programs written in Hyper are compiled to machine code. And like Java, Hyper tries to be a platform independent programming language, but not in the same way.

History

Somewhere in the beginning of the year 2003, I started thinking about creating my own programming language. At that time, I had programming experience in BBC BASIC, Visual Basic, VB.NET, Oberon 2 and a bit of C++. I started thinking about what I did not like in the languages I was familiar with. For about a year, it remained just a couple of ideas. Then, I became a bit disappointed about the ideas I had, that they just remained ideas but nothing more. So I started some reading on the web about compilers and how they are created. Soon after that, I started to write one. I thought I could already implement what I had figured out to be in the language. The rest of the features would be thought out and implemented later.

So I started working on it. After the initial parser for namespaces, classes and procedures was more or less ready, I got a bit stuck. I first needed to figure out what type system I was going to use. Initially I wanted to use reference types for classes as in VB.NET and Java. But this would mean that user-defined value-types were impossible to define. I knew the type system that C++ uses; it has value types and uses pointers. But I didn't like that either, because I did not like the referencing and dereferencing you have to do all the time. My solution to this was a type system somewhere in between (see this page for more info). At that point I could continue the implementation of the compiler. Many other necessary things were also added.

Today

The base for the language is now figured out, and the compiler supports most of it (see compiler status). You can download the compiler from this website. My focus is now on having the compiler do more complete checks on the language features it currently supports, on documenting the language on this website (see website status) and on the creation of a back end for the compiler (see full compiler).

Characteristics

A brief explanation of some important characteristics:

Syntax

Hyper's syntax is somewhat like Pascal and BASIC. For most syntactical things reserved keywords are used. And for the end of block constructs, the end keyword is used. Statements are not terminated by semicolons. The principle is to have one statement per line, so a termination character is not needed. There is also a way for long statements to be split over multiple lines. Leading whitespace (indentation) and trailing whitespace are ignored. Whitespace in between is not significant. Identifiers and reserved keywords are case-sensitive. Reserved keywords are written in lowercase. Two styles of comments are supported: single-line comments and nestable multiline comments.

Types

A simple rule for types: they are written and interpreted from left to right. For a pointer type for example, this would be an asterisk followed by the type it points to.

Pointers are declared explicitly, but are used implicitly most of the time. They are not referenced or dereferenced, because the compiler does this automatically. To manipulate pointers there are pointer-specific operators: pointer assignment/equality (depends on the context) and pointer inequality.

All built-in primitive types are class types. Every class implicitly inherits from the primitive type ‘object’, unless another base class is specified.

Arrays are not just simply a pointer to their first element. They behave like a class and carry their size with them. This allows for open arrays to be used anywhere, not only as procedure parameters. Arrays cannot be resized. True multidimensional arrays are supported; they are classes that have multiple dimensions, and their index operator uses multiple arguments.

Files

The language does not use separate header files. A system of namespaces is used, it is similar to the package system from Java. Source files are expected to be in UTF-8 encoding.

Libraries

I like the idea of a large standard library as it exists in Java. My objective here is that you will be able to program as in write once, compile everywhere (i.e. your code can be cross-compiled to any platform without having to port it). The standard library will support commonly used things like containers and threads. It will also provide platform-independent abstraction mechanisms. And I hope that the library will also be able to provide a platform-independent GUI framework.

Example

The popular hello world program.

See also


Valid HTML 4.01 Strict Valid CSS!