28
$\begingroup$

I am an engineering student in computer science and recently my parents asked me to explain a bit what I do, which is their way of asking "What is coding?".

They have no idea of what coding is, what languages are, lines of codes etc, and I wanted to explain briefly how it all works. I wanted to explain what a programming language is and how it is used to write algorithms, make computations... To me it seems very logical that the interpreter reads lines of code from top to bottom, understanding the statements of a particular language.

I can't find the right words and nice examples to help them understand globally how it works.

How can I explain this idea to them?

$\endgroup$
  • 2
    $\begingroup$ Thanks for the question. Could you provide your parents' background? Not all parents are ignorant of computer science. dilbert.com/strip/1998-07-15 $\endgroup$ – Ellen Spertus Jun 20 '17 at 17:33
  • 2
    $\begingroup$ I feel this is too broad. HTML is code, assembler is also code. Code is just that, a formal language that expresses something. If I were an average C++ programmer, I would describe my job to my grandmother as such: "I write computer programs, that is, I use a specialized formal language - akin, in this respect, to the language of mathematics - to express the behavior I want the machine to exhibit. My understanding of what the correct behaviour should be must be sound in order for this to work." It's all kinds of wrong, technically, but I feel it conveys the idea. $\endgroup$ – Tobia Tesan Jun 21 '17 at 10:18
  • 3
    $\begingroup$ Unfortunately, no one can be told what the Matrix is, @Aurora0001, is this you? $\endgroup$ – Ghanima Jun 21 '17 at 20:50
  • 2
    $\begingroup$ I wonder... The oldest computers I know of might be the player pianos... $\endgroup$ – Malady Jun 21 '17 at 22:03
  • 2
    $\begingroup$ It's not that hard to explain. public static void main(), *ahem*. Lorem ipsum dolor sit amet, consectetur adipiscing elit... $\endgroup$ – Mehrdad Jun 22 '17 at 3:53

18 Answers 18

42
$\begingroup$

Coding is like writing a recipe for the computer to follow so that it solves your problem. The computer "reads" each step, and follows it, eventually reaching a solution. Some programs are better than others, just like some recipes are better than others - they are faster, they produce a better result, etc. Programmers aren't really the cooks, though - the computer itself produces the result. The programmers are more like the cookbook authors, producing the recipes (programs) for the computer to follow.

Now, I don't know about you, but I've followed a recipe before, and there have been times where I've been left wondering, "Have I put in 2 or 3 cups of flour?" or having mixed in an extra couple of chocolate chips (quite by accident, of course). A computer doesn't have these problems. It can make your "recipe" much more swiftly and accurately than you can. However, this gives you no excuse for providing the wrong recipe. No amount of accuracy will make brussels sprouts into ice cream, unfortunately.

Lastly, @dckuehn brings up a great point. No analogy is perfect, and this one is no exception (heheh). Whereas, in a recipe, you really try hard not to vary the input so as not to vary the output, most programs take different kinds of input and produce different kinds of output, according to the same rule. Sort of like you can put a bunch of different cookies in the oven to bake them - not the same input, not the same output, but a fairly similar process inbetween.

$\endgroup$
  • 3
    $\begingroup$ Very nice analogy. "The programmers are more like the cookbook" :) $\endgroup$ – Ben I. Jun 20 '17 at 23:06
  • $\begingroup$ Nice indeed ! Very simple, yet accurate. Maybe adding a simple real example of code (like do the sum of the first 100 integers as @Cort Ammon suggested) would make them understand better. $\endgroup$ – Shashimee Jun 21 '17 at 7:09
  • 6
    $\begingroup$ I think it also helps to explain that computers do very simple things, but do them extremely quickly, and very reliably. Kind of like how a production line can build a car in lots of steps. $\endgroup$ – Sean Houlihane Jun 21 '17 at 12:45
  • $\begingroup$ I think it would be worth explaining that programs differ from recipes in that the result is not always the same. You expect (hope) a recipe to yield the same thing each time. The program will react different to different inputs, similar to a math equation. $\endgroup$ – dckuehn Jun 21 '17 at 16:52
  • 1
    $\begingroup$ I like and use the recipe analogy a lot, but I usually add the caveat that a program is a recipe written for an entity that cannot think for itself. A standard recipe will just say something like "add 2 cups of flour". However, there's a lot of assumed knowledge there that a computer program has to include explicitly. Where does the flour come from? What should be used to bring it over to the bowl? What if there's not enough? What if it spills? $\endgroup$ – chazlarson Jun 22 '17 at 16:48
