Dude I'm high as f watching random cs videos and I see we returned to hieroglyphs wtffffffff
@vaap Жыл бұрын
I love this so much
@willmcpherson2 Жыл бұрын
bro 💀
@swyveu Жыл бұрын
420 likes .... coincidence?
@arshamshayan Жыл бұрын
my exact reaction when I saw APL for the first time 😭
@anerdsmeltybrain26 күн бұрын
I'm high right now
@yeicore3 жыл бұрын
APL is how coding looks like for non-coders
@everyhandletaken2 жыл бұрын
Looks like emojilang & mindf$ck had a baby & they named it APL. 🤯
@NStripleseven2 жыл бұрын
Most coding languages look like gibberish to non-coders, APL looks like gibberish to everybody. Equality.
@everyhandletaken2 жыл бұрын
@@NStripleseven lol I like that analogy!
@torarinvik4920 Жыл бұрын
This comment is epic, it's so accurate!
@viridianite Жыл бұрын
So are you saying APL programmers are above coders? lol
@telnobynoyator_61833 жыл бұрын
what programming looks like to non programmers
@yardez59903 жыл бұрын
APL looks like minecraft enchanting table language
@saidkorseir1923 жыл бұрын
I am .net developer for 6+ years. I didn't understand anything not a jot.
@TRVQ22 жыл бұрын
@@saidkorseir192 Then just start from Python first ;)
@espana862 жыл бұрын
Doesn't APL look very similar to just Greek?
@skratky3 жыл бұрын
Great talk. For reference, this is how you could solve the problem in the Wolfram Language: (nums - FoldList[Min, nums]) // DeleteCases[0] // Prepend[-1] // Max
@telnobynoyator_61833 жыл бұрын
Readable AND short ? Looks like a great language to me !
@biskitpagla2 жыл бұрын
my normie ass automatically assumed everything after // to be comments, spent a solid 10 secs thinking about where the rest of the logic was
@locallyringedspace31903 ай бұрын
Nice one! You can significanlty cut down on character count in WL for this problem using replace repeated to get rid of those pesky zeros: a - FoldList[Min, a] //. 0 -> -1 // Max I also took a stab at a short MATLAB version with a different approach: -min(min(tril(a-a'))) This is pretty terse but I can't find a clever way to make it return -1 instead of 0 for decreasing lists (yet!)
@guilhermegigeck59463 жыл бұрын
Honestly, from the video you made me prefer Haskell over APL. It really doesn't matter if the code is shorter if you need someone specialized on the language to make sense of it, while on Haskell after you explained the S operator and that was all I needed to get a rough ideia of what the code was doing.
@hongnken2 жыл бұрын
I totally agree. Haskell nails both readability and simplicity
@batlin2 жыл бұрын
Many would take that further and justify Scala over Haskell, then Java over Scala, then C over Java, then assembly over C. The question is whether the value you get is worth it in exchange for initial understanding barrier. Personally I'm intrigued enough to try APL and BQN out.
@casperes09122 жыл бұрын
@@batlin How on Earth did you get to assembly being more readable than C or Java?
@batlin2 жыл бұрын
@@casperes0912 I didn't. Please read the thread again.
@smurfo42212 жыл бұрын
APL isn't meant to be read, its a write it once and then recreate it if you need to change it later kind of thing. This is at least what everyone i've been learning from has said. This might seem stupid, but the language is meant to be easily written out so you can focus on the thing that needs to be done instead of how to do it.
@15shekels3 жыл бұрын
Me: oh c++ thats pretty verbose but I can somewhat understand it *changes to python* Ah! I really get the idea now, yeah this is fairly intuitive *switches to scalla and haskel* uhhh huh... *digression* im trippin balls dude *switches to APL* WHAT THE F-
@monad_tcp3 жыл бұрын
"WHAT THE F-" F\omega is a programming language too.
@monad_tcp3 жыл бұрын
After APL and Haskell blew your mind. You are read for ...... ..... Forth
@15shekels11 ай бұрын
@@AndreiGeorgescu-j9p dawg I wrote this 2 years ago. Recently dabbled with C / Raylib and can confirm what you say is true
@halneufmille3 жыл бұрын
APL feels like Chinese in that there is a single symbol per concept. The learning curve is steep but it's beautifully rewarding when you get there.
@lane13133 жыл бұрын
I have an APL book called "APL An Interactive Approach" and you can tell it's old because it asks you to plug your computer into a phone line. Such a weird and obscure language but it was pretty fun to mess around with.
@benjaminscherrey11243 жыл бұрын
When introducing the Python solution @ 17:12 , replaces clear easy to read semantically meaningful variable names with short abbreviations while stating "...change the variable names to make them more concise which, in my opinion makes them a lot more readble" - realizing, oh yeah his fav language is APL! ;-) haha Also nice job on the combinators intro!
@johannestafelmaier6163 жыл бұрын
It's 7:12
@voxelfusion98943 жыл бұрын
Yeah I was like, this has to be sarcasm, making fun of unreadable code and mystery names. Later I realized he's simply nuts.
@saltrocklamp1993 жыл бұрын
Yeah, this is a style that I strongly disagree with. Also, the Python algorithm is a linear scan, while the functional version seems like it might end up making 2 passes over the data, unless I misunderstand how Haskell and friends can optimize code. I would have assumed the Haskell version was just the imperative version translated to recursion.
@austininflorida3 жыл бұрын
My least favorite part of programming is figuring out what everyone's abbreviations mean. They are never as obvious to the reader as they are to the writer.
@imadetheuniverse4fun3 жыл бұрын
@@austininflorida Also when they abbreviate words by a single letter to make it just that bit shorter. It's like... why? "low" becomes "lo"... just write "low"!
@anthonycousins8533 жыл бұрын
Thank you so much. This is by far the most accessible intro to combinators and combinatorial logic I've ever seen. I do admit to never making a true effort to seek out understanding of combinators beyond a very quick skim of Wikipedia, but that doesn't change the fact that what little effort I have put in was never rewarded with conceptual clarity. For example, all previous videos I've seen making the claim that they are an easy intro to the topic... well, they failed me. I guess what I'm saying is thank you! So concise and clear and completely useful!
@TimothyJesionowski3 жыл бұрын
I never even knew these existed. I barely understand basic FP tools like map/zip...
@deanroddey28813 жыл бұрын
Personally, I'd take the C++ (or a Rust) implementation. It's more obvious what's going on and all of the intermediate values are easily available for evaluation or logging or whatever during debugging. And it's likely better performing, particularly once you get beyond trivial examples. And of course, you can just put the whole thing in a helper if you need the algorithm more than once, and you never even see the guts unless you need to (at which point it's a lot easier to see the guts.) I'd also argue that extremely minimal syntax isn't really an important goal of software. Creating products for people to use is the real purpose of software. One problem in software (as in many pursuits) is that too many people become more about the pursuit itself than about the purpose of the pursuit. Nothing wrong with that in and of itself, but it can become an issue. I think C++ is suffering from this currently. It's too driven by people who are into languages and not enough people who just want to create products for people to use.
@lorenzrosenthal1193 жыл бұрын
it's all fun and games until you need to reason about side effects and concurrency...
@deanroddey28813 жыл бұрын
@@lorenzrosenthal119 Whether a piece of code has side effects isn't a function of the language it's written in. You can of course write plenty of C++ code that is without side effects, in those areas where it's a benefit, but not have to jump through hoops to deal with mutable shared state, which is something that you often really need. Sometimes everyone needs to agree on the state of the state right now.
@mbartelsm3 жыл бұрын
I agree, when programming we are programming for other people, and that usually means that elegant code is probably not what you want to write. Take the haskell S-combinator, it'd probably be just as readable, if not more, to just define an argument and pass that to the function.
@alpalz3 жыл бұрын
@@deanroddey2881 it sort of is based on language though. Sure I can write c++ with no side effects but there's not many language level constructs to guarantee it. As a mutable / effectful language by default, the burden is put onto the developers to opt into it, which means i don't really trust any c++ code to do what it says haha. When working in a large code base I have to hope they aren't doing anything funky and have to read the implementation of code more than I would like to. When a language supports it from a more basic level I can KNOW when something is a pure function which saves me a lot of effort / time debugging and digging.
@deanroddey28813 жыл бұрын
@@alpalz I would never argue that C++ is SAFE of course. I've spent my life writing a huge amount of C++, so I know that isn't the case. It CAN be safe but it is of course on the writer to do so, and most writers are going to take the easier route in a lot of cases. My own C++ code base, which is 1M+ lines, is as good as it gets, because it was written in as close to optimal conditions as possible. Hardly any serious code base even comes close to enjoying those kinds of circumstances, and that's were C++ gets particularly dangerous. In my case, it's all one writer, and everything is uber-consistent, and nothing was ever hacked into place. In that kind of situation, C++ is awfully nice. And it helps that I don't use the STL, or any other third party code, I have built my own entire world, so it's more like working in C# or Java in a lot of ways, in the sense of being built as a completely unified system from the ground up with a comprehensive runtime library that is all designed to work together.
@atrus38233 жыл бұрын
Great video! Really interesting. A couple of comments: 1. It seems really redundant to use -1 to signify no solution, since, if you read the problem carefully, nums[i] < nums[j]. This means that nums[j] - nums[i] > 0, if a candidate solution. So, if max of all candidates is 0, there is no solution. This would simplify the Scala especially. 2. I understand that Python was just used as an example language for imperative programming, but it could come off that you were comparing Python and Haskell/Scala's abilities, when Python is capable of solving this in a very functional manner as well. In fact, the implementation can be quite elegant: max(map(sub, nums, accumulate(nums, min))) Though Python does not explicitly have scanLeft or zipWith, Python's map auto zips multiple iterables, and the standard itertools library has accumulate, which is essentially the same as scanLeft. Conveniently, if you don't provide an initial value to accumulate, the first value is just the first item of the iterable (which seems similar to Haskells scanl1). Python's operator library provides the sub function. One other nice thing about this, is that it works entirely with iterators, so there are no intermediate results. If you want to use -1's instead of 0's, I think the most elegant way would just be to use an 'or' operator, since 0 is falsey: max(map(sub, nums, accumulate(nums, min))) or -1
@MrMeszaros3 жыл бұрын
Thanks - just wanted to say that functional solutions can be written in Python!
@geeshta3 жыл бұрын
@@a2sbestos768 Also I don't think variable names as "lo" and "e" should be used in Python, as explicit is better. Also I'm a huge fan of type annotations so I'd prefer def maximum_range(nums: List[int]) -> int:
@rikschaaf3 жыл бұрын
@@geeshta It is the trade-off between code readability and code "elegance". Some people like it when there is as little as possible boilerplate and redundant code. Long variable names are therefore a no-no if a shorter one conveys its purpose well enough. Lo for "the lowest number so far" is good enough in this case. I do think that this does increase the size of your function documentation though, because you need to define more specifically what a variable means. Same goes for the "elegant" uses of the combinators to combine multiple statements into one line to not repeat the use of a variable for instance. Sure it saves characters, but you now need to spend more characters in the documentation to help future code refactorers decipher what the piece of code does.
@gloverelaxis2 жыл бұрын
this is *infinitely* better code than every example in the video. self-describing and simple
@jumbo_mumbo14412 жыл бұрын
You swapped i and j in your first point, just fyi
@philiphanhurst26553 жыл бұрын
I think APL deserves a prize for being more esoteric than assembly.
@henriquefinger9353 жыл бұрын
Assembly isn't esoteric at all.
@charlesthompson93953 жыл бұрын
Assembly is at least remotely useful when it comes to retro games
@FaranAiki3 жыл бұрын
@Charles Thompson, and APL is OP at array manipulating. APL is not esoteric at all, it serves a cool purpose, not like "Brainfsck".
@chouaibsam43813 жыл бұрын
I had a headache
@batner3 жыл бұрын
Why you consider asm esoteric?
@kDrewAn3 жыл бұрын
Im pretty sure APL is the code Neo sees as the matrix when he gets revived… the moral of the film is we should all take a page from neo’s book and learn APL 😤
@ianbridges60403 жыл бұрын
This is probably one of the, if not the best, computer science video I have ever watched. This helped me expand my perspective on problem solving as a new programmer. Thank you!
@stevemcgrath40403 жыл бұрын
APL (A Programming Language) has been the source of jokes in the programming community for nearly 50 years! I couldn’t readily find good references beyond en.wikipedia.org/wiki/Write-only_language?wprov=sfti1 , but there used to be fun competitions on who could write the shortest and most indecipherable code in APL. More practically, APL started out at a time when programming was still regarded by some as an extension of pure mathematics, so a highly symbolic syntax was not totally out of left field. Memory at the time was also at a premium, likely costing over a dollar a bit, so being able to represent core functionality in a glyph represented by just a few bits had practical benefits.
@FaranAiki3 жыл бұрын
I thought it was, "Array Programming language".
@foxoninetails_2 жыл бұрын
Iverson's decision to keep APL functionality to single glyphs was far less a product of chance or circumstance than of intention. While it may have helped save on memory incidentally, programming was by no means considered "an extension of pure mathematics" in the 60s; these were the days of FORTRAN and COBOL, when programming was still in its infancy but was largely verbose and strictly procedural, and was beginning to be more and more seriously used for day to day business rather than simply mathematics. Even at the time, APL's syntax was very much out of left field to most programmers. It was no mistake or happenstance that he chose notation so dense. Rather, he considered the dense notation of APL to be a feature and selling point in itself, as once you get past the learning curve of understanding the notation, its density shifts into clarity and ease of expression, similar to how exceptionally complex concepts can be expressed in very small amounts of mathematical notation. I highly recommend reading through his paper "Notation as a Tool of Thought" for more insight on why he chose to lean in the direction of the more "mathematical" appearance of APL.
@swikle Жыл бұрын
@@foxoninetails_ That sounds like a reasonable explanation. I would guess that, based on the fact that he wrote that paper, it is the correct one. I may try to track the paper down now. One of the first books I owned was APL/360: An Interactive Approach. In 1972, in high school, the only terminal I had access to was based on the IBM Selectric Typewriter. That was a very successful typewriter for IBM and it had swappable character balls. At the time, I did know Iverson worked for IBM and I had assumed the "weird character" approach was because at IBM Research, they might have been encouraged to help sell Selectric based technology. I don't think the language became as mainstream as IBM might have hoped. However, there are a lot of people my age, those who leaned towards math anyway, who learned that language right after FORTRAN and were quite taken by it. I think APL taught me more about how to think as a programmer than any thing I learned in my high school and college careers. I have run into many people since in the tech world who also fell in love with APL. And I would say, to some extent, it taught me how to think about matrix math in general.
@laughingvampire7555 Жыл бұрын
APL is also functional programming, the main difference is that arrays are the main data structure while in Lisp the Single Linked List is the main data structure.
@fsharpdev2 жыл бұрын
IMO dev teams are diverse and code ideally should be readable for everyone. I personally liked Scala and Haskell solutions (although I need to learn combinators to fully understand it, so I'll watch your videos about it). What's nice about this F# solution is that it's clear, concise, and can be run step by step interactively in REPL to see the transformations: let maximumDifference nums = nums |> Seq.scan min System.Int32.MaxValue |> Seq.tail |> Seq.zip nums |> Seq.map (( Seq.filter (() 0) |> Seq.fold max -1
@bimsherwood70063 жыл бұрын
Is it just me, or is the Scala form the most readable? The briefer the function gets, the harder it is for me to read. Even when I know haskell and not Scala.
@bimsherwood70063 жыл бұрын
Yeah, after thinking about it, I'd use the haskell Let expression to name the lists, just like how you explained the algorithm at the start.
@alexanderhurst19983 жыл бұрын
I don't know why we are caring so much about how concise the function can get by adding more symbols. Like he mentions how you might not want to spell flip and use parentheses yet the APL solution has symbols that I have no idea how to type. Typing flip() is easier and it's plain English so it's easier for me to read.
@RaukGorth3 жыл бұрын
Yes very. Like when I read "tail" the first thought is "oh, this is going to remove the first element!"
@hoggmann72173 жыл бұрын
Haskell was the most readable for me. Scala looked bloated. People that know math tend to go towards concise solutions and languages because symbols make it shorter to write and read. Once you know what the symbol means it's tedious to grok more and more expanded versions of it. That said I'd rather read the Scala than the Python.
@monad_tcp3 жыл бұрын
Its not, F# and Ocaml are better. Actually APL is more readable after you learn the symbols.
@pspicer7773 жыл бұрын
My moment has finally come! _I used APL before you were a glint in your father's eye_ . 👍. Great video. Enjoy the journey it's everything.
@voxelfusion98943 жыл бұрын
One one hand I'm awed at the deep mathematics on display, on the other hand I want to never use it myself. All of these highly formal functional languages are so ridiculously complex and unmaintainable, I can't imagine anyone using them in a serious setting.
@15shekels3 жыл бұрын
I figured the same. Coming from a python background I cant live without intuitive programming design that kinda makes comments not necessary In the grand scheme of things, all thats important to me is: *can i read it off the bat and come back to it later and remember what this function does and what created that call back?" *is it efficient? Ironically having said this youd probably laugh at me since i mentioned efficient and python in the same comment but i digress, something like python with a little more control over variable instantiation would be nice.
@leftaroundabout3 жыл бұрын
You may well find Haskell complex, but it's certainly not _unmaintainable_ - in fact, IMO the biggest advantage of Haskell is that its strong type system makes it almost impossible to break code that's worked before, without the compiler detecting the problem. Thus one can confidently change APIs without the risk that some dependency then ends up with bugs in production. And ultra-compact, point-free code is actually rather frowned upon in the Haskell community. This video strongly overstates the similarities in practice to APL.
@BeansEnjoyer9113 жыл бұрын
In my opinion, in imperative languages, branching into loops and conditional blocks really benefit from braces. I agree they add noise, but I feel like it helps sort out what the blocks of code are doing. Which is a main reason I find python infuriating, it's still imperative, but relies on a lot of tabbing to generate structure, which can get annoying to read in large parsing sections of code. For context Haskell is my favorite language, with C# being my professional language
@gigabek3 жыл бұрын
Combinatory logic gameplay: Combinatory logic lore: "Somebody I Used To Know remix played over this accelerated video" Thanks for this video, quite interesting introduction to combinatory logic and array programming.
@laurenpinschannels3 жыл бұрын
this sounds interesting, tell me more...
@cristian-si1gb3 жыл бұрын
This is going to be a good one, I can feel it
@echoptic7753 жыл бұрын
Was it?
@LyricWulf3 жыл бұрын
@@echoptic775 I think they are still recovering from the digression
@srijanpaul3 жыл бұрын
Great talk as always. The slides were much smoother this time around, loved it.
@rikschaaf3 жыл бұрын
Imperative programming is like a recipe. You follow the steps and out comes the result at the end. Functional programming is like an assembly line for your data, where each step computes, recombinates or combines the data, to get to the endproduct. I feel that the recipes of imperative programming are easiest to read and follow, because you can easily digest it step by step and see the intermediate results. If you do simple things like map, filter and reduce and an occasional zip, functional programming can still be very readable for most programmers, but it becomes way more complex once you start using the combinators. And I don't mean that those can't be understood. I mean if you can see at a glance what it does without too much effort, which helps maintainability.
@utof2 жыл бұрын
Well as everything i think one becomes good at doing a thing with practice. After some time u probably will be able to quickly think, read and type with combinators, but the problems arise as soon as you need to show it to someone. Pretty high chance it will take quiiite some time to understand. If it was a thing taught in schools/uni, then probably there would be no problems
@curlyfryactual Жыл бұрын
@@utof the beauty of industry: you will need to show it to someone as you cannot maintain code forever, and your boss will not pay for that person to sit around learning a new way to think.
@deudaux Жыл бұрын
Just the first video I watched on this channel, and looking at other videos... this is probably the best channel I found over the last ~10 years
@ssfrr2 жыл бұрын
it's worth noting that the problem being solved has a real-world interpretation: If the numbers are a time series of prices (like daily prices for a stock), this gives the maximum profit you could make if you bought and sold at the optimal times (assuming you can't short-sell). So if you are evaluating some trading algorithm this gives the upper bound on performance. This is also solved in one of the "Q for mortals" videos.
@ravimaithreyregulagedda21583 жыл бұрын
Man I really really loved this video. You convinced me to look into combinatory logic. I'm gonna check out To Mock a Mockingbird. Thanks for the great video!
@markwvh3 жыл бұрын
Your strategy is overly complex, no? maxDiff :: [Int] -> Int maxDiff = snd $ foldl' go (maxBound, -1) where go (lo, diff) x = (min lo n, max diff (x - lo))
@henriquefinger9353 жыл бұрын
I'm a Haskell beginner, this was my solution: maxDiff [] = -1 maxDiff (a:as) = mD as a mD [] _ = -1 mD (a:as) m = if a > m then max (a-m) (mD as m) else mD as a
@joaquinbarrientoscr3 жыл бұрын
Wow, just amazing! You are just the programming channel I was looking for. Thanks for your content, keep it up! Cheers!
@c4tubo3 жыл бұрын
APL was the very first programming language that I learned at the age of 8, taught to me by deaf friends. The next was BASIC. Imagine that!
@RedHair651 Жыл бұрын
Galaxy brain
@Jupiter__001_5 ай бұрын
Probably easier to get into at a younger age because much of maths is still weird glyphs at that stage, so it wouldn't seem so out of left field as it does for adults.
@zachb17063 жыл бұрын
I was shocked when I first saw the APL version of the gave of life, a game that took me ~100 lines to code in python written in a single line
@garklein80893 жыл бұрын
The parentheses aren't even needed in the APL solution, making a cool looking function with the max reduce at one side and the min scan at the other
@code_report3 жыл бұрын
Sigh :facepalm: I definitely should have noticed that
@lesfreresdelaquote11763 жыл бұрын
Thank you, this is the first time I have a good idea of what the S Combinator is all about... Sharing the same argument again, without being forced to mention it twice... Neat...
@0dWHOHWb03 жыл бұрын
How do you even produce those characters on your keyboard? Is typing a function call really so taxing that reducing it to a single character is the difference maker? I don't understand how this kind of language can be easier to read/write or reason about.
@ravimaithreyregulagedda21583 жыл бұрын
I think you missed the point. The guy is talking about why he thinks a certain language is amazing in his opinion. He thinks that way because he loves the math and all behind combinatory logic. I agree with you that it might not be practical, but the guy thinks it's cool and he likes the concept and loves that an existing langauge has all this combinatory logic in it. That's why he made this video. At least that's how I understood the video anyway ¯\_(ツ)_/¯
@0dWHOHWb03 жыл бұрын
@@ravimaithreyregulagedda2158 It's possible, yeah. We're left to guess at the motivations of the author since they weren't clearly stated.
@stevemcgrath40403 жыл бұрын
@@0dWHOHWb0 Back in the days when APL was cool, you had special keyboards and unique encodings (well before Unicode). So you probably just use a custom keyboard mapping. I don’t remember the count, but there aren’t that many glyphs in APL. Conceptually, it’s most like the broad use of symbols in mathematics in general; you’re writing a mathematical expression, not a story.
@orkhepaj3 жыл бұрын
hipster lang , they dont use this for anything
@jamieg24273 жыл бұрын
it's not that difficult to have certain key presses produce other characters. vim, for example, makes setting up this type of scheme pretty trivial, but it can be done at a system level very easily on linux and windows. also, J, made in the 90s by the creator of APL, uses ascii characters, so fear not. (:
@Jupiter__001_5 ай бұрын
So the S combinator duplicates the argument of the function that follows it and inserts it in the place of itself? i.e. foo bar applied to List gives us foo List (bar List), where foo takes two arguments and bar one. I have never heard of combinators, but this seems quite useful in a language like Haskell wherein there were no explicit references to a named argument anywhere in the function definition.
@casperes09122 жыл бұрын
What people like this guy often forget, is that code is read a lot more than it's written
@RonMcclain-o5j Жыл бұрын
I assume to people who live in APL, it's very readable. Those ten people can probably read this immediately.
@lpi3 Жыл бұрын
From my experience it's not true.
@0LoneTech Жыл бұрын
It's often very fast to get the gist of an expression, but a little slower for me to confirm the exact workings of the chain. In comparison, C syntax is very noisy with redundant terminators, separators, names etc. Haskell is a fairly sweet spot, but forking of data often involves some awkward back and forth parsing.
@AndreiGeorgescu-j9p10 ай бұрын
Do you say that when you see Chinese and tell them they need to rewrite their language so people who don't speak Chinese can read it?
@harshrathod503 жыл бұрын
This is the first time I came to know of combinators. Interesting.
@vivekkaushik95082 жыл бұрын
I hardly understand 5% of what's going on here but I feel amazed and quite smart after watching these vids. LMFAO. Seriously the world of computing is mind blowing. The so called "developers" like me don't even know 1% on what goes behind the scenes when we call an in-built function or use any tooling like Git or SDKs etc. Thanks mate for keep making these vids. Hope you're keeping backups we don't know when WW3 ends everything.
@DrGreenGiant3 жыл бұрын
So what you're saying is that some languages have more useful (for this problem) standard library functions than others. So the comparison is between standard libraries, not languages. Still a valid discussion but you're mixing syntax Vs library
@mbartelsm3 жыл бұрын
While that is true for Haskell vs Scala, it is not true for Haskell vs APL, as both languages have very distinct ways of laying out the code.
@jms0193 жыл бұрын
Thank you. I finally get what combinators are _for_ not having seen it explained in a way I have understood as an engineer until now.
@KR-uc9ei3 жыл бұрын
clojure solution: (defn maximum-difference [nums] (->> nums (reductions min) (map - nums) (filter pos-int?) (cons -1) (apply max))) i like it better than the skala solution and clojures map fn forgoes the need to zip, which is always nice. But point free solutions like these tend to fall apart when you don't have a consistent placement for argument (notice my use of cons instead of conj). But that can happen in haskell and apl too, if it werent for combinators to save the day. clojure just solves this with more macros which has it's own tradeoffs.
@allenmaudiln3 жыл бұрын
I love your podcast! I didn’t realise this was your channel.
@ivanivanovich47783 жыл бұрын
How does changing variable names from clear words to random meaningless syllables make the code more readable
@RaukGorth3 жыл бұрын
It doesnt
@ShadyE3 жыл бұрын
I wonder if Clojure's macros can be used to introduce combinators 🤔
@andreiiaz20973 жыл бұрын
I can't wait to see this showdown. 😁 Thanks in advance for making this!
@dlmcnamara3 жыл бұрын
This talk demonstrates why functional programming is less widely adopted: the imperative approach is, more or less, “do what the problem description says to do”, the functional approaches require reinterpreting the problem in terms of the concepts that are well supported by the language.
@nikitamyazin65863 жыл бұрын
Except it's not true. In fact, imperative approach is the opposite thing to declarative approach, so it is always about "how to do what the problem description says" and not "do what the description problem says". Otherwise it's not an imperative approach anymore. The reason why it _looks like_ imperative does whatever the problem description tells you to do, is because resources like leetcode, hackerrank etc most of the time provide issues designed _specifically_ for an imperative approach. They fit imperative approach well, programmers who use imperative approach might face them often. However, I'd argue there are tons of tasks that look clean and understandable with functional approach and ugly with an imperative approach. But that's not the most important thing. The most important thing is that in real world no one will ever give you a ticket that says "I want to find a max difference between two elements in the array". It's just a low level implementation detail which will never exist in functional world in the first place. So it does not matter which approach you are using, you will always choose proper low level algorithm that will look great and understandable in the project paradigm and most likely will look horrible in any other paradigm.
@henriquefinger9353 жыл бұрын
As someone who knows a little bit of Haskell, I can assure you there is a solution in Haskell that looks way more like the imperative solution. Here he abused some of the more confusing aspects of the language.
@red13emerald3 жыл бұрын
7:40 100% disagree. Even though I knew what the variables were originally, I got immediately confused by these short variable names. It’s maybe to do with parsing mathematical formulas, which I am super bad at, but I feel like 1-3 word variables are much more readable than 1-3 letter variables. Except for i in a loop, but even there, index, position or location may be more appropriate depending on what you’re actually iterating over.
@saltrocklamp1993 жыл бұрын
I have a lot of experience parsing math formulas and I still think the short variable names are worse!
@31redorange083 жыл бұрын
Wasn't this whole video a joke?
@red13emerald3 жыл бұрын
@@31redorange08 I… don’t know. Maybe? I guess, yeah, when you think about it like that, it makes sense, but I can also see how people do find beauty in pure languages like this. I just thought that it wasn’t for me?
@henriquefinger9353 жыл бұрын
Before the functional language section I tried to solve the problem with Haskell myself. What surprised me is that my solution was completely different from yours. I only used recursion and ifs, no fancy functions like scan, map, filter, reduce and combinators, but my code is still O(n). It made me wonder which is faster for larger input arrays, I might check it out later.
@guptadagger8962 жыл бұрын
Scan was new to me, but map and folds should be very standard haskell toolset
@codebitcookie80533 жыл бұрын
Oooooh a very interesting comparison! Love your channel
@monad_tcp3 жыл бұрын
I love APL . It helped me so much with Linear Algebra and Calculus.
@amj8643 жыл бұрын
Would you do a Julia over view? It looks like a jack of all trades and master of few.
@Nellak20113 жыл бұрын
I'm pretty sure APL was developed by our alien overlords.
@cranknlesdesires3 жыл бұрын
Nah, Ken just wanted a version of maths that made sense, like why does summing everything have its own symbol but subbing everything doesn't? Why does min and max have no symbol even though we use often? Why do we need to remember Bedmas/Pedmas, what about if a expression has a Sigma, when do I do that? So Ken made something more consistent, with more symbols and less rules, and it was found that it can be made a programing language easily enough.
@wowzers1237____3 жыл бұрын
If BQN also had all the type theory stuff Haskell does, I'd be sold. Without it, although the glyph notation is cool, it's just a limited version of Haskell not worth learning (imo) - just learn Haskell at that point. Or I guess I can ask: Other than the fact that it's more succinct on account of the glyphs, what does BQN offer that Haskell doesn't?
@0LoneTech Жыл бұрын
It's not just the glyphs, but also the syntax and chosen data types and polymorphisms. For instance, CBQN will happily build byte arrays rather than Double arrays to improve memory access patterns, simply because the data fits. When they advertise context free syntax (really, only local context), it's to assist both human and automatic readers. It really isn't a version of Haskell. If anything, it's a version of APL, and the array oriented programming is a useful paradigm to learn, which you could translate to some degree into Haskell Massiv. It does bug me that people keep comparing Haskell lists to arrays. There are arrays even in standard Haskell (Data.Array), though not in base.
@howuhh89603 жыл бұрын
This is definitely really cool. But for me there is always a question: how to get things done on such languages? What's the purpose? How difficult it would be to write for example autodiff library on APL? Or train ML model (or GPT-3 for example)? process tabular data from csv? scientific algo, which should be as efficient as possible?
@LittleLily_3 жыл бұрын
Processing and extracting data from csv's is just about the perfect use for functional and array languages. It excels in things where the input is simple to quantify and the result can be expressed as a series of transformations on that input, so reducing a set of rows and columns into some meaningful value you want to extract from it would look much simpler than an imperative solution.
@walrustrent20012 жыл бұрын
I think the very idea that only collections (aka arrays) of things should exist is brilliant, kudos to APL to introduce that.
@alpers.21233 жыл бұрын
11:00 Scala code, python equivalent: max(-1,*(n-m for m,n in zip(list(reduce(lambda x,y: x+[min(y,x[-1])], nums, [sys.maxsize]))[1:], nums) if n-m)) 19:30 haskell code, python equivalent (no INT_MAX, yet python doesnt have S combinator, so this is best I can): max(-1,*(n-m for m,n in zip(reduce(lambda x,y: x+[min(y,x[-1])], nums[1:], nums[0:1]), nums) if n-m)) Update: Just saw atrus' comment. here is pythonic way: max(map(sub, nums, accumulate(nums, min))) or -1
@holykoolala5 ай бұрын
For a quick look at J I recommend "A Brief J Reference". J in j is the symbol for Complex Numbers. Imaginary numbers are super fun in geometry.
@peerhenry3 жыл бұрын
The S combinator explained at 17:32 reminds me of functions as monads: you can chain a binary function x onto a unary function y, so in Haskell it would be something like y >>= x. I believe the same is achieved by treating functions as applicatives with x y (solution of this video).
@explosionspin34223 жыл бұрын
You probably already treat functions as monads. That's what Reader is. Reader a b is pretty much the same as a -> b, under the hood
@chainik-chainik3 жыл бұрын
So, how to open a file using APL?
@_xeere3 жыл бұрын
Point-free-programming is a very nice way of saying code-obfuscation. Please don't play golf in any code that you work on with other people.
@taylors15453 жыл бұрын
Anyone ever open a door out of curiosity and instantly regret it? Time for another mug of coffee...
@GamerMrScorpion3 жыл бұрын
It's too esoteric to me to be honest haha, but it seems really cool to know how to program in a language like this. And I have 2 questions about Array Programming (or APL): 1 - To code in APL you need a specif IDE? because I don't even know if it's possible to type some of the characters that I saw. 2 - And what kind of problems this type of language is target for? like, in which scenario I would choose Array programming instead a normal approach (like C++)?
@deidyomega3 жыл бұрын
1) You can do it with plugins + dyalog in vscode. 2) I have zero idea... why you'd ever use it
@mlliarm3 жыл бұрын
1) Dyalog APL has a nice built-in REPL with all the character set, and also they have the RIDE IDE which is nice too. 2) In the past APL has been used for teaching maths, and for computational physics. There isn't a hell of a lot of material for the second part, but I can share a 70pg report from the 80s that does some serious physics calculations (Newtonian gravity, Einsteinian gravity, Schrödinger equation, Feynman path integrals) I've found. If you've got a problem that can be modelled using matrices (linear algebra), then APL and J are perfect for it. Also J seems much more equiped and powerful for anything related to mathematics and data. I hope modern APLs will catch up.
@madsteeez3 жыл бұрын
MATLAB: res = max(nums (2:end)-nums(1:end-1)) If all(res
@asteriskman3 жыл бұрын
"The expressivity of the single glyphs"? oh yea, totally sold me...I'm switching to APL, where do I buy a keyboard with all these expressive symbols?
@Baterodalo3 жыл бұрын
APL is the Doctors handwright of programing
@ningúhosaptot3 жыл бұрын
Please could you comment how do you do those smooth text code transtions? Thanks in advance.
@CaptainWumbo3 жыл бұрын
nothing really to stop you aliasing combinators in haskell to whichever character you like, if you think terseness is king. Still need spaces in many cases of course. cant say I share your surprise that array languages arent wider spread. Although there is huge untapped value to terseness (we need only look at the history of our number systems compared to our positional system), it needs to be combined with expressiveness and dare I say a certain amount of familiarity and domain specific concerns. There is no natural place in apl to express the nuances of german tax law.
@ArabicNameGuy3 жыл бұрын
>German tax law (;;;*_*)
@benjidaniel55953 жыл бұрын
Elegance !== Legibility
@HenrikMyrhaug3 жыл бұрын
About the example problem: I believe it might be faster to store two variables of the highest number and highest difference, and instead of comparing the difference between the min and the current number to the current biggest difference on every single step, we just compare the current number to the highest number. Each time we find a new min, we compare the highest difference to the different between the current max and min, and store the largest of those as the largest difference, then set the min and max to the new min we found. So instead of doing a subtraction for every element in the array, we only do a subtraction each time we find a new minimum. I have no idea how fast variables can be accessed and stored, so I don't know wether the increased number of variables used increases compute times more than the reduction from fewer subtractions.
@joaoholanda30219 ай бұрын
Honestly I am far from understanding it but congratulations for the great presentation and thank you for taking the time to explain it. There's a lot I still have to learn tô fully appreciate it.
@imadetheuniverse4fun3 жыл бұрын
What are the pros and cons of writing the algorithm in one paradigm vs the other? For example the pros and cons of the Haskel implementation vs the Python one? For context, Python is my main language but I'm kind of interesting in learning Haskel.
@MultiJaxk3 жыл бұрын
What's your opinion on J programming Language vs APL? honestly I've been giving both a bit of review, and seem to like J language more. What would you say - which one is "more powerful", if you could/can compare them?
@CostaKazistov3 жыл бұрын
Audio is distorted again. Reduce input volume by 10-15% to alleviate the issue.
@code_report3 жыл бұрын
Yea, I thought I had done the adjustment prior to recording but apparently something got reset.
@loutragetadk4533 жыл бұрын
I would like to learn more about this combinatory logic stuff.
@HOWTO-sf6sy3 жыл бұрын
Waiting⏳also your sicp course is insane
@lorenzrosenthal1193 жыл бұрын
20:38 him: "blahblah, higher logic blahbla" me: "I like the tilde thingy with the friendly eyes above it :)"
@thinker22733 жыл бұрын
So APL is what people refer to as a write-only language
@RajeshPandianM3 жыл бұрын
I wanted to ask this in the last video. Did you create a logo for APL? If so, this looks cool! 😁😁
@jenaf37602 жыл бұрын
I dont get why people think that the wierd unicode symbols are a boon?
@bzboii2 жыл бұрын
20:35 Twin Algorithms secret reference (and 21:58) could have sniped his conference talk while he waited to give it in person
@ninimouss Жыл бұрын
> At 18:17 "In the future, I will give a full either 40-60 or 90 min talk all about Combinatory logic and Combinators" Please tell me we live in that future and that video exists somewhere and I just didn't find it 🙏
@@code_report Thank you for the link! This was a great video! I would love your opinion as a C++ developer: it's clear to admit that Array programming is extremely elegant and terse, but I wonder if the elegance comes at the cost of the performance? I didn't catch up with all the ArrayCast podcast episodes, so apologies if it has been addressed there, but at this point I'm still unsure if array programming and performance mix well or poorly with performance, the "naive" examples I came across seem to favor terseness over efficiency but don't know if it's a tendency or not.
@XetXetable3 жыл бұрын
I come from a more Haskelly background and eventually gave up on array based programming because I appreciated different things. I never found point-free programming particularly elegant. It's a more restrictive, less efficient version of interaction combinators (combinators whose abstract syntax is a rooted graph rather than a tree). Ordinary lambda calculus is closer to such things than Curry-style combinators and I don't sympathize with the perspective which sees combinators as more elegant than pure lambda expressions. Without that perspective, there's not a lot to appreciate in the current batch of array based languages. I don't want all my data to be arrays, I would rather all my data be functions. Ordinary combinator calculi give you that at least, but array based languages don't.
@Freddy789095 ай бұрын
The Python solution was the most elegant. And I'm 99% sure the functional solution is slower than the imperative if both written in the same language
@diegofloreschavez84203 жыл бұрын
You can do it one-liner in Python like this: def solve(*args: int) -> int: return max(args[min(args):]) - min(args) if min(args) != args[-1] else -1 But I think it would be better if you store "min(args)" first in a variable.
@prawnydagrate Жыл бұрын
7:55 - for the python example, isn't it better to use math.inf instead of sys.maxsize?
@0LoneTech Жыл бұрын
Possibly, but not type consistent. sys.maxsize is like Haskell's maxBound::Int, except Python's int has no max value (it's arbitrary precision like Integer). It's not great as Python code goes anyhow; I might e.g. write max(max(nums[i:])-min(nums[:i]) for i in range(1,len(nums)-1)), which may not be as algorithmically efficient but avoids naming new magic values and probably runs faster.
@reda291003 жыл бұрын
5:00 doesn't it make more sense to assume the max_dif to be n[1]-n[0] if positive, otherwise -1, such that .we increase the difference as we find a larger one, instead of assuming it to be MAX_INT?
@walrustrent20012 жыл бұрын
Data-oriented algorithms should use reverse notation so that the reading order matches the application of functions. Elm has really smart notations that lead to easier reading than Haskell, since it provides operators for both function composition and function application in both directions) Namely |> and > and ( zipWith (-) scanl1 min ) |> filter(/= 0) |> foldl max (-1) Of course you loose the pointfree notation but I think it is largely worth it
@0LoneTech10 ай бұрын
What do you mean about losing point free notation? x is the only point in your example, so each operation is written point free. Just change "maxDiff x = x |> " with "maxDiff = " and |> with >>, and you're fully point free. |> is also used in Futhark, and internally in GHC, and is named & in Data.Function. Protolude and Relude both expose & by default.
@brendanhansknecht46503 жыл бұрын
It would be amazing if you did BQN or APL tutorials.
@pauhull3 жыл бұрын
imagine you have to check a pull request and see this: 20:12
@Colaholiker3 жыл бұрын
That is probably what Klingons use to program. Working in the embedded world (C, Assembler) with some tool programming in Python, C# or Java and some "field trips" into web backends in PHP, it really makes me wonder why someone would need or even enjoy that (no offense) and where that is used outside of academic contexts.
@bjk837 Жыл бұрын
I would love to know how you manage your time. Would love to start doing more outside of work, but I you’re like 10X and I’m struggling
@nuxs3 жыл бұрын
Lisp isn't array programming lang?
@code_report3 жыл бұрын
Not in my books. Lisp is almost it's own paradigm, but languages like Clojure and Racket definitely belong in the functional paradigm IMO.
@alexxx44343 жыл бұрын
Such a great presentation!
@mlliarm3 жыл бұрын
Smullyan's bird book will arrive most likely on 2021-12-18. I'd ordered it well before I saw this video. I'm happy to see that you recommend it too :D!
@hebozhe7 ай бұрын
Smullyan and Priest write some of the most accessible logic books. I don't study much in this area of logic, but I'd definitely pick through the Smullyan text if I wanted a quick comprehensible dive. Good recommendation.
@RobotProctor2 жыл бұрын
I assert that this is great IF you can hold more abstract things in your head at once. I think there's room to make programming more accessible, and I don't think APL is the solution.
@rjameslower3 жыл бұрын
What do you think about GNU APL for a beginner?
@korigamik Жыл бұрын
Your videos are cool! Can I ask what you use to create these amazing slides and animations?
@code_report Жыл бұрын
I have a tutorial here: kzbin.info/www/bejne/jJmWqmSbocZgldU