Zimbu now supports destructors. When an object is about to be garbage collected and it has a Finish() method, that method is invoked. It can free up resources and do anything needed. Destructors are also called on exit, thus they are much more useful than Java destructors. Details can be found in the language specification, Object Destruction section.
Combine this with the feature to put an object on the stack, and the destructor will be called when leaving the block where the variable was defined. Also when an exception is thrown while executing statements in the block. An ideal mechanism to grab a lock and make 100% sure it is released at the end of the block, as the new autoLock class will do:
PROC addFoo(Foo f)
autoLock %lock = NEW(myLock) # will grab myLock
myList.add(f) # This might crash
# autoLock.Finish() called, which releases myLock, no matter what
Recent incompatible changes:
Triple quoted strings are now marked with ''" until "''. This makes it much easier to see where it starts and ends.
bytes was renamed to byteString, varbytes to varByteString and varstring to varString.
ExamplesThe Hello World program: hello.zu
FUNC Main() int
An overview of special features of Zimbu on the highlights
The biggest existing Zimbu program is the Zimbu compiler itself. You can browse the code here
Install and run Zimbu
Download a snapshot or clone the Mercurial repository from code.google.com/p/zimbu
For instructions see the Getting Started page.
Discuss ZimbuThe maillist is here: http://groups.google.com/group/zimbu-discuss
- The language is somewhere between a "proof of concept" and version 1.0.
- The compiler can compile itself and most programs. The examples on this site run properly.
- Not all parts of the language have been implemented (e.g. float is missing) and there are a few bugs and hacks.
- This website has useful info but is still incomplete, much more to follow.
More information on the main work items
Suppose you want to write a new program, something like a text editor. What language would you write it in?
- It has to be as fast as possible, so interpreted languages are out.
- You don't want to micro manage memory, so C is out.
- You don't want to require programmers to have a degree, so C++ is out.
- You want fast startup and not depend on a big runtime, so Java is out.
- It has to run on most systems, anything with a C compiler, so D is out.
- You want to have fun making something new.
No existing language really meets these demands, so let's create a new one that does!
Zimbu is an experimental programming language. It is a very practical, no-nonsense kind of language. It mixes the good things of many existing languages and avoids their deficiencies. And then throws in a few brand new ideas.
GoalsMore on the Goals page.
- easy to read back - code is read N times more often than it is written
- avoid common mistakes - make it difficult to write bad code (but you can write hacks if you really want to)
- keep it short and clear, don't state the same thing twice - no header files, don't repeat type specs
- the effect of a statement should be predictable and not depend on something in another file
- efficient execution: no startup delay, reasonable memory use - no Just In Time compiler effects, minimize "stop the world" garbage collection.
- support a wide range of applications - Zimbu can be used to write an OS kernel, a short script and a big GUI application
- portable - be able to compile and run on almost any system
- many standard data types, modules and classes - most things you need are already there
ChoicesMain choices made so far (more on the design page):
- convert the program to C and use the C compiler to produce machine code (could be something else later)
- mostly use static type checking, also allow runtime type checking
- object oriented, all data is handled like an object, but there also are simple types
- an import defines one symbol, this avoids name conflicts in large projects
- the standard modules and classes are available without imports, avoids boring work
- many modules are part of the language, they work the same way everywhere
- all keywords are in capitals, you can use all other names without worrying about the next version breaking your program