Write AWESOME Code With These 3 Functional Programming Concepts

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

КОМЕНТАРІ • 156

  • @ArjanCodes
    @ArjanCodes  11 місяців тому +2

    💡 Get my FREE 7-step guide to help you consistently design great software: arjancodes.com/designguide.

  • @MTT818
    @MTT818 2 роки тому +151

    I encourage you to come up with a full production series, which could be couple of dozen of videos but would be extremely useful. Considering a simple application deployment and put it in production with all software design consideration, such as how to put together all pieces of a software in production such as dockerization, traffic balance, and maintenance, CI/CD all on cloud of course, I offer my help if needed. Thank you!

    • @aflous
      @aflous 2 роки тому +5

      That would indeed be amazing. Happy to help too if needed

    • @ArjanCodes
      @ArjanCodes  2 роки тому +83

      In principle, that’s a good idea. Unfortunately, it’s really not suitable for UA-cam as the algorithm favors videos that stand on their own (even the 2 or 3 part miniseries I post from time to time do less well than my standalone videos). I am thinking of offering something like this as an online program though.

    • @ndiegow1
      @ndiegow1 2 роки тому +13

      @@ArjanCodes I would love to buy a complete course.

    • @digiryde
      @digiryde 2 роки тому +5

      @@ArjanCodes In the Python World, Using Django, it would be possible to build several stand alone apps that could be tied together. Though, that might still be too niche.
      Whatever you do or not, you are doing a great job. Thank you.

    • @muhammadiqbalbazmi9275
      @muhammadiqbalbazmi9275 2 роки тому

      @@ArjanCodes yeah this would be a better option to have a complete course end to end.

  • @kycklingmannen931
    @kycklingmannen931 2 роки тому +53

    You have one of the best UA-cam channels for Python programming. You always provide clear explanations and show code examples of why you are changing anything. I am always happy to see new videos from your channel. Thank you for making videos!

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Thanks so much Nathan, glad it was helpful!

    • @ddctechinstitute6861
      @ddctechinstitute6861 Рік тому

      Not just for python programming but software engineering as a whole. You can apply this principles to any language all you need do is learn with an open heart not a syntax or language oriented.

  • @asif.haswarey
    @asif.haswarey Рік тому +7

    The 3 ideas:
    *#1*
    4:54 : Group side effects and use pure functions.
    8:46 : Functions or methods should have return values that only depend on the input parameters.
    9:23 : Functions or methods should return consistent results for their respective input parameters. For example, for function F, input I and output O, i.e. if I = 3 and O = 5, every call to F(3) should produce the output of 5.
    *#2*
    11:18 : Functions are first-class citizens. What can you do with functions? You can compose them, deconstruct them, pass them to other functions (as parameters), and return them as "values" from other functions. Higher-order functions take input parameters as functions and return functions.
    14:32 : Partial functional application. Create a new function from an original function with some of the input parameters already applied. Frequent use of this will make the code less readable.
    *#3*
    16:52 : Use immutability to your advantage.
    In imperative languages (Python), variables can be accessed/changed anytime. Where as, in declarative languages (Excel), variables are generally bound to expressions and keep their value for the entire life of program execution. Immutability helps with resource sharing in use cases which employ concurrency and parallelization. Ref: Concurrency is not Parallelism by Rob Pike. Immutability eases unit testing.

  • @JosephLeeHS
    @JosephLeeHS 2 роки тому +9

    The `greet_list` method/function can be improved using lazy evaluation, turning it into a generator function with the `names` argument as an Iterable. This is particularly useful if you need to read your names from a large file or database table.

  • @jindy94
    @jindy94 2 роки тому +9

    Just wanted to say that you really have inspired me to write much much better code now as a machine learning engineer and really elevated not just my capability but my passion in coding design. It is really so satisfying to produce lean and efficient code!!!

  • @MrBachianas
    @MrBachianas 2 роки тому +17

    Yes! Great stuff. Keep the FP in Python content going, it's almost impossible to find (:

    • @ArjanCodes
      @ArjanCodes  2 роки тому +2

      Thank you MrBachianas, will do!

  • @molomono9481
    @molomono9481 Рік тому +1

    First video i watched of yours i had to quit because it was to advanced for me at the time. But still needed to refactor my code so i watched the Code Smells series and it changed the way i program python. After just 2 weeks time my code has had immense progress, in development, maintainability and reusability and that speeds up my overal production time. Huge thanks for all your material, now i am able to follow the more complicated videos as well.
    I love that the material covered is Theory in Practice, because i've read about polymorphism and hashtables and all kind of datastructures and coding principles. But you just say what it is you are going to do, then show it and explain why with just the right amount of jargon involved for me to go read more about it if i want, but not get distracted or confused. Thank you so much!

    • @ArjanCodes
      @ArjanCodes  Рік тому

      Thank you so much for sharing this! I'm glad that my videos are helpful :)

  • @yeetdeets
    @yeetdeets 2 роки тому +8

    F2 allows you to rename all occurrences of a variable within a scope at once. Thus you don't need to rename the uses of the parameter when you rename it.

  • @memsb1
    @memsb1 2 роки тому +2

    Don't let your view count determine your worth. These videos are really valuable to all that watch

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks Marty, happy you’re enjoying the content!

  • @esteenbrink
    @esteenbrink 2 роки тому +4

    Maybe it's just a detail, but when you said using the callable Greeting reader in the greet_list list comprehension, it will call the callable for each instance of the result list which will use different datetime instances.

  • @williamduvall3167
    @williamduvall3167 Рік тому

    I am a lone python programmer/environmental engineer with all types of python tools I use day to day. These videos have been the sweet spot to make these tools better. I just became a member, thanks!

    • @ArjanCodes
      @ArjanCodes  Рік тому

      Glad you like the content and thanks for becoming a member!

  • @esiarpze7908
    @esiarpze7908 Рік тому +2

    Great video! Just a suggestion - It’d have been nice if you could have run a profiler after every version of code change you made. Maybe in the future ones you can do a performance analysis also side by side.

  • @pro100tom
    @pro100tom 2 роки тому +2

    Thank you for the demo, ideas behind functional programming and scenarios when it is feasible to apply it.
    I have noticed you example about shuffling cards and I still believe mutable approach can be better due to the fact that it is more intuitive for humans - we don't end up with another deck after shuffling. I, myself, try to carefully pick the right tool for the right task.
    I guess, a good advice for new developers would be not to perceive every problem as nails, when they've discovered a hammer.
    Great video!

  • @Mutual_Information
    @Mutual_Information 2 роки тому +7

    Love the topic! If anyone needs evidence that functional programming is a powerful paradigm, consider JAX.
    JAX is Google’s most recent bet on a neural network framework. It’s their contended with PyTorch and, beyond that, it’s designed to major shortcoming of frameworks in general: speed and reproducibility. And JAX (written in Python) is a effectively all functional programming tool. Everything is a function.

  • @2010edward1978
    @2010edward1978 2 роки тому +6

    Thank you, it was very interesting! Another related topic could be about balancing OOP and FP in Python.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thank you Eduard, and great suggestion ;).

  • @paulbird2772
    @paulbird2772 2 роки тому +6

    The partial function is interesting, would be great to show how using would make some existing code easier to read and or more concise. (probably needs a more complicated example). I can understand what it is doing from your clear explanation, but can't really see why I would need it.

    • @ian4175
      @ian4175 2 роки тому +3

      I don’t know if this is exactly the same, but I’ve found that partial functions is nice for having a single source of truth (or functionality in this case I guess). I’m my case it was in JS and went something like this:
      // NOTE: simplified for example (also copying into an IDE will make it easier to read)
      // most general form of fetching data
      function runFetch(baseUrl, endpoint, method, params, data) {
      // makes request to api using inputs
      }
      // Used specifically for user data
      function runUserFetch(endpoint, method, params, data) {
      return runFetch('userDataApi.com', endpoint , method, params, data)
      }
      // Specifically for GETting user data
      function getUser(endpoint, params) {
      return runUserFetch(endpoint, 'GET', params, {})
      }
      // Specifically for GETting a users friends
      function getUserFriends(params) {
      return getUser('/friends', params)
      }
      // Specifically for POSTing user data
      function postUser(endpoint, params, data) {
      return runUserFetch(endpoint, 'POST', params, data)
      }
      // Specifically for POSTing a users login time
      function postUserLoginTime(endpoint, params) {
      return postUser(endpoint, params, { loginTime: Date.now() })
      }
      As you can see with each new, more specific, function we make we reuse the more general form and set some input to a static value.
      This to me has one major upside, and that is EVERY time we fetch data we end up calling the same function (runFetch) and so now if we want to add something, (like maybe a cache or something), all we have to do is modify that single function to add that new feature. Or if we wanted to debug an issue with data fetching we only have to print out data in one place.
      TLDR: Starting with a general function, with lots of input options, we create more and more specific functions by calling the general form with some function specific input options. This allows us to have a single source of functionality so that if we ever want to modify that we only have to change one function.
      PS: This is just what Ive picked up along the way, not saying this is best practice or anything.

  • @chuxmyk
    @chuxmyk 2 роки тому +2

    It’s the Vim extension for me. I love VSCode and Vim and extension gives you the best of both worlds 🔥🔥

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Thanks Chuks, happy you’re enjoying the content!

  • @asdrubalivan18
    @asdrubalivan18 2 роки тому +1

    I'm currently learning Haskell as a way to learn functional programming to apply it to Python and Typescript! This is very useful!

    • @scotttang6229
      @scotttang6229 2 роки тому +1

      You can use Ramda for JS or Lodash/FP. Those are very good to use with functional pattern with JS/TS. It's a bit more work using those libraries with TS though. But it's very doable.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Thanks so much, glad it was helpful!

  • @rcc420
    @rcc420 Рік тому

    Hey dude. Thank you very much for the knowledge you drop in this channel. I work as a DevOps engineer and I find your channel super useful in my quest to improve my python skills. You're the best !! Thanks. Keep up the good work and spread the knowledge, so we can all become better engineers. Cheers!

  • @user-hf5be1zu7s
    @user-hf5be1zu7s 2 роки тому

    I could have gone out with my friends, but seen you have uploaded so I had to stay and watch. I am so happy I stayed for the video, your content is just golden and your advice is solid. Truly a diamond, I am so happy I came across your channel, It means a lot for me. thank you!

  • @marcosdiez7263
    @marcosdiez7263 2 роки тому +2

    Nice explanation. I'm new to Phyton yet experienced in other languages and paradigms (in 35 years or experience I took pride of studying paradigms and trying to combine them). I believe the word you wanted to describe the lack of side effect as a feature is "deterministic", which implies that a function produce the same outcome when given the same parameters.
    This is used in many declarative and functional languages behind the scene to cache responses and eventually choose between the cost of calling a function again with the same parameters and the cost of storing the response to return it again instead. For instance, Most SQL servers attempt (but may fail) to tell appart deterministic from non deterministic functions to do this and cache functions responses, and in some scenaries involving grouping data and aggregate functions this may lead to unexpected outcomes and to solve them, anti intuitively you need to pass as parameters the colums making an unike key to each row even if the function doesn't use them internally to "couple" your function determinism to the rows for which you expect it to be executed and cached.
    In the other hand, I believe someone surely implemented the idea of caching function responses in Phyton for high cost algorithms like telling when a number is prime or calculating large factorials, and if not, it'd be a great programming excercise for an application of deferring a function with Callable or another better mean that I suspect may exist and I am still unaware of.

    • @clementdato6328
      @clementdato6328 2 роки тому

      I think side effect also includes cases of mutating states outside of its inputs and outputs and local variables. For example, Python list append always returns None except exceptions. It is “deterministic”, but it is not side-effect-free.

    • @zl4518
      @zl4518 2 роки тому

      I believe there's a cache decorator under the functools module

  • @codewithray
    @codewithray Рік тому

    You are a legend man. Very informative tips. Keep it going !!!

  • @mikec64
    @mikec64 2 роки тому +2

    I really appreciate your videos but I lost the thread here on the value of higher order functions. For me, your example made the syntax clear but the example code became harder to read without any clear advantage. I'm going to watch this a few more times because it feels like an important step for me to learn, but I hope you'll give more time to use cases in the future.

  • @brothercaleb
    @brothercaleb Рік тому

    Top level stuff. Thanks Arjan! 👏🏽👏🏽👏🏽👏🏽👏🏽

    • @ArjanCodes
      @ArjanCodes  Рік тому

      Thanks so much, Caleb glad the content is helpful!

  • @UNgineering
    @UNgineering 2 роки тому +3

    Functional programming is not given appropriate attention in schools these days. It is huge for code test-ability. Excellent video as always.

  • @golammuhaimeen2825
    @golammuhaimeen2825 2 роки тому

    this was such a great demonstration Arjan! Thanks so much! Loved it.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thank you Golam, glad you liked the video!

  • @jessexing3456
    @jessexing3456 5 місяців тому

    thank you, always learning a lot here

    • @ArjanCodes
      @ArjanCodes  5 місяців тому +1

      Glad to hear! I'm always happy to be part of people's learning journeys.

  • @hcubill
    @hcubill 2 місяці тому

    Excellent Arjan! Do you test main functions as well?

  • @presstv
    @presstv 2 роки тому

    this functional programming video is so informative. thanks Arjan

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks so much, glad it was helpful!

  • @miniappletheapple
    @miniappletheapple 2 роки тому +1

    Great vid, it would be nice if most of OOP programmers know

  • @abdelghafourfid8216
    @abdelghafourfid8216 2 роки тому +4

    while I do agree that doing immutable operation might simplify the code desing and testing. But in some contexts it may impact the performance, for instance in pandas usually the immutable operations take more time as they require making copies of the dataframe each time. So one sould keep this also in mind.

    • @user-lk1fw1lp8b
      @user-lk1fw1lp8b 2 роки тому

      It is not our problem to solve. Languages should be optimised for these scenarios.

    • @karserasl
      @karserasl 2 роки тому +1

      Thats pandas problem. In functional programming, these data structures were rewritten to be efficient, they just keep a copy of things that modified, not the whole structure.

    • @user-lk1fw1lp8b
      @user-lk1fw1lp8b 2 роки тому

      @@karserasl object-oriented languages were initially designed for people who coded in C with all of its beatiful features. OO languages came, but the thinking remained imperative.

  • @Celestialzzz
    @Celestialzzz 2 роки тому

    Another amazing video. Thank you so much for this!

  • @kopytko998
    @kopytko998 2 роки тому

    Thanks for this video. You are a fantastic teacher.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks Andrzej, happy you’re enjoying the content!

  • @markhathaway9456
    @markhathaway9456 Рік тому

    Excellent example(s). I'd like to see it in Scala too.

  • @fa11en1ce
    @fa11en1ce 2 роки тому

    Thanks for the great content Arjan. I am kind of appalled at the lack of manners some of the commenters have here. Don't worry about them, and keep up the good work!

  • @DrGreenGiant
    @DrGreenGiant Рік тому +1

    I feel like you didn't give a fair argument in favour of mutable, only against.
    Mutable uses much less memory and is much more cache efficient (so faster) than immutable.
    Which one you choose is of course down to the application constraints. But it's very much worth understanding the disadvantages of immutability. Especially with micropython now being a thing on low memory bare metal processors

  • @ymarinho
    @ymarinho 2 роки тому

    Arjan I really like your videos for their teaching skills and competence. Congratulations.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks so much Yves, glad it was helpful!

  • @cetilly
    @cetilly 2 роки тому

    This video is SO so so good!!! Thanks Arjan

  • @NicholasShanks
    @NicholasShanks 2 роки тому +1

    I learnt more about Python than FP from this video. However, I suggest you re-upload this with two edits: only move the current timestamp out of the class; leave the greeting string in there. By moving the greeting string to main() you pollute what should be the 'dirty' function with otherwise pure code. Keep the string code in the lower level functions where they can be easily tested too!
    Secondly, put your data argument last. You had a function to which you passed a list of names and a greeting or greet_fn - swap the argument order. By having data last, you follow the standard function layout of other languages and codebases which don't have variable argument order.

  • @tommybrecher7742
    @tommybrecher7742 2 роки тому

    Thanks @ArjanCodes, great content as usual.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Thanks Tommy, happy you’re enjoying the content!

  • @georgytoporkov2041
    @georgytoporkov2041 Рік тому

    Great video! I wander whether there's also function composition in Python :D

  • @MTT818
    @MTT818 2 роки тому

    Thanks Arjan, your videos are very useful.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thank you - glad you find the videos useful!

  • @againstthegrain5914
    @againstthegrain5914 2 роки тому

    I like this way of coding better.. do you mentor folks?

  • @ethanholz3733
    @ethanholz3733 2 роки тому

    This is a really cool video, thanks!!!

  • @dietermenne
    @dietermenne 10 місяців тому

    Great content - and I could concentrate much better if there was no background music. So I have to "listen" to the subtitles

  • @CayoBuay
    @CayoBuay 3 місяці тому

    Good content, thanks.

  • @albertjose9654
    @albertjose9654 2 роки тому

    Thanks man Great stuff, will you make a video on microservice architechure in python

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Thank you Albert, will do!

  • @mauisam1
    @mauisam1 2 роки тому

    Sorry, I got lost with the Callable decoration and how it works. I looked in you YT for a video on this didn't see one.

  • @MMarcuzzo
    @MMarcuzzo 2 роки тому +2

    What keyboard shortcuts do you use when typing and editing code?

    • @NostraDavid2
      @NostraDavid2 2 роки тому +1

      I remember he said that he used the vim extension, but vim is fucking wild compared to most standardized editors (probably because the origins of vim is from before ctrl-c ctrl-v were a thing - in 1969 the Ed editor was created, which spawned Ex, which spawned vi, which spawned vim, which spawned Neovim and the vscode extension)

    • @NostraDavid2
      @NostraDavid2 2 роки тому +1

      I like using ctrl + left/right arrow to jump over words, which I can combine with shift to make selections. End and Home are nice too.

    • @MMarcuzzo
      @MMarcuzzo 2 роки тому

      @@NostraDavid2 I do that a lot. But I want to powerup even more my editing, if possible. If I notice that's not possible on conventional editors, I'll try different ones

  • @Han-ve8uh
    @Han-ve8uh 2 роки тому

    9:24, "functions/methods should return same if parameter values are same".
    For class methods, what does it mean for self to be the same? Self is something automatically created when we instantiate a class so how to control it repeatably during tests?
    If i remember right, self causes problems during functools lru_cache too since the user may not be aware self (being part of the cached tuple key) is changing.

  • @v0id_d3m0n
    @v0id_d3m0n Рік тому

    Greet doesn't feel like a word anymore. Greet groot.

  • @gmarcosoldo
    @gmarcosoldo Рік тому

    Great video, but the functions names (greeting_reader, greet, etc) got a bit confusing at time tbh

  • @davidsyengo1893
    @davidsyengo1893 2 роки тому

    True python guru!

  • @Jedimaster36091
    @Jedimaster36091 11 місяців тому

    Somehow, I don't see what the purpose of the Greetings class is, after the changes. It doesn't really do anything useful, just returns the provided greeting_intro. As far as I understand, the whole value of the program was to greet the name based on the time of day.

  • @ianbdb7686
    @ianbdb7686 Рік тому

    Question: So if i was making a commercial software where i use the IO package should i override the class and make the output native to the prospective client machine.

  • @weihu-ai
    @weihu-ai 2 роки тому

    Another takeaway I get from this video is that use meaningful aliases for types in type hints to make the codes more readable.

    • @weihu-ai
      @weihu-ai 2 роки тому

      that actually depends. in examples in this video, the argument names already contain information as suggested by the type alias. It might be better to just have the real type in the hint to provide the real signature

  • @joansparky4439
    @joansparky4439 2 роки тому

    Been programming functional in Python since I started with it in 2008.
    I preface my variables with their expected types, so I know what I'm dealing with..
    str_ , int_ , lst_, los_ (list of strings), lol_ (list of lists), dct_ (dict), FLG_, CNT_, dto_ (datetime object), dts_ (datetime string)
    The class stuff that comes with python most often is useful. But I myself seem somewhat incapable to create/use it for what I do.. which pretty much boils down to run csv like data conversion/modification and displaying.
    Nice content.

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks so much, glad you liked it!

    • @raphaels2103
      @raphaels2103 2 роки тому +1

      Do you continue to do that with type hints?

    • @joansparky4439
      @joansparky4439 2 роки тому

      @@raphaels2103 you mean do I stick with the practice? Yes. It's helpful to me.. so I keep doing it.

  • @JohnJohnson-dl8oq
    @JohnJohnson-dl8oq 4 місяці тому

    I understand the benefits of FP, but in the first example the knowledge of how to greet went from nicely encapsulated in the class, to spread out between the class and main. There is little need for the class anymore.
    Perhaps this example was just intended to be a segue to the rest of the video.

  • @edgeeffect
    @edgeeffect Рік тому

    I have to be VERY careful not to commit code with strings like "Bugger off!" in them... every time I push my branch there's a little tingle of fear that I might have "said" something I shouldn't.

  • @kishorecharandhuli9137
    @kishorecharandhuli9137 Рік тому

    Excellent….!!!!!!

  • @AnthonySherritt
    @AnthonySherritt 2 роки тому

    Love this!

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks Anthony, happy you’re enjoying the content!

  • @pieter5466
    @pieter5466 Рік тому

    What's going on in line 12 `greetings: list[str] = []`, not sure I've seen that before?

  • @szeredaiakos
    @szeredaiakos Рік тому

    And what are the downsides of working with immutable data?

  • @slhcn8609
    @slhcn8609 2 роки тому

    Is that a kind of complaint? Who said "Bugger off" to you :) thanks for your efforts!

  • @ewerybody
    @ewerybody 2 роки тому

    Hej Arjan! I generally really like your style and enjoy your videos. But the greeting code example seemed rather artificial. I could see that it all works but the benefits were not clear. I mean it seemed it makes everything much more complicated but for what reason? 😐

    • @ewerybody
      @ewerybody 2 роки тому

      Sure testability is most obvious: Maybe show a tiny unittest to make clear that its cumbersome to test for expected output.

  • @dmytrokorbanytskyi1586
    @dmytrokorbanytskyi1586 2 роки тому

    I really like it, thanks!

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks so much, glad you liked it!

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

    why is reading from a file considered a side effect? If the function just reads from the file without writing to the file, the original file is unchanged so where is the side effect?

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

      Reading from a file is considered a side effect because this task depends on the external state of the file system. The content of the file might change between different reads, which means that the function performing the read operation doesn’t always produce the same output for the same input (the file name or path). It also involves interacting with an external system (the file system). This can have side effects such as I/O operations that affect performance or potentially lead to I/O errors, which the function then needs to handle.

  • @deepakpune1
    @deepakpune1 2 роки тому

    is this similar to separation of concern ?

  • @oreychandan9229
    @oreychandan9229 2 роки тому

    Yo you did it!

  • @rianderous8761
    @rianderous8761 2 роки тому +1

    But now, when you put the if elif else statement to define the correct greeting in your main or somewhere else outside the class, essential logic that was inside the class is now spread across the application. I can imagine that this is also something to consider? Would a class method be a good option here? Then you know the code belongs to the greeting class

  • @edgeeffect
    @edgeeffect 2 роки тому +3

    I wouldn't go so far as to say functional is declarative... I'd say it was "closer to" declarative but still imperative.

  • @Terroid
    @Terroid 2 роки тому

    What linter/language server plugin do you use In VSC? It seems to be really strict, I use the Python plugin and pylance, and those 2 aren't so strict like yours
    What other tools do you use??
    Thanks in advance :D

    • @chinin97
      @chinin97 2 роки тому +1

      Pylance as you but has it on strict mode. He has a video about vs code extensions

    • @NostraDavid2
      @NostraDavid2 2 роки тому +1

      Can confirm there's a strict mode. Use ctrl-, to open setting and search for "pylance strict" and it should pop up.

  • @johncarlo4028
    @johncarlo4028 2 роки тому +2

    Is it just me or is it true to everyone else that you look like hopper from Stranger Things.

  • @basedmuslimbooks
    @basedmuslimbooks 2 роки тому +1

    @ArjanCodes, do you have a twin who knows rust? 🤭

    • @avidrucker
      @avidrucker 2 роки тому +1

      I'm also interested to know about this "twin" 😂

  • @halfsourlizard9319
    @halfsourlizard9319 10 місяців тому +1

    FP is a way of thinking, not some 'neat tricks'. You can't just add random ideas from FP to imperative code -- that's like adding vegetables to a meat stew and pretending that you're doing anything like cooking vegetarian food.

  • @sparrowhawkguitarboy
    @sparrowhawkguitarboy Рік тому

    I can’t see the video for the most part 😔

  • @epgui
    @epgui 4 місяці тому +1

    The best thing you can do to improve your python code is to throw it away and try a language that is actually elegant, something like Clojure or Haskell. Yes, there is such a thing as a better language.

  • @raj.svc.google911
    @raj.svc.google911 2 місяці тому

    Python is, unfortunately , a bad choice for teaching functional programming, primarily because it is statement-based, and not expression-based .

  • @tir0__
    @tir0__ 2 роки тому

    ❤️👌🏻👌🏻👌🏻

    • @ArjanCodes
      @ArjanCodes  2 роки тому

      Thanks Priye, happy you’re enjoying the content!

  • @deemon710
    @deemon710 2 роки тому +1

    I tried but I definitely wasn't following along by two thirds of the video.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +1

      Until what part were you able to follow the video? When did things start to get fuzzy? Please let me know as this is very useful feedback for me and I can incorporate that in future videos.

  • @seventeeen29
    @seventeeen29 2 роки тому

    Why are you telling people to move complex functionality out of classes? The motivations behind why you're doing this are completely sound but the place where you handle that complex state is a class. That way any dependencies of this functionality can test their own implementations independently to how the shared logic is implemented by replacing the dependency at runtime

  • @stevenhe3462
    @stevenhe3462 2 роки тому +1

    This feels like squeezing in functional programming to Python's object oriented environment… The benefits are obvious. But, it feels unnatural.
    Also, the effort does not produce as elegant code as you get in more functional languages.
    I'm not saying that this is not good. It is. It is Python itself that is very limiting in this regard.
    Try to add monads and you'll see…

  • @user-lk1fw1lp8b
    @user-lk1fw1lp8b 2 роки тому +1

    After he said "OOP is a subset of imperative programming" I stopped watching immediately. This dude does not even understand what he is talking about. If you can't write declarative OO code it doesn't mean that it is not declarative. What a nonsense.

  • @Jebusankel
    @Jebusankel 2 роки тому +1

    Yet another video that creates a straw man of bad code and calls it OOP and then calls the fixed version functional.

  • @muhammadyusoffjamaluddin
    @muhammadyusoffjamaluddin 2 роки тому +2

    2:18 Seriously you use Wikipedia?? Sir? Hello?

    • @ArjanCodes
      @ArjanCodes  2 роки тому +20

      Normally the knowledge is injected into my brain via a neural link, but unfortunately the data was corrupt, so I had to use another resource.

    • @nowyouknow2249
      @nowyouknow2249 2 роки тому

      @@ArjanCodes 😆 🤣

    • @RatafakRatafak
      @RatafakRatafak 2 роки тому +3

      Whats wrong with wikipedia?

  • @MTT818
    @MTT818 2 роки тому

    It would be good to stop using print and start using log since we don't use print almost never in production and I guess everyone needs to learn what is used in real world than just practising things they would never/shouldn't use. Please avoid distributing bad practices.

    • @ArjanCodes
      @ArjanCodes  2 роки тому +8

      I have experimented with using logging instead of print and it was confusing to the audience since extra boilerplate is needed to setup logging.
      I get that using printing as a logging solution is bad practice. But I’d argue that the way I use print is not logging: it’s what the example application actually does.

    • @avidrucker
      @avidrucker 2 роки тому +3

      How about a video just on logging best practices? 👍😁

  • @Klej0aka0Klej
    @Klej0aka0Klej 2 роки тому

    Great video, terrible shirt :)

    • @ArjanCodes
      @ArjanCodes  2 роки тому +11

      In the Star Trek mirror universe, I run a successful fashion channel but I write terrible code.

    • @cetilly
      @cetilly 2 роки тому +2

      The shirt is good 👍🏻