Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a self-taught, novice programmer. The language I chose was Objective-C, so that I can write Apple applications and software. I have learned the hard way that Objective-C has a steep learning curve, but I have forced myself to look at it over and over until I get it right.

I feel I am completing one major step, and that is becoming very comfortable with the syntax. Now as I enter the next big step - finding out what is possible with a computer programming language - I am thinking that all software is just developed within the confines of:

  • classes
  • loops
  • booleans
  • IF/OR statements
  • variables
  • etc.

Is that a true assessment? When thinking of software in my head do I just need to learn to convert it all to the above? Right?

Sorry if this question sounds funny, but I am just learning how to take the language in and talk (what I think is) the language of a computer. Is there a good book or tutorial that helps illustrate how to "speak as a computer would"?

share|improve this question

closed as not constructive by Walter, Glenn Nelson, MichaelT, World Engineer, Eric King Feb 14 '13 at 22:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

I had a vision of Scotty speaking into a mouse. –  MathAttack Mar 24 '12 at 17:14
1001111011100011001 –  Glenn Nelson Mar 25 '12 at 1:21
here is a good place to start if you want a bit of history and you can dig down into how electricity is used to model states that we can ascribe meaning to in order to create a computer. –  Ryathal May 8 '12 at 21:30
"Hey computer, wassup?" –  Michael Durrant May 9 '12 at 3:06
That's actually a very good "soft" question! Those are too rare. –  Joachim Sauer May 9 '12 at 5:36

3 Answers 3

Fundamentally, computers can only do a few basic things:

  1. They can perform simple arithmetic
  2. They can execute instructions sequentially
  3. They can branch to another instruction, based on a condition
  4. They can loop (a variation of branching)
  5. They can move data from one place to another
  6. They can store data and retrieve it for later use.

That's about it. Everything you see a computer do is just an elaborate abstraction over these simple operations.

Programming languages are one of those abstractions. They allow us to speak the computer's language (technically, machine code), using a symbolic language that is closer to the language we humans use to communicate. Programs called compilers translate programming languages into machine code, so that the machine can execute our instructions, just as we specified them.

There are many different computer languages, each optimized for a particular way of thinking or problem solving. These ways of thinking are called paradigms; many programming languages support more than one paradigm. Objective C is just one such language.

The way each computer programmer gets started is as individual as your fingerprints. If you really want to "get" the idea of computers, my advice is to learn more than one language. Study other languages; see how they differ. See how they all have certain things in common; although they might solve a problem differently, at their core they still resolve down to the same fundamental operations.

share|improve this answer
Well said... :-) –  Dr.Kameleon Mar 24 '12 at 6:26
Wow! That was a great reply - Thank you for the explanation. It makes me really excited to learn another and then another language. Thanks! –  SalemSeven Mar 24 '12 at 21:09
You forgot to add: "They can store data and retrieve it for later use." –  Bernard Mar 24 '12 at 23:07
Then can also execute some instructions in parallel, depends on the processor(s) and the instructions. –  Danny Varod May 9 '12 at 11:12

First-Class Functions

Another useful feature that a programming language can have is first-class functions. A first-class function is a function that can be used as data.

In a language in which you can treat functions as data, you can create variables that refer to them, pass them around as arguments to functions, and return them from functions. Once case where you might use this is the famous map function.

Say that I just got some string from a file or something and that the string contains a series of integers separated by spaces. Say I use a string-splitting function to get an array of strings containing each of the integers (still as strings). I have access to a library function to parse an integer from a string, and I want to use it to convert each of these strings containing integers to actual integer values. I create the new array and write a loop to convert each string and store the resulting integer in the new array.

Now say I want to take a different array of integers and find the absolute value of each and store the results in a new array. I can use another loop to do this. However, I have this pattern showing up in my code: start with an array, perform some transformation of each value in the array, and store all of the results in a new array. I could just write out the code to do this each time, but there is a way to abstract out the process of creating the new array, looping, transforming, and storing.

I can write a function that takes as arguments

  • an array of type x
  • a function for somehow transforming objects of type x into objects of type y (possibly the same type as x)

and have it create an array of elements of type y of the correct length, loop over the values in the original array, call the function argument to do the transformation, store the results in the new array, and return the new array.

After I've written this function, map, I don't have to write this code out by hand any more.

Objective-C should have function pointers because C has them.

The way I described map also took advantage of some sort of generic typing.


Another feature is closures. A closure is a function object that captures some of the variables that existed in the scope in which it was created. What does that mean?

Some languages let you write function literals, functions that don't (necessarily) have names and just appear in you code without a special separate declaration. When you write a function literal in another function, there might be variables in the same scope as the function literal. There are situations where you might find it useful to use those variables inside of the function literal and have those variables stay with the function object. Such a function object would be a closure.

Here's an example of code that I wrote that creates a closure (written in Common Lisp):

(defun exponential-change (function constant)
  (lambda (time)
    (* (expt constant time) (funcall function time))))

(Don't ((let (the) parentheses) scare you)). Think of it as being written like this:

function exponential_change (function, constant) {
    return function (time) {
        return exponent(constant, time) * function(time);

I wrote this for synthesizing sound. I represent a sound as a function of time that returns amplitude samples (-1 to 1). This function, exponential-change, transforms a sound by making the amplitude increase or decrease (depending on the constant) in an exponential fashion. exponential-change creates returns a function of time based on another function of time. The fact that the new function keeps track of what function it needs to modify prevents other code from having to keep track of that detail.

Closures not only keep track of the values of the variables they capture but also the variables themselves. This means that you could create a function that modifies those variables.

share|improve this answer

You should try getting a degree in computers. There are many tedious and boring, yet extremely useful concepts and techniques in a long list of theoretical subjects that you must go through if you are seeking a career in programming. If you are not and programming is just a hobby to you then you have no business here.

Its fun to jump to the gun and start shooting the first day, but better to first go through the long and seemingly useless drills, tree-climbing and map reading stuff if you are preparing for a war.

You do have got it right though about the fundamentals. Its the combination of these fundamentals that actually matters. 26 letters in english languages results in 800,000 meaningful words, billions of meaningful sentences and orders of magnitude more articles, novels, dramas etc.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.