
Ask HN: Is coding like speaking another language? - tbirrell
I&#x27;m in a position where I need to describe what coding is like to someone else. I&#x27;ve been programming since I was 13, so I understand it at a level that is hard to put into words, let alone describe to someone else. My latest attempt is as follows:<p>&quot;Coding is like working in another language. Just like spoken languages, programming language each have their own grammar and keywords. Reading code and understanding it is like having to translate a document.&quot;<p>However, I&#x27;m not bilingual, so I was wondering if someone who was could tell me if this is a reasonable simulacrum. Especially the comparison of effort and difficulty between grokking code and successfully translating documents.
======
travisjungroth
I think comparing programming languages to natural languages will lead your
listener down the wrong path.

Programming is writing instructions for a computer. It's just like how you
program your alarm clock to go off at a certain time. But imagine if you could
write instructions like, "If it's a weekday ring at 8, if it's a weekend ring
at 9. If I hit snooze, ring again in 5 minutes." A programming language is a
formal way of writing this down so it's easy for the computer to understand.

~~~
thomk
Its not just for computers, it's also (usually) for other programmers; people.

~~~
laythea
Yes but then it would be for other programmers for computers. Or for other
programmers for other programmers for computers. Better to say its for
computers :)

------
superplussed
As a programmer who is working on a language learning startup, I've thought
alot about how and why these two disciplines are different. And I believe that
learning a spoken language is actually much harder than learning a programming
language for the following reasons:

* In order to strengthen your spoken language skills you must engage in what amounts to a performance in front of experts, akin to getting on stage as an raw amateur and performing jazz music to a crowd of experts. Programming can be learned in the quiet and safety of your home.

* Speaking a language is a synchronous activity, programming is asynchronous. You need full command over an enormous amount of new material when speaking a new language, whereas with programming you can always pause things in order to look something up.

* Learning to speak a language has a slow feedback loop compared to programming. You learn concept or word A, and by the time you first need to deploy that word or concept in the wild, it has been forgotten.

* Learning to speak a language has inconsistent feedback, with native speakers giving contradictory or unclear advice. Compilers, not so much.

* Speaking a language requires relearning muscoskeletal behavior that has been ingrained since birth.

* Speaking a new language badly is an act of courage that often penalizes introverted or perfectionist personality types. These types thrive when learning computer programming.

I could go on... :)

------
Tharkun
No. It's more like speaking the same language (English or whatever) aimed at a
very specific audience. A bit similar to talking to someone who takes
everything literally. Without room for interpretation.

In that sense, it's closer to a method of organizing thought than it is to
another language.

Background: software engineer who speaks 5 languages.

~~~
tomphoolery
Do you feel like learning each of the languages you can speak has affected the
way you think in any way?

In other words, does being fluent in different languages cause people to think
differently?

~~~
maxxxxx
Yes, different languages make you think differently. Some things are easier to
express in one language than the other.

------
captainmuon
I think it is very unfortunate that we use the same work "language" for human
languages and computer languages. They are nothing alike, except you can write
them in textual form and they have some kind of "grammar". It's a bit silly,
but if you can't say "I love you", it is not a language to me.

I would rather say, programming is like designing an intricate mechanism, such
as a mechanical clock. Some people have compared it to carpentry, or
engineering.

~~~
oerpli
In the native dialect of western Austria you can't say "I love you".

Some form of "I like you" is as high as the emotions get there.

~~~
StavrosK
"The authorities are desperately searching for a husband of 47 years, who
killed his wife in a horrific crime of mild attraction"

------
imron
It's not like working in another language at all (I speak English and
Mandarin).

When I try to explain to non-programmers what programming is like, the analogy
I like to use is drawing.

With drawing, you start of with a blank piece of paper, and someone asks you
to draw something (or you decide to draw it for yourself) and so you draw
away, adding bits here and bits there, adjusting things, erasing things,
redoing mistakes and maybe even starting over entirely. Slowly it starts to
take shape and you keep going until you are satisfied with the end result
(though sometimes you are never fully satisfied and there are always small
adjustments you feel you could make).

Each artist has their own style and you could ask 10 people to draw you a
picture of a house or a dog, and you'd get 10 different pictures of houses and
dogs, each one definitely a house or a dog (assuming competent artists here),
but each one unique and drawn in the style of the individual artist.

