Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

C is a great language, for fun I'm slowly working on my own highly C like langage - https://github.com/g-programming/glang.

Its basically C with Go like syntax, and a package system instead of headers. I aim to fully interop with existing C code and have no runtime requirements beyond what C has.

I'm not trying to go crazy with extra features over what C has though. An important part of what will make it work, is perfect interop with existing C code.

Yes I understand memory safety issues, but there is always a need for machine independent assembly languages. which C essentially is.



Unfortunately, no one will agree exactly on which aspects of C to change and which to keep - that's why we now have hundreds of languages used by less than 10 people each.

E.g. while I applaud the idea, I found many aspects of your example code snippets ugly and un-C-like. This is not to say that I'm worthy of judging your work, but that a) so much of it is a matter of taste rather than objective thought and b) humans can adapt to literally anything, given time to get used to it.


They are closer to Go than C I admit. Many languages are actually shifting to grammars similar to this for a few reasons. At the very least the grammar is less ambiguous, and its easier to code editing tools to recover after parse errors.


You are not alone. Here is some guy doing something similar but his syntax is not so heavily inspired by Go (but still steps forward): c2lang.org


c2 has simlar syntax and ideas :). Looks cool. I have a few other ideas that I think will differentiate later.


This is really cool, but what about porting the go standard library to C instead? Will this make that easier? Does the ABI of g meet C's?


G will use llvm as its primary backend, and my intention follow the C ABI exactly so interop requires no work.

I haven't considered the standard library much beyond the fact that I would G to have its own that is inspired by the good parts of other languages. At first it would have to rely on C libraries.

G won't be able to support every way that the Go standard library works. But if you need everything Go has, then you probably want to use Go to begin with.


Your project sounds very cool. Will it have the Go methods and interfaces system too?


I think its important only add those things after the language can run the same sorts of programs C can currently.

For the future, some of my ideas include:

a form of combined data types that require a type-switch to disambiguate (and is checked by the compiler), like algebraic data types. (essentially sugar over tagged unions)

It may also have a form of defer blocks similar to Go defer statements. (sugar over the C idiom goto cleanup;)

A final thing I considered was a built in reference counted pointer type. Just to partially alleviate memory management, but without resorting to a garbage collected run time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: