iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🪃

Uiua Development Environment

に公開

https://zenn.dev/hatappo/articles/e1451b535232a4

Continued from the above.

Font

The officially recommended DejaVu Sans Mono font.
Since the charm of Uiua is halved if the glyphs aren't displayed beautifully, the font choice is considered important.
Download it from the link below. It includes various derivative fonts, but look for DejaVu Sans Mono and install it.

https://dejavu-fonts.github.io/Download.html

On macOS, you can just double-click the corresponding DejaVuSansMono.ttf file and install it.

VSCode Extension

This is provided officially.

https://marketplace.visualstudio.com/items?itemName=uiua-lang.uiua-vscode

After installing it, DejaVu Sans Mono was automatically specified in the default settings for Uiua, which saved some effort.

  // Configure settings where the uiua language takes precedence.
  "[uiua]":  {
    "editor.semanticHighlighting.enabled": true,
    "editor.inlayHints.enabled": "on",
    "editor.fontFamily": "DejaVu Sans Mono, monospace",
    "editor.fontSize": 16
  },

There are only a few items that can be configured in the extension itself.

Just the item to specify the location of the Uiua executable. If it's in your PATH, you don't need to configure anything specifically.

{
  // Path to the Uiua executable used by the Uiua extension. When empty, the extension will try to find the Uiua executable in your PATH environment variable.
  "uiua.executablePath": ""

}

Trying it out

Copy and paste a suitable sample from the official documentation: https://uiua.org/pad?src=⇌[⍥(%2B%2C%2C)10 1 0]

  1. State immediately after pasting
  2. After saving the file. The extension's formatter runs and it's converted into glyphs.
  3. Hovering the cursor over each glyph displays a description. In this case, .
  4. Execution
main.ua
$ uiua run
[7 1 9 9 5]
  1. Code explanation: ⌊×10[⍥⚂5]
    1. Evaluated from right to left.
    2. [] creates an array.
    3. Push 5 onto the stack.
    4. random operator: Generates a random number. Random numbers are between 0 and 1.
    5. repeat operator: Repeats the argument operator (in this case, random) for the number of times popped from the stack (in this case, 5). The result is pushed onto the stack.
    6. Push 10 onto the stack.
    7. × multiply operator: Multiplies. Uiua operators usually handle both scalar values and collections [1] appropriately. In this case, it multiplies 10 by each element of the array.
    8. floor operator: Rounds down the number. In this case as well, it acts on each element of the array.
    9. Finally, what remains on the stack is "an array with five numbers obtained by multiplying random 0-1 values by 10 and rounding them down."
  2. To see the intermediate progress, I'll insert the . duplicate operator, which duplicates the top element of the stack and pushes it onto the stack, to try and copy and keep the intermediate state.
    ⌊×.10.[⍥⚂5]
$ uiua run
[0.143500830471 0.987054020347 0.583803611989 0.59630190826 0.069020688416]  # Array with 5 random numbers
[1.435008304713 9.870540203471 5.83803611989 5.963019082604 0.690206884163]  # Multiply each value by 10
[1 9 5 5 0]  # Round down

Impressions

Some glyphs are intuitive, while others are less so.
The code appearance is fun.
Code becomes even shorter than S-expressions.

Continued ↓
https://zenn.dev/hatappo/articles/9a7f4e601df235

脚注
  1. In Uiua, arrays are the only existing collection type. ↩︎

Discussion