Choose the language for your problem, not the problem for your language.
I have been writing lots of notes on PROLOG and some people asked me: why PROLOG? You can solve this problems in any language! And they are right! :) I also believe that it doesn’t matter which problem you have, you can solve it in any given language.
But there is more. I also believe that it is possible to find the best language for the problem you have. No one should be too attached to any language, as every single one has ups and downs!
So I decided to add here two simple examples of PROLOG code in comparison to Haskell code - both extremelly elegant IMO - and I will leave it up to you to check how it would look like in your favorite imperative language :)
The Depth-First Search is a well know algorithm, that traverses a data structure. It starts at the root and explores the branch as long as possible before backtracking.
And here it goes. I am also putting them next to each other so you can compare them :)
dfs ::(a -> Bool) -- Goaltest (goal)
The Breadth-First Search is also a search algorithm, that also traverses a data structure. The difference is that it starts at the root and explores the neighbor nodes in the same level (depth) before going to the deeper level.
And here it goes again.
bfs goal succ start =
And if you are still not sure that some languages are better for some problems, try to check the code for this problem in Java ;) Just sayin’ !