Programming is then drawing with math and logic. You start with a blank file,
and someone asks you to program something (or you decide to program it for
yourself) and so you program away, adding bits here and bits there, adjusting
things, erasing things, redoing mistakes and maybe even starting over
entirely. Slowly it starts to take shape and you keep going until you are
satisfied with the end result (though sometimes you are never fully satisfied
and there are always small adjustments you feel you could make).

Each programmer has their own style and you could ask 10 programmers to
implement a given program or feature and you'd get 10 different programs, each
one matching the requirements (assuming competent programmers here) but each
one unique and programmed in the style of the individual programmer.

Anyway, it's not a perfect analogy, but I've found it works quite well to
explain things to non-programmers.

------
Bjorkbat
Not really. Looking at my code, I'll often see myself writing comments where I
refer to functions and the like as "things". I never see written sentences as
things, at least not in the same way.

The closest analogy I can think of are magic spells. When I think of, say, a
wizard, casting a spell, I don't think of him speaking some kind of magical
language, he's uttering some words which have magical consequences. In this
way a spell is a thing which results in an action. In the same way I use a
programming language to write what I see as discrete blocks of code that cause
something to happen. By contrast, "normal" languages are just used for
communication.

It's kinda hokey, and you probably won't be able to tell people that
programming is like creating magical spells, but you asked.

------
conner_bw
When it comes to code, English speakers like to talk about how good, pure, or
expressive a code language is. For example, ask people up in here to describe
PHP and you'll get bile. Ask them to talk about Closure and you'll get
accolades. Usually summarized as "because the language is bad the result will
be bad"

...the irony is that the discussion will be in English. One of the worlds most
inconsistent, awkward, written languages. [1] Further more, most code _is_
English. Example: it's usually "if/else" not "si/sinon" or "と/又は"

IMHO I don't think the analogy holds. However, I don't know of a better way to
describe it.

PS: I'm bilingual (French/English)

[1] [http://aclassen.faculty.arizona.edu/content/english-
language...](http://aclassen.faculty.arizona.edu/content/english-language-
crazy-inconsistencies)

~~~
_proofs
There are a number of polyglots who disagree with your sentiment. Nabokov
immediately comes to mind. He preferred english because of its capacity for
precision and expressive-ness.

------
turc1656
No, definitely not. To me it is about the logical flow of thought that is put
into a structured format. That might sound like spoken language, and to a
certain extent it is. But code is more than just that. It is precise. There is
no ambiguity. There are hard rules. A violation of format/structure/syntax is
not allowed.

Most importantly, logical errors result in unexpected behavior. In most spoken
language, someone could be an absolutely terrible speaker and can still manage
to get the idea across. There is no code equivalent of saying to someone, "I
dunno, it's hard to explain, but you know what I mean, right?"

I would say the closest "language" that code can be related to is legalese. It
has definitions and exceptions and legal agreements tend to conform to
standard to ensure their validity and enforceability. A significant error in
this regard would void the agreement, or at least part of it - similar to a
compiler error. Also, I like to think of good code being a battle plan where
you want to make sure no one is able to do anything you don't want them to do,
even if they do something unexpected or deliberately try to break your code.
You try to think of every scenario that you can possibly encounter and you
code for it. This creates a defense for your code. Legal documents tend to be
created with a similar mindset of protection and survival.

------
metaphorm
I think it's more like learning to express yourself in a different style,
rather than learning an entirely different language.

The style we are accustomed to allows for an interlocutor with significant
ability to fill in the gaps in what you've said or written. To read
appropriate context and subtext into your words and interpret them
meaningfully despite ambiguity.

The style we must learn when programming is to remove all possible ambiguity
and subtext, and explicitly provide a context (arguments, scope, closure,
environment, etc.) for evaluation.

When we learn a new language we learn new vocabulary and alternate syntax but
we still express ourself in the same style. When we learn a new style we must
unlearn and relearn all of our assumptions about how language is interpreted.
That's what learning programming is like.

------
drewrv
I don't think they're similar at all. It's an anecdote and all, but I am
terrible at learning foreign languages. Something about the way my brain
works. I lived in France for two years and married a French woman and I still
couldn't get by for more than a day or two in that country on my own. Yet I
picked up programming pretty quickly and consider myself good at it.

I think the best analogy is mathematics, in the sense that you're reasoning
about abstract objects and solving puzzles. Unfortunately most people don't
think about math that way so it probably doesn't help much.

