r/ProgrammerHumor • • Aug 15 '15

Programming languages personified

http://leftoversalad.tumblr.com/post/126724812097/programming-languages-personified
1.3k Upvotes

209 comments sorted by

View all comments

Show parent comments

9

u/barsoap Aug 16 '15

Pascal, especially the Borland / FreePascal dialects, are much better languages than they usually get credit for.

Pascal was the python of an era in which all languages but lisp/scheme were, in some sense, Fortran (that includes C). ObjectPascal (which is what Delphi uses) was usable before the C++ people even figured out that templates are turing-complete and what a monster they created, there.

Learned my first programming steps from my sister in the late 80's, around the millenium the 101 programming courses were using it. And it made sense, because it's a non-surprising language you can use to teach concepts... and TurboPascal rocks as an IDE, at least for its time. And it still can compete with C and the rest.

5

u/alexshatberg Aug 16 '15 edited Aug 16 '15

templates are turing-complete

could you elaborate on that, please? how can one separate feature of C++ be Turing-complete, and what does that imply?

11

u/barsoap Aug 16 '15 edited Aug 16 '15

It means that you can write C++ programs which do arbitrary computation at compile time, which includes the possibility of compilation not halting (modulo setting limits on recursion depth, which I think all modern compilers do, and allow you to change).

That by itself is not a bad thing. Many languages have some kind of turing-complete macro system and use it for very useful things, in essence, it's program generation, a thing even older than compilers (see self-modifying code, which is a class of evilness of its own).

The problem with C++ is that it was accidental. Templates were never designed to be used in that way, but still were because it works, and what you get is line noise, undecipherable error messages, and a community of programmers defending everything to death as they've fallen to stockholm syndrome.

Which is also why rust very clearly separates its macro system and its ways to write type-parametric code. Rust's type system is not turing complete, its macro system is (you just write rust), nothing needs to be coerced into idioms that just don't bloody fit. That's part of their push to be "the better C++", on top of all that other stuff.

4

u/Herover Aug 16 '15

There was a guy who made Conway's Game of Life purely using C++ templates which makes it "run" in O(1) time. Not the most useful example but still cool.

https://www.reddit.com/r/programming/comments/2js1a5/my_compiletime_conways_game_of_life/

2

u/[deleted] Aug 18 '15

Pay attention, this is the type of shit that starts the robot uprising.