fig, figueira, and a rare case for localized keywords

generally speaking, programming means english-based keywords even if you dont speak english. for a larger language, the benefits of a compatible codebase far outweigh the benefits of localizing the keywords.

localizing documentation, error messages, strings, all that– makes perfect sense anyway. but for example, for basic– almost every dialect is going to have the same “print” command, no matter what.

in rare cases, for small educational languages, localization of keywords is something thats done and possibly has merit. librelogo for example, has a hungarian manual with hungarian keywords.

i decided, for the sake of someone i was helping with fig, to work on a portuguese-based version of fig. this is not entirely portuguese– its us-keyboard based, its abbreviated codes, but this is the second portuguese speaker ive spent time on fig with.

the previous one complained that they hated programming, (no… they corrected this: they hated their teacher.) we tried a gentler approach, and i think it helped. good thing, because they were going to be studying a heavily computer-related field at university.

fig is designed for teaching programming concepts with somewhat practical examples (at least more practical than moving a cartoon around, but im not against that and i write more ascii-art and low-res graphics snippets than most things, for fun…) and so we went over the basics: variables (varivels,) input (entrada,) output (saida,) basic math (mathematica,) loops (all ive got for this is “loops”) and conditionals (condicionais?) and functions (funcoes) — i think thats what theyre called.

i am not a portuguese speaker, and the ones i have met do speak reasonably good english. as to whether this is about brazilian or european portuguese, its both. and while i had to do a lot of guesswork and make a couple mistakes, i got through localizing the language, with some help sitting down with a native speaker and going through the keywords.

six of the words got renamed or altered by a friend of mine– separar, seg, segem, fechar, mudar and meio.

the most important thing was, that we had spent an hour or so going over coding for the first time, using fig. and after i put together figueira, i showed this to them and said, “is this easier?” i got a firm yes in return.

i am not indicating that localized keywords are necessary to programming education– the opposite is suitably demonstrated. it will help in some cases, and is probably not worth pursuing in most cases; either with language development, or with students. it just isnt needed in general.

but figueira wasnt developed out of necessity, it was developed partly for fun, and partly to help just one person. after spending a week or two putting the words together, making the necessary alterations to the fig compiler took lets say an hour or two.

