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 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 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 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.
The document discusses Kotlin collections and aggregate operations on collections. It explains that Kotlin collections can be mutable or immutable, and by default collections are immutable unless specified as mutable. It then covers various aggregate operations that can be performed on collections like any, all, count, fold, foldRight, forEach, max, min, none etc and provides code examples for each operation.
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.
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 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 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.
The document discusses Kotlin collections and aggregate operations on collections. It explains that Kotlin collections can be mutable or immutable, and by default collections are immutable unless specified as mutable. It then covers various aggregate operations that can be performed on collections like any, all, count, fold, foldRight, forEach, max, min, none etc and provides code examples for each operation.
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.
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.
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 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
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Столпы функционального программирования для адептов ООП, Николай МозговойSigma Software
This document provides an overview of functional programming concepts for object-oriented programmers. It discusses the fundamentals of FP including immutability, purity, first-class and higher-order functions, closures, and recursion. It provides examples of these concepts in languages like Lisp, F#, C#, and JavaScript. The document also compares OO and FP concepts and discusses derived FP concepts like partial application, lazy evaluation, and pattern matching.
Hammurabi is an internal domain-specific language (DSL) for rule-based programming implemented in Scala. It allows domain experts to write rules in plain Scala code without learning a new language. Rules are evaluated by a rule engine that executes matching rules on a working memory of facts. The DSL aims to be readable, flexible and leverage Scala features like autocompletion. It also supports priorities, selecting objects, and exiting or failing evaluation. The architecture uses actors for concurrent rule evaluation. Future work includes improving performance using RETE algorithm and providing alternative selection methods.
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
The document discusses several key concepts in functional programming including:
- Immutable data and pure functions avoid side effects and allow for referential transparency.
- Higher order functions and avoiding mutable state enable concurrency and parallelism without data races.
- Programs can be designed with a pure functional core and push side effects to the outer layers for modularity.
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.
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.
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 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.
Do you want to learn Kotlin programming language from scratch? This is the 2nd episode of a simple course, focused on function and functional programming
OOP and FP - Become a Better ProgrammerMario Fusco
The story of Simon, an experienced OOP Java developer, exposed to the new lambda features of JDK 8. His friend Mario, a long-bearded FP geek, will try to convince him that FP can help him develop more readable and maintainable code. A journey into the discovery of the main new feature - lambda expressions - of JDK 8
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.
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.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
The document discusses using ES6 features in real-world applications. It provides examples of using arrow functions, classes, destructuring, template literals, and default parameters to write cleaner code. It also discusses tools for enabling ES6 features that are not yet fully supported, such as transpilers, and flags in Node.js and Chrome to enable more experimental features. Overall, the document advocates adopting ES6 features that make code more concise and readable.
Java 8 Stream API. A different way to process collections.David Gómez García
A look on one of the features of Java 8 hidden behind the lambdas. A different way to iterate Collections. You'll never see the Collecions the same way.
These are the slides I used on my talk at the "Tech Thursday" by Oracle in June in Madrid.
In this presentation, John A. De Goes looks at several concurrency and scalability problems similar to the ones all programmers have to face, and shows how purely functional solutions written using Scalaz 8 are shorter, faster, easier to test, and easier to understand than competing solutions written using Akka actors. Discover how functional programming can be your secret superpower when it comes to quickly building bullet-proof business applications!
Slides from my talk at UA Mobile 2017, 2017-11-25
Video: https://www.youtube.com/watch?v=tql9fmWX_oc
Modern programming cannot be imagined without long-running operations such as CPU-intensive computations or blocking IO running in the background. Unfortunately, having too many active threads is very expensive and kills performance, but there's a solution - coroutines. They provide a way to avoid blocking a thread and replace it with a cheaper and more controllable operation: suspension of a coroutine.
I'll talk about generators/yield, async/await, channels, composable/delimited continuations, and its usage; consider available APIs and make the overview of standard kotlinx.coroutines library.
Coroutines in Kotlin provide a way to write asynchronous, non-blocking code while maintaining a synchronous appearance and avoiding callbacks. Coroutines allow suspending functions to yield and resume work, providing an alternative to callbacks for asynchronous operations. The Kotlin standard library provides primitives for coroutines including suspending functions, builders for sequences and streams, and methods for job control and cancellation. While still experimental, coroutines are stable and recommended for use in production code.
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.
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 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
Lambdas and Streams Master Class Part 2José Paumard
These are the slides of the talk we made with Stuart Marks at Devoxx Belgium 2018. This second part covers the Stream API, reduction and the Collector API.
What is the state of lambda expressions in Java 11? Lambda expressions are the major feature of Java 8, having an impact on most of the API, including the Streams and Collections API. We are now living the Java 11 days; new features have been added and new patterns have emerged. This highly technical Deep Dive session will visit all these patterns, the well-known ones and the new ones, in an interactive hybrid of lecture and laboratory. We present a technique and show how it helps solve a problem. We then present another problem, and give you some time to solve it yourself. Finally, we present a solution, and open for questions, comments, and discussion. Bring your laptop set up with JDK 11 and your favorite IDE, and be prepared to think!
Столпы функционального программирования для адептов ООП, Николай МозговойSigma Software
This document provides an overview of functional programming concepts for object-oriented programmers. It discusses the fundamentals of FP including immutability, purity, first-class and higher-order functions, closures, and recursion. It provides examples of these concepts in languages like Lisp, F#, C#, and JavaScript. The document also compares OO and FP concepts and discusses derived FP concepts like partial application, lazy evaluation, and pattern matching.
Hammurabi is an internal domain-specific language (DSL) for rule-based programming implemented in Scala. It allows domain experts to write rules in plain Scala code without learning a new language. Rules are evaluated by a rule engine that executes matching rules on a working memory of facts. The DSL aims to be readable, flexible and leverage Scala features like autocompletion. It also supports priorities, selecting objects, and exiting or failing evaluation. The architecture uses actors for concurrent rule evaluation. Future work includes improving performance using RETE algorithm and providing alternative selection methods.
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
The document discusses several key concepts in functional programming including:
- Immutable data and pure functions avoid side effects and allow for referential transparency.
- Higher order functions and avoiding mutable state enable concurrency and parallelism without data races.
- Programs can be designed with a pure functional core and push side effects to the outer layers for modularity.
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.
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.
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 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.
Do you want to learn Kotlin programming language from scratch? This is the 2nd episode of a simple course, focused on function and functional programming
OOP and FP - Become a Better ProgrammerMario Fusco
The story of Simon, an experienced OOP Java developer, exposed to the new lambda features of JDK 8. His friend Mario, a long-bearded FP geek, will try to convince him that FP can help him develop more readable and maintainable code. A journey into the discovery of the main new feature - lambda expressions - of JDK 8
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.
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.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
The document discusses using ES6 features in real-world applications. It provides examples of using arrow functions, classes, destructuring, template literals, and default parameters to write cleaner code. It also discusses tools for enabling ES6 features that are not yet fully supported, such as transpilers, and flags in Node.js and Chrome to enable more experimental features. Overall, the document advocates adopting ES6 features that make code more concise and readable.
Java 8 Stream API. A different way to process collections.David Gómez García
A look on one of the features of Java 8 hidden behind the lambdas. A different way to iterate Collections. You'll never see the Collecions the same way.
These are the slides I used on my talk at the "Tech Thursday" by Oracle in June in Madrid.
In this presentation, John A. De Goes looks at several concurrency and scalability problems similar to the ones all programmers have to face, and shows how purely functional solutions written using Scalaz 8 are shorter, faster, easier to test, and easier to understand than competing solutions written using Akka actors. Discover how functional programming can be your secret superpower when it comes to quickly building bullet-proof business applications!
Slides from my talk at UA Mobile 2017, 2017-11-25
Video: https://www.youtube.com/watch?v=tql9fmWX_oc
Modern programming cannot be imagined without long-running operations such as CPU-intensive computations or blocking IO running in the background. Unfortunately, having too many active threads is very expensive and kills performance, but there's a solution - coroutines. They provide a way to avoid blocking a thread and replace it with a cheaper and more controllable operation: suspension of a coroutine.
I'll talk about generators/yield, async/await, channels, composable/delimited continuations, and its usage; consider available APIs and make the overview of standard kotlinx.coroutines library.
Coroutines in Kotlin provide a way to write asynchronous, non-blocking code while maintaining a synchronous appearance and avoiding callbacks. Coroutines allow suspending functions to yield and resume work, providing an alternative to callbacks for asynchronous operations. The Kotlin standard library provides primitives for coroutines including suspending functions, builders for sequences and streams, and methods for job control and cancellation. While still experimental, coroutines are stable and recommended for use in production code.
What's in Kotlin for us - Alexandre Greschon, MyHeritageDroidConTLV
The document discusses Kotlin for Android development. It provides an overview of Kotlin, explaining that it is a programming language created by JetBrains that is now adopted by Google for Android. It highlights some key features of Kotlin like being concise, interoperable with Java, and adding null safety to the type system. The rest of the agenda covers topics like Android Kotlin extensions, functions, classes, and a glimpse at the future of Kotlin.
Great Scott! C# 7 is almost out!
Time to hop into the DeLorean with Doc Brown. If my calculations are correct, when this baby hits 88 miles per hour, we'll be traveling back to the future with C# 7. Switches? Where we're going, we don't need Switches we got Pattern Matching. Just hold on for one second. Let's get this straight, in the future Tuples will be usable! This will beg the questions. Where are we? When are we? We are in the future and we now have Local Functions and Records.
You'll walk away with a sense of where C# is going and how you can learn about its new features today by looking back to the future. This is heavy.
NetPonto - The Future Of C# - NetConf EditionPaulo Morgado
The document discusses various new features in C# and .NET, including:
- Async Main method allowing async entry points
- Inferred tuple element names for cleaner tuple syntax
- Default literal expressions avoiding unnecessary casts
- Non-trailing named arguments for more flexible calling syntax
- Pattern matching and switch expressions for more control flows
- Reference semantics for value types for improved performance
- And more proposals still in development like nullable reference types, ranges, and patterns.
It also provides links to documentation and code repositories for further reading.
The document discusses iPhone app development using Objective-C. It covers the basics of getting started, including what is needed to begin like a Mac, Xcode, and an iPhone. It then explains key Objective-C concepts like classes, methods, and memory management using retain counts. The document also discusses unit testing iOS apps using OCUnit and some Xcode tips. It emphasizes testing first and concludes by noting the market demands more apps and there is room for improvement.
ES6 is Nigh is a presentation on the future of JavaScript. It discusses the history of JavaScript and why ES6 is important for advancing the language. The presentation outlines many new features being added in ES6, such as arrow functions, classes, modules, template strings, symbols, generators, and proxies. It emphasizes that ES6 is purely additive and introduces these features without breaking backwards compatibility.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
Kotlin Perfomance on Android / Александр Смирнов (Splyt)Ontico
РИТ++ 2017, AppsConf
Зал Касабланка, 6 июня, 14:00
Тезисы:
http://appsconf.ru/2017/abstracts/2816.html
В докладе рассмотрим цену использования Kotlin в Runtime, обсудим варианты, как улучшить картину мира. Смотреть будем с точки зрения производительности, синхронно углубляясь в особенности Android, а также подумаем, как можно использовать получившийся байткод.
В докладе срыв подкапотных оптимизаций, байткод и цифры, которые покажут, насколько сильно вам смогут помочь все указанные оптимизации.
Mixing functional and object oriented approaches to programming in C#Mark Needham
The document discusses mixing functional and object-oriented programming approaches in C#. Some key points:
1) Functional programming concepts like immutable data, recursion and pattern matching can help make code more easy to understand and change.
2) Objects are still important for encapsulation and abstraction.
3) These paradigms can work together, with functional approaches used for smaller pieces of code and objects used at larger scales.
Wolltest du schon immer die Vorteile und Ideen von Scala in deinen Java oder Kotlin Projekten nutzen? Dann ist Vavr (ehemals Javaslang) genau die richtige Bibliothek für dich.
Anhand echter Projektbeispiele schauen wir uns den Nutzen an, den Vavr mit seinen syntaktischen Erweiterungen und Features bei der täglichen Arbeit bietet. Wir schauen uns Value Types, echte funktionale Datentypen an und werden lernen, wie wir Exceptions sinnvoller behandeln können. Alles für besser wartbaren und sauberen Code!
Vavr bietet die Möglichkeit, die Vorteile objekt-funktionaler Programmierung zu nutzen, ohne Java den Rücken kehren zu müssen.
Kotlin is a statically typed language that runs on the JVM, Android and browsers. It was developed by JetBrains and had its first stable release in February 2016. Some key features of Kotlin include null safety, lambdas, extension functions, and delegation which allow avoiding null checks and reducing boilerplate code compared to Java. It also integrates well with Android by reducing the need for findViewById and providing libraries like Anko that simplify common tasks. Performance tests have shown Kotlin to be as fast as Java.
This document discusses Java generics, collections, streams and related concepts. It provides code examples of:
- Defining generic classes and methods
- Using common collection interfaces like List, Set, Map and their implementations
- Working with streams to perform operations on data in a declarative way
- Using lambda expressions and functional interfaces with streams
C++: Constructor, Copy Constructor and Assignment operatorJussi Pohjolainen
The document discusses various C++ constructors including default constructors, initialization lists, copy constructors, assignment operators, and destructors. It provides examples of how to properly implement these special member functions to avoid problems like shallow copying and double deletes.
The document discusses various data types including primitive data types, strings, enumeration types, subrange types, arrays, associative arrays, record types, union types, and pointer/reference types. It provides examples of these types in languages like C++, Java, Perl, COBOL, Ada, and discusses concepts like weak typing, file I/O, memory representation, and pointer problems. The lecture outline covers these data type topics at a high level for Chapter 6.
Android Developer Group Poznań - Kotlin for Android developers
STXInsider example project in Kotlin:
https://github.com/kosiara/stx-insider
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 for 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, has clear benefits for developers on one hand and keeps short compile times on the other.
As a mobile team we got interested in Kotlin a few months before its final release which gave us time to test it thoroughly before production use. The language has some clear advantages for an Android programmer - it enables migration from Java projects that have been under development for some time already. Java&Kotlin coexistence simplifies Kotlin introduction as only new functionality is written in JetBrain’s new language leaving all the legacy code untouched.
Transitioning gives the developer an opportunity to use lambdas, new syntax for data objects, extension functions to easily expand Android SDK’s classes functionality and infix notation to write DSL-like structures. Almost all the libraries you use today will work with Kotlin thanks to 100% Java compatibility. The same is true for Android SDK classes - all of them will seamlessly work with the new programming language. Kotlin gives you more choice when it comes to reflection, creating documentation and being null-pointer safe. Android works great with it out of the box so you won’t need to change your development habits.
Our production project in Kotlin turned out to be a success after 4 months of development. We had 0 bugs related to Kotlin as a programming language. Our code footprint is almost 30% smaller thanks to JetBrain’s, we benefit from nullpointer safety, closures, translated enums, data objects and use infix notation for logging and displaying Snackbars.
===========
In this presentation you'll find 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 compilation is presented and the language is compared to SCALA and SWIFT.
We 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.
From JVM to .NET languages, from minor coding idioms to system-level architectures, functional programming is enjoying a long overdue surge in interest. Functional programming is certainly not a new idea and, although not apparently as mainstream as object-oriented and procedural programming, many of its concepts are also more familiar than many programmers believe. This talk examines functional and declarative programming styles from the point of view of coding patterns, little languages and programming techniques already familiar to many programmers.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Zilliz
Join us to introduce Milvus Lite, a vector database that can run on notebooks and laptops, share the same API with Milvus, and integrate with every popular GenAI framework. This webinar is perfect for developers seeking easy-to-use, well-integrated vector databases for their GenAI apps.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
6. lateinit properties
public final User user;
public final User getUser() {
if (user == null) {
throwUninitializedPropertyAccessException("user");
}
return user;
}
public final void setUser(User newUser) {
checkParameterIsNotNull(newUser, "<set-?>");
user = newUser;
}
@iChanSek bit.ly/chansecode
7. lateinit properties
public final User getUser() {
if (user == null) {
throwUninitializedPropertyAccessException("user");
}
return user;
}
public final void setUser(User newUser) {
checkParameterIsNotNull(newUser, "<set-?>");
@iChanSek bit.ly/chansecode
8. lateinit properties
public final User getUser() {
if (user == null) {
throwUninitializedPropertyAccessException("user");
}
return user;
}
public final void setUser(User newUser) {
checkParameterIsNotNull(newUser, "<set-?>");
user = newUser;
}
@iChanSek bit.ly/chansecode
11. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy((Function0)2.INSTANCE);
}
}
@iChanSek bit.ly/chansecode
12. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy((Function0)2.INSTANCE);
}
}
@iChanSek bit.ly/chansecode
13. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy((Function0)2.INSTANCE);
}
}
@iChanSek bit.ly/chansecode
14. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy((Function0)2.INSTANCE);
}
}
@iChanSek bit.ly/chansecode
15. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy(() -> 10);
}
}
@iChanSek bit.ly/chansecode
16. Delegated Properties
public final class DelegatedProperties {
static final KProperty[] props = new KProperty[]{ ... }
private final Lazy xDelegate;
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
public DelegatedProperties() {
this.xDelegate = LazyKt.lazy((Function0)2.INSTANCE);
}
}
@iChanSek bit.ly/chansecode
17. Delegated Properties
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
@iChanSek bit.ly/chansecode
fun main() {
val delegatedProp = DelegatedProperties()
println(delegatedProp.x)
println(delegatedProp.x)
}
18. Delegated Properties
class SynchronizedLazyImpl<out T>(initializer: () -> T, lock: Any? = null) : Lazy<T> {
private var initializer: (() -> T)? = initializer
@Volatile private var _value: Any? = UNINITIALIZED_VALUE
private val lock = lock ?: this
override val value: T
get() {
if (_value !== UNINITIALIZED_VALUE) {
return _value as T
}
return synchronized(lock) {
...
}
}
}
@iChanSek bit.ly/chansecode
fun main() {
val delegatedProp = DelegatedProperties()
println(delegatedProp.x)
println(delegatedProp.x)
}
public final int getX() {
return ((Number)xDelegate.getValue()).intValue();
}
19. Delegated Properties
class SynchronizedLazyImpl<out T>(initializer: () -> T, lock: Any? = null) : Lazy<T> {
private var initializer: (() -> T)? = initializer
@Volatile private var _value: Any? = UNINITIALIZED_VALUE
private val lock = lock ?: this
override val value: T
get() {
if (_value !== UNINITIALIZED_VALUE) {
return _value as T
}
return synchronized(lock) {
...
}
}
}
@iChanSek bit.ly/chansecode
20. Delegated Properties
class SynchronizedLazyImpl<out T>(initializer: () -> T, lock: Any? = null) : Lazy<T> {
private var initializer: (() -> T)? = initializer
@Volatile private var _value: Any? = UNINITIALIZED_VALUE
private val lock = lock ?: this
override val value: T
get() {
if (_value !== UNINITIALIZED_VALUE) {
return _value as T
}
return synchronized(lock) {
...
}
}
}
@iChanSek bit.ly/chansecode
26. Nullable and Non-Nullable
C c;
if (a != null) {
B b = a.b;
if (b != null) {
c = b.c;
}
}
@iChanSek bit.ly/chansecode
27. Nullable and Non-Nullable
C c;
label1: {
if (a != null) {
B b = a.b;
if (b != null) {
c = b.c;
break label1;
}
}
c = null;
}
@iChanSek bit.ly/chansecode
45. When Expression
switch(WhenMappings.$EnumSwitchMapping$0[colour.ordinal()]) {
case 1:
...
break;
case 2:
...
break;
case 3:
...
break;
......
}
@iChanSek bit.ly/chansecode
public final class WhenKt$WhenMappings {
public static final int[] $EnumSwitchMapping$0 = new
int[Colour.values().length];
static {
$EnumSwitchMapping$0[Colour.RED.ordinal()] = 1;
$EnumSwitchMapping$0[Colour.GREEN.ordinal()] = 2;
$EnumSwitchMapping$0[Colour.BLUE.ordinal()] = 3;
}
}
46. When Expression
switch(WhenMappings.$EnumSwitchMapping$0[colour.ordinal()]) {
case 1:
...
break;
case 2:
...
break;
case 3:
...
break;
......
}
@iChanSek bit.ly/chansecode
public final class WhenKt$WhenMappings {
public static final int[] $EnumSwitchMapping$0 = new
int[Colour.values().length];
static {
$EnumSwitchMapping$0[Colour.RED.ordinal()] = 1;
$EnumSwitchMapping$0[Colour.GREEN.ordinal()] = 2;
$EnumSwitchMapping$0[Colour.BLUE.ordinal()] = 3;
}
}
52. Destructuring Declarations
data class User(
val name: String,
val age: Int
)
val user = User("Chandra", 10)
val (name, age) = user
@iChanSek bit.ly/chansecode
53. Destructuring Declarations
public final class User {
...
public final String component1() {
return this.name;
}
public final int component2() {
return this.age;
} val user = User("Chandra", 10)
} val (name, age) = user
@iChanSek bit.ly/chansecode
54. Destructuring Declarations
public final class User {
...
public final String component1() {
return this.name;
}
public final int component2() {
return this.age;
}
}
@iChanSek bit.ly/chansecode
String name = user.component1();
int age = user.component2();
56. Sealed Classes
sealed class Calculation
class Add(val num1: Int, val num2: Int) : Calculation()
class Sub(val num1: Int, val num2: Int) : Calculation()
class Mul(val num1: Int, val num2: Int) : Calculation()
class Div(val num1: Int, val num2: Int) : Calculation()
@iChanSek bit.ly/chansecode
57. Sealed Classes
public abstract class Calculation {
private Calculation() {}
}
class Add(val num1: Int, val num2: Int) : Calculation()
class Sub(val num1: Int, val num2: Int) : Calculation()
class Mul(val num1: Int, val num2: Int) : Calculation()
class Div(val num1: Int, val num2: Int) : Calculation()
@iChanSek bit.ly/chansecode
58. Sealed Classes
public abstract class Calculation {
private Calculation() {}
}
public final class Add extends Calculation { ... }
public final class Sub extends Calculation { ... }
public final class Mul extends Calculation { ... }
public final class Div extends Calculation { ... }
@iChanSek bit.ly/chansecode
59. Sealed Classes
private fun calculate(calculator: Calculation) {
when(calculator) {
is Add -> calculator.num1 + calculator.num2
is Sub -> calculator.num1 - calculator.num2
is Mul -> calculator.num1 * calculator.num2
is Div -> calculator.num1 / calculator.num2
}
}
@iChanSek bit.ly/chansecode
60. Sealed Classes
private static final void calculate(Calculation calculator) {
int result;
if (calculator instanceof Add) {
result = ((Add)calculator).getNum1() + ((Add)calculator).getNum2();
} else if (calculator instanceof Sub) {
result = ((Sub)calculator).getNum1() - ((Sub)calculator).getNum2();
} else if (calculator instanceof Mul) {
result = ((Mul)calculator).getNum1() * ((Mul)calculator).getNum2();
} else if (calculator instanceof Div) {
result = ((Div)calculator).getNum1() / ((Div)calculator).getNum2();
}
}
@iChanSek bit.ly/chansecode
63. Inline Classes
public final class UserId {
private final long id;
public static long constructor_impl(long id) {
return id;
}
public static final UserId box_impl(long v) {
return new UserId(v);
}
public final long unbox_impl() {
return this.id;
}
}
@iChanSek bit.ly/chansecode
64. Inline Classes
public final class UserId {
private final long id;
public static long constructor_impl(long id) {
return id;
}
public static final UserId box_impl(long v) {
return new UserId(v);
}
public final long unbox_impl() {
return this.id;
}
}
@iChanSek bit.ly/chansecode
65. Inline Classes
public final class UserId {
private final long id;
public static long constructor_impl(long id) {
return id;
}
public static final UserId box_impl(long v) {
return new UserId(v);
}
public final long unbox_impl() {
return this.id;
}
}
@iChanSek bit.ly/chansecode
66. Inline Classes
public final class UserId {
private final long id;
public static long constructor_impl(long id) {
return id;
}
public static final UserId box_impl(long v) {
return new UserId(v);
}
public final long unbox_impl() {
return this.id;
}
}
@iChanSek bit.ly/chansecode
67. Inline Classes
fun main() {
val userId = UserId(10L)
getUser(userId)
}
private fun getUser(id: UserId) {
// Do something with id
}
@iChanSek bit.ly/chansecode
68. Inline Classes
public static final void main() {
long userId = UserId.constructor_impl(10L);
getUser(userId);
}
// UserId became long in the argument
private static final void getUser(long id) {
// Do something with id
}
@iChanSek bit.ly/chansecode
73. Default Methods
public final class DefaultCalculatorImpl implements Calculator {
public int div(int a, int b) {
return Calculator.DefaultImpls.div(this, a, b);
}
}
public final class CalculatorImpl implements Calculator {
public int div(int a, int b) {
...
}
}
@iChanSek bit.ly/chansecode
77. Extension Function
public static final void swap(int[] arr, int index1, int index2) {
Intrinsics.checkParameterIsNotNull(arr, "arr");
int temp = arr[index1];
arr[index1] = arr[index2];
arr[index2] = temp;
}
@iChanSek bit.ly/chansecode
81. Default Arguments
fun add(a: Int,
b : Int,
c: Int = 100,
d: Int = 200,
e: Int = 300) =
a + b + c + d + e
@iChanSek bit.ly/chansecode
82. Default Arguments
... int add(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
@iChanSek bit.ly/chansecode
83. Default Arguments
... int add(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
fun main() {
add(2, 3, 4, 5, 6)
}
@iChanSek bit.ly/chansecode
84. Default Arguments
... int add(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
fun main() {
add(2, 3, 4, 5, 6)
add(2, 3)
}
@iChanSek bit.ly/chansecode
85. Default Arguments
... int add(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
fun main() {
add(2, 3, 4, 5, 6)
add(2, 3)
add(2, 3, 4, 5)
}
@iChanSek bit.ly/chansecode
86. Default Arguments
... int add(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
public static final void main() {
add(2, 3, 4, 5, 6);
add(2, 3, 0, 0, 0, 28, _);
add(2, 3, 4, 5, 0, 16, _);
}
@iChanSek bit.ly/chansecode
87. Default Arguments
... int add$default(int a, int b, int c, int d, int e, int var5, _) {
...
}
public static final void main() {
add(2, 3, 4, 5, 6);
add$default(2, 3, 0, 0, 0, 28, _);
add$default(2, 3, 4, 5, 0, 16, _);
}
@iChanSek bit.ly/chansecode
88. Default Arguments
... int add$default(int a, int b, int c, int d, int e, int var5, …) {
...
}
public static final void main() {
add(2, 3, 4, 5, 6);
add$default(2, 3, 0, 0, 0, 22 + 23 + 24, _);
add$default(2, 3, 4, 5, 0, 24, _);
}
@iChanSek bit.ly/chansecode
89. Default Arguments
... int add$default(int a, int b, int c, int d, int e, int var5, _) {
if ((var5 & 4) != 0) c = 100;
if ((var5 & 8) != 0) d = 200;
if ((var5 & 16) != 0) e = 300;
return add(a, b, c, d, e);
}
@iChanSek bit.ly/chansecode
91. Local Functions
fun outer() {
fun inner() {
println(“ Kolkata”)
}
println(“Welcome to DevFest")
if (event == "DevFest Kolkata") inner()
}
@iChanSek bit.ly/chansecode
92. Local Functions
public static final void outer() {
Inner inner = Inner.INSTANCE;
System.out.println("Welcome to DevFest");
if (Intrinsics.areEqual(event, "DevFest Kolkata")) {
inner.invoke();
}
}
@iChanSek bit.ly/chansecode
93. Local Functions
public static final void outer() {
Inner inner = Inner.INSTANCE;
System.out.println("Welcome to DevFest");
if (Intrinsics.areEqual(event, "DevFest Kolkata")) {
inner.invoke();
}
}
@iChanSek bit.ly/chansecode
final class Inner extends Lambda
implements Function0 {
... Inner INSTANCE = new Inner();
public final void invoke() {
System.out.println(" Kolkata");
}
Inner() { super(0); }
}
96. Lambda Functions
val sum: (Int, Int) -> Int = { x, y -> x + y }
... Function2<_, _, _> sum = new Function2<_, _, _>() {
@Override
public final int invoke(int a, int b) {
return a + b;
}
};
@iChanSek bit.ly/chansecode
97. Lambda Functions
() -> Unit == class XXX implements Function0<Unit>
@iChanSek bit.ly/chansecode
98. Lambda Functions
() -> Unit == class XXX implements Function0<Unit>
(Int, Int) -> Int == class XXX implements Function2<Int, Int, Int>
@iChanSek bit.ly/chansecode
102. Lambda with Receiver
val sum: Int.(Int) -> Int = { this + it }
... Function2<_, _, _> sum = new Function2<_, _, _>() {
@Override
public final int invoke(int $receiver, int a) {
return $receiver + a;
}
};
@iChanSek bit.ly/chansecode
103. Lambda Functions
() -> Unit == class XXX implements Function0<Unit>
(Int, Int) -> Int == class XXX implements Function2<Int, Int, Int>
@iChanSek bit.ly/chansecode
104. Lambda Functions
() -> Unit == class XXX implements Function0<Unit>
(Int, Int) -> Int == class XXX implements Function2<Int, Int, Int>
Int.(Int) -> Int == class XXX implements Function2<Int, Int, Int>
@iChanSek bit.ly/chansecode