+1  A: 

Depending on the problem, your combinatorial problem might be an interesting fit with Oz, in particular it's finite domain constraint programming. I'll admit it's a bit exotic, though.

John the Statistician
...plus, Oz/Mozart is dynamically typed (Van Roy and Haridi explain very well in their masterpiece of a book why that doesn't matter that much, and in as much as it matters it's a positive for very-open code... but the OP seems to be eschewing Python only because of that feature, so, Oz/Mozart?-). There is (was?) an AliceML (superb static typing a la ML, _almost_ as good as Haskell's;-), with "constraint programming in the tradition of Oz/Mozart", but I have no idea whether it's gone anywhere over the last five years or so.
Alex Martelli
Oz has pattern matching. Let's ignore its typing system in favor of celebrating this, as making heavy use of it will probably cause you to get plenty of errors when you make mistakes. Further, Mozart makes it absurdly easy to test individual lines of code and individual functions. You do plan to use Emacs, right?
Brian
A: 

I wouldn't use C++, because it won't catch things lack indexing off the end of arrays, and because it won't provide you with a garbage collector. Personally, I'd use, Java, just because that's what I'm familiar with.

I would consider what you are familiar with, what people you want to work with or at least communicate with are familiar with, and what libraries are available that you might want to use. This might include things like I/O or graphics libraries for post-processing results, as well as specialiased combinatorial algorithms. You might also look for profiling tools, so you can see where your algorithm is spending all its time.

mcdowella
There would have been the chance to use STL-Debug-Mode in GCC for checking index.bounds but i got your point.A garbage collector surely can be a good thing, but i think Java is as big and complex as C++ and maybe its a bit to heavy to switch to it in my context.
sascha
+7  A: 

I think that you are going to find that most of the popular very high level languages that are ideal for prototyping are 'weakly typed'.

Also, when I unit test, it's almost never to make sure that things are of the right type. This is very seldom as big a problem as it's made out to be. You should unit test to ensure freedom of the algorithm from bugs of any cause.

You mentioned python, so I will recommend that, not being familiar with haskell myself. Python has Numpy and integrates very well with C. It also has the itertools module in stdlib which is very nice for combinatorial work (judiciously applied, It can outperform slightly better than mediocre C). I'm currently working on a similar project and I prototyped it out with python. I'm currently in the process of translating most of it to C. This is a nice process because I already have a python implementation of every algorithm so once I get my C wrapped for python, I can test the two off against each other to make sure that they give identical output on identical input. So because I built a prototype in python, I get both a very cheap testing framework for my application and a python module written in C.

Plus I've already found optimal (or at least sufficient) algorithms and if a new one occurs to me, I can quickly modify the python in a different branch to test it for efficiency.

Whatever language you choose, consider making sure that it integrates well with your ultimate target language to take advantage of similar perks.

aaronasterling
thanks for your tips, especially for mentioning the itertools.
sascha
+1  A: 

I haven't used Python, and I've only used Haskell a little, for exactly the purpose you describe -- prototyping things. The thing to watch out for there is not the slowdown that laziness gives you, but rather the fact that seemingly constant-space algorithms can have space leaks that consume all available memory with thunks representing unevaluated chunks of code. Space leaks are hard to see.

Of course, you can worry about them and scour your program looking for them, exterminating them with seq and other forms of ugliness... But the point of using a prototyping language is to avoid all those headaches.

If you're playing with problem sizes so small that it doesn't matter if a thunk is created in memory for every evaluation step in your program from beginning to end, then I could recommend Haskell.

j_random_hacker
Thanks for the warning and the link.
sascha
+1  A: 

C# 4.0

It has almost all the features you require.

  1. Functional programming
  2. Higher order functions
  3. .NET Parallel extensions
  4. Lazyness
  5. Generics
  6. Arrays

Some ProjectEular Examples

NOTE: I myself would go with Python and write some modules in C++. ;)

TheMachineCharmer
Definitely have to check out this.
sascha
A: 

I would suggest to give D a shot. It is close to C++, but much easier to reason about and without all the ugly warts. If you're thinking about writing the final implementation in C++, it's much easier to translate D to C++ as Python, and additionally you have the option to stay with D, as the performance is on par with C++.

Landei
+2  A: 

While i'd encourage you to learn more languages, if your goal is to prototype this problem as quickly as possible i'd stick with C++ (as you seem to be proficient in it already).

