network-programmingoptimizationtradeoff

Coding speed, programming speed tradeoff: C++ or Java with native code


I wanted to explore neural nets by writing a program to play with different types of networks. So far I've written a basic perceptron in c++. As I understand it neural networks can require a lot of computing power to do even fairly minor tasks, so optimization is a concern, or at least I want to take the idea seriously without going to an extreme like gpu programming.

I'm comfortable programming in Java, less so with C++, but would like to get more experience with it anyway.

My Question:

Given that I would be able to write the main program faster in Java, but am concerned about speed. Does it make more sense to write the main program in Java and write the more intensive parts in C++ or instead write the entire program in C++?

I have no user interface requirements that would prefer one language over the other (i.e. I'm not planning to stick it in a web app).

**No one else would be using this, as there are already more professional open source versions available (FANN/Encog). This is purely for my entertainment/learning. I would like to learn more C++ so I want to write at least some if it with that (though if someone feels it makes more sense to completely write it in Java I would be interested in knowing why.)


Solution

  • This is a fairly subjective question and isn't really a good fit for SO but i'll give it a shot.

    Depending on your implementation, you may find yourself far more limited by things like bandwidth and latency. If I were you, I'd write it as much as possible in a language you were comfortable with, profile it, and come back and rewrite the slow parts in something faster, with optimization in mind.

    This is the procedure of optimization I'd follow for projects expected to be CPU bound in general.

    Since you're doing it to grasp C++ better, it might benefit you to use C++ instead of java for the whole thing, and optimize parts of it later, but a neural net might not be a very "beginner friendly" project. It's possible you'd end up with a train wreck caused by a design better suited for another language. You'd still probably learn from it, but you wouldn't be able to use it after you finished.