title: What is a good example to show to a non-programmer to explain what programming "looks like"?
body: <p>A friend of mine asked me the other day if I'm just looking at lists of numbers when I'm programming, or how it works. I tried to explain that it's generally more like math formulae, with the odd english word tossed in, and that it's generally mostly readable. But that's a very vague explanation, and it doesn't really explain much to a non-programmer.</p>
  
  <p>But it got me to thinking about what would make a good example. Not because I want to teach her programming or anything, but simply to give her an idea of what program code "looks like".</p>
  
  <p>And that got me to wonder about what would actually work as a good example. And that's turning out to be surprisingly difficult.</p>
  
  <p>My first thought was obviously a simple "Hello World" program. But it really doesn't show anything useful. It doesn't really show how we use functions, or variables, or control flow structures like <code>if</code> or <code>while</code> to make a program that actually <em>does something</em>. There's no logic to it. The program doesn't react to anything.</p>
  
  <p>So perhaps something like computing prime numbers would be a better example. But then again, that might be too theoretical and impractical... (What good is that? What does it have to do with writing "real" programs?) And again, there's no significant control flow logic in it. It's just a straight sequence of maths.</p>
  
  <p>And also, which language should be used?</p>
  
  <p>Ideally, I don't think it has to be a very "clean" language. But rather, it should probably make the structure clear. If it does that, then a certain amount of noise and clutter might be fine. Perhaps something like C++ would actually be a better example than Python for that reason. The explicit curly braces and type specifiers are obvious "hooks" to help explain how the program is structured, or to highlight that it's not <em>just</em> simple statements that can almost be read out as english.</p>
  
  <p>But with C++ we also get into some downright weird syntax. Why is <code>std::cout &lt;&lt; x</code> used to print out x? Why not a "normal" function call syntax? And <code>printf</code> isn't much better, with its arcane format string, and lack of extensibility (do I want to complicate the program by using <code>char*</code> for strings? Or do I use <code>std::string</code> and settle for calling the seemingly unnecessary <code>s.c_str()</code> to get a string that can be printed with <code>printf</code>?</p>
  
  <p>Perhaps a higher level language would be better after all. But which one? And why?</p>
  
  <p>I know there are plenty of similar questions here about which language/example program to use to teach programming. But I think the requirements here are different. When teaching programming, we want simplicity more than anything. We want to avoid anything that hasn't been taught yet. We want to make sure that the student can understand <em>everything</em> on the screen.</p>
  
  <p>I'm not interested in simplicity per se. But rather in giving an "outsider" an idea of "what a program looks like". And programs aren't simple. But they <em>do</em> generally exhibit a certain structure and method to the madness. What language/program would best highlight that?</p>
  
  <p><strong>Edit</strong><br>
  Thanks for all the suggestions so far. Some of you have had a somewhat different angle on it than I'd intended.</p>
  
  <p>Perhaps an example is in order. I can't fly an airplane, but I've got a basic understanding of what the cockpit looks like, and what a pilot "does" while flying.</p>
  
  <p>And I'm not a trained carpenter, but I know a saw or a hammer when I see one.</p>
  
  <p>But when you see anything to do with programming in movies, for example, it's usually just screens filled with garbage (as in the green text in the Matrix). It doesn't look like something a normal human being can actually <em>do</em>. There's nothing recognizable in it. Someone who isn't a programmer simply thinks it's black magic. </p>
  
  <p>I don't want to teach her to fly, or to program software.
  But I'd like to give her a basic frame of reference. Just an idea of "ah, so that's what you're working with. So it's not just random symbols and numbers on the screen". Even just showing a simple <code>if</code>-statement would be a revelation compared to the Matrix-style random symbols and numbers.</p>
  
  <p>Some of you have suggested explaining an algorithm, or using pseudocode, but that's what I want to avoid. I'd like something that simply shows what <em>actual</em> code looks like, in the same way that you don't have to be a carpenter to look at a saw and get a basic idea of what it is and how it works.</p>
  
  <p>When I was a kid, we once went on vacation in Italy. On the way down, the pilot let me into the cockpit of the plane. Of course, I didn't learn how to fly the plane. But I did get a peek into the pilot's world. I got an idea of how they make the plane go, what the pilot actually does.</p>
  
  <p>That's really all I want to do. My friend has no interest in learning programming, and I don't want to force her to understand source code. But she was curious about what kind of tools or entities I work with. Is it Matrix-style symbols scrolling across the screen? Pure mathematics? English in prose form?</p>
  
  <p>All I'm interested in conveying is that very high-level understanding of "What does it look like when I work".</p>