Plain Functional Programming by Martin Odersky

  Рет қаралды 97,231

Devoxx

Devoxx

Күн бұрын

Please subscribe to our KZbin channel @ bit.ly/devoxx-youtube
Like us on Facebook @ / devoxxcom
Follow us on Twitter @ / devoxx
In a short time, functional programming went from an obscure academic endeavor to the technology "du jour" of the software industry. On the one side, this is great, because functional programming holds real promise to simplify the construction of highly reliable software. On the other hand, it is also frightening because the current hype might lead to over-selling and sometimes too uncritical adoption of concepts that have not yet been sufficiently validated in practice. In particular I see with worry the trend to over-abstract, which often leads to cargo-cult technology.
In this talk I give my opinion of what the core of functional programming is that we can and should use today, why that core matters, and where we currently face challenges. I argue for combining functional programming with the principle of least power, for eschewing fancy abstractions, and for being modest in what we can and should express in our programs. I also show how some of these approaches are reflected in our work on the next version of Scala.
Martin Odersky is the inventor of the Scala language, a professor at EPFL in Lausanne, Switzerland, and a founder of Lightbend. His work concentrates on the fusion of functional and object-oriented programming. He believes the two paradigms are two sides of the same coin, to be unified as much as possible. To prove this, he has worked on a number of language designs, from Pizza to GJ to Functional Nets. He has also influenced the development of Java as a co-designer of Java generics and as the original author of the current javac reference compiler.