here is a complete keyword list, with mostly english definitions. oh and yes, i can code in this version too. having spent a little bit of time getting slightly more familiar with the portuguese language, and written most of the keywords based on portuguese, they are not too difficult. i could switch from fig to figueira and use it daily, but it would be more trouble for english speakers.

    crono
        category: input (shared-line)
        change var principal to number of seconds past midnight

    ordstdin
        category: input (shared-line)
        change var principal to array containing lines of stdin

    linhaentra
        category: input (shared-line)
        change var principal to string input from keyboard

    alinhaentra  arquivo  
        category: input (shared-line)
        change var principal to string of line from open file arquivo

    hora
        category: input (shared-line)
        change var principal to string of current time: hh:mm:ss

    ordaberto  arquivo  
        category: input (shared-line)
        change var principal to array of file lines in arquivo

    data
        category: input (shared-line)
        change var principal to string of the date: mm/dd/yyyy

    ordcurl  url  
        category: input (shared-line)
        like ordaberto, except downloading url into the array

    pausa  segundos  
        category: input (shared-line)
        wait for number of seconds before continuing with program

    comando
        category: input (shared-line)
        change var principal to array of command line parameters

    impress
        category: output (shared-line)
        output var principal to the screen (aka stdout)

    impressha
        category: output (shared-line)
        put var principal to screen; like print but stays on the line.

    aimpress  arquivo  
        category: output (shared-line)
        write var principal to open file designated by arquivo

    display
        category: output (shared-line)
        1st time: stop automatic graphx update. 2nd, etc: update.

    lmp
        category: output (shared-line)
        clear the screen. currently only affects text screen

    graficos
        category: output -- own line
        dont(or stop) suppress(ing) graphics. this is the default.

    textomodo
        category: output -- own line
        suppress graphics; force graphics commands to use text.

    cortexto  corcodigo  
        category: output (shared-line)
        change color of upcoming text to colorcode from 0 - 15

    realcar  corcodigo  
        category: output (shared-line)
        change background color of upcoming text to colorcode 0-15

    localiz  linha    coluna  
        category: output (shared-line)
        move to textmode position at linha, coluna

    ppus  x    y    c  
        category: output (shared-line)
        draw dot at location (x, y) in colorcode c (0 - 15)

    linha  x1    y1    x2    y2    c  
        category: output (shared-line)
        draw line from (x1, y1) to (x2, y2) in colorcode c (0-15)

    enquant
        category: loop -- own line
        mark the start of a loop (will keep going without saida)

    saida
        category: loop -- own line
        put in the middle of a loop to exit (stop looping)

    para  vc    de    para    quanto  
        category: loop -- own line
        start a for loop, changing vc from de to para, by quanto

    paraem  itemv    ordem  
        category: loop -- own line
        loop through each item in ordem; for each, set itemv to item

    severd  cfvar  
        category: conditional -- own line
        run lines between severd and fig if cfvar is "non-zero"

    seigual  var1    var2  
        category: conditional -- own line
        run lines between seigual and fig if var1 equals var2

    semais  var1    var2  
        category: conditional -- own line
        run lines between semais and fig if var1 is > var2

    semenos  var1    var2  
        category: conditional -- own line
        run lines between semenos and fig if var1 is < var2

    tentar
        category: conditional -- own line
        put code that might not work between tentar and exceto

    exceto
        category: conditional -- own line
        if code between tentar/exceto fails, run the code after exceto

    retomar
        category: conditional -- own line
        mark the end of tentar/exceto/retomar command block

    outra
        category: conditional -- own line
        after se- line, before fig. run lines if condition isnt true

    funcao  nome    p1    p2    …  
        category: function -- own line
        define function named nome with optional params p1,p2, etc

    obter  parametro  
        category: function (shared-line)
        (no longer required) copy parametro value to var principal

    python
        category: function -- own line
        put inline python code between lines python and fig

    fig/seg/segem/efim
        category: fig (interchangeable)
        function --\own\line finalize a block (started by se/enquant/funcao/para/paraem

    passar
        category: function -- own line
        blocks (for/next, etc) require something inside lines; passar works / does nothing

    mincula
        category: function (shared-line)
        change var principal to all-lower-case copy of own value

    maicula
        category: function (shared-line)
        change var principal to all-upper-case copy of own value

    cad
        category: function (shared-line)
        convert var principal from number to string

    shell
        category: function (shared-line)
        run var principal contents in a command shell (os specific)

    asc
        category: function (shared-line)
        change var principal from string to ascii code of 1st char

    val
        category: function (shared-line)
        change var principal from string to numeric (int if whole)

    comprim
        category: function (shared-line)
        change var principal to numeric length of var principal

    estanao
        category: function (shared-line)
        change var principal to zero if non-zero; or -1 if zero

    ecorta
        category: function (shared-line)
        strip whitespace from left side of var principal

    dcorta
        category: function (shared-line)
        strip whitespace from right side of var principal

    car
        category: function (shared-line)
        change var principal from numeric to ascii/uni string

    ordshell
        category: function (shared-line)
        change var principal to array of shell output (from var principal)

    ordreverso
        category: function (shared-line)
        change var principal from array to reverse order of array

    reverso
        category: function (shared-line)
        like ordreverso (which might be faster for array) for strings

    ordordena
        category: function (shared-line)
        change var principal from array to sorted array

    #
        category: comment (can share)
        place at beginning (or end) of line, prior to a comment

    ():;|=,.  (    )    :    ;    |    =    ,    .  
        category: optional (shared-line)
        use in a shared line (and some others) for aesthetics/notation

    esquerdo  numdecaras  
        category: function (shared-line)
        change var principal to leftmost group of caras/items

    direito  numdecaras  
        category: function (shared-line)
        change var principal to rightmost group of caras/items

    ordobter  ordem    posicao  
        category: function (shared-line)
        change var principal to posicao-nth item from ordem

    ordpus  posicao    que  
        category: function (shared-line)
        change item in array in var principal to value of que

    meio  posicao    comprimento  
        category: function (shared-line)
        change var principal to range of comprimento items from posicao

    cadeia  n    asciiorcad  
        category: function (shared-line)
        change var principal to n instances of asciiorcad

    separar  cadeia    comcadeia  
        category: function (shared-line)
        split cadeia by separator comcadeia into array, to var principal

    juntar  ordem    comcadeia  
        category: function (shared-line)
        change var principal to string by joining ordem using comcadeia

    incad  cadeia    olharpara  
        category: function (shared-line)
        change var principal to numeric position of olharpara in cadeia

    mudar
        category: function (shared-line)
        change current folder to path string from var principal

    sistema
        category: function (shared-line)
        put on (usually at the end of) a line to stop the program

    fechar
        category: function (shared-line)
        close the open file designated by var principal

    fim
        category: function (shared-line)
        interchangeable with sistema which ends the program

    aberto  modo  
        category: function (shared-line)
        open file at arquivo var principal in modo "r" or "w"

    retorno  var  
        category: function (shared-line)
        (optional) exit current function, returning value var

    troca  var1    var2  
        category: function (shared-line)
        change contents of var1 to contents of var2 and vice-versa

    mais  numcadord  
        category: math (shared-line)
        change var principal to itself plus num or cadeia or ord

    menos  numerico  
        category: math (shared-line)
        change var principal to itself minus numerico

    divipor  numerico  
        category: math (shared-line)
        change var principal to itself divided by numerico

    multipor  numerico  
        category: math (shared-line)
        change var principal to itself times numerico

    oct
        category: math (shared-line)
        change var principal from numeric decimal to octal

    hex
        category: math (shared-line)
        change var principal from numeric decimal to hexadecimal

    cosseno
        category: math (shared-line)
        change numeric var principal to the cosine of itself

    seno
        category: math (shared-line)
        change numeric var principal to the sine of itself

    tan
        category: math (shared-line)
        change numeric var principal to its tangent

    atan
        category: math (shared-line)
        change numeric var principal to its arctangent

    int
        category: math (shared-line)
        change var principal from decimal (aka "float") to integer

    smb
        category: math (shared-line)
        change var principal to 0 if 0, to -1 if < 0, or 1 if > 0.

    raizquadr
        category: math (shared-line)
        change var principal to square root of itself

    mod  denominador  
        category: math (shared-line)
        change var principal to: var principal módulo denominador

    apoten  n  
        category: math (shared-line)
        raise numeric var principal to n-th power

    aleatint  menor    maior  
        category: input (shared-line)
        change var principal to random number from menor to maior

    ordem
        category: function (shared-line)
        change var principal to array (starting with same contents) 
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s