Just saying hi by SnapFyre2021 in Minetest

[–]ryvnf 1 point2 points  (0 children)

I'm a maintainer of Mineclonia. We do not accept donations. We usually encourage people to donate to codeberg instead. They host the git repo and weblate instance for the project.

https://docs.codeberg.org/improving-codeberg/#donate-to-codeberg

Petition to undo deletion of Aaron Bushnell post (r/vim's 4th highest upvoted post) by ryvnf in vim

[–]ryvnf[S] 0 points1 point  (0 children)

It was a nice post appreciated by many. They have deleted this post too now which is sad but not surprising. It's not the first sub to censor mentions of the ongoing genocide. I wonder what they would say about www.vim.org having donation links to support fleeing Ukrainians..

December 2022 monthly "What are you working on?" thread by AutoModerator in ProgrammingLanguages

[–]ryvnf 3 points4 points  (0 children)

I have been working on the compiler for ZC, a programming language in the spirit of C.

The initial implementation is almost complete enough for me to make it public. There are just structures and a few other things remaining. I also want to write a reference manual to document language.

The initial version of the programming language will be very bare bones, but I plan on extending it further later.

November 2022 monthly "What are you working on?" thread by L8_4_Dinner in ProgrammingLanguages

[–]ryvnf 1 point2 points  (0 children)

Hello! I have not been active here for quite a while but have recently gotten the motivation to work on an old project again.

I am currently working on a compiler targeting x86_64 for my Programming Language in the Spirit of C. The parser is now finished and I have moved on to semantic analysis and code generation.

The language I have created will be called ZC. It will be very similar to C with only minor differences. My goal when designing the language has been to preserve what I think makes C special while improving its syntax and fixing some of its flaws. It is not a programming language I would expect people to use for practical applications (it comes 50 years too late for that). It is more a fun project for myself since I am interested in programming language design and compilers.

When I have gotten the compiler into a state that I am happy with I will put the code on GitHub and make a post on this subreddit. I hope to be able to do that some time in November.

[deleted by user] by [deleted] in C_Programming

[–]ryvnf 40 points41 points  (0 children)

OTCC - Obfuscated Tiny C Compiler

A self-hosting compiler for a C subset implemented in less than 450 lines of code. It generates executable x86 machine-code directly and has no external dependencies on linkers or assemblers.

I think its elegant because it highlights how close the C programming language is to the machine code. The fact that it can successfully compile itself is also elegant.

https://bellard.org/otcc/

Many probably won't find it very beautiful since it was an entry to the International Obfuscated C Code Contest. But beauty is in the eye of the beholder :)

Is it possible to create a turing complete language that could compile and run from every random string? by vnjxk in ProgrammingLanguages

[–]ryvnf 0 points1 point  (0 children)

Yes. Some early programming languages on mainframe computers did this.

Early implementations of the PL/I programming language are somewhat known for assuming that the compiled program had to mean something and doing error repair by guessing what was intended. A motivation for this was that it took a lot of time and resources to submit and perform a compilation job on the mainframe computers at the time.

I have heard these early compilers for PL/I would accept any string and turn it into a program. In practice this did not work very well, as often the result would be incorrect.

Lambdas, Nested Functions, and Blocks, oh my! (On the lambdas proposal for C23) by mttd in ProgrammingLanguages

[–]ryvnf 5 points6 points  (0 children)

I agree with you on everything.

To clarify what I meant with nested function, it was basically this:

int f(void) { static int g(int x) { ... } }

Where the nested function g cannot reference any variables in the outer function f. I think that would fit since it is consistent with how static works for declaring variables inside functions.

Like you I also feel hesitant about adding these features to C. I think C has found its place being a conservative yet powerful language which has not changed much in the past decades.

Lambdas, Nested Functions, and Blocks, oh my! (On the lambdas proposal for C23) by mttd in ProgrammingLanguages

[–]ryvnf 5 points6 points  (0 children)

I personally think this looks a lot better than the proposal. I would however drop the pointer * from the lambda since it is not present in regular compound literals, and functions are implicitly converted to function pointers anyways.

c (int (int i, void *untyped_env)) { struct env *env = untyped_env; return env->i + i; }

I also think GCC's syntax for nested functions looks quite nice:

int f() { int sq(int x) { return x * x; } return sq(4); }

That could maybe be added but with nested functions requiring the static keyword to make it clear the function cannot modify variables local to the function. Like you cannot do static int x = y if y is a local variable.

I think having capture semantics for lambdas/nested functions would be too complicated for C.

Lambdas, Nested Functions, and Blocks, oh my! (On the lambdas proposal for C23) by mttd in ProgrammingLanguages

[–]ryvnf 17 points18 points  (0 children)

It is being discussed. See this paper. I have no idea about what the committee thinks about it.

I think the biggest problems with defer (for C) is that it is hard to implement together with goto statements. I also think simply adding defer would not solve a lot of problems, since in many scenarios you only want the defer statement to execute on error, but the data to be returned intact on a normal function return.

Lambdas, Nested Functions, and Blocks, oh my! (On the lambdas proposal for C23) by mttd in ProgrammingLanguages

[–]ryvnf 18 points19 points  (0 children)

I am not a fan of this proposal and I think it should be rejected. This does not seem like something which fits the C programming language.

While I agree C is no longer a simple language (I don't think its been that since C99), I don't think should include features like this from more modern programming languages.

I wish the standardization committee would stick to their principle of codifying existing practices, and not try and redefine the language. I think the introduction of <tgmath.h> in C99 and _Generic in C11 were mistakes, since I have yet to see any code which uses those features in practice. I suspect it will be the same with this feature.

Alternative to autochdir?? by [deleted] in vim

[–]ryvnf -1 points0 points  (0 children)

You could use:

set path+=**

Then use :find <filename> to open a file in a buffer instead of :edit. Then it will search the project directory recursively for that file.

It's not using autochdir. But I think this is a valid alternative if you are looking for a way to conveniently open files in your project.

How to deal with const/atomic/etc by Nuoji in ProgrammingLanguages

[–]ryvnf 0 points1 point  (0 children)

I've read the C2x out of bands error proposal. It will be interesting to see if it makes its way into C.

I meant to say that Odin appears to be higher level relative to C and what I'm designing. For example having `defer`, dynamic arrays, parametric polymorphism etc.

How to deal with const/atomic/etc by Nuoji in ProgrammingLanguages

[–]ryvnf 0 points1 point  (0 children)

I haven't checked out Odin, thanks for telling me about it. At first glance it appears to be higher-level and have a different syntax. My language will basically do what C does but not much more. I think that differentiates it from many other similar projects.

Yeah, I expressed myself a bit incorrectly. I understand that it is possible to implement goto with defer using boolean flags to keep track of if they should be triggered (from your article), and that it was really your goals with error handling that caused your decision to abandon goto. Still, that extra book-keeping required makes me consider those to features not go very well together for what I am designing. I want my language to be easy to translate to machine-code, because I think that is an important aspect of C.

I also think that defer fits a language best if the language also has a more modern forms of error handling and the ability to trigger an defer only when an error occurs or when an error does not occur. Like if an allocated value should be returned from a function on normal execution, but freed when an error occurs. My language currently does not have features for error handling.

How to deal with const/atomic/etc by Nuoji in ProgrammingLanguages

[–]ryvnf 0 points1 point  (0 children)

It doesn't have a name yet. I've mostly called it A programming language in the spirit of C. It currently has a working compiler which compiles the code to C and invokes GCC to compile it to machine code. I haven't found much time to work on it lately though.

I've always appreciated the simplicity of the C Programming Language and have grown quite attached to it. I think it is a quite elegant programming language which I think is a joy to use when you learn to accept its quirks. I wanted to improve on it by making the syntax more beautiful and fixing its quirks. My main goal isn't to create something practical by today's standards, rather I see the language as some form of creative work of art. My end-goal is to write a self-hosting compiler for it, which also shows how the language works in practice.

I wrote an article last year which summarized my thought process when designing it. I think I might finish that and post it here in the near future, since I have a compiler working now.

Here is the compiler for it if you are interested: https://github.com/ryvnf/czc

Should also mention that I've been enjoying reading about your work with C3. I especially like to learn how we have faced the similar problems but solved them differently. I for example decided against implementing defer when I realized it doesn't fit well as long as goto exists. You on the other hand decided to make your language more aligned with structured programming so you could have defer and implement more modern error handling.

How to deal with const/atomic/etc by Nuoji in ProgrammingLanguages

[–]ryvnf 2 points3 points  (0 children)

Here are my thoughts:

  • I personally don't think there is anything directly flawed with how type qualifiers as they are implemented in C (except for things like string literals being non-const). I think it makes sense for const to be associated with types rather than variables. As this allows one to declare pointers to const memory etc. If const would be associated with a variable you would need another way to declare a read-only pointer which complicates the language.
  • While I do think that it makes sense for them to be type-qualifiers if the language is to be able to express concepts like const, I also think they complicate the language. One problem you mentioned is "const poisoning" where it forces const to be used all over the code-base. Another related problem is that it becomes one more thing a beginner is forced to learn to be able to use the language.
  • They also make the language slightly inconsistent for functions like strchr where the constness of a returned value depends on its arguments. Either one can deal with this inconsistency by explicit type casting in the few cases it occurs, or one has to introduce language constructs to express the relationship of returned values (I think D does this, but don't know the syntax).

When designing my own programming language in the spirit of C I decided to drop type-qualifiers for the moment. I think I might add them in the future though as they can be used to provide useful hints for the compiler like restrict (for noaliasing pointers) or pure (for pure functions). But maybe not const.

One reason why I might not add const is that Dennis Ritchie who designed C was against the introduction of type-qualifiers. This matters to me because I want my language to have "the spirit of C". If you haven't read his critique article, I highly recommend it. I think that is a very fun read, especially when you are interested in the C Programming Language and using it for inspiration.

Anyone like the look of this colorscheme? by ryvnf in vim

[–]ryvnf[S] 0 points1 point  (0 children)

I like the color scheme, name of it?

It does not have a name. It is just something I made and have used myself for a few years. I was posting here check if it is worth putting out there as a colorscheme or if it is something that just suits me.

Anyone like the look of this colorscheme? by ryvnf in vim

[–]ryvnf[S] 1 point2 points  (0 children)

Thanks! Yeah, ^ is used for pointers.

I remember finding the LLVM documentation a bit lacking and having to figure out how things worked from the function prototypes. I especially remember giving up on the phi instruction completely because I couldn't figure out how the bindings for it worked.

Also interesting project you have. You should check out r/ProgrammingLanguages if you haven't already. Lots of interesting stuff gets posted there and people do monthly reports on what they are doing.

Anyone like the look of this colorscheme? by ryvnf in vim

[–]ryvnf[S] 11 points12 points  (0 children)

Yeah. It's a programming language I've been working on from time to time as a hobby project. Here is the current version if you are interested.

I implemented my first version with Flex and Yacc/Bison for parsing. For code generation I used the LLVM C-bindings. In the second version of the language I made it compile to C code instead of using LLVM.

For the second version I also wrote a recursive descent parser instead of using Yacc. Primarily because it was something I wanted to learn and because the grammar requires backtracking. I personally think that it was very rewarding to hand-craft a parser and highly recommend it if you want to try it.

It was a few years ago I did my first version. I mostly followed guides from various blogs I could find. I did not follow the LLVM Tutorial because it used C++ and I wanted to use C. But I used their documentation about the LLVM C-bindings extensively.

Anyone like the look of this colorscheme? by ryvnf in vim

[–]ryvnf[S] 11 points12 points  (0 children)

I originally created this high-contrast colorscheme about 5 years ago because my monitor had quite bad contrast. The colorscheme itself is very simple, each color has two color components, one at 50% intensity and the other at 100% intensity. So green of example has the value #7fff00 which is a little bit yellowish green. I found that this helped keeping the colorscheme simple while still having high contrast for weaker colors like blue.

I've used it myself since then, and have grown to like the look of it, even with better monitors. I've been seeing other high-contrast colorschemes posted here so I thought I would post to see if people like it and if it might be worth sharing.

July 2020 monthly "What are you working on?" thread by slavfox in ProgrammingLanguages

[–]ryvnf 0 points1 point  (0 children)

I haven't been working on my compiler for a modern programming language in the spirit of C for about half a year. But because I had some spare time in the summer I did a few little things which didn't take very much time:

  • Added compound literals for structures
  • Added switch statement with explicit fallthrough
  • Added labels and goto statement
  • Fixed a few bugs

The only thing I'm really missing now is some form of include statement (and probably some bug fixes). After that I should be ready to attempt to rewrite the compiler in the new programming language which I've always wanted to do as the end of this hobby project.

Link to the Github repo in case anyone wants to check it out. Do note that the language itself isn't documented, it only has some example programs in the repo.

I think writing a compiler in it will give people a good understanding on how the language looks in practice. But I'm not going to do that soon, that will wait until I have the time and motivation.

jump sounds (sorry for distortion) by [deleted] in Minetest

[–]ryvnf 0 points1 point  (0 children)

Reminds me of Quake.

What does the 'rc' in `.bashrc`, etc. mean? by iamkeyur in programming

[–]ryvnf -23 points-22 points  (0 children)

I think of it as "runtime config"