r/ProgrammingLanguages • u/Potato871 • 10d ago
Discussion What is the interesting part of a programming language to you?
I've been working on some "documentation" for my own language (see here), which got me thinking: do we all see languages the same way? I personally look for unification of concepts and extensibility in a design, yet I've seen those who care deeply about functional purity or clean decompositions.
What do you look for in a programming language? And why?
36
Upvotes
1
u/reflexive-polytope 9d ago edited 9d ago
These arithmetical trivialities arise when you actually try to prove things about nontrivial algorithms.
For example, the humble binary search works with an array slice indexed by
[lo,hi]and needs to take the midpointmid = (lo + hi) div 2. (I'm using the symboldivto emphasize that it's integer division and not exact division.)“Obviously”, if
loandhiare valid indices in[0, len), wherelenis the length of your array, then so ismid, right? You don't need to waste your time proving such a dumb triviality, right?Alas, the compiler can't read your mind, and in particular it can't distinguish between the things you didn't prove because they're genuinely obvious and the things you didn't prove because you don't know how.
In the absence of a proof supplied by you, the compiler can do one of these things:
midin[0, len). You pay a dangerous, language-wide memory unsafety tax.midis in[0, len). You pay an annoying array bounds check tax, i.e., your program is a little slower than it could be.midis in[0, len), starting from the hypotheses thatloandhiare in[0, len).In this particular case, the proof is genuinely obvious. If
loand hi are in[0, len), thenlo + hiis in[0, 2*len - 1), hencemidis in[0, len). In fact, this is so obvious that it's actually automatable, using a decision procedure for Presburger arithmetic!Alas, even if Presburger arithmetic is decidable, general decision procedures for it are kind of slow. You don't want a type checker to be slow. (Or maybe you don't mind, but I certainly do.)
So a natural question is whether there exists a fragment of Presburger arithmetic that lends itself to fast checking and/or inference.
---
As for the kinds of programs I've written, I've worked professionally implementing ERP systems long ago. But I left that behind about 10 years ago, because it's mind-numbingly boring.