Top
Best
New

Posted by helloplanets 17 hours ago

The seven programming ur-languages (2022)(madhadron.com)
279 points | 105 comments
Syzygies 4 hours ago|
I recently revisited a language comparison project, a specific benchmark tallying the cycle decompositions in parallel of the 3,715,891,200 signed permutations on 10 letters. I kept a dozen languages as finalists, different philosophies but all choices I could imagine making for my research programming. Rather than "ur" I was looking for best modern realizations of various paradigms. And while I measured performance I also considered ease of AI help, and my willingness to review and think in the code. I worked hard to optimize each language, a form of tourism made possible by AI.

The results surprised me:

             F#  100    19.17s  ±0.04s
            C++   96    19.92s  ±0.13s
           Rust   95    20.20s  ±0.38s
         Kotlin   89    21.51s  ±0.04s
          Scala   88    21.68s  ±0.04s
  Kotlin-native   81    23.69s  ±0.11s
   Scala-native   77    24.72s  ±0.03s
            Nim   69    27.92s  ±0.04s
          Julia   63    30.54s  ±0.08s
          Swift   52    36.86s  ±0.03s
          Ocaml   47    41.10s  ±0.10s
        Haskell   40    47.94s  ±0.06s
           Chez   39    49.46s  ±0.04s
           Lean   10   198.63s  ±1.02s
https://github.com/Syzygies/Compare
LeCompteSftware 1 hour ago|
Naively this is quite surprising, but the devil is in the details. With the exception of Lean I'd point out they're all fairly close: Chez being 2.5x slower than C++ is not ignorable but it's also quite good for a dynamically-typed JITted language[1]. And I'm not surprised that F# does so well at this particular task. Without looking into it more closely, this seems to be a story about F# on.NET Core having the most mature and painless out-of-the-box parallelism of these languages. I assume this is elapsed time, it would be interesting to see a breakdown of CPU time.

I don't think these results are quite comparable because of slightly differing parallelism strategies; I'd expect the F# implementation of just spinning off threads to be more a little more performant than a Rayon parallel iterator, which presumably has some overhead. But that really just shows how hard it is to do a cross-language comparison; Rust and C++ can certainly be made faster than the F# code by carefully manipulating a ton of low-level OS concurrency primitives. This would arguably also be little misleading. Likewise C and Haskell have good C FFI; does that count? It's a tricky and highly qualitative analysis.

[1] FYI, one possible performance improvement with the Chez code is keeping the permutations in fxvectors and replace math operations with the fixnum-specific equivalent - this tells the compiler/interpreter that the data are guaranteed to be machine integers rather than bigints, so they aren't boxed/unboxed. I am not sure without running it myself, but there seems to be avoidable allocations in the Chez implementation. https://cisco.github.io/ChezScheme/csug/objects.html#./objec...

remywang 9 hours ago||
We got to build mini versions of the first 4 languages (imperative, lisp, ML, Smalltalk) in the PL course at tufts which is now published as a textbook [1]. There used to be a prolog part that sadly got cut.

[1]: https://www.cambridge.org/ir/universitypress/subjects/comput...

Chirael 7 hours ago|
Maybe a version with the Prolog part could show up on the Internet Archive?
remywang 5 hours ago||
Here’s the accompanying code on github but we never got to that part in class: https://github.com/nrnrnr/build-prove-compare-student-code
steve_gh 11 hours ago||
One correction I'd make to the article's taxonomy: Ruby is an object oriented language not an Algol. Its inspiration is Smalltalk, and much of the standard library naming comes from that route (eg collect rather than map).

Ruby is object oriented from the ground up. Everything (and I do mean everything) is an object, and method call is conceived as passing messages to objects.

While Ruby is most often compared to Python (an Algol), they come from very different evolutionary routes, and have converged towards the same point in the ecosystem. I think of Ruby as a cuddly Alpaca compared to Python's spitting camel.

