Python vs Uiua vs BQN

Поділитися
Вставка
  • Опубліковано 25 чер 2024
  • A video comparing several implementations of the Pythagorean Theorem in Python, Uiua, BQN and an unnamed stack language. Initial Python code is take from the ‪@StrangeLoopConf‬ • "Concatenative program...
    Uiua: www.uiua.org/
    UiuaPad Code: uiua.org/pad?src=SHlwb3Qg4oaQ...
    BQN: mlochbaum.github.io/BQN/
    BQN Code: mlochbaum.github.io/BQN/try.h...
    CombinatoryLogic.com: combinatorylogic.com/index.html
    ‪@StrangeLoopConf‬ 2023 Talk: • "Concatenative program...
    ‪@cppnorth‬ 2023 Talk • Function Composition i...
    Chapters:
    0:00 Intro
    0:15 Motivation (Strangeloop Talk)
    0:49 Douglas's Python Solution
    2:00 Refactor the Python Solution
    4:04 Ask ChatGPT for Function Name
    4:31 Why Python is Amazing
    5:12 Douglas's Stack Language Solution
    5:28 Is it Forth?
    6:57 Uiua Solutions
    9:27 BQN Solutions
    13:31 Combinator Comparison
    14:31 Learn More About Combinators
    15:38 Outro
    Follow me on Github: github.com/codereport
    Follow me on Twitter: / code_report
    Follow me on LinkedIn: / codereport
  • Наука та технологія