Пікірлер: 69
@StEvUgnIn
@StEvUgnIn 4 жыл бұрын
Thank you Mr. Odersky for your introduction to Scala programming.
@royalgoose
@royalgoose 6 жыл бұрын
This is genius. I wasn't so excited about implicit functions before seeing this talk, and Martin does an amazing job of explaining why they are useful. Don't get me wrong, this is advanced material, but if you've looked at all the alternatives he does a good job of breaking down why this approach is better. Implicits continue to be given a bad wrap because of their power, but I personally feel like they might be one of the single greatest programming language features to ever be invented. Brilliant abstraction.
@eg4933
@eg4933 10 ай бұрын
this man is amazing and scala should be adapted to high-performance applications as well. Amazing language.
@Moriadin
@Moriadin 3 жыл бұрын
software complexity arises from mortgage-driven development. True story bruh...
@vimalneha
@vimalneha 2 жыл бұрын
To understand Functional programming I found this video to be the best one. In the Java world, it is not that well explained or assumed. One needs to understand a bit deeper and from a different angle. And I agree with Moriadin that Software complexity arises from Mortgage-Driven Development, where some individual keeps the whole company hostage, till everything crumbles under its own weight.
@amigalemming
@amigalemming 4 жыл бұрын
Did he use the grammar of Haskell 98 or of Haskell plus all GHC extensions in 2016? Unfortunately, many Haskell library writers seem to be happy only if they need to enable more than 20 GHC extensions.
@obszczymucha1337
@obszczymucha1337 5 жыл бұрын
I came here looking for an answer to "why is scala overcomplicated"? And then it seems Odersky is asking himself that question too: 12:38
@parakhonskiygleb8509
@parakhonskiygleb8509 4 жыл бұрын
@@klnlkjoinoin when you write it as a closure, you can compose them (with `compose` or `andThen`)
@rentedunicorn
@rentedunicorn 4 жыл бұрын
where can I find the code shown here?
@kevalan1042
@kevalan1042 6 жыл бұрын
What is the appeal of the "receiver functions" DSL? (I understand how it is implemented using implicit functions, but why is it a popular feature in Kotlin/Groovy?)
@bishbashboshjt
@bishbashboshjt 5 жыл бұрын
same reason that JSX is popular for React
@leonk6950
@leonk6950 5 жыл бұрын
Just start using them, you'll understand.
@RomanScherbatyuk
@RomanScherbatyuk 6 жыл бұрын
scala is amazing, looking forward to create some cool project on scala and akka)
@rxshiva
@rxshiva 6 жыл бұрын
i tried this example in 2.10.6 and 2.12 expression not supported, any idea in which Scala version this works.
@mohance
@mohance 6 жыл бұрын
You should try using dotty version - dotty.epfl.ch/. Scala-2.13
@Nicofisi
@Nicofisi 6 жыл бұрын
Dotty is Scala 3.0 though
@bjornkihlberg2103
@bjornkihlberg2103 5 жыл бұрын
5:00 Lisp: "Hold my beer"
@mrdarky3377
@mrdarky3377 4 жыл бұрын
Björn Kihlberg yes! hahaha
@DenisG631
@DenisG631 4 жыл бұрын
Is grammar an indication of complexity? Does it make Haskell simpler than java8? I thought CLOS is a Common Lips Object System or is Martin referring to smth else? `Possibly[Configured[T]]` definition is awesome though
@jaspereijkenboom4716
@jaspereijkenboom4716 4 жыл бұрын
Size of grammar is NOT an indication of complexity, that is precisely his point. He asks "People percieve Scala as being complex. Why do they percieve Scala this way?", he then shows the size of grammar to show that the two are not correlated. Afterwards he makes his real argument: Culture Shock.
@DenisG631
@DenisG631 4 жыл бұрын
@@jaspereijkenboom4716 But people claim Scala being complex, not due to its grammar though. This is exactly my point. When people say language X is more complex than language Y they don't mean complexity(grammar(X)) > complexity(grammar(Y)), because that would imply that Java is more complicated than Haskell (or so it seems, again we are not talking about academic terms, but general developer perception of the langauge). Well, we can talk for hours about what exactly is - complicated. What is its definition. Is it complexity or unfamiliarity. Yet again, the point made was that Scalas' complexity is attributed not due to its simple/complicated grammar, therefore I don't buy that argument.
@sobanya_228
@sobanya_228 6 жыл бұрын
But can you do effects with continuations right now in dotty?
@lucduponcheel
@lucduponcheel 6 жыл бұрын
The implicit "WiFi" (as opposed to explicit "Plumbing") capability of implicit functions really shines! When implementing reader monad transormers (yes, imho they do have their usage) they "just work". I never enjoyed "deleting code and noticing that everything still works" as much!
@alex1476
@alex1476 6 жыл бұрын
Great talk! Looking forward for Dotty compiler to be used in production.
@TheddunTOSS
@TheddunTOSS 6 жыл бұрын
What is the best introduction to Scala?
@gamespazm
@gamespazm 6 жыл бұрын
It was too repetitive to write implicit config: Config, so instead let's write Possibly[Configured... everywhere!
@yevgennerush2793
@yevgennerush2793 6 жыл бұрын
When a function has dependency on M parameters, it is better to write ImplicitFunctionType[T] N times than writing M parameters N times, because 1*N is always less than M*N, where M > 1.
@kevalan1042
@kevalan1042 6 жыл бұрын
To replace the implicit config: Config, you just need to write Configured. In addition, Possibly makes the possibility of exceptions explicit in the types.
@jakemiles999
@jakemiles999 3 жыл бұрын
Strange right? That we replaced three words per method for three other words per method. But the new three words do notably more than the original three words. One is that they remove the side effect of the thrown exception, putting the possibility of failure in the type and therefore not a surprise at runtime. Another is that because the effects are now represented by a type, you can create a type alias for the composite type to make it less verbose, which you couldn't do if you needed to add other implicit parameters to handle other effects. For example, if `Possibly[Configured[Name]]` is too verbose, you can create a local alias `type PC[T] = Possibly[Configured[T]]`, and then the methods return things like `PC[Age]` and `PC[Name]` - less to type and less to read with the same benefits. And that scales to as complex a set of effects as you need: if you need to, for example, read config asynchronously from a remote service, the returned type could become something like `Possibly[Async[Config[Name]]]`. And with a type alias, `type PAC[T] = Possibly[Async[Configured[T]`, the returned types become `PAC[Age]` and `PAC[Name]`. So it scales with complexity much more efficiently in terms of the verbosity of the method signatures.
@kevalan1042
@kevalan1042 6 жыл бұрын
Which editor is he using?
@lorenzotesta9136
@lorenzotesta9136 6 жыл бұрын
visual studio code
@kevalan1042
@kevalan1042 6 жыл бұрын
thanks!
@TheMrTape
@TheMrTape 6 жыл бұрын
The greatest difficulty is dealing with the massive amounts of incompetence within this entire field. It's absolutely riddled with inexperienced programmers and managers having no clue what they're doing; the general structure of development via compartmentalization is bad, the manager needs to be the programmer, otherwise they have no perspective of how a project could feasibly be structured etc. The incompetence mostly stem from school taught programmers, who tend to suck ass because they have no personal interest in the programming itself, they're not interested in exploring it, only to learn the bare essentials and to achieve some result by any arbitrary working method, which among many other fallacies leads to the necessity of shitty OOP, since they have zero overview of what they're doing, and thus needs encapsulation to avoid the inevitable catastrophic results of their blind and spastic-like bashing of their arms onto a keyboard. I still wonder how they ever get anything to compile.
@JMFAudio
@JMFAudio 6 жыл бұрын
TheMrTape oh man so true. Recommend times 1000
@timmark4190
@timmark4190 6 жыл бұрын
Agree. So how does one get the right experience or training.
@demonkoryu
@demonkoryu 6 жыл бұрын
There can be managers who aren't technical experts who still do a great job - maybe a better job than a SE type manager - because they listen to their expert; and then they have the management acumen...
@TheMrTape
@TheMrTape 6 жыл бұрын
Tim, By exploring by yourself and by learning to become your own teacher. Any programmer of just slightly versatile expertise must constantly or at least often consult manuals and documentation of languages, libraries etc. Firstly nobody can remember complex function arguments etc. when they don't regularly use them, and secondly there's constantly new challenges where you need to learn; you can only learn and completely remember a relatively tiny bit of the whole programming spectrum in a lifetime with all libraries, API's etc. considered, so can only take expertise in so much. Get the grammar (syntax) of some language right, then the rest is just looking up definitions (documentation) of the words (functions) you need, when you need them. Use Google like a maniac. Besides just looking up documentation, I can recommend this guy, great teacher and mentor, who pushes teaching yourself: TheChernoProject demon, I agree but it's the minority of cases; managers can definitely be very beneficial if everybody truly knows whats up, but it's often their lack of or understanding that makes them push decisions that aren't beneficial. With loose guidance and by giving freedom to the programmer it can work, just asking them to accomplish some task in whatever way they see best fit.
@Gashdal
@Gashdal 5 жыл бұрын
self taught passionate programmers represent!
@nicholasking2267
@nicholasking2267 3 жыл бұрын
"Here, on page 362, they finally get around to proving that 1+1=2."
@jordanzimmerman7590
@jordanzimmerman7590 6 жыл бұрын
Implicit parameter explosion is one the worst aspects of maintaining Scala code. In larger projects trying to comprehend how to import and understand which implicit parameters are used/needed can be maddening.
@matthewdedetrich6867
@matthewdedetrich6867 6 жыл бұрын
How is this anymore complicated when comparative tools in Java (i.e. Spring) do all of the same work, its just at runtime where as in Scala its at compile time? What do you think stuff like @Autowired does? Its pretty much magic that is all hidden behind runtime reflection
@jordanzimmerman7590
@jordanzimmerman7590 6 жыл бұрын
If that's all it was it would be fine. With tools such as Spring/Guice, the injections are usually pretty clear (but not always). With implicits, you have to import them and the order of imports can change which implicits are used. Then, you can have chains of implicits and on and on. It's much much more complicated.
@jordanzimmerman7590
@jordanzimmerman7590 6 жыл бұрын
I can tell you it happened to me the other day. Spray JSON uses chained implicits. I put an import statement in the class that was using the JsonFormat instance and I got an unintelligible error message. I moved it to the top of the class and it compiles. Also, I'm not defending Guice/Spring. IoC frameworks in Java introduce more problems than they solve.
@Olololsh
@Olololsh 6 жыл бұрын
I've been shot in my leg when i got a completely unreadable error when someone used implicit parameter in implicit function definition. So I'm in agree with Jordan, implicit could be good, but without a certain amount of experience and attitude to smell bullshit - they are completely complexity makers.
@gmnboss
@gmnboss 6 жыл бұрын
Kleisli is plain??!
@spesterwecial
@spesterwecial 6 жыл бұрын
Kofi A No, he does not claim that. On the contrary his argument in the talk is that Kleisli (and by extrapolation monad) is a more complicated abstraction than necessary for the use case of configuration. It violated the “principle of least power”, so he proposes a “plainer” (typed) functional solution which, although it might not yet be familiar, does not require arcane knowledge of category theory.
@ajinkyax
@ajinkyax 5 жыл бұрын
@5:00 why not compare with GoLang , it has type system. Can be written in Functional fusion
@mskiptr
@mskiptr Жыл бұрын
Purely functional programming removes a whole dimension of complexity. It _removes time_ (you can kinda import it back)
@TonyBenBrahim
@TonyBenBrahim 6 жыл бұрын
I wrote a JavaScript interpreter in OCAML a few years ago, and I gave up on this video 15 minutes in. Functional programming is not hard, but I get the impression Scala is hard, if Martin had anything to do with the documentation.....
@philippederome2434
@philippederome2434 6 жыл бұрын
Possibly give it a chance later on. I think he could have spent 3-4 minutes more around 24-27", go more slowly about the details of exception handling. Ideally, this talk could last 50-100% more than it did to be approachable to a wide audience.
@obszczymucha1337
@obszczymucha1337 5 жыл бұрын
I agree. Scala is way overcomplicated. Even Odersky gets confused. 12:38
@leftover7766
@leftover7766 4 жыл бұрын
@@obszczymucha1337 How are you at giving talks in your third or fourth language? Scala is complicated enough to be able to use math to the greatest extent when solving programming problems. Not using math (mostly because shortcuts taken in setting up the language/environment that the problem is solved in) is the source of all bugs in s completed, shipped program.
@vetiarvind
@vetiarvind 2 жыл бұрын
This is silly. Kleisli is part of other FP libraries like cats or scalaz. It's not part of core Scala.
@clarkie132
@clarkie132 6 жыл бұрын
I hate to say this and I hope it isn't misconstrued but I personally think that Martin himself is one of the things that makes Scala seem hard. He is obviously brilliant but I found his functional programming course very intimidating, even though it was very rewarding.
@BulentBasaran
@BulentBasaran 6 жыл бұрын
clarkie132 I think there is some truth to that. First, my experience is that Martin is an outstanding teacher. He is very demanding and explains concepts very clearly. For relative beginners (to FP let alone imperative languages) his delivery is likely to be too fast. Give yourself some time to absorb and code to get a better feel. It will pay large dividends soon enough.
@kevalan1042
@kevalan1042 6 жыл бұрын
Really? Funny how the perception of such things can be different from person to person. I personally think Martin is among the few who can make Scala feel easy! :)
@MercedeX7
@MercedeX7 6 жыл бұрын
student : i want to learn scala ☺️ Martin : to understand a program part you need no longer account for the possible histories of executions that can lead to that program part. student : 😨
@darkesto
@darkesto 5 жыл бұрын
@@MercedeX7 it is as simple as it is
@tieskedh
@tieskedh 6 жыл бұрын
I think the implicit things are the things that make Scala hard
@scarface548
@scarface548 6 жыл бұрын
what does " transform a type name into a value" mean?
@tieskedh
@tieskedh 6 жыл бұрын
I think that in most of the cases the things that make languages powerful are also the things that are the hardest... This doesn't mean that it should be left out! It just means that the learning curve is higher. Ps. I mean everything which is implicit, so also the implicit casting
@leccio
@leccio 6 жыл бұрын
Yes, too much magic!
@lucduponcheel
@lucduponcheel 6 жыл бұрын
there is this difference between "easy vs difficult" and "simple vs complex" ... computers can manage complexity ; computers have a hard time with difficulty ... human beings can (hopefully) manage difficulty ; human beings have a hard time with complexity ... as Martin pointed out, one of the main challenges of software engineering is managing complexity (some things are so complex that they *appear* to be difficult) ... well: implicits are a (at first sight, maybe) difficult feature that contributes to managing complexity ... once you understand their power you can start appreciating the simplicity that is implied by them.
@obszczymucha1337
@obszczymucha1337 5 жыл бұрын
@@alexelcu You sound like a fanboi. Implicits make code less readable and hard to understand and reason about. There are hidden things everywhere. That's not simplicity, that's overcomplication.
@vladpetric7493
@vladpetric7493 Жыл бұрын
Having a smaller grammar doesn't make a language readable, see LISP for instance. The biggest problem is readability, and Haskell suffers greatly from it. But yeah, one can always cherry-pick the metric that fits their ideological world view.
@MercedeX7
@MercedeX7 6 жыл бұрын
blah blah blah and nothing useful or meaningful that's the simplicity he is talking about!
@saprahan
@saprahan 5 жыл бұрын
Totaly agree. Too bad, now Odersky became a typical business man. Long time ago his lectures were much better
Scala: Beyond the basics with Christopher Batey
48:05
Devoxx
Рет қаралды 48 М.
Functional Programming with Effects by Rob Norris
49:43
Scala Days Conferences
Рет қаралды 25 М.
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 484 М.
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 44 МЛН
Robert C  Martin -  Functional Programming; What? Why? When?
58:27
Martin Odersky - Scala's Role in the Programming Languages Ecosystem
45:53
Scala Days Conferences
Рет қаралды 10 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 806 М.
Functional Programming for Pragmatists • Richard Feldman • GOTO 2021
40:30
Uncle Bob LOVES Functional Programming | Prime Reacts
22:59
ThePrimeTime
Рет қаралды 113 М.
Functional programming design patterns by Scott Wlaschin
1:05:44
Ivan Plyusnin
Рет қаралды 191 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
Как слушать музыку с помощью чека?
0:36
Неразрушаемый смартфон
1:00
Status
Рет қаралды 2,3 МЛН
В России ускорили интернет в 1000 раз
0:18
Короче, новости
Рет қаралды 1,3 МЛН
Мой инст: denkiselef. Как забрать телефон через экран.
0:54