pjmlp 8 hours ago||
Since Python introduced new style classes, it also became a pure OOP language, even though it might not look like it at "Hello World" level, all primitive types have become objects as well.

I love to point this out to OOP haters,

    >>> type(42)
    <class 'int'>

    >>> dir(42)
    ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'is_integer', 'numerator', 'real', 'to_bytes']
the__alchemist 1 hour ago|||
I have found the definition of OOP to be fuzzy. For example, I don't see why having methods would make a data type object oriented. I associate OOP with factories, inheritance, using classes in places that might be functions otherwise, and similar abstractions.

Perhaps this is the counterfactual: I program in Python regularly, but don't program in an OOP style; I use dataclasses and enums as the basis, in a way similar to Rust, which by some definitions can't do OOP. So, if Rust can't do OOP (assumption) and I can write Python and Rust with equivalent structure (Assumption), does that mean Python isn't strictly OOP?

thesuperbigfrog 54 minutes ago||
> if Rust can't do OOP (assumption)

Rust handles basic OOP, but not all of the characteristics seen in C++ or Java:

https://doc.rust-lang.org/book/ch18-01-what-is-oo.html

ang_cire 7 hours ago||||
This is very cool, and I did not know this. Thank you!

I wonder if my formal university python training predated this change (~2010), or if the professors were themselves unaware of this.

pjmlp 7 hours ago||
They were unaware of it, or unwilling to talk about it, article from 2002, about changes introduced in 2001

https://gnosis.cx/publish/programming/metaclass_1.html

https://www.python.org/download/releases/2.2/descrintro/

arijun 7 hours ago|||
> I love to point this out to OOP haters

That seems like a pretty lame gotcha--saying "Aha! The language you write in uses your hated paradigm under the hood" seems to invite the immediate response of "So? I don't use it."

pjmlp 6 hours ago||
It is more about those that proudly use Python because it isn't an OOP language, yep those do exist.
tialaramex 7 hours ago|||
I think the choice to identify a specific ur-language as "Object oriented" throws people off since OO is just a style of programming in the same way that procedural is. I don't think it's useful to say that Python and C++ are both the same kind of language because they both have multiple inheritance, rather that's just an observable commonality, like noticing that both Delhi and Vegas are too hot. Yeah, but I don't think that's because they're the same kind of place...
narcraft 5 hours ago||
Yeah, but the thing about Vegas is that it's really more of a dry heat
bitwize 7 hours ago||
Aren't camels a Perl thing?
AdieuToLogic 39 minutes ago||
> Aren't camels a Perl thing?

That's a deep cut. :-)

For anyone reading this, O'Reilly was once legendary for their cover-art mascots.

pfdietz 12 hours ago||
I might add another class of languages: those intended to express proofs, via the Curry-Howard correspondence. Lean is a primary example here. This could be considered a subclass of functional languages but it might be different enough to warrant a separate class. In particular, the purpose of these programs is to be checked; execution is only secondary.
User23 1 minute ago||
[delayed]
armchairhacker 11 hours ago|||
Theorem proving and complex types are like extensions on an otherwise ordinary language:

- Agda, Idris, etc. are functional languages extended with complex types

- Isabelle, Lean, etc. are functional languages extended with complex types and unreadable interactive proofs

- Dafny etc. are imperative languages extended with theorems and hints

- ACL2 is a LISP with theorems and hints

Related, typeclasses are effectively logic programming on an otherwise functional/imperative language (like traits in Rust, mentioned in https://rustc-dev-guide.rust-lang.org/traits/chalk.html).

nextaccountic 11 hours ago||
> Agda, Idris, etc. are functional languages extended with complex types

I think they are not. No amount of type level extensions can turn a regular functional language like Haskell into something suitable for theorem proving. Adding dependent types to Haskell, for example, doesn't suffice. To build a theorem prover you need to take away some capability (namely, the ability to do general recursion - the base language must be total and can't be Turing complete), not add new capabilities. In Haskell everything can be "undefined" which means that you can prove everything (even things that are supposed to be false).

