BQN vs Uiua
Вставка
- Опубліковано 17 чер 2024
- A video comparing the BQN and Uiua programming languages. We revisit the CheckMatrix problem previously solved and compare the tacit solutions in both languages.
Uiua: www.uiua.org/
UiuaPad Code: uiua.org/pad?src=CheckMatrix%...
BQN: mlochbaum.github.io/BQN/
BQN Code: mlochbaum.github.io/BQN/try.h...
APL vs BQN vs J vs Q vs NumPy vs Julia vs R Talk: • APL vs BQN vs J vs Q v...
ArrayCast Uiua Episode: www.arraycast.com/episodes/ep...
Chapters:
0:00 Intro
0:38 Problem Description
1:20 Recap of Previous APL/J/BQN Solutions
2:22 Explicit BQN Solution
3:48 Tacit BQN Solution
6:10 Uiua Solution
8:16 The Beauty of Uiua
9:00 Outro
Follow me on Github: github.com/codereport
Follow me on Twitter: / code_report
Follow me on LinkedIn: / codereport - Наука та технологія
I love array languages as much as the next guy, but we're rapidly approaching the point where it looks like two aliens are playing code golf.
😂
@wikinut1 you say that but coming from trad programming languages, i 100% thought that was the idea until i read your comment
@@DrazkurHW
i didnt realize until just now that these are meant to be actual languages people use and not just exercises in terseness
I literally thought the whole comment section was in on a joke, but this is actually a real thing???
@@maxsteffey6521it's.. pretty bizarre yeah
At some point he says something along the lines of "I like this approach better because it's more readable", and he actually says it like he believes it
3:50
This feels like im watching a programming tutorial from an alternate universe
Fr bro
honestly that's exactly why I like array languages; not for practical purposes so much, but because they *feel* like a programming language from a parallel universe too, and that's just fun.
Why does this look like an average game of Noita when you are crafting wands. This is amazing.
This is what all coding looks like to a non-coder.
A lot of coding mimics English and standard math really closely, so most people could get the gist of a program if the functions and variables are named well. This, on the other hand, just looks like nonsense to nearly everyone lol
I can immediately understand them by this comment. Thank you.
Looks like we have returned to some sort of egyptian hieroglyphs
@@gonzalezm244 True, there's a difference between being able to read through and understand code and actually write it. The average person could write code with a little practice but could understand most simple applications of code without any. Specific syntax rules is what makes writing code so much trickier to an inexperienced developer than being able to read it.
@@dabbopabblo 100%
Just realized I say "identity matrix" when I mean "x matrix" a bunch of times. "x matrix" has both diagonals as 1s, identity only has the one diagonal. Sorry for any confusion.
Trust me, that was the least confusing part about the video
"I think it makes it more readable"
Is it just me or is he coding in enchantment table language?
someone thought... I've 30 levels, let's enchant a pc
I watched basically this whole thing while having no idea what any of this was about... 😂... I really hoped I was going to learn something new but I am apparently HOURS worth of prerequisites away from understanding this video.
Damn, who would have thought that just inserting stack operations into array operations would turn out so great? Love it. I definitely have to look at this language.
Wait so... this isn't an april fools video? PLEASE TELL ME THIS IS AN APRIL FOOLS VIDEO I'M SCARED
it isn't :)))
HELP@@matthias916
I'm learning Uiua as my first array language. It's been an awesome experience!
It seems less intimidating than BQN and APL.
How you learn something like this?
@@victorpinasarnault9135 There is a tutorial on the language's website.
@@victorpinasarnault9135how do you learn any programming language?
madlad
For a second I thought you said "as my first language" and was gonna urge you to reconsider haha
uiua is a really interesting language, will definitely be checking it out. hoping to see more content about it aswell 😊
People used to (are?) mock Perl because you could smash your head on the keyboard and the code would run. To the untrained eye, Perl is so much more readable than this.
It wasn't true in Perl either. TECO on the other hand...
MY FAVORITE PROGRAMMING CHANNEL!!!
please some day also make a video on Nial, seems like one of the more friendly array languages to get into, as it in some ways lets you also do something in a more 'classical' imperative way... and it is not typed in arcane sigils
Why do all array languages use weird glyphs?
They're genuinely fun to use but I feel like the glyphs are unnecessary and increase the barrier of entry for curious folks.
I understand that the design philosophy behind APL was that having glyphs for all operations will somehow make people able to understand them better, but I think by now we all know that that doesn't work.
Uiua's Unicode looks beautiful and the direct/automatic plotting makes it fun to play around in.
Array languages make it really easy to write pipelines. The fact that you can write a "branching and/or converging" pipeline on one line makes it a bit harder to see. If trains were written like the branching statements they are then I think it would be easier to parse. Uiua doesn't do pipelines, it does stack operations. You're still effectively going through a pipeline you just have a stack, which makes not needing branching to do combinator things.
What is the performance of array languages compared to c and zig, for example, is it much O(n^2) or am I missing something?
Part of the benefit of array languages is that everything is an array. The interpreter can take advantage of this by using algorithms optimized for arrays and choosing the best algorithm on the fly for different operations and sizes of arrays. I can't speak for every array language but I know that J will recognize common idioms in the code and use specific, clever algorithms for that particular purpose. Yes, you could do all of this yourself in a lower-level programming language like C, Zig, Rust, Odin, etc. but the beauty of array languages is that the language implementers can do a lot of the tough numerical programming for you, and you can use an expressive language that is still really fast. It takes a lot of the burden off of the programmer when working with problems that are a good fit for array programming languages.
the usefulness does not outweigh the obscurity in design
You get used to reading it pretty fast. I like diving into projects of othes people ant seeing how they do things. Not too hard, a little dense at times.
I've watched a bunch of these array language videos from you. I've got 2 questions:
What's the best way to learn to use them? And are there good examples of major pieces of software written in any of them so that I can look at the code and get a sense of how a largish project is organized and works?
I like trying to solve small problems in them. They Dyalog APL Competition is a great source if you are learning APL. And there are a ton of APL and BQN large projects out there on GitHub. Here is one for BQN: github.com/mlochbaum/BQN/blob/master/md.bqn and bunch for APL: github.com/the-carlisle-group
messing around in an IDE... altough there are a few useful tricks: Since the language is tacit, you can replace any last operation with comma, to log the given arugments, cut and paste working chuncks of code to partially run code that isn't working, you can even log and continue with an anonymus function that prints and then returns it's argument unchanged.
also, you can try your code with as many inputs as you want at once. what is a minute in other languages is 2 seconds here. The Lispy REPL style should be used to the maximum.
About the second question... the boring answer is that Dyalog APL supports object oriented features... so it can be organised in the usual way, about the alternatives, I myself don't know much, but it's not core to the language so there must be some other method.
still more comprehensible than academia math "syntax"
I had to check if this was uploaded on 1 April
Looks like the prefered coding language of ancient civilizations
It seems to me like a magic I definitely want to try learning it
I wonder if this will make it harder to parse long expersions. In bqn, either you are parsing a train or variables end up repeating. The repition in the example you showed may actually help with readability in long expressions.
I assume tracking the stack in our head is more errorprone. For example, if you first copy the main array like 6 times for later use that might be really confusing. Though maybe if you only ever make one copy at a time, it will be ok.
Any thoughts @code_report?
I mean, slightly more atomized functions isn't a big issue imo, and it's not like you can't put things into variables
@@GanerRL Uiua only allows global variables. No locals.
@@brendanhansknecht4650 well guess im not going to try uiua then lol
@@GanerRL it actually is a pretty nice language. Having a stack makes locals less necessary. Though it is a weird constraint at times.
@@brendanhansknecht4650is that delibrate, or is the language less developed?
what would the code look like if values were not restricted to integers >= 0 (e.g (-0.3) being recognized as valid entry)? and - from your experience - how hard is it to read the code you've written, say, 3 months ago? curious how practical these languages are.
just replace "min 1" by "≠0"
As someone who has only done coding/scripting with languages whose characters are within the ascii standard, this scares me
3:48 - "I think it's actually more readable"
Yeah, sure. Because we're really concerned about readability here.
Reminds me of IconForth that let you draw your own glyphs for definitions.
I love these videos but I'm so confused. Where would I learn about all these combinators and 2,3-trains and whatnot?
My favorite thing about Uiua is the transpose function. :)
Can you make a video of your project regarding making your own glyphs/array language?
Glad to see that I'm not the only one who has been bitten by the Uiua bug :D
Next time I need a script for a fantasy language, I come to you.
Did this video make it through the 4th dimension. Dude is clearly from a parallel universe. How many fingers do you people have
this language is awesome!!!
Bro codes in hieroglyphics
This is really cool, but I spent the first five minutes trying to figure out if it was an elaborate shitpost
Are there any useful reasons to learn languages like that or is it just for fun?
thanks for showing a use case for Uiua. I have installed both cBQN and Uiua but don't know where to get the PADs??
Bqnpad and Uiuapad are both just websites
can't it be solved in, let's say APL by:
{(×omega)match(=∨(1+tallyomega)=+)/each(⍳⍴ omega}
so... checking for each index whether it's either equal in coordinates or they sum to tally+1 (or tally if you use base 0) and then compare it to the sign of the input? Just an idea.
I'd love to see the possible practical applications os Uiua. I don't know what it's good for other than cool little puzzles like this. I'm sure it's designed for something I'm just ignorant
Is it fast enough to do serious numerical work? Can I create long running programs with it? Can I do interesting io with it? Can I write some boring app with it looks a to-do list or something?
I'm not sure about this language, but APL is a `decent` language for doing numerical calculations, it's basically a very powerful linear algebra library, you tensors, matrices and almost everything you might need to work with high and low density matrices and big vectors. That's what the language was designed for, I guess. The problem is that no one is writing anything for it, so making something actually practical will take a lot of effort. I would not use an array language like APL for IO heavy tasks, like heavy reading to data bases or manipulating a bunch of files. It was really not designed for that.
@@user-uf4rx5ih3v long running numerical programs usually run on multiple cores in parallel. I don't think APL or BQN Uiua run in parallel. I'm yet to check my gnu apl in parallel. Also would be great if any could be compiled to stand-alone executables. I know of only Futhark that compiles. Don't know if Dyalog has a compiler or can use GPUs to accelerate.
Uiua creator here.
Most of the array operations are pretty optimized. For things like doing math on arrays, reducing, scanning, etc, it should have near-C performance, at least for large arrays, as that stuff all happens in tight optimized loops.
Believe it or not, I intend it to eventually be pretty general purpose.
For example, in the repository, there is an example of a simple multithreaded http server that is good enough to serve the website.
The language natively supports image and audio encoding/decoding.
There are some system APIs I haven't added hooks into yet, but they're on the todo.
@@kaikalii You did amazing work with Uiua! I already want to play around with bindings or somehow using it to connect to a postgres database. It would be an amazing tool for exploring and analyzing data from a db.
kdb+/q is an apl descendant with a decent install base managing huge databases (mostly in the finace sector)
Are these symbols only native to his programming languages or are any other language using them? Where can we learn more about the meaning of these symbols? Is OP maybe an Alien from the Storm Area 51 Facebook Raid?
⍝ Many of the symbols are standard mathematical notation, like +×÷ (arithmetic), =≠
not sure if this has been commented yet but your solution breaks on negative numbers, you should've taken the absolute value before 1min-ing it
Thus literally looks like something that would display on an alien computer in a video game
I like to play with array languages from time to time but I have no idea how someone can use them for solving real life problems
same, without readable keywords like ordinary languages they seem like toys to me. I don't understand the purpose of using only special glyphs
Real problems? 99% of you are sending json requests and have nearly no actual code
@@lexacutablewhat? I'm not even advocating for concatenative languages but this is actually painful to read. You realize that you learn what the symbols mean over time right? You know that's like how every field of math works right? The use symbols, not words... Are you pretending that giving them names even changes anything because you'll still have to use them to really understand them anyway
"Table", famously pre-existing as "The square window" on Playschool. :)
5:55 "the explicit one" :))) both look like a Unicode render error, at least the dot one has a glimmer of a comprehensible structure
This is so beautiful.
I really want a version of this for tree and graph structures.
I feel like these languages are really distilling the patterns of transformation into some sort of cannonical system. Really feels like a waste to do it any other way.
In the ultra long term, i think this way of coding will be the only way to tame the ballooning complexity of all the code we write.
Yes it's kinda hard to learn at first, but if one doesn't learn these patterns, you are just doomed to write incorrect or idiosyncratic versions of the same thing anyway...
I'd like to see a such a mainstream version too. But as longs as our vocabulary reserves short words for bum and butt and lets generic patterns be called x combinators, I don't think it's gonna work.
They need to be made easy to say, type and understand, their association with math symbols isn't helping either.
I've made a basic directed unweighted graph, represented by adjacency list in Uiua.
I can add Edges, check if an edge exists and remove an edge.
And I'm having lots of fun coding in Uiua! But yeah, it will never be a "professional" language.
@@Thwy is your code open source? I've been working with graphs a lot lately, and I'm very curious to check it out.
@@usopenplayer Uiua links are too long for UA-cam, but I can give you part of the code here:
# Args: num_of_vertices
newG ← |1 {⍥[]}
# Args: vertex graph
adj ← |2 !⊡
# Args: origin destination graph
isAdj ← |3 /↥∊ adj ⇵[0 2 1]
# Args: origin destination graph
addE ← (|3
□⊂adj ⇵[0 2 1 0 2 0] # Appends destination to adjlist
↻¯∶⊂∶↘️1↻↷ # Replaces the old adjlist with the new one
)
# Deduplicate edges from a graph
cls ← |1 ∵⍜!⊝
g ← newG 4
g ← cls addE 0 3_1_3 addE 3 0_2_3 g
g
@@blacklistnr1 As a mathematician, it honestly really helps me know what the symbols are if they are maths symbols
Stack-based is an interesting idea, but I'm concerned about the performance ceiling. Everywhere I've looked, it seems that the less the formalism involves itself in _how_ it gets computed, the faster and more efficient it can ultimately be made. Granted, this matters less if the operations themselves are bulky (as they tend to be in the typical domains of array languages), but not all workloads are like that.
On the other hand, any formalism even _thinking_ about computational efficiency is plenty performant enough. Mr BQN himself says so.
I thought this was an April Fool's joke until I looked up these languages
So readable
7:03 > _"without ever needing parenthesis"_
that's one of several *_key_* benefits of post/prefix languages, so...
What are array languages good for? As in, no one is going to use them in production or in a big personal project, right? I'm a Software Engineer, and I just don't understand the appeal.
"because this is more readable"
At first I thought this video is a joke. But it appeared to be fckn awesome
when did you find out these are your favorite languages?
I watch these videos not because I love array languages or even remotely understand them...but because it makes me feel as lost as I did when I was first learning programming...or as lost as a non-programmer does when looking at "regular" imperative code...and all the stuff you say about combinators...might as well be talking about polymorphism or generics to my grandma lol.
This is like regex but way more mind-melting
Where can u get the keyboard to type the codes, i really need one!
BQN can use key combos and uiua can use the words as commands.
Wow that just looks like nonsense to me, never touched array languages. Assembly looks easy compared to this... any recomendation on how to start with those languages?
APL has been around a long time, but a bit of a pain to set up. Dunno about the newer ones, wasn’t aware they existed until I saw this video
Uiua has learning material
How do you write all these characters?
Is uiua pure fp? How does it deal with shared state?
At first I thought those languages are ridiculous, but then I remembered how many special characters RegExp has and that's something I actually use at work all the time.
at least you can type regex with relative ease
my man over here is typing in extended unicode
i didn't knew ancient Egyptians were developers
You could also use the shape directly rather than just one side length. I.e. instead of =⌜˜↕≠ you can use =´¨↕≢
Downside: It would no longer error out for rectangular matrices, but check diagonals from the top corners.
@4:57 But if at least one of the b combinators evaluates into a unary expression, you can get undefined behavior and random results as output. Better be safe and use parentheses. These my 2 cents!
Speaking of which, that's a nice thing about uiua - no overloading of binary vs. unary expressions, any given symbol takes a *fixed* number of arguments. No need to parse a whole expression to figure out what's dyadic or monadic!
after watching this it makes sense people call these "write-only languages" lol
thats me 2 years ago learning nutrition
cyanocoboalamine methylcobalamine adrenosolcobalamine hydroxocobalamine tho thefore animal corpse
Okay, but why can't they use symbols actually found on keyboards?
I love how syntax slowly got further and further from machine language and became closer and closer to human language, but now we are at the point where it overshot the sweet spot and starts getting unreadable again
I don't want to become one of those grandpas that resist change and innovation, but damn... I like my cosy python and cpp
don't expect me to start writing code like a fucking alien
Doesn't this only work for positive numbers?
Yeah but why is the twitter x logo part of the code?
because the twitter X logo is literally just a character that already existed in Unicode, and 𝕨 and 𝕩 are at least less obscure than the α and ω that APL used.
Because it's a stupidly unoriginal copy of an overused symbol. The most common x is for some arbitrary variable, in BQN the one on the right. The X window system (as in Xorg) also has a similar logo.
There are only two reasons to rename Twitter like that: 1) to destroy the brand, and 2) to brag that he bought a single letter second level domain. Both are in poor taste.
Well, I am confused. This is...
I don't even know what this is. Is it beautiful? Maybe, is it readable? Most certainly not.
Do I like it? Yes... I want to use it but I can think of literally no use-case.
Thanks for the video!
idk about bqn. I don't want elon musk coming after me for using his companies logo in my code
I dont know. The : operator seems to make readability of this hard. I am curious how this language tackles reading code, as one thing that i know tires me out relentlessly is a constantly changing reading direction.
What about the colon makes it harder to read than any of the other symbols?
@@kilianvounckx9904 it flips the order. So to know what the first glyphs operate on you now need to parse all the way to the back of the function to figure out what it's doing
I dont think the colon is the reason for this being hard to read, at least as an outsider to ultra compact programming
Forth and APL had a child!
I've never seen this programming language, what's the point? In what case could this barely readable language be more useful than using any other? How do you write the symbols?
It's readable once you learn what the symbols mean, just like every other language on earth.
It's more useful because every main combinator is predefined with a glyph and you end up writing tacit code. You could do this in any language but most people are never going to be using blackbird or phoenix even though they should. It's mostly a change of thinking
I've never seen sql or stuff similar to it before. These symbols on screen are scaring me 💀
It's time we're going back to cuneiform.
what the f did I stumble upon :D
you can code in chinese?
i have a question: is there any reason to have this as incomprehensible nonstandard lettering instead of written operators
why is the length and range weird symbols instead of ... you know 'length' or 'range'
I think it is for code golfing where the win condition is having the shortest possible piece of code. Otherwise I cant think of a reason apart from it looking like literal magic.
Or even the mathematical operators which exist in Unicode.
My physics textbook and professor usually write "v" instead of "velocity" and "a" instead of "acceleration" when doing math. I figure they do it because the equation takes up less space, and it is still readable because I know what a and v are.
While I've never used one of these wacky array programming languages before, maybe people like them for the same reason. These little symbols allow you to fit the whole program in the center of your vision! Maybe that helps readability?
On the other hand, the C or Java implementation of this might take up the whole screen. (No offense to C or Java programmers!)
The entire point and history of concatenative languages is to give combinators symbols
@@ahdog8no it's because the same way you use `+` instead of `addition` in arithmetic, you treat combinators the same way. I think it's taken too far but the idea makes perfect sense. And they end up using combinators you guys will never bother using even though you should, like blackbird and phoenix
What kind of programming languages are these?
Array programming languages! Descendants of APL, one of the first programming languages from the 1960s. en.wikipedia.org/wiki/APL_(programming_language)
Concatenative
I still dont see the benefit of all of these sigils except for unneeded tersness.
You can always make a longer verbosee thing more terse by definijng a function ( or word in forth ).
This is a joke right? Everyone is playing along, right? Right?
no way they got the X logo
This is what happens when you go beyond Haskell
Why is it spicy
good God, lets go!
Looks readable like hell
I'm asking my self "WTF"
wouldn't it be easier to just multiply the identity x-matrix with the input matrix and compare the result to the original?
All the 0s should zero out all the values in their corresponding cells, which means the two matrices will be the same if the 0s are located in the correct places, and wrong otherwise
That does not check that the diagonals are nonzero
@@qanon4realvsqanon4gery70.... yeah I forgot about that detail
but why
1:11 ironic
love this language - not very good at array languages and already this one is coming so easy to me!
to help people test their check functions: heres how to generate 10 by 10 X matrices with random integers between 1 and 500 inclusive along the diagonal
* maxrev.table=.rangelength. reshapereshape2:+1floor* unroll [repeat(random)power 2]. 10 500
Can these languages handle sets and multisets? I have a mathematical background and realised that for recursively finite sets (finite sets, with finite sets as elements etc.) the axiom of extension together with the well-foundedness axiom imply that equality is algorithmic; (provided equality for "atoms" is algorithmic, but in set theory we just have the null set as an atom) and I was thinking of finding an algorithm that inputs a pair (for now) of recursively finite, well-founded lists, (all lists have lists as elements, the empty list is allowed as an "atom"), and outputs whether they're equal or not, and also reorders them in such a way that repetitions are placed adjacently (all the way to the level of elements, the elements of elements etc.) and if one list's underlying set is a subset of the other this should be reflected in the reordering (one would be an initial fragment of the other, up to the existence of repetitions). So that a different algorithm could then take over and erase repetitions, if we're interested in sets and not multisets. I think a nested "for" loop can do it in pseudocode but maybe these languages can do it more elegantly. (Or maybe LOGO that calls a function inside the function itself can do it.🤪)
I don't think taking non-repetitive arrays modulo the Symmetric Group is a good idea, that thing's size is n! for n the size of the list.
I'm sorry to ask, and don't want to sound mean or anything. But... who the heck uses this kind of esoteric language in the real world (and industry), with real problems ??
just out of curiosity I searched online job reqs for a single one that mentioned BQN or Uiua at literally any point. In total I found 4 "BQN" jobs when I went to Indeed - BQN, the airport.
@@Catamount1412 older, more professional array languages like APL, J, and K *do* get used, but mostly in obscure financial-industry stuff and sometimes in scientific computing. BQN and Uiua are both new and as far as I can tell mostly for fun.
@@Nerdule I knew an engineer that loved APL, if not as anything he expected to use professionally, and while I don't personally see the appeal, at least I can sort of see what APL is going for and the use cases for it, and even knowing next to nothing about array languages, it at least looks like real, purposeful code and can be readily interpreted with little prior knowledge and minimal referencing.
BQN and UIUA just strike me as *too* abstract and esoteric.