15
$\begingroup$

The best way to explain coding to someone is very dependent on their background. You really need to tailor the story to fit what they understand. That being said, they're parents so...

Coding is a way to give instructions to the computer, telling it what to do. Think about the instructions you leave for a babysitter. They tell the babysitter exactly what needs to happen while they are away. Now, despite some appearances, the computer is not very smart. It doesn't have good common sense. Think of it like the first babysitter they ever hired. Surely they wrote up a massive document with every last little tiny detail about how to take care of you, emergency contacts, emergency emergency contacts (in case the emergency contacts can't be reached), food allergies, medicine allergies, allergic reactions to allergy medications. You name it. They made sure every last detail was covered, so the babysitter had instructions to handle whatever may be encountered while they are away.

Now, computers are fast. Really really fast. They did a billion things while you read this sentence. As far as this computerized babysitter is concerned, it's not like your parents are gone for a night - it's like they're gone for a month.

Now have them imagine the manifest they would have typed up for this brand new babysitter, babysitting you for the first time, for a month. Imagine all of the precise instructions laid out in the best order the can manage so that the babysitter can just check off each instruction, line by line.

That's coding. I have a feeling they appreciate for loops right about now.

$\endgroup$
10
$\begingroup$

I tend to describe code as a contract. Most people know that if you read a contract, it's not in English - it's in "legalese". Legalese is a language that looks mostly like English, but it's full of odd phrases and very specific wording, and the punctuation is different. Contracts are written this way because each phrase has been interpreted by a court to mean something very specific, and so contracts will use the same precise wording so that they will be interpreted by a court in the way the lawyer wants.

Programming languages often look kind of like English too; they use English words, but have different structures and punctuation. This is because a compiler is like a court: it will interpret these specific phrases in a specific way, and each phrase will add a certain piece of behaviour to the program that the compiler produces.

A contract can have loopholes or grey areas. These are places where the wording of the contract is unclear, isn't an accurate representation of what the lawyer or their client wanted, or doesn't cover a certain scenario, which means that what happens is either up to the court, or not governed by the contract. For the lawyer, either of these scenarios is bad. A good lawyer can write you a contract with no loopholes or grey areas, but it can be very difficult, because legalese can be hard to read, the law is very complex, and some scenarios are very detailed.

A program can have loopholes and grey areas too: we call them "bugs". These are places where your code doesn't tell the computer what to do in a particular scenario, or it describes something that actually isn't quite what you wanted. A good programmer can write you a program with no bugs, but it's often very hard to do, because code can be hard to read, computers are very complicated, and the program might be doing a lot of very intricate things.

A great lawyer can write a contract that has no loopholes or grey areas, but is still relatively easy to read, even by someone who isn't a lawyer. This is good for the client, because they can understand their contract, but also for the law firm, because it means that any lawyer can understand the contract and make amendments without missing something subtle and introducing a loophole.

A great software engineer can write a program that has no bugs, but is still relatively uncomplex and easy to read. This is good for the client, because it means their program is easier to review and verify correct, but also for the software company, because it mean that any programmer can read the program and make alterations without missing something subtle and introducing a bug.