There's some ways you can recover Turing completeness in theorem provers. You can use effects like in F* (non-termination can be an effect). You can separate terms that can be used in proofs (those must be total) from terms that can only be used in computations (those can be Turing complete), like in Lean. But still, you need the base terms to be total, your logic is done in the fragment that isn't Turing complete, everything else depends on it.

solomonb 6 hours ago|||
I mean you are kinda right but kinda wrong. To get a proof checker you take a typed lambda calculus and extend it with Pi, Sigma, and Indexed Inductive types while maintaining soundness.

Yes haskell's `bottom` breaks soundness, but that doesn't mean you need to take away some capability from the language. You just need to extend the language with a totality checker for the new proof fragment.

LeCompteSftware 11 hours ago|||
This is just wrong, you're being too didactic. Idris specifically lets you implement nontotal functions in the same way that Rust lets you write memory-unsafe code. The idea is you isolate it to the part of the program with effects (including the main loop), which the compiler can't verify anyway, and leave the total formally verified stuff to the business logic. Anything that's marked as total is proven safe, so you only need to worry about a few ugly bits; just like unsafe Rust.

Idris absolutely is a general-purpose functional language in the ML family. It is Haskell, but boosted with dependent types.

andai 10 hours ago|||
Random passerby chiming in: so this means you can write "regular" software with this stuff?

While reading TFA I thought the theorem stuff deserved its own category, but I guess it's a specialization within an ur-family (several), rather than its own family?

It definitely sounds like it deserves its own category of programming language, though. The same way Lojban has ancestry in many natural languages but is very much doing its own thing.

nextaccountic 10 hours ago||
Yes Idris was meant to write regular code. F* is also meant to write regular code

But I think that the theorem prover that excels most at regular code is actually Lean. The reason I think that is because Lean has a growing community, or at least is growing much faster than other similar languages, and for regular code you really need a healthy ecosystem of libraries and stuff.

Anyway here an article about Lean as a general purpose language https://kirancodes.me/posts/log-ocaml-to-lean.html

nextaccountic 10 hours ago|||
I mentioned this later

> You can separate terms that can be used in proofs (those must be total) from terms that can only be used in computations (those can be Turing complete), like in Lean

What I meant is that the part of Idris that lets people prove theorems is the non-total part

But, I think you are right. Haskell could go there by adding a keyword to mark total functions, rather than marking nontotal functions like Idris does. It's otherwise very similar languages

zozbot234 5 hours ago|||
These are not true programming languages because by definition they are not Turing complete. If they were Turing complete it would be possible to write a false proof that just compiled down to a non-terminating program.
gf000 3 hours ago||
There has never been a requirement for a "true" programming language to be Turing complete.

Also, basically every such language has escape hatches similar to unsafe in Rust to allow expressions that are not provably terminating.

They can then just be accepted as an axiom.

mcmoor 1 hour ago||
I feel like Turing completeness has always been set as the boundary of programming language if there's any boundary at all. That's what people has been using to not include HTML as programming language for example. Or to include MTG as one.
solomonb 7 hours ago|||
These fall directly out of ML.
LeCompteSftware 11 hours ago||
Lean is definitely a dependently typed ML-family language like Agda and Idris, so "ML" has it covered. And the long-term goal of Lean certainly is not "execution is only secondary"; Microsoft is clearly interested in writing real software with it: https://lean-lang.org/functional_programming_in_lean/Program...

OTOH if you really want to emphasize "intended to express proofs" then surely Prolog has that covered, so Lean can be seen as half ML, half Prolog. From this view, the Curry-Howard correspondence is just an implementation detail about choosing a particular computational approach to logic.

gobdovan 12 hours ago||
there's a few more semantic families: verilog, petri nets and variants, Kahn process networks and dataflow machines, process calculi, reactive, term rewriting, constraint solvers/theorem provers (not the same with Prolog), probabilistic programming,