------
noahlt
The authors of SICP draw a distinction between declarative knowledge (facts
about the world) and procedural knowledge (instructions for how to do things).
Programming, they say, is a way to precisely communicate procedural knowledge.

Most interpersonal communication is both imprecise and not procedural
knowledge, and that is the biggest difference between speaking with a person
and programming a computer.

------
lillesvin
Linguist here. It's doesn't seem very similar to speaking another language at
all. Hockett's Design Features is a set of features that is commonly used to
distinguish natural human languages from other systems of communication:
[https://en.wikipedia.org/wiki/Hockett%27s_design_features](https://en.wikipedia.org/wiki/Hockett%27s_design_features)

Not that those features are requirements or anything, but they serve as a good
guideline. As you can see, programming languages lack many of these features.
For one, lack productivity — you can't suddenly switch up the syntax in some
novel way or make up a new keyword to achieve some effect and expect the
compiler/interpreter to just understand it.

Programming is probably more akin to a jargon + some technical knowledge to go
with it, but it's still a bad comparison because a jargon is still a part of a
natural language — programming languages are not.

------
pinkythepig
I like to equate it to giving instructions to someone who takes everything you
say extremely literally. Ask me to make a PB&J? If you tell me to stick the
knife in the PB, since you didn't specify what side to stick in, I sometimes
put it in handle first, sometimes knife edge first, depending on how I found
it. To make a successful program, you would need to account for all the
possible inputs (the different orientations of the knife in the drawer, the
possibility that there might not be a knife, etc.). The difference between
good software and bad software is that the good software will properly handle
all of these error conditions, and the bad software will either do the wrong
thing (sticking it in handle first, because the instructions assumed the knife
was always oriented correctly) or will crash when something unexpected happens
(such as there not being any more knifes, or running out of peanut butter half
way through making a sandwich).

------
0x4f3759df
Coding is like describing a trip to the grocery store in 100 pages.

"He stood up, he walked forward 10 paces, he grabbed the door, he opened the
door, he walked through the door..."

~~~
KirinDave
Let's all stop using such imperative languages!

~~~
qbrass
...(by walking through the door (by opening the door (by grabbing the door (by
being close enough to grab the door (by taking one step towards while being
more than one step away from the door and repeating until he was close enough
to grab the door))))...)

~~~
KirinDave
closeDoor >>= foldM (stepsTo valhalla)

------
dansanuf
As a bilingual person, I wouldn't describe learning to code as being similar
to learning a new human language. The fundamental building blocks of
programming (loops, variables, functions, etc.) are vastly different from the
building blocks of human language (nouns, verbs, adjectives, etc.).

However, I would describe learning a new programming language if you already
know one (say, C++ to Python) as similar to learning a new human language
(English to Spanish). The languages in both cases may be different, but the
fundamental building blocks of expression are mostly the same.

------
fragmede
Who's your target audience, and what will that description be used for?

That single sentence of description is fine for a general audience, and as a
lead-in to a more in-depth discussion but it's a single sentence and not an
in-depth analysis. There are books more that could be said about the
differences and similarities between being multilingual for programming
languages verses spoken languages but a dissertation on why the comparison
(likely) not what's being asked of you.

The follow-on ramifications of something being in a different language than
one you speak, rather than a comparison of multilinguality itself might be
useful to highlight. It's one thing for you as a person to speak two
programming languages, but if one language runs server-side, and the other is
client side, it's good to illustrate that teaching Chrome to "speak" a
different language is going to be harder than for your company to provide
translations. Similarly, if the company is trying to move to and canonicalized
on a second programming language, it needs to be illustrated (in lines of
code) as to how much currently exists at in the first language, and must be
translated to the second.

Programming languages are not like spoken languages because people there can
be discussions about syntax and parsing, but then a new version of the
compiler comes out and the system is rolled and every"one" speaks the new
version (and the old, for that matter). Meanwhile we're still working on being
able to do that for humans.

------
innocentoldguy
I know several programming languages (e.g. Elixir, Elm, Erlang, Haskell, Ruby,
Python, etc.), and I also speak English and Japanese fluently. With
programming languages, the fundamentals beneath the syntax are basically the
same. For example, whether I use recursion or for loops, all of the
programming languages I know support iterating through a list of data.
Similarly, they all have some mechanism for making logic decisions, such as if
or case statements. So, learning a new programming language is just a matter
of mapping new syntax to concepts I already know. If learning a new spoken
language were simply a matter of mapping vocabulary words to meanings, then I
would say both are the same, but this is not the case.

In spoken languages, there are cultural differences that have to be learned
and concepts that just don't translate well between languages, if at all.
Idioms are also difficult. Often times, there is no cultural foundation in one
language to make sense of the idioms used in another. Unlike computer
programming, there is no underlying base that you can use to map new knowledge
too. You have to build your entire understanding from scratch.

------
CodeTheInternet
I would assume it feels that way to those who don't speak English natively.
Otherwise, I would say it's more like turning math into a language.

------
ramses0
Programming is a "class of language" ... latin/romance, germanic, slavik, etc.

"I speak programming. Specifically I speak C++."

Furthermore, within programming there are classes of languages (imperative,
functional, oo, pattern matching, etc).

"I speak programming. I understand imperative and OO from C++, but struggle to
understand functional, as I'm not used to composing my thoughts that way."

There are varying degrees of fluency / literacy in each of these classes of
languages.

"I'm an expert in C++11, and wouldn't hesitate to write or maintain any C++
code. I can also read and modify many C-like languages (Java, JavaScript,
Objective-C, Go) and may play with them on the weekend, but they would not be
my first choice in starting a project at work. I can read some lisp code, but
I can never understand something written in erlang no matter how many times I
try."

So I would say that you can draw comparisons between northern v. southern
english (ie: versions of C++) then english (ie: C-like languages) rolling up
into germanic / romance (ie: imperative languages).

Regarding "translation", that's reasonable to understand. However, a
programming translation has extra requirements to be successful.

1) it must be complete (at least the translated portion) 2) it must be 100%
correct 3) regardless of the language, it must cause the same effect

