This document contains the agenda and notes from a talk on functional programming and Kotlin. The talk promotes the benefits of functional programming such as determinism, total functions, purity, and composability. It also highlights some key features of Kotlin like data classes, default values, constructors, and copy methods that make the language more functional-like compared to Java. The talk uses examples to explain concepts like deterministic, total, and pure functions in FP. It also compares code samples in Java and Kotlin to demonstrate how Kotlin reduces boilerplate and improves readability.
The document discusses features of the Kotlin programming language. It provides examples of how Kotlin simplifies object-oriented programming tasks like data classes and property access compared to Java. Data classes in Kotlin can auto-generate getters, setters, equals(), hashCode() and toString() methods. Kotlin also allows functional-style programming with properties like immutable state and avoiding null references.
Madrid gug - sacando partido a las transformaciones ast de groovyIván López Martín
Groovy es un gran lenguaje con capacidades muy potentes de metaprogramación en tiempo de compilación. ¿Sabías que hay más de 40 transformaciones AST disponibles para hacernos la vida más fácil como desarrolladores?
En esta charla aprenderás las transformaciones más importantes que proporciona Groovy a través de muchos ejemplos para explicar todos los conceptos.
Greach 2015 AST – Groovy Transformers: More than meets the eye!Iván López Martín
Slides for my Greach 2015 talk: http://greachconf.com/speakers/ivan-lopez-ast-groovy-transformers-more-than-meets-the-eye/
The source code is: https://github.com/lmivan/greach2015
Groovy is a great language with extremely powerful capabilities about compile time meta-programming. Do you know that provides more than 40 AST transformations out-of-the box just to make your life as a developer easier?
In this talk you will learn the most important transformations provided by Groovy. I’ll use a lot of code examples to explain all the concepts.
The document discusses Scala as a potential replacement for Java on the JVM. It provides quotes from several influential Java developers who express their view that Scala is the most capable replacement for Java currently available on the JVM, and the momentum behind Scala is growing. The document also briefly outlines an agenda for introducing Scala, covering basic syntax, patterns, functions, classes and traits.
Kotlin er et open-source programmeringsspråk til JVMen laget av JetBrains, som også bruker språket til utvikling av sine egne produkter. Det er et pragmatisk alternativ til Java med konsis syntaks, eksplisitt håndtering av nullverdier og gode verktøy for funksjonell programmering. Med andre ord kommer Kotlin med mye snacks som Java ikke har i dag.
Vi i BEKK mener at Kotlin gjør mye riktig og er et godt alternativ eller supplement til Java, samtidig som terskelen for å bruke det er lav. Java-utviklere vil raskt kunne sette seg inn i en kodebase skrevet i Kotlin og fordelene ved å starte å bruke Kotlin er verdt det.
Wykorzystanie języka Kotlin do aplikacji na platformie Android3camp
Kotlin is a programming language that the author chose to use for Android development. Some reasons for this choice include curiosity about the language, reviews of its code from JetBrains, and benefits like small app size and fast compilation. While there was a learning curve of around 50 hours, the syntax and approach are different from Java. Some of the features the author most appreciates about Kotlin are its safe code, simple class definitions, lambda expressions, and string templates. Issues are addressed quickly by JetBrains and the Kotlin team. Recommendations for learning Kotlin include reviewing documentation on the Kotlin website and Google samples. Major companies that use Kotlin include Google and JetBrains.
The talk is about Kotlin features, which are decompiled to Java code. You’ll understand how all of this ‘magic’ works in depths, which benefits it’ll give to you and what you may loose. Some benchmarks are included as a bonus.
The document discusses features of the Kotlin programming language. It provides examples of how Kotlin simplifies object-oriented programming tasks like data classes and property access compared to Java. Data classes in Kotlin can auto-generate getters, setters, equals(), hashCode() and toString() methods. Kotlin also allows functional-style programming with properties like immutable state and avoiding null references.
Madrid gug - sacando partido a las transformaciones ast de groovyIván López Martín
Groovy es un gran lenguaje con capacidades muy potentes de metaprogramación en tiempo de compilación. ¿Sabías que hay más de 40 transformaciones AST disponibles para hacernos la vida más fácil como desarrolladores?
En esta charla aprenderás las transformaciones más importantes que proporciona Groovy a través de muchos ejemplos para explicar todos los conceptos.
Greach 2015 AST – Groovy Transformers: More than meets the eye!Iván López Martín
Slides for my Greach 2015 talk: http://greachconf.com/speakers/ivan-lopez-ast-groovy-transformers-more-than-meets-the-eye/
The source code is: https://github.com/lmivan/greach2015
Groovy is a great language with extremely powerful capabilities about compile time meta-programming. Do you know that provides more than 40 AST transformations out-of-the box just to make your life as a developer easier?
In this talk you will learn the most important transformations provided by Groovy. I’ll use a lot of code examples to explain all the concepts.
The document discusses Scala as a potential replacement for Java on the JVM. It provides quotes from several influential Java developers who express their view that Scala is the most capable replacement for Java currently available on the JVM, and the momentum behind Scala is growing. The document also briefly outlines an agenda for introducing Scala, covering basic syntax, patterns, functions, classes and traits.
Kotlin er et open-source programmeringsspråk til JVMen laget av JetBrains, som også bruker språket til utvikling av sine egne produkter. Det er et pragmatisk alternativ til Java med konsis syntaks, eksplisitt håndtering av nullverdier og gode verktøy for funksjonell programmering. Med andre ord kommer Kotlin med mye snacks som Java ikke har i dag.
Vi i BEKK mener at Kotlin gjør mye riktig og er et godt alternativ eller supplement til Java, samtidig som terskelen for å bruke det er lav. Java-utviklere vil raskt kunne sette seg inn i en kodebase skrevet i Kotlin og fordelene ved å starte å bruke Kotlin er verdt det.
Wykorzystanie języka Kotlin do aplikacji na platformie Android3camp
Kotlin is a programming language that the author chose to use for Android development. Some reasons for this choice include curiosity about the language, reviews of its code from JetBrains, and benefits like small app size and fast compilation. While there was a learning curve of around 50 hours, the syntax and approach are different from Java. Some of the features the author most appreciates about Kotlin are its safe code, simple class definitions, lambda expressions, and string templates. Issues are addressed quickly by JetBrains and the Kotlin team. Recommendations for learning Kotlin include reviewing documentation on the Kotlin website and Google samples. Major companies that use Kotlin include Google and JetBrains.
The talk is about Kotlin features, which are decompiled to Java code. You’ll understand how all of this ‘magic’ works in depths, which benefits it’ll give to you and what you may loose. Some benchmarks are included as a bonus.
Groovy is a great language with extremely powerful capabilities about compile time meta-programming. Do you know that provides more than 40 AST transformations out-of-the box just to make your life as a developer easier?
In this talk you will learn the most important transformations provided by Groovy. I'll use a lot of code examples to explain all the concepts.
Scala is becoming the language of choice for many development teams. This talk highlights how Scala excels in the world of multi-core processing and explores how it compares to Java 8.
Video Presentation: http://youtu.be/8vxTowBXJSg
Take idiomatic C# and apply a few favorite patterns and concepts from functional languages like F# to make something hopefully more expressive, more elegant, and less bug-prone.
A talk by Bob Davidson for South Dakota Code Camp 2016.
This document introduces Kotlin, an open-source programming language developed by JetBrains. It notes that Kotlin is statically typed, interoperable with Java, and Android friendly. It provides examples of Kotlin code for basic "Hello World" programs, classes, functions, and other features. Major companies that use Kotlin, like Google, Netflix and Expedia, are listed. The document encourages learning more about Kotlin through resources on the Kotlin website.
This document provides an introduction to Groovy for Java developers. It discusses Groovy's features such as closures, optional typing and syntax, and how it compiles to Java bytecode. It then provides examples of writing a simple Groovy script to generate XML, using closures, mocking objects in tests, and building projects with Ant.
The document contains code examples showing how Kotlin code is compiled to Java bytecode. It demonstrates how Kotlin classes, functions, properties, and other language features are represented in the compiled Java code. Key aspects that are summarized include data classes, property delegates like lazy, extension functions, and overriding behavior.
This document contains information about an introduction to Kotlin programming course held on August 29th in Newlands at CodeBridge. It also references an expert drinks event on August 2nd. The document is authored by Robert MacLean and includes his Twitter and website contact details.
This document summarizes Hamlet D'Arcy's presentation on AST transformations using tools like Lombok, Groovy, CodeNarc, and Mirah. It discusses how these tools allow manipulating abstract syntax trees to add functionality like automatic property generation, static analysis, and embedded domain-specific languages. Local AST transformations are performed without changing bytecode or requiring new semantics. Type checking can also be added through transformations. Mirah compiles to pure Java classes without additional syntax.
Are you stuck in the Java world? I’ll share my story about convincing my team and the client of the benefits of Kotlin. Furthermore I’ll delve into how we migrated an existing Java Android app, with 300k active users, to Kotlin.
Even if you have never seen Kotlin before, come and see how you will create better apps with this modern and elegant language. At the end of this talk you’ll be able to convince your team / client why it’s a great to use Kotlin.
The power of Kotlin can be leveraged everywhere you use Java, since it compiles to JVM bytecode. So even if you’re not an Android developer, check out this session to get acquainted with Kotlin!
No excuses: switch to Kotlin
GDG DevFest 2017 - Inspections of Kotlin implementations by Bytecode.
세션 이후 "Kotlin은 Java의 wrapper인가요?" 라는 질문을 몇번 받았습니다.
—
답변: 그렇지 않습니다.
특정한 언어로 구현된 코드는 파싱을 거쳐 추상화된 형태(AST)와 추가 정보들을 가지는 1차적인 결과물로 처리됩니다. 보통 이런 역할을 하는 것은 컴파일러에서 전단부(frontend)라고 호칭하며 이러한 AST 등의 결과물은 대상 머신이나 플랫폼에 맞추어 처리됩니다.
이를 바로 실행하면 인터프리터라고 하지만, 실행 가능한 형태(Executable)로 생성하는 경우라면 컴파일러 후단부(Backend)가 이를 수행합니다.
백엔드의 타겟 코드는 충분히 다양한 대상을 다룰 수 있으므로, 우리가 다양한 백엔드 구현을 통해 동일 코드를 멀티 플랫폼을 대상으로 실행할 수 있도록 할 수 있는 것입니다.
코틀린 역시 대상으로 하는 플랫폼(과 머신)은 현재 다음과 같은 실행 가능한 형태를 지원하고 있습니다. (물론 아직 모든 타겟이 완벽하지는 않겠죠.)
1. Bytecode 포맷에 따른 JVM(안드로이드 포함)
2. JavaScript에 의한 브라우저나 Node.js
3. llvm을 이용하여 여러 타겟의 네이티브 코드
이 자료는 이 중 1번을 기반으로 디컴파일된 코드를 살펴보고 코틀린의 코드 생성 목적이나 언어 설계의 원인(어떤 painpoint)를 찾아보는 과정의 일부였을 뿐입니다.
언어는 항상 요구되는 표현을 위해 가장 적합한 형태로 변화해나갑니다. 프로그래밍 언어는 비교적 단기간에 만들어지는 언어이고, 그에 따라 특정 사람과 집단의 목적에 충실합니다. 다만, 이 관점에서 봤을 때도 Kotlin이 Java의 wrapper로써 설계되었을 것보다는 다양한 타겟 플랫폼이 고려되고 있는 하나의 프로그래밍 언어로 받아들여 주시기를 바랍니다. :)
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
I Google Developer Group (GDG) sono una community internazionale di appassionati delle tecnologie: sviluppatori, designer e startupper. Sono suddivisi per città, e GDG Italia è la famiglia che rappresenta tutti i gruppi presenti sul territorio locale. Mike Trizio e Carmelo Ventimiglia introdurranno i GDG, le loro attività e perchè è utile e divertente farne parte. Leonardo Pirro invece ci introdurrà Kotlin, un linguaggio di programmazione che ha avuto un crescente successo negli ultimi anni. Analizzeremo le caratteristiche principali del linguaggio e i suoi vantaggi/benefici rispetto a Java.
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.
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.
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.
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.
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.
This document provides an introduction to the Scala programming language. It discusses that Scala is a hybrid language that is both object-oriented and functional, runs on the JVM, and provides seamless interoperability with Java. It highlights features of Scala such as pattern matching, traits, case classes, immutable data structures, lazy evaluation, and actors for concurrency.
This document appears to be a transcript from a presentation on software estimation. It discusses how estimation is different for software projects compared to construction projects due to factors like constantly changing tools and requirements in software. A key example given is the Berlin Brandenburg Airport project, whose costs ballooned from an original budget of €2.83 billion to over €9.4 billion due to delays and changes. The presentation argues that while estimation is important, it is difficult to be perfectly accurate for software due to its inherently changing nature.
This document discusses communicating with aliens using lambda calculus. It explains that lambda calculus is a minimal functional programming language that can represent logic, mathematics, computation, and theorems. Everything in lambda calculus is a function, and it provides a way to define and apply functions. Basic concepts like boolean logic and arithmetic can be modeled. The document suggests that if aliens understand logic and modus ponens, they would understand lambda calculus as it is a universal system discovered from fundamentals of logic. It then provides examples of lambda calculus functions and applications.
Groovy is a great language with extremely powerful capabilities about compile time meta-programming. Do you know that provides more than 40 AST transformations out-of-the box just to make your life as a developer easier?
In this talk you will learn the most important transformations provided by Groovy. I'll use a lot of code examples to explain all the concepts.
Scala is becoming the language of choice for many development teams. This talk highlights how Scala excels in the world of multi-core processing and explores how it compares to Java 8.
Video Presentation: http://youtu.be/8vxTowBXJSg
Take idiomatic C# and apply a few favorite patterns and concepts from functional languages like F# to make something hopefully more expressive, more elegant, and less bug-prone.
A talk by Bob Davidson for South Dakota Code Camp 2016.
This document introduces Kotlin, an open-source programming language developed by JetBrains. It notes that Kotlin is statically typed, interoperable with Java, and Android friendly. It provides examples of Kotlin code for basic "Hello World" programs, classes, functions, and other features. Major companies that use Kotlin, like Google, Netflix and Expedia, are listed. The document encourages learning more about Kotlin through resources on the Kotlin website.
This document provides an introduction to Groovy for Java developers. It discusses Groovy's features such as closures, optional typing and syntax, and how it compiles to Java bytecode. It then provides examples of writing a simple Groovy script to generate XML, using closures, mocking objects in tests, and building projects with Ant.
The document contains code examples showing how Kotlin code is compiled to Java bytecode. It demonstrates how Kotlin classes, functions, properties, and other language features are represented in the compiled Java code. Key aspects that are summarized include data classes, property delegates like lazy, extension functions, and overriding behavior.
This document contains information about an introduction to Kotlin programming course held on August 29th in Newlands at CodeBridge. It also references an expert drinks event on August 2nd. The document is authored by Robert MacLean and includes his Twitter and website contact details.
This document summarizes Hamlet D'Arcy's presentation on AST transformations using tools like Lombok, Groovy, CodeNarc, and Mirah. It discusses how these tools allow manipulating abstract syntax trees to add functionality like automatic property generation, static analysis, and embedded domain-specific languages. Local AST transformations are performed without changing bytecode or requiring new semantics. Type checking can also be added through transformations. Mirah compiles to pure Java classes without additional syntax.
Are you stuck in the Java world? I’ll share my story about convincing my team and the client of the benefits of Kotlin. Furthermore I’ll delve into how we migrated an existing Java Android app, with 300k active users, to Kotlin.
Even if you have never seen Kotlin before, come and see how you will create better apps with this modern and elegant language. At the end of this talk you’ll be able to convince your team / client why it’s a great to use Kotlin.
The power of Kotlin can be leveraged everywhere you use Java, since it compiles to JVM bytecode. So even if you’re not an Android developer, check out this session to get acquainted with Kotlin!
No excuses: switch to Kotlin
GDG DevFest 2017 - Inspections of Kotlin implementations by Bytecode.
세션 이후 "Kotlin은 Java의 wrapper인가요?" 라는 질문을 몇번 받았습니다.
—
답변: 그렇지 않습니다.
특정한 언어로 구현된 코드는 파싱을 거쳐 추상화된 형태(AST)와 추가 정보들을 가지는 1차적인 결과물로 처리됩니다. 보통 이런 역할을 하는 것은 컴파일러에서 전단부(frontend)라고 호칭하며 이러한 AST 등의 결과물은 대상 머신이나 플랫폼에 맞추어 처리됩니다.
이를 바로 실행하면 인터프리터라고 하지만, 실행 가능한 형태(Executable)로 생성하는 경우라면 컴파일러 후단부(Backend)가 이를 수행합니다.
백엔드의 타겟 코드는 충분히 다양한 대상을 다룰 수 있으므로, 우리가 다양한 백엔드 구현을 통해 동일 코드를 멀티 플랫폼을 대상으로 실행할 수 있도록 할 수 있는 것입니다.
코틀린 역시 대상으로 하는 플랫폼(과 머신)은 현재 다음과 같은 실행 가능한 형태를 지원하고 있습니다. (물론 아직 모든 타겟이 완벽하지는 않겠죠.)
1. Bytecode 포맷에 따른 JVM(안드로이드 포함)
2. JavaScript에 의한 브라우저나 Node.js
3. llvm을 이용하여 여러 타겟의 네이티브 코드
이 자료는 이 중 1번을 기반으로 디컴파일된 코드를 살펴보고 코틀린의 코드 생성 목적이나 언어 설계의 원인(어떤 painpoint)를 찾아보는 과정의 일부였을 뿐입니다.
언어는 항상 요구되는 표현을 위해 가장 적합한 형태로 변화해나갑니다. 프로그래밍 언어는 비교적 단기간에 만들어지는 언어이고, 그에 따라 특정 사람과 집단의 목적에 충실합니다. 다만, 이 관점에서 봤을 때도 Kotlin이 Java의 wrapper로써 설계되었을 것보다는 다양한 타겟 플랫폼이 고려되고 있는 하나의 프로그래밍 언어로 받아들여 주시기를 바랍니다. :)
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
I Google Developer Group (GDG) sono una community internazionale di appassionati delle tecnologie: sviluppatori, designer e startupper. Sono suddivisi per città, e GDG Italia è la famiglia che rappresenta tutti i gruppi presenti sul territorio locale. Mike Trizio e Carmelo Ventimiglia introdurranno i GDG, le loro attività e perchè è utile e divertente farne parte. Leonardo Pirro invece ci introdurrà Kotlin, un linguaggio di programmazione che ha avuto un crescente successo negli ultimi anni. Analizzeremo le caratteristiche principali del linguaggio e i suoi vantaggi/benefici rispetto a Java.
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.
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.
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.
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.
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.
This document provides an introduction to the Scala programming language. It discusses that Scala is a hybrid language that is both object-oriented and functional, runs on the JVM, and provides seamless interoperability with Java. It highlights features of Scala such as pattern matching, traits, case classes, immutable data structures, lazy evaluation, and actors for concurrency.
This document appears to be a transcript from a presentation on software estimation. It discusses how estimation is different for software projects compared to construction projects due to factors like constantly changing tools and requirements in software. A key example given is the Berlin Brandenburg Airport project, whose costs ballooned from an original budget of €2.83 billion to over €9.4 billion due to delays and changes. The presentation argues that while estimation is important, it is difficult to be perfectly accurate for software due to its inherently changing nature.
This document discusses communicating with aliens using lambda calculus. It explains that lambda calculus is a minimal functional programming language that can represent logic, mathematics, computation, and theorems. Everything in lambda calculus is a function, and it provides a way to define and apply functions. Basic concepts like boolean logic and arithmetic can be modeled. The document suggests that if aliens understand logic and modus ponens, they would understand lambda calculus as it is a universal system discovered from fundamentals of logic. It then provides examples of lambda calculus functions and applications.
The document discusses how monads can be used to prevent bugs and handle side effects like missing data in code. It provides examples of using Optional to represent missing values and chaining operations with flatMap to avoid nested if-checks. Monads allow sequencing computations in a declarative way while handling problems in the data or failures transparently.
The document discusses performance myths and optimizations in Scala code. It begins with an example of calculating Fibonacci numbers on a 68040 processor and how branch prediction strategies can impact performance. Benchmark results are shown comparing immutable and mutable implementations of a calculator, with the immutable version being much slower. Tools for measuring performance like JMH, Java Flight Recorder and Java Mission Control are also introduced. The document cautions that performance can depend heavily on context and benchmarks only show tools, not decisions that should be made based on numbers.
The document discusses Haskell for the JVM using Eta, which compiles Haskell to JVM bytecode. It provides examples of writing Haskell code and using Eta, including quicksort, foreign imports, and optimizations like TCO. Eta aims to provide an experience similar to GHC for Haskell developers on the JVM.
Another programming language - jeszcze jeden językJarek Ratajski
This document discusses the history of programming languages through snippets of code and descriptions of various languages from the 1940s to the 1970s. It begins with machine code and assembly languages and progresses through higher-level languages like FORTRAN, COBOL, LISP, ALGOL, BASIC, Pascal, FORTH, C and others. It highlights reasons for the creation of new languages like making programming easier, preventing errors, and introducing new concepts and paradigms. Interspersed are notes about the evolving hardware landscape from punch cards to early computers.
This document discusses Eta, a compiler that allows writing Haskell code and running it on the Java Virtual Machine (JVM). Eta works by compiling Haskell to the STG intermediate language like GHC, and then compiling STG to JVM bytecode. This allows Haskell code to interoperate with Java code via foreign function interfaces. Performance benchmarks show Eta achieves performance comparable to equivalent Java code for algorithms like quicksort. Eta supports many Haskell language extensions and libraries from Hackage. This enables Haskell code to run on the JVM while maintaining high-level functional programming abilities.
This document discusses best practices for handling null values in Java. It recommends: failing fast with NullPointerExceptions instead of silently returning null; never returning null values from methods; marking optional parameters and return values with Java's Optional class; using Optional's map and flatMap methods to avoid deep null checks; and using Guava transforms if on Java 6/7 prior to Java 8 streams. The document provides code examples demonstrating these techniques for optional user objects returned from databases and assigned to groups.
This document summarizes Eta, a compiler that allows writing Haskell code to run on the Java Virtual Machine. Eta works by compiling Haskell to the STG intermediate representation and then generating JVM bytecode from STG. This allows Haskell code using GHC language extensions to run on the JVM without modifications. Performance is improved through optimizations like TCO. Eta supports packages from the Haskell Hackage repository by patching native C calls to equivalent JVM calls. This allows most Haskell libraries to work on Eta.
The document discusses developing code and IDEs for virtual reality. It proposes using A-Frame to build simple VR scenes with JavaScript due to its ease of use in WebVR. While current VR technology has limitations for complex coding tasks, the document envisions simulating code visually by representing it as interacting particles governed by physics laws. This would allow viewing code structure and analysis in an immersive 3D environment. Fully interactive development remains difficult, but the author is interested in exploring new presentation methods for code as VR hardware continues advancing.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
This document provides information about an individual named Jarek Ratajski. It lists that he works for CSS Versicherung as a developer and wizard. It provides his email and Twitter handle. It then lists the various programming languages and technologies he has experience with. The rest of the document appears to be about architecture and challenges in scaling applications. It discusses using non-blocking architectures to process many events using few threads. It provides an overview of Lagom, a framework from Lightbend for building reactive microservices applications. It discusses entity components in Lagom like commands, events and state. It also covers reading from Cassandra and implementing read models.
This document provides information about Jarosław Ratajski, including that he is a developer who lives in Luzern and works at CSS Insurance. It also discusses an alien pizza delivery domain model called Galakpizza that was developed using two different approaches - one using plain Java objects ("Normal") and the other using a relational database and JPA ("Other"). The domain model includes concepts like Orders, Variants, Sizes and Planets. The services implemented allow placing orders and retrieving the orders from the best planet.
This document describes an alien development of a pizza ordering and delivery system in two parallel universes. In the normal universe, the system uses plain Java objects and data structures, while in the other universe it uses a relational database with JPA annotations. Both implementations provide the same core functionality of placing orders, retrieving the best planet for orders, and counting total orders. The document includes code examples showing how the domain model, services, and implementations differ between the two parallel universes.
The Comprehensive Guide to Validating Audio-Visual Performances.pdfkalichargn70th171
Ensuring the optimal performance of your audio-visual (AV) equipment is crucial for delivering exceptional experiences. AV performance validation is a critical process that verifies the quality and functionality of your AV setup. Whether you're a content creator, a business conducting webinars, or a homeowner creating a home theater, validating your AV performance is essential.
The Role of DevOps in Digital Transformation.pdfmohitd6
DevOps plays a crucial role in driving digital transformation by fostering a collaborative culture between development and operations teams. This approach enhances the speed and efficiency of software delivery, ensuring quicker deployment of new features and updates. DevOps practices like continuous integration and continuous delivery (CI/CD) streamline workflows, reduce manual errors, and increase the overall reliability of software systems. By leveraging automation and monitoring tools, organizations can improve system stability, enhance customer experiences, and maintain a competitive edge. Ultimately, DevOps is pivotal in enabling businesses to innovate rapidly, respond to market changes, and achieve their digital transformation goals.
🏎️Tech Transformation: DevOps Insights from the Experts 👩💻campbellclarkson
Connect with fellow Trailblazers, learn from industry experts Glenda Thomson (Salesforce, Principal Technical Architect) and Will Dinn (Judo Bank, Salesforce Development Lead), and discover how to harness DevOps tools with Salesforce.
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...kalichargn70th171
Visual testing plays a vital role in ensuring that software products meet the aesthetic requirements specified by clients in functional and non-functional specifications. In today's highly competitive digital landscape, users expect a seamless and visually appealing online experience. Visual testing, also known as automated UI testing or visual regression testing, verifies the accuracy of the visual elements that users interact with.
The Rising Future of CPaaS in the Middle East 2024Yara Milbes
Explore "The Rising Future of CPaaS in the Middle East in 2024" with this comprehensive PPT presentation. Discover how Communication Platforms as a Service (CPaaS) is transforming communication across various sectors in the Middle East.
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Ortus Solutions, Corp
Join us for a session exploring CommandBox 6’s smooth website transition and efficient deployment. CommandBox revolutionizes web development, simplifying tasks across Linux, Windows, and Mac platforms. Gain insights and practical tips to enhance your development workflow.
Come join us for an enlightening session where we delve into the smooth transition of current websites and the efficient deployment of new ones using CommandBox 6. CommandBox has revolutionized web development, consistently introducing user-friendly enhancements that catalyze progress in the field. During this presentation, we’ll explore CommandBox’s rich history and showcase its unmatched capabilities within the realm of ColdFusion, covering both major variations.
The journey of CommandBox has been one of continuous innovation, constantly pushing boundaries to simplify and optimize development processes. Regardless of whether you’re working on Linux, Windows, or Mac platforms, CommandBox empowers developers to streamline tasks with unparalleled ease.
In our session, we’ll illustrate the simple process of transitioning existing websites to CommandBox 6, highlighting its intuitive features and seamless integration. Moreover, we’ll unveil the potential for effortlessly deploying multiple websites, demonstrating CommandBox’s versatility and adaptability.
Join us on this journey through the evolution of web development, guided by the transformative power of CommandBox 6. Gain invaluable insights, practical tips, and firsthand experiences that will enhance your development workflow and embolden your projects.
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
Stork Product Overview: An AI-Powered Autonomous Delivery FleetVince Scalabrino
Imagine a world where instead of blue and brown trucks dropping parcels on our porches, a buzzing drove of drones delivered our goods. Now imagine those drones are controlled by 3 purpose-built AI designed to ensure all packages were delivered as quickly and as economically as possible That's what Stork is all about.
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISTier1 app
Are you ready to unlock the secrets hidden within Java thread dumps? Join us for a hands-on session where we'll delve into effective troubleshooting patterns to swiftly identify the root causes of production problems. Discover the right tools, techniques, and best practices while exploring *real-world case studies of major outages* in Fortune 500 enterprises. Engage in interactive lab exercises where you'll have the opportunity to troubleshoot thread dumps and uncover performance issues firsthand. Join us and become a master of Java thread dump analysis!
Boost Your Savings with These Money Management AppsJhone kinadey
A money management app can transform your financial life by tracking expenses, creating budgets, and setting financial goals. These apps offer features like real-time expense tracking, bill reminders, and personalized insights to help you save and manage money effectively. With a user-friendly interface, they simplify financial planning, making it easier to stay on top of your finances and achieve long-term financial stability.
Just like life, our code must adapt to the ever changing world we live in. From one day coding for the web, to the next for our tablets or APIs or for running serverless applications. Multi-runtime development is the future of coding, the future is to be dynamic. Let us introduce you to BoxLang.
Orca: Nocode Graphical Editor for Container OrchestrationPedro J. Molina
Tool demo on CEDI/SISTEDES/JISBD2024 at A Coruña, Spain. 2024.06.18
"Orca: Nocode Graphical Editor for Container Orchestration"
by Pedro J. Molina PhD. from Metadev
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Paul Brebner
Closing talk for the Performance Engineering track at Community Over Code EU (Bratislava, Slovakia, June 5 2024) https://eu.communityovercode.org/sessions/2024/why-apache-kafka-clusters-are-like-galaxies-and-other-cosmic-kafka-quandaries-explored/ Instaclustr (now part of NetApp) manages 100s of Apache Kafka clusters of many different sizes, for a variety of use cases and customers. For the last 7 years I’ve been focused outwardly on exploring Kafka application development challenges, but recently I decided to look inward and see what I could discover about the performance, scalability and resource characteristics of the Kafka clusters themselves. Using a suite of Performance Engineering techniques, I will reveal some surprising discoveries about cosmic Kafka mysteries in our data centres, related to: cluster sizes and distribution (using Zipf’s Law), horizontal vs. vertical scalability, and predicting Kafka performance using metrics, modelling and regression techniques. These insights are relevant to Kafka developers and operators.
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio, Inc.
Alluxio Webinar
June. 18, 2024
For more Alluxio Events: https://www.alluxio.io/events/
Speaker:
- Jianjian Xie (Staff Software Engineer, Alluxio)
As Trino users increasingly rely on cloud object storage for retrieving data, speed and cloud cost have become major challenges. The separation of compute and storage creates latency challenges when querying datasets; scanning data between storage and compute tiers becomes I/O bound. On the other hand, cloud API costs related to GET/LIST operations and cross-region data transfer add up quickly.
The newly introduced Trino file system cache by Alluxio aims to overcome the above challenges. In this session, Jianjian will dive into Trino data caching strategies, the latest test results, and discuss the multi-level caching architecture. This architecture makes Trino 10x faster for data lakes of any scale, from GB to EB.
What you will learn:
- Challenges relating to the speed and costs of running Trino in the cloud
- The new Trino file system cache feature overview, including the latest development status and test results
- A multi-level cache framework for maximized speed, including Trino file system cache and Alluxio distributed cache
- Real-world cases, including a large online payment firm and a top ridesharing company
- The future roadmap of Trino file system cache and Trino-Alluxio integration
What is Continuous Testing in DevOps - A Definitive Guide.pdfkalichargn70th171
Once an overlooked aspect, continuous testing has become indispensable for enterprises striving to accelerate application delivery and reduce business impacts. According to a Statista report, 31.3% of global enterprises have embraced continuous integration and deployment within their DevOps, signaling a pervasive trend toward hastening release cycles.
3. Jarek Ratajski
Jarek Ratajski
Jarek Ratajski
working for
working for
working for Digital Asset
Digital Asset
Digital Asset
This talk does not represent company views, it
This talk does not represent company views, it
This talk does not represent company views, it
is based on personal experience
is based on personal experience
is based on personal experience and opinions
and opinions
and opinions
11. PART 1
PART 1
PART 1
FP
FP
FP
FUNCTIONAL PROPAGANDA
also known as
also known as
also known as Functional Programming
Functional Programming
Functional Programming
18. Two hours after deployment
Two hours after deployment
Two hours after deployment
19. What is functional programming?
What is functional programming?
What is functional programming?
Programming with functions:
Programming with functions:
Programming with functions:
deterministic
total
pure
20. What is functional programming?
What is functional programming?
What is functional programming?
Programming with functions:
Programming with functions:
Programming with functions:
deterministic
total
pure
Ok, I have no idea. Just copied this definition
Ok, I have no idea. Just copied this definition
Ok, I have no idea. Just copied this definition
from John De Goes ;-)
from John De Goes ;-)
from John De Goes ;-)
21. DETERMINISTIC
depend on arguments only
always yield same results for the same
arguments
fun
fun
fun hello() = "Hello Devoxx Poland"
fun
fun
fun fact(n:Int) = if
if
if (n<=1) 1 else
else
else n*fact(n-1)
fun
fun
fun radom() = Math.random()*0.7
22. TOTAL:
Yields result/finishes for all possible arguments
Yields result/finishes for all possible arguments
Yields result/finishes for all possible arguments
fun
fun
fun negate(a:Int):Int = -a
fun
fun
fun radomize(v:String) = "Radom znowu $v"
fun
fun
fun parseInt(t:String):Int = /* whatever */
23. PURE:
Leaves no traces.
Leaves no traces.
Leaves no traces. The only (practical) way to
The only (practical) way to
The only (practical) way to
detect if the function was called is by reading a
detect if the function was called is by reading a
detect if the function was called is by reading a
result.
result.
result.
fun
fun
fun add(a:Int, b:Int) = a+b
[CODE A]
val
val
val x = add(6,3) [OR] val
val
val x = 9
[CODE B]
24. fun
fun
fun add(a:Int, b:Int) = a*b //happy debugging
fun
fun
fun add2(a:Int, b:Int) = run {
Thread.sleep(a*1000)
Thread.sleep(b*1000)
return
return
return a+b
}
fun
fun
fun add3(a:Int, b:Int) = (a+b).also {
log("was adding something...")
}
25. Killer feature of functional programming
Killer feature of functional programming
Killer feature of functional programming
26. Killer feature of functional programming
Killer feature of functional programming
Killer feature of functional programming
COMPOSABILITY
COMPOSABILITY
COMPOSABILITY
27. Killer feature of functional programming
Killer feature of functional programming
Killer feature of functional programming
COMPOSABILITY
COMPOSABILITY
COMPOSABILITY
28. PART 2
PART 2
PART 2
KOTLIN PROPAGANDA
KOTLIN PROPAGANDA
KOTLIN PROPAGANDA
32. Data class
Data class
Data class
kotlin
kotlin
kotlin
data
data
data class
class
class Person(
val
val
val name:String,
val
val
val age:Int,
val
val
val drinking:Boolean = true
)
33. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
}
34. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
}
val drinking:Boolean = true
val drinking:Boolean = true
val drinking:Boolean = true
35. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String
String
String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String
String
String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String
String
String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String
String
String name, int
int
int age) {
this
this
this(name, age, true);
36. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String
String
String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String
String
String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String
String
String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String
String
String name, int
int
int age) {
this
this
this(name, age, true);
equals and hashCode
equals and hashCode
equals and hashCode
37. public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name)
&& this
this
this.age == var2.age
&& this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
38. public
public
public int hashCode() {
String var10000 = this
this
this.name;
int var1 = ((var10000 != null ? var10000.hashCode() : 0) * 31 + this
this
this.
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name)
&& this
this
this.age == var2.age
&& this
this
this.drinking == var2.drinking) {
return
return
return true;
}
}
return
return
return false;
} else
else
else {
return
return
return true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking
}
41. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
}
42. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
println(p) //Person(name=irek, age=27, drinking=true)
println(p1) //Person(name=Irek, age=27, drinking=true)
}
43. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
val
val
val p2 = p1.copy(age = 28)
}
44. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
val
val
val p2 = p1.copy(age = 28)
val
val
val p3 = p2.copy(drinking = false)
}
45. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
val
val
val p2 = p1.copy(age = 28)
val
val
val p3 = p2.copy(drinking = false)
val
val
val p4 = p3.copy(age = 29, drinking = true)
}
//Person(name=Zdzich, age=30, drinking=false)
46. fun
fun
fun main() = run {
val
val
val p = Person("irek", 27, true)
val
val
val p1 = p.copy(name = "Irek")
val
val
val p2 = p1.copy(age = 28)
val
val
val p3 = p2.copy(drinking = false)
val
val
val p4 = p3.copy(age = 29, drinking = true)
val
val
val p5 = p4.copy(name = "Zdzich", age = p4.age+1, drinking = false)
println(p3) //Person(name=Irek, age=28, drinking=false)
println(p5) //Person(name=Zdzich, age=30, drinking=false)
}
47. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String name, int
int
int age) {
this
this
this(name, age, true
true
true);
}
public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.age) * 31;
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name) && this
this
this.age == var2.age && this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking=" + this
this
this.drinking + ")";
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
48. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String name, int
int
int age) {
this
this
this(name, age, true
true
true);
}
public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.age) * 31;
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name) && this
this
this.age == var2.age && this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking=" + this
this
this.drinking + ")";
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(int
int
int age) {
return
return
return new
new
new Person(this
this
this.name, age, this
this
this.drinking);
}
49. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String name, int
int
int age) {
this
this
this(name, age, true
true
true);
}
public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.age) * 31;
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name) && this
this
this.age == var2.age && this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking=" + this
this
this.drinking + ")";
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(int
int
int age) {
return
return
return new
new
new Person(this
this
this.name, age, this
this
this.drinking);
}
almost
almost
almost
50. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String name, int
int
int age) {
this
this
this(name, age, true
true
true);
}
public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.age) * 31;
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name) && this
this
this.age == var2.age && this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking=" + this
this
this.drinking + ")";
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(int
int
int age) {
return
return
return new
new
new Person(this
this
this.name, age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(boolean
boolean
boolean drinking) {
return
return
return new
new
new Person(this
this
this.name, this
this
this.age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, drinking);
}
@NotNull
51. public
public
public final
final
final class
class
class Person {
@NotNull
private
private
private final
final
final String name;
private
private
private final
final
final int
int
int age;
private
private
private final
final
final boolean
boolean
boolean drinking;
@NotNull
public
public
public final
final
final String getName() {
return
return
return this
this
this.name;
}
public
public
public final
final
final int
int
int getAge() {
return
return
return this
this
this.age;
}
public
public
public final
final
final boolean
boolean
boolean getDrinking() {
return
return
return this
this
this.drinking;
}
public
public
public Person(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
this
this
this.name = name;
this
this
this.age = age;
this
this
this.drinking = drinking;
}
public
public
public Person(@NotNull String name, int
int
int age) {
this
this
this(name, age, true
true
true);
}
public
public
public int
int
int hashCode() {
String var10000 = this
this
this.name;
int
int
int var1 = ((var10000 != null
null
null ? var10000.hashCode() : 0) * 31 + this
this
this.age) * 31;
return
return
return var1 + (drinking ? 1 : 0);
}
public
public
public boolean
boolean
boolean equals(@Nullable Object var1) {
if
if
if (this
this
this != var1) {
if
if
if (var1 instanceof
instanceof
instanceof Person) {
Person var2 = (Person) var1;
if
if
if (Intrinsics.areEqual(this
this
this.name, var2.name) && this
this
this.age == var2.age && this
this
this.drinking == var2.drinking) {
return
return
return true
true
true;
}
}
return
return
return false
false
false;
} else
else
else {
return
return
return true
true
true;
}
}
@NotNull
public
public
public String toString() {
return
return
return "Person(name=" + this
this
this.name + ", age=" + this
this
this.age + ", drinking=" + this
this
this.drinking + ")";
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(int
int
int age) {
return
return
return new
new
new Person(this
this
this.name, age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(boolean
boolean
boolean drinking) {
return
return
return new
new
new Person(this
this
this.name, this
this
this.age, drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, int
int
int age) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, age, this
this
this.drinking);
}
@NotNull
public
public
public final
final
final Person copy(@NotNull String name, boolean
boolean
boolean drinking) {
Intrinsics.checkNotNullParameter(name, "name");
return
return
return new
new
new Person(name, this
this
this.age, drinking);
}
@NotNull
30 semicolons included
30 semicolons included
30 semicolons included
54. data
data
data class
class
class Person(
val
val
val names:List<String>,
val
val
val lastName:String,
val
val
val birthDate:LocalDate,
val
val
val email:Email,
val
val
val address:Address,
val
val
val family:List<Person>,
val
val
val drinking:Boolean = true
)
55. In java there are
In java there are
In java there are records
records
records but unfortunately as
but unfortunately as
but unfortunately as
for
for
for java 16
java 16
java 16 there is nothing like
there is nothing like
there is nothing like .copy(...)
.copy(...)
.copy(...)
yet.
yet.
yet.
71. vavr list
vavr list
vavr list
val
val
val list1 = list(1, 2, 3)
val
val
val list2 = list1.prepend(0)
println(list1)
println(list2)
//List(1, 2, 3)
//List(0, 1, 2, 3)
72. kotlin immutable (default list)
kotlin immutable (default list)
kotlin immutable (default list)
val
val
val list1 = listOf(1, 2, 3)
val
val
val list2 = listOf(0) + list1 // not efficient
println(list1)
println(list2)
//[1, 2, 3]
//[0, 1, 2, 3]
73. val
val
val list1 = listOf(1, 2, 3)
val
val
val list2 = listOf(0) + list1
(list1 as
as
as MutableList)[1] = -1
println(list1)
println(list2)
//[1, -1, 3]
//[0, 1, 2, 3]
75. Not all Lists are created equal
Not all Lists are created equal
Not all Lists are created equal
io.vavr.collection.List
io.vavr.collection.List
io.vavr.collection.List >
>
>
kotlin.ImmutableList
kotlin.ImmutableList
kotlin.ImmutableList >
>
> java.util.List
java.util.List
java.util.List
(for
(for
(for typical
typical
typical business
business
business code)
code)
code)
79. val variableName : OptionalType = ...
val variableName : OptionalType = ...
val variableName : OptionalType = ...
class
class
class A(val
val
val fieldAndConstructorArf:B, onlyArg:String) {
val
val
val fieldInitializedInClass = onlyArg+"_suffix"
fun
fun
fun a(arg:Int):String {// :String not needed
val
val
val variable = "$arg and $fieldInitializedInClass"
val
val
val other:String = variable //:String not needed
return
return
return other
}
}
80. val variableName : OptionalType = ...
val variableName : OptionalType = ...
val variableName : OptionalType = ...
class
class
class A(val
val
val fieldAndConstructorArf:B, onlyArg:String) {
val
val
val fieldInitializedInClass = onlyArg+"_suffix"
fun
fun
fun a(arg:Int):String {// :String not needed
val
val
val variable = "$arg and $fieldInitializedInClass"
val
val
val other:String = variable //:String not needed
return
return
return other
}
}
one simple syntax rule - fits everywhere
one simple syntax rule - fits everywhere
one simple syntax rule - fits everywhere
81. Type inference means type safety
Type inference means type safety
Type inference means type safety
82. Type inference means type safety
Type inference means type safety
Type inference means type safety
doubts?
doubts?
doubts?
83. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
84. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
85. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
86. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
87. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
must be not like recent 20 passwords
88. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
must be not like recent 20 passwords
or
or
or
89. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
must be not like recent 20 passwords
or
or
or
90. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
must be not like recent 20 passwords
or
or
or
91. Which password policy is better (safer)?
Which password policy is better (safer)?
Which password policy is better (safer)?
at least 12 characters
must include upper, lower case, digit and
special character
must be changed weekly
must be not like recent 20 passwords
or
or
or
97. Kill statements
Kill statements
Kill statements
fun
fun
fun addWithStatements(a:Int, b:Int):Int {
return
return
return a + b
}
fun
fun
fun addAsExpression(a:Int, b:Int) = a + b
98. Kill statements
Kill statements
Kill statements
fun
fun
fun addWithStatements(a:Int, b:Int):Int {
return
return
return a + b
}
fun
fun
fun addAsExpression(a:Int, b:Int) = a + b
return
return
return is a younger brother of
is a younger brother of
is a younger brother of GOTO
GOTO
GOTO
99. Instructions are not funny
Instructions are not funny
Instructions are not funny
101. sealed
sealed
sealed class
class
class Order(val
val
val sum: Int)
class
class
class Created(s: Int) : Order(s)
class
class
class Paid(s: Int) : Order(s)
class
class
class Delivered(s: Int) : Order(s)
val
val
val orders = list(
Created(120),
Paid(20),
Delivered(30),
Paid(40)
)
102. sealed
sealed
sealed class
class
class Order(val
val
val sum: Int)
class
class
class Created(s: Int) : Order(s)
class
class
class Paid(s: Int) : Order(s)
class
class
class Delivered(s: Int) : Order(s)
val
val
val orders = list(
Created(120),
Paid(20),
Delivered(30),
Paid(40)
)
fun
fun
fun impureSum(orders: Seq<Order>): Int {
var
var
var sum = 0
for
for
for (order in
in
in orders) {
when
when
when (order) {
is
is
is Paid -> sum = sum + order.sum
is
is
is Delivered -> sum = sum + order.sum
}
}
return
return
return sum
}
fun
fun
fun main() {
println(impureSum(orders)) //90
}
103. fun
fun
fun pureSum(orders: Seq<Order>): Int =
orders.foldLeft(0, { accumulator, order ->
when
when
when (order) {
is
is
is Paid -> accumulator + order.sum
is
is
is Delivered -> accumulator + order.sum
is
is
is Created -> accumulator
}
})
fun
fun
fun main() =
println(pureSum(orders)) //90
104. fun
fun
fun pureSum(orders: Seq<Order>): Int =
orders.foldLeft(0) { accumulator, order ->
when
when
when (order) {
is
is
is Paid -> accumulator + order.sum
is
is
is Delivered -> accumulator + order.sum
is
is
is Created -> accumulator
}
}
fun
fun
fun main() =
println(pureSum(orders)) //90
105. fun
fun
fun pureSum(orders: Seq<Order>): Int =
orders.foldLeft(0) { accumulator, order ->
when
when
when (order) {
is
is
is Paid -> accumulator + order.sum
is
is
is Delivered -> accumulator + order.sum
is
is
is Created -> accumulator
}
}
fun
fun
fun main() =
println(pureSum(orders)) //90
fold - don't loop
fold - don't loop
fold - don't loop
109. Business: We have to add new types of orders
Business: We have to add new types of orders
Business: We have to add new types of orders
110. sealed
sealed
sealed class
class
class Order(val
val
val sum: Int)
class
class
class Created(s: Int) : Order(s)
class
class
class Paid(s: Int) : Order(s)
class
class
class Delivered(s: Int) : Order(s)
//new guy
class
class
class Cancelled(s:Int) : Order(s)
//new guy
class
class
class Archived(s:Int) :Order(s)
val
val
val orders = list(
Created(120),
Paid(20),
Delivered(30),
Paid(40),
Cancelled(20),
Archived(10)
)
111. fun
fun
fun impureSum(orders: Seq<Order>): Int {
var
var
var sum = 0
for
for
for (order in
in
in orders) {
when
when
when (order) {
is
is
is Paid -> sum = sum + order.sum
is
is
is Delivered -> sum = sum + order.sum
}
}
return
return
return sum //90 - wrong
}
112. fun
fun
fun impureSum(orders: Seq<Order>): Int =
orders.foldLeft(0) { accumulator, order ->
when
when
when (order) {
// Error: 'when' expression must be exhaustive,
// add necessary 'is Cancelled', 'is Archived' branches
// or 'else' branch instead
is
is
is Paid -> accumulator + order.sum
is
is
is Delivered -> accumulator + order.sum
is
is
is Created -> accumulator
}
} //wont compile
113. Compiler is like your BEST friend.
Compiler is like your BEST friend.
Compiler is like your BEST friend.
Best friend:
Best friend:
Best friend: Will tell you the truth even if You do not want to hear
Will tell you the truth even if You do not want to hear
Will tell you the truth even if You do not want to hear
it
it
it
Compiler will
Compiler will
Compiler will tell you that your code will eventually crash on
tell you that your code will eventually crash on
tell you that your code will eventually crash on
production.
production.
production.
114. if
if
if ,,
, when
when
when,,
, try
try
try etc. are expressions in Kotlin
etc. are expressions in Kotlin
etc. are expressions in Kotlin
use them
use them
use them
fun (a:Int,b:Int) =
a + if
if
if (b<5) a else
else
else -a
116. sealed
sealed
sealed class
class
class Order(internal
internal
internal val
val
val sum: Int) {
open
open
open fun
fun
fun income(): Int = sum
fun
fun
fun cancelled() = Cancelled(this
this
this)
}
class
class
class Created(s: Int) : Order(s) {
override
override
override fun
fun
fun income(): Int = 0
fun
fun
fun pay() = Paid(this
this
this)
}
// cannot create Paid without seeing first ordser in Created state
class
class
class Paid internal
internal
internal constructor
constructor
constructor(order: Created) : Order(order.sum) {
fun
fun
fun deliver() = Delivered(this
this
this)
}
[...]
val
val
val orders = list(
Created(120),
Created(20).pay(),
Created(30).pay().deliver(),
Created(40).pay(),
Created(20).pay().cancelled(),
Created(30).pay().deliver().archive()
)
fun
fun
fun pureSum(orders: Seq<Order>): Int =
orders.foldLeft(0) { accumulator, order ->
accumulator + order.income()
}
fun
fun
fun main() {
119. SIDE EFFECTS
SIDE EFFECTS
SIDE EFFECTS
Functional programming is all about side
Functional programming is all about side
Functional programming is all about side
effects
effects
effects
120. class
class
class Paid internal
internal
internal constructor
constructor
constructor(order: Created) : Order(order.sum) {
fun
fun
fun deliver() = Delivered(this
this
this).also {
println("delivered")
}
fun
fun
fun deliverFast() = Delivered(this
this
this).also {
println("delivered fast")
}
}
122. Surprise
Surprise
Surprise
fun
fun
fun doubleDelivery() = run {
val
val
val created = Created(25)
val
val
val paid = created.pay()
paid.deliver()
if
if
if (paid.income() > 20) {
paid.deliverFast()
}
}
fun
fun
fun main() = doubleDelivery()
//delivered
//delivered fast
123. SIDE EFFECTS DONE PURELY
SIDE EFFECTS DONE PURELY
SIDE EFFECTS DONE PURELY
How to not have surprises (that often)
How to not have surprises (that often)
How to not have surprises (that often)
124. a fail
a fail
a fail
fun
fun
fun sayIt() = println("I am just dirty side effect")
126. fun
fun
fun sayItLater() = { println("No side effects")}
fun
fun
fun main() = run {
sayItLater() //nothing
val
val
val x = sayItLater() // nothing
x() //"No side effects" (there it happens)
}
127. Back to the problem:
Back to the problem:
Back to the problem:
fun
fun
fun crashDelivery() = run {
val
val
val created = Created(25)
val
val
val paid = created.pay()
paid.deliver()
if
if
if (paid.income() > 20) {
paid.deliverFast()
}
}
130. class
class
class Naleśnik<out A>(private
private
private val
val
val inside: () -> A) {
fun
fun
fun <B> map(f: (A) -> B) =
Naleśnik { f(this
this
this.inside()) }
fun
fun
fun <B> flatMap(f: (A) -> Naleśnik<B>): Naleśnik<B> =
Naleśnik { f(this
this
this.inside()).inside() }
fun
fun
fun unsafeRun(): A = inside() //use with caution
}
131. sealed
sealed
sealed class
class
class Order(internal
internal
internal val
val
val sum: Int) {
open
open
open fun
fun
fun income(): Int = sum
fun
fun
fun cancelled() = Naleśnik { Cancelled(this
this
this) }
}
class
class
class Created(s: Int) : Order(s) {
override
override
override fun
fun
fun income(): Int = 0
fun
fun
fun pay() = Naleśnik { Paid(this
this
this) }
}
class
class
class Paid internal
internal
internal constructor
constructor
constructor(order: Created) : Order(order.sum) {
fun
fun
fun deliver(): Naleśnik<Delivered> = Naleśnik {
Delivered(this
this
this).also {
println("delivered")
}
}
fun
fun
fun deliverFast(): Naleśnik<Delivered> = Naleśnik {
Delivered(this
this
this).also {
println("delivered fast")
}
}
}
132. fun
fun
fun crashDelivery():Naleśnik<Delivered> = run {
val
val
val created = Created(25)
val
val
val paid = created.pay()
val
val
val delivered = paid.flatMap { it.deliver() }
paid.flatMap { if
if
if (it.income()> 20) it.deliverFast() else
else
else it.de
}
fun
fun
fun main() {
crashDelivery().unsafeRun()
//delivered fast
}
133. Naleśnik / pancake - harder to mess side
Naleśnik / pancake - harder to mess side
Naleśnik / pancake - harder to mess side
effects
effects
effects
139. Transaction is a Monad
Transaction is a Monad
Transaction is a Monad
class
class
class Transaction<A>(private
private
private val
val
val action: (Connection) -> A) {
fun
fun
fun <B> map ( f: (A)->B) = Transaction { conn -> f(action(conn))}
fun
fun
fun <B> flatMap( f: (A)->Transaction<B>) =
Transaction { conn -> f(action(conn)).action(conn) }
fun
fun
fun runTransaction(conn:Connection): Either<Exception, A> = run {
val
val
val initialAC = conn.autoCommit
conn.autoCommit = false
try
try
try {
val
val
val res = action(conn)
conn.commit()
Either.right(res)
} catch
catch
catch (e: Exception) {
conn.rollback()
Either.left(e)
} finally
finally
finally {
conn.autoCommit = initialAC
}
}
}
143. Do not write:
Do not write:
Do not write:
class
class
class Hasiok {
@Resource
val
val
val jdbcConnection: Connection
@Transactional
@Secure
@Cacheable
@Retryable
fun
fun
fun f(p:P) {
//code
}
}
144. Write like:
Write like:
Write like:
class
class
class Hasiok {
fun
fun
fun enterprisyFunction(x:Int) = Nee.pure(
secure + retryable + cache.of(x) + tx
) {jdbcConnection:Connection ->
//code using jdbcConnection
}
//declaration above means security is checked before retrial
//and retrial is made before cache which happens before transacti
}
153. Plugin for
Plugin for
Plugin for detekt
detekt
detekt
Rule Detects Properties
with defaults
Requires
i
LoopUsage use of for, while active: true
ReturnStatement use of return statement active: true
VariableUsage use of var active: true
ReturnUnit use of function returning Unit,
Nothing, Void
active: true
checkFunctionType:
true
:ballot_box_with_check:
ClassDefinition use of object-oriented class active: false
AbstractClassDefinition use of object-oriented abstract
class
active: false
ThrowExpression use of throw active: true
MutableCollections use of mutable collections active: true :ballot_box_with_check:
BranchStatement use of if or when as statement :white_check_mark:
MissingElse use of if statement without else
type resolution
157. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
158. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
no void (Unit)
159. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
no void (Unit)
no return
160. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
no void (Unit)
no return
no throw
161. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
no void (Unit)
no return
no throw
no mercy
162. PURE CODE NOS
PURE CODE NOS
PURE CODE NOS
no variables (var)
no loops
no instructions
no void (Unit)
no return
no throw
no mercy
with the exception of main
163. DO YOU NEED FP?
DO YOU NEED FP?
DO YOU NEED FP?
164.
165.
166. Who needs calculator if all we do is adding
Who needs calculator if all we do is adding
Who needs calculator if all we do is adding
things like
things like
things like 123 + 352
123 + 352
123 + 352
167.
168. Who needs electronic calc if all we do is
Who needs electronic calc if all we do is
Who needs electronic calc if all we do is
multiplying things like
multiplying things like
multiplying things like 323 *3
323 *3
323 *3
169.
170. Who needs computer calc if divide and multiply
Who needs computer calc if divide and multiply
Who needs computer calc if divide and multiply
few numbers
few numbers
few numbers
171. For someone having experience with abacus
For someone having experience with abacus
For someone having experience with abacus
only - this machine is useless
only - this machine is useless
only - this machine is useless
173. PROJECT LINKS
PROJECT LINKS
PROJECT LINKS
example of pure todo list with arrow-fx and
example of pure todo list with arrow-fx and
example of pure todo list with arrow-fx and
ktor
ktor
ktor
springy effects for kotlin
springy effects for kotlin
springy effects for kotlin
example ktor project with Nee ("todo list like")
example ktor project with Nee ("todo list like")
example ktor project with Nee ("todo list like")
https://github.com/neeffect/kure-potlin
https://github.com/neeffect/kure-potlin
https://github.com/neeffect/kure-potlin
https://github.com/jarekratajski/just_another_to
https://github.com/jarekratajski/just_another_to
https://github.com/jarekratajski/just_another_to
https://github.com/neeffect/nee
https://github.com/neeffect/nee
https://github.com/neeffect/nee
https://github.com/neeffect/kotlin-stones
https://github.com/neeffect/kotlin-stones
https://github.com/neeffect/kotlin-stones
179. SUMMARY
SUMMARY
SUMMARY
FP
FP
FP
The more complex program we write the more
The more complex program we write the more
The more complex program we write the more
it helps
it helps
it helps
It is not a sliver bullet
It is not a sliver bullet
It is not a sliver bullet
180.
181. SUMMARY
SUMMARY
SUMMARY
FP
FP
FP
The more complex program we write the more
The more complex program we write the more
The more complex program we write the more
it helps
it helps
it helps
It is not a sliver bullet
It is not a sliver bullet
It is not a sliver bullet
It's a long way. But there are many convenient
It's a long way. But there are many convenient
It's a long way. But there are many convenient
steps
steps
steps
182.
183. SUMMARY
SUMMARY
SUMMARY
FP
FP
FP
The more complex program we write the more
The more complex program we write the more
The more complex program we write the more
it helps
it helps
it helps
It is not a sliver bullet
It is not a sliver bullet
It is not a sliver bullet
It's a long way. But there are many convenient
It's a long way. But there are many convenient
It's a long way. But there are many convenient
steps
steps
steps
Each step is a potential
Each step is a potential
Each step is a potential profit
profit
profit
184.
185. SUMMARY
SUMMARY
SUMMARY
FP
FP
FP
The more complex program we write the more
The more complex program we write the more
The more complex program we write the more
it helps
it helps
it helps
It is not a sliver bullet
It is not a sliver bullet
It is not a sliver bullet
It's a long way. But there are many convenient
It's a long way. But there are many convenient
It's a long way. But there are many convenient
steps
steps
steps
Each step is a potential
Each step is a potential
Each step is a potential profit
profit
profit
186. Kotlin is not Scala - but with some
Kotlin is not Scala - but with some
Kotlin is not Scala - but with some
tools/constraints it can be quite pure
tools/constraints it can be quite pure
tools/constraints it can be quite pure