$\endgroup$
  • $\begingroup$ Welcome to CSE! This is an excellent analogy. I sure hope we will be hearing from you again soon. $\endgroup$ – ItamarG3 Jun 21 '17 at 9:54
  • $\begingroup$ And "language lawyer" is a real term! wiki.c2.com/?LanguageLawyer $\endgroup$ – Baldrickk Jun 21 '17 at 10:32
  • 2
    $\begingroup$ "A good programmer can write you a program with no bugs" - Maybe, but depending on the complexity it may be impossible to determine that. I find that telling the layperson that it is possible to produce a program with no bugs is giving a flawed impression. Perhaps this would be better: "Good programmers can write you a program with few bugs." Gives a more nuanced impression about bug-checking and implies teamwork. $\endgroup$ – called2voyage Jun 21 '17 at 14:29
  • $\begingroup$ Like I said, it can be hard to produce code with no bugs, because computers are complicated, languages are complex, and applications are varied. It is possible to produce a program with no bugs, but the difficulty of doing so grows exponentially with program scope and complexity. That's something you can explain alongside the analogy, but I don't think it's necessary to muddy the waters of something that is intended to illustrate the concept to laypeople with details of how difficult this job can be. $\endgroup$ – anaximander Jun 21 '17 at 14:42
  • 1
    $\begingroup$ @called2voyage As a professional software engineer, I'm painfully aware of that. All I'm saying is that, for the purposes of an analogy to answer the question "what is coding?", I don't think it's necessary to go into that much detail. Having used this analogy to explain my job to non-technical friends and family on several occasions, I do tend to go on to explain that the average computer program is so complex that it's nigh impossible to have zero bugs in anything beyond the truly trivial, but I'd consider that tangential to the actual answer to the question being asked here. $\endgroup$ – anaximander Jun 21 '17 at 15:08
6
$\begingroup$

My explanation would be:

The computer isn't some machine that can do a lot of intelligent things. Rather it is very dumb, but can execute instructions carefully, very fast and without getting bored.

For instance: given the task of adding up all numbers from 1 to 1 million, a human probably wouldn't make it past 100 without making some mistake and getting bored with it. A computer happily performs this task in a couple of milliseconds.

The job of the coder is to supply the computer with a detailed set of instructions to perform some task - this is the program or application.

It is not "the computer" that makes an error, usually it is the programmer that didn't forsee some combination of events and thus didn't provide instructions for that.

The instructions are in some computer language, of which there are many, each with it's own strengths and weaknesses.

EDIT
Of course there is a formula to calculate the sum of consecutive numbers. This strengthens the point: a human might think "there has got to be a simpler way" and figure it out, a computer would never think that. It blindly continues counting (and still finishes sooner than the human with the formula).

$\endgroup$
  • $\begingroup$ Welcome to CSE! I like the way you've described bugs here. I hope we hear more from you in the future! $\endgroup$ – Ben I. Jun 21 '17 at 10:51
  • 6
    $\begingroup$ Just as an aside. I wouldn't get bored of calculating the sum of 1 to 1 million. It's 1,000,001*500,000 = 500,000,500,000 I would get bored if I actually added them up. $\endgroup$ – Phil M Jones Jun 21 '17 at 15:14
  • $\begingroup$ I recently asked my pupils to sum the numbers 1…100, I gave them 30 seconds. We then looked at how we could do it. We ended up with the formula $(n+1)\times{}n/2$ same as what @PhilMJones did. $\endgroup$ – ctrl-alt-delor Jul 14 '17 at 16:26
4
$\begingroup$

"What is coding ?"

A set of instructions written in human readable language (at least to developers) that is executed to perform a task or goal.

"what a programming language is"

High level: Just like any language that exists in the world today, it has it's own alphabet, syntax and grammar that is for communication.

Technical: First off I just want to note that some languages are interpreted while some are compiled, as for their differences I believe it's off-topic. The idea is that your "code" is tokenized based on the language's alphabet and syntax and formatted into a parsing tree. The parsing tree is then translated into some intermediate code. Lastly the compiler translates the intermediate code into source code or machine code that can be executed by the CPU.

"how it is used"

Since programming languages are made for humans to easily learn and write in, it is like writing a book. We choose alphabets of the language and write meaningful segments that perform tasks whether it is to loop over an array or read some files.

$\endgroup$
4
$\begingroup$

Well, I would personally suggest you to show them the first lecture of Harvard CS50 class and believe me they will not leave it without completing all of them. It is one of the best structured course for any student (well in this case you can call your parents as students :p) irrespective of the background of the person.

