DEV Community

Cover image for CS50 Journal : Week 0
Dionysia Lemonaki
Dionysia Lemonaki

Posted on

CS50 Journal : Week 0

Computational Thinking, Scratch

So I am finally embarking on the journey that is CS50. And these are my notes from week 0.

After a lot of hesitation and a lot of saying to myself that 'I'll do it at some point, just not now, it's not the right time' I came to the conclusion that 'You know what? Right now is the best time'.

I was doing tutorial after tutorial and they have been holding my hand during my coding journey so far.When the time to practice codewars came, I was taken aback by my inability to do even the most seemingly "easy" ones. I stumbled, I got frustrated and realized that I can't solve problems to save my life. When face to face with a coding challenge my first instinct is to panic and want to be done with it,solve it immediately with the first try and move on to the next thing.Now that is some unrealistic expectations right there. It doesn't work that way.

My brain associates them with Math class during my school years and I feel like I get PTSD when remembering that I was told 'You are just terrible at maths, you can't do anything science related' by my teachers. I want to work on that and change that mindset and fear.

So I taking CS50 to work on my problem solving skills and gain an understanding of the fundamentals. I am hoping that by the end of it I'll feel more confident and learn new skills that will serve me in the future.

Should you do it? Yes. The course starts off by saying that 2/3 of CS50 students have never taken a Computer Science class before. So if you come from a non-technical background or have little to non programming experience this course is for you too.

My favourite quote mentioned in this week's class was :

What matters in this course is not so much where you end up relative to your classmates but where you end up relative to yourself when you began

Write that down somewhere where you can see it everyday.

Even more,it is mentioned that the course is less about programming itself and just learning to code. It's more about problem solving. The principals learned on the course can be applied to any area of work and even life itself.

amen

First Impressions

I'll start off by saying that it's a state of the art production.The visuals, the video quality,the cinematography-it could easily be a TV series-,the notes available, the assignments,the website itself. It shows that a lot of work has been put into it. The teacher,David J. Malan, is just amazing. His energy is infectious,he is thorough with his explanations and he doesn't assume any previous knowledge.He is engaging and manages to keep your attention throughout the class.He clearly loves what he does and that comes across.

Talk binary to me

So what is the essence of Computer Science? Problem solving. And what is problem solving? Taking details, information about a problem (input), and generating a result, a solution to that problem(output). Everything in between that process is the magic that happens or else the code that we'll write. The picture below was used to illustrate this point :

Input-output

However to get to that stage, a common language has to be used in order to represent those inputs and outputs. Computers have the ability to store all kinds of information from numbers to letters, sounds, videos and images. But how are all of these represented in a standardised way?

For representing numbers we are already familiar with two numeral systems:

  • The unary system ( e.g. one finger to represent one thing)

  • The decimal system(or base 10) which consists of 10 digits from the numbers 0-9.
    An example was used to illustrate this,the system we learned in school and now we just do mental math and don't really think about the process behind it.Say we have the number one hundred twenty three, 123. How did we get to that number?

Each place for a digit represents a power of 10 since there are 10 possible digits for each place(102 101 100)
The 3 is in the ones column(100)
The 2 is in the tens column(101)
The 1 is in the hundreds column(102)

So the math we do now without even thinking is 100*1 + 10 * 2 + 1 * 3 = 123

This is all great for us humans,but computers speak binary. All this information is stored in that language, a numeral system that has only two digits 0 and 1.

Instead of the base 10 system used above,we can use a base 2 system where we have powers of 2 for each value(22 21 20)
Examples: the number 1 in binary is 001
The number 2 in binary is 010
The number 3 in binary is 011
The number 4 in binary is 100
The number 8 in binary is 1000

binary

Each 0 and 1 or otherwise binary digit is called a bit.

All of the above make sense when we think that computers operate on electricity and need only 2 values, to determine whether they're on or off, or otherwise true or false or now we speak binary 0 or 1.

So far only numbers have been mentioned, but computers can do more than just calculate and crunch numbers. How is it made possible for us to read text, emails, watch videos and listen to music on our computers when they speak binary and save data in patterns of 0s and 1s ?

In order to represent letters we have to map numbers to those letters. That is achieved with a standard mapping named ASCII.For accent marks and emojis there is another standard named Unicode.
So what happens when you send your friend an emoji πŸ‘½ ? The computer receives a pattern of numbers in binary which it then maps to the image of that emoji based on the Unicode standard.

