Introducing Kotlin — JVM-based language made by JetBrains. Kotlin takes aim at the age and perceived uncoolness of the Java with fresh and popular language features. It can do anything the Java language can do and more, but often with a more concise and pleasant syntax.
Optional was introduced in Java 8 to help deal with null references in a safer way. Optional wraps an object that may or may not be present, and supports methods like map, filter, and flatMap to operate on the wrapped value in a functional style. Using Optional helps avoid NullPointerExceptions and makes it clear whether a value is present or absent, improving code readability and safety over directly using null references.
Kotlin: A pragmatic language by JetBrainsJigar Gosar
A pragmatic language for JVM and Android.
Combines OO and functional features.
Focused on interoperability, safety, clarity, tooling support.
Open Source.
Works everywhere where Java works.
Key focus on interoperability and seamless support for mixed Java+Kotlin projects.
This document discusses virtual inheritance in C++. It defines classes for Animal, Horse, Bird, and Pegasus that inherit from each other virtually and non-virtually. The main function creates a Pegasus object and calls methods to demonstrate the inheritance and polymorphism.
This document provides an overview of the Swift programming language. It discusses Swift's basic data types including variables, constants, strings, arrays, dictionaries, tuples, optionals, and basic control flow structures like if/else statements and loops. It also covers classes, structures, enums, extensions, generics, closures, and other advanced topics like protocols, operators, and subscripts.
A character or string function is a function which takes one or more characters or numbers as parameters and returns a character value. Basic string functions offer a number of capabilities and return a string value as a result set.
The document provides an introduction to Swift programming concepts including variables, constants, data types, operators, control flow, functions, arrays, dictionaries, classes, structs, enums and more. Code examples are provided to demonstrate how to declare and use variables, constants, functions, arrays, dictionaries, classes, structs and enums in Swift. Key Swift concepts like optionals, tuples, protocols and generics are also briefly covered through code snippets.
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.
Optional was introduced in Java 8 to help deal with null references in a safer way. Optional wraps an object that may or may not be present, and supports methods like map, filter, and flatMap to operate on the wrapped value in a functional style. Using Optional helps avoid NullPointerExceptions and makes it clear whether a value is present or absent, improving code readability and safety over directly using null references.
Kotlin: A pragmatic language by JetBrainsJigar Gosar
A pragmatic language for JVM and Android.
Combines OO and functional features.
Focused on interoperability, safety, clarity, tooling support.
Open Source.
Works everywhere where Java works.
Key focus on interoperability and seamless support for mixed Java+Kotlin projects.
This document discusses virtual inheritance in C++. It defines classes for Animal, Horse, Bird, and Pegasus that inherit from each other virtually and non-virtually. The main function creates a Pegasus object and calls methods to demonstrate the inheritance and polymorphism.
This document provides an overview of the Swift programming language. It discusses Swift's basic data types including variables, constants, strings, arrays, dictionaries, tuples, optionals, and basic control flow structures like if/else statements and loops. It also covers classes, structures, enums, extensions, generics, closures, and other advanced topics like protocols, operators, and subscripts.
A character or string function is a function which takes one or more characters or numbers as parameters and returns a character value. Basic string functions offer a number of capabilities and return a string value as a result set.
The document provides an introduction to Swift programming concepts including variables, constants, data types, operators, control flow, functions, arrays, dictionaries, classes, structs, enums and more. Code examples are provided to demonstrate how to declare and use variables, constants, functions, arrays, dictionaries, classes, structs and enums in Swift. Key Swift concepts like optionals, tuples, protocols and generics are also briefly covered through code snippets.
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.
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan s.r.o.
KotlinPref is a library that provides delegation functionality for Android's SharedPreferences in Kotlin. It allows accessing SharedPreferences values via synthetic properties rather than directly calling getString, getInt etc. This reduces boilerplate and makes the code more readable. The document provides examples of how to use KotlinPref to store and retrieve values from SharedPreferences in a simpler way compared to the traditional Android approach.
The document discusses an introduction to C++ programming. It covers basic C++ concepts like variables, data types, input/output, operators, and functions. It provides examples of simple C++ programs and explains concepts like object-oriented programming, classes, and inheritance. The document is meant to introduce students to C++ as their first object-oriented programming language.
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.
The present and the future of functional programming in c++Alexander Granin
This document discusses functional programming concepts in C++. It begins with a list of talks on functional programming in C++ given by various speakers. It then provides an overview of the philosophy of functional programming and how the C++ language and developers have evolved to incorporate more functional concepts. The rest of the document discusses elements of functional programming in C++ like lambdas, purity and immutability, and provides examples of implementing pure functional programming concepts using templates like recursive functions.
The document describes monadic parsers and how they can be implemented using functional programming concepts like functors, applicatives, and monads. It shows how parser combinators can be built to parse input using techniques like binding, alternative parsing, and between operators. Examples demonstrate parsing employee records and expressions using monadic parsers.
Let's make a contract: the art of designing a Java APIMario Fusco
The document discusses best practices for designing Java APIs. It emphasizes making APIs intuitive, consistent, discoverable and easy to use. Some specific tips include using static factories to create objects, promoting fluent interfaces, using the weakest possible types, supporting lambdas, avoiding checked exceptions and properly managing resources using try-with-resources. The goal is to design APIs that are flexible, evolvable and minimize surprises for developers.
The final dream of every developer is creating his own programming language. Today it is possible to realize that dream with a reasonable effort. In addition to that is also possible to leverage the JVM to make a language that can reuse a huge amount of libraries. In this presentation we are going to see what elements do we need to build our own language, with a compiler for the JVM. This is not only a lot of fun but it can be also useful in practice, to build Domain Specific Languages that compiles to bytecode and can be used together with mainstream languages in larger applications.
Kotlin is a statically-typed programming language for the JVM and the browser, built by a team at JetBrains and designed as a pragmatic and easy-to-use Java alternative. In this presentation we'll explore the most notable Kotlin features, such as:
- Extension functions
- Null-safety
- Smart casts
- and many more
Check out and see that programming in Kotlin is fun!
The document summarizes new features introduced in Java 5, including generics for type-safe collections, enhanced for-each loops, auto-boxing/unboxing of primitive types, typesafe enums, variable arguments, static imports, annotations, and improved formatted output. It provides code examples to illustrate how these new features improve on and replace older styles in Java.
This document summarizes the key concepts and components of Gremlin's graph traversal machinery:
- Gremlin uses a traversal language to express graph queries via step composition, with steps mapping traversers between domains.
- Traversals are compiled to bytecode and optimized by traversal strategies before being executed by the Gremlin machine.
- The Gremlin machine consists of steps implementing functions that process traverser streams. Their composition forms the traversal.
- Gremlin is language-agnostic, with language variants translating to a shared bytecode that interacts with the Java-based implementation.
Towards Domain Refinement for UML/OCL Bounded Verificationrclariso
Correctness of UML class diagrams annotated with OCL constraints can be checked using bounded verication, e.g. SAT solvers. Bounded verication detects faults efficiently but, on the other hand, the absence of faults does not guarantee a correct behavior outside the bounded domain. Hence, choosing suitable bounds is a non-trivial process as there is a trade-o between the verication time (faster for smaller domains) and the condence in the result (better for larger domains).
Unfortunately, existing tools provide little support in this choice.This paper presents a technique that can be used to (i) automatically infer verication bounds whenever possible, (ii) tighten a set of bounds proposed by the user and (iii) guide the user in the bound selection process. This approach may increase the usability of UML/OCL bounded verification tools and improve the efficiency of the verification process.
Presented in SEFM 2015 (13h International Conference on Software Engineering and Formal Methods, 8-11 Sept 2015, York, UK). Work co-authored with Carlos A. González and Jordi Cabot.
Presented on 27th September 2017 to a joint meeting of 'Cork Functional Programmers' and the 'Cork Java Users Group'
Based on the Kotlin Language programming course from Instil. For more details see https://instil.co/courses/kotlin-development/
At the heart of data processing, event-sourcing, actors, and much more is the queue—a data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goes—architect of the Scalaz 8 effect system—introduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Scalaz-stream introduced the Scala ecosystem to purely functional streams. Although widely deployed in production at Verizon, SlamData, and elsewhere, the last release of scalaz-stream was October 23rd, 2016, and newer projects such as FS2, Monix Iterant, and others have risen to fill the gap, each addressing different use cases in the functional programming community. In this talk, John A. De Goes, architect of the Scalaz 8 effect system, unveils a new design for a next-generation version of scalaz-stream. Designed to embrace the powerful features of the Scalaz 8 effect system—features not available in any other effect type—this design features higher-performance, stronger guarantees, and far less code than previous incarnations. You are invited to discover the practicality of functional programming, as well as its elegance, beauty, and composability, in this unique presentation available exclusively at Scale By the Bay.
Functional programming for production quality codeJack Fox
This document discusses functional programming techniques for production quality code. It covers topics like partial application, summation types, pattern matching, monadic binding, function composition, and units of measure. It also discusses using computation expressions for asynchronous code and functional approaches to working with relational data using F# types generated from SQL queries and stored procedures.
This document provides an introduction to the Swift programming language presented by Giuseppe Arici and Matteo Battaglio. It covers the history and principles of Swift, highlighting that it is a modern, multi-paradigm language inspired by many other languages. The document then discusses key Swift concepts like constants and variables, functions and closures, tuples and pattern matching, classes and structs, protocols and extensions, generics and optionals. It encourages exploring these concepts through playgrounds and considers open questions around Swift's future and use in production environments.
La teoria delle categorie sta alla programmazione funzionale come i GoF design pattern stanno a quella ad oggetti. Vista l’imminente introduzione delle lambda expression, è tempo anche per gli sviluppatori Java di imparare qualcosa in più riguardo ai più comuni pattern di programmazione funzionale. Le monadi sono probabilmente le più espressive (e forse le più incomprese) fra questi pattern, per cui lo scopo del talk è quello di introdurle, chiarendo con esempi pratici come e quando dovrebbero essere usate, sottolineando i loro vantaggi e mostrando come possono essere implementate in Java8.
Lambdaj is an internal DSL that allows manipulating collections without loops. It provides static methods to filter, sort, extract, and otherwise operate on collections. By treating collections as single objects and allowing method references, lambdaj can concisely represent operations that would otherwise require loops. While lambdaj is generally 4-6 times slower than iterative versions, it improves readability of collection operations.
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
This document provides an overview of Kotlin basics including:
- Basic data types like Int, String, Boolean
- Collections like List, Set, Map
- Variables, functions, control flow
- Classes, properties, constructors
- Inheritance, interfaces
- Additional features like lambdas, extensions, coroutines
It aims to introduce fundamental Kotlin concepts and syntax in a concise manner.
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.
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan s.r.o.
KotlinPref is a library that provides delegation functionality for Android's SharedPreferences in Kotlin. It allows accessing SharedPreferences values via synthetic properties rather than directly calling getString, getInt etc. This reduces boilerplate and makes the code more readable. The document provides examples of how to use KotlinPref to store and retrieve values from SharedPreferences in a simpler way compared to the traditional Android approach.
The document discusses an introduction to C++ programming. It covers basic C++ concepts like variables, data types, input/output, operators, and functions. It provides examples of simple C++ programs and explains concepts like object-oriented programming, classes, and inheritance. The document is meant to introduce students to C++ as their first object-oriented programming language.
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.
The present and the future of functional programming in c++Alexander Granin
This document discusses functional programming concepts in C++. It begins with a list of talks on functional programming in C++ given by various speakers. It then provides an overview of the philosophy of functional programming and how the C++ language and developers have evolved to incorporate more functional concepts. The rest of the document discusses elements of functional programming in C++ like lambdas, purity and immutability, and provides examples of implementing pure functional programming concepts using templates like recursive functions.
The document describes monadic parsers and how they can be implemented using functional programming concepts like functors, applicatives, and monads. It shows how parser combinators can be built to parse input using techniques like binding, alternative parsing, and between operators. Examples demonstrate parsing employee records and expressions using monadic parsers.
Let's make a contract: the art of designing a Java APIMario Fusco
The document discusses best practices for designing Java APIs. It emphasizes making APIs intuitive, consistent, discoverable and easy to use. Some specific tips include using static factories to create objects, promoting fluent interfaces, using the weakest possible types, supporting lambdas, avoiding checked exceptions and properly managing resources using try-with-resources. The goal is to design APIs that are flexible, evolvable and minimize surprises for developers.
The final dream of every developer is creating his own programming language. Today it is possible to realize that dream with a reasonable effort. In addition to that is also possible to leverage the JVM to make a language that can reuse a huge amount of libraries. In this presentation we are going to see what elements do we need to build our own language, with a compiler for the JVM. This is not only a lot of fun but it can be also useful in practice, to build Domain Specific Languages that compiles to bytecode and can be used together with mainstream languages in larger applications.
Kotlin is a statically-typed programming language for the JVM and the browser, built by a team at JetBrains and designed as a pragmatic and easy-to-use Java alternative. In this presentation we'll explore the most notable Kotlin features, such as:
- Extension functions
- Null-safety
- Smart casts
- and many more
Check out and see that programming in Kotlin is fun!
The document summarizes new features introduced in Java 5, including generics for type-safe collections, enhanced for-each loops, auto-boxing/unboxing of primitive types, typesafe enums, variable arguments, static imports, annotations, and improved formatted output. It provides code examples to illustrate how these new features improve on and replace older styles in Java.
This document summarizes the key concepts and components of Gremlin's graph traversal machinery:
- Gremlin uses a traversal language to express graph queries via step composition, with steps mapping traversers between domains.
- Traversals are compiled to bytecode and optimized by traversal strategies before being executed by the Gremlin machine.
- The Gremlin machine consists of steps implementing functions that process traverser streams. Their composition forms the traversal.
- Gremlin is language-agnostic, with language variants translating to a shared bytecode that interacts with the Java-based implementation.
Towards Domain Refinement for UML/OCL Bounded Verificationrclariso
Correctness of UML class diagrams annotated with OCL constraints can be checked using bounded verication, e.g. SAT solvers. Bounded verication detects faults efficiently but, on the other hand, the absence of faults does not guarantee a correct behavior outside the bounded domain. Hence, choosing suitable bounds is a non-trivial process as there is a trade-o between the verication time (faster for smaller domains) and the condence in the result (better for larger domains).
Unfortunately, existing tools provide little support in this choice.This paper presents a technique that can be used to (i) automatically infer verication bounds whenever possible, (ii) tighten a set of bounds proposed by the user and (iii) guide the user in the bound selection process. This approach may increase the usability of UML/OCL bounded verification tools and improve the efficiency of the verification process.
Presented in SEFM 2015 (13h International Conference on Software Engineering and Formal Methods, 8-11 Sept 2015, York, UK). Work co-authored with Carlos A. González and Jordi Cabot.
Presented on 27th September 2017 to a joint meeting of 'Cork Functional Programmers' and the 'Cork Java Users Group'
Based on the Kotlin Language programming course from Instil. For more details see https://instil.co/courses/kotlin-development/
At the heart of data processing, event-sourcing, actors, and much more is the queue—a data structure that allows producers to pass work to consumers in a flexible way. On the JVM, most libraries, including Akka, are powered by Java concurrent queues, which are reliable but were designed in a different era, for synchronous (blocking) procedural code. In this presentation, John A. De Goes—architect of the Scalaz 8 effect system—introduces IOQueue, a new type of queue powered by the Scalaz 8 IO monad. IOQueue never blocks and provides seamless, composable back-pressure across an entire application, without users having to think about the problem or write any special code. John will discuss how IOQueue achieves these remarkable properties, and show how the structure can be used to solve hard problems with just a few lines of type-safe, leak-free, composable Scala code. Come learn about the power of Scalaz to solve the hard problems of software development, in a principled way, without compromises.
Scalaz-stream introduced the Scala ecosystem to purely functional streams. Although widely deployed in production at Verizon, SlamData, and elsewhere, the last release of scalaz-stream was October 23rd, 2016, and newer projects such as FS2, Monix Iterant, and others have risen to fill the gap, each addressing different use cases in the functional programming community. In this talk, John A. De Goes, architect of the Scalaz 8 effect system, unveils a new design for a next-generation version of scalaz-stream. Designed to embrace the powerful features of the Scalaz 8 effect system—features not available in any other effect type—this design features higher-performance, stronger guarantees, and far less code than previous incarnations. You are invited to discover the practicality of functional programming, as well as its elegance, beauty, and composability, in this unique presentation available exclusively at Scale By the Bay.
Functional programming for production quality codeJack Fox
This document discusses functional programming techniques for production quality code. It covers topics like partial application, summation types, pattern matching, monadic binding, function composition, and units of measure. It also discusses using computation expressions for asynchronous code and functional approaches to working with relational data using F# types generated from SQL queries and stored procedures.
This document provides an introduction to the Swift programming language presented by Giuseppe Arici and Matteo Battaglio. It covers the history and principles of Swift, highlighting that it is a modern, multi-paradigm language inspired by many other languages. The document then discusses key Swift concepts like constants and variables, functions and closures, tuples and pattern matching, classes and structs, protocols and extensions, generics and optionals. It encourages exploring these concepts through playgrounds and considers open questions around Swift's future and use in production environments.
La teoria delle categorie sta alla programmazione funzionale come i GoF design pattern stanno a quella ad oggetti. Vista l’imminente introduzione delle lambda expression, è tempo anche per gli sviluppatori Java di imparare qualcosa in più riguardo ai più comuni pattern di programmazione funzionale. Le monadi sono probabilmente le più espressive (e forse le più incomprese) fra questi pattern, per cui lo scopo del talk è quello di introdurle, chiarendo con esempi pratici come e quando dovrebbero essere usate, sottolineando i loro vantaggi e mostrando come possono essere implementate in Java8.
Lambdaj is an internal DSL that allows manipulating collections without loops. It provides static methods to filter, sort, extract, and otherwise operate on collections. By treating collections as single objects and allowing method references, lambdaj can concisely represent operations that would otherwise require loops. While lambdaj is generally 4-6 times slower than iterative versions, it improves readability of collection operations.
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
This document provides an overview of Kotlin basics including:
- Basic data types like Int, String, Boolean
- Collections like List, Set, Map
- Variables, functions, control flow
- Classes, properties, constructors
- Inheritance, interfaces
- Additional features like lambdas, extensions, coroutines
It aims to introduce fundamental Kotlin concepts and syntax in a concise manner.
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 introduces Swift syntax and basics. It begins by asking why readers are interested in Swift and what their programming experience is. It then provides brief descriptions of Swift and the instructor's background. The document goes on to cover Swift variables, constants, strings, collection types like arrays and dictionaries, control flow like loops, functions, classes and properties. It provides examples of each concept to demonstrate Swift syntax.
This document discusses Kotlin, a statically typed programming language that is concise, safe, and interoperable. It was created by JetBrains and can be used for both Android and server-side development. The document provides examples of Kotlin code showing functions, variables, conditional expressions, null safety checks, type checks, ranges, collections, and more. It directs readers to additional Kotlin resources and encourages attendees of the JConf Centroamerica 2020 conference.
Kotlin is a JVM language developed by Jetbrains. Its version 1.0 (production ready) was released at the beginning of the year and made some buzz within the android community. This session proposes to discover this language, which takes up some aspects of groovy or scala, and that is very close to swift in syntax and concepts. We will see how Kotlin boosts the productivity of Java & Android application development and how well it accompanies reactive development.
01 Introduction to Kotlin - Programming in Kotlin.pptxIvanZawPhyo
Kotlin is a programming language that is expressive, concise, and portable. It runs on the Java Virtual Machine and is fully interoperable with Java. Kotlin focuses on safety, interoperability, and tooling support. The basics of Kotlin include top-level functions, variables, if/when expressions, loops, ranges, null safety features, and string templates. Kotlin avoids null pointer exceptions through language features like the Elvis operator, safe calls, and non-null types.
Kotlin is a programming language that is expressive, concise, and portable. It runs on the Java Virtual Machine and is fully interoperable with Java. Kotlin focuses on safety, interoperability, and tooling support. The basics of Kotlin include top-level functions, variables, if/when expressions, loops, ranges, null safety features, and string templates. Kotlin avoids null pointer exceptions through language features like the Elvis operator, safe calls, and non-null types.
- Typeclasses in Scala allow defining common behavior (like printing) for unrelated types through implicit parameters and resolution. This avoids needing to modify types to add functionality.
- They work by defining typeclass traits that take a type parameter (like Show[T]), providing implicit values that implement traits for specific types, and having methods use implicit parameters of the typeclass.
- While powerful, typeclasses can cause issues like ambiguous implicits and lack consistency when multiple instances are defined. The Shapeless library addresses some limitations by allowing automatic typeclass instance derivation based on a type's structure.
This document provides an introduction to the Kotlin programming language. It highlights several key features of Kotlin including static typing, null safety, type inference, immutability, fun syntax, classes, data classes, delegates, extensions, lambdas, and domain-specific languages (DSLs). It also summarizes new features being added in Kotlin 1.1 such as direct Java 8/9 support, type aliases, delegated properties everywhere, and coroutines with async/await. The document encourages the reader to start their journey with Kotlin and provides some links for additional resources.
Presentation in Portuguese (Brazilian) about Kotlin basics. Can be used as reference to the basics of the language. It is specially focused on people with prior development experience, specially in Java.
A better version can be found at https://app.box.com/s/8zuk8yd4x9m7rbvinkb0xztz17x6xoqj
This is the slide for a presentation at Golang Melbourne meetup.
The document discusses various idioms in Swift including optional binding with guard let and if let, nil coalescing operator, switch statements with optionals and associated values, closures, lazy properties, and computed properties with property observers. Key idioms covered include using guard let to ensure non-nil arguments, extracting associated values from enums using switch, initializing immutable variables with closures, and updating for loops to the Swift 3 syntax.
This document contains a summary of a Swift school presentation. It discusses introducing Objective-C and Swift, benefits of Swift like multiple returns, optionals for safety, and powerful enums. It also provides code examples of Swift features like variables, constants, optional handling, switches, loops, functions, classes, protocols, and bridging Objective-C and Swift.
This document discusses Kotlin coroutines and how they can be used with the Spring Framework. It provides an overview of coroutines, explaining concepts like fibers, green threads, and suspendable computations. It also covers using coroutines with Spring features like the @Async annotation and asynchronous MVC return types. The document provides code examples of coroutines concepts like channels, jobs, and yielding in sequences.
Kotlin provides a modern, statically-typed, and expressive alternative to Java, offering null safety, coroutines for asynchronous programming, and a succinct, intuitive syntax.
This presentation will give an introduction to Kotlin, looking at various language features, how those features are utilized by the Kotlin Standard Library, and how they are implemented in performance-conscious ways.
Kotlin For Android - Functions (part 3 of 7)Gesh Markov
This presentation is part of a workshop series.
In this section you will learn about operators, inlining, a little bit about generics, named parameters, lambdas and closures, obtaining references to functions and passing them to other functions, and higher-order functions.
License:
This presentation is licensed under the Creative Commons, No Derivatives, Version 3.0 US: https://creativecommons.org/licenses/by-nd/3.0/us/legalcode
Beginning Haskell, Dive In, Its Not That Scary!priort
Haskell can get a bit of a reputation for being this lofty, academic, difficult to learn language. This talk aims to dispel this myth and offer an introduction to this beautiful and pragmatic language. From the point of view of someone who has been functional programming in Scala and Clojure for a while now, but who has, more recently been taking a dive into Haskell, this talk will give a basic introduction to Haskell. Hopefully it will encourage anyone who hasn't tried functional programming in Haskell to dive in too and give it a go.
The talk will be a whistle stop tour of some functional programming fundamentals in Haskell from basic data structures, logic constructs, functional transformations, recursion to some of the basics of Haskell's type system with data declarations and type classes.
TypeScript is a superset of JavaScript that primarily adds support for static types, classes, and interfaces to the language without imposing constraints on JavaScript code. It is primarily used to enable catching errors earlier and providing better tooling support. Some key benefits of TypeScript include managing modules and namespaces, scoping variables, and adding type safety to JavaScript code. TypeScript code is compiled to plain JavaScript, so any valid JavaScript code is also valid TypeScript code.
Get started with creating intuitive native user interfaces on Android platform key features and understand the difference between the imperative..✨
We present to you the first session of the Android compose camp on Kotlin and Android basics
2. What is Kotlin?
• Statically typed programming language
• JVM-based language developed by JetBrains
• From industry not academia
• 100% inter-operable with the Java language
Open Source - https://github.com/JetBrains/kotlin
3. Why Kotlin
Concise - Drastically reduce the amount of boilerplate code you need to
write.
Safe - Avoid entire classes of errors such as null pointer exceptions.
Versatile - Build server-side applications, Android apps or front-end code
running in the browser.
4. Kotlin in Expedia Android
Kotlin code is at 23% and rising.
Refactoring started mid 2015.
Hotels, Packages, Flights, Services and MockWebServer & tests
classes are 90% in Kotlin
Cars/LX/Legacy tablet code still in java.
Other teams in Expedia are experimenting with Kotlin in the web.
5. Features
• Null type and safety
• Lambdas
• Optional params
• Data classes
• Extension functions
• Delegates
• Smart Casting
6. Not so good about Kotlin!
• Tools support
• Compile time
7. Kotlin
Roadmap for Android
• Incremental compilation
• support for Jack and Jill toolchain
• Instant run works for cold swaps right now not
for hot swaps
• Lint checks in Kotlin 1.0.2
17. Using a for loop
fun doSomething(args: Array<String>) {
for (arg in args)
print(arg)
}
18. Using a for loop
fun doSomething(args: Array<String>) {
for (arg in args)
print(arg)
}
fun doSomething(args: Array<String>) {
for (i in args.indices)
print(args[i])
}
19. Using when expression
fun doSomething(obj: Any) {
when (obj) {
1 -> print("One")
"Hello" -> print("Kotlin")
is Long -> print("Long")
!is String -> print(“!string")
else -> print("Unknown")
}
}
20. Using ranges
fun doSomething(x: Int, y: Int) {
if (x in 1..y - 1)
print("In")
for (x in 1..5)
print(“N")
if (x !in 1..y - 1)
print(“In")
}
21. Using ranges
fun doSomething(x: Int, y: Int) {
if (x in 1..y - 1)
print("In")
for (x in 1..5)
print("N")
if (x !in 1..y - 1)
print(“In")
}
22. Using ranges
fun doSomething(x: Int, y: Int) {
if (x in 1..y - 1)
print("In")
for (x in 1..5)
print("N")
if (x !in 1..y - 1)
print(“In")
}
23. Class in Java
public class SomeClass {
private String variable;
private final String defaultVar;
SomeClass(String variable) {
this.variable = variable;
this.defaultVar = "Java";
}
SomeClass(String variable, String defaultVar) {
this.variable = variable;
this.defaultVar = defaultVar;
}
}
// Use
new SomeClass("Kotlin", "Java");
new SomeClass("Kotlin");
24. Class in Kotlin
class SomeClass(var variable: String, val defaultValue: String = "Java") {
}
// Use
SomeClass("Kotlin", "Java")
SomeClass("Kotlin")
33. class Vehicle(var value: String) {
}
fun doSomething() {
val type = Vehicle("Car")
println("${type.value}")
}
34. class Vehicle(var value: String) {
}
fun doSomething() {
val type = Vehicle("Car")
println("${type.value}")
}
35. class Vehicle(var value: String) {
}
fun doSomething() {
val type = Vehicle("Car")
println("${type.value}")
}
36. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val type = Vehicle("Car")
type.print()
}
37. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val type = Vehicle("Car")
type.print()
}
38. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val types = listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike"))
}
39. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val types = listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike"))
for (type in types) {
type.print()
}
}
40. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val types = listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike"))
types.forEach { type ->
type.print()
}
}
41. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val types = listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike"))
types.forEach { it.print() }
}
42. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
val types = listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike"))
types.forEach { it.print() }
}
43. class Vehicle(var value: String) {
fun print() = println("$value")
}
fun doSomething() {
listOf(
Vehicle("Car"),
Vehicle("Truck"),
Vehicle("Bike")
).forEach { it.print() }
}
44. open class Vehicle(var value: String) {
fun print() = println("$value")
}
class Car(var type: String) : Vehicle(type){
}
fun doSomething() {
listOf(
Car("Car"),
Vehicle("Truck"),
Vehicle("Bike")
).forEach{it.print()}
}
45. open class Vehicle(var value: String) {
fun print() = println("$value")
}
class Car(var type: String) : Vehicle(type){
}
fun doSomething() {
listOf(
Car("Car"),
Vehicle("Truck"),
Vehicle("Bike")
).forEach{it.print()}
}
46. open class Vehicle(var value: String) {
open fun print() = println("$value")
}
class Car(var type: String) : Vehicle(type){
override fun print() = println("Yo, Its a $value")
}
fun doSomething() {
listOf(
Car("Car"),
Vehicle("Truck"),
Vehicle("Bike")
).forEach{it.print()}
}
47. open class Vehicle(var value: String) {
open fun print() = println("$value")
}
class Car(var type: String) : Vehicle(type){
override fun print() = println("Yo, Its a $value")
}
fun doSomething() {
listOf(
Car("Car"),
Vehicle("Truck"),
Vehicle("Bike")
).forEach{it.print()}
}
48. Nullability
I call it my billion-dollar mistake. It was the invention of the null reference …. has led to
innumerable errors, vulnerabilities, and system crashes, which have probably caused a
billion dollars of pain and damage in the last forty years.
-Sir Charles Antony Richard Hoare
49. Null and type safety
fun doSomething() {
var a: String = "abc"
a = null // compilation error
}
50. fun doSomething() {
var a: String = "abc"
a = null // compilation error
var b: String? = "abc"
b = null // ok
}
Null and type safety
51. fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l = a.length
}
Null and type safety
52.
fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l2 = b.length // error:variable 'b' can be null
}
Null and type safety
53. Checking for null in conditions
fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l = if (b != null) b.length else -1
}
54. Safe Calls
fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l2 = b?.length
}
55. Elvis Operator
fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l = if (b != null) b.length else -1
}
56. fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l2 = b?.length ?: -1
}
57. if (originLocation != null) {
if (originLocation.hierarchyInfo != null) {
if (originLocation.hierarchyInfo.airport != null) {
if (originLocation.hierarchyInfo.airport.airportCode != null) {
departureAirportCode =
originLocation.hierarchyInfo.airport.airportCode;
}
}
}
}
else {
departureAirportCode = "";
}
58. val departureAirportCode = originLocation?.hierarchyInfo?.airport?.airportCode ?: ""
if (originLocation != null) {
if (originLocation.hierarchyInfo != null) {
if (originLocation.hierarchyInfo.airport != null) {
if (originLocation.hierarchyInfo.airport.airportCode != null) {
departureAirportCode =
originLocation.hierarchyInfo.airport.airportCode;
}
}
}
}
else {
departureAirportCode = "";
}
59. The !! Operator
fun doSomething() {
var a: String = "abc"
var b: String? = "abc"
b = null // ok
val l1 = a.length
val l2 = b!!.length
}
62. Data class
data class Traveler(val name: String?, val age: Int)
Automatically implements:
equals()/hashCode()
toString() of the form "User(name=John, age=42)",
copy() function
63. val testTravlerJohn = Traveler(“John”, 42)
val testTravlerJane = Traveler(“Jane”, 41)
assertEquals(testTravlerJohn, testTravlerJane)
Data class in Testing
64. public class Traveler(String name, Int age)
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Traveler)) {
return false;
}
Traveler traveler = (Traveler) o;
if (name != name) {
return false;
}
if (age != traveler.age) {
return false;
}
return true;
}
65. Extension Functions
//In Java
public class StrUtils {
public static String encodeString(String str) {
return str.replaceAll(" ", "_")
}
}
String text = "Hello World";
System.out.println(StrUtils.encodeString(text));
66. Extension Functions
//In Kotlin
fun String.encodeSpaces(): String {
return this.replaceAll(" ", "_")
}
val text = "hello world"
println(text.encodeSpaces())
67. val list = listOf("E", "H", "Hello", "Hi", "I")
val map = mapOf(Pair("A", 1), Pair("B", 2), Pair("C", 3))
list.forEach { s ->
s.length
}
"E, H, Hello, Hi, I"
Kotlin Collections Extensions
68. val list = listOf("E", "H", "Hello", "Hi", "I")
val map = mapOf(Pair("A", 1), Pair("B", 2), Pair("C", 3))
var count = 0
list.forEachIndexed { i, s ->
count += i
s.length
}
"E, H, Hello, Hi, I"
69. val list = listOf("E", "H", "Hello", "Hi", "I")
val map = mapOf(Pair("A", 1), Pair("B", 2), Pair("C", 3))
list.filter { s ->
s.contains("H")
}
"H, Hello, Hi"
70. val list = listOf("E", "H", "Hello", "Hi", "I")
val map = mapOf(Pair("A", 1), Pair("B", 2), Pair("C", 3))
list.first { s ->
s.startsWith("He")
}
"Hello"
71. val list = listOf("E", "H", "Hello", "Hi", "I")
val map = mapOf(Pair("A", 1), Pair("B", 2), Pair("C", 3))
map.forEach { entry ->
entry.value
}
"A, B, C"
72. //In Java
final int[] sponsoredIndexes = { 0, 50, 51 };
ArrayList<Property> sponsored = new ArrayList<Property>();
ListIterator<Property> it = properties.listIterator();
while (it.hasNext()) {
Property prop = it.next();
if (prop.isSponsored()) {
it.remove();
sponsored.add(prop);
}
}
for (int i = 0; i < sponsored.size() && i < sponsoredIndexes.length; i++) {
if (sponsoredIndexes[i] <= properties.size()) {
properties.add(sponsoredIndexes[i], sponsored.get(i));
}
}
73. //In Kotlin
fun putSponsoredItemsInCorrectPlaces(hotelList: List<Hotel>): List<Hotel> {
val (sponsored, nonSponsored) = hotelList.partition { it.isSponsoredListing }
val firstChunk = sponsored.take(1)
val secondChunk = nonSponsored.take(49)
val thirdChunk = sponsored.drop(1)
val rest = nonSponsored.drop(49)
return firstChunk + secondChunk + thirdChunk + rest
}
74. //In Java
Observable.just("Hello World")
.map(new Func1<String, Object>() {
@Override
public Object call(String s) {
return s + "!";
}
})
.subscribe(new Subscriber<String>() {
@Override
public void onCompleted() {
//Completion
}
@Override
public void onError(final Throwable e) {
//TODO : Handle error here
}
@Override
public void onNext(final String s) {
Log.e("Output",s);
}
});
Reative Java
76. Flow sensitive typing
//In Java
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() != LOADING_VIEW) {
((ViewHolder) holder).updateHotel();
}
else if (holder.getItemViewType() != HOTEL_VIEW) {
((LoadingViewHolder) holder).loadView();
}
}
77. Flow sensitive typing
//In Kotlin
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (holder) {
is HotelCellViewHolder-> holder.updateHotel()
is LoadingViewHolder -> holder.loadView()
}
}
78. Delegates
var p: String by Delegate()
Properties using the delegate expression will have its
get() and set() methods delegated to the expression.
* lazy
* observable
* notNull
79. val view: Presenter by lazy {
var view = stub.inflate() as Presenter
view
}
Delegates.lazy
80. Delegates.notNull
class Foo {
var bar : Bar by Delegates.notNull() // type is now Bar
init {
val s = bar // Using before setting throws an IllegalStateException!
bar = Bar()
}
}