plus up and coming (actual production-ready) languages that don't fit perfectly in the 7 categories: unison, darklang, temporal dataflow, DBSP

It may feel like a little bit of cheating mentioning the above ones, as most are parallel to the regular von Neumann machine setup, but was meaning for a while to do an article with 'all ways we know how to compute (beyond von Neumann)'.

andai 7 hours ago||
> was meaning for a while to do an article with 'all ways we know how to compute (beyond von Neumann)'.

Would be very glad to read this.

In the meantime, I reproduce a part of an article by Steve Yegge:

---

What Computers Really Are

Another realization I had while reading the book is that just about every course I took in my CS degree was either invented by Johnny von Neumann, or it's building on his work in mostly unintelligent ways.

Where to start? Before von Neumann, the only electronic computing devices were calculators. He invented the modern computer, effectively simulating a Universal Turing Machine because he felt a sequential device would be cheaper and faster to manufacture than a parallel one. I'd say at least 80% of what we learned in our undergrad machine-architecture course was straight out of his first report on designing a programmable computer. It really hasn't changed much.

He created a sequential-instruction device with a fast calculation unit but limited memory and slow data transfer (known as the infamous "von Neumann bottleneck", as if he's somehow responsible for everyone else being too stupid in the past 60 years to come up with something better. In fact, Johnny was well on his way to coming up with a working parallel computer based on neuron-like cellular automata; he probably would have had one in production by 1965 if he hadn't tragically died of cancer in 1957, at age 54.)

Von Neumann knew well the limitations of his sequential computer, but needed to solve real problems with it, so he invented everything you'd need to do so: encoding machine instructions as numbers, fixed-point arithmetic, conditional branching, iteration and program flow control, subroutines, debugging and error checking (both hardware and software), algorithms for converting binary to decimal and back, and mathematical and logical systems for modelling problems so they could be solved (or approximated) on his computing machine.

-Steve Yegge, Math Every Day

https://archive.ph/6tOQF

andai 7 hours ago|||
>term rewriting

In uni we had to make a spreadsheet software.

I volunteered to do the formula parser, thinking it sounded like a fun challenge.

I was stumped for a week, until I realized I could rewrite the formulas into a form I knew how to parse. So it would rewrite 1+1 into ADD(1,1) and so on.

I also refused to learn regex, so the parsing code was "interesting" ;)

I recall a comment from a colleague. "Okay, Andy says it works. Don't touch it." XD

Guy from another group used regex and his solution was 20x shorter than mine.

gf000 3 hours ago||
Regular expressions are probably not enough for parsing formulas (depending of course on the exact task given), they usually are at least a context free language.
Someone 7 hours ago|||
> plus up and coming (actual production-ready)

Plus up and coming (not quite production-ready IMO, but used in production anyways): ChatGPT and the like.

Of course, it’s debatable whether they are programming languages, but why wouldn’t they be. They aren’t deterministic, but I don’t think that is a must for a programming language, and they are used to let humans tell computers what to do.

gobdovan 12 hours ago|||
also Sussman's propagators are nice to check out [0]

[0] The Art of the Propagator (mit url down for the moment)

lioeters 7 hours ago|||
Great list of languages that don't fit the conventional families. I've been curious about some of them, like Petri nets and term rewriting, and will enjoy exploring the others.

Found a working link to the paper about propagators.

The Art of the Propagator, Alexey Radul and Gerald Jay Sussman. https://groups.csail.mit.edu/mac/users/gjs/6.945/readings/ar... (PDF)