КОМЕНТАРІ • 138

  • @joseburgosguntin
    @joseburgosguntin 8 місяців тому +55

    you can also use this solution with ' (bind) when you are composing only two functions that need to passed to someother function like ∩ (both)
    √+∩'ⁿ2
    it just saves one character

    • @code_report
      @code_report  8 місяців тому +12

      Yea, that is really nice! Wish I had known : )

    • @NoNameAtAll2
      @NoNameAtAll2 8 місяців тому +2

      aliens keep playing code golf -_-

    • @JoStro_
      @JoStro_ 8 місяців тому +2

      you could also square by using invert on squareroot (resulting in √+∩⍘√), eliminating the need for the bind. but that's really getting into code golf territory.

  • @44mira
    @44mira 8 місяців тому +53

    i love how he was absolutely RAGGING the guy with the strangeloop talk for the first part

    • @Lukeisun7
      @Lukeisun7 8 місяців тому +9

      I feel bad for the guy

    • @themcchuck8400
      @themcchuck8400 8 місяців тому +10

      You need to watch the Strangeloop talk. Then you'll understand the point the guy was trying to make, and how it has nothing to do with writing good Python code. The point was to show how named variables act in most programming languages, using Python as an easy example.

    • @davidmurphy563
      @davidmurphy563 8 місяців тому +4

      ​@@themcchuck8400Ah ok, that'll be why he named a lot of variables then. Sneaking suspicion he knew perfectly well how to write pythonic code.

  • @SomeKindOfMetalhead
    @SomeKindOfMetalhead 8 місяців тому +19

    I practically never comment on videos, but I just wanted to say that I’ve been enjoying your content for a while and that you single-handedly inspired me to explore different programming languages and paradigms. Thanks to you, I’ve also been preparing some presentations for my fellow grad students, as I’m really excited to share what I’ve learned!
    By the way, I’ve been loving the videos on Uiua! I think it’s a really exciting language and I hope to see more of it through this channel as well :D

  • @dzaima
    @dzaima 8 місяців тому +16

    Some more BQN solutions:
    +⌾(ט) - sum under square, using the fact that square root is the inverse of square
    and.. •math.Hypot :)

    • @code_report
      @code_report  8 місяців тому +3

      Wow, that is so beautiful!

    • @JamesSully
      @JamesSully 8 місяців тому +1

      uiua equivalent:
      Hypot ← ⍜(ⁿ2)(/+)⊂

    • @kaikalii
      @kaikalii 8 місяців тому

      I though this was so cool I just added it to Uiua.
      Next update you'll be able to do ⍜∩(×.)+

    • @red13emerald
      @red13emerald 8 місяців тому +1

      @@JamesSullyDon't need the parens around /+ because / is a modifier, but it is more readable this way :)

    • @bobtherriault
      @bobtherriault 8 місяців тому

      @@code_report +/&.:*: in J😉

  • @jrockenjoyer
    @jrockenjoyer 8 місяців тому +32

    The math import can be avoided if you only need sqrt. Just using **.5 is fine. So something like hypot=lambda a,b:((a*a)+(b*b))**.5

    • @0LoneTech
      @0LoneTech 8 місяців тому +16

      As a Python programmer, it often baffles me why people are so against importing things from the *standard library* of all places. This is not some third party dependency.

    • @Oscar-vs5yw
      @Oscar-vs5yw 8 місяців тому +8

      No reason though, from math import hypot is gonna probably get you a function far faster

    • @K0nomi
      @K0nomi 8 місяців тому +1

      @@0LoneTech for fun

    • @schlopping
      @schlopping 8 місяців тому +3

      Avoiding standard libraries is crazy. Literally 0 benifit from doing it your way. Probably a performance cut as well.

  • @PaulFisher
    @PaulFisher 8 місяців тому +15

    if i were going to make the most pythonic Pythagorean function, i would eliminate *all* the leg variable names:
    def hypot(*legs):
    return sum(leg ** 2 for leg in legs) ** (1/2)
    this takes advantage of constructs that are unique(ish) to idiomatic Python rather than just things common to essentially all imperative languages. that and golfing this type of thing is fun.
    (also having known Creager from a mutually previous company, he’s super nice. not directly relevant to any of my code antics, just wanted to mention it.)

    • @NithinJune
      @NithinJune 2 місяці тому

      i mean this is worse no? makes it seem like you can pass an arbitrary length array

    • @PaulFisher
      @PaulFisher 2 місяці тому +1

      @@NithinJune you can! the formula works in any number of dimensions!

    • @NithinJune
      @NithinJune Місяць тому +2

      @@PaulFisher 🤯

    • @PaulFisher
      @PaulFisher Місяць тому +1

      @@NithinJune it’s fun to derive that fact from only the 2D version! give it a try if you haven’t already done so-it helps to think of the 3D case as a c-height diagonal off of the original a/b diagonal. then you can go from there to infinity with induction :)
      another cool consequence: it also works in 1D, since sqrt(a²) = a. you can even do 0D: sqrt(sum([])) = sqrt(0) = 0.

  • @librarygangster9108
    @librarygangster9108 8 місяців тому +4

    Your videos about uiua convinced me to try an array programming language for the first time, and since then, I pretty much use it to solve coding challenges every day. Thank you.

  • @code_explorations
    @code_explorations 8 місяців тому +7

    I’ve taken an interest in your APL/BQN solution videos for a while now, but Uiua is next-level interesting. All the power but more accessible, it seems. The more videos you make on Uiua, the better the world will be. And for some of them, you could assume the viewer has no prior knowledge of the paradigm.

  • @farhanrejwan
    @farhanrejwan 5 місяців тому +2

    4:00 - fun fact : that theorem probably was not even created by Pythagoras, rather re-discovered. today, a more generalized version of the theorem is known as Al-Kashi's theorem.

  • @aleksandersabak
    @aleksandersabak 8 місяців тому +5

    Not only did not do justice to Python, he didn't do justice to concatenative programming either. In an actual concatenative language like Factor the hypot function would look like this, where `bi@` is like uiua's `both`:
    ```
    : hypot ( a b -- c ) [ dup * ] bi@ + sqrt ;
    3 4 5 12 [ hypot ] 2bi@
    ```

    • @0LoneTech
      @0LoneTech 8 місяців тому

      Feels more like RPL than Forth, but we can do it in Forth too using ' :noname and execute. Something like : bi@ dup -rot execute -rot execute swap ;

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

    The stack code works in the Factor language. Of course, you would probably want to replace dup * with sq in that case.

    • @notfancy2000
      @notfancy2000 8 місяців тому +1

      It also looks to me like valid Postscript.

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

    whats wrong w `lambda (a,b): (a**2+b**2)**0.5` am i crazy??

  • @Thwy
    @Thwy 8 місяців тому +4

    Each update makes Uiua easier. I'm loving the language even though all my code from last month is now deprecated haha

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

    On 2:05, I believe the comments are there to represent the output of the print. Shouldn't the 12 be 13?
    Great Video 🤗

    • @code_report
      @code_report  8 місяців тому +4

      Ah yes! My mistake, good catch.

  • @thorsday5505
    @thorsday5505 8 місяців тому +2

    I think why he wrote python in that way can be justified, because it's the closest representation to what is actually happening in the stack frame, by explicitly listing out every intermediate result. He later demonstrated this execution process, and compared to how a stack-base language would approach the same problem. After all, it's not a talk about python

    • @0LoneTech
      @0LoneTech 8 місяців тому

      It's not a talk about Python, but it's misrepresenting a LOT of languages. He said it was to represent name-based languages, which Python is to a higher degree than most, but went out of his way to pretend unnamed intermediates don't exist, turning the code into pseudo-assembly for a register machine (static single assignment style). In reality CPython's VM is stack based and uses fixed slots for locals (frames don't grow the way he showed), so the cost of naming is nearly entirely misattributed; looking up sqrt would be the big one.
      He does note repeatedly that he's talking of how the source text is built. In that regard, Python does expect values to be named, but hardly *all* of them. In the comparison shown, the stack language winds up losing out because even though he arbitrarily named all results, he had to complicate it with dup and swap when not doing so.

  • @granieiprogramowanie2235
    @granieiprogramowanie2235 8 місяців тому +1

    just finished😁 amazing video. maybe ill get into combinatory logic, it looks cool

  • @granieiprogramowanie2235
    @granieiprogramowanie2235 8 місяців тому +1

    great video so far🤗🤗

  • @SimGunther
    @SimGunther 8 місяців тому +1

    "If you're gonna reinvent the wheel that standard libraries created, at least bother to 'man up' and do it super fastly or else I'm not taking it seriously. BTW use a real, NOT hypothetical, stack language to do the hypotenuse formula and display the results live. Don't you come back here no more until you learn you some Iversonian languages real good like a real manly man, ya' hurr?"
    Is what you were basically saying to the Strange Loop speaker.
    Just because you're in the domain of ML/GPU accelerated computing doesn't mean everyone is forced to do so by getting into Iversoinan languages like APL, Uiua, BQN, and J/K. Sometimes it's okay to have a Forth for systems/embedded programming, conditionals, or a DSL, sometimes you need a Uiua for protypable big maths.

  • @EngineerNick
    @EngineerNick 8 місяців тому +1

    "hypot" in most languages actually a special implementation; For most programming languages this probably forwards a call to cmath::hypot which does special scaling magic to help reduce floating point issues with very large or very small numbers. I learned this the hard way after hours debugging failed tests.

  • @addcoding8150
    @addcoding8150 8 місяців тому

    When I saw this talk I instantly thought of Uiua. Nice to see it explored here

  • @0LoneTech
    @0LoneTech 8 місяців тому +1

    There's a standard extension word set for floating point, wherein the stack example is simply missing an F prefix on all the words called. Many forths targets systems without that, though, and tend to use fixed point math when appropriate.

  • @alurma
    @alurma 8 місяців тому +4

    Hi, Conor, love your videos.
    I don't think the purpose of the example in the talk was to somehow put a shade on Python.
    The purpose was to show that it's possible to rely on local variables in non-concatenative languages (which is cool).
    Locals (and named parameters) are generally (not always!) avoided in concatenative languages (some languages even lack them) because they complicate ability to cut chunks of the code and paste them somewhere else.
    That is, if locals are absent in concatenative code, then it's possible to cut any piece of the code, name it somehow, and paste that definition back in.
    ===
    After I think about it, I think that also applies to Python to some extent. But parameters in Python defs and lambdas must be explicitly named, which eliminates above stated property of concatenative languages (I guess you can use a global stack to pass everything but that sounds goofy)

    • @alurma
      @alurma 8 місяців тому +1

      (Neither purpose of the code was to be beautful. I'm glad you made it beauful, butI hope you understand why that code in the talk was so ugly)

    • @code_report
      @code_report  8 місяців тому

      Yea that is a good point, but if that is true - they should have made it clear that this isn't how you should write Python code. In a video comparing X language vs Y language where you are trying to "promote" Y language (or the paradigm Y is in) - it looks bad in my opinion if you write some code in language X that looks really bad without saying "this isn't idiomatic but im just trying to highlight how you can use locals everywhere." Otherwise it kind of just looks like you are making an "unfair" comparison.

    • @alurma
      @alurma 8 місяців тому +1

      For reference, I think this talk shows very well the power of cut and paste in concatenative languages: ua-cam.com/video/faHB4MGQIG8/v-deo.html

  • @Goodvvine
    @Goodvvine 8 місяців тому +1

    Not holding any punches 😂

  • @angeloceccato
    @angeloceccato 8 місяців тому +1

    I Heard 1/2 of your talk about combinatory intuition, i will continue in the weekend 😅

  • @charlieleemburg
    @charlieleemburg 8 місяців тому +3

    The stack based language example might just be pseudocode to prove a point and not in any specific language.
    And I also solved this problem in my own array langauge:
    Hypot ← ^2/+√2
    Hypot ← ×₀/+√2
    I don't really have something to do those last two with, it is definitely a nice feature to have a dedicated square root operator, but then what about third roots, like in Uiua for example I could do this:
    ⁿ÷3 1 27
    Like I'm not great at Uiua so I don't know if there is a way to do that without needing to do 1/3, because you don't want to be writing out all those 3's, in my language I made it just √3.

  • @leightondawson9247
    @leightondawson9247 8 місяців тому

    I strongly suspect given the quoted programs (see 9:41 in the strange loop talk) that Douglas Creager is using a version (or descendant) of the Joy language in his talk, especially given that he cites MvT's "mathematical foundations of Joy" in the description

  • @gtgunar
    @gtgunar 8 місяців тому +1

    There is also the Under dyadic operator often being user defined in APL, that does for A under B:
    A,then B, then A_inverse... I'm not sure about the exact syntax but this train of tought was mentioned multiple times in APL talks.
    Squaring under Summing would also work ((* jot 2) ü +).

  • @Otomega1
    @Otomega1 8 місяців тому

    What would be really nice and cool is operations on more complex data structures like graphs, tensors and complex/hypercomplex numbers.

  • @acykablyatley
    @acykablyatley 8 місяців тому

    its worth noting that hypot would take floating point arguments, not integers, and the hypot implementation has more logic to handle overflow/underflow cases that sqrt(a*a+b*b) does not.

  • @lionbryce10101
    @lionbryce10101 8 місяців тому

    what was that transition at 3:07 where the a in math dropped off and was replaced by a different a? lol

  • @roccociccone597
    @roccociccone597 4 місяці тому

    The thing about libraries is true to a certain extent. But eventually you'll reach the situation you're in in JS land where you have dependencies to check whether things are a string or not. Always find a balance, certain things don't need a library.

  • @ProCoder2007
    @ProCoder2007 4 місяці тому

    Well, I like watching Uiua and BQN videos but still I have no idea where should I use these. Any ideas? :) ty!

  • @galenivanov5575
    @galenivanov5575 8 місяців тому

    The J solution using "under" is also very concise:
    hypot =. +&.*:
    3 hypot 4
    5
    It's read: summatioan under square. First both left and right argument are squared, then the results are added together and finally square root of the summation is taken.

  • @jesusjar11
    @jesusjar11 8 місяців тому +1

    Damn; beef has no bounds 😂

  • @Yupppi
    @Yupppi 8 місяців тому +1

    Sooo... Starting with the complaint that someone wrote the variable names to a commoner instead of someone who liked math in school and made it looks ugly because it had names that were relevant to the trigonometry. Is the argument that an experienced python programmer doesn't follow the philosophy of writing descriptive and clear variables, even if it's a math problem?
    I prefer using parentheses just to make it clear at a glance. Someone who reads the code without focusing can miss that one of the blots was plus and the others *, or which one. Furthermore despite doing a decent amount of calculations daily (or becausd of it) I do make mistakes that are purely from sloppiness. So in (my opinion) good engineering practice, I prefer limiting, minimizing and removing all the possibilities to abuse, misuse and misinterpret. Like doing the correct order of calculations when you're thinking of something else. I do agree it's not a very high concern here, but I assume the program is not made for me either. When the equations get more complicated and there's division etc, that's when I really prefer unambiguous marking.
    But I did agree with the idea of writing it in a single line and avoiding extra operations for obvious, it being more compact, descriptive and serving the goal better. And I saw how much slower python gets in scaling up for every unnecessary operation even if the operation doesn't do anything.
    I also agree on the thought that python is so great for the libraries. Like 100% of the time it's better to use a library that does it in C than do it yourself in python and make it much worse than it'd need to be. The only complaint from me about that is that I never understand what's happening in the reference codes because it's basically just random human language words or mangled human word pieces, and it never works. Because it uses so many libraries and behind the scenes things that can't be seen from the code. And perhaps all of the libraries and even python version itself are different than the current ones so they work differently. Like honestly most of the time when you watch some coding tips/tutorials/advice on python it makes no sense and won't work for you.

  • @cmdlp4178
    @cmdlp4178 8 місяців тому

    Python:
    hypot = lambda *a: (sum(d**2 for d in a))**0.5

  • @golumclanstreams1129
    @golumclanstreams1129 8 місяців тому

    There is an error in the first part of the video. The code comment of hypot(5, 12) says it should be 12 but actually it would be 13.

  • @chofmann
    @chofmann 8 місяців тому +4

    i am so triggered by the thumbnail having the bqn and uiua code not in the order of the logos

    • @0LoneTech
      @0LoneTech 8 місяців тому

      And here I was just lucky enough that both were so unfamiliar and similar I couldn't tell which was which.

  • @aslpuppy1026
    @aslpuppy1026 8 місяців тому +2

    I’m want to learn an array programming language. Does anyone have any recommendations as to where to start? I tried APL and I liked it, but I couldn’t find a way to write programs, only one-liners in the interpreter. So, any suggestions? (other than APL).

    • @0LoneTech
      @0LoneTech 6 місяців тому

      Depends a lot on what you want to learn. Consider e.g. Futhark (mid level CPU/GPU programming), Octave (a free implementation of the Matlab language), NumPy (adds numeric array types in Python), or for closer to C++ SYCL, ArrayFire or libgpuarray. If you have data you want to work on, Pandas is probably a quick way there. CBQN also does have an FFI and access to arguments, terminal, time and files, and is a lot more APL-ish than any of the others I've mentioned. I'm probably going to play a bit with CBQN now.

    • @aslpuppy1026
      @aslpuppy1026 6 місяців тому

      @@0LoneTech Thank you so much! I’ll make sure to look into them.

  • @c4tubo
    @c4tubo 8 місяців тому

    Nice scorching hot takedown. Break a leg!

  • @spacelem
    @spacelem 8 місяців тому +1

    In Julia (if we define a square function first)
    square(x) = x.^2
    Then we can get a lovely point free solution with
    myhypot = sqrt ∘ sum ∘ square
    myhypot([3,4,5])
    7.071...
    However an actual hypot definition would probably divide by the largest component of x first, then multiply it back in to avoid overflow. So I'll go with
    function safe_hypot(x)
    mx = maximum(x)
    mx * sqrt(sum((x / mx).^2))
    end
    safe_hypot([3,4,5])
    7.071...
    And leave the prettying up of that to later.

    • @0LoneTech
      @0LoneTech 8 місяців тому

      CPython's math.hypot does that scaling internally.

  • @theappearedone
    @theappearedone 8 місяців тому

    does any company or project actually use these languages?

  • @mayabartolabac
    @mayabartolabac 7 місяців тому

    who's gonna tell this guy hypot is 2 characters now

  • @guruware8612
    @guruware8612 5 місяців тому +1

    13:36 one could also use klingon for coding, i prefer my code to be readable/understandable the next day i wrote it.

  • @Grahamplaysgo
    @Grahamplaysgo 6 місяців тому

    It would be nice to compare UiUa with Factor another stack based language

  • @fredguth1315
    @fredguth1315 8 місяців тому

    A,b are floats or hypot returns int

  • @qu4ku
    @qu4ku 8 місяців тому

    code_report, the destroyer of code.

  • @halneufmille
    @halneufmille 8 місяців тому

    3:43 Sorry, I'm not too familiar with Python. Is there a reason to specify the input type as int? Isn't there some sort of number type?

    • @code_report
      @code_report  8 місяців тому +3

      You could use float but i prefer int. And if you use type annotations you can use type checkers like mypy which are very useful.

    • @mathiassven
      @mathiassven 8 місяців тому +1

      Additionally, in python, there is no "Number" type, Int is actually considered a subtype of float, so if you wanted to be more general you would use float.
      Note: A subtype only in terms of static checking, Int isn't a subclass of float

    • @0LoneTech
      @0LoneTech 8 місяців тому

      @@mathiassven There is numbers.Number, which both int and float are subclasses of.

    • @mathiassven
      @mathiassven 8 місяців тому

      ​@@0LoneTech Int and float are virtual subclasses of Number, but they are not subtypes, or at least considered as such. So doing `def add1(a: Number) -> Number: return a + 1`, you would not be able to call it with `add1(1)`

    • @0LoneTech
      @0LoneTech 8 місяців тому +1

      @@mathiassven I most certainly can, but mypy does fail to type check it. This is now a matter for your type checker of choice and not Python.

  • @12-343
    @12-343 8 місяців тому

    3:16 for the issue of parenthesis here, I would honestly write a*a + b*b, with whitespace to show the precedence.

  • @jmirodg7094
    @jmirodg7094 8 місяців тому +3

    I'm booth fascinated and terrified by those stack glyph languages, 30 years ago I did a bit of Forth, it was very powerful, but I quickly realized that it was not really maintainable, A few years later I had a look at Pearl which was pretty compact but quite unmaintainable as those squiggly signs could discretely and powerfully change what the code is doing. those are language that you write once and can not really read again. But now when I see BQN and Uiua there we are at an other level combining the stack with an extreme glyph generates code where it might take a month for an expert coder to decipher 100 lines of code if he/she is not the one who has written it.
    I guess maybe it will be easy for a LLM AI to read and write this type of code, however it seems not very adapted to humans.

  • @maninalift
    @maninalift 8 місяців тому

    Why are a and b ints in your toe annotation?

  • @alex_s168_p
    @alex_s168_p 8 місяців тому

    How would you split an array at specific indecies in Uiua?
    for example:
    indecies: [4 8 12]
    array: "test aaa ccc awfs"

    • @code_report
      @code_report  8 місяців тому

      SplitOnIndex ← ⊜□⬚1↙⧻,¬⍘⊚
      SplitOnIndex [4 8 12] "test aaa ccc awfs"

  • @r4fa3l59
    @r4fa3l59 8 місяців тому +2

    I ❤ UIUA

  • @themcchuck8400
    @themcchuck8400 8 місяців тому

    Modern concatenative languages have similar combinators, but they are applied in order left to right, and so are easier to read.
    Here are Listack examples of your two methods:
    def: "hypot1" [Num, Num] {\sqr both .+ sqrt} # does not listify arguments
    def: "hypot2" [Num, Num] {2 .enlist {dup .*} .each .+ .sqrt} # listifies arguments
    Or, if you really want to use local variables and a more traditional style:
    def: "hypot3" [Num, Num] { -2 |> sqrt((a.sqr) + (b.sqr))

  • @oida10000
    @oida10000 8 місяців тому

    I would properly also refactored from asq=a*a to asq=a**2.

  • @codework-vb6er
    @codework-vb6er 4 місяці тому

    Postscript is based on Forth ( I think Postscript uses "roll" instead of swap).

  • @angeloceccato
    @angeloceccato 8 місяців тому

    But elixir/erlang have combinatory support?

    • @movax20h
      @movax20h 6 місяців тому

      Not really. There are standard Lisp-like operators, like map, reduce, fold, foldmap, filter, zip. But these are just normal functions getting other functions and lists. It is possible to construct combinators, even the Y combinator (I did it in Erlang like 15 years ago, including one without Y combinator referencing itself by name either), but that is true for most languages that do have functions as values (i.e. JavaScript, C++, D, Python).

  • @alphabasic1759
    @alphabasic1759 7 місяців тому

    That code does really look a lot like forth

  • @TheMlg556
    @TheMlg556 8 місяців тому +1

    I also love the "pythogoras" typo at 1:49 :D python+pythagoras=pythogoras???

    • @code_report
      @code_report  8 місяців тому +2

      Lol, I didn't even notice that 😂

  • @anon_y_mousse
    @anon_y_mousse 8 місяців тому

    This was interesting, but I'm still not sure what you're trying to say. Is it that Uiua and BQN are more expressive than Python? If so, then agreed, but expressivity (if I can abuse the word here), really shouldn't be the end goal when it results in write-only code. I skimmed the comments and couldn't find anyone else providing the answer, but the unnamed stack language was Porth. I only know of it because I watch the guy who created it, Tsoding. And one final thought, but ChatGPT's answer offends me, and you might think it's weird, but C99 diverged from C++ to such an extent that it was easy to write code which would work in C but not in C++ and no one should have continued clumping them together, but 24 years later and people are still doing it, as evidenced by the LLM which did so and gave an incorrect slash incomplete answer. For one, and I'm sure you know this, but for C++ either std:: would need to be prepended to the function or a using directive would've needed to be used, so the two should have been separated at the least to distinguish that notable difference.

  • @jhfybcsyyhgf
    @jhfybcsyyhgf 3 місяці тому

    why not just do sqrt(a^2+b^2)?

  • @TheChexmo
    @TheChexmo 8 місяців тому

    Do Uiua or BQS have real life usage? I mean... It doesn't matter how much I'd like to happen what Im going to say... but I don't believe any enterprise would program a performant REST API with this....

  • @adityamwagh
    @adityamwagh 8 місяців тому

    How is any of this legible? I don’t understand the purpose of UIUA.

  • @yash1152
    @yash1152 8 місяців тому

    7:16 Uiua386 font based on APL386 ahhhww, thats the reason it exists. ohkay. I was windering, why a new font - ohkay, but why the suffix 386. it makes sense now.

  • @TankorSmash
    @TankorSmash 8 місяців тому +6

    I think you were exaggerating for effect, but it comes off a little strong towards the author of that talk. I know you didn't mean it that way, but it comes off as mean or belittling, rather than funny. Maybe you know the person and I'm out of line though!

    • @code_report
      @code_report  8 місяців тому +4

      No you are right. I was trying to be comical but I asked a colleague and they said it sounds a bit mean. If Douglas comes across this talk I hope he doesn't take it that way 🙈

  • @naturallyinterested7569
    @naturallyinterested7569 8 місяців тому +1

    My big issue with these is that if I came across this implementation without the name in some code I would have a hard time figuring out what is being computed here, while sqrt(a*a + b*b) is pretty much universal. And I don't think that's just a skill issue. APL and co have been called write-only languages by people much smarter than me.

    • @brendanhansknecht4650
      @brendanhansknecht4650 8 місяців тому

      By people who have never taken the time to learn apl. The symbols make it more readable, not less. Also, names are still used once a function gets long enough.

    • @naturallyinterested7569
      @naturallyinterested7569 8 місяців тому +1

      @@brendanhansknecht4650 I don't necessarily think so. In the python example you have no problem to decipher sqrt(a^2 + b^2), _because it's sqrt(a^2 + b^2)._
      In the BQN example you have to go (a bit overdramaticized)
      Is the _sqrt_ part of the combinator...? No it binds more strongly, I think. So it's just plus and times with a tilde?
      Okay, so it's the k combinator... that means it's _f (g x) (g y)_
      So _f_ is _+,_ easy peasy!
      Then _g_ is... times. But with a self modifier? I'm not that good. Or is that swap? What's the argument's type and rank? Does it distribute over an array? (it does)
      So it's _+ (* x x) (* y y)_ ?
      And now it's sqrted. So it's sqrt(x*x + y*y)? What's the context? Scalar, array, matrix? Character? No, not character. Me very sad. Well, depends on the glyphs directly to the left and right... Or did I mis-parse the operator precedence? Oh god is that rank operator laughing at me? Mommy, I want off Mr. BQN's wild ride.

    • @brendanhansknecht4650
      @brendanhansknecht4650 8 місяців тому

      @@naturallyinterested7569 sure, but in bqn you don't have to be so terse or tacit. Conor likes to get solutions with as few characters as possible, that is not the case for all array language users. There definitely are options here. I do agree there are more ways to write hard to read code, but I definitely find that in general it is a boon for readability (when not focused too much on golfing).
      That said, some combinators and such do become automatic with time. No question when reading it. Just know.

    • @0LoneTech
      @0LoneTech 8 місяців тому

      ​@@naturallyinterested7569 Just thought I'd note that ˆ (caret) is bitwise xor in Python (as in C), exponentiation is ** (double asterisk). I'd be more likely to write scipy.linalg.norm or something anyway, because the code exists more for human readers than computers.

  • @morphx666
    @morphx666 8 місяців тому +5

    5:24 As soon as I saw it I recognized it as the language used by all RPN-based HP calculators, such as the famous HP48 models.
    From Wikipedia: The calculators use Reverse Polish Notation (RPN) and the RPL programming language.

    • @leetaeryeo5269
      @leetaeryeo5269 8 місяців тому +1

      Yep, that's what I was gonna say. The RPL programming language looks very much identical to that. The only difference I can see between that and RPL is that sysRPL uses xSQRT as its sqrt function according to the documentation, but that could very well just be a documentation notation that I'm not familiar with and the actual function call is SQRT (with the x reminding the reader that there needs to be something on the stack).

  • @xernerac
    @xernerac 8 місяців тому

    (a**2 + b**2)**0.5

  • @yash1152
    @yash1152 8 місяців тому

    10:15 aaaahhhh, uiua is sooo better with stacks than these other things.

    • @yash1152
      @yash1152 8 місяців тому

      ... [these other things] based on infix

  • @Bliss467
    @Bliss467 8 місяців тому

    Not sure I like how () reads backwards

  • @MrDiverXHD
    @MrDiverXHD 8 місяців тому +1

    Lang5

  • @emilien.breton
    @emilien.breton 8 місяців тому

    from math import hypot as pythagoras 🤷

  • @MrEo89
    @MrEo89 6 місяців тому

    Fry meme: “can’t tell if my man is lvl 40 trolling the other coder AND US, or if he really thinks python is “great” bc other people have probably already written the code you need to write.
    To me it sounds like he’s confusing python with stackoverflow 😂

    • @0LoneTech
      @0LoneTech 5 місяців тому

      It is an intentional Python feature, often referred to as batteries included.

  • @Dent42
    @Dent42 8 місяців тому +2

    2:30 Gotta disagree with your renaming of those variables. Sure, leg1 and leg2 aren’t ideal names, but they’re at least descriptive. Renaming variables in *code* to be as nondescript as “a” and “b” just because that’s the convention in math is big oof.
    Mathematicians use (mostly) single-character abbreviations because historically, math has been done by hand, so characters representing words/concepts saved time and ink. Early programming languages used minimal characters for built-ins to save time, wrists, paper, and ink.
    We currently live in a time with intelligent code completion, easy code generation from LLMs, and effectively limitless stable storage. Descriptive nomenclature takes more time to write the first time, but pays dividends by saving time spent reading the code.

    • @0LoneTech
      @0LoneTech 8 місяців тому +2

      Early programming characters often used limited lengths to simplify the logic parsing, storing, and looking them up. E.g. single character names in dc or BASIC. Starting FORTH shows examples where only the first 3 characters of words are stored. C89 specifies a large variety of limits, including names differing in the first 31 characters within a compilation unit, or 6 for external linkage. The Colossal Cave Adventure is known as ADVENT, and FORTH as FORTH, because of operating system limits in file name length. The core reason is a _trade off;_ by only handling shorter symbols, more could be tracked in one pass, so the linker would function for larger programs. We wrote programs in systems whose entire memory was counted in a few thousand words, not billions of bytes.
      That aside, mathematicians use glyphs more to improve readability than to conserve ink, and so does APL. It's a concept of concise communication, not merely terse.
      It does have limits. Often we require out of band metadata to explain which notation is used, e.g. chemical formulæ or Eintstein sum notation. And when symbol sets grow large, we need structure to look them up, e.g. radicals and stroke orders in hanzi, vowels in kana, or the order of the futhark or alphabet. Additionally, as we talk to each other, we need a verbal way to convey the same ideas; e.g. FORTH specifically documents that @ is fetch and ! is store, and thus our symbols need naming.
      In this particular case, leg1 and leg2 have some ups and downs. Firstly, they do communicate that they're legs (catheti). In Python, argument names are externally relevant; you could specify them in the call, and renaming them is an API change. But the numbering is arbitrary, only moderately distinct, and repetitive. Python's math.hypot instead uses a single container *coordinates, which conveys the orthogonality better than leg did while generalizing count.
      The single character names in math are instead chosen to convey generality. The formula isn't what decides whether you're calculating a vector length or working with a right angle triangle. Variables are purely placeholders for substitution. Common sequences like abc, ijk or xyz are used as shorthand to lessen the burden of new names; programmers do the same with names like foo bar baz or x:xs. Renaming x to firstElementOfFirstList and xs to firstListExcludingFirstElement won't help when you're reading dozens of functions. That reminds me of LISP's car and cdr combinations; (cdadr l) = (second (first (second l))).
      Established terminology also matters. Consider C++. They have a committee spending much time to pick names for things. They picked some names like transform, partial_sum, and accumulate. The problem is these copy well established concepts with different names. These names are longer than map, scan and fold/reduce. One could even argue partial_sum and accumulate are more descriptive of what they do. But does that help you when you don't recognize what map-reduce means?
      Congratulations to C++20 for introducing ranges, by the way. It only took 35 years to recognize that it's useful to have a concept of "this section" over "start here, stop here, and malfunction drastically if I those didn't match".
      Eh. I'm rambling of topic again.

  • @0LoneTech
    @0LoneTech 8 місяців тому

    First idea in Haskell: hypot = sqrt . sum . map (ˆ2)
    This sure resembles a few of those glyphy solutions.