An introduction to Kotlin for advanced Android beginners, covering command-line compilation of Kotlin files, conditional logic, val/var, basic functions, higher order functions, recursion.
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
Kotlin is a statically typed programming language that targets the JVM, Android and web. It has been in development since 2010 by JetBrains. Kotlin code is concise, expressive and safe to develop with. It is interoperable with Java code and has equivalent performance, with a smooth learning curve that maintains existing Java investments. JetBrains uses Kotlin in their own products and tools. The document provides examples of Kotlin features like classes, traits, null safety, extension functions, operator overloading, and HTML builders.
This document provides an introduction and overview of the Kotlin programming language. It begins with an agenda and quote about Kotlin being a good choice for Spring applications. The remainder of the document covers what Kotlin is, its main features like type inference, functional programming support, interoperability with Java, and language concepts like properties, classes, inheritance, interfaces, functions, collections and more. Code examples are provided to illustrate many of the language features. Resources for learning more about Kotlin are listed at the end.
The document provides idiomatic Kotlin coding style guidelines and best practices for expressions, classes, functions, and the standard library. Some key recommendations include using 'when' and 'try' as expression bodies, avoiding classes just for functions, extracting non-essential APIs to extensions, using data classes, type aliases, and destructuring declarations, and leveraging functions like 'apply', 'filterIsInstance', and 'groupBy' from the standard library. Overall the document advises organizing code in a concise and functional way that fully utilizes Kotlin language features.
Kotlin provides a lot of features out of the box even though those are not supported by JVM. Have you ever wondered how Kotlin does it? If yes, then this presentation is for you.
Kotlin compiler tweaks our code in such a way that, JVM can execute it. this deck goes through lots of Kotlin features and explains how it looks at runtime for JVM compatibility. Of course we are not going to look into bytecode, instead we will look into the decompiled version of the bytecode generated by Kotlin compiler.
NOTE: This was presented at DevFest Kolkata 2019.
This document compares several JVM languages including Java, Scala, Groovy, Kotlin, Clojure and Ceylon. It discusses their classification as functional or object-oriented, static or dynamic typing. It also summarizes key features of each language such as support for functional programming paradigms, closures, immutable data structures, and parallel processing capabilities. The document provides code examples to illustrate concepts in Scala, Kotlin, and Groovy.
Kotlin Bytecode Generation and Runtime Performanceintelliyole
In this talk, we'll dive into the details of how various language features supported by Kotlin are translated to Java bytecode. We'll use the JMH microbenchmarking tool to study the relative performance of various constructs and to understand how we can ensure top performance of the Kotlin code that we write.
Kotlin is something more than just tool that help you remove boilerplate from you code. It brings much more than just lamdas and handy syntax to your Java or Android project
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
Kotlin is a statically typed programming language that targets the JVM, Android and web. It has been in development since 2010 by JetBrains. Kotlin code is concise, expressive and safe to develop with. It is interoperable with Java code and has equivalent performance, with a smooth learning curve that maintains existing Java investments. JetBrains uses Kotlin in their own products and tools. The document provides examples of Kotlin features like classes, traits, null safety, extension functions, operator overloading, and HTML builders.
This document provides an introduction and overview of the Kotlin programming language. It begins with an agenda and quote about Kotlin being a good choice for Spring applications. The remainder of the document covers what Kotlin is, its main features like type inference, functional programming support, interoperability with Java, and language concepts like properties, classes, inheritance, interfaces, functions, collections and more. Code examples are provided to illustrate many of the language features. Resources for learning more about Kotlin are listed at the end.
The document provides idiomatic Kotlin coding style guidelines and best practices for expressions, classes, functions, and the standard library. Some key recommendations include using 'when' and 'try' as expression bodies, avoiding classes just for functions, extracting non-essential APIs to extensions, using data classes, type aliases, and destructuring declarations, and leveraging functions like 'apply', 'filterIsInstance', and 'groupBy' from the standard library. Overall the document advises organizing code in a concise and functional way that fully utilizes Kotlin language features.
Kotlin provides a lot of features out of the box even though those are not supported by JVM. Have you ever wondered how Kotlin does it? If yes, then this presentation is for you.
Kotlin compiler tweaks our code in such a way that, JVM can execute it. this deck goes through lots of Kotlin features and explains how it looks at runtime for JVM compatibility. Of course we are not going to look into bytecode, instead we will look into the decompiled version of the bytecode generated by Kotlin compiler.
NOTE: This was presented at DevFest Kolkata 2019.
This document compares several JVM languages including Java, Scala, Groovy, Kotlin, Clojure and Ceylon. It discusses their classification as functional or object-oriented, static or dynamic typing. It also summarizes key features of each language such as support for functional programming paradigms, closures, immutable data structures, and parallel processing capabilities. The document provides code examples to illustrate concepts in Scala, Kotlin, and Groovy.
Kotlin Bytecode Generation and Runtime Performanceintelliyole
In this talk, we'll dive into the details of how various language features supported by Kotlin are translated to Java bytecode. We'll use the JMH microbenchmarking tool to study the relative performance of various constructs and to understand how we can ensure top performance of the Kotlin code that we write.
Kotlin is something more than just tool that help you remove boilerplate from you code. It brings much more than just lamdas and handy syntax to your Java or Android project
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
Kotlin advanced - language reference for android developersBartosz Kosarzycki
StxNext Lightning Talks - Mar 11, 2016
Kotlin Advanced - language reference for Android developers
This presentation contains the second talk on Kotlin language we had at STXNext. We try go deeper into language specifics and look at the positive impact new syntax can have on boilerplate removal and readability improvement.
Kotlin really shines in Android development when one looks at “Enum translation”, “Extension functions”, “SAM conversions”, “Infix notation”, “Closures” and “Fluent interfaces” applied to lists. The talk, however, compares language-specifics of Java & Kotlin in terms of “Type Variance”, “Generics” and “IDE tools” as well.
We present real-world example based on Stx-Insider project written in Kotlin which incorporates Dagger 2, Kotterknife, Retrofit2 and is composed of 5+ Activities.
Full agenda
Live templates
Enum translation
Calling extension functions from Kotlin/Java
Constructors with backing fields
Warnings
F-bound polymorphism
Variance (Covariance/Contravariance)
Variance comparison in Kotlin/Java/Scala
Annotation processing - KAPT
SAM conversions
Type equality
Lambda vs Closure
Reified generics
Fluent interfaces
Infix notation
Static extension methods in Kotlin
Generic types
Sealed classes
Dokka - documentation in Kotlin
J2K converter
Real-world example
Reflection
Presentation is accompanied with an example project (StxInsider):
https://github.com/kosiara/stx-insider
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
The document introduces the Kotlin programming language developed by JetBrains. It provides an overview of Kotlin's motivation, features, syntax and tooling. Key points include Kotlin being a statically typed JVM language intended for industrial use, its focus on common sense features from other languages, and full interoperability with Java.
Introduction to functional programming using Ocamlpramode_ce
The document provides an introduction to functional programming concepts using Ocaml as the teaching language. It outlines the workshop plan which will cover Ocaml syntax, important functional programming concepts, and understanding the functional paradigm through Ocaml. It then discusses Ocaml background, where Ocaml is used, the Ocaml REPL, function definition, type inference, recursion, tail calls and TCO, higher order functions, algebraic data types, pattern matching, immutability, and more.
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan s.r.o.
This document provides an overview of the Kotlin programming language. It defines Kotlin as a statically typed language that targets the JVM and JavaScript, is 100% interoperable with Java, and was created by JetBrains as a better alternative to Java. The document then covers 10 features of Kotlin, including null safety, data classes, extension functions, smart casts, and support for functional programming patterns. It provides code examples to demonstrate how these features work in Kotlin.
Introduction to Functional Programming in JavaScripttmont
A presentation I did for work on functional programming. It's meant as an introduction to functional programming, and I implemented the fundamentals of functional programming (Church Numerals, Y-Combinator, etc.) in JavaScript.
Scala - where objects and functions meetMario Fusco
The document provides an overview of a two-day training course on Scala that covers topics like object orientation, functional programming, pattern matching, generics, traits, case classes, tuples, collections, concurrency, options and monads. The course aims to show how Scala combines object-oriented and functional programming approaches and provides examples of commonly used Scala features like classes, traits, pattern matching, generics and collections.
StxNext Lightning Talks - Feb 12, 2016
Kotlin - one of the popular programming languages built on top of Java that runs on JVM. Thanks to JetBrains support and excellent IDE integration, it’s an ideal choice when it comes to Android development. 100% Java compatibility, interoperability and no runtime overhead is just the beginning of a long list of strengths. Kotlin is supposed to be a subset of SCALA, on one hand covering major advantages for developers and on the other - keeping short compile times.
This presentation is a Developer Starter - a set of hand-picked information allowing a person with no knowledge of Kotlin to start writing basic Android activities and set up an Android-kotlin project. It starts with language background, reasons for its creation and advantages. Then presents basic use cases, syntax, structures and patterns. Later on Kotlin is presented in Android context. Simple project structure, imports and Kotlin usage with Android SDK is explained. In the end cost of Kotlin usage is presented and the language is compared to SCALA and SWIFT.
The document discusses the Kotlin programming language. It highlights that Kotlin is a modern, pragmatic language that provides good tooling and interoperability with Java. It has grown significantly in popularity since its initial release. The document then discusses various features of Kotlin like its concise and readable syntax, null safety, support for lambdas and extensions, and how it can be used for multi-platform projects. Kotlin aims to be an improvement over Java by making code more concise, safe, and expressive while maintaining interoperability with existing Java code and libraries.
Intro to Functional Programming in ScalaShai Yallin
Scala is a functional and object-oriented programming language that runs on the Java Virtual Machine. It features type inference, immutable collections, pattern matching, and functions as first-class values. The document provides an overview of Scala's features such as its static typing, traits for multiple inheritance, and case classes for value objects. It also demonstrates Scala's collections API and use of functions and pattern matching.
Java 7, 8 & 9 - Moving the language forwardMario Fusco
The document summarizes new features in Java 7-8 including lambda expressions, switch on strings, try-with-resources, and the fork/join framework. Java 8 will focus on lambda expressions to provide functional programming capabilities and default methods to allow interfaces to have default implementations without breaking existing implementations. Java 9 may include additional modularization support.
Kotlin is a statically typed programming language that targets the JVM. It was developed by JetBrains to be concise, prevent errors, and interoperate fully with Java. Key features include properties, higher-order functions, extension functions, and null safety. Kotlin code compiles to JVM bytecode and works with Java code and libraries. Tooling includes an open source compiler and IDE plugins for IntelliJ IDEA and Eclipse. The language was designed based on learning from other languages like Groovy, C#, Scala, and Gosu, with a focus on common sense and avoiding unnecessary complexity.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Kotlin is a concise, safe, and statically typed programming language that compiles to JVM bytecode and JavaScript. It focuses on interoperability with Java and solves many Java pitfalls. Kotlin removes verbosity like semicolons and replaces "extends" and "implement" with a colon. Functions are defined with the "fun" keyword and return types follow. Properties are treated like fields. Kotlin avoids null references through null safety features like the safe call operator and non-null assertion operator. When expressions replace switch statements. Extension functions can extend existing classes without subclassing.
3 kotlin vs. java- what kotlin has that java does notSergey Bandysik
This document discusses Kotlin functions and lambda expressions. It explains that lambda expressions can be passed immediately as expressions or defined separately as functions. It also discusses that using higher-order functions can introduce runtime overhead which can be eliminated by inlining lambda expressions. Finally, it provides an example of an inline fun that demonstrates inlining and non-inlining of lambda expressions.
The document discusses programming with futures in Java and Scala. It introduces futures in Java 8 using CompletableFuture and shows how they allow composing asynchronous operations without blocking threads. It then discusses how streams and futures in Java 8 share similar composition concepts using thenApply and thenCompose. The talk moves on to introduce more abstract concepts from category theory - monads, foldables and monoids. It shows how these concepts can be implemented for futures and lists to provide generic sequencing and folding of asynchronous and synchronous operations in a precise way.
This document discusses the history and evolution of functional programming in Java, including lambda expressions and streams. It describes how lambda expressions allow passing behaviors as arguments to methods like normal data. This improves API design, opportunities for optimization, and code readability. Streams encourage a lazy, pipelined style and can execute operations in parallel. Functional idioms like immutability and pure functions help enforce correctness and isolation of side effects.
An invited talk by Xavier Leroy explaining the current state of OCaml at the OCaml Users and Developers Workshop 2014. http://ocaml.org/meetings/ocaml/2014/
The document discusses operator overloading in Kotlin using the example of a Coin enum and Wallet class. It defines a Coin enum with values for common coins (PENNY, NICKEL, etc) that each have a cents value. A Wallet class is defined with a plusAssign operator function that allows adding Coin values to the wallet amount. Examples are shown incrementing a wallet variable by adding Coin values like QUARTER to demonstrate operator overloading.
This document provides an introduction and overview of the Kotlin programming language. It covers key Kotlin concepts and features such as properties, null safety, classes, interfaces, extensions, and collections. It also includes Kotlin's timeline, development tools, and basic data types. The agenda outlines topics like String templates, OOP concepts, lambdas, and infix notation that are explained further in the document.
Short (45 min) version of my 'Pragmatic Real-World Scala' talk. Discussing patterns and idioms discovered during 1.5 years of building a production system for finance; portfolio management and simulation.
Kotlin advanced - language reference for android developersBartosz Kosarzycki
StxNext Lightning Talks - Mar 11, 2016
Kotlin Advanced - language reference for Android developers
This presentation contains the second talk on Kotlin language we had at STXNext. We try go deeper into language specifics and look at the positive impact new syntax can have on boilerplate removal and readability improvement.
Kotlin really shines in Android development when one looks at “Enum translation”, “Extension functions”, “SAM conversions”, “Infix notation”, “Closures” and “Fluent interfaces” applied to lists. The talk, however, compares language-specifics of Java & Kotlin in terms of “Type Variance”, “Generics” and “IDE tools” as well.
We present real-world example based on Stx-Insider project written in Kotlin which incorporates Dagger 2, Kotterknife, Retrofit2 and is composed of 5+ Activities.
Full agenda
Live templates
Enum translation
Calling extension functions from Kotlin/Java
Constructors with backing fields
Warnings
F-bound polymorphism
Variance (Covariance/Contravariance)
Variance comparison in Kotlin/Java/Scala
Annotation processing - KAPT
SAM conversions
Type equality
Lambda vs Closure
Reified generics
Fluent interfaces
Infix notation
Static extension methods in Kotlin
Generic types
Sealed classes
Dokka - documentation in Kotlin
J2K converter
Real-world example
Reflection
Presentation is accompanied with an example project (StxInsider):
https://github.com/kosiara/stx-insider
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
The document introduces the Kotlin programming language developed by JetBrains. It provides an overview of Kotlin's motivation, features, syntax and tooling. Key points include Kotlin being a statically typed JVM language intended for industrial use, its focus on common sense features from other languages, and full interoperability with Java.
Introduction to functional programming using Ocamlpramode_ce
The document provides an introduction to functional programming concepts using Ocaml as the teaching language. It outlines the workshop plan which will cover Ocaml syntax, important functional programming concepts, and understanding the functional paradigm through Ocaml. It then discusses Ocaml background, where Ocaml is used, the Ocaml REPL, function definition, type inference, recursion, tail calls and TCO, higher order functions, algebraic data types, pattern matching, immutability, and more.
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan s.r.o.
This document provides an overview of the Kotlin programming language. It defines Kotlin as a statically typed language that targets the JVM and JavaScript, is 100% interoperable with Java, and was created by JetBrains as a better alternative to Java. The document then covers 10 features of Kotlin, including null safety, data classes, extension functions, smart casts, and support for functional programming patterns. It provides code examples to demonstrate how these features work in Kotlin.
Introduction to Functional Programming in JavaScripttmont
A presentation I did for work on functional programming. It's meant as an introduction to functional programming, and I implemented the fundamentals of functional programming (Church Numerals, Y-Combinator, etc.) in JavaScript.
Scala - where objects and functions meetMario Fusco
The document provides an overview of a two-day training course on Scala that covers topics like object orientation, functional programming, pattern matching, generics, traits, case classes, tuples, collections, concurrency, options and monads. The course aims to show how Scala combines object-oriented and functional programming approaches and provides examples of commonly used Scala features like classes, traits, pattern matching, generics and collections.
StxNext Lightning Talks - Feb 12, 2016
Kotlin - one of the popular programming languages built on top of Java that runs on JVM. Thanks to JetBrains support and excellent IDE integration, it’s an ideal choice when it comes to Android development. 100% Java compatibility, interoperability and no runtime overhead is just the beginning of a long list of strengths. Kotlin is supposed to be a subset of SCALA, on one hand covering major advantages for developers and on the other - keeping short compile times.
This presentation is a Developer Starter - a set of hand-picked information allowing a person with no knowledge of Kotlin to start writing basic Android activities and set up an Android-kotlin project. It starts with language background, reasons for its creation and advantages. Then presents basic use cases, syntax, structures and patterns. Later on Kotlin is presented in Android context. Simple project structure, imports and Kotlin usage with Android SDK is explained. In the end cost of Kotlin usage is presented and the language is compared to SCALA and SWIFT.
The document discusses the Kotlin programming language. It highlights that Kotlin is a modern, pragmatic language that provides good tooling and interoperability with Java. It has grown significantly in popularity since its initial release. The document then discusses various features of Kotlin like its concise and readable syntax, null safety, support for lambdas and extensions, and how it can be used for multi-platform projects. Kotlin aims to be an improvement over Java by making code more concise, safe, and expressive while maintaining interoperability with existing Java code and libraries.
Intro to Functional Programming in ScalaShai Yallin
Scala is a functional and object-oriented programming language that runs on the Java Virtual Machine. It features type inference, immutable collections, pattern matching, and functions as first-class values. The document provides an overview of Scala's features such as its static typing, traits for multiple inheritance, and case classes for value objects. It also demonstrates Scala's collections API and use of functions and pattern matching.
Java 7, 8 & 9 - Moving the language forwardMario Fusco
The document summarizes new features in Java 7-8 including lambda expressions, switch on strings, try-with-resources, and the fork/join framework. Java 8 will focus on lambda expressions to provide functional programming capabilities and default methods to allow interfaces to have default implementations without breaking existing implementations. Java 9 may include additional modularization support.
Kotlin is a statically typed programming language that targets the JVM. It was developed by JetBrains to be concise, prevent errors, and interoperate fully with Java. Key features include properties, higher-order functions, extension functions, and null safety. Kotlin code compiles to JVM bytecode and works with Java code and libraries. Tooling includes an open source compiler and IDE plugins for IntelliJ IDEA and Eclipse. The language was designed based on learning from other languages like Groovy, C#, Scala, and Gosu, with a focus on common sense and avoiding unnecessary complexity.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
Kotlin is a concise, safe, and statically typed programming language that compiles to JVM bytecode and JavaScript. It focuses on interoperability with Java and solves many Java pitfalls. Kotlin removes verbosity like semicolons and replaces "extends" and "implement" with a colon. Functions are defined with the "fun" keyword and return types follow. Properties are treated like fields. Kotlin avoids null references through null safety features like the safe call operator and non-null assertion operator. When expressions replace switch statements. Extension functions can extend existing classes without subclassing.
3 kotlin vs. java- what kotlin has that java does notSergey Bandysik
This document discusses Kotlin functions and lambda expressions. It explains that lambda expressions can be passed immediately as expressions or defined separately as functions. It also discusses that using higher-order functions can introduce runtime overhead which can be eliminated by inlining lambda expressions. Finally, it provides an example of an inline fun that demonstrates inlining and non-inlining of lambda expressions.
The document discusses programming with futures in Java and Scala. It introduces futures in Java 8 using CompletableFuture and shows how they allow composing asynchronous operations without blocking threads. It then discusses how streams and futures in Java 8 share similar composition concepts using thenApply and thenCompose. The talk moves on to introduce more abstract concepts from category theory - monads, foldables and monoids. It shows how these concepts can be implemented for futures and lists to provide generic sequencing and folding of asynchronous and synchronous operations in a precise way.
This document discusses the history and evolution of functional programming in Java, including lambda expressions and streams. It describes how lambda expressions allow passing behaviors as arguments to methods like normal data. This improves API design, opportunities for optimization, and code readability. Streams encourage a lazy, pipelined style and can execute operations in parallel. Functional idioms like immutability and pure functions help enforce correctness and isolation of side effects.
An invited talk by Xavier Leroy explaining the current state of OCaml at the OCaml Users and Developers Workshop 2014. http://ocaml.org/meetings/ocaml/2014/
The document discusses operator overloading in Kotlin using the example of a Coin enum and Wallet class. It defines a Coin enum with values for common coins (PENNY, NICKEL, etc) that each have a cents value. A Wallet class is defined with a plusAssign operator function that allows adding Coin values to the wallet amount. Examples are shown incrementing a wallet variable by adding Coin values like QUARTER to demonstrate operator overloading.
This document provides an introduction and overview of the Kotlin programming language. It covers key Kotlin concepts and features such as properties, null safety, classes, interfaces, extensions, and collections. It also includes Kotlin's timeline, development tools, and basic data types. The agenda outlines topics like String templates, OOP concepts, lambdas, and infix notation that are explained further in the document.
Ever wonder what this "new" Kotlin thing is? Curious what the syntax looks like? Unsure how to implement this at your own company? Or do you just want to know what Nick and Cody's favorite things are about this language?
All that and (maybe) more are revealed in Privet Kotlin.
Kotlin for backend development (Hackaburg 2018 Regensburg)Tobias Schneck
Off to a new island - Kotlin for backend development
Tobias Schneck, Simon Hofmann
Get a first insight to new JVM language Kotlin and learn how you can use Kotlin also for backend development. We will compare traditional Java code to the new fancy Kotlin code and show why we fell in love with it. We will also show how you can spin up your Kotlin Spring Boot backend server in just a few minutes and how you use Java and Kotlin code together in one project.
Kotlin is a statically typed programming language that runs on the Java Virtual Machine and is fully interoperable with Java. It was developed by JetBrains as an alternative to Java for Android development, with improvements like null safety, lambdas, and concise syntax. Kotlin aims to be a safer language than Java by eliminating NullPointerExceptions and adding features like data classes, extensions, and higher-order functions. These features allow for more readable, concise code compared to Java.
With the announcement on officially supporting Kotlin for Android, this presentation tries to compare Java and Kotlin to encourage people to switch to Kotlin
Jetbrains was looking for a new programming language to replace Java for developing their large codebase of IDE and server-side tools. They wanted a language with Java interoperability, null safety, concise syntax, and easy tooling. Kotlin was selected as it met these criteria while having faster compilation times than Scala. Kotlin has since gained popularity with over 20,000 repositories and official support from Google for Android development.
https://www.youtube.com/watch?v=QIRJKIDLZgU
Effective Java는 효율적이고 잘 설계된 Java 프로그램을 구현하기 위한 지침들을 소개하는 책입니다. Kotlin에서는 이 지침들이 잘 적용될 수 있는 설계를 갖추고 있는데요, Kotlin Reference 문서에서는 설명을 뒷받침하기 위해 이 책을 인용하기도 합니다. 세션에서는 "이펙티브 자바" 책의 규칙들을 짚어가면서, Kotlin에 어떻게 반영되었는지, 혹은 어떻게 적용될수 있는지에 대해 공유합니다.
Kotlin 1.2: Sharing code between platformsKirill Rozov
Discover what's new in Kotlin 1.2: syntax, standard library, performance and , of course, "Multiplatform project". Take closer look at how Kotlin authors see way of reusing code between platforms.
Kotlin was created by JetBrains to improve developer productivity and enjoyment when building tools like IntelliJ IDEA. Some key features of Kotlin include properties, smart casts, extension functions, and null safety. Kotlin works well for server-side development using frameworks like Kara and Exposed, as well as Android development using Android Extensions and Anko. To succeed with Kotlin, developers should take initiative by starting with tests and utilities in existing Java projects rather than waiting for new projects.
"JavaScript in 2016" by Eduard Tomàs
Some years ago in a far far away company, Brendan Eich created JavaScript. A lot of things happened since then. Times changed, the web grown, the language itself was updated, and we as a developers need to adapt too. Last year the last standard of the language arose: ECMAScript 2015 is here, and has some new and interesting features. In this talk we will show the most relevant ones, and also we will introduce some interesting patterns that you can use in JavaScript: you'll learn how to master the language and made JavaScript your best ally to conquest the world!
This presentation shows tools and technologies used in Android Development such as Kotlin, Retrofit, and Room. It also shows different architectural patterns such as MVC, MVP, and MVVM
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdfAndrey Breslav
New languages are inspired by existing languages: every generation learns from the previous one. Kotlin is no exception: its design is based substantially on the designs of languages such as Java, Scala, C#, Groovy, Python, Nice, etc. This talk will explain which parts of the design are inspired by which languages and what Kotlin does differently in each case.
Swift is a new programming language that is statically typed, multi-paradigm, and designed to work with Cocoa and Cocoa Touch. It features modern language elements like optionals, generics, closures, and pattern matching. Swift code is compiled to native executables making it performant, and it is designed to bridge seamlessly with Objective-C and Cocoa allowing existing iOS and OS X apps to migrate code over.
In this PDF you can learn about Kotlin Basic as well as Intermediate part. As also you can develop the android apps and publish in a google play store.
- Kotlin is a compiled, statically typed language that is interoperable with Java libraries and seamlessly bidirectional with Java.
- Kotlin offers more compile time safety compared to other statically typed languages as code will fail fast during compilation rather than at runtime.
- Kotlin has an easy learning curve for Java developers and allows freedom to mix imperative and functional programming styles.
This document provides an introduction to the Kotlin programming language. It discusses Kotlin's history and key features such as being free, open-source, and running on the JVM. It then covers basic Kotlin concepts like data types, variables, operators, control flow statements, and functions. The document gives examples to illustrate Kotlin keywords, variables, data types like numbers, characters and strings, and operators like arithmetic, relational, and logical operators. It also demonstrates the use of control structures like if/else, when, for loops, while loops, and break/continue statements.
This session for beginners introduces tf.data APIs for creating data pipelines by combining various "lazy operators" in tf.data, such as filter(), map(), batch(), zip(), flatmap(), take(), and so forth.
Familiarity with method chaining and TF2 is helpful (but not required). If you are comfortable with FRP, the code samples in this session will be very familiar to you.
This document provides an overview and introduction to TensorFlow 2. It discusses major changes from TensorFlow 1.x like eager execution and tf.function decorator. It covers working with tensors, arrays, datasets, and loops in TensorFlow 2. It also demonstrates common operations like arithmetic, reshaping and normalization. Finally, it briefly introduces working with Keras and neural networks in TensorFlow 2.
A fast-paced introduction to Deep Learning concepts, such as activation functions, cost functions, back propagation, and then a quick dive into CNNs. Basic knowledge of vectors, matrices, and derivatives is helpful in order to derive the maximum benefit from this session.
A fast-paced introduction to TensorFlow 2 about some important new features (such as generators and the @tf.function decorator) and TF 1.x functionality that's been removed from TF 2 (yes, tf.Session() has retired).
Some concise code samples are presented to illustrate how to use new features of TensorFlow 2.
A fast-paced introduction to TensorFlow 2 about some important new features (such as generators and the @tf.function decorator) and TF 1.x functionality that's been removed from TF 2 (yes, tf.Session() has retired).
Concise code samples are presented to illustrate how to use new features of TensorFlow 2. You'll also get a quick introduction to lazy operators (if you know FRP this will be super easy), along with a code comparison between TF 1.x/iterators with tf.data.Dataset and TF 2/generators with tf.data.Dataset.
Finally, we'll look at some tf.keras code samples that are based on TensorFlow 2. Although familiarity with TF 1.x is helpful, newcomers with an avid interest in learning about TensorFlow 2 can benefit from this session.
This fast-paced session provides a brief history of AI, followed by AI-related topics, such as Machine Learning, Deep Learning and Reinforcement Learning, and the most popular frameworks for Machine Learning. You will learn about some of the successes of AI, and also some of the significant challenges in AI. No specialized knowledge is required, but an avid interest is recommended to derive the maximum benefit from this session.
A fast-paced introduction to Deep Learning concepts, such as activation functions, cost functions, back propagation, and then a quick dive into CNNs, followed by a Keras code sample for defining a CNN. Basic knowledge of vectors, matrices, and derivatives is helpful in order to derive the maximum benefit from this session. Then we'll see a short introduction to TensorFlow 1.x and some insights into TF 2 that will be released some time this year.
Introduction to Deep Learning, Keras, and TensorflowOswald Campesato
A fast-paced introduction to Deep Learning concepts, such as activation functions, cost functions, back propagation, and then a quick dive into CNNs. Basic knowledge of vectors, matrices, and derivatives is helpful in order to derive the maximum benefit from this session. Then we'll see how to create a Convolutional Neural Network in Keras, followed by a quick introduction to TensorFlow and TensorBoard.
Introduction to Deep Learning for Non-ProgrammersOswald Campesato
This session provides a brief history of AI, followed by AI-related topics, such as robots in AI, Machine Learning and Deep Learning, use cases for AI, some of the successes of AI, and also some of the significant challenges in AI. You will also learn about AI and mobile devices and the ethics of AI. An avid interest is recommended to derive the maximum benefit from this session.
An introductory presentation covered key concepts in deep learning including neural networks, activation functions, cost functions, and optimization methods. Popular deep learning frameworks TensorFlow and tensorflow.js were discussed. Common deep learning architectures like convolutional neural networks and generative adversarial networks were explained. Examples and code snippets in Python demonstrated fundamental deep learning concepts.
An introductory document covered deep learning concepts including neural networks, activation functions, cost functions, gradient descent, TensorFlow, CNNs, RNNs, GANs, and tensorflow.js. Key topics included the use of deep learning for computer vision, speech recognition, and more. Activation functions such as ReLU, sigmoid and tanh were explained. TensorFlow and tensorflow.js were introduced as frameworks for deep learning.
A fast-paced introduction to Deep Learning concepts, such as activation functions, cost functions, back propagation, and then a quick dive into CNNs. Basic knowledge of vectors, matrices, and derivatives is helpful in order to derive the maximum benefit from this session. Then we'll see a short introduction to TensorFlow and TensorBoard.
A fast-paced introduction to Deep Learning (DL) concepts, starting with a simple yet complete neural network (no frameworks), followed by aspects of deep neural networks, such as back propagation, activation functions, CNNs, and the AUT theorem. Next, a quick introduction to TensorFlow and TensorBoard, along with some code samples with TensorFlow. For best results, familiarity with basic vectors and matrices, inner (aka "dot") products of vectors, the notion of a derivative, and rudimentary Python is recommended.
Intro to Deep Learning, TensorFlow, and tensorflow.jsOswald Campesato
This fast-paced session introduces Deep Learning concepts, such gradient descent, back propagation, activation functions, and CNNs. We'll look at creating Android apps with TensorFlow Lite (pending its availability). Basic knowledge of vectors, matrices, and Android, as well as elementary calculus (derivatives), are strongly recommended in order to derive the maximum benefit from this session.
This document provides an overview and introduction to deep learning. It discusses key concepts such as neural networks, hidden layers, activation functions, cost functions, and gradient descent. Specific deep learning applications are highlighted, including computer vision, speech recognition, and recommendation systems. Deep learning frameworks like TensorFlow and concepts like convolutional neural networks (CNNs) and generative adversarial networks (GANs) are also explained at a high level. The document aims to introduce attendees to the main ideas and terminology within deep learning.
A fast-paced introduction to Deep Learning concepts, such as activation functions, cost functions, backpropagation, and then a quick dive into CNNs. Basic knowledge of vectors, matrices, and elementary calculus (derivatives), are helpful in order to derive the maximum benefit from this session.
Next we'll see a simple neural network using Keras, followed by an introduction to TensorFlow and TensorBoard. (Bonus points if you know Zorn's Lemma, the Well-Ordering Theorem, and the Axiom of Choice.)
This fast-paced session starts with an introduction to neural networks and linear regression models, along with a quick view of TensorFlow, followed by some Scala APIs for TensorFlow. You'll also see a simple dockerized image of Scala and TensorFlow code and how to execute the code in that image from the command line. No prior knowledge of NNs, Keras, or TensorFlow is required (but you must be comfortable with Scala).
"A fast-paced introduction to Deep Learning (DL) concepts, such as neural networks, back propagation, activation functions, and CNNs. We'll also look at JavaScript-based toolkits (such as TensorFire and deeplearning.js) that leverage the power of WebGL. Basic knowledge of elementary calculus (e.g., derivatives) is recommended in order to derive the maximum benefit from this session.
A fast-paced introduction to Deep Learning that starts with a simple yet complete neural network (no frameworks), followed by an overview of activation functions, cost functions, backpropagation, and then a quick dive into CNNs. Next we'll create a neural network using Keras, followed by an introduction to TensorFlow and TensorBoard. For best results, familiarity with basic vectors and matrices, inner (aka "dot") products of vectors, and rudimentary Python is definitely helpful.
This document provides an overview and introduction to deep learning concepts including linear regression, activation functions, gradient descent, backpropagation, hyperparameters, convolutional neural networks (CNNs), recurrent neural networks (RNNs), and TensorFlow. It discusses clustering examples to illustrate neural networks, explores different activation functions and cost functions, and provides code examples of TensorFlow operations, constants, placeholders, and saving graphs.
Liberarsi dai framework con i Web Component.pptxMassimo Artizzu
In Italian
Presentazione sulle feature e l'utilizzo dei Web Component nell sviluppo di pagine e applicazioni web. Racconto delle ragioni storiche dell'avvento dei Web Component. Evidenziazione dei vantaggi e delle sfide poste, indicazione delle best practices, con particolare accento sulla possibilità di usare web component per facilitare la migrazione delle proprie applicazioni verso nuovi stack tecnologici.
Transforming Product Development using OnePlan To Boost Efficiency and Innova...OnePlan Solutions
Ready to overcome challenges and drive innovation in your organization? Join us in our upcoming webinar where we discuss how to combat resource limitations, scope creep, and the difficulties of aligning your projects with strategic goals. Discover how OnePlan can revolutionize your product development processes, helping your team to innovate faster, manage resources more effectively, and deliver exceptional results.
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio, Inc.
Alluxio Webinar
June. 18, 2024
For more Alluxio Events: https://www.alluxio.io/events/
Speaker:
- Jianjian Xie (Staff Software Engineer, Alluxio)
As Trino users increasingly rely on cloud object storage for retrieving data, speed and cloud cost have become major challenges. The separation of compute and storage creates latency challenges when querying datasets; scanning data between storage and compute tiers becomes I/O bound. On the other hand, cloud API costs related to GET/LIST operations and cross-region data transfer add up quickly.
The newly introduced Trino file system cache by Alluxio aims to overcome the above challenges. In this session, Jianjian will dive into Trino data caching strategies, the latest test results, and discuss the multi-level caching architecture. This architecture makes Trino 10x faster for data lakes of any scale, from GB to EB.
What you will learn:
- Challenges relating to the speed and costs of running Trino in the cloud
- The new Trino file system cache feature overview, including the latest development status and test results
- A multi-level cache framework for maximized speed, including Trino file system cache and Alluxio distributed cache
- Real-world cases, including a large online payment firm and a top ridesharing company
- The future roadmap of Trino file system cache and Trino-Alluxio integration
Odoo releases a new update every year. The latest version, Odoo 17, came out in October 2023. It brought many improvements to the user interface and user experience, along with new features in modules like accounting, marketing, manufacturing, websites, and more.
The Odoo 17 update has been a hot topic among startups, mid-sized businesses, large enterprises, and Odoo developers aiming to grow their businesses. Since it is now already the first quarter of 2024, you must have a clear idea of what Odoo 17 entails and what it can offer your business if you are still not aware of it.
This blog covers the features and functionalities. Explore the entire blog and get in touch with expert Odoo ERP consultants to leverage Odoo 17 and its features for your business too.
An Overview of Odoo ERP
Odoo ERP was first released as OpenERP software in February 2005. It is a suite of business applications used for ERP, CRM, eCommerce, websites, and project management. Ten years ago, the Odoo Enterprise edition was launched to help fund the Odoo Community version.
When you compare Odoo Community and Enterprise, the Enterprise edition offers exclusive features like mobile app access, Odoo Studio customisation, Odoo hosting, and unlimited functional support.
Today, Odoo is a well-known name used by companies of all sizes across various industries, including manufacturing, retail, accounting, marketing, healthcare, IT consulting, and R&D.
The latest version, Odoo 17, has been available since October 2023. Key highlights of this update include:
Enhanced user experience with improvements to the command bar, faster backend page loading, and multiple dashboard views.
Instant report generation, credit limit alerts for sales and invoices, separate OCR settings for invoice creation, and an auto-complete feature for forms in the accounting module.
Improved image handling and global attribute changes for mailing lists in email marketing.
A default auto-signature option and a refuse-to-sign option in HR modules.
Options to divide and merge manufacturing orders, track the status of manufacturing orders, and more in the MRP module.
Dark mode in Odoo 17.
Now that the Odoo 17 announcement is official, let’s look at what’s new in Odoo 17!
What is Odoo ERP 17?
Odoo 17 is the latest version of one of the world’s leading open-source enterprise ERPs. This version has come up with significant improvements explained here in this blog. Also, this new version aims to introduce features that enhance time-saving, efficiency, and productivity for users across various organisations.
Odoo 17, released at the Odoo Experience 2023, brought notable improvements to the user interface and added new functionalities with enhancements in performance, accessibility, data analysis, and management, further expanding its reach in the market.
WWDC 2024 Keynote Review: For CocoaCoders AustinPatrick Weigel
Overview of WWDC 2024 Keynote Address.
Covers: Apple Intelligence, iOS18, macOS Sequoia, iPadOS, watchOS, visionOS, and Apple TV+.
Understandable dialogue on Apple TV+
On-device app controlling AI.
Access to ChatGPT with a guest appearance by Chief Data Thief Sam Altman!
App Locking! iPhone Mirroring! And a Calculator!!
Superpower Your Apache Kafka Applications Development with Complementary Open...Paul Brebner
Kafka Summit talk (Bangalore, India, May 2, 2024, https://events.bizzabo.com/573863/agenda/session/1300469 )
Many Apache Kafka use cases take advantage of Kafka’s ability to integrate multiple heterogeneous systems for stream processing and real-time machine learning scenarios. But Kafka also exists in a rich ecosystem of related but complementary stream processing technologies and tools, particularly from the open-source community. In this talk, we’ll take you on a tour of a selection of complementary tools that can make Kafka even more powerful. We’ll focus on tools for stream processing and querying, streaming machine learning, stream visibility and observation, stream meta-data, stream visualisation, stream development including testing and the use of Generative AI and LLMs, and stream performance and scalability. By the end you will have a good idea of the types of Kafka “superhero” tools that exist, which are my favourites (and what superpowers they have), and how they combine to save your Kafka applications development universe from swamploads of data stagnation monsters!
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Paul Brebner
Closing talk for the Performance Engineering track at Community Over Code EU (Bratislava, Slovakia, June 5 2024) https://eu.communityovercode.org/sessions/2024/why-apache-kafka-clusters-are-like-galaxies-and-other-cosmic-kafka-quandaries-explored/ Instaclustr (now part of NetApp) manages 100s of Apache Kafka clusters of many different sizes, for a variety of use cases and customers. For the last 7 years I’ve been focused outwardly on exploring Kafka application development challenges, but recently I decided to look inward and see what I could discover about the performance, scalability and resource characteristics of the Kafka clusters themselves. Using a suite of Performance Engineering techniques, I will reveal some surprising discoveries about cosmic Kafka mysteries in our data centres, related to: cluster sizes and distribution (using Zipf’s Law), horizontal vs. vertical scalability, and predicting Kafka performance using metrics, modelling and regression techniques. These insights are relevant to Kafka developers and operators.
8 Best Automated Android App Testing Tool and Framework in 2024.pdfkalichargn70th171
Regarding mobile operating systems, two major players dominate our thoughts: Android and iPhone. With Android leading the market, software development companies are focused on delivering apps compatible with this OS. Ensuring an app's functionality across various Android devices, OS versions, and hardware specifications is critical, making Android app testing essential.
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISTier1 app
Are you ready to unlock the secrets hidden within Java thread dumps? Join us for a hands-on session where we'll delve into effective troubleshooting patterns to swiftly identify the root causes of production problems. Discover the right tools, techniques, and best practices while exploring *real-world case studies of major outages* in Fortune 500 enterprises. Engage in interactive lab exercises where you'll have the opportunity to troubleshoot thread dumps and uncover performance issues firsthand. Join us and become a master of Java thread dump analysis!
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
Consistent toolbox talks are critical for maintaining workplace safety, as they provide regular opportunities to address specific hazards and reinforce safe practices.
These brief, focused sessions ensure that safety is a continual conversation rather than a one-time event, which helps keep safety protocols fresh in employees' minds. Studies have shown that shorter, more frequent training sessions are more effective for retention and behavior change compared to longer, infrequent sessions.
Engaging workers regularly, toolbox talks promote a culture of safety, empower employees to voice concerns, and ultimately reduce the likelihood of accidents and injuries on site.
The traditional method of conducting safety talks with paper documents and lengthy meetings is not only time-consuming but also less effective. Manual tracking of attendance and compliance is prone to errors and inconsistencies, leading to gaps in safety communication and potential non-compliance with OSHA regulations. Switching to a digital solution like Safelyio offers significant advantages.
Safelyio automates the delivery and documentation of safety talks, ensuring consistency and accessibility. The microlearning approach breaks down complex safety protocols into manageable, bite-sized pieces, making it easier for employees to absorb and retain information.
This method minimizes disruptions to work schedules, eliminates the hassle of paperwork, and ensures that all safety communications are tracked and recorded accurately. Ultimately, using a digital platform like Safelyio enhances engagement, compliance, and overall safety performance on site. https://safelyio.com/
2. What is Kotlin?
•A language for Android development
•Official support: Google IO (2017)
•Currently in version 1.0
•Supports Java Frameworks/Libraries
•Kotlin files have a “.kt” extension
3. Kotlin Features
•Code is compiled to byte code
•Compile time code checking
•Run-time code checking
•Integrates with Maven, Gradle, etc
•IntelliJ automatically converts Java to Kotlin
4. Kotlin Features
• provides null safety
•Does not require “;” to separate statements
•Support for functions outside of classes
•Variables are first, then the variable type:
firstName: String
5. Kotlin Primitives
•Numeric: Double, Float, Long, Int, Short, Byte
•Other primitive types: Char, String, Boolean
•Conversion between types must be explicit
•+/-/*/ operator precedence: same as Java
6. A Kotlin “Hello World” Program
•Kotlin code:
fun main(args: Array<String>) {
println("Hello, World!")
}
•Java code:
public class HelloWorld1 {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
7. Compiling a Kotlin Program
•Step 1: compile HelloWorld.kt:
kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
•Step 2: notice the newly created JAR file:
HelloWorld.jar
•Step 3: launch HelloWorld:
java -jar HelloWorld.jar HelloWorld
•Output: Hello, World!
8. A Kotlin Program: Command Line Args
fun main(args: Array<String>) {
if (args.size < 2) {
println("Please enter a string")
return
}
println("Hello, ${args[1]}!")
}
9. Compiling a Kotlin Program
•Step 1: compile CommandLine1.kt:
kotlinc CommandLine1 -include-runtime -d CommandLine1.jar
•Step 2: notice the newly created JAR file:
CommandLine1.jar
•Step 3: launch CommandLine1:
java -jar CommandLine1.jar CommandLine1 Pasta
•Output: Hello, Pasta!
10. Kotlin Variables
•All variable declarations must be initialized
•'var' keyword: a variable that can be modified
•'val' keyword: a variable that cannot be modified
•A 'var' variable generates a getter and setter
•A 'val' variable generates only a getter
11. Kotlin Pointers
•Kotlin avoids the null pointer exception:
Use of the “Elvis” operator
•Sample code that compiles:
val name: String? = null
•Sample code that does not compile:
val name: String? = null
val namelen = name.length
12. Kotlin “val” Example
fun main(args: Array<String>) {
//val x1 : Int = 5
//val x2 : Int = 7
val x1 = 5
val x2 = 7
println("x1 = "+x1)
println("x2 = "+x2)
}
Output:
x1 = 5
x2 = 7
13. Kotlin “var” Example
fun main(args: Array<String>) {
var x1 : Int = 5
var x2 : Int = 7
var x3 = 13
var x4 = 22
val y1 = 8
val y2 = 2
14. Kotlin “var” Example
println("x1 = "+x1)
println("x2 = "+x2)
println("x3 = "+x3)
println("x4 = "+x4)
println("y1 = "+y1)
println("y2 = "+y2)
}
Exercise: compile and run this code sample
16. Kotlin unit-returning Functions
•they do not return a value
•the return type is Unit
•Unit is optionally specified
•Example:
•fun printHello(name: String?) {
• print("hello")
•}
17. Kotlin Single-Expression Functions
•return a single expression
•the curly braces can be omitted
•the body is specified after an "=" symbol
•These 3 function definitions are equivalent:
fun triple(x: Int): Int {
return 3*x
}
fun triple(x: Int): Int = 3*x
fun triple(x: Int) = 3*x
20. Kotlin Lambda Expressions
What is a Lambda Expression?
•a way of representing a function
•a powerful feature in Kotlin
•simplifies Android development
21. Kotlin Lambda Expressions
Kotlin versus Java Lambda Expressions
Kotlin lambda expressions:
•can access/modify all variables that are in scope of their
declarations
Java 8 lambda expressions:
•can only access external variables but cannot modify them
22. Kotlin Lambda Expressions
fun main(args : Array<String>) {
val printHelloWorld = {
println("Hello, world!")
}
// two ways to print result:
printHelloWorld()
printHelloWorld.invoke()
}
23. Kotlin Lambda Expressions
fun main(args : Array<String>) {
val greet = { user: String ->
println("Good afternoon, $user")
}
greet("Sara")
val showAge = { user: String, age: Int ->
println("$user is $age")
}
showAge ("Steve", 35)
}
24. Kotlin Lambda Expressions
fun main(args : Array<String>) {
val max = { a: Int, b: Int ->
if (a > b)
a
else
b
}
println("max of 10 and 4 = "+max(10,4))
}
25. Kotlin Lambda Expressions
fun main(args : Array<String>) {
val add1 = {x: Int, y: Int -> x + y}
val add2 = {x: String, y: String -> x + y}
val x1 = add1(5,7)
val x2 = add2("Hello", "Kotlin")
println("x1 = "+x1)
println("x2 = "+x2)
}
26. Kotlin Lambda Expressions
fun main(args : Array<String>) {
val add1 = {x: String, y: String -> x + y}
val add2 = {x: String, y: Any -> x + y}
val add3 = {x: Any, y: Any -> x + y} // error
val x1 = add1("Hello", "Kotlin")
val x2 = add2("Hello", "Kotlin")
val x3 = add3("Hello", 123)
println("x1 = "+x1) // HelloKotlin
println("x2 = "+x2) // HelloKotlin
println("x3 = "+x3) // error
}
27. Kotlin Higher Order Functions
•What is a Function Type?
it’s a type consisting of:
• a function signature and
• a function return type
• separated by -> operator
28. Kotlin Higher Order Functions
•Function Type Examples:
•() -> Unit // returns Unit
•() -> String // returns String
•(String) -> Unit // returns Unit
•(String) -> Float // returns Float
29. Kotlin Higher Order Functions
fun main(args : Array<String>) {
fun Fn(a:Int, b:Int) : Int {
return a + b
}
val sum = Fn(3, 5)
println("sum = "+sum)
}
30. Kotlin Higher Order Functions
fun main(args : Array<String>) {
fun Fn(a:Int, b:Int, func:(a:Int, b:Int) -> Int) {
val result = func (a, b)
println("Fn result: $result")
}
// add is of type (Int,Int) -> Int:
val add = {x: Int, y: Int -> x + y}
Fn(3, 5, add)
}
31. Kotlin Higher Order Functions
fun main(args : Array<String>) {
fun Fn(a:Int, b:Int, func1:(a:Int, b:Int) -> Int), func2:(a:Int, b:Int) -> Int) {
val result = func1( func2(a, b), func1(a,b) ) // func1(4, 14)
println("Fn result: $result")
}
// add and sub are of type (Int,Int) -> Int:
val add = {x: Int, y: Int -> x + y}
val sub = {x: Int, y: Int -> x - y}
Fn(9, 5, add, sub)
}
32. Kotlin Higher Order Functions
• Kotlin Higher Order Functions:
• The counterpart to many “intermediate operators” in FRP
• Available in various collections:
• Arrays, collections, lists and iterators
• Support method chaining
• Avoid the need for intermediate variables
34. Kotlin Higher Order Functions
• Example: working with filters:
val nums = 1 . . 25
val evens = nums.filter { it % 2 == 0 }
val odds = nums.filter { it % 2 == 1 }
evens.forEach { n -> println(n) }
odds.forEach { n -> println(n) }
35. Kotlin Higher Order Functions
• Example: working with the map function:
val numList = 1 . . 5
val times2 = numList.map{ it * 2 }
times2.forEach{ n -> println($n) }
36. Kotlin Higher Order Functions
• Example: working with filters and maps:
val nums = 1 . . 5
val x = nums.filter { it % 2 == 0 }
.map{ it * 3 }
x.forEach { n -> println($n) }
Output: ?
37. Kotlin Higher Order Functions
• Example: working with filters and maps:
val nums = 1 . . 9
val x = nums.filter { it % 4 == 0 }
.map{ it * it }
x.forEach { n -> println($n) }
Output: 16, 64
val nums = 1 . . 9
val x = nums.map { it * it }
.filter { it % 4 == 0 }
x.forEach { n -> println($n) }
Output: 4, 16, 36, 64 // 1,4,9,16,25,36,49,64,81
38. Kotlin Higher Order Functions
• Example: working with reduce:
val numList = 1 . . 5
val sumList = numList.reduce { x, y -> x + y }
println("Reduce sumList = $sumList")
39. Kotlin Higher Order Functions
• Example: working with fold:
val numList = 1 . . 5
val sumList = numList.fold(0) { x, y -> x + y }
println("Fold sumList = $sumList")
40. Kotlin Recursion
• What is Recursion?
• A solution that is composed of smaller solutions of the same type
• Can be easier to define than its iterative counterpart
• Note: problems can have an iterative and recursive solution
• Example 1: the Tower of Hanoi
• Example 2: Sierpinski triangles
• Example 3: Mandelbrot Sets (fractals)
41. Kotlin Recursion
• What are Recursive Functions?
• Functions that are defined in terms of themselves
• Example 1: the factorial function
• Example 2: Fibonacci numbers
• Example 3: Euclid’s algorithm
• Example 4: Ackerman functions
42. Kotlin Recursion
• Add the first n integers: iterative solution
• fun main(args: Array<String>) {
• var num = 5
• var result:Int = 0
• for(i in 1..num) {
• result += i
• }
• print("The sum from 0 to "+num.toString()+" = "+result.toString()+"n")
•}
• NB: the closed form solution is n*(n+1)/2
43. Kotlin Recursion
•Add the first n integers: recursive solution
• fun main(args: Array<String>) {
• var num = 5
• var result:Int
• result = sum(num)
• print(num.toString()+" factorial = "+result.toString()+"n")
•}
•fun sum(num:Int): Int {
• if(num <= 1) return 1
• return num + sum(num-1)
•}
44. Kotlin Recursion
• Factorial function: iterative solution
• fun main(args: Array<String>) {
• var num = 5
• var result:Int = 1
• for(i in 1..num) {
• result *= i
• }
• print(num.toString()+" factorial = "+result.toString()+"n")
•}
45. Kotlin Recursion
•Factorial numbers: recursive solution
• fun main(args: Array<String>) {
• var num = 5
• var result:Int
• result = fact(num)
• print(num.toString()+" factorial = "+result.toString()+"n")
•}
•fun fact(num:Int): Int {
• if(num <= 1) return 1
• return num*fact(num-1)
•}