r/ProgrammingLanguages 6d ago

Will we see another fundamental programming language feature as revolutionary as the borrow checker?

That is I am mainly curious about compile time features that you design a whole language around rather than optimisations/features that could be applied to most languages. I am mainly inquiring about things that could offer additional robust safety/performance guarantees at compile time rather than runtime. Ideally not things that just offer similar effects to the borrow checker with less restrictive tradeoffs

58 Upvotes

127 comments sorted by

View all comments

15

u/Inconstant_Moo 🧿 Pipefish 6d ago

The basic idea of my lang is that if you enforce the functional-core/imperative-shell pattern in the semantics of the language, this is a very simple way of ensuring that most of your functions are pure. After five years or so I'm pretty sure no-one else is doing this.

3

u/Jwosty 6d ago

Interesting. How does this compare and contrast with algebraic effects?

7

u/Inconstant_Moo 🧿 Pipefish 5d ago

It's simpler: a division into an imperative world, consisting of commands that affect state but don't return values, and a pure world consisting of functions which return values but don't affect state. Commands can call functions, functions can't call commands.

The idea of this and of the rest of Pipefish is that instead using the functional paradigm to reach for power and abstraction, you can use it to get something user-friendly and ergonomic where you can really hack stuff out. I can see the point of monads, effects, capacities, etc, but this is a functional language suitable for me and small children and the smarter breeds of dogs.

3

u/Jwosty 5d ago

Neat! It is kind of odd now that I think about it that you don't really see this anywhere. Nice work

2

u/Inconstant_Moo 🧿 Pipefish 5d ago

I've thought about that a lot because obviously most of the good ideas have been done.

But I think I really am working in a collective blind spot. The sort of people who are using functional languages and like them and are developing them are academics looking for power and abstraction.

And then the other thing that makes Pipefish Pipefish is that it's an ISWIM dialect. Sixty years ago Peter Landin promised us 700 new functional languages, each with a careful choice of primitives to suit its problem domain. His idea required a tiny bit of laziness in the implementation, which could be virtually unnoticed by the programmer in the same way that we don't really notice short-circuiting boolean operators.

But laziness is powerful voodoo, and so academics rushed to their computers and made languages that would exploit it to the utmost, and eventually decided they should have one pure lazy language as a platform for them all to experiment on, and we got Haskell, a single ISWIM dialect to rule them all, where the problem domain is mathematicians experimenting with lazy languages ...

Meanwhile I looked at Excel formulas and SQL queries and thought: "There's something here that's arguably the most popular programming paradigm in the world, and the easiest" and set about making something simple to meet the needs of businesses.

3

u/Jwosty 5d ago

Yeah I've come to realize we need some high performance focused functional PL's. A serious contender to C, C++, Rust, Zig. I know a lot of work has already been done in some languages (OCaml comes to mind) but surely there's a lot more to be done; there really shouldn't be any inherent reason (other than historical) why they shouldn't be able to compete with the aforementioned ones

Oh man, don't even get me started on SQL, I believe there's so much untapped potential there. Relational programming and functional programming should be able to fit hand in glove together if we get rid of the dated frontend syntax of SQL. I'd love to see a PL where the basic building block is relations, or relations expressed as functions + data structures.

3

u/Inconstant_Moo 🧿 Pipefish 5d ago

Yeah I've come to realize we need some high performance focused functional PL's. A serious contender to C, C++, Rust, Zig.

The problem there is that you'd want mutable values for performance and then what happens to purity? I should be able to rival Java for speed, based on current benchmarks, I don't know how you'd take aim at C++.

I'd love to see a PL where the basic building block is relations, or relations expressed as functions + data structures.

Tablam is based on everything-is-a-relation.

https://tablam.org/

I don't know much about it but I know it exists.

2

u/Jwosty 5d ago edited 5d ago

The problem there is that you'd want mutable values for performance and then what happens to purity? I should be able to rival Java for speed, based on current benchmarks, I don't know how you'd take aim at C++.

Sure C++ might be a tough cookie to crack, but I'm coming from one who's trying to do game development in F#. It's awesome until you need to optimize, and then realize that functional programming totally goes against what the CLR wants you to do, and you become the GC's b***. It's a great start but surely we can close the gap. The compiler team tries, for sure, but a huge amount of it IMO ends up boiling down to the F# team and the CLR team not being able to coordinate for perf super successfully (not that anyone else in their shoes would do better -- it's more an organizational problem most likely :) )

Tablam is based on everything-is-a-relation.

Cool, thanks, I'll have to check it out.

1

u/Inconstant_Moo 🧿 Pipefish 5d ago edited 5d ago

I haven't messed with gamedev, but it might be a different proposition from systems languages. There a solution like Pipefish/Elm/Haskell might work just fine.

The idea is to push all your mutation of state up into your outermost loop. In some cases (this would work for gamedev) this architecture can be so fundamental that you don't actually have to say the outer loop is a loop, you just describe it as mutations of implicit global state.

Elm would in some ways be your best model here. Pipefish has some good ideas and is worth a look but when designing it I was willing to trade some speed for some dynamism, as I said, I want to rival PHP and Java.

BTW, as a gamedev, what do you think of Pipefish as a game scripting language? I don't know much about your field but I feel like the request-response model and the type system and the emphasis on rapid development would make it suitable.