Great programming language features, other languages should steal?
You cannot be fluent in all programming languages. But this also makes you blind for language features a particular language really got right, or killer libraries that are just amazing. Which are these widely unknown features, that you only get to know, when working with a language and its ecosystem?
Example: I'm coming from Scala. Starting to develop a Flutter app with Dart, made me realize how great and safe the serialization ecosystem in Scala is. You can serialize types (and type hierarchies) with a convenient syntax that is completely decoupled from the type itself, while high-performance serialization code is generated at compile-time via macros. Libraries include: https://circe.github.io/circe/ https://github.com/suzaku-io/boopickle
It's more of a paradigm than a feature but, multiple dispatch à la Julia. One of the creators of Julia makes a strong case that it is the key to libraries that "compose" without being aware of one another:
https://www.youtube.com/watch?v=kc9HwsxE1OY
Every language should have robust, standard collections functions like Python does. Once you start doing quick things with lists like the zip function, or list comprehensions, it's hard to go back.
This is pretty minor but I like how in Rust you can use constructs like if-statements and match-statements as expressions. For example:
let foo = if some_condition {
"condition is true"
} else {
"condition is false"
};
let bar = match x {
0 => "string",
1 => "another string",
_ => "default"
};
It's not super significant but I think it's an elegant syntactic feature.
1. Python's list slicing and indexing is the perfect mix of simplicity, intuition and power. It is surprising how few languages have similar implementations.
2. Currying like in Haskell.
Golang, avoid this idea in the service of software engineering.
Go tries to be a syntax minimalist so that the writers can make what's there the best rather than building the world of fancy new PL features. It also means there are fewer days of doing the same thing and most people's code looks the same. <- this is such a difference maker
Python data structure manipulation/comprehensions. I realize there's some overlap with other languages, but this to me is Python's 'killer' feature.
1. Pattern matching with destructuring a la scala, rust, ocaml, etc.
2. scoped threading a la kotlin and by using certain libraries, rust to a degree.
3. structs / records (i feel bad putting this since every language but java seems to have it).
4. macros of some kind
5. type inference
6. enums a la rust / sealed types in kotlin which are needed for pattern matching afaik
1. I like Erlang's Supervisor. If Go's goroutine has a unique ID, I think it can steal that design.
2. There was one new language that I don't remember the name, its data structures automatically turned to thread-safe upon concurrent access. That's smart. I wish all languages do that. Less data structure names people have to remember.
3. The compiler can cross-compiles to many different architectures similar to Go or Zig. This makes deployment story much simpler.
4. The compiler produces single binary by default. This also makes deployment story simpler.
5. This is year 2020. Every language must have an event loop so that they can have async I/O routines. Preferably in the form of CSP (green threads + channels).
As you can see I care about the ergonomics and tooling outside the language itself.
I like how Erlang handles binary and bitstring data. Extremely useful if you're doing any sort of protocol implementation.
I really like the trait/struct/enum model of programming that you find in Rust. I'm a quant and I do a lot of higher math, and the trait method of programming is very very similar to how you might construct algebraic structure in the set=>group=>field etc way.
* Pattern matching with totality checking. Warn us if a cased is missed.
* Higher-kinded types. Can a List and a Stream both be considered a T ?* Differentiate between functions with and without effects.
Kotlin Extension Functions
https://kotlinlang.org/docs/reference/extensions.html
I personally love it for when I have different data classes for different layers of the application (REST objects vs. controller level objects vs. Database objects) and need to convert between them. I simply just add an extension to one layer's data object to convert it to the other layer's type
Goal-directed evaluation from Icon. Makes generators composable.
R6rs scheme's (or even better Racket's) macro system. Recently similar systems have been making their way into other languages, but the AST-like syntax of lisps make it a fair bit easier to use.
Other than that? Delimited continuations. Guile-fibers, a parallel concurrent ML (which I would describe as a generalisation of go's concurrency model) for guile scheme is implemented using them as a scheme-only library. No low level voodoo. Just straight forward scheme.
Factor allows almost any special character in word (function) names. It is incredibly useful when you get the hang of it. I would love to have it in other languages.
E.g. is_prime(1234) => prime?(1234), append_inplace(l, e) => append!(l, e), array_equal(a, b) => array=(a, b), midi_to_mp3(a) => midi>mp3(a), reciprocal(a) => ^-1(a)
Lisp can do some of it but not "()" or (I think) "`';"
Nullability built into the type system like Kotlin. one main difference between kotlin optionals and swift options (for example) is that Kotlin nullability is enforced during compile time.
I'm not aware of many languages which do that other than Kotlin.
JavaScript’s object destructuring
Golang's level of boringness. It's just boring enough to still be useful. Often it's easy to understand random code and write "reasonable" code.
My ideal language is something like F# but with HKTs, trait, macros, union types (without discriminator), basically most features dotty aka scala 3 introduced.
algebraic data types and parametric polymorphism, so you can define an option type for computations that fails and get rid of nulls