Crystal: Use Esperanto instead of English

Created on 1 Apr 2016  ·  30Comments  ·  Source: crystal-lang/crystal

Saluton!

We wanted to propose this for a long time and now we have gathered enough evidence to think this is a good idea.

What if we make Esperanto the default language used by Crystal? With this we don't mean just the official docs, but the language itself: the keywords, the classes, the methods, etc.

Why? Well, I'll enumerate the reasons in no particular order.

1. Question and bang methods

Right now some methods have a question method at the end. For example:

array.empty?

I believe the reason Ruby did this, and why we copied this rule, is because this:

array.empty

is confusing: will it empty the array or is it asking if the array is empty? Of course an alternative is to use array.is_empty, but that reminds us of more verbose languages so we prefer to avoid that.

The real reason is that the gramatical use of a word is not clear in English: "empty" can be both a verb and an adjective.

In Esperanto a word's gramatical meaning is encoded in itself via its ending:

  • If a word ends with "a" then it's an adective
  • If a word ends with "i" it's a verb

So, in esperanto it could simply be:

aro.malplena

No confusion: it ends with "a" so its an adjective. Here "malplena" means "empty". "Plena" means "full", and the prefix "mal-" gives the exact opposite meaning of a word (I'll talk about this later).

(By the way, note that "aro" ends with "o": all nouns end with "o".)

Then to empty an array we currently have array.clear (which, by the way, might be bringing the same confusion as empty). In Esperanto it will be:

aro.malplenigi

The suffix "-ig-" (put before the gramatical indicator of a word) means "to make something ..." or "to turn something into ...". In this case it means "to make something empty". How more obvious can it be? Right now in Ruby there are many aliases, and I believe it's because you can express yourself in English in too many ways. In Esperanto there's always a clear, obvious way, so the language's vocabulary becomes more intuitive by design.

Also talking about the "-ig-" suffix, we could have:

aro.kolekti { ... }   # same as `array.map  { ... }`
aro.kolektigi { ... } # same as `array.map! { ... }`

because "-ig-" means "to turns something into". The bang method becomes redundant and we could use it for another meaning, maybe "not_nil!".

This will also free the question symbol. We could use it for the "lonely operator":

foo.try &.bar # current syntax
foo?.bar # new syntax

It's a win-win situation.

2. US vs UK

We received many complaints about some Ruby/Crystal methods. The most obvious ones are "initialize" and "finalize". Some messages we received in private and IRC:

  • Why "initialize" instead of "initialise"?
  • I always find this confusing, can we maybe choose another name?

We agree, the name must change. But since there's no obvious good candidate (US or UK?), it seems fair to switch to a neutral language.

The names for "initialize" and "finalize" in Esperanto will be "iĝi" and "maliĝi". "iĝi" means "to become" (note the similiarity with the word "igi" described above). The prefix "mal-" gives a word its opposite meaning so "maliĝi" means "cease to exist". Wouldn't this be super awesome and intuitive in a language? I mean, there's no obvious relation between "initialize" and "finalize", if you look at them.

3. ! (not)

In Esperanto you can attach the "ne-" prefix ("ne" means "no") to give a word the meaning "not ..." (note that this is different from "mal-" which gives a word its total opposite meaning). So, we could make the language recognize methods starting with "ne" to mean "!...". For example:

se koekto.malplena # if array.empty?
  # ...
fino # end

se aro.nemalplena # if !array.empty?
fino # end

Of course this is just syntax sugar, but if you read it in Esperanto it's a gramatically correct sentence. However, "if not array empty" is not a valid English sentence.

4. Learn Crystal, learn Esperanto... and the other way around

We believe both Crystal and Esperanto need to grow. If learning Esperanto means you can also start programming in Crystal, and if learning Crystal means that you can start to speak Esperanto, then its a mutual help where both parties could really benefit.

Not to mention that learning Esperanto opens your mind to other languages, and makes it easier to learn them. For example after I learned Esperanto I learned French and it was very easy: "fenêtre" in French is "window", and in Esperanto its "fenestro". Or you re-learn (because you probably learned that in school) about direct objects, and how in Esperanto you use "-n" for this, and how in Japanese you use "を" for the same purpose.

It's also the case that learning Crystal opens your mind for learning other programming languages :-)

5. Why English?

We don't see any particular reason to choose English over another language other than "it's the _lingua franca_ of the moment". In a previous century it was French, so why choose a language that might stop being used that much? In any case docs for Crystal are still made for other languages, like Japanese, Portuguese and Russian, which probably means that not everyone understands English very well.

Esperanto has the benefit that (almost) no one is born knowing it so nobody has an advantage over somebody else (for example native English speakers always feel at home with programming languages), so it's only fair to use a neutral language. Many also compare Esperanto with Unix, calling it the "open source" spoken language.

Final notes

Here's a small code example written in the future language:

klaso Aro
  dif malplena
    @grandeco == 0
  fino
fino

aro = [] de Int32
se aro.malplena
  printi "La aro estas malplena"
sene
  printi "La aro havas #{aro.grandeco} erojn"
fino

(If you find the above confusing it's probably because of lack of proper syntax highlighting)

We believe that as we will translate the language to Esperanto we will find many more cases where Esperanto's clear and concise rules will benefit the language.

What do you think? We'd love to know your opinion on this!

draft wontfix

Most helpful comment

Neden Türkçe yapmıyoruz? (Why not Turkish?)

sınıf Merhaba
  işlev dünya
    mesaj = "Merhaba Dünya!"
    yazdır mesaj
  bitti
bitti

sayılar = Int32 ile []
sayılar.ekle 1
sayılar.ekle 2
eğer sayılar.boyut > 0
  yazdır "Sayılar #{sayılar.boyut} adet"
değilse
  yazdır "Sayı yok"
bitti

Merhaba.yeni.dünya # "Merhaba Dünya"

All 30 comments

Mi tute konsentas! :+1:

Perfekta!

A strong downvote from me :-1:

LOL :smile:

april fool!! :tada: :tada: :tada:

Neden Türkçe yapmıyoruz? (Why not Turkish?)

sınıf Merhaba
  işlev dünya
    mesaj = "Merhaba Dünya!"
    yazdır mesaj
  bitti
bitti

sayılar = Int32 ile []
sayılar.ekle 1
sayılar.ekle 2
eğer sayılar.boyut > 0
  yazdır "Sayılar #{sayılar.boyut} adet"
değilse
  yazdır "Sayı yok"
bitti

Merhaba.yeni.dünya # "Merhaba Dünya"

Great idea! I'll go get myself an Esperanto book straight away ;)

klass Uppsättning
   def tom?
     @storlek == 0
   slut
slut

uppsättning = [] av HelTal32
om uppsättning.tom?
   skriv "Upsättningen är tom"
annars
   skriv "Uppsättningen har {uppsättning.storlek} artiklar"
slut

B-)

Mi amas esperanto! :heart:
Eble ni devus ŝanĝi al io kiel http://www.emojicode.org/

I think we will need to add a compiler level or language level translation support :laughing:

hahaha 👏🏼

@rhysd We could make transition easier by requiring a file included in the standard library:

bezoni "English"

# Now we can use English again
require "array"

Thanks to macros this should be super easy:

makro require(file)
  bezoni {{file}}
fino

@asterite

Sounds great :heart:

:+1: Finfine!

I support the idea, but I think you shouldn't stop with that. Obviously the language should be called
kristalo then.

For those who want to learn Esperanto there is a course at Duolingo: https://www.duolingo.com/course/eo/en/Learn-Esperanto-Online

@bcardiff

Mi amas esperanto!

Me forgesu pri akuzativo, samideano!:)