They have an interactive environment called as Scratch in which you can design new interesting projects. Have a look at some featured projects, they are very good!

$\endgroup$
  • 1
    $\begingroup$ I don't think his parents want to learn how to code, but rather how to coding and programming languages work. $\endgroup$ – ItamarG3 Jun 20 '17 at 14:40
  • $\begingroup$ If they're willing to sit through that first lesson (and if they understand English well enough), they will certainly come out with a pretty good idea of what coding is. David Malan is absolutely electrifying! $\endgroup$ – Ben I. Jun 20 '17 at 15:01
  • $\begingroup$ This is close to a link-only answer, which is frowned upon on Stack Exchange sites. Could you summarize what is discussed in the CS50 lecture, and what makes it compelling? $\endgroup$ – 200_success Jun 21 '17 at 0:51
4
$\begingroup$

Simple: you let one of the best science teachers of all time explain it to them for you.

Here's a video of Richard Feynman introducing computers to a non-technical audience at some new-age retreat back in the 80s. Starts by explaining how computers work from the inside out, and goes on into heuristics and AI, all in his signature style of great analogies (army of filing clerks, dumber but faster).

As someone who had never come in touch with coding throughout my education, this lecture gave me quite a few Aha! moments and single-handedly encouraged me to start dabbling with programming.

$\endgroup$
  • $\begingroup$ Welcome to CSE! RF is, indeed, amazing. I hope we hear more from you in the future! $\endgroup$ – Ben I. Jun 22 '17 at 1:56
3
$\begingroup$

In addition to the excellent definitions already provided, consider taking a slightly different approach or at least augmenting it a bit. This comes back to good pedagogy: I wouldn't give students definitions without context. Moreover, I would support whatever concept I want to get across, no matter how broad or narrow, with specific examples and implementations.

To explain programming to someone who has no idea what it means, it is necessary to have short blocks of code at the ready. Explaining it in the abstract probably won't be too successful. Relatively straightforward ideas like printing "hello, world" or the even numbers from 1-100 or the sum of the integers 1-50 would show the bare minimum of logical and computational ability. Maybe even something relatively intuitive like bubble sort or linear search. From there, compiling the program - assuming a language like C or Java - would at least allow you to explain the notion of translation.

