Building my first website was fun. But I learned how difficult it is to build a website as soon as I tried to work without following a tutorial. I realised that I needed a more foundational knowledge of coding before I could build products by myself.
CS50 is a 12-week, introduction to code course led by Professor David Malan who taught (at the time) at Harvard in the US. You can sign up for free on EdX - I really recommend you do (I'm not being sponsored or paid to say so 😇).
It took me quite a bit longer than 12 weeks to complete the course. But complete it, I did, and I'm so proud of myself for doing so.
I learned how to write simple programs in C:
int main(void)
{
//Ask for user input
string name = get_string("What is your name?\n");
//Print user's name
printf("hello, %s\n", name);
}
The problem sets got progressively more technical. After a few weeks of using C, learning a little about pointers, linked lists and tries, we moved onto Python. (And I haven't looked at C since).
I found the learning curve from C to Python surprisingly difficult. It took me a while to "get" the syntax of Python and I'd wonder why lots of the forum posts I read online would say things like, "Python is so easy - you can almost write in English sentences". I found it strangely counterintuitive to think of code in terms of language a human (rather than a computer) might use.
For example, I couldn't get my head around loops. In C, I had got used to writing for-loops like the one below (which collects votes from X voters, where voter_count = X, and then compares the input of each user against the list of candidates):
for (int i = 0; i < voter_count; i++)
{
string name = get_string("Vote: ");
// Check for invalid vote
if (!vote(name))
{
printf("Invalid vote.\n");
}
}
This made a sort of sense to me since I could visualise the computer starting at i = 0, and incrementing up until the point that i = voter_count + 1, when the loop will stop (since all voters will have voted).
Initially I struggled to visualise Python in the same way. But using dictionaries and lists, I learned that Python is much quicker to code in. Lots is taken for granted with Python, so rather than declaring a function, vote() on name, I can just ask Python to iterate through the candidate list to check if a vote is valid.
*Disclaimer, I haven't run the Python script below. I'm fairly certain it will work, but let me know if you spot an error and I'll amend it.
for voter in voters:
vote = input('Vote: ')
if vote not in candidates:
print('Invalid vote.')
I now find Python much simpler to use. And have thankfully got to the point where I know how to search StackExchange for bug fixes!
I built a web application for my final project. My application allows users to register, takes their christmas gift wish lists and shares those lists with their friends. Their friends can then tick items off the list as they find them, letting others know that that gift has been found.
I learned an absolute tonne from building a working website, but mostly I learned:
I really enjoy coding and debugging
I don't enjoy setting up my integrated development environment or configuring my app to run on a server
I need to learn more about how Python works before I use it more seriously
for instance, I'm still not totally sure what some terms mean: "python shell", "$PATH" etc
I'll write specifically about my web app in another post on this website later.
For now, I'm happy with my (brief!) summary of CS50.