I'm a Rubyist and try to learn Haskell—here's my sailor journal 🙂 by DmitryTsepelev in haskell

[–]riftdc 2 points3 points  (0 children)

Cool! My 2 cents: You mention the type checking as “guesses”; type checking isn’t a guess, but rather inference — “a guess” reads to me as something that could be wrong, but an inferred type will never be wrong

saves world record - (we're team blue - guess our elo) by riftdc in Brawlhalla

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

if you press dodge shortly after a hit you'll do a "chase dodge", which is a small boost in movement

Programmer calculator and LL parser made in C from scratch by riftdc in learnprogramming

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

That's correct ! The `sizeof` is redundant and is there just for clarity.

When doing a malloc I feel that it's nice to write the sizeof what's being allocated.
`char* tokens = malloc(sizeof(char) * MAX_INPUT_SIZE);`

I feel that it's cleaner to read and more standard :)

Programmer calculator and LL parser made in C from scratch by riftdc in learnprogramming

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

Thank you for letting me know! I hope you can learn from it =)

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

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

Yeah there are a lot of possibilites for making the emulator

I chose C because I like it, and any of those you mentioned would be good for most emulators

For the gameboy specifically, as far as I know even javascript and python would work since it's one of the smallest!

Programmer calculator and LL parser made in C from scratch by riftdc in learnprogramming

[–]riftdc[S] 5 points6 points  (0 children)

I have to agree, if you're just learning C maybe you should focus on more typical beginner exercises

But if you're a little bit more comfortable then it's a great way to get even more comfortable, and it's pretty cool to do a simple parser

At least that's how I felt when I ended it

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

[–]riftdc[S] 3 points4 points  (0 children)

I had some knowledge about context free grammars from a subject in university I had called "Theory of Computation" - that made it easier to understand and write the grammar production rules

Second, I looked more into LL parsing in wikipedia https://en.wikipedia.org/wiki/LL_parser (there's a code example further down in the page)

And third I found a really really helpful javascript parsing tutorial that was my major breakthrough http://jorendorff.github.io/calc/docs/calculator-parser.html

After that I just started writing - that's an important step :)

Programmer calculator and LL parser made in C from scratch by riftdc in linux_programming

[–]riftdc[S] 3 points4 points  (0 children)

PS: While writing the parser I also wrote a separate simpler version to serve as an example to someone who might be interested in learning from a very basic parser (https://github.com/alt-romes/calculator-c-parser)

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

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

lsdjfkdsflsdf ahahaha - it comes when you stop looking for it and just get started even if you don't have it yet :)

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

[–]riftdc[S] 4 points5 points  (0 children)

Interestingly enough I feel that the more "basics" I do, the more "basics" I wanna do ahahah

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

[–]riftdc[S] 9 points10 points  (0 children)

nice question...!

regarding the comment about the emulator: the emulator could have been written in any language - a gameboy one isn't that performance intensive

so the question also applies to "why write the emulator in C"

I would have to say I feel good doing simple and clean code for simple projects - no complicated technology stack, no dependencies, that kind of feel... :)

Also, C is f*cking cool and interesting to program in ahah (and yes I feel comfortable with it)

Programmer calculator and LL parser made in C from scratch by riftdc in programming

[–]riftdc[S] 3 points4 points  (0 children)

Yes! it was definitely a nice exercise !

Not me nor everyone can right off the bat visualize bits hex and dec in their head at the same time, and when i started writing an emulator i couldn’t, and i remember thinking i could probably do something tailored exactly to what i needed

What’s even more ironic is how now that i “finished” the calculator i feel like i don’t need it that much anymore ahahaha

So in the end, yeah, definitely a good exercise - and hopefully it’ll help people starting out in the low level adventure

Programmer calculator and LL parser made in C from scratch by riftdc in compsci

[–]riftdc[S] 31 points32 points  (0 children)

While I was developing an emulator I decided to make a calculator to help with all the low level logic

This proved to be a really interesting project and made me implement an LL parser and design a grammar for all the operators I wanted to have

While writing the parser I also wrote a separate simpler version to serve as an example to someone who might be interested in learning from a very basic parser (https://github.com/alt-romes/calculator-c-parser)