I like to use the metaphor that computers "speak" binary, but I speak C (or Python or Java or...). I need to translate what I want to accomplish into the language that the computer can understand. You can explain compilers/interpreters as a kind of translator that understands both computer-speak and human-speak and knows how to take your thoughts and turn them into "words" that the computer can understand. (You can optionally include the idea of assembly and instruction sets, but again, that's probably beyond the scope of this conversation.)

$\endgroup$
3
$\begingroup$

I've been a professional Software Developer for about 30 years, and a hobby programmer before that going back to the 70's. So I've been asked this a lot, and have had time to try lots of approraches.

The main issue is that you are talking a different universe than most everyone else's experience. In a social situation, you have one or two sentences before the eyes start to glaze over, so you can't really go into detail. So after decades of experimentation, the explanation I now give for what I do is:

I tell the computer what to do. It flips me off (or insert offensive invective here to taste) and merrily does something else. Then I spend the rest of the day trying to figure out why.

I once gave this explanation to a room full of public school teachers, and got the rather amusing response:

That's the same as teaching!

I think they are actually onto something there.

Note that Brooks' Mythical Man Month* devotes the last half of its first chapter to roughly this question (the sections titled The Joys of the Craft and The Woes of the Craft). I think what I wrote above is actually about the best possible tl;dr of Brooks' text. But if someone is really interested in reading 18 paragraphs about it, send them the link above.

* - Generally considered The Bible of Software Engineering. As Brooks himself quipped, this is because "everybody quotes it, some people read it, and a few people go by it".

$\endgroup$
  • $\begingroup$ That's a cute joke. Welcome to CSE! $\endgroup$ – Ben I. Jun 21 '17 at 12:45
  • $\begingroup$ @BenI. - Thank you. Expanded it to make it more of a proper answer though (perhaps removing a bit of the punch. Sorry.) $\endgroup$ – T.E.D. Jun 21 '17 at 13:26
3
$\begingroup$

I think I would explain it like this:

What is a programming language?

I'd say, it is a set of instructions1 (a "language", the words are the operators, sentences are expressions and so on) to tell a computer what it should do. There are instructions to do basic arithmetic or calculations, instructions you can use to interact with the user, and instructions that can control the program's flow, for example by repeating other instructions or branching, so it does different things when confronted with different inputs.

How is it used to make computations?

As with the human languages, there are multiple programming languages. To develop in a certain language you usually write (text) files containing the instructions (you could now mention how this looks in a programming language you like). These text files are read and executed by the computer. Depending on whether the language is low- or high-level, the computer might need additional software (the interpreter) to understand the language.

Often, developers use so called IDEs which make development easier as they offer hepful features (for example, automatically creating instruction(s) you normally use a lot or immediately pointing out errors).

What is coding?

This is just the process of making a program. The combined instructions that eventually make up your program are often called "code" by developers, so they use the verb "(to) code" to describe the process of writing down instructions to solve a particular task.

1 As Brian H. pointed out in his comment, a more precise definition of a programming language would be "a set of syntactical and grammatical rules bundeled with a standard library that provides instructions to tell the computer what to do". However, as you asked for an explanation in layman's terms, I wouldn't recommend this definition to explain what a programming language is.

$\endgroup$
  • $\begingroup$ i don't agree with: What is a programming language?: it is a set of instructions. The set of instructions is called a program, and the language is a set of syntactical and grammatical rules to make sure the computer understands these instructions. $\endgroup$ – Brian H. Jun 21 '17 at 14:26
  • $\begingroup$ @BrianH I'd agree that a program is a set of instructions. However, I do think the language is also a set of instructions as it defines them - I could only think of moving the instructions to the construct of the "standard library": "A language is a set of syntactical and grammatical rules combined with a standard library that provides several instructions that can be used following in a program". Would this be better in your eyes? $\endgroup$ – TuringTux Jun 21 '17 at 14:53
  • $\begingroup$ Sounds about right i think. $\endgroup$ – Brian H. Jun 21 '17 at 14:57
  • $\begingroup$ @BrianH. I've edited this into my answer as a footnote, I hope you're okay with it :) $\endgroup$ – TuringTux Jun 21 '17 at 17:51
2
$\begingroup$

A programmer writes the instructions for a computer to do its job. A program is a set of instructions for it to follow to accomplish or aid in performing a task. Sometimes the instructions can be rather abstract things like skipping certain instructions or doing others over and over. The programmer assembles instructions into smaller groups that accomplish a part of the task, called a subroutine (or function, method, etc). These are used as building blocks from which they construct the larger program.

Or, in one sentence: If computers are magic then coding is writing the spells.

$\endgroup$
  • $\begingroup$ Welcome to CSE! I hope we hear more from you in the future. $\endgroup$ – Ben I. Jun 21 '17 at 21:37
  • $\begingroup$ No no, computers are magic. I should know, I'm an actual professional friggin' wizard. I got into illusion magic recently, too. (In all seriousness, this comment is being serious). $\endgroup$ – Draco18s Jun 23 '17 at 16:58
1
$\begingroup$

I'm a programmer and when people ask me to explain what I do, I usually say that computers talk in bits, right? Zeros and ones. And it's hard for a human to understand that, so there are this tools called programming languages that are able to translate a more human-like text into zeros and ones.

The problem is that programming languages have lots of rules and each programming languages has it's own structure and rules (just like normal languages!) our job as programmers is to know this rules and play with them in order to get what I want.

Example time!

Let's say that we choose as our tool the Python programming language (not to be confused with the snake)

And our goal is to print 10 times on the screen "Hi" We as smart programmers know that in python if we say:

print("Hi")

It will show "Hi" on the screen, but it doesn't solve our problem, right? We want to see it 10 times in the screen, so we as VERY smart programmers tell python:

