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 Жыл бұрын
Yea, that is really nice! Wish I had known : )
@NoNameAtAll2 Жыл бұрын
aliens keep playing code golf -_-
@JoStro_ Жыл бұрын
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 Жыл бұрын
i love how he was absolutely RAGGING the guy with the strangeloop talk for the first part
@Lukeisun7 Жыл бұрын
I feel bad for the guy
@themcchuck8400 Жыл бұрын
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 Жыл бұрын
@@themcchuck8400Ah ok, that'll be why he named a lot of variables then. Sneaking suspicion he knew perfectly well how to write pythonic code.
@farhanrejwan Жыл бұрын
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.
@SomeKindOfMetalhead Жыл бұрын
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
@PaulFisher Жыл бұрын
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.)
@NithinJune8 ай бұрын
i mean this is worse no? makes it seem like you can pass an arbitrary length array
@PaulFisher8 ай бұрын
@@NithinJune you can! the formula works in any number of dimensions!
@NithinJune8 ай бұрын
@@PaulFisher 🤯
@PaulFisher8 ай бұрын
@@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.
@dzaima Жыл бұрын
Some more BQN solutions: +⌾(ט) - sum under square, using the fact that square root is the inverse of square and.. •math.Hypot :)
@code_report Жыл бұрын
Wow, that is so beautiful!
@JamesSully Жыл бұрын
uiua equivalent: Hypot ← ⍜(ⁿ2)(/+)⊂
@kaikalii Жыл бұрын
I though this was so cool I just added it to Uiua. Next update you'll be able to do ⍜∩(×.)+
@red13emerald Жыл бұрын
@@JamesSullyDon't need the parens around /+ because / is a modifier, but it is more readable this way :)
@bobtherriault Жыл бұрын
@@code_report +/&.:*: in J😉
@librarygangster9108 Жыл бұрын
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.
@guruware8612 Жыл бұрын
13:36 one could also use klingon for coding, i prefer my code to be readable/understandable the next day i wrote it.
@jrockenjoyer Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
No reason though, from math import hypot is gonna probably get you a function far faster
@Konomi_io Жыл бұрын
@@0LoneTech for fun
@schlopping Жыл бұрын
Avoiding standard libraries is crazy. Literally 0 benifit from doing it your way. Probably a performance cut as well.
@Chunes3 Жыл бұрын
The stack code works in the Factor language. Of course, you would probably want to replace dup * with sq in that case.
@notfancy2000 Жыл бұрын
It also looks to me like valid Postscript.
@code_explorations Жыл бұрын
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.
@elitonmachadodasilva3308 Жыл бұрын
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 Жыл бұрын
Ah yes! My mistake, good catch.
@bzboii Жыл бұрын
whats wrong w `lambda (a,b): (a**2+b**2)**0.5` am i crazy??
@thorsday5505 Жыл бұрын
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 Жыл бұрын
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.
@Thwy Жыл бұрын
Each update makes Uiua easier. I'm loving the language even though all my code from last month is now deprecated haha
@EngineerNick Жыл бұрын
"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.
@0LoneTech4 ай бұрын
Indeed. CPython's at least avoids overflows and handles arbitrary dimensions. BQN's •math.Hypot is described as correctly rounded dyadic Hypot⇐+⌾(ט). If a library routine sounds trivial, odds are good it's there to avoid typos and corner cases. No programmer is perfect.
@leightondawson9247 Жыл бұрын
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
@aleksandersabak Жыл бұрын
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 Жыл бұрын
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 ;
@0LoneTech Жыл бұрын
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.
@lionbryce10101 Жыл бұрын
what was that transition at 3:07 where the a in math dropped off and was replaced by a different a? lol
@aslpuppy1026 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@0LoneTech Thank you so much! I’ll make sure to look into them.
@morphx666 Жыл бұрын
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 Жыл бұрын
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).
@0LoneTech11 күн бұрын
@@leetaeryeo5269 As I understand it: Generally System RPL has specializations, while User RPL has dynamic dispatch. I.e. %SQRT, %%SQRT and C%SQRT handle real, extended real, and complex numbers respectively, and User RPL only has SQRT which calls the appropriate System RPL routine for its input. This lets System RPL code skip type checks. System RPL specializations are not listed in the computer's name tables, saving ROM space too.
@chofmann Жыл бұрын
i am so triggered by the thumbnail having the bqn and uiua code not in the order of the logos
@0LoneTech Жыл бұрын
And here I was just lucky enough that both were so unfamiliar and similar I couldn't tell which was which.
@charlieleemburg Жыл бұрын
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.
@acykablyatley Жыл бұрын
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.
@gtgunar Жыл бұрын
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) ü +).
@12-343 Жыл бұрын
3:16 for the issue of parenthesis here, I would honestly write a*a + b*b, with whitespace to show the precedence.
@Grahamplaysgo Жыл бұрын
It would be nice to compare UiUa with Factor another stack based language
@alurma Жыл бұрын
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 Жыл бұрын
(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 Жыл бұрын
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 Жыл бұрын
For reference, I think this talk shows very well the power of cut and paste in concatenative languages: kzbin.info/www/bejne/nJKrc2eDfLZ8fZo
@opposite3426 ай бұрын
14:31 might just be me not understanding array languages well, but I feel like BQN having both C and W combinators as one glyph is quite confusing. Although of course when you know about it you understand that it will be C on two args (dyadic) and W on one arg. But before you explained it here I was so confused and couldn't follow along with your BQN solution that well. I intuit on Uiua much better because it has them in two different glyphs (and also because I think being stack-based makes it simpler to understand and follow along with the steps but that's beside the point).
@0LoneTech4 ай бұрын
There's usually some rationale behind choices like glyph sharing. In this case you're talking about ˜ self/swap. Swap exchanges 𝕨 and 𝕩, but what to do if there was no 𝕨? There's only one argument, so it goes in both places (𝕩 cannot be removed). From the other way, self makes sure a function is called dyadically. If it already was, swapping the arguments does something for an expression. You can even think of it as one then the other, since swap inside self is a no-op. There is a real cost to figuring out whether something is dyadic or monadic, though. Same with forks. Uiua is less irregular, but its modifiers do complicate things. As for C and W? W doubles an argument, so there's some sort of association through the name of the letter in some languages (not e.g. German). I have no idea for C. Oh look, K is from German. If I look in combinatorylogic/table, there are really only 5 names present (the other two are distorted), all in the Haskell column. The only one of them to also appear in the theory columns is mislabelled a bird. Naming is an infamously hard problem, and I do wish combinatorics fans would come up with a better idea than "birds are a theme". Perhaps actually considering the names Iversonian languages already have, and not C++ style bikeshed entirely different ones out of spite.
@angeloceccato Жыл бұрын
I Heard 1/2 of your talk about combinatory intuition, i will continue in the weekend 😅
@alphabasic1759 Жыл бұрын
That code does really look a lot like forth
@fredguth1315 Жыл бұрын
A,b are floats or hypot returns int
@SimGunther Жыл бұрын
"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.
@0LoneTech4 ай бұрын
Does any Iversonian language other than Co-dfns support GPUs? The low level side ismore the domain of Chapel or Halide.
@Goodvvine Жыл бұрын
Not holding any punches 😂
@galenivanov5575 Жыл бұрын
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.
@theappearedone Жыл бұрын
does any company or project actually use these languages?
@addcoding8150 Жыл бұрын
When I saw this talk I instantly thought of Uiua. Nice to see it explored here
@golumclanstreams1129 Жыл бұрын
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.
@ProCoder200711 ай бұрын
Well, I like watching Uiua and BQN videos but still I have no idea where should I use these. Any ideas? :) ty!
@roccociccone59710 ай бұрын
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.
@mayabartolabac Жыл бұрын
who's gonna tell this guy hypot is 2 characters now
@granieiprogramowanie2235 Жыл бұрын
just finished😁 amazing video. maybe ill get into combinatory logic, it looks cool
@TheMlg556 Жыл бұрын
I also love the "pythogoras" typo at 1:49 :D python+pythagoras=pythogoras???
@code_report Жыл бұрын
Lol, I didn't even notice that 😂
@Yupppi Жыл бұрын
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.
@alex_s168_p Жыл бұрын
How would you split an array at specific indecies in Uiua? for example: indecies: [4 8 12] array: "test aaa ccc awfs"
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@mathiassven There is numbers.Number, which both int and float are subclasses of.
@mathiassven Жыл бұрын
@@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 Жыл бұрын
@@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.
@granieiprogramowanie2235 Жыл бұрын
great video so far🤗🤗
@confronter19 ай бұрын
why not just do sqrt(a^2+b^2)?
@codework-vb6er10 ай бұрын
Postscript is based on Forth ( I think Postscript uses "roll" instead of swap).
@0LoneTech6 ай бұрын
PostScript roll is a generalized stack rotate (rot in Forth), such that: 2 1 roll = swap, 3 -1 roll = rot, 3 1 roll = -rot, 4 2 roll = 2swap. Forth usually doesn't do deep changes in the stack.
@naturallyinterested7569 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
@@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 Жыл бұрын
@@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.
@0LoneTech6 ай бұрын
@@naturallyinterested7569 That's certainly a dramatic overcomplication. It really reads root of sum of multiplication with self. BQN's precedence rules are beautifully simple; we only need to tell the difference between functions and modifiers, and that can be done by shape without identifying the particular glyph. The main twists are ambivalence (which often creates a related function) and forks. Transliteration of √+○(ט) using the primitive names: square root (add over (multiply self)). Over has (is) a big circle, so it's a 2-modifier, and self is a 1-modifier as it's up high (but not a quote). The use of over in particular (not atop) suggests the whole thing is dyadic and makes multiply-self monadic (that's why it's self, not swap). Root is monadic because it's left in a 2-chain (implicit atop). I'm not raised on BQN, though. I don't think "atop" but "of", short for function composition (. in Haskell). Still, I prefer a vector form such as +´⌾(ט). In contrast... sqrt(aˆ2 + bˆ2) is perfectly clear, but why are you spacing out the higher precedence addition between those xors? And why are you doing a floating point operation to something you've done bitwise operations to?
@Otomega1 Жыл бұрын
What would be really nice and cool is operations on more complex data structures like graphs, tensors and complex/hypercomplex numbers.
@spacelem Жыл бұрын
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 Жыл бұрын
CPython's math.hypot does that scaling internally.
@yash1152 Жыл бұрын
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.
@maninalift Жыл бұрын
Why are a and b ints in your toe annotation?
@qu4ku Жыл бұрын
code_report, the destroyer of code.
@marcosgrzesiak45182 ай бұрын
Uiua had Complex numbers, so this is just `abs complex` (2 chars) now
@adityamwagh Жыл бұрын
How is any of this legible? I don’t understand the purpose of UIUA.
@angeloceccato Жыл бұрын
But elixir/erlang have combinatory support?
@movax20h Жыл бұрын
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).
@jmirodg7094 Жыл бұрын
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.
@TheChexmo Жыл бұрын
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....
@oida10000 Жыл бұрын
I would properly also refactored from asq=a*a to asq=a**2.
@jesusjar11 Жыл бұрын
Damn; beef has no bounds 😂
@c4tubo Жыл бұрын
Nice scorching hot takedown. Break a leg!
@Bliss467 Жыл бұрын
Not sure I like how () reads backwards
@TankorSmash Жыл бұрын
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 Жыл бұрын
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 🙈
@user-kn4wt6 ай бұрын
haha this video was hilarious 😅 also for python you can use ** 2 to make it look like the formula, i.e math.sqrt(a ** 2 + b ** 2)
@r4fa3l59 Жыл бұрын
I ❤ UIUA
@anon_y_mousse Жыл бұрын
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.
@Dent42 Жыл бұрын
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 Жыл бұрын
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.
@themcchuck8400 Жыл бұрын
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))
@cmdlp4178 Жыл бұрын
Python: hypot = lambda *a: (sum(d**2 for d in a))**0.5
@yash1152 Жыл бұрын
10:15 aaaahhhh, uiua is sooo better with stacks than these other things.
@yash1152 Жыл бұрын
... [these other things] based on infix
@emilien.breton Жыл бұрын
from math import hypot as pythagoras 🤷
@xernerac Жыл бұрын
(a**2 + b**2)**0.5
@MrEo89 Жыл бұрын
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 Жыл бұрын
It is an intentional Python feature, often referred to as batteries included.
@MrDiverXHD Жыл бұрын
Lang5
@0LoneTech Жыл бұрын
First idea in Haskell: hypot = sqrt . sum . map (ˆ2) This sure resembles a few of those glyphy solutions.