It's been two evenings I'm trying to code again and... nothing despite my motivation. I've wanted to use this big break to start again some projects in C but I don't have the mindset right now. Maybe I need a bigger break to recharge my brain.

@thomasorus @metasyn What are you having trouble with? What kind of projects are you aiming for? I love C, warts and all, and I would be happy to help rekindle the spark if I can :)

@bd @metasyn I’m trying to redo a text parser with bits of syntax inspired by markdown. I can read each line of a file and detect the symbols but I’m not sure how to capture the content between them.

@thomasorus @metasyn Right, I would suggest that you read it character by character and have a way of "peeking" the next character and checking the previous one or having a way of coming back to a previous point.

For example let's say you have this and you want to capture the link:

"Find the link [here]("

You would read until you find the symbol '[', storing this position and continuing until you find the closing bracket ']', then, if the immediate character is '(' you know you have a link and can do the appropriate transformation to it.

There are more complicated approaches like AST but you may not need them for your application.
@thomasorus @metasyn The simplest option is to read the entire file into a buffer, so that you don't have to worry about memory allocations and then you just keep pointers for moving around.

@bd @metasyn Thanks for the tips, gonna try this! I've tried a version in JS with an accumulator and I had a hard time making it work (I'm more a design + html/css guy), it's time to try again!

@bd @metasyn It's a whole new adventure to code in such a language but it's fascinating and it feels like "the right thing" to do. 😅

@thomasorus @metasyn Well you should always use the right tool for the job, so doing it in JS is also fine if that is the application domain ;)

In a way it can be simpler once you understand the fundamentals, since procedural code tends to be much more straightforward and without "magic" that do things you don't expect or understand.

@thomasorus have you checked out nim? statically typed, compiles to c, fun to write, fast and free, etc ... however...

it's more important to choose what is right for YOU than what other people tell you to do, or whatever is in vogue in merveilles (or elsewhere). i am skeptical of lots of things but trying new programming languages for fun isn't one of them for sure haha

at the moment end of the day, PL are just ways to get something done. if you enjoy it and can do it fast enough... ✨🌺💚💅

@metasyn Well there are a lot of languages and things to try that seem fun! The thing is, I want to cultivate myself on a low level language by doing a real project on it and C seems like a cool challenge. If I don't enjoy it in the end I'll just redo it in my language of choice.

@thomasorus @bd @metasyn I’ve got a very naive markdown to gemtext converter I wrote in C which has my solution to the problem at least... I can send you the code for it for reference if you’d like because it’s mercifully short.

I mostly tried to go for ruthless resource efficiency, terseness and making it pass valgrind and with warnings dialled up to 11 on clang and.

Really not a C expert myself though!

@thomasorus @bd @metasyn

You can either `make` or just read the contents of it out of the beginning of `to_gem.c` - I kinda tried out some weird things with this because I didn't think anything would ever use it :P

But yeah, the code's all in one file with the docs, and I appear to have documented all of the functions!

Sign in to participate in the conversation

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.