Table of Contents for Programming Languages: a survey
Haskell
Because it is so well-liked, Haskell gets its own chapter.
See chapter on chapter on Haskell
Scala
Scala is a multiparadigm language, both OOP and functional.
Tours and tutorials:
Cons:
- big language
- slow compilation
- culture of punctuation-based DSLs can make readability hard
Best practices:
Tutorials and books:
Comparisons:
Features:
- higher-kinded types
- implicits
- " Scala is completely interoperable with Java (and with some qualifications also to C#). A Scala component can: • access all methods and fields of a Java component, • create instances of Java classes, • inherit from Java classes and implement Java interfaces, • be itself instantiated and called from a Java component. " -- [1]
- "Scala’s concepts subsume SML modules. More precisely, (generative) SML modules can be encoded inνObj,but notvice versa." -- [2]
- Abstract Types " Here is a type of “cells” using object-oriented abstraction. trait AbsCell? { type T val init: T private var value: T = init def get: T = value def set(x: T): Unit = { value = x } }
The AbsCell? class has an abstract type member T and an abstract value member init. Instances of that class can be created by implementing these abstract members with concrete definitions.
val cell = new AbsCell? { type T = Int; val init = 1 } cell.set(cell.get * 2)
The type of cell is AbsCell? { type T = Int }.
Path-dependent Types: You can also use AbsCell? without knowing the specific cell type:
def reset(c: AbsCell?): Unit = c.set(c.init);
Why does this work?
- c.init has type c.T
- The method c.set has type c.T => Unit.
- So the formal parameter type and the argument type coincide.
- c.T is an instance of a path-dependent type.
In general, such a type has the form x0...xn.t, where
- x0 is an immutable value
- x1, ..., xn are immutable fields, and
- t is a type member of xn " -- [3]
Some notes on Scala 3 features:
example of scala 3 'givens' which are (part of) the successor to scala implicits:
https://alvinalexander.com/source-code/scala-3-dotty-complete-givens-using-example/
so afaict these are just similar to Haskell typeclass instances. I guess what scala is really contributing is that i think these are lexically scoped, rather than globals like (i think) in Haskell.
Extensions:
Retrospectives:
Implementations:
Opinions:
- "Scala is the single best language I've ever used. And I don't even use all of it. I just use the subset of Scala that is Everything Java Should Have Been. It has lambdas and closures. It has just enough type inference. It has mutability control for slots. It has object orientation and case-classes/pattern-matching and type-classes via implicit parameters. Scala lets me figure out what language paradigm I need to Get Stuff Done. It's the Python of statically-typed languages, and it interoperates with a vast outside ecosystem to boot." -- [5]
- "I do want a functional language like Scala, because I believe that school represents a better design. That school of language design saves me the headache of null pointers; it helps me write unit tests with QuickCheck?; it allows me to define custom generic collections; it places emphasis on having a fast GC; it features monadic style to help with error handling." -- [6]
- [7]
- "...problem with all of these languages is that they are still obscure compared to everything else, with all that this entails: It's harder to find developers...Scala has some good parts, but is overdesigned and way too complex, in my opinion. Last I checked, performance was worse Java. It also runs on the JVM, which means its memory usage is inherently inefficient." -- [8]
- "Scala has always seemed like an abomination to me, but I haven't used it enough." -- [9]
- http://grundlefleck.github.io/2013/06/23/using-scala-will-make-you-less-productive.html
- "Scala's the only one of these three languages with any adoption right now. Groovy is virtually only used in its original dynamic mode from 2003 for things like scripting and Gradle build files, and very few people use the @CompileStatic? mode introduced in 2012. Kotlin 1.0 has just been released, was subjected to stringent QA, and I expect JetBrains? to use it more and more in its own products like IntelliJ?, so it's a good bet it will become more popular with developers. So I'd say use Scala and Kotlin if you need static typing. Clojure, though it doesn't have static typing, has other features like syntactic macros for terseness, default immutability, and concurrency that would recommend it in many situations." [10]