APL vs BQN vs Uiua

Поділитися
Вставка
  • Опубліковано 26 вер 2024

КОМЕНТАРІ • 59

  • @red13emerald
    @red13emerald 11 місяців тому +27

    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 11 місяців тому +2

      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.

  • @whatthehelliswrongwithyou
    @whatthehelliswrongwithyou 11 місяців тому +28

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

    • @samuelemorreale7510
      @samuelemorreale7510 11 місяців тому +2

      Is the average of a?

    • @oantolin
      @oantolin 11 місяців тому

      ​@@samuelemorreale7510Yes.

    • @Kh-ik3de
      @Kh-ik3de 2 місяці тому

      @@samuelemorreale7510parentheses duh

  • @rood2137
    @rood2137 11 місяців тому +13

    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 11 місяців тому +27

    Love it. Please keep the Uiua content flowing 😊

  • @charlieleemburg
    @charlieleemburg 11 місяців тому +4

    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 11 місяців тому +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 10 місяців тому

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

  • @bailey6112
    @bailey6112 11 місяців тому +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

  • @davidzwitser
    @davidzwitser 11 місяців тому +1

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

  • @kibels894
    @kibels894 11 місяців тому +7

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

  • @robertfrysch7985
    @robertfrysch7985 11 місяців тому +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 6 місяців тому +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.

  • @Arbmosal
    @Arbmosal 11 місяців тому +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 11 місяців тому +3

      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 11 місяців тому +1

    Thanks for linking the talks yoh mentioned!

  • @parlor3115
    @parlor3115 11 місяців тому +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!

  • @Hedshodd
    @Hedshodd 11 місяців тому +6

    Just real quick: uiua has an under operator too 😉

  • @sinom
    @sinom 11 місяців тому +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 11 місяців тому +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 6 місяців тому

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

  • @Bliss467
    @Bliss467 11 місяців тому +1

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

  • @DrewryPope
    @DrewryPope 11 місяців тому +1

    i.. almost understood this.

  • @inserteunnombreapropiado9079
    @inserteunnombreapropiado9079 11 місяців тому

    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?

  • @alejandroulisessanchezgame6924
    @alejandroulisessanchezgame6924 11 місяців тому

    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.

  • @mendelovitch
    @mendelovitch 11 місяців тому +52

    Write-only languages.

    • @bzboii
      @bzboii 11 місяців тому +4

      as in purely functional lol

    • @aloussase
      @aloussase 11 місяців тому +29

      Skill issue

    • @tytrdev
      @tytrdev 11 місяців тому +7

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

    • @tytrdev
      @tytrdev 11 місяців тому +7

      @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.

    • @cheeseplated
      @cheeseplated 11 місяців тому +1

      ​​@xnick99in uiua you do write most of the glyphs by writing out their names and the interpreter formats them on runtime, no idea if there's an option to disable the reformatting though

  • @AntoshaPushkin
    @AntoshaPushkin 11 місяців тому +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 11 місяців тому

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

    • @AntoshaPushkin
      @AntoshaPushkin 11 місяців тому

      @@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

  • @charstringetje
    @charstringetje 11 місяців тому +3

    Uiuauizzard

  • @scramjet4610
    @scramjet4610 7 місяців тому +2

    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 6 місяців тому +2

      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

  • @stupid4President
    @stupid4President 11 місяців тому +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….

  • @RusMermaid
    @RusMermaid 11 місяців тому +1

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

  • @01110100011101110110
    @01110100011101110110 11 місяців тому +5

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

  • @badmanjones179
    @badmanjones179 11 місяців тому +11

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