Cool programming language features that you think should be more widely adopted

in BQN, an array language, most user functions are made of composing other functions together without using variables; this is called ‘tacit programming’ (or pointfree). another feature is that BQN has a large set of primitive functions, as opposed to a small set of derived and defined functions. most primitives have an ‘inverse’ defined, which does the opposite. the tacit programming allows you to easily automatically define inverses for user functions, in addition.

all of this comes together for a BQN ‘killer feature’ - Under. BQN has a combinator that takes two functions(fg), and an array. It applies f, then applies g, then applies the inverse of f, undoing it.

this, for instance, allows you to operate at a specific index or set of indexes on an array, operate under a reversed array, etc. it’s really cool, and of the array language world, only BQN has it fully integrated.

2 Likes

The Rust-style traits.

They essentially mark a struct as having an “ability” to do something. For example, a struct may have the Default trait implemented, meaning that you can get a default value from it. This by itself does not sound special (quite similar to interfaces), but you can write methods like this:

pub fn do_thingy<S: Into<String> + Display>(name: S) {
    let name: String = name.into();
    println!("{}", name);
}

This function parameter name accepts any type, as long as it has the Into and Display trait, meaning that it can seamlessly be converted into a string using the .into() method and that some form of text representation can be shown in formatted text.
Because of these restrictions (called “trait bounds”), this is entirely safe to do. If you want to do more with the parameter, you have to tighten the bound to contain traits for everything you intend to do with the value.

The amazing feature of this is that even the most obscure libraries, despite not having been updated in years, will simply…accept your struct, as long as it has the proper traits defined.

1 Like

symbol types like in lisp and ruby

they’re incredibly handy when you need an identifier that is also data, and can make metaprogramming smoother

1 Like

hey, K has those! and erlang too!

2 Likes

we don’t know either of those languages but nice

yea, it’s a nice functionality. K has them because it wants strings that aren’t also arrays, and because its lisp influenced

I think Erlang and Elixir’s implementation of the actor model of concurrency really makes a lot of distributed systems things much more trivial when compared to doing similar things in literally any other language.

Lisp is pretty famous for it’s “code = data” philosophy.

OCaml is super interesting to me because of how it mixes programming paradigms: it mostly encourages a functional and immutable style of programming but allows you to have data structures and code that are imperative when you want to be particular about the performance characteristics a specific part of a program.

Finally, Datafun is a super interesting language that is essentially datalog + functional programming. The idea that our everyday programming languages should be more like declarative query languages and that our query languages should perhaps be a bit more like our functional programming languages is facinating and there’s a great talk on this given at Strange Loop.

heres the datafun paper: https://www.cl.cam.ac.uk/~nk480/datafun.pdf

1 Like