@iGEL That's another good reason to switch, as Google will probably give more accurate searches when searching "krystalo" instead of "crystal".

Sounds lovely.
Vidu I estas bona ĉe ĉi.
:laughing:

Awesome !! But I will prefer Greek language because characters looks beautiful !!

Καλό μήνα

I'd love you'd posted this tomorrow

Ej! Kiel granda ideo. Fartu bone. Adiaŭ!

mqdefault

I … I might actually like that.

Well, I think that's enough for today :smile_cat:

Thank you for taking this in a funny way, and I really hope nobody got offended with this. My intention was just to put a little humour today, but at the same time propose something that might actually make sense. I myself speak Esperanto and really like it, and I'm glad to have found some Esperanto answers in here as well!

It was also interesting to see some nice comments about Esperanto in hackernews and reddit, even making critics to this proposal by, for example, saying that I should have used "u" (imperative) instead of "i" (infinitive) in the examples. Or reading that someone thinks this is a good introduction to Esperanto (really nice), or mentions in Esperanto about this issue.

And thank you @sdogruyol for spreading the word in those websites! :bow:

Sometimes you make me so happy, github <3

I stumbled across this from reddit. I just have to say I didn't know this existed and I love the idea. I would not be able to pick up the language without a lot of help. But I would be heavily incentivized to give it a shot because of the sentiment. I applaud this project for concepts like this, both in vision and inclusiveness.

I've been learning esperanto. That would be so cool and make (somewhat) sense to have a programming language in esperanto.

Jes, kompreneble! Ĝi estus tre bona ideo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sija picture Sija  ·  3Comments

jhass picture jhass  ·  3Comments

will picture will  ·  3Comments

ArthurZ picture ArthurZ  ·  3Comments

pbrusco picture pbrusco  ·  3Comments