Comment by lelanthran

1 day ago

> Entirely built from scratch in C without any dependencies. Now I wrote this code when I was 16

Very few young folk are learning C; I think it is commendable that you are.

You code doesn't seem very strongly structured (to be expected, TBH) but much better than any learner would see.

What resources did you use to start learning C? I ask because it looks to me that those resources covered "how to program in C" but not so much design and structure.

Here's two links (my own blog) to get you started on one or two common C patterns designed to minimise bugs:

https://www.lelanthran.com/chap9/content.html

https://www.lelanthran.com/chap13/content.html

Hey, thanks for your comment :) I had a look at your blog, it's looks really useful and high quality! I will go through it with vim open on the side and a nice coffee

Yeah and I'd agree with your point. One BIG critique I have for my own 2-year-past code was that I did not know how to do dynamic heap allocation very well, hence you may have seen everything is stack allocated lol

Particularly egrigeous example:

  typedef struct ListingItem {
    char lTitle[CONFIG_MAX_PATH_SIZE];
    char lDate[CONFIG_MAX_PATH_SIZE];
    char lContent[CONFIG_MAX_FILE_SIZE];
    char lPath[CONFIG_MAX_PATH_SIZE];
    int lOrder;
  }  ListingItem;

(I had read "clean code" by uncle bob at the time, so I was trying to emulate clean code I saw in the book. Needless to say, pretty good example of the nuance needed when writing clean code haha)

So with the V3 release, I am re-writing the markdown compiler for instance, and being a bit more mindful of the structure

Example: https://github.com/Aadv1k/kevlar/blob/markdown-compiler-rewr...

I think once I am done I will create a separate "Show HN" post to get valuable feedback (like this one!) from smarter folks than me. Once again, thanks for the fantastic blog :) will be sure to go through it

Cheers!