r/ProgrammingLanguages • 🧿 Pipefish • 20d ago

Origins of programming languages

Pretty much all successful general-purpose programming languages were thought of by someone with a particular use-case in mind, or even just one particular use. They became successful because in trying to do whatever-it-was really well, the authors hit a larger target than they aimed for, and the more successful they became, the more this is true. Some examples, in alphabetical order:

  • C was designed solely to write UNIX in. This is the poster-child for "hit a bigger target than they intended". Besides C's other merits, it came out when (a) fine control over memory and clock was important even if you weren't doing systems programming (b) the users were the sort of l33t geeks who were quite happy to stay up 'til 4 am chugging Mountain Dew and swearing at malloc in exchange for an inner loop that goes brr.
  • The C++ origin story is that Bjarne Stroustrup was trying to model computers interacting in a network, and wrote a beautiful version in Simula which would take a hundred years to yield enough data; followed by an ugly version in C which was performant --- and wished, naturally, for the best of both worlds.
  • Erlang (the surprise sleeper hit of languages, now the basis for Elixir and Gleam) was designed to make Ericsson's telephone exchanges more stable.
  • We all know what JavaScript was designed for. It works for that, and has now been used for everything else. JavaScript is something of a special case of course, because of its association with web-browsers, but we should consider that for example Java applets failed at the same task, along with ActionScript, VBScript, JScript, Silverlight and NaCl.
  • Fortran was invented to do big math and science fast. Fortran would be supplanted by later languages (C, obviously) for everything but its core competence, but before then it was used for the first adventure game, for payroll software, chess engines, CAD, mainframe utilities, and self-hosting compilers.
  • Go has not unkindly been called "a DSL for writing servers".
  • Haskell was invented as a platform for mathematicians to experiment with lazy functional languages, which explains pretty much everything about it.
  • Lisp was invented after John McCarthy had been working for IBM on an extension of Fortran for list processing. The people at IBM were very happy with his work; he was frustrated. What he wanted, very reasonably, was to be able to automatically differentiate a function and then evaluate it, which sounds like exactly the sort of thing computers should be making easy for us. Fortran made it impossible despite its math orientation and despite the fact that McCarthy had been hired to write his own extensions to the language. The path to Lisp's homoiconicity is obvious; only slightly less obvious is why he reinvented flow-of-control as expressions. (Hint: think of differentiating a function defined by cases.)
  • Julia was made for math people to do math things in.
  • Lua was designed to solve the needs of scientists and engineers in Brazil's fossil fuel industry. (It became wedded to the games industry when someone at LucasFilms Games read about it in Dr Dobb's Journal and realized it was better than what they'd done in-house.)
  • ML was invented as the meta-language for a theorem-prover and people who used it spontaneously demanded the language without the theorem prover.
  • PHP, despite being objectively terrible, and coming from (and being aimed at) a dysfunctional "worse is better" culture, managed to spread like wildfire or a plague of poorly-designed locusts because its initials stood for Personal Home Page: it knew exactly what it was for.
  • Python was created because Guido van Rossum realized that a dynamic language with powers to do OS-level things could make his life much simpler: "I thought, well, oh man, if we just could program ABC instead of C, each of those utilities would be like half a page of code and I could write the entire suite of utilities in a couple of weeks instead of the years that it looked like it was going to take us."
  • Rust was famously inspired by a stuck elevator reminding Graydon Hoare of how terribly often things break, a rather more "meta" inspiration than for example C's origin story but still a moment that gave Rust a fixed purpose.

And then there's the obvious outliers:

  • Java's original use-case was embedding into consumer electronics, at which it failed, so to rescue the project it was pivoted into powering "applets" (embeddable client-side applications to be embedded in HTML), at which it failed, and then it became the giant among languages that it is today because Sun Microsystems spent a billion dollars on advertising to persuade Business Idiots that this was How To Do Business Properly. There should be a law against marketing technical solutions directly to management just like there are laws against marketing cigarettes to children but what do I know?
  • C# is Microsoft Java.
  • Kotlin is Java redesigned by people who hated Java but didn't hate it enough.

Some things worth noting:

There are two kinds of programming languages, those written for the author, and those written for other people. And in the second case, the other people are always dumber than the author, who is talking down to them. BASIC wasn't designed because Kemeny and Kurtz needed BASIC. BASIC was designed because Kemeny and Kurtz thought that liberal arts graduates needed BASIC, because what would make things simple for their muddled little heads is a language where all values are passed by mutating global state, which is like having a bicycle for beginners where instead of having training wheels you douse it in gasoline and set it on fire.

