How One Week of CS50 Changed the Way I Think About Coding
Tags: beginners, computerscience, todayilearned, programming
Published: 2022-12-14 06:19:55

A few years back I attempted <a title="Harvard CS50" href="https://cs50.harvard.edu/x/2022/" target="_blank" rel="noopener">Harvard's CS50</a> after seeing how often it was recommended as an invaluable resource to self taught programmers. Unfortunately, CS50 is heavily lecture/video oriented and I have sensory issues when it comes to watching the videos. I never even made it through the first lecture.

After coming back to web design and discovering that, this time, I was much more interested in the development side of things, I decided to check out CS50 again. I was delighted to find that they now had accessibility options, including full transcripts of the lectures which I could follow along with.

As a side note, my example here is but one of many which shows why <a title="Introduction to Web Accessibility" href="https://www.w3.org/WAI/fundamentals/accessibility-intro/" target="_blank" rel="noopener">accessibility on the web is necessary</a>.
<h2>Programmers Solve Problems</h2>
Programming is not about the code you write nor the language you write it in. Programming is about solving problems. Then CS50 broke problem solving down to this most basic element of computer science.
<blockquote>Problem solving is the process of taking some input (a problem that needs to be solved) and generating some output (the solution to the problem).</blockquote>
I saw this lesson cemented when I moved on to week 1 and started doing the exercises in C, a language I've never even looked at before. I found myself not worrying about the syntax or trying to remember terms. Instead I was focused on how the particular language I was working with, C, and seeing how it can be used to solve problems.
<h2>Programming Logic</h2>
Ultimately, when using a programming language, it comes down to figuring out how to solve a problem within the limitations of that specific language. This is why it's more important to be fluent in programming logic than in any one particular language.

To begin to understand programming logic you need to understand how programming a computer actually works. How do we give a computer instructions? How does the computer process those instructions?
<h3>Binary</h3>
We communicate with computers using a binary number system consisting of 0 and 1, with a <strong>bit</strong> being each individual binary digit. Computers are made up of billions of transistors that can be switched on and off, manipulating the flow of electricity. A bit is represented by turning a particular switch on or off to represent a 0 or 1. Different types of information is conveyed using patterns of 1s and 0s.
<h3>Algorithms</h3>
The next step in understanding programming is understanding the <strong>algorithm,</strong> the step by step instructions that we, as programmers, feed to the computer allowing it to solve a problem (transforming input to output). It's funny that I had always heard so much about the algorithm and it was always made to seem like such an illusive thing. Probably because no one ever knows how google's seo algorithm works. But, though the practice is hard, it's really such a simple concept.

An algorithm can be written in any programming language, expressed using a flow chart, or with pseudocode.
<h3>Pseudocode</h3>
If you had to be completely fluent in one language and one language only, it should be <strong>pseudocode</strong>. Okay, that's kind of a trick answer since pseudocode isn't really a language at all. It consists of writing out the algorithm, the steps that the computer must perform, in your own written/spoken language.

The example below from CS50 covers the important elements common to all programming languages. It's best to write your pseudocode with the terms used in most languages such as if, else if, else as well as the proper indents.

<ul>
<li>Actions / verbs -- pick up, open, look -- are referred to as <strong>functions</strong>.</li>
<li>Branches that lead to different paths -- if, else if, else -- are called <strong>conditionals</strong>.</li>
<li>Questions that decide where we go, true/false statements -- is earlier, is on, is later -- are <strong>expressions</strong>.</li>
<li>Words that make us repeat parts of the program -- go back to -- are <strong>loops</strong>.</li>
</ul>

```
Pick up phone book
Open to middle of phone book
Look at page
  If person is on page
    Call person
  Else if person is earlier in book
    Open to middle of left half of book
    Go back to line 3
  Else if person is later in book
    Open to middle of right half of book
    Go back to line 3
  Else
Quit
```
<h2>Conclusion</h2>

I never would have thought that CS50 Week 0, a lesson I assumed would be more setup and prep than anything, would teach me such an important lesson. Whenever I thought of programming before I always thought of specific languages. Now the way I think has shifted and instead of considering programming languages, I consider the language of programming.