debuggable

 
Contact Us
 

The Linguistics of Programming

Posted on 16/9/08 by Felix Geisendörfer

Hey folks,

this is post #27 of my 30 day challenge.

When we think about programming languages, we often times think of them in terms of features, limitations, performance, syntax and other aspects.

Being asked how many "languages" we speak we might joke around, saying half a dozen not including a bunch of dialects of basic.

But really? How often do you really think of your programming languages just as you would of human languages? Lately I've been given the concept a lot more thought. And it is quite surprising how many parallels you can find.

It probably all started with the idea of having a dictionary for computer languages. For human languages we are very much used to the concept of using a dictionary that translates between a language we already know and the new language we want to learn. Why doesn't there seem to be books or sites out there that pick up on the idea for computer languages?

I mean, somebody's previous language skills seem to be just such an important aspect when learning a new language. Depending on the vocabulary (commands), syntax (~alphabet), grammar, philosophy (history) and features (expressions / idioms / constructs) people just come in with all kinds of assumptions when learning a new language. How can this be ignored in all of the learning material out there?

A follow up to this post will come tomorrow, but meanwhile I'd like to hear a little from you guys and what concepts you think are important in the human / computer language comparison.

-- Felix Geisendörfer aka the_undefined

 
&nsbp;

You can skip to the end and add a comment.

Mark Story said on Sep 16, 2008:

Felix: Are you thinking of something along the lines of a English-German dictionary, but aligned with programming languages ie. PHP-Python or Java-Ruby Dictionary?

I think that is an interesting idea, it would certainly help with learning a new language, especially when you are well versed in one language and just learning a second. I would definitely use a tool that would allow a language to language function look up / syntax reference.

More interesting would be the sections related to philosophy of the language and keeping things PHPified or pythonic for example. That to me is the hardest part of learning new programming languages.

timmyc said on Sep 16, 2008:

I completely agree. Recently I have been working quite a bit with Rails (coming off heavy Cake dev) and stumbled across a site (which also has a companion book) that helped me quite a bit:

http://railsforphp.com/reference

I think this is kind of what you are talking about... a cross-reference to lookup how to do 'x' function in your new language. But as Mark pointed out, there are definate 'culture' differences in languages... but like learning a spoken language, I think learning the culture, and how you fit in comes with immersion in the new culture!

Chris Forrette said on Sep 16, 2008:

It's odd that you post this because I've thought about this a lot lately as well. I just recently travelled (to Mexico) and I also saw this poster on the train to work that had the word 'Welcome' in a bunch of different languages, which, as a nerd, brought up parallels between our spoken languages and the coding ones.

Between all of the Latin-based languages you see a lot of similarities, e.g. 'Welcome' translates to something similar to 'Welcome' or 'Bienvenue' in almost every language, just as you would probably find something like 'echo' or 'print' in almost every coding language. There's also punctuation: "How are you?" versus "¿Como estas? and:

$someObject->myFunction("paramValue"); (PHP)

versus:

[someobject myFunction:"paramValue"]; (Objective C)

... and so on. There are even cases, for example sometimes with true OO languages versus PHP, where things will even get "lost in translation".

I've considered an application that would address this issue before and it would be very useful, especially if it translated concepts and general practices as well, not just simple echo = print, e.g. defining all the details of "PHPified" and "Pythonic", as Mark Story puts it...

Peter Goodman said on Sep 16, 2008:

Computer programming languages are defined in terms of grammars and to that extent are very similar to written languages (where a written language grammar would look at non/terminals as sentences, phrases, verbs, adjectives, nouns, punctuation, etc).

Language idioms are a bit more interesting; they are a lot like expressions in natural language. I think an interesting piece would focus on how to identify a programming language idiom.

GreyCells  said on Sep 16, 2008:

Hehe - when at parties and other social gatherings and the conversation turns to:

"...so, what do you do for a living?"
"I'm a creative writer."

"Really? How interesting."

"Mmmm, I write in several different languages."

"Wow! What languages?"

"PL/SQL, PHP, Java, Bash..." (interrupted)

"What?"

Well, at least it lasts longer than:
"...so, what do you do for a living?"

"I'm a programmer."

"Oh."

Felix Geisendörfer said on Sep 16, 2008:

GreyCells: Yeah I haven't quite figured out what to tell people in this situation. When I'm really bored I'll tell them I run an internet porn business, very fast way to get to know people by their response to that ; ).

Tim Koschützki said on Sep 16, 2008:

Lol yeah, this is always fun, especially Felix moved to Berlin and got to know all my friends. :D

Bruno Bergher said on Sep 16, 2008:

Felix,

I think it's an interesting point, but you have to consider something first: you can only turn to a dictionary for translation when you have at least some hold of the language.

I'm a native Portuguese speaker, and I can tell that when you I studied German (for six months or so), there wasn't almost anything that could be directly translated. A dictionary at that initial point in the learning curve would be entirely useless.

But when you start to understand a few things (German has three genres ad Portuguese has two and English has mostly a single, neutral one, Portuguese has the verbs in the opposite order of German and English, etc), you can then turn to a dictionary to try to translate specific words or expressions.

But when moving this concept to programming languages, the time it would take for you to get a good hold of the basics of the new language is equal or just slightly smaller than the one you need to get quite some vocabulary.

My point is that a reference like the one you propose would be certainly very useful, such as the one timmyc shares above, but when you are in a position to start to use it, the core of learning the new language (along with it's main syntax/construct/etc) would be already learned.

I'm not sure I offer any conclusive considerations, I just mean to add a bit to the thought pool : )

Joel Perras  said on Sep 16, 2008:

On the theoretical side, as long as the programming languages you are comparing are both Turing-complete, then a bijection can be found between the two. This basically means that your 'dictionary' would be comprehensive. (Note that most programming languages are TC, except really weird and useless languages based on untyped lambda-calculus. I try to forget about those, otherwise I might lose my lunch).

However, languages implement features quite differently; "repetition" is achieved using loops in PHP and most C derivatives, while recursion is used in functional languages such as Haskell and SML.

I believe a type of dictionary for languages could be achieved easily enough if their basic structures are similar, such as C# and Java, or even PHP and Python (ok, this one would be a bit harder, but easier when PHP6 is released). I would find it incredibly difficult to do this for Haskell and PHP, however, due to their inherently different implementations and philosophies.

SkieDr( Yevgeny)  said on Sep 17, 2008:

Language can be build as set of (Morphology, Syntax, and Semantic).
Morphology - operations and rules now you should name variables for example.

Syntax - a way how command combined in program (loops, branches and other constructions).

Functions, Classes and Methods live on semantic level.

Dictionary words in natural languages also lead to semantic.

You can transform code on Morphology and Syntax level but problem can appear on semantic if in one language some function should does not exists.

Mohamed Zeid  said on Dec 07, 2008:

That would be a great idea indeed, but I am not sure if you are referring to pseudocode (http://en.wikipedia.org/wiki/Pseudocode). If this is what you are thinking of, that would be great. I am sure this will be very helpful for all novice and advanced programmers. Creating a pseudocode dictionary for CakePHP and PHP for example, will give all people all details in plain English.

This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.