Edit: This list is now maintained in the rust-anthology repo.
#Intro
Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3
Kotlin project website is at kotlin.jetbrains.org.
All the codes here can be copied and run on Kotlin online editor.
Let's get started.
This benchmark has been misleading for a while. It was originally made to demonstrate how JIT compilers can do all sorts of crazy stuff to your code - especially LuaJIT - and was meant to be a starting point of discussion about what exactly LuaJIT does and how.
As a result, its not indicative of what its performance may be on more realistic data. Differences can be expected because
- the text will not consist of hard-coded constants
# Download latest archlinux bootstrap package, see https://www.archlinux.org/download/ | |
wget 'ftp://ftp.nluug.nl/pub/os/Linux/distr/archlinux/iso/latest/archlinux-bootstrap-*-x86_64.tar.gz' | |
# Make sure you'll have enough entropy for pacman-key later. | |
apt-get install haveged | |
# Install the arch bootstrap image in a tmpfs. | |
mount -t tmpfs none /mnt | |
cd /mnt | |
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1 |
object Example { | |
import cats._, implicits._ | |
import cats.effect._ | |
import fs2._ | |
import scala.concurrent.ExecutionContext | |
// start N streams concurrently, and stream their results in order | |
// e.g. download a file from a server in N parts concurrently, and stream it | |
abstract class Channel[F[_], A] { |
import cats.Monad | |
import cats.effect.concurrent.{Ref, Semaphore} | |
import cats.effect.{Concurrent, Resource} | |
import cats.implicits._ | |
import fs2.{Pipe, Stream} | |
import fs2.concurrent.{NoneTerminatedQueue, Queue} | |
/** Represents the ability to enqueue keyed items into a stream of queues that emits homogenous keyed streams. | |
* |
This note outlines a principled way to meta-programming in Scala. It tries to combine the best ideas from LMS and Scala macros in a minimalistic design.
-
LMS: Types matter. Inputs, outputs and transformations should all be statically typed.
-
Macros: Quotations are ultimately more easy to deal with than implicit-based type-lifting
-
LMS: Some of the most interesting and powerful applications of meta-programming
Java 8 introduced lambdas to the Java language. While the design choices differ in many regards from Scala's functions, the underlying mechanics used to represent Java lambdas is flexible enough to be used as a target for the Scala compiler.
Java does not have canonical heirarchy of generic function types (ala scala.FunctionN
), but instead allows a lambda to be used as a shorthand for an anonymous implementation of an Functional Interface
Here's an example of creating a predicate that closes over one value: