Functional Programming with Kotlin • Hadi Hariri • GOTO 2018

  Рет қаралды 39,580

GOTO Conferences

GOTO Conferences

Күн бұрын

Пікірлер: 45
@marcelmundl9012
@marcelmundl9012 5 жыл бұрын
As for the last question: You can pretty easily accomplish that with a simple extension function: inline operator fun T.invoke(lambda: T.() -> Unit) = lambda(this)
@TroenderTass
@TroenderTass 4 жыл бұрын
@Jon Do Haven't seen the ideo yet, but if you try to run that code. you gonna be dispointed. That lambda doesn't even take a param. Now, you could run that code without passing this in as a param, and rather use this.lambda()
@mehdimohammadi1623
@mehdimohammadi1623 5 жыл бұрын
It was interesting especially the final part about sample DSL in Kotlin using extension function passing into higher-order function
@nasserabbassi7303
@nasserabbassi7303 3 жыл бұрын
how life would be easier with functional paradigm . special thanks to Hadi Hariri
@gareginasatryan6761
@gareginasatryan6761 3 жыл бұрын
Can’t you have functions as objects in OOP?
@damaddinm88
@damaddinm88 6 жыл бұрын
Nice presentation. Basically everything what is new and about Kotlin is nice :)
@simplet3306
@simplet3306 4 жыл бұрын
Simple and understandable. Thanks alot
@raymuko
@raymuko 5 жыл бұрын
That DSL won't work unless you call f() from your invoke operator function. It should be: operator fun invoke(f: Configuration.() -> Unit) = f()
@jean4j_
@jean4j_ 2 жыл бұрын
Is there an advantage to use Kotlin over Scala for functional programming though? This is a serious and honest question
@vibovitold
@vibovitold Жыл бұрын
I'm not an expert, but since you haven't received any better answer... Kotlin isn't as powerful for a functional language as Scala, it's missing some constructs such as union types, for example (and some can be just emulated). And this is by design, Kotlin is meant to remain a "friendly", hybrid language. On the other hand, Scala syntax can be intimidating and it's easier to write virtually incomprehensible code in Scala Kotlin is probably best suited for "diet" functional programming where you don't intend to take the paradigm all the way. So I guess the advantage of Kotlin over Scala, or vice versa, comes down to the technical background of the team, and the project requirements (full blown FP vs. FP-flavored)
@HudsonPereiradishark
@HudsonPereiradishark 6 жыл бұрын
Great talk! Didn't know this Arrow KT library. Thank you!
@damaddinm88
@damaddinm88 6 жыл бұрын
As well one improvement idea. People like seeing code running :)
@vibovitold
@vibovitold 5 жыл бұрын
It's an interesting talk which could be better if it wasn't for some slip-ups. Let me share a few nitpicks 3:11 While I agree with the general message, to be fair, your imperative implementation is obfuscated by poor naming as much as by its imperativeness. The "element" variable is misnamed. It clearly doesn't represent an element - an element is element[i]. Your "element" represents the number of occurrences of a given element, and the name should reflect that for the code to be readable. In my case this by itself was responsible for most of the delay in figuring out what the code does. Poor naming can be more of an obstacle than poor code structure. 20:43 - inside the numbers.forEach, what is "numbers % 5 == 0" supposed to mean? You probably meant "it % 5 == 0" 25:48 - putting const on a getter of Date type makes no sense at all. const can't have a getter. And const can't be used for non-primitive types (such as Date) either; strings being a sole exception. You haven't correctly indicated how the keyword works and what it is for, only created more confusion. 37:25 - "this I can do in shorthand". But what you do then isn't a shorthand for what you had before at all. "this is the same as doing an if". But no, it's not the same. You don't have println. Just the value. And println(s?.length) - which is what someone might thought they'd need, relying on your words - would actually execute println with a null argument, if s were null. This isn't clear from your explanation. For the code to really do the same thing you'd need something like s?.length?.let(::println), or s?.run { println(length) } etc. This piece of the puzzle is missing. 42:50 to 43:07 - I doubt if anyone who doesn't already know how it works from elsewhere actually understood the (non-)explanation...
@ossamabounnite4922
@ossamabounnite4922 6 жыл бұрын
What's the programming language that starts with "b" and finishes with "k" which he was talking about?
@gregorykhvatsky7668
@gregorykhvatsky7668 6 жыл бұрын
Well, maybe I didn't get your sarcasm/joke, but he was talking about Brainfuck
@mhdunknown
@mhdunknown 2 жыл бұрын
Brainfuck.
@suhaib96
@suhaib96 Жыл бұрын
Brainf*ck by Urban Müller
@suhaib96
@suhaib96 Жыл бұрын
kzbin.info/www/bejne/npWrm514iJmWqZo
@AnonimoslawAnonimowy
@AnonimoslawAnonimowy 4 жыл бұрын
Nice presentation, but I haven't got what the last part about DSL capabilities of Kotlin have to do with functional programming. (except that functions are used for DSL)
@zhangwei2671
@zhangwei2671 6 жыл бұрын
so how to type the lambda symbol? :)
@natepepin09
@natepepin09 6 жыл бұрын
In your font settings change it to a fira or some other programming font that has support and then enable font ligatures.
@lyrixtuber
@lyrixtuber 5 жыл бұрын
copy and paste from wikipedia
@xpulse03
@xpulse03 5 жыл бұрын
he added a live template which replaces the florin symbol (OPT+F on us-keyboard macs) with the lowercase lambda, but you can also use any other identifier, like "lambda"
@gareginasatryan6761
@gareginasatryan6761 4 жыл бұрын
Honest question. Why was Kotlin invented, when they already had Scala. Also why did Scala start losing out to Kotlin?
@_DATA_EXPUNGED_
@_DATA_EXPUNGED_ 3 жыл бұрын
Because google decided so, i'd say. Additionally, the java-compatibility thing is quite important too, with kotlin you can without issues continue a java app in the new language. With scala you're going to have to be quite careful. Thus, kotlin has much easier access to the java ecosystem.
@jean4j_
@jean4j_ 2 жыл бұрын
@@_DATA_EXPUNGED_ Also there are just way too many ways to do things and sometimes pretty exotic and fancy things (in a bad way when it comes to software development as a team). The Scala community kind of sucks too. I do like Scala. Some people consider Kotlin as sane Scala. I think that's one way to look at it :)
@vibovitold
@vibovitold Жыл бұрын
Kotlin's stronghold, and arguably the driving force behind its adoption, became Android, because developers were really stuck with Java, and unlike on backend, it wasn't even new versions of Java (unavailable, due to VM limitations). Scala never made a dent there - despite some attempts, it was never adopted for Android development. the notoriously long build times probably played a role (while one of the design goals of Kotlin was to be as fast as Java in this regard). and yes, another important issue is interoperability with Java. it's quite limited with Scala, while Kotlin is fully interoperable (some unavoidable quirks notwithstanding). this was again among Kotlin's chief design goals, and it's of particular importance on Android. finally - although this is subjective - Scala falls a bit on the "academic" side of languages, while Kotlin has a simpler, friendlier feel to it.
@i.i
@i.i 6 жыл бұрын
how about curring
@yasindiouri6088
@yasindiouri6088 6 жыл бұрын
Currying*. Arrow supports it.
@MuhammadAlkady
@MuhammadAlkady 6 жыл бұрын
Thanks
@piotreek7
@piotreek7 5 жыл бұрын
What is the point of using Option, when Kotlin has it built in? All the examples shown in the presentation would be much shorter and more readable with Int? instead of Option.
@vibovitold
@vibovitold 5 жыл бұрын
Kotlin's nullable types are nulls (for the sake of interoperability with Java). If you use a library that doesn't allow for nullability, like - most prominently - RxJava 2, then you can't send an instance of T? down the stream. It'll crash on a null in runtime. If you can't control the source of data, and/or refactoring the entire thing to remove nullability isn't easy, then you could use Optional as a value wrapper for "absent" values. Note the same problem doesn't exist in the - otherwise very similar - Swift, where the issue of Java interoperability obviously doesn't apply, and conversely, T? types in Swift are syntax sugar for Optionals.
@IUfidi
@IUfidi 2 жыл бұрын
Thanks?, Hadi.
@edgeeffect
@edgeeffect 2 жыл бұрын
Nice slides.... completely impossible to read.
@dengan699
@dengan699 5 жыл бұрын
According to him php and python are functional
@anthavio
@anthavio 6 жыл бұрын
Please stop calling usage of lambdas functional programming. Even using datatypes from Arrow is not a functional programming.
@yasindiouri6088
@yasindiouri6088 6 жыл бұрын
Please enlighten all of us about what is functional programming!
@heliobessonirodrigues6632
@heliobessonirodrigues6632 6 жыл бұрын
It IS functional programming. But it's not a PURE functional language.
@okdoomer620
@okdoomer620 5 жыл бұрын
We can call it "functional programming", but that kind of misses the point of using words. You can do this stuff in almost any language used today. I would argue, that the real difference is between pure functional languages like haskell, nix or elm, and all the other languages. Pure func. languages have referential transparency, that allow the compiler to make guarantees about the code, can give you hints, can make optimizations, and can execute it in the order it wants. To get this to work you can not have variable mutation and you need to carefully seperate side-effectful code from pure code. This distinction is not made in all the popular languages. And to complicate things further, there are even languages like scala, that allow you to optionally seperate these things, so it's the responsibility of the programmer to make it work, but the compiler doesn't really care. Mixing those things in Haskell would result in a compile time error. Maybe Hello Bessoni Rodrigues is right and we should just view "functional programming" as a style (independently from the language) where you just put maps and filters where you had for-loops previously, but that would be very different to what you get with pure functional programming, so using the term like this is kind of misleading, and the terms "functional programming" and "pure functional programming" would fall into to different categories.
@vibovitold
@vibovitold 5 жыл бұрын
I agree. This is a bit like saying "I touched an object, therefore I do OOP". Imagine if this object is just a backet for some main() function, and within this function you're referring to Console or something, but it's all spaghetti, then yes you're technically dealing with some objects, but you're writing procedural code regardless :)
C++ - The Newest Old Language • Matt Godbolt • GOTO 2018
43:37
GOTO Conferences
Рет қаралды 50 М.
Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
41:35
GOTO Conferences
Рет қаралды 821 М.
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
KotlinConf 2019: The Power of Types by Danny Preussler
34:49
JetBrains
Рет қаралды 22 М.
Kotlin 102 - Beyond the Basics • Hadi Hariri • GOTO 2018
55:32
GOTO Conferences
Рет қаралды 15 М.
10 Kotlin Tricks in 10 ish minutes by Jake Wharton
17:24
Devoxx
Рет қаралды 68 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 101 М.
Functional Programming in Kotlin - Venkat Subramaniam
53:41
Diving into advanced Kotlin features by Simon Wirtz
49:37
Devoxx
Рет қаралды 23 М.
What can Kotlin do for me? (GDD Europe '17)
30:18
Google for Developers
Рет қаралды 77 М.
Черная Magic Mouse
0:53
Romancev768
Рет қаралды 807 М.
ЛАЙФХАК НА КУХНЕ ! 🧐🤦🏻‍♂️ #shorts #лайфхак
0:15
Крус Костилио
Рет қаралды 109 М.
🪄Вечная спичка #diy #выживание #поход
1:00
Короче, ВИ
Рет қаралды 2,8 МЛН
LNS - 2 cô gái tốt bụng || Kind 2 girls #shorts
0:47
Linh Nhi Shorts
Рет қаралды 4,2 МЛН
ПОСТАРЕЛА ЗА 1 ДЕНЬ НА 20 ЛЕТ - МУЖСКОЕ ЖЕНСКОЕ
55:44
ПРИЯТНЫЙ ИЛЬДАР
Рет қаралды 677 М.