Julieta: spanish version of Julia!

733 views
Skip to first unread message

Ismael VC

unread,
Dec 18, 2015, 7:52:01 PM12/18/15
to julia-dev
Hello everyone!

I'm trying to make an Spanish translated version of Julia, AKA Julieta, using JuliaParser.jl and I would love to hear your opinions (if this belongs to julie-users I'll move it there).

In order to make spanish aliases of identifiers, for functions a simple const assignement will do:

julia> const primos = Base.primes
primes
(generic function with 2 methods)

For types using typealias:

julia> typealias Ent Int
Int64

For macros more macros:

julia> macro tiempo(ex) :(@time $ex) end


julia
> @tiempo  1 + 1
 
0.000002 seconds (4 allocations: 160 bytes)
2

SubModules:

julia> Base.eval(:(const Prueba = Test))
Base.Test

julia
> using Base.Prueba


For reserved keywords this is what I've been able to do so far:

               _
   _       _ _
(_)_     |  A fresh approach to technical computing
 
(_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _
| |_  __ _   |  Type "?help" for help.
 
| | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0-dev+1526 (2015-11-30 04:16 UTC)
 _/
|\__'_|_|_|\__'_|  |  Commit b775873 (18 days old master)
|__/                   |  x86_64-w64-mingw32


julia
> cd(Pkg.dir("JuliaParser"))


shell
> git branch
* Julieta
  fix
-tests
  master


julia
> using JuliaParser.Parser


julia
> julieta_code = """
           empezar
               x = 42
           fin
       """

"    empezar\n        x = 42\n    fin\n"


julia
> julia_code = """
           begin
               x = 42
           end
       """

"    begin\n        x = 42\n    end\n"


julia
> Parser.parse(julieta_code)
quote
    $
(Expr(:line, 2, :none))
    x
= 42
end


julia
> Base.parse(julia_code)
quote  
# none, line 2:
    x
= 42
end


julia
> eval(Parser.parse(julieta_code)) == eval(Base.parse(julia_code))
true

A type:

julia> julieta_code = """
           tipo Tablero
               cols       :: Ent
               nodos      :: Ent
               diag45     :: Ent
               diag135    :: Ent
               soluciones :: Ent


               Tablero() = nuevo(0, 0, 0, 0, 0)
           fin
       """

"    tipo Tablero\n        cols       :: Ent\n        nodos      :: Ent\n
 diag45     :: Ent\n        diag135    :: Ent\n        soluciones :: Ent\n    \n
        Tablero() = nuevo(0, 0, 0, 0, 0)\n    fin\n"



julia
> Parser.parse(julieta_code)
:(type Tablero # , line 2:
        cols
::Ent # , line 3:
        nodos
::Ent # , line 4:
        diag45
::Ent # , line 5:
        diag135
::Ent # , line 6:
        soluciones
::Ent # , line 8:
       
Tablero() = begin
                $
(Expr(:line, 8, :none))
                nuevo
(0,0,0,0,0)
           
end
   
end)


julia
> eval(ans)
ERROR
: UndefVarError: Ent not defined
 
in eval at boot.jl:263
 
in eval at boot.jl:262
 
in eval at boot.jl:263


julia
> typealias Ent Int
Int64


julia
> Parser.parse(julieta_code)
:(type Tablero # , line 2:
        cols
::Ent # , line 3:
        nodos
::Ent # , line 4:
        diag45
::Ent # , line 5:
        diag135
::Ent # , line 6:
        soluciones
::Ent # , line 8:
       
Tablero() = begin
                $
(Expr(:line, 8, :none))
                nuevo
(0,0,0,0,0)
           
end
   
end)


julia
> eval(ans)


julia
> Tablero
Tablero


julia
> Tablero()
ERROR
: UndefVarError: nuevo not defined
 
in call at none:8
 
in eval at boot.jl:263

My first question is how does the implementation of `new` works? Where is it defined in the Julia source code (I'm not asking you to explain me JuliaParser code, but I feel that if I understand the Julia Implementation then I'll be able to understand JuliaParser) I don't see how to alias that one.

The second is how does the implementation of the Julia REPl works? 

I just need some hints, please don't tell me to go read the source, I'm doing that (I wish it where better documented with comments), what I need is a way to instantiate another REPL, but make it use my hacked JuliaParser.Parser.parse instead of Base.parse. Ideally i would like to put in .juliarc.jl

using Julieta; julieta_repl()

My third question is, is there a better way to do this?

My last question is about how do you feel about the idea of Julia being fully i18n to several languages?, here is some reference:

https://en.wikipedia.org/wiki/Non-English-based_programming_languages

This would be a tremendous help in the educational space, I don't think that English must be a prerequisite in order to learn programming, which sadly is true today. I've been teaching children beggining Python lesons, we have to go slowly and I have to teach them some english along the way most times. And even the smart and motivated ones get slowed down by this, I have to show them pseudocode (which more and more resembles Julieta lately) in spanish and then do the thing in Python.

Imagine we had registered all identifiers, strings with errors, warnings, info and documentation and that their meanings could be programatically swapped by others, It could be done with "language extension packs".

Something that like:

$ export LANG=es_MX

$ julia    # this starts in spanish!

I'm really interested in your opinions.

This is my mock example:

               _
   _       _ _
(_)_  _         |  Un nuevo enfoque para la computación técnica
 
(_)     | (_) (_)| |        |  Documentación: http://docs.julialang.es.org
   _ _   _
| |_  ___| |_ __ _  |  Tecleé "?ayuda" para la ayuda.
 
| | | | | | |/ _ \ __| _` | |  
  | | |_| | | |  __/
|| (_| | |  Versión 1.0 (201?-??-?? ??:?? UTC)
 _
/ |\__'_|_|_|\___|_| \__'_| |  Commit ??????? (? días detrás de master)
|__/                          |  x86_64-w64-mingw32


julieta
> módulo NReinas


         exportar solucionar


         tipo
Tablero
             cols      
:: Ent
             nodos      
:: Ent
             diag45    
:: Ent
             diag135    
:: Ent
             soluciones
:: Ent


             
Tablero() = nuevo(0, 0, 0, 0, 0)
         fin


         
"Marca si está ocupada una casilla."
         funci
ón marcar!(t::Tablero, k::Ent, j::Ent)
             t
.cols    $= (1 << j)
             t
.diag135 $= (1 << (j + k))
             t
.diag45  $= (1 << (32 + j - k))
         fin


         
"Prueba si una casilla está amenazada."
         funci
ón probar(t::Tablero, k::Ent, j::Ent)
             t
.cols    & (1 << j)            +
             t
.diag135 & (1 << (j + k))      +
             t
.diag45  & (1 << (32 + j - k)) == 0
         fin


         
"Solucionador de retroceso."
         funci
ón solucionar!(t::Tablero, niv::Ent, dx::Ent)
             si niv
> 0
                 por i en
0:dx - 1
                     si probar
(t, niv, i) == verdadero
                         marcar
!(t, niv, i)
                         solucionar
!(t, niv - 1, dx)
                         marcar
!(t, niv, i)
                     fin
                 fin
             sino
                 por i en
0:dx - 1
                     si probar
(t, 0, i) == verdadero
                         t
.soluciones += 1
                     fin
                 fin
             fin
             t
.nodos += 1
             t
.soluciones
         fin


         
"Soluciona el problema de las `N` reinas, en un tablero de $n × n$ casillas."
         solucionar
(n::Ent) = solucionar!(Tablero(), n - 1, n)


         fin


julieta
> usando NReinas
NReinas


julieta
> solucionar(8)
92


julieta
> @tiempo solucionar(15)
 
13.114574 segundos (6 asignaciones: 224 bytes)
2279184


ayuda
?> solucionar
buscar
: solucionar


 
Soluciona el problema de las N Reinas, en un tablero de n × n casillas.


julieta
>


Of the N Queens puzzle, original notebook here: https://gist.github.com/Ismael-VC/941fc35622ca298bf69c

Thanks in advance!







Ismael VC

unread,
Dec 18, 2015, 8:32:53 PM12/18/15
to julia-dev
The prime example of What I would like to achive is Robomind, it's really impresive!

http://www.robomind.net

Imagine children like them learning Julia <3 The part of them doing a WYSIWYG game with it could be acomplished with Escher or somethin like that. I think the last piece of the puzzle could be a `Porter.jl` script to translate registered symbols between the supported languages.

I'm having a lot of fun doing this right now, I'll be working on it during vacations, I have heard lots of people (even spanish speakers) think this is a bad idea because (this is from the people that already know english), but I think this is just a paradigm, they are not greedy, I know your primary concern are current scientists, then newcomers, this could widen Julia newcomers don't you think?

I it's just imagination right now, but in my mind this could be something supported by the language like the documentation, so that Pakages could also benefit from this. I certainly wouldn't want to have to make a satellite fork, I think that would actually be the most complex approach.

Don't forget that I'm not an expert on this so but I'm very open to critiques. I could get some testimonials of the use cases where something like this could be needed and helpful. Translating strings is easy, I could do spanish and esperanto.

The limits of my language means the limits of my world.

Ludwig Wittgenstein
...

Ismael VC

unread,
Dec 18, 2015, 8:40:09 PM12/18/15
to julia-dev
There are some people interested already at our gitter chat room: https://gitter.im/JuliaLangEs/julialang-es


El viernes, 18 de diciembre de 2015, 18:52:01 (UTC-6), Ismael VC escribió:
...

Ismael VC

unread,
Dec 19, 2015, 1:19:19 AM12/19/15
to julia-dev
How could I have missed this?

http://julia.readthedocs.org/en/latest/devdocs/init

Bookmarking Julia manual 0.4 was not a good idea. This is great guys, thanks for doing this!


El viernes, 18 de diciembre de 2015, 18:52:01 (UTC-6), Ismael VC escribió:
...

Tony Kelman

unread,
Dec 20, 2015, 5:23:43 PM12/20/15
to julia-dev
I don't have much technical input to give you here at the moment, but wanted to say I think it's really cool both that this is possible and that you're doing it. So keep it up!

Christof Stocker

unread,
Dec 21, 2015, 12:03:58 PM12/21/15
to juli...@googlegroups.com
This looks cool! In the end you should work on what interest you and what you believe in.

I am a native German speaker myself. Learning how to program thought me a lot about English that I would have otherwise not learned so early or at all. I would not have wanted it any other way. Most online resources on programming were in English as well. Other than programming, there really any incentive to learn English back then. But times have changed. I think todays youth learns English mostly through watching movies and series online (at least where I am from), and they are better off for it.

To sum up, you might very well be on the right track for todays time. People like me just have a distorted view of how things have to be.

Ismael VC

unread,
Dec 22, 2015, 3:40:48 AM12/22/15
to julia-dev
Thank you very much, I will! I have had this idea since long ago, but this is the first time that I think it's actually worth it, since Julieta would still be Julia, so it could also be used in production, not only for educational purposes. I'll just have to metaprogram the heck out of it.

Ben Obi-Wan Kenobi
: ...use Metaprogramming, Luke. LOL

Ismael VC

unread,
Dec 22, 2015, 3:46:37 AM12/22/15
to julia-dev
I have taught Python to young children and I know how a difficult barrier the English language can be for most of them, the only reason why schools don't teach CS in Spanish (or at all) is because of paradigms, but who cares about those?

If I could add just one ungracious demand to the julian list of greed, that would be this ...multi lang! 
...

Scott Jones

unread,
Dec 23, 2015, 11:32:39 AM12/23/15
to julia-dev
One issue is that in Spain (and Latin America and the US), TV and movies are almost always dubbed in Spanish, so you don't find children exposed to English at an early age, as you would in many countries in Europe (like Belgium, where I go to work and also my nephew and his family life).
Given that (at least according to various sites I've seen searching with Google) Spanish is the largest language in the world in terms of native speakers (Chinese *as a group* is larger, however, that ignores that fact that there are really many Chinese dialects/languages, that are about as close as Spanish / Portuguese / Italian / Catalan, tied together by the *written* language) with around 400 million native speakers, English has around 325 million.

Because of that lack of English exposure, it makes programming much harder for Spanish speakers.

I think what Ismael is doing here is great (and should be extended to Portuguese and other languages as well), and not just for young kids, for anybody who wants to learn to program, but doesn't know English.

This could be combined with a translator, Julia <-> Julieta, (maybe using Google Translate to help translate doc strings and comments), to help sharing Julieta code with Julia programmers.

Scott
...

Ismael Venegas Castelló

unread,
Dec 28, 2015, 2:40:24 AM12/28/15
to julia-dev
Just trying to support at least 3 languages and since I only know bad english, spanish and esperanto....

julia> using JuliaParser

julia> Jparse = JuliaParser.Parser.parse
parse (generic function with 3 methods)

julia> src_es = """
           función prueba(x::Int)
               retornar x ^ 2
           fin
       """
"    función prueba(x::Int)\n        retornar x ^ 2\n    fin\n"

julia> src_eo = """
           funkcio testo(x::Int)
               reveno x ^ 2
           fino
       """
"    funkcio testo(x::Int)\n        reveno x ^ 2\n    fino\n"

julia> src_en = """
           function test(x::Int)
               return x ^ 2
           end
       """
"    function test(x::Int)\n        return x ^ 2\n    end\n"

julia> Jparse(src_es)
:(function prueba(x::Int)
        $(Expr(:line, 2, :none))
        return x ^ 2
    end)

julia> Jparse(src_eo)
:(function testo(x::Int)
        $(Expr(:line, 2, :none))
        return x ^ 2
    end)

julia> Jparse(src_en)
:(function test(x::Int)
        $(Expr(:line, 2, :none))
        return x ^ 2
    end)

julia> eval(Jparse(src_es))(4)
16

julia> eval(Jparse(src_eo))(4)
16

julia> eval(Jparse(src_en))(4)
16

julia>


That's it for tonight! :D
...

Ismael Venegas Castelló

unread,
Dec 28, 2015, 2:45:43 AM12/28/15
to julia-dev
Some timings: 

julia> @time parse(src_en);
  0.000277 seconds (22 allocations: 1.078 KB)

julia> @time Jparse(src_en);
  0.000187 seconds (180 allocations: 8.126 KB)



El viernes, 18 de diciembre de 2015, 18:52:01 (UTC-6), Ismael Venegas Castelló escribió:
...

Ismael Venegas Castelló

unread,
Dec 28, 2015, 2:49:22 AM12/28/15
to julia-dev
if suite test:

julia> if_src = """
           si false
               :x
           osi false
               :y
           sino
               :z
           fin
       """
"    si false\n        :x\n    osi false\n        :y\n    sino\n        :z\n
fin\n"

julia> Jparse(if_src)
:(if false # , line 2:
        :x
    else  # , line 3:
        if false # , line 4:
            :y
        else  # , line 6:
            :z
        end
    end)

julia> eval(ans)
:z

julia>




El viernes, 18 de diciembre de 2015, 18:52:01 (UTC-6), Ismael Venegas Castelló escribió:
...

Ismael Venegas Castelló

unread,
Dec 28, 2015, 2:57:08 AM12/28/15
to julia-dev
Fixed true and false:

julia> if_src = """
           si falso
               :x
           osi verdadero
               :y
           sino
               :z
           fin
       """
"    si falso\n        :x\n    osi verdadero\n        :y\n    sino\n        :z\n
    fin\n"

julia> Jparse(if_src)
:(if false # , line 2:
        :x
    else  # , line 3:
        if true # , line 4:
            :y
        else  # , line 6:
            :z
        end
    end)

julia> eval(ans)
:y




El viernes, 18 de diciembre de 2015, 18:52:01 (UTC-6), Ismael Venegas Castelló escribió:
...

Páll Haraldsson

unread,
Feb 15, 2016, 8:57:59 AM2/15/16
to julia-dev
On Monday, December 21, 2015 at 5:03:58 PM UTC, Christof Stocker wrote:
This looks cool! In the end you should work on what interest you and what you believe in.

Learning how to program thought me a lot about English

Likewise, I remember asking by dad what SAVE (and LOAD, and I guess PEEK and POKE) meant, at the age of nine to read the Oric-1 computer/[BASIC] manual, that made me learn English.

Maybe it's a hurdle for some [young] people, I'm of two minds if this good or bad.. I guess it can't be bad for beginners, will it hurt you later translating your code to the English version (or English language users understanding your code..)? I assume users would eventually want to use standard Julia, and couldn't you make Julieta generate Julia code (as Julia2C), translating e.g. función" to "function" (but not function/variable names.. or comments)?


Trivia: My computer science professor (and students) made the Icelandic language "Fjölnir":


For a population of 350,000 (or maybe 300k at the time?), that knows Icelandic, this language never had a change (and I'm sure Arabic, AMMORIA, with I guess right-to-left script, language or https://en.wikipedia.org/wiki/Chinese_BASIC are not used either).

Maybe since you are basing on an actually used.. language, you have a chance. Keep up the good work (on this and other stuff).

-- 
Palli.

Reply all
Reply to author
Forward
0 new messages