Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming languages that define the problem instead of the solution?

Are there any programming languages designed to define the solution to a given problem instead of defining instructions to solve it? So, one would define what the solution or end result should look like and the language interpreter would determine how to arrive at that result. Looking at the list of programming languages, I'm not sure how to even begin to research this.

The best examples I can currently think of to help illustrate what I'm trying to ask are SQL and MapReduce, although those are both sort of mini-languages designed to retrieve data. But, when writing SQL or MapReduce statements, you're defining the end result, and the DB decides the best course of action to arrive at the end result set.

I could see these types of languages, if they exist, being used in crunching a lot of data or finding solutions to a set of equations. The dream language would be one that could interpret the defined problem, identify which parts are parallelizable, and execute the solution across multiple processes/cores/boxes.

like image 470
Jon Smock Avatar asked Aug 06 '09 13:08

Jon Smock


People also ask

What programming language is used for problem solving?

Indeed, C++ is one of the most recommended and widely used programming languages for Competitive Programming.

How do you define a problem in programming?

Specifically, the task of defining the problem consists of identifying what it is you know (input-given data), and what it is you want to obtain (output-the result). Eventually, you produce a written agreement that, among other things, specifies the kind of input, processing, and output required.

Which is also known as problem Oriented language?

High level language is problem oriented language. For original formulation are called problem-oriented languages.

What is an example of imperative programming language?

Examples of imperative programming languages include C, C++, Java and Fortran.


8 Answers

What about Declarative Programming? Excerpt from wikipedia article (emphasis added):

In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it. This is in contrast with imperative programming, which requires an explicitly provided algorithm.

like image 190
Karl Voigtland Avatar answered Sep 22 '22 15:09

Karl Voigtland


The closest you can get to something like this is with a logic language such as Prolog. In these languages you model the problem's logic but again it's not magic.

like image 32
Savvas Dalkitsis Avatar answered Sep 22 '22 15:09

Savvas Dalkitsis


This sounds like a description of a declarative language (specifically a logic programming language), the most well-known example of which is Prolog. I have no idea whether Prolog is parallelizable, though.

In my experience, Prolog is great for solving constraint-satisfaction problems (ones where there's a set of conditions that must be satisfied) -- you define your input set, define the constraints (e.g., an ordering that must be imposed on the previously unordered inputs) -- but pathological cases are possible, and sometimes the logical deduction process takes a very long time to complete.

If you can define your problem in terms of a Boolean formula you could throw a SAT solver at it, but note that the 3SAT problem (Boolean variable assignment over three-variable clauses) is NP-complete, and its first-order-logic big brother, the Quantified Boolean formula problem (which uses the existential quantifier as well as the universal quantifier), is PSPACE-complete.

There are some very good theorem provers written in OCaml and other FP languages; here are a whole bunch of them.

And of course there's always linear programming via the simplex method.

like image 28
Meredith L. Patterson Avatar answered Sep 22 '22 15:09

Meredith L. Patterson


These languages are commonly referred to as 5th generation programming languages. There are a few examples on the Wikipedia entry I have linked to.

like image 31
Ionuț G. Stan Avatar answered Sep 18 '22 15:09

Ionuț G. Stan


Let me try to answer ... may be Prolog could answer your needs.

like image 41
nightingale2k1 Avatar answered Sep 18 '22 15:09

nightingale2k1


I would say Objective Caml (OCaml) too...

like image 32
peroumal1 Avatar answered Sep 20 '22 15:09

peroumal1


This may seem flippant but in a sense that is what stackoverflow is. You declare a problem and or intended result and the community provides the solution, usually in code.

It seems immensely difficult to model dynamic open systems down to a finite number of solutions. I think there is a reason most programming languages are imperative. Not to mention there are massive P = NP problems lurking in the dark that would make such a system difficult to engineer.

Although what would be interesting is if there was a formal framework that could leverage human input to "crunch the numbers" and provide a solution, perhaps imperative code generation. The internet and google search engines are kind of that tool but very primitive.

Large problems and software are basically just a collection of smaller problems solved in code. So any system that generated code would require fairly delimited problem sets that can be mapped to more or less atomic solutions.

like image 41
Gordon Potter Avatar answered Sep 20 '22 15:09

Gordon Potter


Lisp. There are so many Lisp systems out there defined in terms of rules not imperative commands. Google ahoy...

like image 39
David Plumpton Avatar answered Sep 22 '22 15:09

David Plumpton