This wiki is associated with Cognito Mentoring, an advising service for learners run by Jonah Sinick and Vipul Naik. The wiki is very much in beta, so you're likely to find many broken links and incomplete pages. Please be patient with us as we continue to improve our offerings.
Please connect with us to offer feedback on the wiki content.

Programming guide

From Cognito
Jump to: navigation, search

This page includes a preliminary version of a guide on learning programming. See also our programming learning resources, programming learning benefits, and learn programming pages.

#1: Programming for non-programmers

There are some skills that don't really constitute programming, but:

  • require some familiarity with programming-style thinking,
  • help make one more computer-savvy, and
  • make it a little easier to start learning programming (the differential isn't huge)

Examples are:

  • Markup or text formatting languages such as LaTeX, HTML, Markdown, Mediawiki syntax
  • Shell commands (such as the Bash shell)
  • Computational software (such as Mathematica, Matlab, R (command prompt)). To a lesser extent, this also applies to spreadsheet software such as Excel.

In each of these cases, either the same language supports full-fledged programming, or there are languages built on it that support full-fledged programming. For instance, LaTeX can be used to write complicated functions to control formatting and layout, though the typical use case of LaTeX does not involve programming. Similarly, HTML isn't a programming language, but a bunch of tools built atop it, such as CSS, PHP, Ruby on Rails, and Javascript, support a varied range of programming capabilities. Matlab and R can be used as interactive interfaces where you type in one command at a time, but we can also write full-fledged programs in these languages.

Using this as a route to learning programming

Of the people who eventually learn programming, a nontrivial fraction start off with learning one or more of the above and only then transition to a proper programming language. Even so, most of those who transition to a proper programming language do so somewhat independently of their experience with these. But it is possible, if rare, to piggyback on one's experience with markup, shell, and computational languages to learn programming. Here are some examples:

  • A person designs his own webpage in HTML. Later, he wants to add more interactivity to the webpage. He adds some Javascript. He wants to make the style uniform across pages. He introduces CSS. He then wants to include some context-dependent displays into the page, so he switches from HTML to PHP to use more general-purpose programming constructs.
  • A person uses the shell command "grep" to find relevant snippets of text within large files. Then, he decides that he doesn't just want to find the snippets, he wants to store them in a separate file. The command line syntax for the grep command gets more complicated. So he realizes that it's better to write a shell script for the job. But then he hears of Perl, and decides to switch to writing a Perl program instead of a shell script.
  • A person is using a computational software to carry out relevant computations. Then, she notices that she is often doing calculations that share some common aspect. She wonders if there's a faster way of doing it than typing out long commands to do the calculations. She learns that she can define a function that can capture the sequence of operations she wants to do. Thus, she's introduced to the idea of functions. Perhaps her needs become more complicated, and she needs to introduce if-then logic into her functions.

The main advantage is that it allows a more gradual ramp-up in the abstraction level. It does not require the person to rapidly absorb a multitude of ideas related to algorithms and various program control and flow structures. The ramp-up is organic.

The main disadvantage is that this can be a slow process. Moreover, unless the person has the right set of needs, he or she may never get to the point where it's necessary to transition to full-fledged programming.

#2: Basic structures of imperative programming

Imperative programming (as opposed to declarative programming) is a mode of programming where explicit instructions are provided on what the program should do. In contrast, declarative programming is a style of programming where the program includes statements on what is true (functional programming is an example of declarative programming).

Most people begin their journey into programming by learning imperative programming, and more specifically, within that, the sub-paradigm of procedural programming, and within that, structured programming. In other words, they learn how to give explicit instructions to machines in a structured format to accomplish what they want the machines to do. There are plausible arguments for beginning one's journey to programming using structured programming:

  • Procedural programming offers the closest correspondence between instructions as they are written in the program source code and how the machine actually executes them. New programmers find that this makes it easy for them to understand how the computer's state is changing as it is executing the program. Functional programming is more opaque (at least to new programmers) in terms of how the instructions are actually executed.
  • As a matter of fact, most programming languages, and most of the world's existing codebase, uses the procedural programming, and more specifically, the structured programming, paradigm.

That being said, some people with a mathematical background might find declarative programming styles, particularly functional programming, an easier and more interesting onboarding experience. This is discussed more later in the guide.

The main components

  • The use of variables as stores of value that can be updated
  • The concept of types for variables
  • The use of arrays and similar structures
  • The use of functions, blocks, and subroutines
  • Conditional logic (if-then-else statements)
  • Iteration logic (for loops)
  • Iteration-cum-conditional logic (do-while loops and while loops)

How far does this get us in programming knowledge?

Anecdotal evidence suggests that 50%+ (perhaps close to 80%) of the work programmers do involves only these skills. This is particularly true of people who are only maintaining a codebase and do not need to design a new system from scratch, or for people who are doing very simple, incremental stuff.

This does not, however, mean that somebody who can do only this stuff is almost ready to do coding. Even if time-wise, only 20-50% of coding requires more advanced skills, a programming job will only go to somebody who is able to handle the harder parts along with the easier parts. Since all the components of coding are tightly integrated, it's not efficient to farm out the "easier" parts to people who can't understand the harder parts.

However, this level of skill, while not enough to get a programming-focused job, might be enough for a person to maintain existing codebases for personal or academic use, and reduces the person's reliance on others in this context.

#3: Combining programming with algorithms and data structures