< More Posts
CS50: Week 1
Published 04 July 2020 at Yours, Kewbish. 1172 words. Subscribe via RSS.
Also published on Dev.to.
Well, it’s been a week since I muddled my way through Scratch and the first week of CS50, and I’ve just about finished Week 1’s problem set. This week, I was introduced to the scary world of C, and the basics of how to use it. As well, we went over how to translate common Scratch recipes to C, and some basic information regarding memory and imprecision, as well as some C examples.
This was where I actually started paying attention to things - while the first couple weeks seem pretty easy, I know they’re going to become the most useful for laying a proper foundation for the more difficult weeks ahead. So, I sat through the hour and forty-six minutes, and delved into the world of C.
Below are my notes1 :
- So what - we’ve established that C is extremely verbose compared to my beloved Python, but now what?
- There are brackets everywhere
- Don’t forget semicolons
- style50 demands this terrible bracket style where the bracket is on its own line2
- You initialize variables with a specific type
- C is statically-typed, unlike Python
- can’t randomly change types midway through the program
- causes a lot of ‘filler’ variables to be made, as well as loops to convert between types, like ints to strings
- C doesn’t have list comprehension, use for-loops
- By the way, their for-loops are like ‘normal’ for-loops
- Completely different from Python for-loops
- less intuitive for looping over objects, but easier for array elements
- Can’t dynamically append to an array
- need to make a counter of some type to find the length of things
- alternatively, for strings, use
- arrays need to be initialized with a certain size, memory allocation things
- We input things with
get_string(), which is part of the CS50 header library
- lots of functionality and sanitization in the CS50 library
- And also, headers are included, not imported
- if it’s in "" quotes, it’s a relative import
- if in <> brackets, it’s somewhere in the depths of the C library compiler
- Scratch did come in handy, liked the translation examples
- String formatting is extremely weird
- Need to specify the type, and use % formatting
- remember what type the variable is before formatting it
- Imprecision is one of those things that I always forget
- In cash, remember that float imprecision exists
- Make is pretty awesome, complete with commands and all those cool things
- I’m trying to set a custom
cs50makecommand in my bashrc instead, but I can’t seem to figure it out quite yet
- I’m trying to set a custom
- For problem sets - do your own research
- I get starting blocks, but after, I’m kind of on my own
In PSET1, you have the option of doing Mario Less or More, and Cash or Credit, based on your experience and comfort with C and programming. I, personally, found the ‘more challenging’ problems more fun to complete, and found that they taught me more of C’s language features, like arrays (even tho we haven’t even been introduced to those).
I would recommend doing both the less and more versions of the problem sets. Usually, (like Mario) the ‘more’ problem sets build off the ‘less’ sets, so they were more or less required to do anyhow. As well, you get more practise, and I find that practise extremely useful, especially when learning such a new language.
As I mentioned in my notes, I guess the differences between lecture and problem sets gets bridged by the shorts and notes, as well as a good amount of Stack Overflowing.
I absolutely hate the IDE. Maybe it’s just because I’m used to Intellisense and whatever cool things that VSCode provides. One example? VSCode allows you to surround things in brackets and quickly use a bunch of keyboard shortcuts, whereas in the CS50 IDE, doing the same commands just delete and do nothing, respectively.
Setting CS50’s CLIs and header files up on WSL were pretty simple, and they’re useful for running check50 and other things up on my own. Also, can we talk about check50? Why do they feel the need to UPLOAD to GitHub first? It’s extremely annoying to mess up my Git commit graphs. But anyhow - still trying to figure out my bash.
So anyway: VSCode, WSL, and Git for the win, CS50 IDE is bad. I like how they make getting started easy for less technically-focused people, and saves a lot of time regarding getting set up. Without it, I know it would have taken a lot longer for my cadre to get started. I really appreciate how it gets everyone up and started quickly.
Teaching Style + Misc.
To be honest, I’d kind of skipped over the shorts for Week 0, but for Week 1, they really came in handy. Going through those as well as rereading notes was probably how I managed to figure out a bunch of things regarding the problem sets.
They never mention it, but checking out some of the source behind the CS50 libraries and doing a couple Google searches was equally useful. Of course, this probably wouldn’t help for people who don’t know where to find it, but stalking various GitHub repos was a fun waste of time / help.
And finally, it’s time to extol Malan again. Extremely clear, though there’s a bit of fluff and relatively ‘unuseful’ information. I wish they’d split up the videos, wait no. They already do that. With chapters. And transcripts. And snacks. I love how CS50’s staff take their time to make the online CS50x just as wholesome and inclusive as the IRL CS50, even taking the next step to build in a snack chooser in their viewer. (Which, by the way, has a bunch of amazing screenview / normal view, shortcuts, and tonnes of other features. I love it. Perhaps I’ll go look at the source somewhere.)
It’ll be a fun couple weeks - it takes longer than I thought to properly write up notes, listen to lectures, do problem sets, and write the words you are reading right now. It’s a little repetitive, so maybe I’ll take a week to speedrun some problem sets, and then write a batch of blog posts at once. Anyway, I’ll find a more efficient way to do things.
In terms of life, I’ve been doing some maintenance on diveintoht.ml, adding a new HTML id’s section and working on a forms section. I have tonnes of ideas for future content, but I’m thinking that it might be a bit much for this introduction. They’ll probably become other projects - maybe an ebook or another guide site. (I have ideas for monetization, but then again, no one will pay for my work :pensive:). We’ll see what I have time to develop.
MLA: Ma, Emilie. "CS50: Week 1." Yours, Kewbish. n.p., 04 Jul. 2020. Web.
APA: Ma, E. (2020, July 04). CS50: Week 1 [Web log post]. Retrieved from https://kewbi.sh/blog/posts/200705/
UBC citation style.
- Yours, Kewbish
< More Posts