Emojis are essentially images and speaking of that,videos are also a sequence of images flying by on the screen rapidly.The same with my personal favourites: gifs. They are looping images moving endlessly.

mr bean

So, whether it's numbers,text or images, whatever the medium used to display data and information, it all comes down to binary : 0 and 1.

Essentially the representation is the same,the patterns are the same, the mapping content to 0 and 1 is the same, just the context changes.Whatever media we use to display information it all always reduces to 0 and 1.Computer programs know from the context of the code whether those binary numbers should be interpreted and then represented as numbers,letters or pixels(it depends whether we open an email,an image file or a spreadsheet).

Algorithms and Coding essentials

When it comes to problem solving we can use our existing intuition in order to approach them.We just need to translate that intuition in a way that computers can understand. Looking back to the picture from the beginning,We are now able to represent inputs and outputs but what about the magic that happens in between, that black box? That is where algorithms come in.

They are step by step instructions for solving problems.Not only do they have to be correct, precise and efficient but they need to be well designed too.

So to represent and implement those algorithms we can write pseudocode. It has code-like syntax,representing ideas in a more specific version of English. It can be used to write a more simple version of our code in plain English before using an actual programming language to implement those ideas. It represents the way we are thinking and it is readable.
Why use pseudocode? The key reasons are the fact that you are not focused on getting the syntax correct.Instead your main aim is to solve the problem in a logical manner.Also,it helps to break down big problems in smaller,more manageable steps.

When writing pseudocode,we can implement certain coding concepts in plain English.The verbs or actions used to start a sentence get the computer to do something(functions). The if, else if,else statements which essentially lead to different paths and decide what it is we'll do(conditions).The questions we need to answer in order to make the above decisions which their answer is either true or false(boolean expressions). The repetitive cycles of doing something again and again(loops). All of the above boil down to implementations of algorithms.

Scratch

In this week, the course starts off with Scratch, a graphical programming language developed by MIT media lab that represents programming fundamentals and essentially you learn by playing. It takes the focus away from syntax,curly braces,semicolons and instead pays attention to learning the basic concepts,the thinking process behind solving coding problems and how to approach them, all done in a playful way using puzzle pieces which you drag and drop.

Some of the more advanced examples available to see in the course were amazing and I was an awe of what you can achieve with Scratch and the kind of games you can build. Check out this one which was my favourite

To be honest, Scratch was much harder than what I imagined it to be, and even though it's used to teach children how to program, it is really challenging. I spent more time than I would like to admit on the assignment and I'm not satisfied with the result but at least it's a start. Here is first my attempt on the assignment and here is my second attempt after watching the walkthrough.

Try and have fun with it and understand the basic concepts used(like variables,loops,conditions), but don't get too caught up with it like I did.

At the end of this week's class it was mentioned also that programming is in fact like Scratch, it's puzzle pieces put together in a way that makes sense. We start small, from something simple and build up to something more complex. In that process we should take into account the design of those puzzle pieces(programs) and how many steps it takes to get to the end result. That is what DRY is (Don't Repeat Yourself).The goal of DRY is to prevent repeated logic. This principle not only ensures that code is reusable, but it also doesn't repeat itself and if a change is needed,we only need to change it in one place. That means less errors in the long run!

πŸ“š Resources used

That's it for this week's notes! Thanks for reading πŸ˜ƒ

Top comments (4)

Collapse
 
mattedwards profile image
Matt Edwards

That’s a great summary of week 0 πŸ‘ŒI completed CS50 earlier this year and absolutely loved it. As you say, the quality is outstanding. The absolute highlights for me were the problem sets. They are brilliantly constructed tests. The lectures, notes and supplementary material will take you to a certain point and the problem sets push you just a little bit beyond that point.
You’re going to love the rest of the course! 😁

Collapse
 
deniselemonaki profile image
Dionysia Lemonaki

I'm glad you really enjoyed the course,I'm certainly looking forward to the rest of it! I'm amazed by how good it is. I only heard good things about it, but it exceeded all my expectations. Thanks for reading πŸ˜ƒ

Collapse
 
namaewayaman profile image
Yaman • Edited

I am also doing cs50 and currently in week 3.Its a great course and indeed by the end of it, you will have a better computational thinking and problem solving skill. I too faced the some issue as u did, courses after courses and later end up knowing nothing. It's better to get the fundamentals right, then everything else will be relatively easy.
Best of luck! ☺

Collapse
 
deniselemonaki profile image
Dionysia Lemonaki

Thank you! :)