# Advice on the appropriate programming language for exploring lower bounds?



## wheezyg (Jun 25, 2010)

Does anyone have advice on what programming language would be best to learn in order to be able to figure out lower bounds on (first) the 3x3x3 (as a self-teaching tool), then eventually different puzzle cubes? I would like to get two things out of this project. First, I would like to be able to learn a programming language (obviously) and secondly, I would like to be able to explore minimal solutions to cubes (or cube-like puzzles), and their subgroups, using what I have learned.

I have a small amount of experience with scheme and C++ (but very, VERY rusty). What have others used to explore minimal solutions? Any advice would be greatly appreciated!

thx 
ENG


----------



## Litz (Jun 25, 2010)

It doesn't really matter what language you do it on. You can code the algorithms with whatever you want.

Scheme is a great language to start learning but I doubt you'll ever use it in the future. If you want to learn a language and already have some experience with Scheme, go ahead with C++. It might take you a while to understand some things, but it will actually make your life easier in the future. And honestly, once you know it, you'll easily pick up other languages if you want to.


----------



## Christopher Mowla (Jun 25, 2010)

I would go with C++ too. I have heard it is a very fast language. I would think speed comes in handy for calculating lower bounds.


----------



## Zarxrax (Jun 26, 2010)

I'd suggest C# as its way easier to deal with than C++.


----------



## Lars Petrus (Jun 26, 2010)

C++ is the fastest, but it's quite a bit harder to be productive with, especially if you're not an expert programmer. 

I'd go with Java. C# is very similar. They're no worse than half as fast.


----------



## Tomk (Jun 26, 2010)

I know someone who does exactly what you want to do in C++.


----------



## souljahsu (Jun 28, 2010)

Python is a good beginner programming language, but its slow...
C is faster but harder to learn...


----------



## LewisJ (Jun 29, 2010)

As long as you write your program to be structured towards what your programming language of choice is good at and to avoid what your programming language of choice is bad at, it almost doesn't matter.

For example - on question 10 on projecteuler, I wrote a lua script tailored to how lua works which comes up with the answer in ~2 seconds on my netbook, while one of my friends wrote a program in java following the same method but taking MUCH longer. Although lua is renowned for its speediness (often regarded as the fastest among scripting language), you'd still expect java to beat it in a simple brawny test. It didn't because the way my program worked to cater to lua's strong points caused a problem with memory allocation in java or something, causing it to take much longer.

Simply saying python is slow vs C is fast is like saying QQ is a faster cuber than faz because QQ is faster at bigcubes. Different languages have different strong sides and applications - as long as you use them appropriately you should be fine.


----------



## masterofthebass (Jun 29, 2010)

OBJC! (stupid apple and their love for it)


----------



## Johannes91 (Jun 29, 2010)

LewisJ said:


> For example - on question 10 on projecteuler, I wrote a lua script tailored to how lua works which comes up with the answer in ~2 seconds on my netbook, while one of my friends wrote a program in java following the same method but taking MUCH longer.


Sure, it's possible to write slow code in any language. But some are still much better than others for writing fast code.

OP: You want a low level language with bit-level operations and support for big arrays of unboxed ints with zero memory over-head. C++ would be a fine choice, I like it a lot for algorithmic programming. While it is a bit of a mess and C# and Java are definitely cleaner languages, I don't think that's really important for what you're planning to do.


----------



## souljahsu (Jun 29, 2010)

sorry, what I was trying to say was:
It's a lot faster to write a program in Python but it will run relatively slow comparing a program written in C, because C is a compiled language and Python is a interpreted language.

edit: so if its a small program, write it in Python; but if it's a big program, write it in C


----------



## LewisJ (Jun 29, 2010)

Johannes91 said:


> Sure, it's possible to write slow code in any language.



That's not the point I was going for - I was trying to show that different languages perform well in different ways. Lua performed well with the way I wrote my solution, while Java would work well with some other method.

Anyway, if you're serious about this, be sure to look into the work Rokicki has done to cut the requirement to 22 moves. Here is his paper on his 25 move solution, I'm not sure if a similar document exists for his 22move proof but it was an extension of the idea used for 25 moves. He never mentions what he wrote his program in, but I would think either x86 assembly or C++. You might contact him to discuss his program - he's been into upper bound work much more than any of us, he would know more.


----------



## Herbert Kociemba (Jun 29, 2010)

I suggest using C++ or C because it is easy to interface with Windows API-functions (or similar Linux functions) which is quite usefull if you want to write really fast code. But if you are a beginner in programming do not expect too much. You should start with a 2x2x2 cube solver. Try to understand the concepts of move-tables, pruning tables, symmetry reductions etc. A good 3x3x3 solver is much more difficult to program and you should not start this before you have managed to write an optimal 2x2x2 solver which gives you the optimal solution within in a few milliseconds.


----------



## Johannes91 (Jun 29, 2010)

LewisJ said:


> That's not the point I was going for - I was trying to show that different languages perform well in different ways. Lua performed well with the way I wrote my solution, while Java would work well with some other method.


I know what you're saying, and it's a good point to make. Especially beginner programmers often put too much weight to the "C is faster than Python" statements, as it really depends on whose using the language and what for.

The point I was trying to get across is that a straight-forward solution in C for that Euler problem runs in a few milliseconds, which is several orders of magnitude faster than your Lua.



Herbert Kociemba said:


> I suggest using C++ or C because it is easy to interface with Windows API-functions (or similar Linux functions) which is quite usefull if you want to write really fast code.


Sounds interesting, could you give some pointers as to which OS functions would be the most useful to look at?


----------

