r/ProgrammingLanguages • • Sep 01 '26

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

111 comments sorted by

View all comments

Show parent comment

1

u/reflexive-polytope Sep 02 '26

As a matter of fact, I'm not making that many subjective calls.

Subjective calls are what an engineer does when he or she needs to plug a hole left by his or her ignorance.

In my experience, it's best to let algebra and universal properties make the calls for you. It leads to a more coherent design. But you need to know the relevant algebra first.

1

u/balefrost Sep 03 '26

As you said earlier.

without sacrificing pleasant properties of a general-purpose language

Those "pleasant" properties are entirely subjective. My point is that what to include and what to exclude is a subjective judgement call.

That choice of word wasn't meant as a pejorative. If you prefer, pretend I said that language designers have to exercise their sense of "good taste" in designing their language.

1

u/reflexive-polytope Sep 03 '26

I don't know about you, but I don't want to spend my life manually proving all sorts of arithmetic trivialities (e.g., “is this a complete set of residues modulo n?”) just because the compiler wasn't designed to infer them.

1

u/Potato871 Sep 03 '26

I'm curious what kind of programs you write, I don't think I ever run into situations where I want to prove mathematical facts like that.
I'm not sure if it's a "what domain are you in" thing, or a "how far along are you with programming" thing.

1

u/reflexive-polytope Sep 03 '26 edited Sep 03 '26

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 midpoint mid = (lo + hi) div 2. (I'm using the symbol div to emphasize that it's integer division and not exact division.)

“Obviously”, if lo and hi are valid indices in [0, len), where len is the length of your array, then so is mid, 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:

  • Never bother check that mid in [0, len). You pay a dangerous, language-wide memory unsafety tax.
  • Check at runtime that mid is in [0, len). You pay an annoying array bounds check tax, i.e., your program is a little slower than it could be.
  • Attempt to deduce on its own that mid is in [0, len), starting from the hypotheses that lo and hi are in [0, len).

In this particular case, the proof is genuinely obvious. If lo and hi are in [0, len), then lo + hi is in [0, 2*len - 1), hence mid is 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.

1

u/Potato871 Sep 03 '26

Ah, I've dipped my toes into ERP for one of my clients... I know what you mean by mind-numbing.

And I think I see why I haven't run up against this yet, I haven't really reached the stage where my main concern is optimizing a program, a lot of it is what program should I even be writing.
Like I recently moved from a stateful Unit-per-user model for my server, to a stateless Unit-serves-any-request model (which is why I can host and post my own website to Reddit now). I dipped my toes into optimizing the memory profile of the Unit-per-user model, but concluded that just making it stateless was the correct move.
Pretty much every time I've been faced with a problem the answer has been "change the cost model" not "optimize the current costs", but at some point you do just have to optimize, and at that point, I'll probably start caring about this kind of inference.
For me now, "the program crashes" means Hazel (my process supervisor) just restarts it, and it being slow is a question of how slow, if its so slow it impacts user experience thats bad, if not I just leave it.
Though I've not been doing this for 10 years yet.

1

u/reflexive-polytope Sep 03 '26

It just dawned upon my mind.

SIMD and Duff's device are all about systematic exploitation of complete sets of residues modulo small powers of 2, like 4, 8, 16.

1

u/balefrost Sep 03 '26

Did you reply to the wrong person? I don't see how that is related to what I was saying.

1

u/reflexive-polytope Sep 03 '26

No, my reply was very much to you.

Not proving obvious trivialities is a very important part of a pleasant programming experience.

1

u/balefrost Sep 03 '26

OK well I'm glad that we can agree that programming language designers use their own personal sense of taste to decide what to put in their language!

1

u/reflexive-polytope Sep 03 '26

It's not a matter of "taste". It's a matter of human factors, as in the subfield of industrial engineering.

1

u/balefrost Sep 03 '26

Look, I was originally trying to give you credit for making an insightful observation. You seem to be arguing against the compliment.

So either you're right and my original judgement was misplaced, or you don't recognize your own wisdom.

In any case, have a great night.