This document discusses the evolution of programming languages and hardware over time. It covers older languages like FORTRAN, BASIC, and C/C++. It also discusses newer languages like Rust, Go, and Julia. It describes how memory management, concurrency models, and distributed computing have changed. It proposes using techniques like functional interpreters and macros to allow languages to be more easily extended and adapted to new hardware. The document advocates for approaches that can efficiently support both old and new programming ideas.
This document discusses various techniques for working with types in Scala, including:
1. The main alternatives for Scala types including classical OO, algebraic, generic, and structured types. It recommends choosing styles based on use cases and setting guidelines.
2. The differences between run-time and compile-time dispatch and how they are implemented in Scala.
3. Techniques for working with types including tagged types, type aliases, and implicit evidence to provide different behaviors based on types known at compile-time.
4. Resources for learning more about advanced type-level programming in Scala, particularly the Shapeless library.
This document provides a dictionary of scala programming concepts including definitions of common jargon like ADT, typeclasses, extension methods, and call-by semantics. It defines ADT as algebraic data types, which were introduced in languages like Algol 60 and ML, and pattern matching which allows decomposing ADT values. Typeclasses are defined as rules for types like equality, with instances providing implementations. Extension methods and implicit conversions add methods to types via implicit parameters. Call-by-name and call-by-need semantics are discussed in relation to lazy evaluation.
This document provides an overview of Scala fundamentals including:
- Scala is a programming language for the JVM that supports both object-oriented and functional paradigms.
- It defines variables, values, lazy values, functions, types, classes, objects, traits, and higher-order functions.
- Classes can extend other classes and traits, allowing for multiple inheritance. Objects are used as singletons.
- Functional concepts like immutability, anonymous functions, and higher-order functions are supported.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Some notes about programming in Scala: it covers Scala syntax and semantics, programming techniques, idioms, patterns. Many Scala features are introduced, from basic to intermediate and advanced. These are not introductory notes, but they assume a working knowledge with some other programming language (Java, C#, C++), object-oriented programming (OOP) concepts, and functional programming (FP) concepts.
Intro to Functional Programming in ScalaShai Yallin
Scala is a functional and object-oriented programming language that runs on the Java Virtual Machine. It features type inference, immutable collections, pattern matching, and functions as first-class values. The document provides an overview of Scala's features such as its static typing, traits for multiple inheritance, and case classes for value objects. It also demonstrates Scala's collections API and use of functions and pattern matching.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
This document discusses various techniques for working with types in Scala, including:
1. The main alternatives for Scala types including classical OO, algebraic, generic, and structured types. It recommends choosing styles based on use cases and setting guidelines.
2. The differences between run-time and compile-time dispatch and how they are implemented in Scala.
3. Techniques for working with types including tagged types, type aliases, and implicit evidence to provide different behaviors based on types known at compile-time.
4. Resources for learning more about advanced type-level programming in Scala, particularly the Shapeless library.
This document provides a dictionary of scala programming concepts including definitions of common jargon like ADT, typeclasses, extension methods, and call-by semantics. It defines ADT as algebraic data types, which were introduced in languages like Algol 60 and ML, and pattern matching which allows decomposing ADT values. Typeclasses are defined as rules for types like equality, with instances providing implementations. Extension methods and implicit conversions add methods to types via implicit parameters. Call-by-name and call-by-need semantics are discussed in relation to lazy evaluation.
This document provides an overview of Scala fundamentals including:
- Scala is a programming language for the JVM that supports both object-oriented and functional paradigms.
- It defines variables, values, lazy values, functions, types, classes, objects, traits, and higher-order functions.
- Classes can extend other classes and traits, allowing for multiple inheritance. Objects are used as singletons.
- Functional concepts like immutability, anonymous functions, and higher-order functions are supported.
Scala Intro training @ Lohika, Odessa, UA.
This is a basic Scala Programming Language overview intended to evangelize the language among any-language programmers.
Some notes about programming in Scala: it covers Scala syntax and semantics, programming techniques, idioms, patterns. Many Scala features are introduced, from basic to intermediate and advanced. These are not introductory notes, but they assume a working knowledge with some other programming language (Java, C#, C++), object-oriented programming (OOP) concepts, and functional programming (FP) concepts.
Intro to Functional Programming in ScalaShai Yallin
Scala is a functional and object-oriented programming language that runs on the Java Virtual Machine. It features type inference, immutable collections, pattern matching, and functions as first-class values. The document provides an overview of Scala's features such as its static typing, traits for multiple inheritance, and case classes for value objects. It also demonstrates Scala's collections API and use of functions and pattern matching.
Slides from my talk at the Feb 2011 Seattle Tech Startups meeting. More info here (along with powerpoint slides): http://www.startupmonkeys.com/2011/02/scala-frugal-mechanic/
This document provides an introduction to functional programming concepts and the Scala programming language. It begins with a brief history of object-oriented programming and why it became popular. It then discusses why functional programming has gained popularity in recent years due to its ability to handle parallel, reactive and distributed systems through immutable data and avoidance of mutable state. The document introduces functional programming concepts like immutable data, first-class functions and purity. It provides an example of functional-style programming in Scala. Finally, it outlines topics that will be covered about practical functional programming in Scala, including collections, functions, pattern matching and lazy evaluation.
This is brief presentation on the Scala programming language. It is aimed at Java developers who are curious about Scala. It was given at a San Francisco Java User Group in January 2009.
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
- The document discusses some of the author's criticisms of Scala, including its use of implicit parameters to configure runtime behavior, and lack of good support for asynchronous programming.
- The author proposes some workarounds, like annotating imports to avoid implicit conflicts, and patching the compiler to add more information to Future exceptions. However, the ideal solution would be language changes or improvements to asynchronous abstractions like Async.
- Overall, the author argues that Scala is not ideal for some use cases like asynchronous programming, but provides some workarounds people can use in the meantime. The best solutions require changes to the language and standard library.
This document provides an introduction to Scala for Java developers. It discusses that Scala is a hybrid object-oriented and functional language that runs on the JVM and interoperates well with Java. It highlights several features of Scala that allow for more concise code compared to Java, such as type inference, expressions instead of statements, higher-order functions, and case classes.
My Scala by the Bay 2014 talk on exploring the ideas behind the implementation of the generic library shapeless, and general ideas about how to do "type level" programming in Scala.
This document provides an introduction to Scala. It discusses:
- Who the author is and their background with Scala and Spark
- Why Scala is a scalable language that runs on the JVM and supports object oriented and functional programming
- How to install Scala and use the Scala interpreter
- Basic Scala syntax like defining values and variables, type inference, strings, tuples, objects, importing classes
- Common functions and operations like map, reduce, anonymous functions, pattern matching
- Code samples for RDD relations and SparkPi
- Tips for using Scala in practice including SBT and good IDEs like IntelliJ
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
This document provides a cheat sheet overview of Scala concepts including packages, imports, variables, constants, classes, traits, generics, methods, functions, operators, arrays, main methods, annotations, assignments, selection, iteration and references. Key points are that Scala uses packages similarly to Java but with curly brace delimiters, imports can be used anywhere in a file, variables use 'var', constants use 'val', classes inherit from Any and can use traits for mixins, generics are defined with type parameters, functions are objects, operators are methods, arrays are classes, main returns Unit, and assignments use = while iteration prefers recursion over loops.
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
This document summarizes a talk given about Nokia's migration to Scala for its Places API. The key points are:
1) Nokia migrated its Places API codebase to Scala to take advantage of Scala's features like its powerful type system, immutable data structures, and functional programming capabilities.
2) The migration was done gradually over time while continuing to develop new features. They discovered many benefits of Scala along the way like improved test readability and JSON parsing capabilities.
3) Nokia uses Scala features like case classes, options, and functions to model data and add type safety to its codebase. This uncovered bugs that would have been hard to find in Java.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
The document provides an overview of higher-kinds, typeclasses, type-level encodings, and continuations in Scala. It discusses how kind systems classify types, how typeclasses allow abstraction over types, and examples of encoding data structures like linked lists at the type level. It also introduces delimited continuations in Scala and how they can be used to simulate control flow constructs like break statements.
This document discusses refactoring Scala code to improve quality and maintainability. It provides examples of issues like stringly typed code, abuse of collections, and poor scoping. The presentation recommends addressing these by using case classes instead of tuples, parsing values instead of passing raw strings, giving intermediate steps meaningful names, and separating logic and data through traits or type classes. Well-scoped code with a small public API and private implementation details is emphasized.
I love Scala, I really do. I find Scala both more productive and more fun then any of the many languages I have worked with before. There are many reasons to use to Scala; however, I will not be talking about them.
Instead, in this talk I will cover some of the things I find annoying or disappointing in Scala. For each I will explain the issue, why it is so, whether or not it is likely to ever change, and what, if anything, we can do about it in the mean time.
The issues covered will include:
Limitations on type inference
Type Erasure
Binary incompatibility
Limitations on overloading
Standard library quality
And more
The lecture is geared towards those who have written between 10 and 10 millions lines of Scala code.
The document discusses how JavaScript engines work under the hood to execute code. It explains that engines first tokenize and parse code into an abstract syntax tree. Variables are then located in memory and their values retrieved, which can involve lookups in objects or arrays. Values are boxed and typed for operations, which engines try to optimize through just-in-time compilation by tracking types. Operations are performed and results are stored, with garbage collection maintaining memory. Future ECMAScript changes may impact these processes. The conclusion advocates type safety, dense arrays, and avoiding operations requiring repeated coercion.
1) The document discusses several Java performance myths and uses microbenchmarks to analyze them. It finds that final variables and String concatenation are not necessarily faster than alternatives.
2) It recommends using the Caliper framework for robust microbenchmarking and provides several useful JVM flags for profiling and optimization.
3) The document outlines various Java optimization strategies used by the JVM compiler including inlining, intrinsics, escape analysis, and loop unrolling. It emphasizes the importance of clear and readable code over premature optimization.
The document discusses the Kotlin programming language. It highlights that Kotlin is a modern, pragmatic language that provides good tooling and interoperability with Java. It has grown significantly in popularity since its initial release. The document then discusses various features of Kotlin like its concise and readable syntax, null safety, support for lambdas and extensions, and how it can be used for multi-platform projects. Kotlin aims to be an improvement over Java by making code more concise, safe, and expressive while maintaining interoperability with existing Java code and libraries.
This document provides an introduction and overview of the Kotlin programming language. It covers key Kotlin concepts and features such as properties, null safety, classes, interfaces, extensions, and collections. It also includes Kotlin's timeline, development tools, and basic data types. The agenda outlines topics like String templates, OOP concepts, lambdas, and infix notation that are explained further in the document.
Redox OS is an operating system written in the Rust programming language.
This short presentation was held as part of an exercise in front of a business class, so some stuff is explained very briefly. Also the amount of time I had was only 10 minutes.
This document provides an introduction to functional programming concepts and the Scala programming language. It begins with a brief history of object-oriented programming and why it became popular. It then discusses why functional programming has gained popularity in recent years due to its ability to handle parallel, reactive and distributed systems through immutable data and avoidance of mutable state. The document introduces functional programming concepts like immutable data, first-class functions and purity. It provides an example of functional-style programming in Scala. Finally, it outlines topics that will be covered about practical functional programming in Scala, including collections, functions, pattern matching and lazy evaluation.
This is brief presentation on the Scala programming language. It is aimed at Java developers who are curious about Scala. It was given at a San Francisco Java User Group in January 2009.
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
- The document discusses some of the author's criticisms of Scala, including its use of implicit parameters to configure runtime behavior, and lack of good support for asynchronous programming.
- The author proposes some workarounds, like annotating imports to avoid implicit conflicts, and patching the compiler to add more information to Future exceptions. However, the ideal solution would be language changes or improvements to asynchronous abstractions like Async.
- Overall, the author argues that Scala is not ideal for some use cases like asynchronous programming, but provides some workarounds people can use in the meantime. The best solutions require changes to the language and standard library.
This document provides an introduction to Scala for Java developers. It discusses that Scala is a hybrid object-oriented and functional language that runs on the JVM and interoperates well with Java. It highlights several features of Scala that allow for more concise code compared to Java, such as type inference, expressions instead of statements, higher-order functions, and case classes.
My Scala by the Bay 2014 talk on exploring the ideas behind the implementation of the generic library shapeless, and general ideas about how to do "type level" programming in Scala.
This document provides an introduction to Scala. It discusses:
- Who the author is and their background with Scala and Spark
- Why Scala is a scalable language that runs on the JVM and supports object oriented and functional programming
- How to install Scala and use the Scala interpreter
- Basic Scala syntax like defining values and variables, type inference, strings, tuples, objects, importing classes
- Common functions and operations like map, reduce, anonymous functions, pattern matching
- Code samples for RDD relations and SparkPi
- Tips for using Scala in practice including SBT and good IDEs like IntelliJ
"The joy of Scala" - Maxim Novak / Wix
Around eight years ago I started my journey as a developer. Since then, I've played around with many languages and thought that C# offers the best developer productivity. After joining Wix two years ago, I was exposed to the amazing world of Scala and Functional Programming and never looked back.
In Scala the code is much more concise, less ceremonious, immutable by default, combines functional with object oriented, seamlessly interoperates with Java, and many software engineering patterns are already baked into the language. Most importantly - Scala is FUN! By the end of the session you too will, hopefully, convert to Scala and never look back.
Recording of the lecture (Hebrew) - https://youtu.be/TcnYTwff2xU
This document provides a cheat sheet overview of Scala concepts including packages, imports, variables, constants, classes, traits, generics, methods, functions, operators, arrays, main methods, annotations, assignments, selection, iteration and references. Key points are that Scala uses packages similarly to Java but with curly brace delimiters, imports can be used anywhere in a file, variables use 'var', constants use 'val', classes inherit from Any and can use traits for mixins, generics are defined with type parameters, functions are objects, operators are methods, arrays are classes, main returns Unit, and assignments use = while iteration prefers recursion over loops.
Some languages, like SML, Haskell, and Scala, have built-in support for pattern matching, which is a generic way of branching based on the structure of data.
While not without its drawbacks, pattern matching can help eliminate a lot of boilerplate, and it's often cited as a reason why functional programming languages are so concise.
In this talk, John A. De Goes talks about the differences between built-in patterns, and so-called first-class patterns (which are "do-it-yourself" patterns implemented using other language features).
Unlike built-in patterns, first-class patterns aren't magical, so you can store them in variables and combine them in lots of interesting ways that aren't always possible with built-in patterns. In addition, almost every programming language can support first-class patterns (albeit with differing levels of effort and type-safety).
During the talk, you'll watch as a mini-pattern matching library is developed, and have the opportunity to follow along and build your own pattern matching library in the language of your choice.
This document summarizes a talk given about Nokia's migration to Scala for its Places API. The key points are:
1) Nokia migrated its Places API codebase to Scala to take advantage of Scala's features like its powerful type system, immutable data structures, and functional programming capabilities.
2) The migration was done gradually over time while continuing to develop new features. They discovered many benefits of Scala along the way like improved test readability and JSON parsing capabilities.
3) Nokia uses Scala features like case classes, options, and functions to model data and add type safety to its codebase. This uncovered bugs that would have been hard to find in Java.
Watch video (in Hebrew): http://parleys.com/play/53f7a9cce4b06208c7b7ca1e
Type classes are a fundamental feature of Scala, which allows you to layer new functionality on top of existing types externally, i.e. without modifying or recompiling existing code. When combined with implicits, this is a truly remarkable tool that enables many of the advanced features offered by the Scala library ecosystem. In this talk we'll go back to basics: how type classes are defined and encoded, and cover several prominent use cases.
A talk given at the Underscore meetup on 19 August, 2014.
A teaser talk for Scala newbies, introducing five basic elements that (in my opinion) make the transition from Java to Scala a no-brainer.
Given at the 7th JJTV (Israeli Java/JVM user group) tool night, July 2nd, 2013.
The document provides an overview of higher-kinds, typeclasses, type-level encodings, and continuations in Scala. It discusses how kind systems classify types, how typeclasses allow abstraction over types, and examples of encoding data structures like linked lists at the type level. It also introduces delimited continuations in Scala and how they can be used to simulate control flow constructs like break statements.
This document discusses refactoring Scala code to improve quality and maintainability. It provides examples of issues like stringly typed code, abuse of collections, and poor scoping. The presentation recommends addressing these by using case classes instead of tuples, parsing values instead of passing raw strings, giving intermediate steps meaningful names, and separating logic and data through traits or type classes. Well-scoped code with a small public API and private implementation details is emphasized.
I love Scala, I really do. I find Scala both more productive and more fun then any of the many languages I have worked with before. There are many reasons to use to Scala; however, I will not be talking about them.
Instead, in this talk I will cover some of the things I find annoying or disappointing in Scala. For each I will explain the issue, why it is so, whether or not it is likely to ever change, and what, if anything, we can do about it in the mean time.
The issues covered will include:
Limitations on type inference
Type Erasure
Binary incompatibility
Limitations on overloading
Standard library quality
And more
The lecture is geared towards those who have written between 10 and 10 millions lines of Scala code.
The document discusses how JavaScript engines work under the hood to execute code. It explains that engines first tokenize and parse code into an abstract syntax tree. Variables are then located in memory and their values retrieved, which can involve lookups in objects or arrays. Values are boxed and typed for operations, which engines try to optimize through just-in-time compilation by tracking types. Operations are performed and results are stored, with garbage collection maintaining memory. Future ECMAScript changes may impact these processes. The conclusion advocates type safety, dense arrays, and avoiding operations requiring repeated coercion.
1) The document discusses several Java performance myths and uses microbenchmarks to analyze them. It finds that final variables and String concatenation are not necessarily faster than alternatives.
2) It recommends using the Caliper framework for robust microbenchmarking and provides several useful JVM flags for profiling and optimization.
3) The document outlines various Java optimization strategies used by the JVM compiler including inlining, intrinsics, escape analysis, and loop unrolling. It emphasizes the importance of clear and readable code over premature optimization.
The document discusses the Kotlin programming language. It highlights that Kotlin is a modern, pragmatic language that provides good tooling and interoperability with Java. It has grown significantly in popularity since its initial release. The document then discusses various features of Kotlin like its concise and readable syntax, null safety, support for lambdas and extensions, and how it can be used for multi-platform projects. Kotlin aims to be an improvement over Java by making code more concise, safe, and expressive while maintaining interoperability with existing Java code and libraries.
This document provides an introduction and overview of the Kotlin programming language. It covers key Kotlin concepts and features such as properties, null safety, classes, interfaces, extensions, and collections. It also includes Kotlin's timeline, development tools, and basic data types. The agenda outlines topics like String templates, OOP concepts, lambdas, and infix notation that are explained further in the document.
Redox OS is an operating system written in the Rust programming language.
This short presentation was held as part of an exercise in front of a business class, so some stuff is explained very briefly. Also the amount of time I had was only 10 minutes.
Rust is a systems programming language developed by Mozilla that provides memory safety without garbage collection. It uses concepts of ownership and borrowing to ensure memory safety issues like use-after-free do not occur. Rust offers zero-cost abstractions meaning abstraction mechanisms like generics have little to no performance overhead. It allows high levels of concurrency but requires memory references be valid during their entire lifetime.
Performance Comparison of Mutex, RWLock and Atomic types in RustMitsunori Komatsu
This document compares the performance of Mutex, RWLock, and atomic types for concurrent access in Rust. It presents benchmark results from a Rust program that tests updating a shared variable with these different synchronization methods under varying read/write loads on Linux and macOS. The results show that RWLock performance degrades significantly with more writes, Mutex performance is consistent even with writes, and atomic types are always the fastest for a counter.
scala-gopher: async implementation of CSP for scalaRuslan Shevchenko
This document describes scala-gopher, a Scala library that implements Communicating Sequential Processes (CSP) concepts like Go channels. It allows asynchronous programming using constructs like select.forever that handle input/output between channels. The library builds on Akka and SIP 22 for asynchrony. It includes channels, transputers that connect via ports, and replication capabilities for running processes in parallel. The goal is to provide CSP functionality within the Scala ecosystem as a complementary approach to streams and actors.
A short introduction (with many examples) to the Scala programming language and also an introduction to using the Play! Framework for modern, safe, efffcient and reactive web applications.
The document outlines concepts covered in a programming languages course, including syntax and semantics, names and bindings, data types, functional programming, polymorphism, parsing and interpretation, modular programming, concurrency, and domain-specific languages. It also lists various languages as examples, such as Scala, JavaScript, C, and internal DSLs in languages like Haskell and Ruby. Finally, it discusses domain-specific languages and provides examples including spreadsheet formulas, query languages, graph layout languages, web languages, game scripting languages, and modeling languages.
These are the outline slides that I used for the Pune Clojure Course.
The slides may not be much useful standalone, but I have uploaded them for reference.
This document describes john-devkit, an experiment to generate optimized C code for hash cracking algorithms in John the Ripper. It aims to separate algorithms, optimizations, and device-specific code to improve performance and scalability. Early results show speed improvements for some formats over John the Ripper's default implementation. The document discusses optimizations like interleaving, vectorization, and early reject that can be applied to any algorithm without effort. It also describes the intermediate language and optimizations specific to password cracking used by john-devkit to generate optimized output code.
EcmaScript 6 introduces many new features to JavaScript including let and const block-scoped variables, arrow functions, classes, promises, and modules. Tooling like transpilers are currently needed to use ES6 in older browsers. Future versions will continue to evolve the language with proposals for ES7 including concurrency, streams, and better support for classes and metaprogramming. Overall ES6 and future versions aim to modernize JavaScript and better support object-oriented and asynchronous programming patterns.
ES6 introduced many new features to JavaScript including let and const block scoping, arrow functions, classes, promises, and modules. Tooling like Babel is currently needed to use new features by transpiling code to older JavaScript versions. Future releases will continue enhancing JavaScript with new syntax and capabilities under an annual release cycle. ES7 proposals include concurrency, streams, math enhancements, and better metaprogramming with classes.
An Introduction to Scala for Java DevelopersMiles Sabin
The document provides an introduction to Scala for Java developers. It outlines key features of Scala including cleaning up Java syntax, going beyond Java with features like case classes, traits, and pattern matching, and its functional focus including support for higher-order functions, the Option type, and for comprehensions. The document also briefly discusses the Scala IDE for Eclipse.
BCS SPA 2010 - An Introduction to Scala for Java DevelopersMiles Sabin
This document provides an introduction to Scala for Java developers. It outlines how Scala cleans up Java syntax by making semi-colons optional, using == for equals and eq for reference equality, and allowing periods to be omitted. It also describes how Scala goes beyond Java by supporting features like case classes, pattern matching, named and default arguments, and mixin composition with traits. The document provides examples of using these features and explains how Scala seamlessly interoperates with Java.
This document discusses functional programming languages Scala and Clojure that run on the Java Virtual Machine (JVM). It provides an overview of what functional programming is, why it is becoming more important with multi-core processors, and why developing new languages on the JVM is advantageous due to its existing investments and performance. Specific details are given about Clojure, including how it has tight integration with Java and the JVM, uses immutable collections and lazy sequences, and provides primitives for concurrency. Scala is described as a functional language that is fast, expressive, and statically typed with features like traits, pattern matching, and XML literals. The document concludes that as developers we should choose the right tools for our
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
Scala is a programming language that blends object-oriented and functional programming. It is designed to be compatible with Java and runs on the JVM. Scala has features like functions as first-class values, pattern matching, and immutable data structures. It aims to improve on Java syntax and provides tools like case classes and for comprehensions. Scala sees growing adoption in companies like Twitter and LinkedIn and future releases will continue to explore new type systems and features.
The document discusses Scala, a programming language designed to be scalable. It can be used for both small and large programs. Scala combines object-oriented and functional programming. It interoperates seamlessly with Java but allows developers to add new constructs like actors through libraries. The Scala community is growing, with industrial adoption starting at companies like Twitter.
The document reviews JavaScript languages that can be compiled to JavaScript, including CoffeeScript, Dart, TypeScript, Traceur, Emscripten, Scala.js, ClojureScript, Kotlin, and others. It discusses their features like static typing, classes, async/await support, and ability to port other language ecosystems to run in the browser. It also covers architectures like Opa and Ur/Web that aim to use a single language across front-end, back-end, and databases.
Martin Odersky outlines the growth and adoption of Scala over the past 6 years and discusses Scala's future direction over the next 5 years. Key points include:
- Scala has grown from its first classroom use in 2003 to filling a full day of talks at JavaOne in 2009 and developing a large user community.
- Scala 2.8 will include new collections, package objects, named/default parameters, and improved tool support.
- Over the next 5 years, Scala will focus on concurrency and parallelism features at all levels from primitives to tools.
- Other areas of focus include extended libraries, performance improvements, and standardized compiler plugin architecture.
Scala 2.8 will include improvements to collections, package objects, named and default parameters, and faster generics through specialization. Over the next 5 years, focus will be on concurrency and parallelism at all levels. Better tools like an improved REPL and IDE integration are also planned. The essence of Scala is concentrating on powerful abstractions to reduce boilerplate and allow powerful libraries.
This document summarizes Martin Odersky's talk about the past, present, and future of the Scala programming language over the next 5 years. It discusses Scala's growth in popularity and adoption from 2003-2009. It also outlines new features in the 2.8 version including improved collections, package objects, named parameters, and improved tooling. Finally, it discusses focus areas for the next 5 years including improved concurrency, parallelism, static typing, and language abstractions to support reliable concurrent programming.
Martin Odersky discusses the past, present, and future of Scala over the past 5 years and next 5 years. Key points include:
- Scala has grown significantly in usage and community over the past 6 years since its first release.
- Scala 2.8 will include improvements like new collections, package objects, named/default parameters, and better tool support.
- Over the next 5 years, Scala will focus on improving concurrency and parallelism through better abstractions, analyses, and static typing support.
SE2016 Exotic Ruslan Shevchenko "Programming languages landscape new & ol...Inhacking
Event: #SE2016
Stage: Exotic
Data: 3 of September 2016
Speaker: Ruslan Shevchenko
Topic: Programming languages landscape new & old ideas
INHACKING site: https://inhacking.com
SE2016 site: http://se2016.inhacking.com/
Ruslan Shevchenko Programming languages landscape: new & old ideasАліна Шепшелей
In this lection we will talk about emerging development in the field of industry programming languages, new ideas for niche and mainstream market and what is possible to use now. Will mark positions and main characteristics for today-s spectrum of new languages: from Scala, Rust, Julia to Wolfram and Racket.
Similar to SE 20016 - programming languages landscape. (20)
This document discusses Scala 3's support for asynchronous programming using async/await. It begins with reminders about monadic effects and reactivity using effect monads. It then discusses how async/await improves on effect monads by avoiding manual coloring and reducing the number of awaits needed. The document describes how automatic coloring can be achieved using a macro. It also discusses challenges around monad interoperability and optimization of the monadic continuation passing style transformation.
This document discusses behavior modeling using behavior algebra and Akka actors. It provides an example of modeling a coffee machine as a behavior using behavior algebra equations and then implementing it in Scala with Akka actors. Key points covered include:
- Defining behaviors as labeled transition systems (LTS) with states, actions, and transitions between states via actions
- Composing behaviors using operations like sequential composition, choice composition, and recursion to build larger behaviors from smaller ones
- Modeling a basic coffee machine as a behavior that can accept coins and button presses and dispense coffee
- Expanding the model to add features like accumulating credit from multiple coins and disabling/enabling the machine
- Implementing the coffee machine
Papers We Love / Kyiv : PAXOS (and little about other consensuses )Ruslan Shevchenko
Slides from talk on 'Papers we Love, Kyiv' meetup: 27.07.2018 -- description of Paxos algorithm and friends.
https://www.meetup.com/Papers-We-Love-Kyiv/events/252974063/
This document discusses factors that influence the evolution and adoption of programming languages like Scala. It argues that for a language to be evolutionarily stable, it needs to survive, be adopted by a user base that is more than 1%, and be attractive. Scala's main value proposition is its support for static metaprogramming, but it needs to improve concurrency support, reduce boilerplate code, and simplify its core to lower the learning curve. New developments like Dotty and Squid could help address current issues and support further language evolution.
The document discusses functions and the Liskov substitution principle. It defines functions with signatures like f: A => B, meaning a function f that takes an input of type A and returns an output of type B. It explains function composition using andThen and |>. It also discusses how the Liskov substitution principle states that if S is a subtype of T, then objects of type T may be replaced with objects of type S without altering any desirable properties of that program. This allows subclasses to substitute behavior while preserving contracts with external consumers.
This document discusses various streaming approaches and implementations in different programming languages and frameworks. It covers:
1) Notable streaming implementations like SISAL, Occam, Inferno, Limbo, Go, Orc, and their origins.
2) Scala implementations of streaming including iteratee/enumeratee, scalaz-streams, fs2, akka-streams, gopher, monix.io.
3) Core concepts of streaming including pull-based and push-based approaches, active channels, and how different frameworks implement these concepts using combinators and domain-specific languages.
This document discusses programming techniques for low-latency Java applications. It begins by explaining what low-latency means and when it is needed. It then covers various techniques including: using concurrent flows and minimizing context switches; exchanging data between threads via queues instead of shared memory; preallocating objects to avoid allocations; and directly accessing serialized data instead of object instances. The document also discusses memory issues like garbage collection pauses and cache line contention. It covers alternatives for accessing native code like JNA, JNI, and shared memory. Critical JNI is presented as a faster option than regular JNI.
This document outlines a presentation about CSP (Communicating Sequential Processes) theory and implementation in Scala using the scala-gopher library. It begins with an introduction to CSP theory, history, and languages like Occam and Limbo that were influenced by it. It then demonstrates how scala-gopher implements key CSP concepts like channels, selectors, and processes in Scala. Examples are shown of writing Fibonacci sequences and broadcasting messages using these primitives. Potential issues with the current scala-gopher implementation are noted.
This document discusses various techniques for integrating R with other programming languages and ecosystems. It begins by asking what to do after building a model in R, such as rewriting the code, integrating R with other languages, or implementing business logic directly in R. The document then covers options for integrating R at the command line, library level, and for calling R from other languages like C++. It also discusses using R for web applications via techniques like rApache, shiny, and openCPU. In the end it argues that R can be effectively used as part of an application infrastructure along with software engineering languages.
The document discusses domain modeling approaches in a post-object-oriented world. It outlines issues with traditional OO domain modeling and proposes an alternative approach. This involves:
1. Describing a limited set of domain objects and relationships as an "algebra" rather than a universal ontology.
2. Using existential equality where identity is defined by attributes rather than identity.
3. Building a simple domain model for a toy billing system to demonstrate the approach.
4. Discussing how the domain model can be implemented and improved, including handling errors, deaggregating components, and using internal domain-specific languages.
Programming Languages: some news for the last N yearsRuslan Shevchenko
This document discusses programming languages and their evolution. It covers topics like syntax, type systems, dependent types, and effects tracking. It suggests that while new academic ideas in programming languages take over a decade on average to see wider adoption, trends in industry include integrating other paradigms into mainstream languages and replacing C++ with alternatives like D or Rust. The document also questions what new academic or open source ideas may become part of industry programming in the future.
The document discusses various web application architecture techniques, including:
- Popular frameworks like Sinatra that use REST APIs and MVC patterns on the client-side.
- Reactive frameworks like Shiny that use websockets for real-time updates between the client and server.
- Challenges in building reactive applications, as infrastructure is still maturing to support callbacks without blocking.
- Other approaches to reactivity on the server including actors, channels, and reactive extensions.
- The document concludes that there is no single ideal architecture, as techniques are continually invented and re-invented over time.
This document discusses integrating R and Scala. It provides context on existing packages like jvmr that allow calling Scala from R and Renjin, which implements an R interpreter in the JVM. It notes challenges like running the Scala compiler at runtime when calling Scala from R and issues with Renjin only working on Linux and requiring looking at GCC internals. The author advocates a simple approach of just adding JAR files to allow calling R from Scala but notes it is slow. The conclusion states that living between the two worlds can be funny.
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
When it is all about ERP solutions, companies typically meet their needs with common ERP solutions like SAP, Oracle, and Microsoft Dynamics. These big players have demonstrated that ERP systems can be either simple or highly comprehensive. This remains true today, but there are new factors to consider, including a promising new contender in the market that’s Odoo. This blog compares Odoo ERP with traditional ERP systems and explains why many companies now see Odoo ERP as the best choice.
What are ERP Systems?
An ERP, or Enterprise Resource Planning, system provides your company with valuable information to help you make better decisions and boost your ROI. You should choose an ERP system based on your company’s specific needs. For instance, if you run a manufacturing or retail business, you will need an ERP system that efficiently manages inventory. A consulting firm, on the other hand, would benefit from an ERP system that enhances daily operations. Similarly, eCommerce stores would select an ERP system tailored to their needs.
Because different businesses have different requirements, ERP system functionalities can vary. Among the various ERP systems available, Odoo ERP is considered one of the best in the ERp market with more than 12 million global users today.
Odoo is an open-source ERP system initially designed for small to medium-sized businesses but now suitable for a wide range of companies. Odoo offers a scalable and configurable point-of-sale management solution and allows you to create customised modules for specific industries. Odoo is gaining more popularity because it is built in a way that allows easy customisation, has a user-friendly interface, and is affordable. Here, you will cover the main differences and get to know why Odoo is gaining attention despite the many other ERP systems available in the market.
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemPeter Muessig
Learn about the latest innovations in and around OpenUI5/SAPUI5: UI5 Tooling, UI5 linter, UI5 Web Components, Web Components Integration, UI5 2.x, UI5 GenAI.
Recording:
https://www.youtube.com/live/MSdGLG2zLy8?si=INxBHTqkwHhxV5Ta&t=0
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesQuickdice ERP
Explore the seamless transition to e-invoicing with this comprehensive guide tailored for Saudi Arabian businesses. Navigate the process effortlessly with step-by-step instructions designed to streamline implementation and enhance efficiency.
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
8 Best Automated Android App Testing Tool and Framework in 2024.pdfkalichargn70th171
Regarding mobile operating systems, two major players dominate our thoughts: Android and iPhone. With Android leading the market, software development companies are focused on delivering apps compatible with this OS. Ensuring an app's functionality across various Android devices, OS versions, and hardware specifications is critical, making Android app testing essential.
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
Transform Your Communication with Cloud-Based IVR SolutionsTheSMSPoint
Discover the power of Cloud-Based IVR Solutions to streamline communication processes. Embrace scalability and cost-efficiency while enhancing customer experiences with features like automated call routing and voice recognition. Accessible from anywhere, these solutions integrate seamlessly with existing systems, providing real-time analytics for continuous improvement. Revolutionize your communication strategy today with Cloud-Based IVR Solutions. Learn more at: https://thesmspoint.com/channel/cloud-telephony
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Drona Infotech is a premier mobile app development company in Noida, providing cutting-edge solutions for businesses.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Mobile app Development Services | Drona InfotechDrona Infotech
Drona Infotech is one of the Best Mobile App Development Company In Noida Maintenance and ongoing support. mobile app development Services can help you maintain and support your app after it has been launched. This includes fixing bugs, adding new features, and keeping your app up-to-date with the latest
Visit Us For :
1. PROGRAMMING LANGUAGES LANDSCAPE
OLD & NEW IDEAS
Ruslan Shevchenko
VertaMedia/ Researcher
ruslan@shevchenko.kiev.ua
https://github.com/rssh
@rssh1
2. PROGRAMMING LANGUAGES LANDSCAPE: OLD & NEW IDEAS
What tomorrow programming will be like.
Languages
Complexity
Hardware
Worlds
Learning Curve
Expressibility
Layers
5. Hardware
1 Processor Unit
1 Memory Unit
1 Machine
N Different Processors (CPU, GPU, NTU, QTU)
N Different Storage Systems (Cache, Mem, SSD, ..)
N Different Machines
PL: Main Language Constructs:
still execution flows
6. Memory Access Evolution:
Fortran 57 : static memory allocation
Algol 60 : Stack
Lisp 58: Garbage Collection
BCPL, C [70] - manual
ObjectiveC [88] — reference counting
Java [95] — Garbage collection become mainstream.
Rust [2010-15] — compile-time analysis become mainstream
C++ [..88] — manual + destructors
Algol 68: - Stack + manual + GC
Smalltalk [72-80] — GC (RC as GC optimization)
Objective C++
ML [70] - compile time analysis
Simula 67
// not all, not main
7. Memory Access Evolution:
Manual allocation: Risky, low-level
Garbage Collection: Generally Ok, but pauses:
not for Real-time systems
not for System-level programming
Type analysis [RUST]
subculture of sun.misc.Unsafe
in java
8. RUST: ownership & lifecycle
T - object of type T (owned by code in scope)
&T - borrowed reference to type T (owned not by us)
&’L T - reference to type T with Lifetime L
mut T - mutable object of type T
* T - row unsafe pointer
let y: & str
{
let email = retrieve_email(….. )
let domain = first_entry(email,”@“)
y = domain
}
// not compiled, lifetime of y is in outer scope.
fn first_entry(value: &’a str, pattern: &’b str) -> &’a str
9. RUST: general
Next step in low-level system languages.
Zero-cost abstraction + safety
more difficult to write in comparison with GC lang.
fast and easy in Comparison with C [may-be C++]
Alternatives:
advanced GC [go, D, Nim ]
10. Concurrency Models Evolution:
Fortran 57 : one execution flow
PL/1 64 : Multitasking API
1972: Actor Model
1988: Erlang [ Actor Model implementation]
1978: CSP Model
1983: Occam [1-st CSP Model Implementation]
1980: Implicit parallelism in functional languages (80-1)
1977. Future [MultiLisp]
2007: Go (CSP become mainstream)
2010: Akka in Scala (Actor Model become mainstream)
2015: Pony [actors + ownership]
// not all, not main
11. Concurrency Models:
Callbacks: [manual], Futures [Semi-manual]
hard to maintain
Actor-Model (Active Object)
CSP Channels; Generators
Async methods.
lightweight threads [coroutines, fibers .. ]
execution flow ‘breaks’ thread boundaries.
Implicit parallelism
hard to implement, not yet in mainstream
14. Async/Transform (by compiler/interpreter):
def method():Future[Int] = async {
val x = retrieveX()
val y = retrieveY()
x+y
}
def method():Future[Int] = async {
val x = await(retrieveX())
val y = await(retrieveY())
x+y
}
class methodAsync {
var state: Int
val promise: Promise[Int]
var x, y
def m():Unit =
{
state match {
case 0 => x = retrieveX onSuccess{ state=1; m() }
case 1 => y = retrieveY on Success { state = 2; m() }
case 2 => promise.set(x+y)
}
}
15. Concurrency Models / current state
Problems:
Data Races. Possible solutions:
immutability (functional programming)
copy/move semantics [Go, Rust]
static alias analysis [Rust, Pony]
Async IO interfaces.
Future:
Heterogenous/Distributed case
Implicit parallelism
16. RUST: race control
T <: std::marker::Send
— it is safe to send object to other thread
— otherThread(t) is safe
T <: std::marker::Sync
— it is safe to share object between threads
— share = send reference
—- otherThread(&t) is safe
{
let x = 1
thread::spawn {||
do_something(x)
}
}
// error - lifetime of x
{
let x = 1
thread::spawn {move||
do_something(x)
}
}
copy of original
17. Pony:
Actors
Type Analysis for data sharing.
Pony Type - type + capability
— T iso - isolated
— T val - value
—- T ref - reference
—- T box - rdonly
—- T trn - transition (write part of the box)
—- T tag — identity only
Destructive read/write
fut test(T iso a) {
var ref x = a
}
// error -
fun test(T iso a){
var iso x = consume a // ok
var iso y = a
// error - a is consumed
}
19. val lines = load(uri)
val count = lines.flatMap(_.split(“ “))
.map(word => (word, 1))
.reduceByKey(_ + _)
Scala, count words:
// Same code, different execution
20. val lines = load(uri)
val count = lines.flatMap(_.split(“ “))
.map(word => (word, 1))
.reduceByKey(_ + _)
Java, count words:
// Same code, different execution
@Override
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String line = (caseSensitive) ?
value.toString() : value.toString().toLowerCase();
for (String pattern : patternsToSkip) {
line = line.replaceAll(pattern, "");
}
StringTokenizer itr = new StringTokenizer(line);
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
Counter counter = context.getCounter(CountersEnum.class.getName(), CountersEnum.INPUT_WORDS.toString());
counter.increment(1);
}
}
}
public static class IntSumReducer
extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}
21. @Override
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
String line = (caseSensitive) ?
value.toString() : value.toString().toLowerCase();
for (String pattern : patternsToSkip) {
line = line.replaceAll(pattern, "");
}
StringTokenizer itr = new StringTokenizer(line);
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
Counter counter = context.getCounter(CountersEnum.class.getName(), CountersEnum.INPUT_WORDS.toString());
counter.increment(1);
}
}
}
public static class IntSumReducer
extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Java, count words:
// Same code, different execution
Can we do better (?) - Yes [but not for free]
- retargeting stream API (impl.effort)
- via annotation processor
- use byte-code rewriting (low-level)
22. Java, count words(2):
// Near same code, different execution
List{???}<String> lines = load(uri)
int count = lines.toStream.map(x ->x.split(“ “))
.collect(Collectors.group{Concurrent,Distributed}By(w->w,
Collectors.mapping(w->1
Collectors.reducing(Integer::Sum)))
[distributed version is theoretically possible]
23. Ideas
Language Extensibility: F: A=>B F: Expr[A] => Expr[B]
• Functional interpreters: Expr[A] build on top of L
• well-known functional programming pattern
• Macros: Expr[A] == {program in A}
• Lisp macroses [1960 … ]
• Compiler plugins [X10],
• Non-standard interpretation of arguments [R]
Reach enough type system, to express Expr[A] (inside language)
24. Language Extensibility: F: A=>B F: Expr[A] => Expr[B]
Small example (functional compiler)
trait GE[T]
Code(
val fundefs: Map[String, String]
val expr: String,
)
trait GERunner
{
def loadValues(Map[String,Array[Double]])
def loadCode(GE[_])
def run()
def retrieveValues(name:String):Array[Double]
}
// GPU contains OpenCL or CUDA compiler
// available via system API
25. case class GEArray(name:String) extends GE[Array[Double]]
{
def apply(i:GE[Int]): GE[Double] = GEArrayIndex(this,i)
def update(i:GE[Int],x:GE[Double]): GE[Unit] = GEUpdate(this,i,x)
def index = new {
def map(f: GE[Int] => GE[Double]):GE[Array[Double]] = GEMap(this,f)
def foreach[T](f:GE[Int] => GE[T]):GE[Unit] = GEForeach(this,f)
}
}
case class GEPlus(x: GE[Double], y: GE[Double])
extends GE[Double]
implicit class CEPlusSyntax(x:CE[Double]) extends AnyVal
{
def + (y:CE[Double]) = CEPlus(x,y)
}
case class GEMap(a:GE[Array[Double]],f:GE[Int]=>GE[Double])
case class GEArrayIndex(a: GE[Array[Double]],i:GE[Int])
extends GE[Double]
case class GEConstant(x:T):GE[T]
case class GEVar[T](name:String):GE[T]
26. val a = GEArray[Double](“a”)
val b = GEArray[Double](“b”)
val c = GEArray[Double](“c”)
for( i<- a.index) {
c(i) = a(i) + b(i)
}
a.index.foreach(i => c(i) = a(i)+b(i) )
a.index(i => GEArrayIndex(c,i).update(i,
GEArrayIndex(a,i)+GEArrayIndex(b,i)))
GEForeach(i =>
(GEUpdate(c,i),
GEPlus(GEArrayIndex(a,i),GEArrayIndex(b,i)))
27. trait GE[T]
case class GPUCode(
val defs: Map[String,String]
val expr: String
)
class GEArrayIndex(x:GE[Array[Double]], i:GE[Int])
{
def generate():GPUCode =
{
val (cx, ci) = (x.generate(),i.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr}[${cy.expr}]”)
}
}
GEArrayIndex(GEArrayVar(a),GEVar(i)) => “a[i]”
class GEIntVar(name:String) ..
{
def generate():GPUCode =
GPUCode(
defs = Map(name -> “int ${name};”)
expr = name)
}
28. trait GE[T]
case class GPUCode(
val defs: Map[String,String]
val expr: String
)
class GEArrayIndex(x:GE[Array[Double]], i:GE[Int])
{
def generate():GPUCode =
{
val (cx, ci) = (x.generate(),i.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr}[${cy.expr}]”)
}
}
GEPlus(GEArrayIndex(GEArrayVar(a),GEVar(i)),
GEArrayIndex(GEArrayVar(b),GEVar(i)) =>
“a[i] + b[i]”
class GEPlus(x:GE[Double], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, cy) = (x.generate(),y.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
29. trait GE[T]
case class GPUCode(
val defs: Map[String,String]
val expr: String
)
class GEArrayIndex(x:GE[Array[Double]], i:GE[Int])
{
def generate():GPUCode =
{
val (cx, ci) = (x.generate(),i.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr}[${cy.expr}]”)
}
}
c.update(i,a(i)+b(i)) => “c[i] = a[i] + b[i]”
class GEPlus(x:GE[Double], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, cy) = (x.generate(),y.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
class GEUpdate(x:GE[Double],i:GE[Int], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, ci, cy) = (x,i,u) map (_.generate)
GPUCode(defs = merge(cx.defs,cy.defs,ci.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
30. trait GE[T]
case class GPUCode(
val defs: Map[String,String]
val expr: String
)
class GEArrayIndex(x:GE[Array[Double]], i:GE[Int])
{
def generate():GPUCode =
{
val (cx, ci) = (x.generate(),i.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr}[${cy.expr}]”)
}
}
GEPlus(GEArrayIndex(GEArrayVar(a),GEVar(i)),
GEArrayIndex(GEArrayVar(b),GEVar(i)) =>
“a[i] + b[i]”
class GEPlus(x:GE[Double], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, cy) = (x.generate(),y.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
class GEUpdate(x:GE[Double],i:GE[Int], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, ci, cy) = (x,i,u) map (_.generate)
GPUCode(defs = merge(cx.defs,cy.defs,ci.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
class GEForeach[T](x:GE[Array[Double]],
f:GE[Int] => GE[T] )
{
def generate():GPUCode =
{
val i = new GEIntVar(System.newName)
val (cx, ci, cfi) = (x,i,f(i)) map (_.generate)
val fName = System.newName
val fBody = s”””
__kernel void ${funName}(${genParamDefs(x)}) {
int ${i.name} = get_global_id(0)
${cfi.expr}
}
“””
GPUCode(
defs = merge(cx.defs,cy.defs,cci.defs,Map(fName,fBody)),
expr = s”${fname}(${genParams(x)})”)
}
}
31. trait GE[T]
case class GPUCode(
val defs: Map[String,String]
val expr: String
)
class GEArrayIndex(x:GE[Array[Double]], i:GE[Int])
{
def generate():GPUCode =
{
val (cx, ci) = (x.generate(),i.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr}[${cy.expr}]”)
}
}
class GEPlus(x:GE[Double], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, cy) = (x.generate(),y.generate())
GPUCode(defs = merge(cx.defs,cy.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
class GEUpdate(x:GE[Double],i:GE[Int], y:GE[Double])
{
def generate():GPUCode =
{
val (cx, ci, cy) = (x,i,u) map (_.generate)
GPUCode(defs = merge(cx.defs,cy.defs,ci.defs),
expo = s”(${cx.expr} + ${cy.expr})”)
}
}
class GEForeach[T](x:GE[Array[Double]],
f:GE[Int] => GE[T] )
{
def generate():GPUCode =
{
val i = new GEIntVar(System.newName)
val (cx, ci, cfi) = (x,i,f(i)) map (_.generate)
val fName = System.newName
val fBody = s”””
__kernel void ${funName}(${genParamDef(x)}) {
int ${i.name} = get_global_id(0)
${cfi.expr}
}
“””
GPUCode(
defs = merge(cx.defs,cy.defs,cci.defs,Map(fName,fBody)),
expr = s”${fname}($genParams(x))”)
}
}
for(i <- a.index) yield
c(i)=a(i)+b(i)
=>
defs: “””
__kernel void f1(__global double * a,
__global double * b,
__global double* c, int n) {
int i2 = get_global_id(0)
c[i] = a[i]+b[i]
}
32. Finally:
val a = GEArray[Double](“a”)
val b = GEArray[Double](“b”)
val c = GEArray[Double](“c”)
for( i<- a.index) {
c(i) = a(i) + b(i)
}
__kernel void f1(__global double*a,
__global double* b,
__global double* c,
int n) {
int i2 = get_global_id(0)
c[i] = a[i]+b[i]
}
GPUExpr(
)
// with macroses can be done in compile time
33. Complexity
Louse coupling (can be build independently)
Amount of shared infrastructure (duplication)
Amount of location informations.
34. Typeclasses:
typeclasses in Haskell
implicit type transformations in scala
concepts in C++14x (WS, not ISO)
traits in RUST
A B
B don’t care about AA don’t care about B & C
Crepresentation of A