23 ms·
The main goal at the moment is to create a C compiler, the function keyword there is just a placeholder for the time being. At the moment anything returned is j
by r1chardnl 5y ago
The main goal at the moment is to create a C compiler, the function keyword there is just a placeholder for the time being. At the moment anything returned is just mov'd into the EAX register and then stored in a local variable if called that way.
- MisterTea 5y agoIf you're looking for C-like languages to study look up the plan 9 Alef language. It was a concurrent C-like that was designed to replace C until they realized its better off as a C library which is what plan 9's thread(2) is. It's mostly extinct but survives: http://doc.cat-v.org/plan_9/2nd_edition/papers/alef/ http://doc.cat-v.org/plan_9/2nd_edition/papers/alef/ https://seh.dev/go-legacy/ https://seh.dev/go-legacy/
- r1chardnl 5y agoLooks really interesting, thanks for sharing this. I'm not sure whether I'll incorporate everything from C or just make it compatible with C and behind the scenes do things differently e.g instead of carrying const char */string pointers everywhere always carry the length of said data structure along with it. Or for instance push an additional pointer on the stack for memory zones, where an allocator is always present and knows it's context, sort of like __thiscall with class methods for this->.
- kubb 5y agoOh, is _this_ where the inspiration for Go came from? It would explain a lot.
- kragen 5y agoYes. Even before Alef, Newsqueak (01989) was almost identical to Golang, and of course Alef, Limbo, etc., descend from Newsqueak.
- spijdar 5y agoWorth pointing out Plan9's C was itself sort of its own language. I think it was a strict subset, but I can't remember all the details. The preprocessor was much simpler, that much I remember.
- mananaysiempre 5y agoNot exactly a subset, there were at least the anonymous struct/union members that partially made it into C11 much later. But then if we look beyond the syntax almost any C implementation is “its own language” in that it defines behaviour the standard doesn’t specify, and frequently also changes behaviour the standard does, if in minor ways. Like how the Windows ABI forces a noncompliant wchar_t. (Even if we look at the preprocessor, the classic algorithm implemented in most places [that I can’t be bothered to find a link for] in fact expands more than the standard strictly guarantees, e.g. you can sometimes get recursive expansion out of it by creative use of token pasting,—I remember reading the ANSI committee thought the case was too “perverse” and didn’t specify anything [no link here as well, sorry... poke me again if you actually care about this]. The standalone preprocessor mcpp has warnings about this specification hole, but other implementations don’t as far as I know. And you’d think the preprocessor, an almost purely syntactic thing, wouldn’t have implementation differences worth keeping around.)
- MisterTea 5y agoYes, Plan 9 c has its own C library which does not follow ANSI/ISO though it is very similar to ISO C. Its syntax is pretty much c89 and the useful bits of c99. To build ANSI/POSIX you use the APE (ANSI/POSIX Environment) compilers and libraries which are built in. It's only reason for existing is to help with porting Unix baggage. The compiler is kencc which is why it is different. Plan 9 also still uses a.out for binary images.
- pjmlp 5y agoActually they realized Alef was useless without a GC, hence why Limbo on Inferno, Plan 9's sucessor was GC based. Below taken from https://en.wikipedia.org/wiki/Alef_(programming_language) https://en.wikipedia.org/wiki/Alef_(programming_language): Alef appeared in the first and second editions of Plan 9, but was abandoned during development of the third edition.[1][2] Rob Pike later explained Alef's demise by pointing to its lack of automatic memory management, despite Pike's and other people's urging Winterbottom to add garbage collection to the language;[3] also, in a February 2000 slideshow, Pike noted: "…although Alef was a fruitful language, it proved too difficult to maintain a variant language across multiple architectures, so we took what we learned from it and built the thread library for C."[4]
- lerno 5y agoAnd if the idea is to extend C in some direction, that is what the language I’m working on does: C3 (http://www.c3-lang.org http://www.c3-lang.org)
- jeffrallen 5y agoIf you are exploring alternatives to the stdlib, you might commit yourself to no zero terminated strings and see where it takes you. A fundamental data type with a pointer, a length and a capacity does a lot to stop buffer overflows.
- guntars 5y agoTo replace C-style strings you only need the length! You also get cheap substrings which is such a common operation that it alone IMO makes it worth taking this route.