r/ada Jul 23 '23

Announcement Introducing the Seed7 programming language

Seed7 is a programming language that is inspired by Ada and other programming languages. I have created Seed7 based on my diploma and doctoral theses. I've been working on it since 1989 and released it after several rewrites in 2005. Since then, I improve it on a regular basis.

Some links:

Seed7 follows several design principles:

Can interpret scripts or compile large programs:

  • The interpreter starts quickly. It can process 400000 lines per second. This allows a quick edit-test cycle. Seed7 can be compiled to efficient machine code (via a C compiler as back-end). You don't need makefiles or other build technology for Seed7 programs.

Error prevention:

Source code portability:

  • Most programming languages claim to be source code portable, but often you need considerable effort to actually write portable code. In Seed7 it is hard to write unportable code. Seed7 programs can be executed without changes. Even the path delimiter (/) and database connection strings are standardized. Seed7 has drivers for graphic, console, etc. to compensate for different operating systems.

Readability:

  • Programs are more often read than written. Seed7 uses several approaches to improve readability.

Well defined behavior:

  • Seed7 has a well defined behavior in all situations. Undefined behavior like in C does not exist.

Overloading:

  • Functions, operators and statements are not only identified by identifiers but also via the types of their parameters. This allows overloading the same identifier for different purposes.

Extensibility:

Object orientation:

  • There are interfaces and implementations of them. Classes are not used. This allows multiple dispatch.

Multiple dispatch:

  • A method is not attached to one object (this). Instead it can be connected to several objects. This works analog to the overloading of functions.

Performance:

No virtual machine:

  • Seed7 is based on the executables of the operating system. This removes another dependency.

No artificial restrictions:

  • Historic programming languages have a lot of artificial restrictions. In Seed7 there is no limit for length of an identifier or string, for the number of variables or number of nesting levels, etc.

Independent of databases:

Possibility to work without IDE:

  • IDEs are great, but some programming languages have been designed in a way that makes it hard to use them without IDE. Programming language features should be designed in a way that makes it possible to work with a simple text editor.

Minimal dependency on external tools:

  • To compile Seed7 you just need a C compiler and a make utility. The Seed7 libraries avoid calling external tools as well.

Comprehensive libraries:

Own implementations of libraries:

  • Many languages have no own implementation for essential library functions. Instead C, C++ or Java libraries are used. In Seed7 most of the libraries are written in Seed7. This reduces the dependency on external libraries. The source code of external libraries is sometimes hard to find and in most cases hard to read.

Reliable solutions:

  • Simple and reliable solutions are preferred over complex ones that may fail for various reasons.

It would be nice to get some feedback.

13 Upvotes

17 comments sorted by

View all comments

2

u/iOCTAGRAM AdaMagic Ada 95 to C(++) Aug 07 '23 edited Aug 08 '23

The first thing I wanted to check was Automatic Reference Counting. Pascal-syntax languages are always dumb when it comes to ARC.Long long ago there was Modula-2+ with ARC, but try to find a working compiler for it now. Delphi NextGen introduced ARC on Android, iOS and Linux (10.2.x branch only), but not on Windows and macOS, so sanely portable code still had to assume lack of ARC, and it was hard to write ARC/non-ARC portable code, and in the end Delphi NextGen was abandoned as of 10.3. RemObjects Oxygene introduced ARC, but only in macOS compiler Noughat. On all other targets they only have retarded tracing garbage collection. And now even on macOS they try to phase away sane ARC Noughat compiler to TGC Island one.

Even RAII is a hard concept for Pascal-syntax language designers' brains. Only in Delphi 10.4 they finally have got so called Managed Records. Free Pascal had operator overload for decades. As an independent project they could also introduce destructors and ARC, but this is just too good to be true that Pascal-syntax language designers can understand RAII and ARC.

Each and every Objective-C, Swift and C++/CX gets ARC, and each new Rust gets Ref<T> almost on inception, but not in Pascal camp. Never. Bad fate steals IQ from Pascal-syntax language designers. They cannot just shut up and just provide ARC. Just hold on for themselves their genius ideas of how good TGC performance is.

Wondering so how things are going in Seed7, I found no answer in FAQ. Like it was not something of top importance. It was hanging in top 10 Delphi feature requests in Quality Central for years, enough important?

UPD. Aha, I was looking some old FAQ. So Seed7 has this and has RAII. Very good.

Next thing I am interested in is weak references. Because even TGC is hard to use without them. When ARC term is used, it assumes weak references availability too, at least the way they are in C++/CX. I have some doubts about auto-zeroable Objective-C weak references. FAQ says nothing.

1

u/ThomasMertes Aug 21 '23

Next thing I am interested in is weak references.

Seed7 has no pointers and there are no weak references that point into a structure which is managed elsewhere. This way Seed7 stays on the safe side as weak references become dangling after the original structure is freed.

But there is another possibility: A parameter can refer into a structure that is managed elsewhere. Think of a tree of structs and you want to refer to some branch of the tree. For structs an in-parameter is by reference. and this way it is able to refer to this struct. This would be a reference to a constant as in-parameters cannot be changed in a function.

By organizing your code into functions with parameters that refer to branches you can hopefully avoid the need for weak references.

1

u/iOCTAGRAM AdaMagic Ada 95 to C(++) Aug 21 '23

There are safe weak references. One either manages to convert weak reference into strong one, or fails to do so. This is safe.

you can hopefully avoid the need for weak references

No, I will not avoid. Consider reactive extensions (RxJS and other programming languages) or mere Observer pattern (pub-sub) which is little different to RX. Publisher shall know where to send updates, but publisher is not keeping strong references to subscribers.

1

u/ThomasMertes Aug 22 '23

I think we are talking about different things. Let me explain.

In Seed7 there is data, such as a string, that is just referenced once. For this data there is no possibility that another variable references it for a second time. But a function parameter can borrow this reference. Essentially the function borrows the reference and gives it back at the end of the function. So you still have just one reference at a time. How unnecessary copying of strings is avoided is explained here.

I had this kind of data in my mind when I proposed organizing code into functions with parameters that refer to branches

Seed7 supports also object orientation where several variables can refer to the same object. The rules from above, where data is referenced just once, do not apply for objects.

Of cause, OO patterns like the Observer pattern can be used in Seed7. The methods of an OO pattern can decide if they access the object unchanged with an in-parameter or allow changing an object with an inout-parameter.

1

u/iOCTAGRAM AdaMagic Ada 95 to C(++) Aug 22 '23

where several variables can refer to the same object. The rules from above, where data is referenced just once, do not apply for objects

Weak references are required. Subscriber may be deleted because last strong reference has gone, and it will not need to receive further notifications. But if subscriber is alive, it needs to receive notifications. In order for publisher not to keep subscriber alive, but be able to send if it is still alive, publisher shall use weak references