DEV Community

Tomasz Wegrzanowski
Tomasz Wegrzanowski

Posted on

100 Languages Speedrun: Episode 85: Linguagem Potigol

Linguagem Potigol is a programming language for Portuguese-speaking beginners where all English words have been replaced with Portuguese words.

To run it you'll need to download the .jar file from GitHub, but it has editor plugins for VSCode, so it's not too bad.

I'll be doing a lot of Google Translate for this episode, so don't expect too much from my Portuguese.

Hello, World!

Let's start with the obvious:

escreva "Olá Mundo!"
Enter fullscreen mode Exit fullscreen mode
$ java -jar potigol.jar -w -c ola.poti
Olá Mundo!
Enter fullscreen mode Exit fullscreen mode

Greetings

We can assign to variables without any hassle, and there's string interpolation:

escreva "Qual é o seu nome?"
nome = leia_texto
escreva "Olá {nome}!"
Enter fullscreen mode Exit fullscreen mode
$ java -jar potigol.jar -w -c ola2.poti
Qual é o seu nome?
Amanda
Olá Amanda!
Enter fullscreen mode Exit fullscreen mode

FizzBuzz

The words are different, but structure of this program is basically identical to what you'd expect:

para número de 1 até 100 faça
  se número mod 15 == 0
    escreva "FizzBuzz"
  senãose número mod 5 == 0
    escreva "Buzz"
  senãose número mod 3 == 0
    escreva "Fizz"
  senão
    escreva número
  fim
fim
Enter fullscreen mode Exit fullscreen mode

By the way accents in all keywords are optional, I'll just use them for extra authenticity. What would be the point of programming in Portuguese and not at least trying to spell it properly?

Fib

We need to declare types of function arguments and return values, but at least we don't need to write any retorne, last expression will be the default valor de retorno.

fib(número : Inteiro) : Inteiro
  se número <= 2
    1
  senão
    fib(número - 1) + fib(número - 2)
  fim
fim

para número de 1 até 30 faça
  escreva "fib({número})={fib(número)}"
fim
Enter fullscreen mode Exit fullscreen mode
java -jar potigol.jar -w -c fib.poti
fib(1)=1
fib(2)=1
fib(3)=2
fib(4)=3
fib(5)=5
fib(6)=8
fib(7)=13
fib(8)=21
fib(9)=34
fib(10)=55
fib(11)=89
fib(12)=144
fib(13)=233
fib(14)=377
fib(15)=610
fib(16)=987
fib(17)=1597
fib(18)=2584
fib(19)=4181
fib(20)=6765
fib(21)=10946
fib(22)=17711
fib(23)=28657
fib(24)=46368
fib(25)=75025
fib(26)=121393
fib(27)=196418
fib(28)=317811
fib(29)=514229
fib(30)=832040
Enter fullscreen mode Exit fullscreen mode

Class

We can declare new types by listing their instance variables. There's default constructor, default string representation, and so on:

tipo Pessoa
  nome : Texto
  sobrenome : Texto
  idade : Inteiro
fim

maria = Pessoa("Maria", "Santos", 27)
josé = Pessoa("José", "Rodrigues", 22)

escreva maria
escreva "{josé.nome} {josé.sobrenome} tem {josé.idade} anos"
Enter fullscreen mode Exit fullscreen mode
$ java -jar potigol.jar -w -c pessoa.poti
Pessoa(Maria,Santos,27)
José Rodrigues tem 22 anos
Enter fullscreen mode Exit fullscreen mode

Portuguese Wordle

Based on this repository, I setup a list of 6254 common 5-letter Portuguese words. The list already filtered out accented characters. I have no idea how good this list is, I'm just coding here.

And with the list, I created command line Portuguese Wordle:

verifique(acho : Texto, palavra : Texto)
  var blocos = ""
  para número de 1 até 5 faça
    se acho[número] == palavra[número]
      blocos := blocos + "🟩"
    senãose palavra.contem(acho[número])
      blocos := blocos + "🟨"
    senão
      blocos := blocos + "⬛"
    fim
  fim
  escreva blocos
fim

palavras = Arquivo.leia("palavras.txt")
palavra = aleatorio(palavras)

var acho = ""

enquanto acho <> palavra faça
  acho := leia_texto
  se acho.tamanho == 5
    verifique(acho, palavra)
  senão
    escreva "palavra deve ter 5 caracteres"
  fim
fim
Enter fullscreen mode Exit fullscreen mode

And here's my totally authentic first game. Not bad:

$ java -jar potigol.jar -w -c wordle.poti
amigo
🟨⬛⬛⬛⬛
fazer
⬛🟩⬛🟩⬛
naves
⬛🟩⬛🟩🟩
xales
🟩🟩🟩🟩🟩
Enter fullscreen mode Exit fullscreen mode

Step by step:

  • for constant values we could just say name = expr, for variables we have more complex syntax var name = expr to declare, then var := expr to update
  • indexing starts from 1 not 0, somehow this annoys me more than all the Portuguese words
  • the rest is basically self-explanatory

How English is programming really?

I downloaded all code from Rosetta Code project, which hosts a mix of all programming languages. Skipping one letter names, here are 100 most common words in the code: if, end, the, for, to, return, int, in, of, string, is, then, print, do, and, list, function, set, else, as, integer, length, new, value, var, array, let, number, next, main, while, with, def, not, from, result, line, println, loop, data, str, sum, true, this, size, count, val, text, len, import, or, name, begin, map, file, define, my, out, it, max, char, false, say, write, input, by, type, on, left, first, io, std, add, func, index, range, xs, get, printf, right, procedure, math, test, class, sub, row, const, call, case, num, self, void, double, item, use, word, be, public, output, dim.

There's no easy way to remove comments, so some of them are mostly from comments (like the).

Most of these words are not really English in any meaningful sense. An average non-programmer has no idea what the hell string or var or def is; print for sure doesn't have anything to do with printers, import nothing with receiving goods from another country, double isn't twice anything, and so on. It really doesn't get all that easier by replacing boolean with booleano - you still need to learn pretty much just as much.

It might be a different story if your native language doesn't use Latin characters. Reading in a foreign alphabet takes a constant mental toll, much greater than a few keywords you get used to fast enough. So the value of programming language spelled in Korean, Russian, Greek, or Hebrew is likely much higher than one spelled in Portuguese or Polish. On yet another hand, coding in non-alphabetic spelling system like Chinese is such a terrible idea, so the Chinese people are probably better off just learning English spelling for it.

Should you use Linguagem Potigol?

The language was actually surprisingly decent. Error messages were better than most "English" languages, and that's really important for beginner language. It was also quite forgiving of minor grammar issues like confusing senãose with senão se and such and did its best to still run what it could.

It's not really going to replace Python anytime soon, but quality was way higher than I expected.

I don't really buy the idea that a handful of "English" keywords are a major barrier to entry to programming, but if you do, and your main language is Portuguese, it's not the worst idea ever.

Code

All code examples for the series will be in this repository.

Code for the Linguagem Potigol episode is available here.

Latest comments (2)

Collapse
 
matheusrich profile image
Matheus Richard

As a native Portuguese speaker, I always cringe when I read code in Portuguese. It's just weird. I wonder how native English speakers feel about this.

This blog post talks a little about this situation: code-anth.herokuapp.com/posts/1

Great overview, btw!

Collapse
 
taw profile image
Tomasz Wegrzanowski

There's at least one place where people use local language for programming, and that's Excel Spreadsheets. From what I can tell, Microsoft uses local names in documentation, and most people use local names, even though English ones work too.