APL vs BQN vs J vs Q vs NumPy vs Julia vs R

  Рет қаралды 30,019

code_report

code_report

Күн бұрын

Пікірлер: 112
@AmexL
@AmexL Жыл бұрын
I gave you a like just for your intro; so many people just list all that stuff but man putting a timeline and visuals to it really painted a clear picture of your experience and journey. Kudos.
@tylerbloom4830
@tylerbloom4830 2 жыл бұрын
As someone who has moved from C++ and traditional Python to Rust, I've really grown to appreciate the expressiveness of non-imperative styles of programming. Learning about array-style and algorithm-centric programming has greatly improved my ability to reason about certain problems. My initial solution for this problem used just chained iterators. Six months ago, I would have written that nested for loop solution. Fantastic talk!
@vectoralphaSec
@vectoralphaSec 2 жыл бұрын
What's easier to write software in? C++, Python or Rust?
@tylerbloom4830
@tylerbloom4830 2 жыл бұрын
@@vectoralphaSec for all but the shortest programs/scripts, Rust is the easiest and best language I have used by almost every measure. I will sound hyperbolic, but learning Rust was world-changing for me.
@multivitamin7
@multivitamin7 2 жыл бұрын
@@vectoralphaSecdepends on what you want to write, but python is undoubtably the easiest of the three you mentioned
@sirajmussafirr147
@sirajmussafirr147 Жыл бұрын
@@multivitamin7also the shittiest😂
@multivitamin7
@multivitamin7 Жыл бұрын
@@sirajmussafirr147 Again. Entirely depends on what you're wanting to write. Not everything calls for what Rust and C++ provide. There are definitely instances where Python is the better tool for the job than C++ and Rust. Stop with the elitist nonsense.
@dadir_alvarez9748
@dadir_alvarez9748 2 жыл бұрын
More videos using Julia please! Great content :)
@spacelem
@spacelem 2 жыл бұрын
Seconded! I've done a couple of projects in Julia, but I'm never entirely sure I'm using it to its full potential.
@keesjalink
@keesjalink Жыл бұрын
absolutely brilliant talk. I learned APL fluently 40 years ago and then saw it perish, being replaced by languages with 5% of the functionality, always wondering why nobody gave a damn....
@bzboii
@bzboii 2 жыл бұрын
Even better the second time :) Can't wait for a combinators video and would love to see more content about (all the different) polymorphisms
@owieccyt
@owieccyt 2 жыл бұрын
In Julia size() will return a tuple with sizes of all dimensions.
@TankorSmash
@TankorSmash Жыл бұрын
I appreciated the line of code in the languages, and it was some smart highlighting of the similarities. Thanks for putting this together!
@abangfarhan1
@abangfarhan1 2 жыл бұрын
In Numpy at 28:38 you can also do outer product just like in Julia at 33:10 by first transposing the array: i[:,None] == i This is generic, I think, which means you can run arbitrary functions like foo(i[:,None], i)
@saltrocklamp199
@saltrocklamp199 2 жыл бұрын
It's not really a transpose, but yes this is a seriously powerful tool in Numpy. It's supported by any ufunc, and you can construct arbitrarily complicated outer products: f(x[None,None,:], y [None,:,None], z[:,None,None])
@MilesMcBain
@MilesMcBain Жыл бұрын
For R you can take advantage of coercion to logical matrices. Examples: check_matrix
@YoshikoJanai
@YoshikoJanai 2 жыл бұрын
MATLAB being an array language makes a lot of sense looking back towards my time in college. None of the classes would preface it with that, so in my (thankfully) limited interactions with it I’d simply approach it wrong. Like it was some kind of imperative language.
@lukepikaart8323
@lukepikaart8323 Жыл бұрын
Yeah it's pretty important to know that because it's very slow if you don't vectorize. That's why I love Julia because you can write whatever style you want and It works well across the board
@yash1152
@yash1152 Жыл бұрын
12:34 this is soooo super awesome talk i am soo liking this coecept of dimain specific languages
@Haskell-Curry
@Haskell-Curry 2 жыл бұрын
12:21 Maybe you should use fmap (functor map): fmap (min 1) x
@0LoneTech
@0LoneTech Жыл бұрын
Sure, but then he'll also want to use an array rather than a list of lists.
@DylanMatthewTurner
@DylanMatthewTurner 2 жыл бұрын
So, I recently made a cli calculator program, something small I can use and not get unfocused like I do w/ a GUI calc or something. I think I went overboard though. I implemented lists and functions, so I could handle a bit more complexity when necessary, but now, after watching this video, it's got me thinking. I may have unintentionally implemented tabling and rank polymorphism with how I handled operations between variables. So, I may have accidentally created a tiny array programming language while making a calculator.
@lunalect
@lunalect 2 жыл бұрын
Just curious, were you against just using a language that came with a REPL, which is essentially a fancy CLI calculator?
@DylanMatthewTurner
@DylanMatthewTurner 2 жыл бұрын
@@lunalect Yeah Basically, the idea is that I don't usually need a calculator for the things I do, so I don't have something open. Anything other than just immediately typing an expression including opening a GUI app, starting up a REPL, using weird syntax, etc takes me out of my groove. I wanted it to just be something like open terminal, type "c 2+2", and then get back to work. Basically I wanted a calculator sitting on my desk ready to go without having to have a calculator sitting on my desk. It's a very specific set of restrictions, but it's what I needed. I did still allow it to be used in a REPL (bc why not?), but it doesn't have to be
@drewsclues8625
@drewsclues8625 Жыл бұрын
I think you reinvented `bc`
@DylanMatthewTurner
@DylanMatthewTurner Жыл бұрын
Wow that may be exactly what I need! Thanks! I don't think it can do complex numbers by default, but I don't have to use them very often anyway. There's a GNU bc, and it's got a POSIX standard. Why the heck is it not in the coreutils???
@0LoneTech
@0LoneTech 16 күн бұрын
For scripting, I like dc (or in language things like $(()) in bash). coreutils has expr. And otherwise I quite like qalc (the cli interface for Qalculate!), which does some fairly advanced math but in particular handles units and intervals. Many to choose from.
@yash1152
@yash1152 Жыл бұрын
5:35 , 5:45 | 6:29 , 7:16 | 16:46 this combinator logic is superrr awesome. similar happens sufficient times in normal non-array situations as well, where i am checking a thing for aome condition and then using that again in the body... and yeah, its super irritating there as well
@DeAdBiGeYeFiSh
@DeAdBiGeYeFiSh Жыл бұрын
why not compare the solutions in terms of performance and memory usage?
@cusaint3596
@cusaint3596 2 жыл бұрын
Thank you very much for your videos. It would be great to see videos showing how to use APL in simpler actions such as sorting of texts and other basic operations (an APL tutorial and tutorials on other similar programming languages). It will be great to hear your opinion about which programming language to learn out of these choices: APL, BQN, J, Q, Kx, Julia, R, and other similar ones. Why so? because J and some others apparently improve on some things that people do not like about APL such as the weird symbols and because maybe array programming languages are apparently mainly used for arrays/matrices and alike. What do you think of the Pure programming language and how it compares do the others I mentioned?. Which free array programming languages you recommend to learn and are they also recommended for regular programming work (not mainly for matrices and alike)?
@yash1152
@yash1152 Жыл бұрын
20:50 > _"now rhat would u expect"_ based on the name "leading axis th" & teachings of linear algebra; i would guess that being smaller cardinality, the leading axis here would be column 21:10 i was right :D
@AndrewTSq
@AndrewTSq 2 жыл бұрын
Imagine getting 200k lines of BQN code that they tell you to find a bug in.
@completemadlad15
@completemadlad15 Жыл бұрын
Finding a bug in 200k lines of any language is not a simple TASK also BQN will save you from those many lines
@dlinnoedlinnoe
@dlinnoedlinnoe Жыл бұрын
This must be exactly the same as asking you to find a bug in equivalent 5M lines of Python or 20M lines of Java.
@yash1152
@yash1152 Жыл бұрын
these are the kind of ppl who say "imagine writing string parser in SQL"
@AndrewTSq
@AndrewTSq Жыл бұрын
hipsters of code
@nunzioturtulici9636
@nunzioturtulici9636 10 ай бұрын
.2M lines of BQN is an OS.
@arwynroberts9038
@arwynroberts9038 2 жыл бұрын
Great talk, Conor! BTW APL solution also works if you move the fork after the selfie and should be faster. Then change max to min for clarity.
@osmanhussein4323
@osmanhussein4323 Жыл бұрын
Please more J stuff, especially at the intermediate level even beginner level. Please. Loved this.
@yash1152
@yash1152 Жыл бұрын
26:32 awesome venn diagram of languages based on: array, iversonian, combinator, functional;;
@brettknoss486
@brettknoss486 Жыл бұрын
Julia can be written checkmatrix(grid) =min. (grid, 1)==max.(1:size(grid,1).==1:size(grid,1)|>transpose, reverse(1:size(grid,1)|>transpose, dims=1))
@NickWindham
@NickWindham 2 жыл бұрын
More videos on Julia please! Tutorial videos from beginner to advanced and implementation of problem solving or projects
@arisweedler4703
@arisweedler4703 2 жыл бұрын
Looking forward to the video on combinators. I understand the concept, but I just don’t know them all. And I certainly don’t remember their bird/letter names. When there’s a visualization for the combinator, I find it really easy to remember what they do
@arisweedler4703
@arisweedler4703 2 жыл бұрын
Maybe I should try to write a web app that takes a chain of combinators and arguments and creates a graph (or DAG). I could just output in graphviz format, like what CMake does for your dependency tree I don’t know how to do this part, but it would be cool to have a keyboard like Dyalog has for all the symbols - but the symbols are all the combinators. And then this is even more ambitious but if you could toggle the languages, and have your combinators symbol change (which by default I would represent with their single letter form). Could support letter form, bird image form, APL, BQN, etc. ofc some of the languages won’t work for a given piece of code because of nonexistent combinators. But if the system could replace the non-existent combinators with phrases that create said combinators… that would work
@RajeshPandianM
@RajeshPandianM 2 жыл бұрын
Nice talk, Conor🤩. Sad to see cpp solution being more vebose 😪. I am CUDA/C++ programmer. Are the elements in the diagonals are assumed to positive? If those were negative the final min will not yield 1s along the diagonals. Could you please clarify whether my understand is right?
@Titousensei
@Titousensei 2 жыл бұрын
For languages that don't have combinators built-in, couldn't your create functions that do that? Like this: `def forkCombinator(unary_fn1, unary_fn, binary_fn): ...`
@tubesteaknyouri
@tubesteaknyouri Жыл бұрын
FYI, the function does not work with negative elements: using LinearAlgebra function check_matrix(grid) i = size(grid, 1) |> I |> Matrix return min.(grid, 1) == max.(i, reverse(i, dims=1)) end x = [1 0 0 2; 0 2 -3 0; 0 5 5 0 ; 10 0 0 -2] check_matrix(x) # returns false
@0LoneTech
@0LoneTech 4 ай бұрын
Correct. That can be fixed using 0≠ or |× (absolute of sign) instead of 1⌊.
@yash1152
@yash1152 Жыл бұрын
7:44 what if there are negative elements?
@elnico5623
@elnico5623 7 ай бұрын
His solution is incomplete
@mully006
@mully006 11 ай бұрын
From an intermediates perspective I would say that the readability of the Julia, R, NumPy and C++ implementations are much much better than the combinatorics format. Additionally, while the code has been reduced to one line, what is happening behind the scenes, what intermediates are being created by the compiler? This is why I prefer the C++ implementation, it is much clearer what the code is doing and what additional variables are being created. Additionally with the C++ solution you can eliminate the branching statements and allow for SIMD optimizations.
@0LoneTech
@0LoneTech 16 күн бұрын
Meanwhile, BQN uses SIMD by default, and automatically selects storage types to fit the data. Which branching statements, by the way?
@yash1152
@yash1152 Жыл бұрын
5:22 .= that seems like the fxn broadcast from julia (:
@gnuvince
@gnuvince 5 ай бұрын
My k6 solution: checkmatrix: { xmat:a||a:=#x; xmat~~0=x } k6 has =i, a monadic verb for creating an identity matrix, which makes the solution quite short and easy.
@piratepartyftw
@piratepartyftw 2 жыл бұрын
looking forward to the combinatory logic video! :)
@enisefe8506
@enisefe8506 Жыл бұрын
Nice solution. Here is the tacit form of J solution: (1&.|.)&=/~&i.&#) However, the question does not state that the numbers that are in the array are larger than zero. (0&~:-:(>.|.)&=/~&i.&#) // Replaced 1&.|.)&=/~&i.&#)
@tricky778
@tricky778 2 жыл бұрын
That's not the equivalent in Haskell for the element-wise scalar minimum! First off you've got a list of lists and not a matrix, a matrix would have a functor instance that you can use directly. Secondly, a linear algebra library like you have installed with your array languages would have an Object type that can be a scalar or a matrix and that would have an PartialOrd instance so that '1 `pmin` mymat' would work just fine. You might say that you get free conversion in those array languages for when you try to use functions from elsewhere but you shouldn't and if you really want it you can cheaply, with flexible instances, define a class with all your array operations for all sorts of mismatched types as well as matched types or you can use typereflection and type families and all sorts.
@arisweedler4703
@arisweedler4703 2 жыл бұрын
Do you have to write code to allow each pair of types to interface? Does a rank N matrix act like a rank M matrix? Can I use the same code to apply a scalar to either one of them. A list of lists is inherently rank 2. The strictly typed divide between those types seems needless, in comparison to the array languages. Of course, this is a very Array-Language oriented perspective :)
@tricky778
@tricky778 2 жыл бұрын
@@arisweedler4703 yes, yes, and yes up to polymorphism. It is possible for someone to write an interface that offers what the array languages offer then you need only download that just as you download your array language but we already learned that it goes wrong and obstructs one a lot so we can ask of the array languages, does it save me when everything is the same as everything else?
@arisweedler4703
@arisweedler4703 2 жыл бұрын
@@tricky778 > but we already learned that it goes wrong and obstructs one a lot > does it save me when everything is the same as everything else? sorry, I'm just not following you. what's going wrong? Your point was that if you have the right Haskell libraries, then Haskell is as expressive and easy to rank polymorphize as APL. Right? > download that just as you download your array language This is uncharitable. None of these are exactly the same: Base language, standard library, popular 3rd party library, existing but not common library, possible-to-write-but-not-written-yet library.
@nanthilrodriguez
@nanthilrodriguez 2 жыл бұрын
Incorrect. Array languages don't have "linear algebra libraries". These functions he's using are primitives, as in native to the language notation, and not special libraries. It supports linear algebra out of the box because it is an array notation.
@tricky778
@tricky778 2 жыл бұрын
@@nanthilrodriguez why is that fact important?
@VivBrodock
@VivBrodock 9 ай бұрын
numPy is usable by Julia, feels a bit weird to include it as it's own thing
@drj-pp8hw
@drj-pp8hw 2 жыл бұрын
Please include R in more of your videos!! 🤓🤓🤓🤓
@yash1152
@yash1152 Жыл бұрын
33:16 , 33:28 transposing a vector increases rank in julia is broken interesting.
@spacelem
@spacelem Жыл бұрын
When I first saw the behaviour I was surprised, but now I'm quite happy with it. Transposing really just permutes dimensions 1 and 2, and it only works when dim
@vegetableball
@vegetableball Жыл бұрын
It is obviously a linear algebra oriented decision. If a person does not have exposure in higher level linear algebra, he may not aware of the generalization, thus thinking it is broken or surprised...
@kgbman7
@kgbman7 2 жыл бұрын
I know Dyalog APL has user defined operators, do any of these other languages have support for them?
@nanthilrodriguez
@nanthilrodriguez 2 жыл бұрын
Yes, you can define all kinds of operators in BQN and J.
@batlin
@batlin 2 жыл бұрын
29:45 for impure languages it's probably difficult to decide when it's safe to memoise the result of a call and avoid calling the same function twice with the same arguments. Referential transparency and all that.
@markoh9974
@markoh9974 Жыл бұрын
Hey bud, you should think about getting a pop filter for that mic...
@c4tubo
@c4tubo 2 жыл бұрын
Superb! More like this. And what is the justification for using Q? It is a proprietary language owned by KX and it looks pretty ugly to me.
@code_report
@code_report 2 жыл бұрын
Q (and KDB+, the database that comes with it) is widely used in the finance industry. If you look at github.com/interregna/arraylanguage-companies, you will notice there are 25 companies you Q/K which is more than the 21 using APL. I know it is not an exhaustive list, but Q/KDB+ might be the most widely used array language in the world. Therefore worth studying IMO.
@pmccarthy001
@pmccarthy001 2 жыл бұрын
I'm new to all this... Can you download BQN to your computer like with J and Dyalog APL?
@code_report
@code_report 2 жыл бұрын
I prefer BQNPAD but you can definitely download it. There is a useful page on all the ways to run BQN here: mlochbaum.github.io/BQN/running.html
@salman-11924
@salman-11924 2 жыл бұрын
Would've loved to see MATLAB compared with them
@badmanjones179
@badmanjones179 2 жыл бұрын
19:40 what's up with the empty node?
@code_report
@code_report 2 жыл бұрын
There is no combinator in BQN that corresponds to that combinator
@badmanjones179
@badmanjones179 2 жыл бұрын
@@code_report ohh lol i was expecting you to say something about the absence in the video, i was like, trying to work it out lol. Great, thank you
@yarrowification
@yarrowification 2 жыл бұрын
I'm more excited for composition intuition than I have ever been for any movie
@andyl.5998
@andyl.5998 Жыл бұрын
Wonder how's the Composition Intuition video coming along. 👀
@adicide9070
@adicide9070 11 ай бұрын
dude you gotta include ocaml in these :)
@bubis
@bubis 2 жыл бұрын
A Q solution without any temporaries: {(0x)~{x=/:x}{x&reverse x}til count x}
@nanthilrodriguez
@nanthilrodriguez 2 жыл бұрын
why not k? {(0x)~{x=/:x}{x&|x}@!# x}
@bubis
@bubis 2 жыл бұрын
@@nanthilrodriguez Because it requres no skill to rewrite it in k4 but most ppl wouldn't understand. :)
@mlliarm
@mlliarm 2 жыл бұрын
Great talk, as always. One observation. I see the reverse columns glyph as a horizontal mirror. The result has mirror symmetry if you imagine putting a horizontal line below/above the matrix acted on. Similarly the reverse rows looks like a vertical mirror. The reversed rows have a vertical mirror symmetry to the matrix you get when this operation is acted on. At least this is how I remember which is which. ps: besides the APL, J, BQN solutions I really like Julia's. Eat that, Python!
@yash1152
@yash1152 Жыл бұрын
15:05 reduce, scan, outer product and guido rossem said rather than reduce, u r better off of writing as for loop lol
@NickWindham
@NickWindham 2 жыл бұрын
Cool video
@dlinnoedlinnoe
@dlinnoedlinnoe Жыл бұрын
Fork in APL but hook in J :) Of course it could be a fork in J too, just one char longer. And I guess, even more "J-ish" way would be to use a tacit definition like check_matrix =. 1&.|.)[:=/~ i.&#
@fewaawef8013
@fewaawef8013 2 жыл бұрын
Julia is based, and ur based for showing it
@sarqf212
@sarqf212 2 жыл бұрын
@code_report what did you use to create the presentation?
@code_report
@code_report 2 жыл бұрын
I have a video coming out in a few days that is a behinds the scenes of how I make my slide decks.
@sarqf212
@sarqf212 2 жыл бұрын
@@code_report that would be very much appreciated!
@xmahler
@xmahler 2 жыл бұрын
def is_X_matrix(m): return ~ np.any(((I := np.identity(m.shape[0], dtype=bool)) | np.flip(I, 0)) ^ m.astype(bool))
@MartinJaniczek
@MartinJaniczek 2 жыл бұрын
Around 8:24 - I wonder whether × could have been used instead of 1⌊. Does it break down for some inputs?
@nanthilrodriguez
@nanthilrodriguez 2 жыл бұрын
0 = 1 × 0 If you multiply the 2 matrices together, of course the diagonals will be equal, but if the diagonal contains a 0... then it will match in the multiplied matrix. But the rule stipulates that there can be no 0's in the diagonals.
@0LoneTech
@0LoneTech 4 ай бұрын
I think this was specifically regarding the clamping function, and using BQN monadic ×, which is sign. It wouldn't break more than it was, and adding absolute (|×) would make it work for negative inputs. 0⊸≠ does the same then.
@itay1232
@itay1232 2 жыл бұрын
Great video! Though one thing that bothered me was that that 1⌊ should really have been a 0≠
@itay1232
@itay1232 2 жыл бұрын
both for readability reasons and because 1⌊ is plain wrong if your matrix has numbers less than 1 that aren't 0 (like 0.5 or -1)
Functional vs Array Programming
30:40
code_report
Рет қаралды 134 М.
APL vs BQN vs Uiua
18:09
code_report
Рет қаралды 8 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Mini PC Madness! - Minisforum UM890 Pro
13:08
Craft Computing
Рет қаралды 12 М.
Python vs Julia
7:10
IBM Technology
Рет қаралды 136 М.
P99 CONF - Zig vs Rust
55:01
ThePrimeTime
Рет қаралды 85 М.
Python vs Uiua vs BQN
15:47
code_report
Рет қаралды 15 М.
I regret doing this... (Tsoding Q&A Stream)
1:20:07
Tsoding Daily
Рет қаралды 90 М.
Stop using std::vector wrong
23:14
The Cherno
Рет қаралды 164 М.
I ❤️ APL & BQN
11:11
code_report
Рет қаралды 19 М.
This is perhaps the greatest feature of modern programming languages.
5:56
The Uiua Programming Language Caught Me By Surprise
12:24
Code to the Moon
Рет қаралды 52 М.
The Return of Procedural Programming - Richard Feldman
52:53
ChariotSolutions
Рет қаралды 61 М.
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН