Hey, this week I've tried [Uiua](https://www.uiua.org/), a very strange 
programming language.

How strange? well it is _functional_ (mutations are not allowed), _array based_ 
, heavily relied on _combinators_ , and _dynamicly typed_. no wait! I'm not 
done! it is also _stack based_ and advocated **tacit programming** (meaning 
your arguments does not have name, only order matters). you can say it is 
successor to APL, a very strange programming language that looks anything but A 
Programming Language [hence the name]. see [Array language 
comparisons](https://github.com/codereport/array-language-comparisons) for more 
info.

if I want to present a little about its weirdness, just take a look at Uiua 
solution for 100 doors problem on [Rosetta 
Code](https://rosettacode.org/wiki/100_doors)
    
    
    ◿2/+=0⊞◿.+1⇡100
    
    
    Run

you can write it line by line. the cool thing about the interpreter is if you 
put empty double comment `##`, after running your script, it will be replaced 
with the latest value on the stack ( actually you dont need to manually run it, 
you just hit `uiua` command and it will start to watch your `.ua` files).

this is line separated version of above code. (I've replaced 100 with 10 to 
show the result)
    
    
    ⇡10
    #- creates a range from 0 to 10-1
    ## [0 1 2 3 4 5 6 7 8 9]
    
    +1
    #- add 1 to all of them
    ## [1 2 3 4 5 6 7 8 9 10]
    
    .
    #- makes a copy of this array on the stack [actually not a copy, just a 
reference]
    ## [1 2 3 4 5 6 7 8 9 10]
    
    ⊞◿
    #- creates a 2D array with each row modulated by column. ◿ is modulo 
function.
    ## ╭─
    ##   0 0 0 0 0 0 0 0 0 0
    ##   1 0 1 0 1 0 1 0 1 0
    ##   1 2 0 1 2 0 1 2 0 1
    ##   1 2 3 0 1 2 3 0 1 2
    ##   1 2 3 4 0 1 2 3 4 0
    ##   1 2 3 4 5 0 1 2 3 4
    ##   1 2 3 4 5 6 0 1 2 3
    ##   1 2 3 4 5 6 7 0 1 2
    ##   1 2 3 4 5 6 7 8 0 1
    ##   1 2 3 4 5 6 7 8 9 0
    ##                             ╯
    
    =0
    #- check which of them are 0
    ## ╭─
    ##   1 1 1 1 1 1 1 1 1 1
    ##   0 1 0 1 0 1 0 1 0 1
    ##   0 0 1 0 0 1 0 0 1 0
    ##   0 0 0 1 0 0 0 1 0 0
    ##   0 0 0 0 1 0 0 0 0 1
    ##   0 0 0 0 0 1 0 0 0 0
    ##   0 0 0 0 0 0 1 0 0 0
    ##   0 0 0 0 0 0 0 1 0 0
    ##   0 0 0 0 0 0 0 0 1 0
    ##   0 0 0 0 0 0 0 0 0 1
    ##                       ╯
    
    /+
    #- sums by column
    ## [1 2 2 3 2 4 2 4 3 4]
    
    
    ◿2
    #- take modulo 2 from every element from array
    ## [1 0 0 1 0 0 0 0 1 0]
    
    
    Run

The resulting array indicated which door is open(1) and which is closed(0).

I've really had hard times to solve very basic advent of code problems, and 
wasted a lot of my time, but the point is: what motivated me to play with this 
insane language the whole week?

I think the most important ones are:

  * **Debugging experience** (I mean `##` that is replaced after running the 
code), although I really didn't understand what I'm doing specially in the 
first few days
  * **Looks** \- the code seems pretty even though unreadable, its online 
editor and VS Code extension colors functions and combinators based on their 
arity (number of arguemtns) e.g. functions with 1 argument are green, functions 
with 2 arguments are blue, ...)
  * **Syntax** \- sorry this can be count as _Looks_ , but isn't it amazing to 
write a function name and get its glyph by the formatter? you just have to 
remember its name! It reminds me Pinyin for Chinese [the language that I love 
but can't find time to learn it]
  * **Curiosity** \- I really wanted to know what is the secret behind this 
cryptic texts!
  * **Documentation** \- in some sections after explaining the idea behind 
concept, it had exercise with ability to run in the browser
  * **Mind Changing** \- it will force you to think differently. sometimes you 
feel dumb but remember [foreign ≠ 
confusing](https://vector-of-bool.github.io/2018/10/31/become-perl.html)



* * *

#### TakeAways

well the result of this insanity [spending a whole week on a strange 
programming language] is that I had a fun time. I really liked their [defense 
of design](https://www.uiua.org/docs/design) though. it made me think about 
basic things

* * *

#### read more:

  * [Uiua for absolute beginners video series [9 
videos]](https://www.youtube.com/watch?v=9T3UU5gbRA8)
  * [Exploring Uiua](https://citizen428.net/blog/exploring-uiua/) \- weblog post
  * [Uiua Combinators](https://www.uiua.org/docs/combinators)


Reply via email to