Seed7: a programming language I've been working on for decades
Posted by ThomasMertes@reddit | programming | View on Reddit | 167 comments
Seed7 is based on ideas from my diploma and doctoral theses about an extensible programming language (1984 and 1986). In 1989 development began on an interpreter and in 2005 the project was released as open source. Since then it is improved on a regular basis.
Seed7 is about readability, portability, performance and memory safety. There is an automatic memory management, but there is no garbage collection process, that interrupts normal processing.
The Seed7 homepage contains the language documentation. The source code is at GitHub. Questions that are not in the FAQ can be asked at r/seed7.
Some programs written in Seed7 are:
- make7: a make utility.
- bas7: a BASIC interpreter.
- pv7: a Picture Viewer for BMP, GIF, ICO, JPEG, PBM, PGM, PNG, PPM and TIFF files.
- tar7: a tar archiving utility.
- ftp7: an FTP Internet file transfer program.
- comanche: a simple web server for static HTML pages and CGI programs.
Screenshots of Seed7 programs can be found here and there is a demo page with Seed7 programs, which can be executed in the browser. These programs have been compiled to JavaScript / WebAssembly.
I recently released a new version that adds support for JSON serialization / deserialization and introduces a seed7-mode for Emacs.
Please let me know what you think, and consider starring the project on GitHub, thanks!
jared__@reddit
You really should put a hello world on the README.md at the beginning
New-Reply640@reddit
You should really code your own project.
WalksOnLego@reddit
''' $ include "seed7_05.s7i";
const proc: main is func begin writeln("hello world"); end func; '''
Atulin@reddit
Oof, not just
begin
-end
kind of blocks, but alsoend func
. Must be a treat to people who love verbosityThomasMertes@reddit (OP)
I think readability improves, if you can see what each "end" keyword is actually terminating; i.e.
func
,for
,while
,if
,case
, etc.ndech@reddit
I think that’s a job for the editor, no need to make the syntax more verbose.
ThomasMertes@reddit (OP)
The IDE could as well help with inserting these things when the code is written.
I don't want that code from the internet or from a book needs to be copied to an IDE to get better readability.
Natural languages also work without IDE that improves readability.
fat_apollo@reddit
It's not just that, it (as it seems from examples) carries some unfortunate traits from Pascal, namely:
all local variables must be declared at the start of the function, not where they're first used
there's no early return from the function, so any function with non-trivial workflow will have cascade of numerous end xxx; at the end.
ThomasMertes@reddit (OP)
This way you have just one place to look for local variable declarations. You don't need to scan the code from the usage of a variable up to the beginning of the function.
In case of error you could use an exception. You can assume that today's compilers (a C compiler is used as back-end for Seed7) will optimize such that the performance is the same (as if you used an early return).
fat_apollo@reddit
Yeah, K&R C did that too, if I remember correctly, but that practice was abandoned, and all good programming guides from '90 onward (Code Complete first comes to mind) suggest that local variables should be declared close to the place they're first used, for better readability and maintaining the local mental context.
I should be able to return from the function at any place and signal to the reader that is it, instead of using endless if-then-else and forcing the reader to parse longer functions to the bottom, hunting for additional code that may be executed. Modern linters warn you if you're using unnecessary else blocks, and for a good reason.
Exceptions should be used for exceptional things, not for control flow; that's a matter of readability, not performance.
syklemil@reddit
I'm also kind of reminded of Js's move from
var
tolet
.Going with only function scope for variables in 2025 will be pretty jarring to people who are used to block scope. Function scope was probably pretty neat at the time where languages that only had global scope were common, but these days those languages are only spoken of around campfires to scare kids.
Combined with the initialization requirement I get the impression users will be forced to initialize some variables with bad values that should never be used, only because they don't have all the information required for the correct initialization yet.
My expectation these days is that variables are block scoped, and that initialization status is tracked, so that an attempted use of an uninitialized variable either won't compile or throws a runtime exception. (There are plenty of languages that don't do that, but I don't consider them good languages. They seem to generally grow a "strict mode" over time to mitigate that shortcoming.)
ThomasMertes@reddit (OP)
I think readability improves, if you can see what each "end" keyword is actually terminating; i.e.
func
,for
,while
,if
,case
, etc.ThomasMertes@reddit (OP)
I think readability improves, if you can see what each "end" keyword is actually terminating; i.e.
func
,for
,while
,if
,case
, etc.SkyMarshal@reddit
What's the "7" about? Why not "5" or "13" etc?
IllegalMigrant@reddit
He addressed the name in a presentation video on YouTube. The seed part is from "planting a seed" that can then grow from the efforts of others. If I recall correctly "7" was just added because it sounded good. It has no meaning.
NarWil@reddit
Pretty cool, man! To begin with a concept and see it through to a completely usable programming language is something many developers simply haven't done. I can't help but think the syntax is going to turn off engineers who are accustomed to C-like syntax. I find it very readable, if a bit verbose (though I acknowledge there's a clear trade-off there in some decisions you made).
Can you give a specific reason or two why someone might choose to learn Seed7 and write a project in it over a more popular language like Java or Go?
ThomasMertes@reddit (OP)
Seed7 addresses some things that are not addressed by most other languages.
Ok-Scheme-913@reddit
Graal doesn't struggle with reflection, it works perfectly well. It just has to know the potential targets at compile time. It can figure out targets by itself that you reach via code, but you have to register classes/fields that you plan to reach dynamically, say via user input.
ThomasMertes@reddit (OP)
I attended to several speeches from the GRAAL team and I know some of the people working on GRAAL in person.
With "struggle" I did NOT mean that GRAAL cannot work with code that uses reflection.
This is what I meant when I used the word "struggle". If Java had no reflection (or a restricted form of it) ahead of time compilation would be much simpler.
Ok-Scheme-913@reddit
Fair enough, I thought that this is what you meant.
I'm just trying to remove the stigma around it, as some people believe it is way worse than it actually is.
ggwpexday@reddit
How is Seed7's focus on maintainability? For example some of the ones I would consider important:
ThomasMertes@reddit (OP)
Seed7 constants cannot change during run-time. If a the type of a constant is a struct or array none of its elements can change. A java object variable might be
final
but the elements of the object can still be changed. In Seed7 this is not the case. If an interface variable is constant the elements in the object cannot be changed. Constant means constants and this extends to all sub-elements.The in-parameter is most commonly used parameter of Seed7. An in-parameter cannot be changed inside a function. I would say that in-parameters are not mutable (although the term mutability is nowhere used in the Seed7 documentation). So instead of declaring an immutable in the middle of the code like
you would define a function with the immutable parameter like
and then you would call a function with the initialization value of the mutable as parameter
This approach uses more lines of code but it is IMHO much cleaner.
Seed7 does not attempt to be a combination of other languages (you mentioned fsharp, ocaml, rust and Haskell). There have been just too many languages which follow this route and I don't think that this is the way towards better programming languages.
ggwpexday@reddit
I see, that's nice. Does it also then also support syntax to create a copy with some changed values?
What do you mean by this? There is a reason these languages (and existing ones) drift towards these features. We want to optimize for reading code, which in part means to take away the hidden inputs & outputs that a function secretly depends on. Mutability and side effects play a big role in this, as both create hidden coupling between functions.
This language therfore seems like it is more low level and focused on performance instead, which is fine as well. Huge achievement nonetheless, great work.
ThomasMertes@reddit (OP)
You do an assignment (which except for object orientation is always a deep copy) and change some element value afterwards:
Long existing languages like C++ adapted concepts from many languages. Over time this has lead to very complex languages.
I think that languages should introduce their own concepts (and maybe introduce something new) instead of following the programming language fashion of the day.
Regarding hidden inputs & outputs and mutability: Circa 99% of the function parameters used in Seed7 are in-parameters which are not mutable.
In consider Seed7 definitely as higher level than Rust, C/C++, Go, Zig and many other languages. Seed7 is a memory-safe language which contrasts to all systems programming languages except Rust. The ability to introduce new statements syntactically and semantically is IMHO also a high-level feature (that almost no other language can provide).
Thank you.
ggwpexday@reddit
This means
a
is mutable again though, right?Some features are pretty fundamental, especially the immutability and discriminated union ones. But yeah C++ is like the most extreme case of feature bloat.
Is it correct that this language doesn't support discriminated unions then?
This is awesome and I hope to get my head around understanding what this does exactly. I read some of the documentation and find it hard to imagine in what situations this is most useful? DSLs?
True, and my view might be in the minority on what is considered "high level". But to me, any lang that doesn't attempt to limit mutation and side effects provide no real readability/understandability improvement over the status quo in the long run.
ThomasMertes@reddit (OP)
The assignment requires that its left-hand-side is a variable. In my example I used the type
rational
A
struct
value is referenced by just onestruct
variable. This is not about object orientation. So variables likea
andb
do not refer to the samestruct
value.In this example
b
is an in-parameter (=not mutable) anda
is a variable (=mutable).So it is not about being mutable again. It's about copying from the not mutable
b
to the mutablea
. This program writeswhich means that the original
numerator
has not changed.You probably have object orientation in mind (where two variables can refer to the same object).
This program writes
so in this case
a
is mutable again.ggwpexday@reddit
Yeah it's about making immutable values easy to use, in this case have
a
immutable as well. So in c# for example you needed to copy over all the values by hand. But with the newwith
syntax, it acutally makes using immutable values practical:Also one thing im curious about since its in the code snippet, is there any compile time safety around null? The
a
var has type file, but what happens if thea := b
assignment isn't done? Does it throw a null exception?ThomasMertes@reddit (OP)
Essentially "clone everything except for certain fields". This sounds weird and I have the suspicion that it is a performance optimization. I would not support it.
Copying some struct and changing a field afterwards feels IMHO cleaner. And the compiler might find out that some field is copied twice and optimize the first copying away.
There is no NULL in Seed7. Interface variables always reference an existing object. STD_NULL is a null file (the name is a reference to
/dev/null
). Anything written toSTD_NULL
is ignored. Reading fromSTD_NULL
does not deliver data.STD_NULL is returned if open() is not able to open a file and it is used as initialization value for file variables as well.
ggwpexday@reddit
Lots of languages support it, I find it curious that you are so against it.
This forces the use of mutability which we try to avoid
Doesnt this imply all types need to define their own dedicated null value? The whole reason NULL is a problem is that it is a magic value that inhabits every type, which from the looks of it, is the same here. If you can use an STD_NULL value without the compiler complaining about enforcing an explicit
if val == STD_NULL
, then this is no better than something like java, right?So there is no way to indicate absence of a value? All types have a dedicated magic
ThomasMertes@reddit (OP)
Obviously we view things differently and therefore we talk past each other. So let me explain how the Seed7 view is.
In Java there are Primitive Data Types like
int
and object types like Integer. The Seed7 typeinteger
is a Primitive Data Type likeint
in Java. You can declarea
andb
in Seed7 as:The variable
a
and the constantb
are totally different entities without any relationship in between them. There can be an assignment:Now
a
has the value5
, but there is still no relationship betweena
andb
. The assignment just copied the value ofb
toa
. Thatb
is a constant and its value is copied to the variablea
is not a problem.In Java the Primitive Data Type logic is only used for the most simple types. In Java
string
is aclass
and it does not follow the Primitive Data Type logic (like any otherclass
in Java).In Seed7 the Primitive Data Type logic is also used for string, array, struct and all other types with the exception of interface.
That some of these types store big amounts of data in the heap is hidden from the user. The implementation maintains a 1:1 relationship between variable/constant and data in the heap. It never happens that variable
a
refers to the data ofb
.ggwpexday@reddit
That may be true, I take it you don't have experience with functional programming?
That's the thing, treating data as just data. It's about the content, not the identity. "Primitive Data Type logic" sounds just like value semantics in c#. Or what typescript is doing with its structural typing. TS even goes to great lengths to enable this structural type of coding.
Maybe thats what it does in the implementation, I'm not sure. But this rant from uncle bob sums up my view pretty clearly https://x.com/unclebobmartin/status/1924784682312294822.
No offense but seeing someone achieving such great things without being familiar with the theory is surprising.
ThomasMertes@reddit (OP)
I used Java Streams a lot. I just don`t see functional programming as solution for everything. I think that variables and assignments have advantages as well. I consider functional programming and object orientation both as important concepts. But I don't think that they should be followed 100%.
I used this concept in the predecessor of Seed7 in the nineties but I did not name it. I just looked up how Java categorized
int
and found the name "Primitive Data Type".Thank you for the uncle bob link. It is a good and short description of functional programming. I am not a fan of uncle bob. Some of his positions contradict my point of view (static type system, etc.).
I have some knowledge about the theory but here is always room to improve. Seed7 uses its own theories and it existed before functional programming became a fad. :-)
I think it's necessary to think out of the box to create real progress.
ggwpexday@reddit
That's barely scratching the surface.
True, if it was, it would have been more prevalent than it is now. But the basics of it do tend to seep into the mainstream more and more and I doubt it will stop any time soon.
Same, idk how the guy ended up thinking dropping types is the way to go.
It's always good to keep exploring. Unison lang is the one that stands out to me here, really progressive ideas. In the end I think simplicity is key.
Calling it a fad, hah! :>
ThomasMertes@reddit (OP)
Exactly.
"Fad" is the wrong word. I don`t think that functional programming is a short lived trend that will go away. English is not my native language. I should have written
I didn't want to belittle functional programming. I just wanted to point out that Seed7 has its own concepts as well:
yanitrix@reddit
bruh
uCodeSherpa@reddit
Yeah. This is a great example of people just saying things.
Personally, I couldn’t read any of the examples.
One thing that stuck out is that “is” does different things by context as well, which is an immediately readability destroying property of something.
davidalayachew@reddit
This hits the nail on the head.
The more I depend on context means the more I depend on state. If the word
if
means the exact same thing, no matter where it is, then that is less computation my brain has to do when it sees the word. Aka, that is more readable.Now, holding more state in your head does not prevent readability. But the argument is not clear when they claim more readability. The README and the FAQ seemed to be well aware of the situation for other languages, but surprisingly missed this point.
ThomasMertes@reddit (OP)
Just that the statement about “is” is just not true (see my other comment).
davidalayachew@reddit
Assuming that this is true, then even in that case, you have created a contextual keyword, and that concept on its own costs some readability. It may give back more than it takes away, but by definition of it being a contextual keyword, I am already paying a tax that I don't have to pay in other languages.
In Java, if I see the keyword
if
, then the only case where it won't mean whatif
means is if it is in a String. Whereas in your language, I might useif
as an identifier. That is the tax I am talking about. You might give me more readability elsewhere such that the total readability is greater than Java, but in this isolated example, Seed7 is forcing me to pay a higher tax than Java is.ThomasMertes@reddit (OP)
In Java, C++, Rust and many other languages a
<
is either an opening angle bracket or an infix operator. The meaning of<
depends on the context (declaration vs. expression). In Seed7 such a dual use of<
is prohibited by the Seed7 Structured Syntax Definition (S7SSD).The syntax definition of the
<
operator is:This definition requests that the right argument of
<
has a priority < 12. A definition of<
as angle bracket would be:But this would conflict with definition of the infix
<
since now the argument after<
could have any priority (because it is enclosed in symbols).Languages which allow the dual use of
<
use ad-hoc solutions or context dependent parsing.For similar reasons Seed7 does not use
:=
in assignments and in declarations.The syntax rules of Seed7 apply everywhere. I consider this approach as cleaner as the ad-hoc hard-coded parsing that is commonly used in many programming languages.
ThomasMertes@reddit (OP)
davidalayachew@reddit
I need a little more context than this. What does no mean?
ThomasMertes@reddit (OP)
You cannot use `if` as e.g. variable identifier.
davidalayachew@reddit
Sorry,
if
was a bad example because every Seed7 program loads that as a keyword.What I was trying to say is that, any keyword that I introduce can then be used as an identifier in a program where that keyword has not been introduced. That essentially means that I am working with slightly different variants of Seed7 for each new program I make, and my working set of keywords changes per each one. That hurts readability upfront, even if it may help it in the long run.
ThomasMertes@reddit (OP)
Isn't the code unreadable if everybody invents new statements?
davidalayachew@reddit
Oh, I read the whole FAQ before I made my first comment. I understand that this is surmountable. My claim isn't to say that this is some flaw of the language.
My claim is that, no matter how you slice it, the mere existence of the concept of contextual keywords means that every program includes a $0...n tax (where n is the number of syntax declarations NOT defined by the language). That's a tax I don't have to pay in Java.
And like you said, if used correctly, then maybe, in some codebases, I can safely assume that the use of a
glubBlub
will only ever be a keyword in all Seed7 programs I write for a certain team. But that's my point -- the fact that I have to avoid the pothole is the tax.eddavis2@reddit
Here is a simple example I found on the website:
I'm a long time C programmer (from 1985), and the above is not hard for me to read at all.
I am a little taken back with the:
For me at least, that needs improving :)
But otherwise, for me at least, it seems pretty straight forward and easy to follow.
Of course your milage may vary!
mr_birkenblatt@reddit
compare this to Python:
in what world is the above more readable than the Python implementation?
vplatt@reddit
So, I think your complaint about Seed7's readability is a bit specious. I know it's not all the rage anymore to use English keywords, but if the grammar of the language used brackets instead, it would consume very little less screen real estate anyway. Furthermore the grammar for Seed7 is arguably MORE readable because you can see what each end* keyword is actually terminating; i.e. func, for, if, etc. But that is subjective. Putting that up against Python's significant whitespace is a bit pointless when we know very well that there are many issues with that by itself.
I don't know about your other questions, but I was curious about the performance aspect of both versions, so I compiled the Seed7 version from here as-is (using "s7c sieve.sd7", and I tried benchmarking using 3 different command lines:
Seed7 Interpreted
Benchmark 1: s7 sieve.sd7
Seed7 Compiled
Benchmark 1: sieve
Python Interpreted
Benchmark 1: python sieve.py
C Compiled
Benchmark 1: sieve_c.exe
And I can vouch for the fact that the Seed7 versions outputted the correct result.
So, other issues aside, you can see what's here is already impressive from a performance standpoint. It doesn't touch C, but it beats the pants off of Python even in interpreted mode, and it's considerably easier to understand the Seed7 version. All that from a compiler that's been under development from a single dev. Pretty impressive I'd say.
ThomasMertes@reddit (OP)
Did you compile Seed7 with optimization flags?
That would be:
or
vplatt@reddit
I did not. O3 isn't working with MSVC in VS 2022 right now; not sure why. O2 worked though:
Benchmark 1: sieve.exe
So, that's an improvement. It might be slightly better if I had this laptop plugged in right now. Either way, I didn't run cl against the C binary with optimization flags either, so it was pretty much apples to apples.
ThomasMertes@reddit (OP)
If you change the
main
function tothe computation of
sieve
is at compile time. This reduces the run-time drastically.vplatt@reddit
🤣
Benchmark 1: sieve.exe
Ok, that's just stupid good fun! Thanks for the laugh!
mr_birkenblatt@reddit
[Citation Needed]
vplatt@reddit
Feeling lazy eh? That's OK. Me too. I'm not going to run through all of this by hand for you from scratch. So, here's ChatGPT collection of notes on the matter. Looks pretty good to be honest.
--
Here is a curated list of articles and discussions that delve into the challenges and criticisms associated with Python's use of significant whitespace:
"Python's Significant Whitespace Problems" by Erik Engheim This article explores the pitfalls of Python's indentation-based syntax, highlighting issues such as visual misalignment and challenges with code copying between editors. 🔗 Read more on Medium
Stack Overflow Discussion: "Are there any pitfalls with using whitespace in Python?" A community-driven discussion where developers share experiences and common problems related to Python's indentation, including mixing tabs and spaces. 🔗 View the discussion
"The Case Against Significant Whitespace" by Erik Engheim An opinion piece arguing that significant whitespace complicates language design and can lead to subtle bugs, especially when code is copied or edited across different environments. 🔗 Read the article
Reddit Thread: "Python and Indentation. Why? :)" A Reddit discussion where users debate the pros and cons of Python's indentation rules, providing various perspectives on its impact on code readability and maintenance. 🔗 Join the conversation
"Why Python's Whitespace Rule is Right" on Unspecified Behaviour This blog post discusses the rationale behind Python's indentation rules and the problems that can arise when code is copied with inconsistent formatting. 🔗 Read the blog post
Stack Overflow: "Why does Python PEP 8 strongly recommend spaces over tabs for indentation?" A question and answer thread explaining the reasoning behind PEP 8's recommendation for using spaces, addressing issues related to code consistency and editor behavior. 🔗 Explore the Q\&A
GeeksforGeeks: "Indentation Error in Python" An educational article that outlines common causes of indentation errors in Python and provides guidance on how to avoid them. 🔗 Learn more
Wikipedia: "Python Syntax and Semantics – Indentation" An overview of how Python uses indentation to define code blocks, including examples and explanations of potential pitfalls. 🔗 Read the Wikipedia entry
Wikipedia: "Programming Style – Python" This section discusses how Python's indentation-based syntax affects programming style and the challenges it may pose when copying and pasting code. 🔗 View the article
GitHub Issue: "How to handle significant whitespace?" A technical discussion on handling significant whitespace in language parsing, relevant for those interested in language design and tooling. 🔗 Read the GitHub issue
These resources provide a comprehensive look at the various concerns and debates surrounding Python's significant whitespace, offering insights from both community discussions and expert analyses.
mr_birkenblatt@reddit
Your argument is about tabs vs spaces (which has been clearly defined by PEP 8 so it hasn't been an issue since 2001) and copy & pasting?
Sure, there were some issues 20 years ago. Any actual argument? Especially one that isn't embarrassingly outdated?
vplatt@reddit
It's not more outdated or irrelevant than "wah, I don't like English keywords!". Your criticism about Seed7 keywords has as much validity as that.
mr_birkenblatt@reddit
I don't like English keywords is your takeaway?
I guess chatgpt read my comment for you as well?
I have you an example how introducing English keywords does not solve the problems you claimed it would solve
vplatt@reddit
All I heard again was "wah!". Huh... must be the tone of your posts. It makes taking you seriously impossible. That's what your snark earns you.
vplatt@reddit
Oh, and I used Python 3.13.2. That's pretty darn current Skippy, so yeah. Deal.
mr_birkenblatt@reddit
So, you set the flag for turning off the GIL (3.13 has that on by default)? No? Then, it's not close to current performance
vplatt@reddit
Well, how dare I decline to use an experimental feature?! And ::gasp:: I'm a WHOLE minor version behind too.... well, spank me twice and no dinner before bed!
Please do feel free though. I'd be curious to see how that version stacks up. (pun intended!)
ThomasMertes@reddit (OP)
The
05
in "seed7_05.s7i" refers to the year 2005, when Seed7 was released.A future (maybe incompatible) version of Seed7 can be introduced with e.g. "seed7_25.s7i". This way two or more versions of the language could be supported in parallel.
Since every program needs to state the language version, with the first include statement, problems with different language versions (e.g. Python 2 vs. Python 3) can be avoided.
ThomasMertes@reddit (OP)
Why do you think that “is” does different things by context?
Seed7 uses the keyword "is" only in declarations. E.g.:
The keyword "is" separates the constant or variable name from its initialization value.
In function declarations the keyword "is" is also used to separate the function name (+ parameters) from the value of the function (the function body):
Function declarations can also use a simplified function body (introduced with the keyword
return
):The keyword "is" is only used in declarations and it is always followed by an initialization value.
shevy-java@reddit
I don't think "is" is anywhere near as problematic as "end func;". I feel the design may not have been to focus "on less syntax is more". Which, to be fair, many programming languages also don't, e. g. C++ or Java, but I find it more efficient the fewer characters I have to type, for the most part (too few characters can also be problematic, but I fail to see the rationale for "end xyz;" really. It reminds me of shell scripts.)
ThomasMertes@reddit (OP)
Nitpicking: The keyword "is" is used for the initialization in declarations and the assignment statement uses
:=
.Many years ago I had the same opinion but over time it changed.
Programs are more often read than written. Seed7 is optimized for reading and not for writing. So instead of "less syntax is more" there is some redundancy on purpose.
There are
end if
,end while
,end case
andend func
on purpose. In case you cannot see the beginning of a statement you can recognize the kind of statement at its end es well.devraj7@reddit
I had the exact same reaction. These make the sources so verbose with a lot of noise that you have to train yourself to visually ignore.
larsga@reddit
I used to write a lot of Pascal and Simula some decades ago. It's not really an issue. You quickly stop seeing them.
Yes, curly braces is better, but it's not really a big deal.
shevy-java@reddit
People use that same explanation for lisp and the numerous (). The human brain can adapt to numerous things but I find it more efficient to have e. g. ruby or python syntax. These are more efficient IMO.
shevy-java@reddit
"end" in itself is not that problematic.
In python we have:
and a mandatory indent
In ruby we have, for the equivalent:
So the difference is not that enormous for this simple case. I don't think 'end' in and by itself is problematic, though deeply nested it can be annoying. I usually try to limit the level to three end; if more would come I tend to group-define when possible e. g.
Or often then:
Not many use the latter style in ruby, which I also understand, but I much prefer the ends on the same level if there would be multiple indents. I typically don't indent once per level, I usually only indent once (with two spaces) or twice (for four spaces); no more than that.
So "end" may not be the most elegant but I don't think this is the biggest issue. In python this is a bit more readable but at the price of mandatory indent (I hate this when I want to copy/paste and python screams foul) and the necessary ':' (and also explicit self, which is the single thing I hate by far the most in Python; I always feel to have to tell the parser where self is, which feels like a bad design. I dislike this way more than mandatory indent, as I indent usually anyway, so only copy/pasting annoys me here).
MiningMarsh@reddit
This language looks like someone took my precious baby LISP and gave it shaken baby syndrome.
If I'm reading it right, it has LISP-style homoiconic macros in BASIC syntax.
prescod@reddit
I’ve never read Seed7 code before but that a snippet is quite readable to me.
It’s a function that coerces an integer to float before adding to a float.
mr_birkenblatt@reddit
I'm confused by this example because it implies that you can not use certain constructs in some circumstances. from what OP gave as example code I would expect the function to look like
ThomasMertes@reddit (OP)
Both are correct (see here).
ILikeLiftingMachines@reddit
It looks like the lovechild of an illicit relationship between C and pascal...
wplinge1@reddit
Yeah, it might have fit in better back when it started in the 80s but languages have kind of settled down now and this one looks egregiously weird.
araujoms@reddit
You can set the minimum index of an array. What at terrible idea. It destroys readability, and is a reliable source of bugs.
Both 0-indexing and 1-indexing have their merits. Arbitrary indexing is the devil's work.
ThomasMertes@reddit (OP)
Languages which allow setting the minimum index of an array are:
Pascal:
Modula2:
Ada:
Algol-68:
Nim:
FORTRAN: (you mentioned it somewhere)
Regarding conspiracy theories:
In theory six years ago I could have created the account PurpleYoshiEgg and over the years gathered much more comment karma than with my main account just to use it in a world shaking dispute about the minimum index of an array.
In reality probably no argumentation whatsoever will change your opinion and that's fine for me. In reality everybody can check the history of accounts and decide if a particular account is a socket puppet or not.
araujoms@reddit
In reality you created the account u/PurpleYoshiEgg/ just to browse Reddit, which naturally makes it accrue more karma, and you use the account u/ThomasMertes only for stuff you want to have associated with your real name. On occasion you also use u/PurpleYoshiEgg/ for stuff that would be embarrassing to have under your real name, such as insulting people who criticize the design of seed7.
You could change my opinion if you could show a sane way to, for example, compute the inner product between two vectors. It seems like in seed7 one would need to do
and I don't believe anyone can say this is more readable than
``` minIdx
JohnPorkSon@reddit
lol that was his alt u were right
Tuxinoid@reddit
No, it's the other way round. *You* are obviously u/ThomasMertes trying to get more attention, and you just have insulted yourself because of ... reasons.
PurpleYoshiEgg@reddit
no it doesn't
araujoms@reddit
Is v[1] the first element of the array or the second? This information is no longer context independent, you have to look at the declaration of every single array to know it.
PurpleYoshiEgg@reddit
How often do you really need to know which number is the first element of the array? I would hazard a guess not very often, and so that it "destroys" readability is suspect.
If it's important, you can get the index of the first element easily with minIdx(A). In fact, with the prevalence of off-by-one errors, I would recommend to use minIdx(A) and maxIdx(A) for looping if for some reason you don't want to use
for
.araujoms@reddit
Every single time I'm working with arrays.
So instead of of v[1] now I should use some weirdly named function for one of the simplest and most common array operations. Seed7 is supposed to be readable, there's nothing readable about "minIdx(A)".
Lol so I should write myself a function for such an elementary operation? No thanks, I prefer programming languages that don't make me struggle to do the basics.
PurpleYoshiEgg@reddit
Sounds like you're using them wrong.
It's not all that weird. You know it now, so you have learned. And now you know to use it. And now you understand what
v[minIdx(v)]
does, and so therefore it is readable.The whole point of Seed7 is its extensibility. If you're afraid of doing basic extensibility, then your complaints make a lot more sense, yet I fear for the quality of your code.
araujoms@reddit
And now you started insulting me. That's why your language will never catch on, you are incapable of listening to criticism and improving the design.
PurpleYoshiEgg@reddit
I didn't really insult you. I am just pointing out the fact you seem to be afraid of extending a software system with functionality like you should do in any language, and that I fear for the quality of your code in that case.
Basic observations of fact are not insults.
Also, it's not my language. I question the premise of "Not knowing if the first array index is 0 or 1"* is properly concluded with "destroys readability". "Destroys readability" would imply that it is not readable with any amount of knowledge, because the ability to understand is the fundamental aspect of what makes something "readable", which has many different usages, and so the vagueness of its opinionated nature does your point a disservice here.
However, I have given you the minimum amount of knowledge to understand how to access the first array index, as well as a better way of actually using the first index of an array that communicates the exact operation better. Therefore, it "destroys readability" is an invalid conclusion.
* - This is in incomplete premise; the more complete premise is: "The first array index can be any integer (as defined by the integer type)" or, more informally as you put it, "Not knowing which integer is the first array index".
araujoms@reddit
And that's yet another insult. I'm not afraid of extending programming languages. I'm in fact a contributor of the Julia programming language. I just think array is a fundamental part, that should be provided by the language itself. Even bare-bones C can do it without any hassle, v[0] is the first element. And you're trying to convince me that I should have to write a function in order to access the first element of a array. That's ridiculous.
And now you're insulting my intelligence, obviously you're Thomas Mertes. Who else would even find my obscure comment in this thread, defend this stupid design decision, and now seed7 in any detail?
PurpleYoshiEgg@reddit
Not an insult.
You only need to write it once. You seem to be under the impression that is an undue burden.
It is not an undue burden for someone who is allegedly a contributor to the Julia programming language.
I am neither insulting your intelligence, nor am I someone named Thomas Mertes.
Your initial comment was a top-level comment to this post, which at the time of this writing has only 142 comments, and had less than that before this comment. It is hardly "obscure".
I am someone who questions the idea that your complaint "You can set the minimum index of an array" can reach the conclusion that it "destroys readability".
And I happen to like Seed7's ideas, so I've looked through its reference documentation a bit. I don't personally use it in any capacity, but it's one of the languages I want to learn more thoroughly on my vague list of languages.
I doubt you can show that all FORTRAN programmers, allowing for a few exceptions to the general rule, make the conscious decision not to use the feature (i.e. "refuse"), particularly for the reason that "it only causes trouble".
In fact, as a counterexample to FORTRAN programmers refusing to use this feature, there is a Julia library for OffsetArrays specifically implementing FORTRAN-like array indexing. In short, this means that it is used enough in FORTRAN that more than a handful of people found it useful to implement in Julia and cite FORTRAN is the inspiration. Such an activity indicates its potential usefulness, and also mitigates the idea that it "destroys readability", not that you have shown yet that conclusion is reasonable.
araujoms@reddit
And now we have two insults! One by insinuating that I can't write such a trivial function, and another by insinuating that I'm lying about contributing to Julia. Of course I can write it, I just refuse to, because this basic utility should be provided by the language itself.
Go on then, tell me that the inner product I wrote to your alt account is readable.
No, I can't prove your ridiculous strawman. I can show you the source code of the reference implementation of LAPACK, which only works for 1-index arrays. And I challenge you to find any relevant FORTRAN project that supports arbitrary-based indexing.
Whatever Julia programmers do is not a counterexample to anything that FORTRAN programmers might or not do. But yes, I'm aware of this package. It's seldom used, because it only causes problems. If you look through the source code of the standard library LinearAlgebra, you'll see lots of calls to
require_one_based_indexing
. This is a function that checks whether an array is 1-based, and throws an error if it's not. This is because actually supporting arbitrary-indexed arrays would make the code unreadable, besides being stupid.PurpleYoshiEgg@reddit
I didn't say you can't write a trivial function. I stated you seem to be under the impression that it is an undue burden. And I said you are allegedly a contributor to the Julia programming language, because, one, I do not wish to follow up to see if it is true, two, I am accepting it as proven for the purposes of discussion, and three, accepting it as true is more damning on your critique of the language.
It is not my alt account. However, I am rusty with vector math, but I am guessing
conj
is conjugation (so I would likely like to expand that function definition toconjugation
unless it is common parlance in a particular library). Based on this, you should be doing this instead:Assumptions for correct output:
x
andy
are defined arrays of the same length and indexing, which are reasonable assumptions given that you are finding the inner product of the two, and you'd likely use consistent indexing numbers with all vectors.I did recommend previously that you should be using
minIdx(x)
andmaxIdx(x)
for this reason, and that you probably don't need to know the number for the first index of an array. So, I do think it is less readable the way you wrote the first one, putting theminIdx(...)+i
in the indexing operator. That said, I don't think it's unreadable, because I understood it fine.Unreadable, to me, means "significantly difficult to understand", and my particular litmus test (that proves, to me, beyond a line of being significantly difficult to understand that it is difficult to understand) is if I understand it for a fleeting moment, and then have to work to re-understand it to move on. I don't think it is such.
Your premise is that FORTRAN programmers refuse to use it. You made the unprovable premise. I just highlighted it.
A strawman is if I distort your premise. Not if I highlight the implications of having to prove the premise that you don't like.
That is one of many possible implementations of libraries written in FORTRAN. One is not all.
Sure it is. They cited FORTRAN as the inspiration for the library. Therefore, it has some potential usefulness.
I don't see that intent documented anywhere. I did find that Julia seems to support arbitrary indexing based on your function reference. And this is official documentation, so it seems the OffsetArrays is an option in Julia itself.
Additionally, it would make sense to limit a linear algebra library to a consistent indexing, e.g. for vectors and such. I don't really see that not allowing offset arrays in a linear algebra library with specific precondition requirements leads to the conclusion that an offset array "only causes problems".
Do you perhaps have a direct link to where this intent is documented?
araujoms@reddit
So arbitrary indexing is fine as long as we don't actually use it. Thanks, you just proved my case. Now I'm going to stop responding because you're clearly just trolling.
PurpleYoshiEgg@reddit
You just unstated your assumption. I stated them. I am not sure how that proves your case.
Nonetheless, you have not provided sufficient evidence nor argument to show that arbitrary indexing "destroys readability".
Seeing as you have indicated you are not going to argue further, I accept your concession.
Thank you for the riveting discussion 🥰
Different-Finding-29@reddit
love the project
acidoglutammico@reddit
But in the next passage you don't really explain why for your language type is not preserved across contexts. If your types are only the concrete ones, simply spit out an error if you cant unify. If you have polymorphic types you could even have more general functions with not much hassle.
Not really that difficult. Plenty of functional languages have it and are perfectly legible (I'll give you haskell, but the rest are fine).
ThomasMertes@reddit (OP)
Consider the expression
In Seed7 the type information moves from the bottom to the top. If the types of
a
andb
are known and the definition of+
applies, then the type of the expressiona + b
is also known.If the type of
b
is unknown the type of the expressiona + b
is also unknown. In this case you get an error in Seed7.A type inference could use the type of
a
and the definition of+
to deduce the type ofb
. Something like: The+
assumes that both types are equal anda
isinteger
and thereforeb
must beinteger
as well. In this case the context ofb
would be used. This violates the bottom up principle.If
+
is overloaded to work with mixed parameters the deduction viaa
and+
is not possible. A type inference could look at other usages ofb
. Maybe it can deduce the type ofb
from another usage ofb
. Let's say there is an assignment likesomewhere. From that it could be deduced that
b
is integer. But this violates the bottom up principle as well. And what if the only hint for the type ofb
is:And in
aFunction
is no hint which type is returned except for the lineAnd the journey goes on to different functions in different files.
acidoglutammico@reddit
Or you could say: since ((+) a) has type int -> int, then if b is not type int it should give an error. So type of b would not depend on context.
Can do it in Haskell!
Why would that be needed? Just deduce the most general type from the definition of b.
That's why type inference is useful :)
Btw very interesting language, just lots of interesting design decisions from the point of view of a modern programmer.
ThomasMertes@reddit (OP)
Many thanks for pointing out that the answer to "Why does Seed7 not use type inference?" has weaknesses.
I plan to use the explanation I wrote above instead.
Can you do it Haskell, because it allows type ambiguities in sub-expressions?
Ambiguous sub-expressions are covered in the FAQ as well.
Maybe I should point out that it should be an unambiguous deduction. What about:
If
+
is overloaded to work with mixed parameters an unambiguous deduction ofb
witha
and+
is not possible.acidoglutammico@reddit
That would be a clearer, yes.
I was a bit sneaky: haskell has a Num type with a Fractional subtype, so it can specialize the types into Int, Float, ..., a bit more elegantly. So 1 would be of type Num, 1.0 would be of type Fractional, so 1+1.0 would be of type Fractional. It can only go towards more specialized types. But the signature of the function (+) is still
Num a => a -> a -> a
, which means you dont need to keep track of numeric types, just specialize when needed.Reading more documentation, it seems that you want to keep complexity down, so not having parametric types is fine. It would be very hard to have recursion in that case.
ThomasMertes@reddit (OP)
I wrote a new answer to Why does Seed7 not use type inference?
What do you think about it?
acidoglutammico@reddit
Looks good, clear and fairly concise. Maybe could be expanded on why something similar to
auto
(like in cpp) is not implemented, but it's not really important.ThomasMertes@reddit (OP)
Exactly. There is a lot of unnecessary complexity in software and I want to reduce it.
Instead of a function with parametric types you define a template (with a type parameter) which defines the function. You need to instantiate the template as well. This way your intentions are documented and there are less things going on behind the scenes.
syklemil@reddit
Having a look at an arbitrary program I get the impression that Seed7 leans in the direction of
void
functions (what some might insist are subroutines rather than functions) that mutate globals.The lack of conventional uppercase for globals also decreases readability for me, e.g. in
the line
reads like a creation of a new variable, but it actually mutates a global variable based on some input parameters. I both couldn't figure how constructing a
hole_status
fromcurr_hole_status
make sense given the claim that declaration happens at function level, not with why you'd continue with stuff likehole_status[line + depth][column] := no_hole
when in that case you'd already constructedhole_status[line][column]
from a variable that containsno_hole
. But then way up at the top of the file there'sand the explanation for what is actually going on here.
I know there are people who like to program that way (I've had some professors who do it that way), but personally I just think of it as "spooky action at a distance" when a subroutine works by mutating variables outside its scope. I'm used to a pretty functional style, so when it's all
void
and side effects I lose track of what's going on.Personally I'm a fan of both enforcing that
GLOBALS_ARE_UPPERCASE
and that object variables are accessed through a keyword likeself
orthis
. Dropping either or both means that a bare variablefoo
can be global, object or locally scoped and I actually have to go looking for the declaration to figure that out.crab-basket@reddit
This is a neat project, but I genuinely don’t understand the trend of writing a programming language that just transpiles code to C. That is almost never what I want in my toolchain. Debugging gets obfuscated, any symbol issues become harder to trace down, etc.
Like why go through the hassle of making a programming language and not even doing the emitting part of it? Toolchains like LLVM make it easy nowadays
XNormal@reddit
This project started in 1989 and you are talking about... trends?
matthieum@reddit
Using LLVM is NOT easy, actually. It's a massive API, and there are breaking changes with every release. It also massively increases compile-times, making it much harder to test the compiler.
Furthermore, there are C compilers for many more targets than there are LLVM backends, so C is a (somewhat) more portable output.
As for debugging, I can't speak for Seed7, but there are preprocessor directives which can be emitted in the C code to point the Debug Instructions to the original source code, instead (see
#line
), and if the source language is "close enough", you can keep the same variable names and prefix all "introduced" variables with$
for example to make them easily distinguishable.Which means that all in all, it's fairly close to first-class debugging support.
ThomasMertes@reddit (OP)
You hit the spot. The Seed7 compiler emits
#line
directives. This way a debugger refers to the original Seed7 source code.Variable names are prefixed with
o_<number>_
where the number makes the names unique. Ifwrite
is overloaded the C function names are e.g.o_1058_write
ando_1240_write
.dravonk@reddit
Is transpiling a language to C just a trend? If I remember correctly even the original C++ was "just" transpiling to C.
One advantage that I see is easier interoperability: if you are writing a library in a new language and it is transpiled to C, you could immediately call the functions from any language that can call C functions. The C compiler would make sure that the calling conventions of the system are used.
Emitting C rather than LLVM IR would enable using both GCC and LLVM, and last I heard GCC still supports more target platforms.
ThomasMertes@reddit (OP)
Wikipedia refers to transpilers as source-to-source compiler. It states:
Since C has no function overloading, no exceptions, no object orientation, no call-by-name parameters and no templates I consider the Seed7 compiler as compiler.
It uses a C compiler as back-end the same way as many C compilers create assembly code and use an assembler as back-end.
Using some sort of portable assembler (=C) as back-end has some advantages.
Seed7 is independent from other compiler projects like LLVM. It can interface many C compilers and operating systems.
Emscripten provides a C compiler which compiles to JavaScript / WebAssembly and it provides also a run-time library.
The Seed7 support of JavaScript / WebAssembly uses Emscripten.
RegisteredJustToSay@reddit
Sorry, but although I agree on your most technical definition of a compiler it still seems you are getting most of the disadvantages of a transpiler based design and therefore I still think the original commenter's point stands almost entirely unmodified. As an analogy, your language seems more like typescript than JavaScript since it effectively becomes a way to express C programs in a different syntax much like Typescript does for JS, furthermore you seem to be getting the same disadvantages as using transpilers since it mangles and changes debug symbols (unless you generate these separately? Typescript does this to solve the issue) and generally couldn't efficiently support language features that C doesn't without additional layers of wrapping of basic features.
I'm not saying this isn't a valid approach, but focusing on semantics over the core of their argument isn't the most meaningful way to convince anyone to use your language.
I also feel like using assembly as an example for C using an intermediate language isn't quite... right. I mean assembly is generally different syntax for expressing raw machine code, so it's more like a text representation of machine code than any kind of high or even low level language per se even if it technically is. Again I don't mean that there isn't any truth whatsoever in the comparison, but it feels more akin to "word of the law" rather than "spirit of the law" if that makes sense.
I'm not saying your language doesn't have other merits though. Your response just didn't do anything to convince me the commenter is wrong in any meaningful sense.
zapporian@reddit
No, this is a perfectly legitimate approach. See GHC (started as Haskell -> C compiler), C++ (ditto), ObjC (ditto).
Typescript (and ye olde coffescript) ofc do / did the same things w/r js, and those specifically at a minimum straddle the line between transpilers and compilers (or more accurately static analyzers in TS’s case), for sure.
This is a really weird PL that definitely looks like a somewhat modernized old, interesting artifact from the 90s, but using C as a target language absolutely still is sensible - and a legit compiler when the target lang is considerably more high level than C (see haskell, objc) - in some cases.
Ofc objc basically / pretty clearly emerged out of a custom smalltalk inspired OOP C preprocessor from hell, so there is… that… too, but I digress.
izackp@reddit
Coming from Swift, it's hard for me to use any language that doesn't have forced checked exceptions. This would make me want to use a Result type for everything which means I will have to handle both exceptions and result errors. I would also say the lack of null will just result in a 'optional' type too. Especially, when it comes to serialization where a key may or may not exist in the data but still be a valid type.
Comparing with swift, swift provides syntax sugar to handle these things thus making them very pleasant to use.
I'm also not a huge fan of your string implementation not handling grapheme clusters. I feel like that's a time bomb waiting to go off.
Otherwise, the rest of it seems neat.
davidalayachew@reddit
This has my attention.
What's the standard library look like? Is there anywhere I can look to get a high level overview of what functionalities are present?
For example, in Java, I can go to the root level of the javadocs, and it will show me the list of modules. From there, I can see the compiler module, the front-end development module, the logging module, the HTTP client and WebSocket module, etc.
Does Seed7 have something similar? Tbh, I am interested enough in the language that seeing the list of provided modules will be the deciding factor for me giving this language a serious shot.
eddavis2@reddit
While not as good a javadocs, there is this link:
Seed7 libraries
Here is an excerpt:
Numbers
Numeric types are supported with the following libraries:
** Strings **
The characters in a string use the UTF-32 encoding. Strings are not '\0;' terminated. Therefore they can also contain binary data. Strings are supported with the following libraries:
The categories include:
As documentation goes, it isn't bad at all.
davidalayachew@reddit
Thanks. I saw that. Is that really all there is? Surely that can't be exhaustive?
For example, the HTTP library seems to only have the ability to do an HTTP GET, but not an HTTP POST. When I saw that, I figured that it was just a quick excerpt of what using that library was like. I didn't figure it to be an exhaustive record of all functionality.
Which is my question -- is there anywhere that has an exhaustive record of all of the functionality in the Standard Library for Seed7?
eddavis2@reddit
I definitely agree that the documentation is somewhat unwieldly. But at least there are docs! :)
Using the side-bar on the left, I went to the http response page, and there is indeed support for HTTP POST:
processPost (in httpResponseData: responseData, inout httpRequest: request) Process a POST request and send a response to the request destination.
Lots of interesting stuff there, but you might have to spend time pouring over it.
davidalayachew@reddit
Thanks. Ok, guess I will have to dig.
vplatt@reddit
https://thomasmertes.github.io/Seed7Home/libraries/index.htm
Left hand side has the modules list under the heading "Libraries", of which I count 174 modules.
shevy-java@reddit
Quite heroic effort.
I am not sure the syntax is very efficient, e. g.:
I don't necessarily mind the getc(), though the trailing "of" is weird, but the "end case;" specifically. That seems not really necessary if "end" already works as a delimiting keyword.
ThomasMertes@reddit (OP)
Thank you. I am the main dev but not the sole one. I get help from others.
Programs are more often read than written.
The person writing a piece of code shouldn’t buy convenience at the expense of the people who will have to read it and modify it in the future.
The syntax of a language should be efficient towards reading and not towards writing.
Of course, "end" would work as delimiting keyword.
I think readability improves, if you can see what each "end" keyword is actually terminating; i.e.
func
,for
,while
,if
,case
, etc.Middlewarian@reddit
Seed7 is the only individual/(proprietary?) project that I know of that's older than my on-line C++ code generator. I'm a few months from 26 years.
ThomasMertes@reddit (OP)
Seed7 is GPL licensed open source software.
McMep@reddit
Coming from the hardware design space this gives me big VHDL vibes
vplatt@reddit
Both VHDL and Seed7 take inspiration from Pascal.
the_other_brand@reddit
So Seed7 is a language that has the portability of Java, the extensibility of Lisp and the performance of a language like Go?
If that is all true this is quite the achievement.
vplatt@reddit
Honestly, it is. I mean, it's not perfect. I prefer languages for which I can easily set up a live debugging session. I haven't found a way to do that with Seed7 yet. Maybe something will be possible with gdb? I don't know.
Oh, but get this: He has working WASM demos too: https://seed7.sourceforge.net/demo.htm
I don't know. I have a soft spot for projects like this.
MooseBoys@reddit
Either this is wrong, or the language is cannot be used to interact directly with hardware. Based on a cursory reading of the docs, it appears to be the latter.
ThomasMertes@reddit (OP)
Seed7 is not a systems programming language. It is not intended to run without operating system.
That said, I wonder how interacting directly with hardware triggers undefined behavior.
I think that a language could interact directly with hardware and still have defined behavior.
THE_STORM_BLADE@reddit
Would any code I write in Seed7 need to be licensed under GPL-2?
ThomasMertes@reddit (OP)
There is no restriction on the license of your Seed7 programs.
tom-dixon@reddit
From a quick glance the the Monte Carlo benchmark should be renamed to "rand() benchmark".
There's no universe where a search algorithm in C is twice as slow as the C++ one. The main difference is the different rand() function.
I didn't run a profiler on them, but I'd bet money that most of the time of the C implementation is spent generating random numbers.
If you want to test how well the compiler optimizes loops and lookups, don't generate 10 million random numbers with a library call in that loop.
casualcaesius@reddit
Did you also make Sub7? That was fun back in the days lol
zhivago@reddit
It would be nice if you told us how you expect seed7 might make our lives easier.
The world is full of uselessly interesting languages, after all.
ThomasMertes@reddit (OP)
You can take a look at the design principles of Seed7.
Software maintenance should be easier, because Seed7 focuses on readability.
It should be easier to port software because it is hard to write unportable code in Seed7.
It should be easier to write efficient programs because Seed7 is high-level and can be compiled to efficient machine-code.
It should be easier to write programs in Seed7 because it provides many libraries.
The templates and generics of Seed7 don't need special syntax. They are just normal functions, which are executed at compile-time.
Assume the new type myType has been defined together with the function str(), which converts a myType value to a string. In this case you can use the template enable_output with
to define everything necessary to write myType values to a file. If you want to do a JSON selialization / deserialization for myType you can use the template declare_json_serde with
to get declarations of toJson and fromJson.
opuntia_conflict@reddit
So...it's just traits and deriving attributes in Rust? Or like inheriting from mixin classes in Python? It's certainly impressive to have made an entire programming language, but I'm not sure I understand how it's unique.
ThomasMertes@reddit (OP)
Seed7 is an extensible programming language. The syntax and semantics of statements (and abstract data types, etc.) is defined in libraries. The whole language is defined in the library "seed7_05.s7i".
The library forloop.s7i defines various for-loops and the library array.s7i defines the array type and its functions.
You can extend the language syntactically and semantically (introduce new loops, etc.).
In other languages the syntax and semantics of the language is hard-coded in the compiler.
the_other_brand@reddit
By extensible, do you mean like Lisp? Where even the syntax of the language can be altered within the language?
If that's the case and you've mixed that functionality with default syntax that doesn't make my eyes bleed then that's really cool.
KsuhDilla@reddit
First off congratulations on making a full programming language - it's an incredible feat.
Question: How do you assure the flexibility of user's defining syntax and semantics won't violate your principals of readability?
zxyzyxz@reddit
Principle not principal
shevy-java@reddit
A principal could care about basic principles though.
KsuhDilla@reddit
Well I extended the language so now its principals
anotheridiot-@reddit
Cool, looks like something Nim would allow.
zhivago@reddit
What's the benefit of enable_output() rather than just having the output protocol accept str producers?
Is this equivalent to declaring the implementation of an interface, but with the mechanism hidden within the macrology?
ThomasMertes@reddit (OP)
If you have defined str() for myType you can use:
After enable_output(myType) you can use:
So write, writeln and the
<&
operator are overloaded by enable_output.zhivago@reddit
ls this overloading a kind of ad hoc interface type replacement?
i.e., normally we would assert that myType satisfies interface X and therefore everything accepting X will accept myType.
ThomasMertes@reddit (OP)
In statically typed (compiled) languages overloading refers to using the same function name (or operator symbol) with different argument types. The compiler examines the type(s) of the argument(s) and decides which function is called.
The overloading is used by many languages (e.g. in Java).
Many languages define the types like
integer
andfloat
and the operator+
to do an addition. Since the representation ofinteger
andfloat
in the hardware is totally different there are different machine instructions to do the addition. So there are actually two different+
operators which correspond to the machine instructions.The programmer will always write
A + B
for an addition. The compiler examines the types ofA
andB
and decides which machine instruction(s) will be used.Overloading is not a kind of object orientation and it works at compile time and without interfaces.
In Seed7 there is a syntax definition of the
+
operator (but this is not an interface):In Seed7 the
+
operator is defined for integer and float with:When a program is compiled the executable has the absolute minimum overhead possible for integer and float addition.
zhivago@reddit
Right, so you have overloading.
Are you using it with this macrology as an ad hoc interface type replacement when writing
enable_output(myType);
?ThomasMertes@reddit (OP)
No
shagieIsMe@reddit
The Codeless Code : Case 107 : Bable
moxyte@reddit
How open is development? Do you take others seed?
Mooripoo@reddit
hahahahaaha
JesseNL@reddit
Great achievement to have created this!
tsammons@reddit
Terry Davis never died
lil_doobie@reddit
wubby7
sweet-arg@reddit
Trash language, just use c#.
Sad-Technician3861@reddit
I prefer golang
neutronbob@reddit
Congratulations on this project. So many languages posted on Reddit and HN have lots of incomplete parts; but you've built the whole thing with an interpreter, compiler/transpiler, large libraries, many utilities, and good documentation. The project really shows the effort and care you've put into this. Good work!
Interesting_Shine_38@reddit
The language gives me Ada vibes.It looks interesting, I love Pascal-like languages.
davidalayachew@reddit
Reading the FAQ, aren't Scanner Functions just a new name for Parser-Combinators? Or is there a meaningful difference that I am not seeing?
True-Environment-237@reddit
Tsoding should experiment with this language!
Catdaemon@reddit
Website is awful to use on mobile, I genuinely tried to care about this but gave up after not being able to click on anything without zooming.
ThomasMertes@reddit (OP)
You are right. The website addresses software developers and it assumes they sit in front of a computer and its screen.
Every time I use the homepage on a mobile I have the same problems as you have. This is a marketing issue and I need to fix it. At the latest when software development is exclusively done on mobiles. :-)
F54280@reddit
Software development is done on desktops. But research on new things that are not work-related are often done in transit, on the toilet, or in a bed -- on a mobile.
Be happy that you have enough users of your language so you only need to focus on the ones doing software development, and have no need acquiring new users or spreading the word on the language :-)
ThomasMertes@reddit (OP)
Fully agree
Catdaemon@reddit
I fully get it, I just don’t use Reddit on my PC for the opposite reason - the experience there is terrible. That means I along with many people mostly do our reading on the phone and writing on the PC. I also like to peruse documentation while out eating etc. I don’t think it’s ridiculous that a site should be usable on mobile in 2025.
A_little_rose@reddit
Works just fine for me