3 ms·
The problem is, simple examples like a trivial sprite-based game are not generally found in the real world, or else already have libraries built for them. (Or y
by crazygringo 15y ago
The problem is, simple examples like a trivial sprite-based game are not generally found in the real world, or else already have libraries built for them. (Or you should build a new library yourself.)
In the real world, you write programs that connect to databases, transform parameters, perform a bunch of linear algebra calculations, invalidate caches, and output results to a webpage (for example).
The overall specification of what the webpage is, from start to finish -- is simply the program you wind up writing! You have to specify what information you're getting from the DB (the query), with what parameters, the equations to perform after it returns (using a numerical library), how to invalidate which caches (a bunch of specific function calls), and how the webpage should be constructed (the HTML template).
Writing all this in a "declarative" way seems to make as much sense as throwing away your cake recipes and just using cake photos instead, because that's the "result" you want.
The cake photo is useful for two things only:
1) Mentally, having an overall idea of what it is you want to make (lacking many details, however)
2) After you baked the cake, making sure it looks like the photo
Analagously, declaring things at a higher level in a programming project works marvelously in two areas:
1) Designing what you want to build, in a big picture
2) Testing that what you built satisfies the top-level constraints
When artificial intelligence is a smart as humans, they'll we'll have computers that can write our programs for us, and we'll have "declarative" programming. But of course, we'll blame the computers when the programs don't work, just like users blame programmers now... :)
- evincarofautumn 15y agoThat’s a fair assessment, but it misses the point somewhat. All I’m saying is that we should be able to write programs that clearly express our intent, and a result-oriented language would make that easier than a process-oriented one. “The overall specification of what the webpage is, from start to finish—is simply the program you wind up writing!” This is not true; the implementation is very far removed from the specification. It is not easy to look at a bunch of SQL and PHP code and deduce precisely what the requirements of the site are. But in a different sort of language, it could be.
- derekp7 15y agoThe problem is that a results oriented / declarative language would by definition not be Turing complete. And in order for a language to be able to express any problem type, it would have to be Turing complete. SQL is an example of this -- it is declarative, but you can't write a web server or an arcade game in just SQL.
- evincarofautumn 15y agoYour first statement is patently false. You miss the meaning not only of “result-oriented”, but also “declarative”. Besides, Turing-completeness is not a difficult criterion to meet in a language—in fact it’s almost more difficult to avoid it.
- tadfisher 15y agoI'm reminded of TeX, where Knuth struggled to keep it declarative-only for years until the macro system added tail-recursion, becoming a Turing-complete language in its own right.
- TheSOB88 15y agoWhy do you say by definition it wouldn't be Turing complete?