while other languages are probably better for prototyping in general if you only know C++ now, you will probably have a resonably large learning curve which will slow you down enough that you lose its advantage for this project at least (especially if you are looking at major paradigm change as well).

on the other hand if this is actually more about broadening your knowledge for the future then pretty much any of the scripting languages will do.

jk
I'm still in the academic world where i have a more or less flexible time window for developing this. This surely could be stretched for learning some basics of a new language first.But the possibility of keeping C++ as first language is still there. Especially because there is alway to learn more in C++ for me.Thanks for your comment.
sascha
if you have the time learning more languages will be useful for the future and potentially give you insight into how to develop better in C++ as well
jk
+8  A: 

I'm a Haskell programmer for more than 7 years and I haven't used any other language for serious work since. My recommendation is, of course, Haskell. :-)

In my experience, here is what you can expect of Haskell:

  • Learning Haskell takes time. Mathematically inclined people tend to pick it up very quickly, but most programmers take a while to unlearn their previous experience and get familiar with purely functional programming. If your project should have been finished yesterday, then you are better off with a language you already know.
  • About 4x-10x less code than C. For example, here a prototype implementation of quick sort

:

 qsort :: Ord a => [a] -> [a]
 qsort []     = []
 qsort (x:xs) = qsort (filter (<x) xs) ++ [x] ++ qsort (filter (>=x) xs)
  • Once your source code compiles, it is usually correct on the first try. The type system and purity, i.e. the lack of mutable data structures, are largely responsible for this.
  • Haskell forces you to think about the problem. If the compiler throws a fit, that's usually a sign that you don't have a clear understanding of your problem domain yet.
  • Space leaks and stack overflows. They happen, but they are usually not difficult to fix once they appear. However, that requires a good understanding of the execution model, i.e. lazy evaluation. Here a typical example of a space leak.
  • The Haskell community is a great resource. If you've met a stumbling block, visiting the #haskell IRC channel or asking on the [email protected] or [email protected] mailing lists is likely to solve your problem.

I don't think it's possible to back up these experiences with anything other than experience; so, you have to take my word for it.

Several experience reports have been published formally, see also the Haskell in Industry page. I found Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment in Software Prototyping Productivity [ps] to be particularly enlightening.

Heinrich Apfelmus
Did already read the paper you mentioned. The underlying problem of this comparison seemed a bit to easy and non-complex, but i believe in the results that a "experieced" haskell programmer can prototype some stuff really fast. Ok, there seems to be a haskell newbie too in this paper, but maybe its the easy problem that got him to do it good :-)Hard too tell. Thanks for pointing me to the haskell community.
sascha
What do you want to say us with "Once your source code compiles"? ;)
FUZxxl
@FUZxxi: "Once you have appeased the type checker that will unforgivingly complain about every bug you put in there." ;-)
Heinrich Apfelmus
Added a recent example for a space leak.
Heinrich Apfelmus
@sascha: Sounds like you agree with the sentiment noted in the report: "The other kind of response had more to do with the 'cleverness' of the solution: it is safe to say that some observers have simply discounted the results because in their minds the use of higher-order functions to capture regions was just a trick that would probably not be useful in other contexts. One observer described the solution as 'cute but not extensible' (para-phrasing)." You see, the point is that *every* problem domain is amenable to cute tricks, and only Haskell can express them all.
Heinrich Apfelmus
Thanks again for the new link to the space leak example. This seems to be an iteresting blog for a haskell newbie like i am.
sascha
A: 

Maybe R is the answer which you are looking for ?

0x69
I'm not sure if R is good for my purpose, but you motivated me to check these more or less non-general-purpose languages like R, Ocatve/Matlab.
sascha
+1  A: 

Haskell can really shine if you can express the problem domain as an "embedded domain specific language" (eDSL). This is actually just a function library with pretensions, but the trick is to define an underlying abstraction and functions to manipulate it. Its difficult to explain in more concrete terms without understanding your domain better, but I expect you want to give an underlying combinatorial algorithm some hints about which parts of the problem to tackle first, and how to identify promising partial solutions.

Start by taking a look at the list monad. If your problem is not too complex then this might actually be all you need. For more, look at this page for ideas on how to add backtracking and pruning.

Paul Johnson
Thanks for mentioning this way of doing it. I read about eDSL's in the past weeks for the first time and they seem to be a powerful tool for a lot of stuff (example: generative programming). And thanks for the link too. I will look into it.
sascha