a super-quick overview of programming

you can get a good “overview” of programming from (i use 7) basic fundamental concepts:

variables — essentally a name, plus a piece of data.

  • assignment gives the name some data by mentioning the name and the data to assign:
  • x = 5
  • reference gets the data, just by using the name: x
  • arrays and lists hold more than one piece of data, so in addition to the name you use a number: x[2]

 

input — basically assigning a variable with data from a device, like a keyboard. or part of a file on the disk.

output — referencing a variable and putting its data onto a device, like a screen or a file on the disk.

basic math — unavoidable.

  • you dont have to be really good with math.
  • you can get the computer to do it for you.
  • you still have to tell it what you want to do.
  • much can often be abstracted with functions, but you will have to use numbers sometimes.

loops — think of a sandwich.

  • the two pieces of bread mark the top and bottom of the loop.
  • the “filling” is the code that runs (typically) more than once. can run once or 0 times.
  • the bottom piece of bread usually doesnt do much.
  • the top piece usually defines (briefly) how many times to loop, or what to wait for to stop.
  • can be simulated with functions, but its more work.

conditionals — code that runs if something is true (or alternatively, runs if not true)

  • can be simulated with a loop, because some loops can run (optionally) 0 times.
  • are a sandwich, like the loop is.
  • the bottom piece doesnt do much
  • the top piece usually defines whether the filling code should run or not
  • can be simulated with functions, but its more work

functions — basically assigning a name to a “paragraph” of program code

  • can make it less work to name/keep track of all your variables
  • can be called / used like any other command, so lets you “make your own commands.”
  • kind of the staple unit of programming– like a bar of notes, or a paragraph of prose.
  • the most difficult of these 7 concepts to really appreciate and understand– powerful but so deceptively simple, there has to be more to it (or it cant be that useful…)

 

fig examples:

# variables:
variable = 5

# input: (in this example, get typing from keyboard)
variable = lineinput

# output: (the ; is optional and can be ignored.)
now variable ; print

# basic math:
x = variable plus 5

# loops:
while
now “print keeps putting this on the screen!” print
wend

# conditionals:
variable = lineinput
ifequal variable, “hello”
now “hello yourself!” ; print
fig

# functions
function blank_the_screen
now cls
fig

variable = “hey there” ; blank_the_screen ; print
# above line blanks the the screen and puts “hey there” at the top.

 

 

Advertisements

2 thoughts on “a super-quick overview of programming

  1. Nice. I can see that you are in love with programming. I completely understand that. As Kristen Nygaard said: programming is understanding.

    You’re right about not needing too much mathematical sophistication for programming, but the older I get, the more I realise that more is better or at least useful and interesting; I wish I had noticed that earlier. 🙂

    Variables, selection, iteration: the key elements. The notion of Turing Completeness is also useful.

    I like your comments about functions, especially when recursion and composition are introduced. The analogies with music and prose are nice.

    The unification of iteration and selection (loops and conditionals) you mention is also nice. A related point can be made about iteration via selection and recursion.

    I write equal amounts of Python and Java (and some C++, R, Matlab, …) these days. With Python I find myself writing fewer classes than I’d expect and more functions and functional-style code (list comprehensions etc). Of course, it’s hard not to write OO code in Java unless you trivially write nothing but static methods. 😉

    Liked by 1 person

    1. my first hobby was legos and drawing on the computer. we also had a basic manual, so i got to learning that.

      i think coding is the quickest route to computer literacy. even if someone hates computers– understanding them is good for making informed decisions that everyone needs to consider these days.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s