APL vs BQN vs Uiua

Sdílet
Vložit
  • čas přidán 27. 06. 2024
  • A video comparing implementations of the standard deviation formula in APL, BQN and Uiua inspired by James Gosling's talk from reClojure 2022 • James Gosling Keynote ...
    BQN: mlochbaum.github.io/BQN/
    BQN Code: mlochbaum.github.io/BQN/try.h...
    Uiua: www.uiua.org/
    UiuaPad Code: uiua.org/pad?src=U3REZXYg4oaQ...
    Dyalog APL: www.dyalog.com/dyalog/dyalog-...
    RIDE: github.com/Dyalog/ride/releases
    Talks Mentioned:
    1. • "A Long Strange Loop" ...
    2. • Alex Miller Keynote "T...
    3. • James Gosling Keynote ...
    Chapters:
    0:00 Intro
    0:22 Motivation (reClojure Talk)
    1:40 APL Solution in James Gosling's Talk
    2:26 Refactor APL Solution
    6:06 BQN Solution
    8:33 BQN Inverse & Under
    10:12 BQN Modifier Exploration
    12:12 Uiua Solutions
    14:10 Uiua Combinator Improvements
    15:10 Uiua Fail (Trying to Replicate BQN)
    17:14 Outro
    Follow me on Github: github.com/codereport
    Follow me on Twitter: / code_report
    Follow me on LinkedIn: / codereport
  • Věda a technologie

