5 ms·
Now suppose that the problem is not so straight forward as in finding the square root. Declarative programming in the general case would allow one to specify to
by zelah 10y ago
Now suppose that the problem is not so straight forward as in finding the square root. Declarative programming in the general case would allow one to specify to a robot that it should walk to a certain location and arrive at a certain time. It knows (or can figure out) how to avoid crashing into things and also about not breaking laws and such. It can decide what time to leave the starting point but you don't have to tell it all the steps that will be involved. It is really about constraint satisfaction. Your program might look like this: "meetAt(workPlace , 5:00AM)". It is a well defined problem that clearly has right and wrong outcomes but the constraints are given, not a specific algorithm for the solution. Prolog is one example of a language that automatically solves declarative constraints but the syntax is bad.
- BjoernKW 10y ago> Prolog is one example of a language that automatically solves declarative constraints but the syntax is bad. That's why I mentioned SQL. Both SQL and Prolog are declarative languages but SQL has a much more approachable syntax. In SQL constraints can be expressed using WHERE and ON clauses. For your more complex robot example this would require some work but it's certainly possible.
- zelah 10y agoI will look closer at the SQL language then but what about efficiency?
- BjoernKW 10y agoIn general SQL is fast enough. In many cases it's faster than scripting languages or even faster than compiled languages (particularly when it comes to dealing with list or set data structures). RDBMS like PostgreSQL for example tend to be highly optimised and efficient pieces of software.
- dragonwriter 10y ago> Prolog is one example of a language that automatically solves declarative constraints but the syntax is bad. The syntax is fine, but conventional logic programming is insufficient for what you describe; you need something more likely constraint logic programming as inplemented in, among other languages, Oz.
- zelah 10y agoI will look at Oz.