print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")
print("Hi")

And our goal is accomplished!

But it's quite tiring to copy and paste that much code, so we as super programmers we know python's syntax and rules so we do:

for x in range(1, 10):
    print("Hi")

And super saiyan programmers will do:

print("Hi\n" * 10)

TLDR: Programmers are human beings trying to talk to computers through very strict and sometimes mean translators. But it's fun though!

$\endgroup$
  • $\begingroup$ Btw, I know in my answer I'm mixing a lot of concepts, but it was on the hope of not overcomplicating my answer $\endgroup$ – Safirah Jun 21 '17 at 11:47
1
$\begingroup$

Code is like the rules of a game.

For instance Hangman. Explaining how the game works step by step is almost writing a computerprogram in pseudocode.

1 - Player 1 randomly picks a word out of a list.

2 - He writes down a number of dashes corresponding to the number of letters in the word.

3 - He askes player 2 to guess a letter.

4 - Does the letter occur in the word or not?

5 - Etc.

The purpose is not to really write the program, although 'we programmers' can probably picture it by now, certainly the part where the the computer is the one thinking of a word for the other player to guess.

$\endgroup$
  • $\begingroup$ P.S. I am not great at computer science, but i am an educator! My answer is a 'lesson one' intended for a layperson. $\endgroup$ – Draakhond Jun 21 '17 at 14:44
1
$\begingroup$

Here is a fun, interactive, and impressively comprehensive-yet-easily-digestible article that covers all the basics of programming/CS for laypersons. It even explains many of the professional aspects of what a being employed as a programmer entails beyond just the theoretical and technical aspects. It's where I usually send people with a similarly un-technical background who display a curiosity about programming.

https://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/

$\endgroup$
  • $\begingroup$ Nice article. Welcome to CSE! I hope we hear more from you in the future. $\endgroup$ – Ben I. Jun 21 '17 at 15:05
1
$\begingroup$

Coding is like writing an instruction or assembly manual for a product. Tell your parents its like them writing a manual for assembling something like a bicycle.

$\endgroup$
  • $\begingroup$ Welcome to CSE! This answer is a little short on details, would you mind fleshing it out a little? Otherwise, it's a pretty nice analogy. I hope we hear more from you in the future. $\endgroup$ – Ben I. Jun 22 '17 at 17:30
0
$\begingroup$

Tell them that you are making a computer work as per instructions, and the instructions we give are a sets of rules(syntax) with which one is able to produce many logical structures. Then explain that an engineer like you tries to think about the best possible logic to instruct the computer to do a specific task (such as "printing multiplication tables from 1 to 100 in a few seconds").

$\endgroup$
  • $\begingroup$ Welcome to CSE!! $\endgroup$ – Ben I. Jun 21 '17 at 12:43
0
$\begingroup$

Coding/Programming is interacting with a computer or device with a language the computer can translate and actually use, because computers and other devices don't understand human languages.

Sometimes those interactions are things like asking questions, or taking notes to keep track of things, or looking up old information wherever you put it.

Programs are big collections of those designed interactions to achieve a specific goal, like, make a spreadsheet, send an email, or draw an object in three dimensions on the screen -- stuff like that.

Programming languages are just languages that humans code with so computers know how to translate and use their designed interactions. Those languages are usually a mix of human words and symbols to help with the creation of those instructions for those interactions.

The computer/device only cares about the instructions, not the language used to make those instructions, so it takes those translated, coded interactions as instructions for a language that the computer knows how to use that we humans can't really read without help of a translator.

Coders/Programmers are basically the middle-men to help with communication and action between machines and humans.

$\endgroup$
0
$\begingroup$

When people asked me what I did, when I was a programmer/software engineer. I would tell them one of these.

  • I am an author.
  • I write instruction manuals for computers. No not manuals on how to use computers, manuals for computers: The computers read the manuals, so that they know what to do.
  • I write poetry for computers.
  • I teach computers, how to be medical pumps. (My last job was programming medical pumps).
  • I am a wizard, I recite magic spells at computers, and they do what I want.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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