Canol Gökel


Sloganı olmayan blog

Smalltalk and Turkish

I realized one important thing which pulls me towards Smalltalk, subconsciously. Smalltalk’s syntax resembles Turkish in some ways. I will try to show it via examples.

The first thing which seperates Turkish from other English like languages is that verbs are put at the end of sentences, not after the subject. In English, the order of sentence components is:

Subject verb object.

In Turkish:

Subject object verb.

In Turkish, you can join subject and verb into 1 word. In that case it is like:

Object verb.

The key thing here is that objects are “before” the verbs in English and “after” the verbs in Turkish. Let’s take some examples:

1 to: 3 do: [something].

In English like languages you normally tell such a pattern as:

Do something from 1 to 3.

In Turkish:

1'den 3'e kadar birşey yap.

“1’den 3’e kadar” means “1 to 3”. “birşey yap” means “do something”. In Turkish “what to do” is said after specifying other details. But in English you first say what to do and then specify the details.

Take an example for splitting a string. A message might be formed like this:

'A string to be splitted' split.

In english you would say:

Split the sentence "A string to be splitted".

In Turkish:

"Bölünecek cümle" cümlesini böl.

“cümlesini” means “sentence” and “böl” means “split”. In programming we don’t need to specify that it is a sentence because it is understood from single quotes. So let’s form English and Turkish sentences without “the sentence” and “cümlesini”:

In English:

Split "A string to be splitted".

In Turkish:

"Bölünecek cümle" böl.

Can you see the closeness of Smalltalk expression and Turkish sentence?

'A string to be splitted' split.
"A string to be splitted" böl.

Maybe a C++ or Tcl like syntax is more close to English in this one:

split("this sentence");
split "this sentence"
Split "A string to be splitted".

This is because in Turkish, you first tell the object and then what to do with it, in contrast to English inwhich you first tell what to do and then the object in concern.

Now take the ifTrue: controlling message:

[something] ifTrue: [do another thing].

In English you would say:

if something is true do another thing.

It is close but not as close as Turkish because you give the “controlling meaning” before the condition via “if”. In Turkish you give the condition first and then give the controlling meaning:

Birşey doğruysa başka birşey yap.

“Birşey” means “something”, “doğruysa” means “if true” and “başka birşey yap” means “do another thing”.

Birşey => [something]
doğruysa => ifTrue:
başka birşey yap => [do another thing]

The classic C style is more close to English:

if (something is true) do another thing;

We can tell the same thing with whileTrue: message.

In conclusion: Although in some situations C style syntax is more close to English; in general, Smalltalk is more close to both English and Turkish compared to C style syntax. But it is even more close to a Turkish language user. There are “suffixes” in Turkish which causes some serious differences between Turkish and English/Smalltalk but the main order of sentence components causes it to feel native to Turkish people. I read somewhere about Turkish being an ideal computer language syntax but didn’t see an example until Smalltalk. But I think the suffix system of Turkish language would make a computer language design unnecessarily complex, like the article system of German language (der die das) would, too.

Maybe the thing I mentioned above is one of the reasons why I fall in love with Smalltalk syntax.

Filed under: Programming, ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: