Ask HN: Is coding like speaking another language?
I'm in a position where I need to describe what coding is like to someone else. I'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:
"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."
However, I'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.
72 comments
[ 3.2 ms ] story [ 135 ms ] threadI would rather say, programming is like designing an intricate mechanism, such as a mechanical clock. Some people have compared it to carpentry, or engineering.
void declareEmotion( bool isInLoveWith ) { if( isInLoveWith ) { printf("I love you\n"); else printf("I'm sorry, this isn't working out...\n"); } }
Some form of "I like you" is as high as the emotions get there.
Whereas, you could "write" programs by arranging little pieces of would with symbols on them on a board. You could punch hole cards for a mechanical loom, or you could solder electronic components together. None of that involves communicating with other people.
I think a better analogy than language would be a mathematical calculus - i.e. the way you can write down certain symbols, and manipulate them using certain rules, and you have certain guarantees about the result.
Another analogy would be a "kit" of standardized/conventional elements for construction, e.g. I-beams, windows, tiles, 2x4s, doors, cable channels, ... . You arrange these things, and if you do it properly, you get something meaningful and useful like a house.
In carpentry you have many standardized off-the-shelf tools and components (hammers, nails, windows, tiles, dimensional lumber) and you have an almost endless number of ways to combine them. You can also create your own tools and components (which is harder). You also have some pre-determined guidelines that are meant to protect/regulate things so that they're safer and easier for a wider audience to live with, maintain, and edit (building codes).
Any of this stuff will work together as long as you stick to the constraints of individual objects as they fit into the laws of physics (a component can only bear X load in Y configuration).
The concept of "properly" is a bit varied. I can build a house with mud and straw and it's a "proper" house in some parts of the world... but it might kill me in an earthquake. This might be due to a pre-determined assessment of earthquake risk, or it might be because of limited knowledge and resources available (very common in coding, and often OK in small scale scenarios).
This link on grammar might also interest you- https://en.wikipedia.org/wiki/Formal_grammar
Japanese don't say "I love you" (winky face)
[1] https://www.quora.com/Do-Japanese-people-say-I-love-you-to-p...
[2] https://answers.yahoo.com/question/index?qid=20090222081745A...
[3] https://www.youtube.com/watch?v=azLpKvKBdHE
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.
* 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... :)
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.
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.
In other words, does being fluent in different languages cause people to think differently?
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.
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.
...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...
When you look at it like that, yeah, it's kinda like JavaScript - not really object oriented and not really functional but borrows concepts from both, loosely typed (rules aren't really enforced), and there's a new library every month that drastically changes the language (slang, evolving with the generations).
I only speak English, so I'm not sure if other languages are like this.
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.
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.
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.
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.
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.
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.
Cognizing (e.g.) the Eclipse codebase might be roughly equivalent to maintaining a complete mental model of NYC.
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?
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.
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.