Posts
Elixir Challenges
Yesterday I finished all the Elixir challenges I had to do this week.
Today I’ll continue working on printf.
Posts
Structs & Agents
Yesterday I did an entire module of the Elixir basecamp I’m doing. I learned about Agents and Structs.
Today I’m gonna finish the challenges for that module and continue working on printf.
Posts
Home stretch
Yesterday I implemented formatting on everything except strings, and my printf is passing on 80% of all tests! I’m so glad this I’m almost done with this project.
I did learn a lot about structuring, debugging and refactoring, but it wasn’t a neat project with an intuitive solution: I spent a total of 70 hours running my code over and over again to make it match poorly documented and arbitrary specs.
Posts
Slowly but surely
Yesterday I did 4 challenges from my bootcamp. I also isolated and refactored a bunch of stuff in my printf.
I really like the current structure of the project: it’s extremely organized, easy to read, easy to test and easy to debug.
The most important thing I learned during this project is that C is very unforgiving to code smell. It’s easy enough as it is to get lost debugging something in well-written C code; debugging messy C code is so slow and tedious that you’ll likely put it off till never.
Posts
Formatting ints like nobody's business
Yesterday I finished the integer conversion with all the possible flag combinations. I’m very happy that part’s over and I’m pretty sure I’m 70% done: The other conversions are pretty similar to int except they have less corner cases, so it should be very easy to port my padding logic to them.
My flag parser ended up very robust with all the refactoring and restructuring. The last challenging thing I have left is handling all the flags for the %s conversion.
Posts
More flags than UNHQ
Yesterday I refactored my code according to the flag specifications in this documentation:
https://www.cplusplus.com/reference/cstdio/printf/ It simplified my parsing a lot and it’s helping me iron out the bugs better.
This is the best documentation on printf's flags that I’ve found so far and I wished I would have found it earlier. The community is helping out too and I’m managing to piece together.
I found this amazing article about how Discord used Rust to extend Elixir and optimize their notification system:
Posts
B-day
Yesterday I finished all the Elixir challenges from the bootcamp I’m doing. I also created a rails app to help me manage my studies (W.I.P):
https://github.com/librity/campus_code_study_on_rails Today’s my birthday and I took a few hours off to celebrate. I played Wind Waker and had a blast.
I made some good progress on my printf: I refactored lot of my code and it’s passing more tests.
I also learned that long and long int are the same thing:
Posts
Thread-safety
Yesterday I studied concurrency and parallelism in Elixir. I wanna do a C tutorial exploring these concepts as well.
Writing thread-safe code in C is extremely hard and almost outdated after Rust. Despite this, I believe there’s a lot of value to it: writing thread-safe code in C gives us a deep understanding of how computers work and how we can optimize them on different domains.
I also created a deploy-ready Hugo template repo: If you wanna get a static site up and running on Netlify without configuring a ton of stuff just fork and deploy it.
Posts
Tail-call optimization
Yesterday I learned about tail-call optimization in recursive functions:
https://dino.codes/posts/tail-call-optimization-in-elixir/ The long and short of it is we can use accumulator variables to cut the number of instructions executed on recursive calls. I’m gonna use an Elixir example since optimizations in C depend a lot on the compiler:
https://stackoverflow.com/questions/3514283/c-tail-call-optimization defmodule UnoptimizedSum do def call(list), do: sum(list) defp sum([]), do: 0 defp sum([head | tail]), do: head + sum(tail) end In UnoptimizedSum, we only start adding the values after the last sum() call:
Posts
Debugging my printf
Yesterday I fixed a lot of bugs on my printf. I’m pretty sure I’ll get it done by Wednesday at the latest.
I learned how to use valgrind and gdb to debug my code: They’re amazing tools and it’s saving me a lot of time.
Valgrind Quick Start GNU Debugger Tutorial You can run them straight from the shell or you can integrate them with your VSCode by following these simple steps:
Posts
42 Dev Diaries
Yesterday I decided to put all my daily updates on a static website with Hugo. I thought it was a good opportunity to learn the technology, and I’m really enjoying it. I also studied other techs and I wasn’t able to work much on printf.
https://gohugo.io/getting-started/quick-start/ https://42devdiaries.netlify.app/ Today I’ll continue working on printf.
Posts
Includes & Portability
Yesterday I made more progress on printf: It’s already handling all the flags except for the wildcard '*', which is the hardest. I also learned that some constant are located in different headers depending on the OS. A good example of this is ARG_MAX, that’s can be found in limits.h on macOS, and in linux/limits.h on linux. For portability reasons it’s a really good idea to check and include the system-appropriate headers in your projects, especially if you’re developing on linux (like I am).