June 5Th 2025
June, 2025
Today I came across a brilliant website called CodeCrafters: https://codecrafters.io/
It walks you through building something like a terminal or an http server in almost any language without spoon feeding you. The brilliance lies in the UX. As the developer, you set up a git repo and push your changes. Code crafters is synced with that repo and for each step in the project runs unit tests.
It has nothing to do with the actual code you're writing, just the outcome of the code. AND THAT'S BRILLIANT! The fact I can go through this tutorial and someone else goes through it and we end up with entirely different projects that function the same way is incredible. This actually teaches you to solve problems.
Anyways I'm using it to learn the C programming language. I'm getting into the Synthetic Biological Intelligence space and a lot of companies require knowledge of system development in their software development positions, so I'm teaching myself.
I'm about 14% of the way through programming a shell from scratch. I recorded this video of myself programming, but I ran out of computer space about halfway through my session today.
You can watch it here: https://youtu.be/71YMGnYdSfk
Here's my entire script so far:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
setbuf(stdout, NULL);
while (1)
{
const char* pathValue = getenv("PATH");
if (pathValue != NULL) {
printf("PATH: %s\n", pathValue);
} else {
printf("PATH environment variable not found.\n");
}
printf("$ ");
char input[100];
char input_copy[100];
fgets(input, 100, stdin);
input[strcspn(input, "\n")] = 0;
char *arguments[4] = {};
strcpy(input_copy, input);
char *token = strtok(input_copy, " ");
int argument_index = 0;
while (token != NULL)
{
arguments[argument_index] = token;
token = strtok(NULL, " ");
argument_index += 1;
}
if (strcmp(arguments[0], "exit") == 0)
{
return 0;
}
else if (strcmp(arguments[0], "echo") == 0)
{
printf("%s\n", input + 5);
}
else if (strcmp(arguments[0], "type") == 0)
{
char *builtin[] = {"exit", "echo", "type"};
int found_match = 0;
for (int i = 0; i < sizeof(builtin) / sizeof(builtin[0]); ++i)
{
if (strcmp(builtin[i], arguments[1]) == 0)
{
printf("%s is a shell builtin\n", arguments[1]);
found_match = 1;
break;
}
}
if (found_match == 0)
{
printf("%s: not found\n", arguments[1]);
}
}
else
{
printf("%s: command not found\n", input);
}
}
return 0;
}