Most Useful Constructs Across Programming Languages

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 266

  • @heckvideos
    @heckvideos Місяць тому +260

    E-nooom 💖😭

    • @KazmirRunik
      @KazmirRunik Місяць тому +27

      it's actually e-GNOME 🧙‍♂️

    • @Bliss467
      @Bliss467 Місяць тому +19

      I mean, it’s short for enumeration, so I guess I understand the thinking.

    • @kantancoding
      @kantancoding  Місяць тому +23

      Unfortunately, I’m from California 🫠

    • @RenderingUser
      @RenderingUser Місяць тому +9

      @@kantancoding I am from earth

    • @iamfastre
      @iamfastre Місяць тому +9

      ⁠@@RenderingUser I’m not from Earth, I’m from Missouri

  • @paradoxicalegg6112
    @paradoxicalegg6112 Місяць тому +105

    Python's "f" strings are amazing

    • @kantancoding
      @kantancoding  Місяць тому +3

      I agree!

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

      Scala has them in a possibly even better way, where it's just special syntax over a method over strings that takes arguments. So you can make it do much more than interpolation.
      Haskell also has quasiquoting, which allows the same thing as scala, but the syntax is not nearly as nice. Still very powerful!
      And I say this as a Python fan.

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

      @@Tomyb15 Python also has a `format()` method for strings, its syntax precedes f-strings. Similar thing in C#, IIRC.

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

      ​@@SugarBeetMC aren't C# $strings the same as fstrings?

    • @semrozema
      @semrozema Місяць тому

      Yes they are ​@@NihongoWakannai

  • @foxcirc
    @foxcirc Місяць тому +25

    My top five (modern) language constructs are:
    1. RAII
    2. Async (the way of taking code that would normally be event-loop style and making it very sequencial) + Generators (same concept)
    3. Comptime (either Zig-style or Generics)
    4. Enums and Pattern matching
    5. (custom) Iterators and Iterator chaining (like saying mylist.map(it * 2).sum()
    I did not count a good type system here as I think every language should have this is some form or another.
    I think stuff like list comprehensions isn't really important because it is just syntax sugar and doesn't fundamentally change the way I code and organize my codebase.

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

      So much of my code in python is comprehensions although i like haskells syntax better, and i would say a module system and a hindley milner type system are must haves for me

    • @mikkelens
      @mikkelens Місяць тому

      python devs need syntax sugar like list comprehensions because you can’t just chain methods/operations easily like you would in languages that are sane and dont have significant indentation

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

      @@mikkelens they don't serve the same purpose. What does chaining have to do with list construction via human readable expressions? The concept comes from set comprehensions in mathematics and is a way of efficiently creating data structures, not to mention you can absolutely chain methods in python

  • @karixening
    @karixening Місяць тому +16

    genereics with contraints: rust, haskell, TS
    function (x: T) {}
    destructuring: rust, python, TS
    const { x, y } = { x: 1, y: 'foo' }
    error and option monads: zig, rust, haskell, gleam

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

      Java also has generics with constraints

    • @mikkelens
      @mikkelens Місяць тому

      @@fabianmontes7553 java ‘generics’ are literally just syntax sugar for object inheritance, and as such you can’t use primitives in generic code, only object versions of them.

  • @naueosiek1599
    @naueosiek1599 Місяць тому +71

    you definitely missed RAII, one of the defining feature of C++ (and Rust). this feature also what makes me love both language. no more memory management headache, no more forgetting closing socket, etc.

    • @kantancoding
      @kantancoding  Місяць тому +9

      Thanks for the input. It will help for the next video :)

    • @mskiptr
      @mskiptr Місяць тому +5

      Maybe also linear types then? It's the mathematical idea behind Rust's ownership model and it is really quite straightforward actually.
      As for what else (besides memory safety) you can achieve with it, I'd highly recommend reading the blog post "Introducing Austral". It contains an awesome explanation of that idea and shows a lot of great examples!

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

      RAII is what you do when you have no clue how to handle memory. Instead of that mess, prealocate for most things and use pools/arenas. Its faster, more efficient in terms of usage, less bug prone and much less code.

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

      I don't get why more languages don't use RAII

    • @svenschneider1578
      @svenschneider1578 Місяць тому +13

      @@filipg4 I think you misunderstand what RAII really means. Even pools/arenas can benefit from RAII. RAII is a very basic and versatile concept. Some languages that miss RAII and introduced a not so potent substitute like "using" in C#, the "try"-syntax-variant in Java), the "with" in Python, or the a bit more flexible "defer" in Go. In the end it is not really about not having a clue, but more about being lazy and/or forget-full, when trying to solve another problem. That what a good programming language is about, I can concentrate on the problem I want to solve, not the language mechanisms.

  • @tepumasutasauno8671
    @tepumasutasauno8671 Місяць тому +139

    Yeah, I guess you've definitely missed defer construct, it's present in Odin language for example and can be implemented in C++ through destructor mechanism

    • @kantancoding
      @kantancoding  Місяць тому +18

      Thanks for the idea! I’ll look into it. Seems interesting 🧐😆

    • @DavidBetz00
      @DavidBetz00 Місяць тому +7

      RAII.

    • @Ba_Dashi
      @Ba_Dashi Місяць тому +9

      Is defer in Odin like defer in Go? It's one of my favorite constructs, I wish more languages implemented it instead of having to use try/finally

    • @Ztaticify
      @Ztaticify Місяць тому +6

      drop in rust is generally a lot better than defer. It lets individual types handle their out of scope operations automatically so you can never, for example, forget to unlock a mutex

    • @katekyy7
      @katekyy7 Місяць тому +10

      @@Ztaticify Drop does basically* the same thing destructors do. Well, 'cause the Drop trait is a destructor.

  • @karlingtonbanks898
    @karlingtonbanks898 Місяць тому +13

    C# has all of these and arguably a better execution in many respects.

    • @tigranrostomyan9231
      @tigranrostomyan9231 9 днів тому

      Does C# have sum types (aka rust enums, aka tagged unions) and pattern matching?
      And what you mean by “better execution”? Better than all presented languages?

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

    In C++, with variants, visit and function overload you also have pattern matching, although in C++26 pattern matching will be a new core feature of the language.

  • @MatthewKelley-mq4ce
    @MatthewKelley-mq4ce 16 днів тому +1

    Honestly. One of the most useful and niche videos I've seen in a while. Very nice

    • @kantancoding
      @kantancoding  16 днів тому

      Hey! That really means a lot. I try hard to come up with different ideas so I’m glad it’s appreciated. Thanks for watching!

  • @mskiptr
    @mskiptr Місяць тому +7

    I feel like a better example from Haskell would be how it unifies lists and generators. After showing how enums work in Rust you can explain how the equivalent works in Haskell and build a linked list with that.
    Then, since the order of evaluation in Haskell almost barely matters, if you have a pair of function where one produces a list and the other one consumes them, together they can be compiled to a simple loop if the compiler is clever enough. And in case it isn't, they will still be generating and consuming about one element at the time because the default lazy evaluation will only ask the producing function to generate the next one if the consuming function is trying to consume it.
    Then you could even show stuff like creating infinite lists and doing actually useful work with them!

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

      Good points! Some great ideas for a future video :)

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

      yeah he's underselling haskell here

  • @arichidoru
    @arichidoru Місяць тому +35

    3:02 "Instead of needing to write two functions". But you did exactly that, it's just that they are called the same and the appropriate implementation is picked automatically by the compiler based on the object it is applied to.
    If you need two different actions, you will have two different functions, there's absolutely no way around that. You can hide it in a bunch of layers of extra stuff, of course, but at the end of the day, it's two functions/procedures.

    • @wareya
      @wareya Місяць тому +13

      The pattern match is inside of the function (singular) rather than being overloading on the outside of it (which would make it two). Haskell is weird ok.

    • @arichidoru
      @arichidoru Місяць тому +5

      @@wareya Implementation details. As someone else mentioned in the comments, a glorified switch statement. You still write two separate pieces of code for each of the shapes, with no overlap. Inline them all you want, it's still two separate things.
      I'm not familiar with haskell, but I just don't think it was a good explanation / example of "pattern matching", especially if it can offer more than achieving polymorphism. I doubt "not writing two functions" is the main purpose / use case of this feature.

    • @Ryuu-kun98
      @Ryuu-kun98 Місяць тому +7

      Yeah, this specific Haskell syntax is pretty bad at just showing pattern matching because it looks so different. A simple Switch/Case/Match-Expression would have been easier to understand because most people are already familiar with them or similar constructs.
      Haskell has pattern matching on function input parameters.
      You can think of it as a function with a Switch/Case/Match testing for each pattern like a condition.
      in C# and in many other languages you can use patterns inside if or variable declarations.
      Its basically fancy conditions that can also declare variables

    • @wareya
      @wareya Місяць тому +8

      @@arichidoru It's not about the work you spend writing the function, it's about what you can do with it. You can pass the function around as a single thing that handles both cases instead of having to potentially pass multiple different functions around. You can't do that with e.g. overloading.

    • @Ryuu-kun98
      @Ryuu-kun98 Місяць тому +1

      @@arichidoru yes! You could pattern match on Lists/Arrays like [a, b, c, ...rest ] declaring a bunch of variables at once or match on specific values like [4, 2, 0, 6, 9] or do both.
      Languages with pattern matching let you match on anything. Classes, Types, Tuples, ...
      As I have said in my other comment: fancy conditions that may declare variables

  • @garretmh
    @garretmh Місяць тому +3

    It’s not really a language construct but Hindley-Milner types deserve a mention for being the best thing ever

    • @kantancoding
      @kantancoding  Місяць тому

      Looks interesting! Let me look into it :)

    • @yangmungi
      @yangmungi 15 днів тому

      Yes, I was about to eventually get to it when looking at the pattern matching example.
      Pattern matching is "doable" in a lot of languages that provide some level of type system, but Haskell is particularly nice because of the lack of additional things required to safely implement a pattern matching system.
      Speaking of Haskell, a generalization of a generator expression is "lazy evaluation" (or deferred if lazy seems derogatory). It is nice that Python has a lot of built-in generator functionality, but it can be implemented in any language.
      I think all of these constructs are just "sugar" (i.e. language mechanics that reduce the amount of boilerplate required), with different languages supporting different levels of pre-run safety checks.

    • @giorgos-4515
      @giorgos-4515 6 днів тому

      If a concept has a name that includes author names it's probably more math and less programming

  • @mysterry2000
    @mysterry2000 Місяць тому +10

    Also check out Rust's macro feature. It's so flexible that you can literally write another language inside rust and still have compile-time checks for that language

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

      proc macros in rust are actual dark magic

    • @apestogetherstrong341
      @apestogetherstrong341 Місяць тому

      Clojure macros are more powerful because they’re unhygienic

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

      I'll check it out!

    • @Kraaven2026
      @Kraaven2026 Місяць тому

      YOO, thats cool. Do you know any examples of this?

    • @mysterry2000
      @mysterry2000 Місяць тому

      @@Kraaven2026 yeah my favorite one is how your SQL gets compile-time checked against your structs as you code. Imagine that - you're writing an SQL statement and it's getting validated even before you write test cases for it. Absolute magic ✨

  • @mrefida
    @mrefida Місяць тому +9

    I'm interested in learning more about small-cost abstraction constructs, similar to Rust's enums, which can be evaluated at compile-time. Could you make a video of such examples? Also, you mentioned string interpolation earlier. Rust has a similar feature with its print macro. While I'm not a big fan of Rust, I find that feature quite neat.

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

      Sure, let me look into it. Thanks for watching :)

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

      The format macro is usually used for string interpolation and it shares (almost) the exact same syntax as the print macros

    • @mrefida
      @mrefida Місяць тому

      @@nebularzz indeed everything inside std::fmt is string interpolation-like, but with limitation such as can't do operation inside a string, but that is not rust limitation, just the std correctness implementation. swift kinda have the better interpolation than others (not swift dev)

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

    Funny that C# has all those concepts, but it hasn't been mentioned once.

    • @kantancoding
      @kantancoding  Місяць тому

      Sorry about that brother. I’ll give C# more spotlight in a future video.

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

    Ayo first on a gucci new video.
    More seriously, fun little video with an interesting topic. It's some of these things you take for granted working within one specific language, but also the fact that you will miss certain features from other languages in the one you're working in now.

    • @kantancoding
      @kantancoding  Місяць тому

      I agree! Especially if you are currently working with a language that you don’t particularly like 😂

    • @raoulkent
      @raoulkent Місяць тому

      @@kantancoding surely that'd never happen 🫠

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

    Id appreciate it if the code stayed on the screen longer, instead of modifying it in real time - makes it easier to follow, in my opinion

    • @kantancoding
      @kantancoding  Місяць тому

      Hey thanks for the feedback. I’m wondering, is it not on the screen long enough to pause on parts where you need my time to ingest it? I’m trying to find a balance :)

  • @oglothenerd
    @oglothenerd Місяць тому +4

    I am making my own language, so you know I am taking notes! 😎

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

      interesting

    • @Vivraan
      @Vivraan 11 днів тому +1

      Same and completely did that for the Haskell bits. I've much to learn.

    • @oglothenerd
      @oglothenerd 11 днів тому +1

      @@Vivraan I don't think anyone fully understands Haskell. Lol.

  • @michalmoroz
    @michalmoroz Місяць тому +4

    Is that list available somewhere? Would love to check if there's something I miss or didn't know the term for.

  • @vidtalk
    @vidtalk 12 днів тому +1

    What font and theme are you using?

  • @willyhorizont8672
    @willyhorizont8672 Місяць тому +7

    please make more videos like this 👍

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

      Will do!

    • @tochimclaren
      @tochimclaren Місяць тому

      ​@@kantancoding what too do you use to make these clean animations.

  • @ismaelsoum6401
    @ismaelsoum6401 14 днів тому +1

    what font are you using?

  • @draakisback
    @draakisback Місяць тому

    I'm a polyglot dev, over the years I've used a lot of different languages and have grown fond of their different abstractions and constructs. That being said, it also depends on the type of language we're talking about. You probably wouldn't want to have higher kinded types in a low-level language given how expensive it would be as an abstraction. A lot of this depends on whether or not you have a garbage collector or not.
    In my opinion, if you're going to point to pattern matching then you definitely can't forget elixirs variant of it. In elixir/erlang, you can do module level pattern matching. In other words, rather than having a really large function with a lot of control flow, you can just have multiple functions with the same name that match on the arguments being passed into them. Staying with elixir/erlang for a moment, actors and supervisors are also really nice language constructs.
    Other useful constructs include higher kinded typing, type covariance and contravariance, defer, function currying, partial application, destructuring, non-nullables, extension functions / methods, type aliasing, lazy application, eager application, opt-in immutability, first class streams/channels/pipes, futures/promises, goroutines/coroutines (green threads), result/maybe/option monads, comptime, hygienic homogeneous macros etc. I'm sure there are more constructs I could think of that I really like but these are the ones that I can think of off the top of my head.

    • @kantancoding
      @kantancoding  Місяць тому

      Great input! Some of these actually almost made it into this video. I will definitely consider them if I make another :)

    • @draakisback
      @draakisback Місяць тому

      @@kantancoding Right on, keep up the good work. By the way just curious, what animation library are you using? I really like how your videos are put together, and I also have my own programming UA-cam channel. I used to just record a live code session and then chop it down into a tutorial but it's way too time-consuming (1 hour of content would equate to about 20 minutes of video after 3-4 hours of editing) which is why I'm looking into other methods of building videos. I'm considering making slides and animations via the 3brown1blue python library or my own bespoke animation library. I figure, writing out some animations and still slides and then recording a voice over would be less time than live coding and editing things down later. Got any opinion on this? Keep up the good work.

    • @kantancoding
      @kantancoding  Місяць тому

      Have you tried manim?

    • @draakisback
      @draakisback Місяць тому

      @@kantancoding I figured that's what you're using. Okay yeah I'll give it a shot.

  • @tietosanakirja
    @tietosanakirja 8 днів тому

    I was introduced to parameter decomposition (as I think it was called) in Haskell.
    There were numerous cases for using it. It could be that a function would return two or more values, and instead of assigning them to a single constant that you'd decompose later to the useful values, you could decompose the values directly:
    a, b = somefunction
    Not only that, but you had more granularity when dealing with larger lists. You could create cases for input parameters and decompose them directly:
    somefunc [ first:rest ]
    or
    somefunction [first:second:rest]
    Finally, apologies for any Haskell pros. It's been a while since I've written Haskell, so my syntax might not be correct. Hopefully I conveyed the idea nonetheless.

    • @kantancoding
      @kantancoding  7 днів тому

      Nice! Interesting stuff. Thanks for sharing 😊

  • @levovix
    @levovix Місяць тому

    I think the most useful feature is macros in Nim. Why? Because in Nim, pattern matching, generator expressions, f-strings, async and more was implemented using just macros.

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

    I would like a part directed to Go's type embedding or Kotlin's delegate which are great tools to favor composition over inheritance. Thanks for the video!

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

      Great point! Thanks for the input. There are a couple more from Go that I wanted to add. Just might make another video.

    • @fabricehategekimana5350
      @fabricehategekimana5350 Місяць тому

      @@kantancoding Thank you !

  • @ibrahimmohammed3484
    @ibrahimmohammed3484 Місяць тому

    Amazing editing and explanation

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

    do you have a link on the list of construct in the video in 0:10 seconds

  • @Vivraan
    @Vivraan 11 днів тому

    Interesting concepts include SkookumScript's (and now UEFN's Verse's) first-class parallel execution primitives.

    • @kantancoding
      @kantancoding  7 днів тому

      The game dev bros always hit me with the wild stuff. Gotta check it out

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

    Operator overloading, which almost any OO language supports.

  • @phillip.dustin
    @phillip.dustin Місяць тому

    Great video, I enjoyed watching. I personally like Python's f strings the most. Their syntax is clear and easy to remember. Although I would be open to listening to other people's takes on this

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

      I actually like Python’s f strings as well. Probably my second favorite. Thanks for watching btw!

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

    Nice video. 't would have been nice to see elm during function composition

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

      Great suggestion! Maybe in the next one :)

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

    I'd say variables and consts are even more useful, and arrays or even better associative arrays :) And boolean operators are very useful too. Not sure if I really had to ever use a generator in production code at work.

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

      Of course you are correct but I opted to leave out the obvious language constructs for obvious reasons 😊

    • @AllanSavolainen
      @AllanSavolainen Місяць тому

      @@kantancoding you even forgot about recursion ;)

    • @kantancoding
      @kantancoding  Місяць тому

      lol did I?

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

    7:57 that would require some compiler preprocessing to do. Besides, how does it determine in which way to stringify the value? What if i want a hexadecimal representation of an int?

    • @greasedweasel8087
      @greasedweasel8087 Місяць тому +3

      Every programming language worth its salt lets you specify formatters a la C’s printf.
      For example the python code
      s = f”A plus B in hex is {a + b:x}”
      uses the f before a string to make it a formatted string, and takes the expression in braces and divides it up by the colon. The left half is an expression which can be evaluated (here it’s the a + b), and the right half is a format string which specifies hexadecimal (here it’s the x).
      By and large just about any kind of formatting can be done, like left and right alignment, different bases, so on and so forth in any language that supports this

  • @kimjong-un8543
    @kimjong-un8543 Місяць тому

    What a nice fucking video. I love the vibe in this video, and the concept too. Looking forward to more videos

    • @kantancoding
      @kantancoding  Місяць тому

      Thank you! More videos coming soon :)

  • @KikkerFish
    @KikkerFish 23 дні тому

    Sick graphics ❤

    • @kantancoding
      @kantancoding  20 днів тому

      Thanks mate! And thanks for watching 😊

  • @apestogetherstrong341
    @apestogetherstrong341 Місяць тому +3

    Missed Clojure macros and erlang actor model. It’s expected.

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

      Thanks for the input. It will help for the next video :)

    • @apestogetherstrong341
      @apestogetherstrong341 Місяць тому

      @@kantancoding If you do a video on any of these topics, then I better subscribe to check it out!

  • @AyushKumar-md9ut
    @AyushKumar-md9ut Місяць тому

    pattern matching as you described sounds like inheritance. is there more to it than just a different syntax for instantiating abstract types with concrete implementations?

    • @secretzpt176
      @secretzpt176 Місяць тому +3

      For Rust he showed you pattern matching on enums, so you can add functions to enums and provide different functionality for each enum by pattern matching.
      But pattern matching goes beyond this, let's say you have a character and you want to know if it's a number, you can pattern match the character to 0..=9 which means any character from 0 to 9 (inclusive because of =). It's about matching a pattern and executing code based on it. I wouldn't think about languages like Rust in terms of OOP.
      The Rust Book and Rust by Example Book are great free resources that you can use to learn more about this.

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

      it has nothing to do with inheritcance. At least the Haskell one. Its just syntax feature and you can unwrap really deep into a nested data type using pattern matching in haskell.
      for example if you have:
      data NestedType = Constructr1 Maybe (Maybe Int)
      you can do:
      func : : NestedType -> Int
      func (Constructor1 (Just (Just 3))) = 3 * 3
      pretty expressive.

  • @anon_y_mousse
    @anon_y_mousse Місяць тому

    Nice. I didn't know that Kotlin had F-strings by default. I can't say as though I really like the list comprehension transformations, but it looks like Julia and Python have the cleanest for loops. I think for most things, generator patterns are probably the wrong way to go because it's slower, but it depends on what you're doing. I also kind of feel like the trait composition that Rust and a few other languages use makes it more difficult to define and implement an interface. Of course, now I wish I had already learned Kotlin years ago, because who knows what other good features it has that could've inspired me in designing my own language. I decided on F-strings by default not because of being inspired by a language which did, but because Python's F-strings annoyed me.

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

      Good points. Would be interested in knowing more about your language.

    • @anon_y_mousse
      @anon_y_mousse Місяць тому

      @@kantancoding I'll have to remember to post a link when I finally publish it. I'm still working on writing the ARM code generator, so that may be a while yet.

  • @gunt-her
    @gunt-her 27 днів тому

    Python example should use generator/yield pattern, this is faster and more generic than list.append.

  • @hundvd_7
    @hundvd_7 Місяць тому +33

    why do you say enum like it's the name of a goofy side character in Star Wars

    • @garretmh
      @garretmh Місяць тому +5

      It’s because enum is short for enumerable which is pronounced that way. I still prefer “ee•numb” personally though.

  • @mattvr13
    @mattvr13 Місяць тому

    I know it has nothing to do with the video, but, which theme did you use for the Python codes?

    • @kantancoding
      @kantancoding  Місяць тому

      I honestly don’t remember since I changed it since then. It’s one of the default vs code ones so if you just scroll through the dark options you should find it.

    • @mattvr13
      @mattvr13 Місяць тому

      @@kantancoding Oh, thanks! I'll check then

  • @trannusaran6164
    @trannusaran6164 Місяць тому

    macros and metaprogramming are cool too :)

  • @dainxor
    @dainxor Місяць тому

    Can you share that list? I'd really like to dive more into the topics, maybe try and make a language that englobes all those features and see what comes out ¯\_(ツ)_/¯

  • @jesseparrish1993
    @jesseparrish1993 Місяць тому

    I want list comprehensions in Go D:

    • @bjarne431
      @bjarne431 23 дні тому

      My favorite feature of Go is probably the easy cross compilation :-)

  • @voicedmemes6251
    @voicedmemes6251 Місяць тому

    Generatoe Expressions are RAD!!!!! (i never used them tho)

  • @thefanboy3285
    @thefanboy3285 Місяць тому

    Correct me if I'm wrong but the way I understood it, the pattern matching in Haskell is "genius-ingly" _"just"_ polymorphism outside of OOP, right ?

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

      no, it's like a beefed up switch

    • @thefanboy3285
      @thefanboy3285 Місяць тому

      @@yjlom the difference between this beefed up switch and polymorphism being ?

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

      In inheritance based polymorphism, anybody can create its own shape as long as you implement the abstract methods (it would be area in the example). With tagged union (or enum or sum types), you can't because the set is fixed. In the video example, you can't add a square after defining the shape type.
      Note: I am simplifying a bit here because there are other ways to do polymorphism in OOP and some languages have features to disable inheritance.

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

      ​@@thefanboy3285
      valid Haskell, invalid Java:
      and :: Bool -> Bool -> Bool
      True `and` True = True
      _ `and` _ = False
      boolean and(bool true, bool true){return true;}
      boolean and(bool default, bool default){return false;}
      invalid Haskell, valid Java:
      talkTo :: Cat -> String
      talkTo c = "Meow"
      talkTo :: Dog -> String
      talkTo d = "Woof"
      String talkTo(Cat c){return "Meow";}
      String talkTo(Dog d){return "Woof";}

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

      @@yjlom i have no idea what you just wrote

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

    And scala has all of them :3

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

    2:44 as a java dev, this is cursed. Like, soooo freaking cursed, I see what is achieved with this but the syntax is just cursed and I hate it

    • @jessedo2668
      @jessedo2668 Місяць тому +3

      You are used to Java syntax, so something different just looks odd to you. I know both languages and I find the Haskell syntax to be much better, much more readable.

    • @jackomeme
      @jackomeme Місяць тому

      @jessedo2668 yeah you're right, in java you would create a Shape interface that defines a calculateArea method which will be implemented in the child classes, here the syntax just looks like you're casting a Shape into a Circle or a Rectangle, I know that it achieve exactly the same thing but it really seems cursed to me hahah

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

      Yeah good points. Polymorphism is a bit different imo but I didn’t go deep enough with the example to really show why.

  • @cryptonative
    @cryptonative Місяць тому +10

    enUm

    • @kantancoding
      @kantancoding  Місяць тому +9

      Tomato tomato 🇺🇸

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

      @@kantancoding I was about to say "it's short for enumeration!!!!!!" but then I realised how enumeration is actually pronounciations implies enum should be pronounced your way. I still think you're wrong though

    • @kantancoding
      @kantancoding  Місяць тому

      I'm ok with being wrong 😉 I actually don't think either way is wrong. I've heard it both ways but I use the way that feel natural to me which is likely just a result of my accent

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

    What font is this

    • @kantancoding
      @kantancoding  Місяць тому

      In the description

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

      @@kantancodingi didn't see any font mentioned in the description

    • @judef
      @judef 19 днів тому

      @@kantancoding there’s no font in the description

  • @stretch8390
    @stretch8390 Місяць тому

    Nice idea for a video.

    • @kantancoding
      @kantancoding  Місяць тому

      Thanks! I’m glad you think so :)

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

    I would like to add implicit interfaces, it might seem like a small feature in Go for example, but the implications on the way you can design code is enormous.Your higher abstractions can define what they require, and along with dependency injection you have no coupling to lower dependencies at all, it is up to the caller to provide what is required and badabing it works.

    • @kantancoding
      @kantancoding  Місяць тому +3

      I actually almost added how the combination of implicit interface implementation and being able to assign methods to types makes cool things possible in Go but it would have taken like 6 minutes to explain 😂
      But now after reading your comment I’m regret not adding it 🫠

    • @RoyRope
      @RoyRope Місяць тому

      @@kantancoding Understandable! Nice video nonetheless mate.

  • @foxwhite25
    @foxwhite25 Місяць тому +4

    Honestly, iterator is imo easier to read and write than list comprehension

    • @theycallmesloth
      @theycallmesloth Місяць тому

      +1.
      In rust we can do just do
      (0..100).filter(|x| x**2>3).map(|x| x*2)
      much easier to read and understand imo

    • @samuraijosh1595
      @samuraijosh1595 Місяць тому

      no way

  • @aarohgokhale8832
    @aarohgokhale8832 Місяць тому

    Haskell does it all

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

    In your python code example in the thumbnail, you can do it in one line, it's called List Comprehension.

    • @kantancoding
      @kantancoding  Місяць тому

      Bro, stop trolling me 😂

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

      @@kantancoding You little bellend, I was simply being a good Samaritan to point out your mistake. You could use a one liner list comprehension in python to accomplish the same.

    • @kantancoding
      @kantancoding  Місяць тому

      😂 is that so?

    • @reitrop6273
      @reitrop6273 Місяць тому

      @@kantancoding Yup. S = [2*x for x in range(100) if x**2 > 3]. Does exactly the same thing.

    • @kantancoding
      @kantancoding  Місяць тому

      Oh you’re right! I had no idea. Thanks bud.

  • @vikingthedude
    @vikingthedude Місяць тому

    What font is this? So i can avoid it

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

    “Sir you can’t smoke that here!”
    “Function”
    “Seriously, stop!”
    “Function(() => double_it_n_give_to_next_person())
    😂😂😂

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

    Kotlin GOAT

  • @Langorithmic
    @Langorithmic Місяць тому +4

    doesn't the inclusion of first order functions imply higher order functions and therefore composition?
    feels like you're listing out consequences of the first item to fatten out the list

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

      I wasn’t trying to “fatten out” the list since the size of the list is arbitrary. I was just trying to show how some constructs can build on top of others. I did something similar with generators and list comprehension. It just felt more intuitive that way.

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

    Destructuring

  • @vannername8413
    @vannername8413 Місяць тому

    Good video!

  • @vectorlua8081
    @vectorlua8081 Місяць тому

    In all fairness, enumberable isn't pronounced e-numb-berable

  • @porky1118
    @porky1118 21 день тому

    2:10 First feature C doesn't support :)

    • @kantancoding
      @kantancoding  20 днів тому

      Much respect for my C bros out there

    • @elpower5226
      @elpower5226 18 днів тому

      It does with function pointers

    • @porky1118
      @porky1118 17 днів тому

      @@elpower5226 Everything until that point. But not pattern matching. Because that's mostly a syntax feature.

  • @ehfoiwehfowjedioheoih4829
    @ehfoiwehfowjedioheoih4829 Місяць тому

    Someone on 4chan made an edit that made you look like you did a really bad crime in Japan

  • @rico_1617
    @rico_1617 Місяць тому

    Most useful construct in C is not even in C, it's __attribute__((cleanup())).

  • @SphereofTime
    @SphereofTime 13 днів тому

    List 0:11

  • @JaredQueiroz
    @JaredQueiroz Місяць тому

    I haven't understood sh*t, god I hate being a beginner.

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

      You'll get there brother! Join the discord if you need support!

  • @patfre
    @patfre Місяць тому +8

    4:27 acting like this is a construct that is enum specific and comes from rust is criminal. This is discriminated unions and is a functional programming construct and can be found in many languages and has nothing to do with enums rust simple combined it

    • @StopBuggingMeGoogleIHateYou
      @StopBuggingMeGoogleIHateYou Місяць тому

      He didn't, though, he covered Haskell first.

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

      The construct that I am talking about is Pattern Matching. Pattern Matching in Rust uses enums. Just because in Rust, discriminated unions are typically implemented using enums, doesn't mean that I am saying that discriminated unions are enum specific or that they come from Rust. I honestly don't even see how you came to that conclusion...

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

    Show me an actually used language that doesn't have some concept of passing functions around as values!

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

      Pretty sure C doesn't have first class support for functions. Compiler extensions exist that improve that, but that's compiler specific and not a part of the language itself.

    • @ehotblch9602
      @ehotblch9602 Місяць тому

      @@nsshurtzThere are function pointers, but they are annoying to use

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

      Yeah imo function pointers don’t count. I’ll definitely pass 😂

  • @HuhuHeyHey-kh2nr
    @HuhuHeyHey-kh2nr Місяць тому

    nice bideo

    • @ackmandesu8538
      @ackmandesu8538 26 днів тому

      Spelling so bad youtube is offering to translate this to English

  • @interstella0
    @interstella0 Місяць тому

    what's the difference between kotlin's string interpolation and python's? I find that python's ability to customize that behaviour a lot more useful. There's a whole mini language spec for instance, f"{2 / 3:.2%}" -> 66.67%

    • @kantancoding
      @kantancoding  Місяць тому

      I think they're pretty similar actually. I too am a fan of Python's f strings :)

  • @FireDragon91245
    @FireDragon91245 7 днів тому

    Lua proxy tables

  • @obinnaokafor6252
    @obinnaokafor6252 Місяць тому

    C# ❤❤❤

  • @thekwoka4707
    @thekwoka4707 28 днів тому

    Eenoom....eenoom

  • @cern1999sb
    @cern1999sb 26 днів тому

    Enoom

  • @igorthelight
    @igorthelight Місяць тому

    0:08 - looks like that list is just an HTML-like file. Why would you compile it? ;-)
    We humans could interpret it on the fly!

    • @kantancoding
      @kantancoding  Місяць тому

      Woah woah… I wouldn’t touch HTML.

  • @IgorB-371
    @IgorB-371 Місяць тому +1

    C#, which has all of these, is purposely ignored 👌

  • @TheSwissGabber
    @TheSwissGabber Місяць тому

    "most useful"
    why is doubleAfterSquare(3) more usefull then double(square(3))
    if you are desperatly looking for a selling point of your compose function maybe ..

    • @Kebabrulle4869
      @Kebabrulle4869 Місяць тому +5

      Not that example specifically, but being able to treat functions as variables is amazing in general.
      I wrote a differential equation solver for a university project once. There are lots of methods to do that numerically (approximating solutions) like Euler's method, AM2, AM3, AB2, AB3, BDF-2, and more. I could then implement one step function for each method, and one solve(...) function that took one of the step functions as an argument as well as initial conditions, and then it took steps until it was done. I think I even made it a generator, so I didn't have to save the entire list of potentially 100,000s of steps if I just wanted the max y value or something.
      In general, it's a great tool to make template functions and separate out the specifics into their own functions.

  • @re1konn
    @re1konn Місяць тому

    apart from python's list comprehensions, everything else in the video is present in almost all functional programming languages.

  • @pullup3041
    @pullup3041 Місяць тому

    c# linq

  • @AslamNazeerShaikh
    @AslamNazeerShaikh Місяць тому +3

    C# is best ❤🎉

    • @orterves
      @orterves Місяць тому +3

      Certainly is pretty good now. Hopefully it finishes stealing everything good from F# and becomes perfect

  • @relt_
    @relt_ Місяць тому

    4:57 That looks unreadable and crammed

    • @thekwoka4707
      @thekwoka4707 28 днів тому

      Absolutely. It's terrible compared to just iterator methods.

  • @thekwoka4707
    @thekwoka4707 28 днів тому

    List comprehension is a crime against god and mand.

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

    A bunch of stuff nobody really cares about. Most of that is already included in most practical languages or not included due to their poor/lame implementationability/readability.

    • @mskiptr
      @mskiptr Місяць тому +5

      Embrace the status quo! Nothing good will ever happen in the future

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

      Higher Order Fuctions are basically functions dealing with Function-Pointers in C, you just wouldn't call them Higher-Order function in C.
      qsort() from the standart-library is a Higher Order Function, as it takes a pointer to a compare-functions as argument.

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

    1:39 This is nothing useful and also dangerous because self modifiable code is undebuggable and prone to errors

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

      can you say the same between (x) => f1(f2(f3(x)))
      and (x) => { let y = f3(x); return f1(f2(y)); } ?
      composition just hides 1 level, and makes it much easier to read and less prone to errors when used correctly. i dont know how it is less debuggable, when you can easily plug in debugging function into the composition, or use debugger to step in and out, and stack is preserved with exceptions. i am not sure what self modifiable means.

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

      This is basically a macro in C. In fact the function feof() from stdio.h is often implemented as a macro reading from the FILE structure.
      While macros are indeed hard to debug, they aren't really self-modifing code.
      In fact self-modfien code fell out of fashion - It was a MS-DOS era thing. Nowadays you have either UNIXoid high end computers that deny write acces to code, or low-end embedded systems that have the Code (as hardvard-architecture) in ROM.

  • @relt_
    @relt_ Місяць тому

    2:16 this whole section makes zero sense. I think you meant to talk about vtables instead of "combining constructors"

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

      The section makes all the sense and in fact has absolutely nothing to do with vtables or inheritance.
      Discrimminated unions are just a single interger (to flag which case it is) and the corresponding data. Since the type as a whole needs to be constant size in compiled langauges, the size is the size of the discrimminator + the size of case-data with the largest size.
      Any operation reading that data just checks the discrimminator to determine how to interpret the data and what actions to take.
      No vtables necessary.

    • @relt_
      @relt_ Місяць тому

      @@mkwpaul that's even worse than vtables!

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

      ​@@relt_ Its actually much better since know you can pass the data around on the stack, instead of the heap.
      Vtables also don't solve the issue of wanting to pass data around that can be one of multiple different possibilities. No need to involve multiple levels of indirection and function pointers just to access data, so its much easier for a compiler to optimize too.
      The whole video is about broadening your horizons. Maybe try understanding how being able to simply and efficiently model a choice between a closed set differently formed data is useful for programming.

    • @samuraijosh1595
      @samuraijosh1595 Місяць тому

      @@relt_ no it performs better than vtables.