...a partial translation, a translation with errors, or a slightly different
meaning can "ruin" the programming translation, whereas minor errors or
awkwardness in your normal translation are generally easy to overcome compared
to a traditional written text designed for human (not computer) consumption.

------
nikdaheratik
It really depends on the language and what you are doing. The majority of of
the field is closest to working with mathematical equations which makes sense
as the people who created the languages took ideas from mathematics when
designing the language and did the hard work of transforming those ideas into
something that could be ran on a computer.

However, as you get closer to the hardware level, you move away from the
abstract and need to think about the way the machine is built/configured and
the actual instructions that will be executed. There are some languages, like
C, that kind of bridge the divide between the two. Others, like Lisp, are
almost entirely abstract with little need to think about how the instructions
get ran at a lower level.

------
jon_richards
Combining a few other answers, I'd say it's a lot like writing a goosebumps
(choose your own adventure) book in another language.

While I do like the analogy of writing instructions for someone who is very
dumb, that analogy doesn't capture the different paths of execution that a
program can take.

------
udfalkso
Not quite, but what I do believe is true is that learning multiple programming
languages is similar to learning multiple spoken languages.

Just as knowing Spanish will aid you in learning Portuguese, knowing Python
will help you pick up Ruby. After you know a few varying languages it becomes
much easier to pick up a new one. You notice that they all share the same
basic constructs.

Also, each language (in both realms) brings new modes of expression to the
table and these can open your mind to alternate ways of thinking. You notice
this with spoken languages most when you run into a phrase that is
untranslatable to some other languages. This part is perhaps more true of
programming languages than spoken languages, but I believe it is true of both
to some degree.

------
KirinDave
It depends. But generally, I think it is. Although it uses different
facilities from those which we commonly use to speak languages.

It's most evident when you use related families of languages. Using up to
Python, Ruby or Coffescript is a lot like the related family of english
languages; once you know one or two you sort of get them all fundamentally.
Javascript, Io and Perl are like lost cousin languages; you can often
recognize bits but the sentence structures and dialogue conventions may seem
quite foreign.

Confronting purely functional languages is VERY much like having to relearn
the same skills of communication from the ground up.

------
alexashka
I'd say it's like writing down very specific instructions to do something,
that afterwards can be translated to manipulation of numbers.

The results get to be stored, retrieved and displayed.

Since it's a manipulation of numbers, the set of rules you get to use are all
based on logic (if this, then that, etc)

Then you can add an extra step of number manipulation can be boiled down to
manipulating binary numbers consisting of 0s and 1s, so the logic used is
boolean logic etc.

So I'd say programming is more like learning logic constructs (math) - it's a
universal language with rules that are interested in manipulating values in
very complex ways.