Komentáře • 60

  • @whatthehelliswrongwithyou
    @whatthehelliswrongwithyou Před 8 měsíci +27

    we might simplify even further knowing that this is sqrt( - ^2)

  • @red13emerald
    @red13emerald Před 8 měsíci +24

    The issue with your attempt of factoring out the function in Uiua is that the stack signature can't infer the signature of functions that are called from the stack (as those could be anything). So you have to explicitly specify how many inputs the function will take (number of outputs is 1 by default):
    StDev ← |1 √!⊙(|2 ⁿ2-!).(÷⊃⧻/+).
    Even if you didn't have to specify stack signatures though, the solution would still be longer and less readable than the original solution you came up with:
    StDev ← √÷⊃⧻/+ⁿ2-÷⊃⧻/+.
    StDev ← √!⊙(ⁿ2-!).(÷⊃⧻/+).
    I have to say, I absolutely love the clarity of this one:
    Avg ← ÷⊃⧻/+
    StDev ← √Avgⁿ2-Avg.
    So obvious, so easy to understand.

    • @c4tubo
      @c4tubo Před 8 měsíci +1

      I was banging my head to solve the signature issue, so thanks for that. And you also tightened it up by getting rid of the double-dipping. But I still prefer the fully tacit variation over naming the Avg function.

  • @rood2137
    @rood2137 Před 8 měsíci +12

    Uiua also has inverse and under combinator
    U ← ⍜⍘√(÷⊃⧻/+)-÷⊃⧻/+.
    Also, solution with annotated function signature
    F ← |1 √!∶ⁿ2-!⊙.,∶(÷⊃⧻/+)
    |x,y is a function signature, where x is number of arguments and y is a number of output values.
    In the F function we annotate that it takes 1 argument and omit num of out values

  • @code_explorations
    @code_explorations Před 8 měsíci +25

    Love it. Please keep the Uiua content flowing 😊

  • @charlieleemburg
    @charlieleemburg Před 8 měsíci +3

    Nice, tried it in my own language
    StDev ← ⋄ ⨱₁‒₁^2/+÷ₙ⫾√2
    Explanation
    ⋄ - this is not important just so it works in any context
    ⨱ - average
    ₁‒₁ - subtracting the average from the input
    ^2 - squaring
    /+ - sum
    ÷ₙ⫾ - dividing by the length of the input
    √2 - square root
    Though the combinators I find more elegant but they make my head spin, at least I don't have to repeat any code here.

  • @r4fa3l59
    @r4fa3l59 Před 8 měsíci +8

    I came back from school just a while ago and was getting ready for dinner (it's 10:58 pm here in Brazil) and then I saw your notification... Gotta watch that first!

  • @argonwheatbelly637
    @argonwheatbelly637 Před 7 měsíci

    Gentle rain, a hot pocket, and this video. Great morning! Thanks! The solutions are elegant and fun.

  • @bailey6112
    @bailey6112 Před 8 měsíci +1

    I've loved seeing the Uiua content you've put out, it's given me a chance to practice the language as I watch

  • @Hedshodd
    @Hedshodd Před 8 měsíci +6

    Just real quick: uiua has an under operator too 😉

  • @davidzwitser
    @davidzwitser Před 8 měsíci +1

    Absolutely amazing. Especially the BQN one because that one I understood. Love these videos!

  • @Arbmosal
    @Arbmosal Před 8 měsíci +15

    Have you used these languages for something bigger than these types of code problems? I'd love to see how one would e.g. build todomvc with htmx or so. Especially excited about Uiua

    • @jameleddinelassoued7228
      @jameleddinelassoued7228 Před 8 měsíci +2

      Uiua is actually very powerful. It even comes with threads. The official website for Uiua is written in Uiua and built with trunk (It is good to note that Uiua itself is written in rust).

  • @versacebroccoli7238
    @versacebroccoli7238 Před 8 měsíci +1

    Thanks for linking the talks yoh mentioned!

  • @kibels894
    @kibels894 Před 8 měsíci +7

    The original made it very clear what operation was being done. Code golf is fun though.

  • @robertfrysch7985
    @robertfrysch7985 Před 8 měsíci +5

    my preferred Uiua version:
    Avg ← ÷⊃⧻/+
    Std ← ⍜(ⁿ2)Avg-Avg.
    There are also possibilities to avoid repeating the Avg, e.g.:
    Std ← √!∶ⁿ2-!∶,,∶(÷⊃⧻/+)
    but I would like to see a more elegant and shorter way to do this :)

    • @jacoblockwood4034
      @jacoblockwood4034 Před 3 měsíci +1

      Sadly your second way of doing removing Avg no longer works since first class functions were removed. Your first way is very nice though. You can remove a character by using unsqrt instead of pow2, because then you can remove the parentheses.

  • @stupid4President
    @stupid4President Před 8 měsíci +3

    I can feel disturbed if something isn’t ‘right’ aka outside my expectation. Now, while Uiua glyphs are beautiful I expected that broadly accepted glyphs would stay the same. Which is mostly the case. Except the ‘not’ glyph. The ! Glyph is globally used therefor. But not in Uiua. It has another thingy.
    And so, Uiau started to become a little bit less beautiful. Until I saw the (big=149,878) Unicode list and found the symbol Uiua uses instead of the standard ‘!’. It is code U+00AC and the description says; ‘not sign’. Okay, Uiau, you win!
    Also, does anyone, when reading the name Uiau, think of the ‘Ula’ sound from ‘War of the worlds’? No? Just me? Oh well….

  • @parlor3115
    @parlor3115 Před 8 měsíci +1

    APL all the way for me. It's much less verbose and is significatly more express in terms of its type system. 100% recommend!

  • @sinom
    @sinom Před 8 měsíci +3

    I honestly have no idea about APL but in general that standard deviation expression saving the average might be because in general you will often need the average when you also need the standard deviation so maybe the original paper reused it at some point later on and already saved it in there so it only gets calculated once?

  • @red13emerald
    @red13emerald Před 8 měsíci +2

    And just like that, Uiua removed functions on the stack and the call operator in version 0.0.21, so half of the part about Uiua is obsolete again 😂

    • @jacoblockwood4034
      @jacoblockwood4034 Před 3 měsíci

      Well, functions on the stack was kinda confusing anyway. Also, you can replicate this behaviour with macros.

  • @Bliss467
    @Bliss467 Před 8 měsíci +1

    A little surprised average isn’t a backed in function/symbol in uiua

  • @badmanjones179
    @badmanjones179 Před 8 měsíci +11

    a uiuaer, or as i like to say, "wee-wah-wer"

  • @alejandroulisessanchezgame6924

    Hi i want to implement an APL interpreter and i want to know if can do it without legal problems because some modern features like trains are in dialog apl.

  • @DrewryPope
    @DrewryPope Před 8 měsíci +1

    i.. almost understood this.

  • @inserteunnombreapropiado9079

    I kind of didn't understand all you were saying. Is there some sort of introduction to this programming paradigm for someone used to OOP? And also, can you write something more useful than these one-liners?

  • @charstringetje
    @charstringetje Před 8 měsíci +2

    Uiuauizzard

  • @AntoshaPushkin
    @AntoshaPushkin Před 8 měsíci +5

    These languages are pretty much write-only. It's cool that you can have a 1-line solution for a problem that takes 20-30 lines of python code, but who cares if nobody can understand it, fix it, change it etc?

    • @denispoisson6839
      @denispoisson6839 Před 8 měsíci

      That's a competency problem. You might as well say the same of Chinese or Japanese.

    • @AntoshaPushkin
      @AntoshaPushkin Před 8 měsíci

      @@denispoisson6839 no, if you write 1-line programs in any language, it will be unreadable. Though other languages don't encourage you to write one-line weird things with strange characters

  • @mendelovitch
    @mendelovitch Před 8 měsíci +51

    Write-only languages.

    • @bzboii
      @bzboii Před 8 měsíci +4

      as in purely functional lol

    • @aloussase
      @aloussase Před 8 měsíci +27

      Skill issue

    • @tytrdev
      @tytrdev Před 8 měsíci +7

      @@aloussase xD
      I wonder if they would say the same about Mandarin or Kanji?

    • @xnick99
      @xnick99 Před 8 měsíci +1

      I would assume you can format the code in a non-symbolic format such that each operator is replaced with a clear understandable function name.

    • @tytrdev
      @tytrdev Před 8 měsíci +5

      @@xnick99 after a while I imagine the symbols become meaningful and clear function names. Dont get me wrong I can’t read this shit either, but I’m sure if we spent a few hundred hours working in a code base with these languages we would be fine.

  • @01110100011101110110
    @01110100011101110110 Před 8 měsíci +4

    I'm sorry, but this is black magic. Burn the witch!

  • @scramjet4610
    @scramjet4610 Před 4 měsíci +1

    C'mon, seriously, the code at 6:00 is horrible to read, not at all intuitive, just a gaggle of symbols; as such, what is the point of this language? It seems like all these cutesy, new "languages" are just trivial, semantic tweaks of each other, cluttering up the language scape. May as well just create functions to do this with C and just use C. A new language should be fundamentally different, like Lisp vs C, or evern Forth vs C. This stuff look like just semantic gymnastics. Where's the value?

    • @jacoblockwood4034
      @jacoblockwood4034 Před 3 měsíci

      If you learn how it works, this way is actually much easier to read than more mainstream languages. Also, APL came out in the 60's, I wouldn't call it new :P

  • @RusMermaid
    @RusMermaid Před 8 měsíci +1

    What's your discord? I'd love to join