views:

1154

answers:

11

I'm doing a Windows Application the uses lots of charts.. Its practically a dataviewer.. I started doing Matlab, because its easier, but I realized it's too slow.. I wanted to change to another language.. Somebody recommended me Visual C++ or Java.. But Im not sure.. What language should I use??

+1  A: 

I would use C#. It is easier than C++ and integrates well with the Windows platform. Just find a free graphing library for it and you're good to go.

There are plenty of other options depending on your preference of language. Eg. Qt with Python or C++.

CookieOfFortune
+3  A: 

It depends on what your requirements are.

The advantage of using matlab is that it's strong in numerical calculations. If you don't need that, then there is no advantage to using matlab. In this case, all those languages are okay, and many others (Python, C#, ...) as well. It depends on which language you are most comfortable with.

If you do want the advantages of matlab then:

  1. Try optimizing in matlab. Most optimization techniques are language independent.
  2. There are tools to translate matlab to C automatically. You can then try to compile with all optimizations on. I seriously doubt this will help much, however, especially considering the GUI part.
Gilad Naor
The problem is that it works with great amounts of data and it turns the application slow.. What I want is a very fast application.. what should i use??
You should profile to see what is taking up all of the time. Choosing a different language just to optimize what you're doing seems to be over-kill. Maybe you're spending time reading row by row from disk instead of bulk reading into RAM.More information is needed for an accurate response.
Gilad Naor
+1  A: 

As far as I know, the most common methodology is to first do the proof of concept or just the main algorithm on Matlab, because of its ease of use and convenience for math calculations, and after that to translate it to a "real" programming language in order to improve the performance. Usually C or C++ act as the "real" language, but in your case, aiming to do a Windows application, perhaps C# will be the best option.

Igor Oks
A: 

First of all Visual C++ is not a language is an IDE for developing applications.

Second... Which languages do you know? You can have serveral options. Take a look to:

  • C++ + Qt (Mine preferred option, powerful and easy to understand)
  • C# + .NET or WPF
  • Java

If you can tell more information we could find a language that matches your needs.

xgoan
+9  A: 

In my opinion the speed gain from going to another "faster" language is not as much as refining your algorithm.

The "problem" with MATLAB is that it allows you to do some nasty things, such as resizing your matrix in a tight loop. You should really try to pinpoint your bottlenecks using the following command:

  profile on
  ... run your program
  profile off
  profile report

This will give you nice information about which function takes how long to execute and which line creates the biggest bottleneck. You can also see how many times a function is called and a M-Lint Code Check Report is included.

These measurements and hints can show you the bottlenecks of your algorithm. if your sure there isn't a way to reduce the callcount/speed of a function using a smarter algorithm. Such as do I really need that big 2d matrix where a smart vector would be large enough, or if I found a artifact, why would I still continue searching for artifacts. You could write the functions you're experiencing the most performance problems with in c/c++ and use it as a function in matlab. You can get a big speedup out of correctly choosing which functions to implement in c/c++. There is an amount of overhead with calling a c/c++ function from MATLAB, or more correctly there is a overhead in c/c++ to get the data from MATLAB, so a function which is called 10000 times will not be the best to implement in c/c++, you'd be better of with the function higher up the callstack.

Davy Landman
+2  A: 

Don't forget that you can create functions in C++ that can be called from Matlab. And TADA, you have access to both environments !

Magnus Skog
+1  A: 

I found that GUI programming in MATLAB can get really nasty if your application gets more complex. BTW MATLAB can also be called from Java easily (and vice versa, current versions basically provide an interactive Java console).

__roland__
+1  A: 

Just as a side note, if you still need the math power of Matlab, you may want to check out Scilab. It's open-source and free, and it has examples of how it can be integrated with other C# or C++. I have created projects on which Scilab was running in the background to perform all the data math operations; and displaying them with C#'s ZedGraph library. Worked like magic!

m_oLogin
+3  A: 

First and foremost, as other answers have mentioned, you need to profile your code to find out where the bottleneck is. I would check out Doug Hull's blog at The MathWorks, specifically this entry about using the profiler. This will help you find out where all the work is being done in your code.

If the source of the slowdown is associated with data processing, there may be a number of ways to speed things up (vectorizing, writing a mex file, etc.).

If the source of the slowdown is your GUI, this may be even easier to solve. There are a number of blog posts, both from Doug and other MathWorkers, which I've seen that deal with GUI design. There have also been a few questions on SO dealing with it (here's one). If you're dealing with displaying very large data sets, this submission from Jiro Doke on The MathWorks File Exchange may help speed things up.

It's hard to give you more specific advice since I don't know how you are designing your GUI, but if that turns out to be the bottleneck in displaying your data there are many resources to turn to for improving its speed before you go through the hassle of switching to a whole other language.

gnovice
A: 
  • An alternative to Matlab and Scilab is another free software: Octave. I don't know about Scilab, but Octave syntax is nearly the same as matlab so you can import code with minimal effort.

If you need fancy toolboxes though, Scilab and Octave might let you down, so check this.

You can execute Octave functions in a C++ program: http://en.wikipedia.org/wiki/GNU_Octave

  • I do not think that you can call your own m-files functions from your C++ program though. In the past, the Matlab compiler would let users run matlab programs without installing Matlab, but not without installing a huge library (250 MB if I remember correctly). Nevermind if your Matlab program took 20 kB, you had to distribute the huge library. Please someone edit/comment on the situation today!

It has been a while since I used the GUI "ability" of Matlab, but back then (2005) I found it awful. Ugly, hard to use, very hard to maintain, dependent on user settings of windows parameters. Please comment or edit on that too, they may have made progress!

If they have not, I believe that Matlab is NOT the way to go for a program that you want to deliver to anyone.

If you can use Visual Studio for doing your GUI, do that. I second the earlier opinions: go with what you're comfortable with. If you need the Matlab functions, go with what you're comfortable with, that supports Matlab libraries.

Gauthier
+1  A: 

I suggest you using Java and the JFreeChart (http://www.jfree.org/jfreechart/) library. I found very easy (and fast) developing applications with a lot of charts of different typologies. If you don't need particularly fast performances, you can use Java. I suppose that there are similar libraries for C#, but I'm not sure.