------
brango
Yes. It's a way of thinking that is communicated by words. Same as speaking a
foreign language for me. I wouldn't be surprised to find out that the same
parts of the brain are involved.

To elaborate, in some spoken languages you have adjective noun (e.g. blue
house), but in others the order is reversed (casa azul). At some point of
learning you just subconsciously know which form to use. This is similar to
programming when you can use the appropriate idioms in each language. E.g.
using duck typing in python vs type checks/conditionals etc. in Java.

------
CryoLogic
I think it's more like a different type english.

You express the same types of concepts, but you break them down into very
small parts and than build up the argument comprised of small parts.

Like instead of saying "the bike went forwards" which is very conceptual and
requires a lot of background understanding of bikes and physics, you describe
a bike consisting of wheels, a frame, a steering wheel etc. than describe the
action of moving in a direction. finally you apply to action to the bike.

------
SadWebDeveloper
No, coding is a series of instruction put on a specific order for a machine to
process not an a instrument to communicate with another (computer) entity.

Modern languages are designed to be the most human-friendly possible to
express those "commands", even the "lowest" language you could learn
(assembly) it's still way to human friendly if compared to real bare bones
communicating with the computer hardware.

------
shujito
It's not (quite)

Despite being called "programming languages", they are not really languages
for people to communicate, but for computers to understand instructions
(although, humans do need to understand a programming language to be able to
code).

Saying that coding is like speaking another language can be confusing, so I'd
recommend that coding is more like instructing a computer to do something (by
writing instructions).

------
indubitably
I don't think so at all. Natural languages evolve with ambiguity built in —
any sort of ambiguity is almost always an error in programming.

------
bjourne
Someone can say "coding is like solving equations" another "coding is like
wandering in a (irl) forest." I don't think there is any right or best answer.
My take on it is that coding is like sculpturing, but that answer is just as
flawed as all the others. Few activities (that I know of) are very similar to
computer programming.

------
machinemob
I actually agree with your simulacrum. I also agree with others that code has
more in common with a cake recipe than Pride and Prejudice ;-)

The above said, language is language whether you're struggling to control a
state-machine, baking vegan cookies or ordering lunch in Paris. It's
difficult, it takes time to learn and delivers the same rewards all around.

Cheers

------
novembermike
Programming is about defining requirements in excruciating detail. A business
person says "I want this data stored somewhere" and a programmer has to define
where it comes from, what the schema is, what transformations happen, how does
it get stored, where does it get stored, and what happens if anything in that
pipeline goes wrong.

------
satisfice
To code is to be very, very specific. That's it. Imagine asking someone to get
you a coffee, but you have tell him exactly how to do it down to the tiny
details of how to grip a cup with fingers.

The challenge of learning to code is largely the challenge of learning to be
specific in your communication and having the patience for all that entails.

------
tptacek
Not even a little bit. It's more (but not perfectly) like if we had multiple
alphabets to express the same language.

~~~
canoebuilder
A cogent thought, by which I assume you mean, it's all ultimately bit
manipulation.

But in this view can't all the world's languages be seen as multiple alphabets
that express and manipulate quantum fluctuations?

Or do different human languages create different underlying realities?

------
eitland
Most of the code I write is a mix of broken English and simple equations.

I agree with you: programming languages are languages.

I personally find them simpler than normal languages (no gender pronouns like
in German, no special rules for past and present tense etc. Oh, and immediate
honest (if somewhat mumbling) feedback from the compiler.

------
caspervonb
Polyglot here, dont think that it matters tho.

I think of it more as a notation and has more in common with constructs like
mathematics than actual spoken language. Yeah we have rules and syntax
grammer, but at the end of the day you are expressing it in plain ol English.

------
dozzie
No, it's not really like that. It's more like preparing an instruction on how
to execute some complicated process, say, cook a fancy meal, for somebody who
is very dumb (but will follow the instruction precisely).

------
rch
I find that programming feels more like spatial navigation than speech or
language.

Cognizing (e.g.) the Eclipse codebase might be roughly equivalent to
maintaining a complete mental model of NYC.

------
ams6110
I would say no. It's a shorthand way of writing very explicit instructions.
There is far more variety and nuance in human languages than in programming
languages.

------
vkjv
No. In my opinion, it's much closer to domain specific jargon. Similar to
other specialized fields (e.g., paleontology).

