r/ProgrammingLanguages • u/Inconstant_Moo đ§ż Pipefish • Apr 28 '26
Hindsight languages
A thought experiment. What languages should they have been writing in the 60s, 70s, 80s, 90s? We can see their faults, in hindsight, and also we've had some really cool ideas since then --- but we can't answer this just by pointing to our shiny new modern languages and saying "they should have done it like that", because of compile times.
(E.g. Pipefish is meant to be for rapid iteration and livecoding, and also does a topological sort on everything at compile-time so you can do top-down declaration. Those wouldn't be compatible goals in the 1980s, I can get away with it now.)
So for example if we think of "a better C", are there any cool modern ideas they could and should have used back in 1972, had they known about them --- or should they just have tweaked the precedence slightly, found a less arcane way of describing types, and left it at that?
17
u/Inevitable-Ant1725 Apr 28 '26
I'm more interested in what ideas aren't popular now that could be useful, so what people tried but didn't catch on interests me more.
For instance constraint language, logic languages.
And also features that turned out to be more too much trouble if in some forms.
For instance image based environments like Smalltalk turn your coding environment into a mess where it's hard to extract your program from the environment, and can also be full of unfinished libraries you wish weren't loaded.
Or pure object oriented languages like Smalltalk and Ruby where when you want a new feature you have to patch it into Object. Another leaky abstraction mess.
Or in logic programming depth first search without tabling is complex not because it's powerful but because it isn't powerful enough.
But your example of sorting and a double pass compiler being too slow for the past doesn't impress me. Compilers with multiple passes were the norm before C and Pascal. And perhaps sorting could be handled efficiently with a clever implementation such as keeping a sorted database on disk and having a update routine for every compile, so you don't sort, you resort.
56
u/alphaglosined Apr 28 '26
Some obvious things that wouldn't have cost much:
10
u/Norphesius Apr 29 '26
I feel like Ada has a few ideas that really could've been used more in the languages that came after it, most impactful being the liberal creation of new types for very specific purposes.
In most statically typed languages when you declare a new type it has to be done at the top level of scope, visible everywhere, and usually is implicitly encouraged to be some "novel" type, and is almost always are comprised of some amount of other types (e.g. an RGB color struct is 3 ints). Ada type definitions can one liners, created inside of and local to a procedure, and don't have to be structurally backed. Stealing an example from the wikipedia page:
All of those types are basically ints, but they aren't compatible. You can't accidentally add a Day and a Month, and because its statically type checked, and you can't accidentally have Day_type that is 32, or Working_Hours of value 13.
It's so common for people to use an int or a string to represent some very specific kind of data, and then have that association bite them in the ass later. Array indices can be larger than the bounds of their array, or even a negative value. A string that's supposed to represent a set of values over only four latin, alphabetical characters has to have checks everywhere to make sure it never gets set to "", "abcdefg", "1 1", "đ©", or any of the basically infinite other invalid values. You can kinda get around this with the "parse, don't validate" approach by creating a type that handles all these checks on construction, but its cumbersome, and only helps at runtime. Even if you want to use a type in just one function, it still has to be declared at global scope for everyone to see and use, potentially far away from its sole usage.
Ada is 5 years older than C++, so it was definitely possible for other languages developed after it to adopt at least some of that style of type construction, and I think we could've potentially eliminated entire classes of bugs if we did.
5
u/rodrigopierre Apr 29 '26
I think a âbetter Câ in 1972 probably wouldnât have needed radically new ideas, just a few cleaner choices early on. Things like stronger type checking, safer defaults around memory, a clearer module system, and a less cryptic declaration syntax could have gone a long way without making compilers unrealistically complex for the hardware of that era.
Some concepts we treat as modernâalgebraic data types, pattern matching, or stronger immutabilityâalready had roots in academic languages back then, but many were likely too expensive or too unfamiliar for mainstream systems programming. The bigger missed opportunity was probably simplicity: keeping low-level control while removing some of Câs sharpest edges.
In hindsight, the best language for that period might have looked less like âmodern Rust in the 70sâ and more like âC designed with Pascalâs clarity and a bit more discipline around safety.â
10
u/WittyStick Apr 28 '26 edited Apr 28 '26
Some ideas that aren't exactly "modern" - some are as old, or older than C itself:
First class functions and closures. (Lisp)
__builtin_call_with_static_chainto pass context to a closure.First-class continuations. (Lisp)
call/ccis problematic - the more modern developments (30+ years) - delimited continuations, are less problematic.setjmp.The Numerical tower (Scheme - but derived from Lisp).
Dynamically scoped variables (Lisp)
thread_localvariables and a stack to try and emulate them.Garbage Collection (Lisp)
Could give several more examples from Lisp and its derivatives alone - arguably, much of the past 3+ decades of language development are efforts to make C-like languages more like Lisp.
4
u/manifoldjava Apr 29 '26
Don't forget a lot of the design decisions were a direct consequence of hardware of the time.
But for C/C++, I would vote for killing header files.
2
u/tobega Apr 29 '26
I don't know, FORTRAN was actually pretty awesome. When we got Unix computers we switched to C, but considered it to be trading down. But it was free while good FORTRAN compilers were expensive.
Dynamic memory management was a little hairy, you could declare a float array on the same memory as an int array, and had to remember that two ints were a float.
Should FORTRAN have had structured loops instead of GOTOs? Maybe. Code was managed as a stack of punch cards. Being able to replace or insert cards individually made sense and so did putting a line number on each card (imagine dropping the pile). To be able to insert, you typically incremented by ten. But that also meant it was hard to insert large blocks of code, typically you needed a goto and then a goto back.
The arithmetic if was interesting, where you branch on negative, zero or positive. I don't see that working without line numbers.
2
u/JeffD000 Squint Apr 29 '26
Algol68 was an extremely powerful language definition, with some incredibly bad compiler implementations. The GNU ga68 compiler is trying to fix that.
PS C was a "perfect" language for the timeframe. Computer hardware looked extremely different back then, and C could be ported quickly with a tiny memory footprint.
2
u/perlgeek Apr 29 '26
I'll take this discussion a bit sideways, and would like to state that some "modern" approaches are actually surprisingly old, and the world could have easily profited from them much earlier.
For example Erlang was first implemented in 1986 (!), and the BEAM virtual machine is from 1997.
Imagine if they had chosen a less obscure syntax, and Open-Sourced it much earlier. We could have had many more stable, rock-solid networking services much earlier.
Similarly, Eiffel had lots of cool ideas, but the main compiler and IDE were commercial for a long time, and so it didn't really get much traction.
1
u/AsIAm New Kind of Paper Apr 29 '26
SmallTalk should have slightly more C-like syntax and we would be in totally different world.
1
u/Ok_East_4017 May 02 '26
To be honest, pretty much all of zig, but at the minimum, instead of `type thing` it should be `thing: type` (much easier to parse), fat strings, null terminated has so many problems, error unions, null pointer safety by default, comptime, so pretty much what zig has done, I think
1
u/ultrasquid9 May 02 '26
B and C made a LOT of weird-ass syntactical decisions that have carried over to modern langauges. A few of these, in no particular order:
=for assignment has forced the use of==for equality, which is strange as in all other fields=indicates equality. I personally like<-for assignment, but:=is a common alternative that'd work well.&and*for "address-of" and "deref" respectively. Older languages (notably BCPL, the predecessor of B) typically used@for address-of and!for deref, which makes a lot more sense.!for "not" doesn't make sense either. If C had a dedicatedbooltype, they could use~for both logical and bitwise negation, which is a symbol with some precedence in logic notation.type functionName()should really have beenfun functionName() type(or some equivalent keyword, likefnorfunc). This'd make it far easier to grep for.-3
u/AnArmoredPony Apr 28 '26
java