zem 6 hours ago||
pure [https://agraef.github.io/pure-lang/] is probably the most "practical" term rewriting language, though mathematica is the most used one by far.
jounker 2 hours ago|||
<snark>So they reinvented speadsheets?</snark>
anthk 7 hours ago||
Logic programming in S9 scheme:

https://www.t3x.org/amk/index.html

You can just get the code without buying the book, learn with Simply Scheme or any other book and apply the functions from the code, the solvers are really easy to understand.

DonaldFisk 11 hours ago||
I wrote something similar here: https://fmjlang.co.uk/blog/GroundBreakingLanguages.html

We agree on Algol, Lisp, Forth, APL, and Prolog. For ground-breaking functional language, I have SASL (St Andrews Static Language), which (just) predates ML, and for object oriented language, I have Smalltalk (which predates Self).

I also include Fortran, COBOL, SNOBOL (string processing), and Prograph (visual dataflow), which were similarly ground-breaking in different ways.

jasomill 4 hours ago||
I like your list better, mostly because of the inclusion of SNOBOL, which I never used, but was one of the first programming languages I read about as a young child after a book about it caught my attention at a public library book sale because of the funny name.

The only languages I was familiar with before this were BASIC, Logo, and a bit of 6502 assembly, though I had only used the latter by hand-assembly and calling it from BASIC following an example in the Atari BASIC manual[1].

Also, it's hard for me to imagine how anyone could make a list of ground-breaking programming languages that doesn't include Fortran and COBOL (or FLOW-MATIC as the source of many of its innovations).

[1] https://archive.org/details/atari-basic-reference-manual/pag...

f1shy 8 hours ago||
I don’t understand why self is placed in the list instead of smalltalk. Smalltalk came first, and Alan Key was the one who invented the “OOP” name.

Also ML is seen as a child of Lisp.

pjmlp 7 hours ago||
They should be placed alongside each other, because Self OOP model is quite different from Smalltalk, including how the graphical programming experience feels like.

For those that never seen it, there are some old videos (taken from VHS) on the language site, https://selflanguage.org/

Kaliboy 12 hours ago||
My favorite subject when studying CompSci (TU Delft) was called "Concepts of programming languages". We learned C, Scala (for functional) and Javascript (prototypes).

It made learning Elixir years later much easier.

We also had a course that basically summed up to programming agents to play Unreal Tournament in a language called GOAL which was based on Prolog.

For years I've wanted to use Prolog but could not figure out how. I ended up making a spellcheck to allow LLM's to iterate over and fix the dismal Papiamentu they generate.

delecti 6 hours ago||
I took a similar class in college, and I'm also glad I did, even though the professor was kinda rubbish.

Even having the thinnest surface level understanding of the other ur-languages is so useful (and even more-so with assembly). I can't do anything useful with them, but it helps keep you from the "when all you have is a hammer, every problem looks like a nail" trap if you're at least aware of the existence of screwdrivers.

andai 7 hours ago|||
I was there, too. o/

The Unreal Tournament was the coolest thing I've ever seen. I think they shut it down the year after mine. (Now they have boring old regular AI like everyone else!)

I haven't found a good use for Prolog, though I haven't put much effort into it. I admit I was much more impressed by GOAL though, and I didn't realize until recently that you can replicate the whole thing in a more "ordinary" language (and that this gives many benefits). D'oh!

beasthacker 7 hours ago||
This GOAL?

https://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

Kaliboy 8 minutes ago||
No this GOAL: https://en.wikipedia.org/wiki/GOAL_agent_programming_languag...
stared 2 hours ago||
I agree with "learn different classes of languages". OCaml was a language in which finally a function was a (mathematical) function. Mathematica thought me to look at expressions themselves as inputs. PostScript (with its reverse Polish notation going beyond simple arithmetics) rewired by brain.

At the same time, I don't agree with that it does not matter if one picks "Java, C#, C++, Python, or Ruby". If your goal is to do quick sort, then well, it does not.

If you want to use language for something (not only for its sake), then it makes a day and night difference. A person who wants to do 3D games and being shown Ruby or a person wanting to do exploratory data science and deep learning and being given Java are likely to get discouraged.

ekropotin 1 hour ago|
Even tho I probably never will get paid for writing Rust, I have zero regrets about learning it - it tough me really think about data ownership in programs.
macintux 13 hours ago||
Reminds me a bit of Bruce Tate’s approach in 7 languages in 7 weeks, which is where I first encountered Erlang.

I think from a historical perspective, describing COBOL and Fortran as part of the ALGOL family is a stretch, but I suppose it’s a good reminder that all history is reductive.

ianburrell 1 hour ago||
I also think going back farther is a stretch. The first assembly languages were imperative, but what made Algol, Fortran, and Cobol interesting were functions and other features that allowed complex programming. Algol has the most descendants but Fortran was the first imperative programming language.
jasperry 9 hours ago|||
Does anybody know whether Fortran is older or younger than Algol? From Wikipedia, it looks like they were both developed around 1957. Was there any overlap in the design?
kergonath 5 hours ago||
Algol was published in 1958, and FORTRAN in 1957. I think it's fair to say they were developed concurrently.
gottheUIblues 13 hours ago||
Rather COBOL is a living fossil? And today's Fortran is the FORTRAN family with horizontal gene transfer from the Algol lineage of programming languages.
pjmlp 7 hours ago|||
Both languages have their standards updated still, latest year in both cases was 2023.

Fortran is one of the reasons OpenCL lost to CUDA, and now even AMD and Intel have finally Fortran support on their own stacks, not Khronos based.

https://developer.nvidia.com/cuda-fortran

Whereas Cobol, even has cloud and microservices.

https://www.rocketsoftware.com/en-us/products/cobol/visual-c...

https://aws.amazon.com/mainframe/

Incredible how being monetary relevant keeps some languages going.

Also note how the beloved UNIX and C are from 1971 - 73, only about 10 younger than COBOL.

kergonath 5 hours ago||
> Fortran is one of the reasons OpenCL lost to CUDA, and now even AMD and Intel have finally Fortran support on their own stacks, not Khronos based.

FWIW, I loved using CUDA-Fortran. I think the ease of use of array variables maps very well with the way CUDA kernels work. It feels much more natural than in C++.

shevy-java 13 hours ago|||
Can COBOL be called a living fossil?

I mean, programming languages do not live; and they do not "die", per se, either. Just the usage may go down towards 0.

COBOL would then be close to extinction. I think it only has a few niche places in the USA and perhaps a very few more areas, but I don't think it will survive for many more decades to come, whereas I think C or python will be around in, say, three decades still.

> family with horizontal gene transfer

Well, you refer here to biology; viruses are the most famous for horizontal gene transfer, transposons and plasmids too. But I don't think these terms apply to software that well. Code does not magically "transfer" and work, often you have to adjust to a particular architecture - that was one key reason why C became so dynamic. In biology you basically just have DNA, if we ignore RNA viruses (but they all need a cell for their own propagation) 4 states per slot in dsDNA (A, T, C, G; here I exclude RNA, but RNA is in many ways just like DNA, see reverse transcriptase, also found in viruses). So you don't have to translate much at all; some organisms use different codons (mitochondrial DNA has a few different codon tables) but by and large what works in organism A, works in organism B too, if you just look to, say, wish to create a protein. That's why "genetic engineering" is so simple, in principle: it just works if you put genes into different organisms (again, some details may be different but e. g. UUU would could for phenylalanine in most organisms; UUU is the mRNA variant of course, in dsDNA it would be TTT). Also, there is little to no "planning" when horizontal gene transfer happens, whereas porting requires thinking by a human. I don't feel that analogy works well at all.

kaycebasques 11 hours ago|
Previous discussion: https://news.ycombinator.com/item?id=35813496
dredmorbius 10 hours ago|
May 4, 2023, to be clear. 323 comments.

Also 30 Sept 2021, 29 comments, <https://news.ycombinator.com/item?id=28704495>.

More comments...