Live data from Hacker News

Uiua: A minimal stack-based, array-based language

uiua.org

71–80 of 107 posts

Re: Uiua: A minimal stack-based, array-based language

#72

I had no experience with array languages and decided to give it a try. It took me 4 hours to write FizzBuzz using only Uiua docs for help: # create an array of number 1-100 ns ← ∵(+1)⇡[100] # make a copy of it in a string form "1"-"100" nsStr ← ∵(□$"_") ns # every i % 3 == 0 is replaced with "Fizz", everything else is "" f ← ∵(□▽∶ "Fizz" =0◿3) ns # every i % 5 == 0 is replaced with "Buzz", everything else is "" b ← ∵…

That's a good start! I'm not exactly great with array langauges myself, but I think it's simpler to fill an array with □"Fizz", one with □"Buzz", one with □"FizzBuzz", then create another indexing array and use pick:

    ⍉[∵(□$"_"+1)⇡100
      [⍥.99□"Fizz"]
      [⍥.99□"Buzz"]
      [⍥.99□"FizzBuzz"]]
    +∵(×2=0◿5+1)⇡100 ∵(=0◿3+1)⇡100
    ≡⊡
    ⍉
There are probably a few more simplifications experienced array programmers can apply.

Re: Uiua: A minimal stack-based, array-based language

#73

I'm a big fan of stack-based languages conceptually, but they always seem to fall flat when it comes to basic reading comprehension. APL has the same issue, as does J. Factor did improve on this a little bit by eschewing the symbol fetish but it was still very difficult to rapidly scan the code for functionality. I'm not convinced the approach shown here is a good pairing with the human brain.

I'm always wondering what kind of people prefer this syntax to more classical syntax

Hot take: people who don't touch type.

Re: Uiua: A minimal stack-based, array-based language

#74

I had no experience with array languages and decided to give it a try. It took me 4 hours to write FizzBuzz using only Uiua docs for help: # create an array of number 1-100 ns ← ∵(+1)⇡[100] # make a copy of it in a string form "1"-"100" nsStr ← ∵(□$"_") ns # every i % 3 == 0 is replaced with "Fizz", everything else is "" f ← ∵(□▽∶ "Fizz" =0◿3) ns # every i % 5 == 0 is replaced with "Buzz", everything else is "" b ← ∵…

That's a good start! I'm not exactly great with array langauges myself, but I think it's simpler to fill an array with □"Fizz", one with □"Buzz", one with □"FizzBuzz", then create another indexing array and use pick: ⍉[∵(□$"_"+1)⇡100 [⍥.99□"Fizz"] [⍥.99□"Buzz"] [⍥.99□"FizzBuzz"]] +∵(×2=0◿5+1)⇡100 ∵(=0◿3+1)⇡100 ≡⊡ ⍉ There are probably a few more simplifications experienced array programmers can apply.

Smart!

Re: Uiua: A minimal stack-based, array-based language

#76

I had no experience with array languages and decided to give it a try. It took me 4 hours to write FizzBuzz using only Uiua docs for help: # create an array of number 1-100 ns ← ∵(+1)⇡[100] # make a copy of it in a string form "1"-"100" nsStr ← ∵(□$"_") ns # every i % 3 == 0 is replaced with "Fizz", everything else is "" f ← ∵(□▽∶ "Fizz" =0◿3) ns # every i % 5 == 0 is replaced with "Buzz", everything else is "" b ← ∵…

That's a good start! I'm not exactly great with array langauges myself, but I think it's simpler to fill an array with □"Fizz", one with □"Buzz", one with □"FizzBuzz", then create another indexing array and use pick: ⍉[∵(□$"_"+1)⇡100 [⍥.99□"Fizz"] [⍥.99□"Buzz"] [⍥.99□"FizzBuzz"]] +∵(×2=0◿5+1)⇡100 ∵(=0◿3+1)⇡100 ≡⊡ ⍉ There are probably a few more simplifications experienced array programmers can apply.

https://code.jsoftware.com/wiki/NYCJUG/FizzBuzz gives a solution in J of:

    FB=:((0 i.~15 3 5|]){::'FizzBuzz';'Fizz';'Buzz';":)"0
    FB i.100
I unfortunately don't know enough J or Uiua to be able to translate that Perhaps someone else can step in!

Re: Uiua: A minimal stack-based, array-based language

#77

Hmm, so ⌊×10[⍥^999] yields a list of numbers, but ⌊×10[⍥^1000] yields an audio clip. That's somewhat unexpected. The ^ above stands for the 3-dot cube dice glyph, which gets eaten by the HN backend, so it's ^ instead.

> The ^ above stands for the 3-dot cube dice glyph, which gets eaten by the HN backend, so it's ^ instead.

Just write "random" instead, then the snippet is copy-pasteable to the web-based interpreter. That's how you would normally write it out anyway, and interpreter will turn that into the dice glyph when run.

Re: Uiua: A minimal stack-based, array-based language

#78
What an interesting and pleasing little language!

I like the use of non-ASCII Unicode glyphs and symbols for some functions/commands.

It makes me wonder why (since we now have rich graphical user interfaces as opposed to monochrome ASCII command-line dumb terminals that were prevalent in the mid-early history of computers) more languages don't support those.

On a related note, I think it would be interesting to research computer languages which were developed in base languages that are not English, i.e., any computer languages originating out of India, Russia, China, Japan, etc. -- to name a few...

Maybe there's such a thing as an Esperanto programming language...

Getting back to symbols though, a future society might implement a purely symbol based programming language.

Were ancient Egyptian hieroglyphs -- a programming language for a computing architecture that has vanished in the depths of time?

One can only speculate!

We do know that in our current day there are programming languages like Mathematica, where Math symbols can be used in lieu of English(y) code, and there may be a trend to more symbols replacing ASCII named/spelled keywords and functions in our code in languages of the future...

The use of symbols to replace words might result in smaller tighter, more readable code -- but (I'm thinking from the perspective of a future society here) it also might sever the bridge to computing's past...

Which may be desirable to have, IF that future society would want to resurrect computers and compuation from a future apocalyptic event...

But perhaps I'm thinking too hard about all of this...

Interested parties may want to check out the following video:

"Why are these 32 symbols found in caves all over Europe | Genevieve von Petzinger":

https://www.youtube.com/watch?v=hJnEQCMA5Sg

Or, fast forward to this point to see the 32 symbols:

https://youtu.be/hJnEQCMA5Sg?t=403

Also, here is a great tutorial page for people who are new to stack-based languages:

https://skilldrick.github.io/easyforth/

Anyway, Uiua looks very nice!

Re: Uiua: A minimal stack-based, array-based language

#79
post #55
post #48

Earlier quoted context omitted.

I want to suggest an alternative encoding/notation where instead of single (very nicely chosen) Unicode codepoints, the operators are single (perhaps less well-suited) printable ASCII characters. This would make the language into its own, human-authorable, bytecode!

Like k

Visually would look kind of like K, yes; but K (obviously) isn't a stack language, and more importantly, K has operators that consist of multiple characters, and circumfix operators like {}, etc. So it really has none of the qualities that a bytecode has. Whereas Uiua/ASCII would have all of the qualities that a bytecode has.
Post reply on HN