<- ^ ->

General, conceptual, differences

2   General, conceptual, differences

2.1   Safety

Gont is safe. This means that compiler shouldn't produce any code, execution of which would cause SEGV. Parse: it should not be possible to overflow buffers, mismatch types of arguments in calls and so on. However note, that SEGV can be obtained from playing with extern_c declaration, compiler has no means of validating.

2.2   Level of abstraction

Gont is much higher level. It generally operates at much higher level of abstraction.

<evangelisation>

[...] And, actually, the more you can avoid programming in C the more productive you will be.

C is very efficient, and very sparing of your machine's resources. Unfortunately, C gets that efficiency by requiring you to do a lot of low-level management of resources (like memory) by hand. All that low-level code is complex and bug-prone, and will soak up huge amounts of your time on debugging. With today's machines as powerful as they are, this is usually a bad tradeoff -- it's smarter to use a language that uses the machine's time less efficiently, but your time much more efficiently. Thus, Python.

Eric S. Raymond
This is quotation from hacker howto by ESR :-). One may easily note that it does not only talk about Python (personally I don't like dynamic typing nor using interpreted language as a general purpose, --mal).

C is, in principle, assembly language, therefore it is almost as fast as real assembly, but it is still easy to write and quite portable. It is great for programming things like kernels, libraries that need high speed operation (like MPEG decoding/encoding), generally most of things that need to be real time. However it is very easy to cut your finger with such a sharp knife. Typesystem provided by C isn't very powerful, most of people familiar with functional programming, would say that typesystem of C is no more then a toy. Similarly C doesn't provide much support for memory management, exceptions, functional and objective programming. Of course, lack of restriction from language, about how you organize your memory management, objects, and error recovery, can be advantage, especially with respect to operating system programming and so on. However in most cases, writing xmalloc() 100th time, is annoying. I think that's the main reason why Java is so popular -- it takes burden of thinking at the very low level away from the programmer, and also it is much harder to make a mistake (at the cost of more keyboards wasted on writing public virtual final void foo() and so on, and performance regression).

</evangelisation>

2.3   Memory Management

Gont provides transparent memory management, along with garbage collection (the particular kind of garbage collector used is Boehm conservative garbage collector, used also by GCJ and Popcorn). It generally means you can allocate as much as you want, forget the pointers, and the Gont runtime system with get rid of unused memory.

2.4   C compatibility

Gont is not compatible with C (this is difference more against C++ then C). It is simply impossible to maintain such compatibility in safe language. What a braindamage might result, one may easy tell from the C++ example.

2.5   Differences against ML

How is Gont different from Caml or SML? (Caml and SML are functional languages, with imperative features from ML family) Hm... generally all languages are interchangeable, what can be written in one, can be written in all other. However in real life it is rather important how easy can you get the code to work, how much bugs will compiler detect (vs bugs left for the programmer) and how fast will it run. Gont places accents on these things somewhere between Caml and C. Generally it does not provide as much support for functional programming as Caml does, similar can be told about Gont's module system (which is a toy, compared to functors and other ML machinery) and restricted polimorphism. On the other hand, linking Gont code with C is very easy, the only thing you need to remember, is not to put pointers from Gont, in malloc()'ed area -- save it on stack, or in GC_malloc()'ed area. Interfacing OCaml is... ghm... nightmare, mainly because of its precise garbage collector. Also Gont code will probably run faster, as it uses highly optimizing back end (gcc), and because of restrictions put on the language itself (this is probably not true yet).

2.6   Differences against Popcorn

How is Gont different from Popcorn? (Popcorn is safe C subset, compiler is available to TALx86 (Typed Assembly Language)). Popcorn was inspiration for Gont :) However, it is somewhat limited (especially to x86) and not currently under development (AFAIK).

2.7   Differences against Cyclone

Cyclone (http://www.cs.cornell.edu/projects/cyclone/) is language similar to Gont in the same sense as C++ is similar to Java. It's a dialect of C designed to be safe: free of crashes, buffer overflows, format string attacks, and so on. Cyclone has more powerful typesystem -- it includes regions, that allow not to use garbage collection all the time. It also has pointers in C's sense. OTOH Gont is not dialect of C. It does not try to be backward compatible. This results in much smaller language, probably easier to understand at first.

<- ^ ->

General, conceptual, differences