So you will notice that none of the things on the list that are used as easy languages for n00bs were designed for that. Python was designed for Guido van Rossum to do systems programming. Lua was designed for engineers and geophysicists. JS ... * gestures broadly at the internet *. They were designed, in fact, to be ergonomic for clever people to use, and it turns out that exactly the same things make languages ergonomic for everyone to use, and that more people are clever than was previously supposed, including liberal arts graduates.

(The fact that > 50% of indie language projects are "C/C++ but better" is because the indie langdevs are all trying to scratch the same itch, they're all trying to write the systems language that they wish they could code in. These are languages written for the authors, where the authors are all very similar people who want similar things.)

The other thing that leaps out at me from my list is that the "classic" functional languages, the Lisp and ML families and Haskell, all came from math people wanting to do hard math things as their paradigmatic use-case, and anyone wondering why functional programming hasn't conquered the world yet should think about that.

(I of course have been thinking about that, and although it is premature to put Pipefish in an article about successful languages, making an FPL for writing CRUD apps has produced an language that hits different, and which can in fact be used for all sorts of cool things besides that. Watch this space for the announcement of my front-end web framework.)

105 Upvotes

115 comments sorted by

View all comments

Show parent comment

1

u/EggplantExtra4946 19d ago

You still haven't told me your idea of a good programming language.

2

u/Inconstant_Moo 🧿 Pipefish 19d ago

They did: "One that lets me get things done."

So what is needed depends on what they're trying to get done.

There is no "good language" any more than there is a "good saw". They all have things in mind. By being good at some things, they are bad at others.

For example, my language, as I said, is for writing CRUD apps and middleware. The power and flexibility I get from dynamism must be weighed against the fact that I can do slightly less compile-time typechecking; the advantages of having a latticial type system and duck typing must be weighed against the disadvantages of not having an algebraic type system and exhaustive pattern matching; the price I pay for garbage collection is wasted clock cycles and nondeterministic execution, and the price I pay for not having low-level access is that no-one will be able to really fine-tune their inner loops to make them go brr (currently they can use Go FFI and when I add C FFI they can use that for brr if they want) ... but it will be better at the use-case I'm thinking of than your language. Because when Sam Whitecollar's boss says "Can you put a service on the hub that lets Chris and Alex from Accounting do <thing>", then I've spent five years trying to make that really easy and you haven't.

OTOH if we both wrote a chess engine and you used all your low-level fuckery to optimize it yours would be seven times faster than mine, so there's that.

1

u/EggplantExtra4946 19d ago edited 19d ago

They did: "One that lets me get things done."

That's not a spec nor a list of concreate features/characteristics. You're not even trying.

There is no "good language" any more than there is a "good saw". They all have things in mind. By being good at some things, they are bad at others.

The things is, there are features like dynamic types which have significantly more disadvantages than advantages. I've used scripting languages for a while, their "dynamicism" is suppose to make them expressive and easy to use but in my experience it's the opposite. When your program is < 500 LOCs you don't care about types but at certain point you do and you have to add explicit code do type checking code at runtime everywhere (at least to check function parameters) to make sure you won't do a stupid mistake. Things like a good module system, classes, sum types, polymorphic types, macros, continuations, embedded regexes is what makes a language actually expressive.

There are features that are really at odds with each others, for example having wrapping arithmetic vs arbitrary precision arithmetic, or manual memory managment vs GC. Each of those alternatives are useful in different situations, with an emphasis on different situation. There is no reason why a language couldn't do both but not at the same time. For example a few functions could use a GC, the rest would use manual memory management, or most integer variables would wrap but a select few would do arbitrary precision arithmetic because you specified their static type to do so.

The crucial thing is that all those choices are useful in different situations (except static vs dynamic types, dynamic types are useless are prevent all the other at-odds features to be integrated together). If the languages can't do all these things then you'll have to use 2 or more languages.

The power and flexibility I get from dynamism must be weighed against the fact that I can do slightly less compile-time typechecking

Wrong, you do SIGNIFICANTLY less compile-time type checkinkg.

the price I pay for not having low-level access is that no-one will be able to really fine-tune their inner loops to make them go brr

If all your language is good for is CRUD apps, of course no one will optimize inner loops. I also doubt the performance sensitive inner loops would be visible at all in such a language, they'd probably be in your runtime code or external libraries.

a chess engine

Funny, as if low level code were a rarity. It's the exact opposite. I don't care if 90% of softwares is not low level, that 90% software code will have 99% less users. Everybody use the same kernels, device divers, standard libraries, decompression libraries, process virtual machines and runtimes, video codecs, GUI toolkits, font libraries, game engines, emulators, maths libraries, network protocol libraries, html and json parsing libraries, etc... Billions of people and devices use those every day. Some random CRUD apps? Most of them will only be used by a few thousand people and not necessarily every day and most of their data processing work will be done by low level libraries.

Because when Sam Whitecollar's boss says "Can you put a service on the hub that lets Chris and Alex from Accounting do <thing>", then I've spent five years trying to make that really easy and you haven't.

Dynamic languages like yours don't have the monopoly on getting things done. A static language with good libraries, with a good module system and with macros will get more shit done than a dynamically typed language withtout macros and without a good module system. I don't care how much of a bully boss Sam Whitecollar is to you, the app he's asking you to make is a rain drop in an ocean of actually relevant software. Your software doesn't necessarily need to be fast, safe, extendable and refactorable but a very significant amount of software out there does.

2

u/anaseto 19d ago

When your program is < 500 LOCs you don't care about types but at certain point you do and you have to add explicit code do type checking code at runtime everywhere (at least to check function parameters) to make sure you won't do a stupid mistake.

Most scripts are under 500 LOCs in expressive scripting languages, though. And you don't need macros or powerful module systems for those. When writing a short script, being able to focus on writing executable code instead of writing declarations is pretty nice. But I agree about "embedded regexes" being helpful, even if that has not much to do with expressive static type systems (that feature is actually more common in dynamically typed languages, probably).

1

u/EggplantExtra4946 18d ago edited 18d ago

Most scripts are under 500 LOCs in expressive scripting languages, though. And you don't need macros or powerful module systems for those.

I never said you need macros and a good module system to write short script, you are mixing up 2 unrelated things I've said. Who care about frigging scripts, this is not the subject of the conversation. You need macros, module system, etc.. for writing complex programs. That's the thing that matters and for which we don't have very many languages, if at all.

When writing a short script, being able to focus on writing executable code instead of writing declarations is pretty nice.

  1. type inference exists
  2. Declaring a struct or sum type definition takes no work at all (you do it once and there is no boiler plate) and it will make it easier to work with the data. It's cleaner to use struct fields than a hashtable/dictionary with string keys, and matching a sum typed value is also cleaner than having a bespoke sum type where the type is a string that you compare for determining which sum type alternative it is.

I agree about "embedded regexes" being helpful, even if that has not much to do with expressive static type systems

I never said it has anything to do with static type system. However, there is no reason why a statically typed language couldn't have them. On the contrary, a static language could have a better implementation, it could implement a regex library using macros or a DSL and compile the regex at compile time instead of at runtime, it could be then further optimize it. If the metaprogramming features allow it, you could have other useful user defined DSLs and gain in expressivity.

1

u/anaseto 18d ago

Who care about frigging scripts, this is not the subject of the conversation.

It wasn't clear to me that complex programs were specifically the topic of the conversation, though even in that case, I'd say that except for projects with lots of inherent complexity, many programs can be divided into small independent ones (the unix way), so the remark still feels kinda on topic.

type inference exists

I know type inference exists (my first language was ocaml, I learnt some haskell later, and I used the coq/rocq proof assistant during my phd). And it never felt as nice for small programs as dynamic typing, and type inference is far from perfect (in particular, I don't even know of any statically-typed array languages with good type inference).

2

u/nzconstructionlawyer 19d ago

There are many types of programs where dynamic typing is imo far superior to static typing.

For example, as you admit, small programs!

You definitely do not need to add type checking code at runtime. That shows you dont really get how dynamic languages work. That's not how good code works in Python or Ruby or Perl.

0

u/EggplantExtra4946 18d ago edited 18d ago

There are many types of programs where dynamic typing is imo far superior to static typing.

For example, as you admit, small programs!

Wow, it is so superior that it's only good for small programs.

You definitely do not need to add type checking code at runtime. That shows you dont really get how dynamic languages work. That's not how good code works in Python or Ruby or Perl.

What the fuck does that mean, idiot? You need to shut the fuck up with you moronic takes, you don't know jack shit. I know fucking well how dynamic types and scripting languages work. That has nothing with the fact that when you want a scripting program or library to be reliable you put those checks in because the alternative is (maybe) getting a cryptic type error thrown or worse, having the implict conversion transform a string or array reference to a big number or 0 and get garbage data out. The goal is getting programs working correctly, the goal is not writing cutesy programs that fails the moment the input is invalid.

Only fucking amateurs like you do not care about correctness. Stop getting your opinions from bullshit meaningless mantras.

1

u/nzconstructionlawyer 18d ago

I didn't say it is only good for small programs you illiterate fuckwit. Imagine being so stupid you can't understand the concept of an example. Oh wait you don't have to use your imagination.

Again you clearly don't have any real experience with dynamic languages. Inserting type assertions all over the place makes no sense: they're duck typed. How would you assert that a function that indexes into its argument gets a valid argument? You can't just assert it's an array; lots of objects can be indexed into.

What is the difference between failing that assertion and failing the index operation itself? There isn't one, obviously. It's a total waste of time and overly constrains your code.

Do people write those checks? Yes. Why? Because like you they're type-brained.

I don't know what a "cryptic type error" is. Maybe you're just stupid and can't understand simple error messages?

As for implicit conversions, where did I say they were a good idea? Once again you've put your brain to work and come up short. Astonishing to confuse dynamic typing with weak typing on a compilers forum but I guess every bell curve needs a left-hand outlier and you're ours.

1

u/EggplantExtra4946 18d ago edited 18d ago

You still haven't told me your idea of a good programming language.

It's easy to say that my idea is not good when you don't have ideas yourself, nor precise criticism outside of "silly" or "it's just like Rust or C++".

Your can think that metaprogramming is bad but your arguments do not move me one bit (which I will never be because I have concrete use cases in mind, I'm not saying it's good because it's trendy or anything) and despite asking you to develop, you haven't told me it is bad but good Lisp, outside of "in Lisp they do metaprogramming on lists" and I don't see how it's any kind of argument.

1

u/nzconstructionlawyer 18d ago

I already explained why metaprogramming is generally bad, and code generators are generally better:

Code generators are easier to understand because they're just ordinary programs. I like ordinary programs: I can run them in a debugger, I can see their outputs, I can ltrace them, I can step through them, I can strace them.

I didn't say explicitly, but the comparison was to metaprogramming which generally involves writing in a special sublanguage of the main language which is less expressive and runs inside the compiler. This is harder or impossible to run in a debugger or under various other tools like strace, ltrace, etc. These programs generally can't access the file system or the network. A code generator is just a normal program which means it's exactly what the programming language was designed for writing in the first place and you can use all your normal tools to debug and improve it.

The contrast with Lisp is that in Lisp you do just write normal Lisp code to manipulate lists because Lisp is good at manipulating lists. Macros in lisp are just ordinary code. So you don't have any of these issues. They are automatically just normal programming. That is rare and is why Lisp is an exception.

You still haven't told me your idea of a good programming language.

I can list off things that are important but none of them really capture the essence which is: it should be good for getting things done. I value practicality over all else.

For example, a good programming language can be run in a debugger. Is this really a language property? Hardly, it's a tooling issue. The simpler the language, the easier it is to build this tooling. But, some simple languages never develop good tools and some very complex languages have good tools. Some languages have been around for yonks but still have bad tools, and some come with good tools from day 1. So tooling is more about culture than anything else, but you can make tooling easier or harder to build with language design.

Another example: a good programming language compiles very quickly. Is this a language property? Sort of. You can create languages that are very difficult to compile quickly in the general case, like Rust or C++. But you can write code that compiles fast in Rust and C++ and you can write much faster compilers than the ones that are popular. Part of the language design of Rust and C++ encourages people to write code that is hard to compile. But part of that is also the language culture. On the other hand, you can have very simple languages that should be fast to compile, and the most popular compilers for them are still slow and bad. For example, Zig for a long time had bad compile times despite in theory being reasonably easy to compile, because it used LLVM. So again, it's not really a language property, it's more of an implementation philosophy, but you can certainly make life easier or harder for the tool designer as the language designer.

1

u/EggplantExtra4946 18d ago edited 17d ago

I already explained why metaprogramming is generally bad, and code generators are generally better:

Let's be clear: bad for you. You think what you want but it's not a general fact. And given that you are not all in on it, the metaprogramming patterns you want to use and are going to be less sophisticated than the people that want to do more with them, like me.

For instance, there is a lot to be done with conditional compilation alone, where you select different code fragments depending on the value of compile time parameters, which leads to the problem that not all combinations of compile time parameters produce valid code, a valid function definition for example. You have to validate all valid combinations and this kind of thing is difficult to express in any paradigm that isn't the logic paradigm, like Datalog or Prolog.

code generators

Compile time code generation IS metaprogramming. The difference is that it is a lot more readable when the languages has a syntax and an evaluation model for it, and it's also less error prone when it comes to problems like macro hygiene. There is also the opportunity to add more safety checks. Imperative/functional programming is not necesarily the only paradigm I want to use for metaprogramming, see paragraph above. I'd also like to use macro expansion and DSLs.

I like ordinary programs: I can run them in a debugger

Compile time code execution and macros are programs and you can run them through the debugger of the language that have them. You could also insert print statements to dump the AST you're generating is probably going to be good enough, not reason why you couldn't. Secondly, this is sounds ridiculous to me because I find debuggers hard to use, hard to gain insight about a normal running program, and it's not going to be better with metaprogramming. Also, things like macro expansion can have special debugging utilities like expanding one macro at a time which will give you good feedback.

The contrast with Lisp is that in Lisp you do just write normal Lisp code to manipulate lists because Lisp is good at manipulating lists.

I think Lisp is horrible to manipulate lisp. For one thing I'd want to maniuplate arrays with indexes and also Lisp programs are too much unreadable, especially programs that manipulate lists with several levels of indentations of (caadar .. ).

It also boggle my mind that Lisp tards like you can't imagine something better. There is absolutely no reason why you couldn't quote and quasiquote code with a C-like syntax. Also, if I'm going to traverse or modify an AST, I'd prefer if it had a proper AST type (a sum types of structs) than a linked list of symbols that don't mean anything themselves. It's also less error prone.

For example, a good programming language can be run in a debugger. Is this really a language property? Hardly, it's a tooling issue. The simpler the language, the easier it is to build this tooling.

Nope it's not a language property. I also want good tooling and in fact it's another reason why I want powerful programming features. For example, if you can traverse the AST and insert code arbitrarily, you could insert print statements more easily than you could in a debugger. You could easil insert code at the entry or exit of certain functions, or before/after writing to a specific struct field of an object on the heap, etc.. It doesn't necessarily replace the need of a debugger but it would an excellemt complementary tool. You could also do the same thing for profiling reasons. Why bother with valgrind when you have that? It's going to run much faster.

Another example: a good programming language compiles very quickly. Is this a language property?

My view is that making language compile fast should mostly not be a language spec constraint. Rust is slow but mostly because of the LLVM implementation as I understand. C++ is slow because the semantics are retarded, the fact that it must recompile the same headers and whatever it is doing with templates. Lisp macro expansion is fast, so there is no reason why things like templetes but with better semantics coulnd't be fast too.

you can certainly make life easier or harder for the tool designer as the language designer.

Also about the tools and metaprogramming, you could allow the user to modify the CFG, or even the SSA IR. It could be more approprite for tools like Valgrind than modifying the AST.

1

u/Inconstant_Moo 🧿 Pipefish 18d ago

That's not a spec nor a list of concrete features/characteristics. You're not even trying.

That's because those things would depend on what one is trying to get done.

Wrong, you do SIGNIFICANTLY less compile-time type checkinkg.

You don't know actually know how Pipefish's type system works or what the type checker does.

If all your language is good for is CRUD apps

It isn't. It's good for lots of other things too. But it is really good for CRUD apps.

Funny, as if low level code were a rarity. It's the exact opposite. I don't care if 90% of softwares is not low level, that 90% software code will have 99% less users. Everybody use the same kernels, device divers, standard libraries, decompression libraries, process virtual machines and runtimes, video codecs, GUI toolkits, font libraries, game engines, emulators, maths libraries, network protocol libraries, html and json parsing libraries, etc...

And 1% of SWEs will be hired to write them. The others need something else. Yes, everyone using Python is also using C. Bully for C, but they are also in a more meaningful sense using Python.

Dynamic languages like yours don't have the monopoly on getting things done.

Right. mine is better for getting some things done, such as > 80% of what people actually do. Any language which is worse than Pipefish at that is not a universally superior language, and so the features I left out of Pipefish are not "indispensable features a modern PL should have". They're features your language should have.