Managing Parallel Development in Two Languages? 108
Abhaga asks: "I work for a technology startup and our research work is mostly done in Matlab. The technology has matured, and now we are looking to build prototypes and products in C++. However, the dilemma is about the further research work/enhancements to the system. Should they be done in Matlab and continuously ported to C++, or is it better to move to C++ once and for all, at this point of time? Anyone having experience with similar things, what should we keep in mind while deciding on one or other."
Ruby is worse (Score:1, Funny)
No, *THE* language for zealots today is Ruby. With a syntax that makes Perl seem easy and Fortran modern, a complexity that makes C++ seem simple, features of an uselessness that make Lisp seem practical, zealots are all abandoning Python for Ruby these days.
Re:Ruby is worse (Score:2)
---
Help me with my Ruby Sudoku Solver [markbyers.com]
Re:Ruby is worse (Score:2)
Probably stuff like
def r a;!(i=a=~/0/)?p(a):((?1..?9).map-(0..80).map{|j|a[ j]+(i-j)%9*
(i/9^j/9)*(i/27-j/27|i%9/3-j%9/3)*9}).map{|k|r$`
has something to do with people being turned off by Ruby... Besides, can't you write the same program in a shorter way using APL?
If you want to obfuscate, at least you should try to do it in a beautiful and elegant way, like this Perl program. [99-bottles-of-beer.net]
Who said anything about obfuscation? (Score:2)
I don't think so otherwise someone would have submitted it.
If you want to obfuscate
I don't. The idea was to make it as short as possible, not as unreadable as possible. If I wanted to make it unreadable, I'd use Perl, like you suggested.
Re:Ruby is worse (Score:3, Interesting)
Give me a break. Nobody writes Ruby that way.
Ruby is far from perfect, and it's not for everyone, but that can be said for any language. You could at least try to criticize it for its faults, not some guy who programs like a moron.
OMFG!!!1 C is a bastardization. Only crazy zealots program in C, cause they're always doing stuff like this [ioccc.org] or this. [ioccc.org] You'd have to be a zealot to use C!
See how stupid that looks?
Re:Ruby is worse (Score:2)
Re:Ruby is worse (Score:1)
Only zealots would respond to an obvious troll n/m (Score:1)
Re:Only zealots would respond to an obvious troll (Score:1)
Mathworks already went with Java (Score:3, Interesting)
Matlab is morphing into a Java scripting language. You know why the Matlab UI takes so long to load these days? Its written in Java, so it needs to load a Java VM when it launches with all of the attendant byte code checking of loaded classes.
Did you know that you can launch Java apps from the Matlab command prompt? That you can also create object instances of individual Java classes and invoke function calls on them? That Matlab automatically m
Do one thing at a time. (Score:2, Insightful)
Trying to write C++ code and develop the math at the same time means that you have four times the trouble debugging. If you have a problem you won't be sure whether it's in the math or the code. If you get the math right first, you
Re:Do one thing at a time. (Score:2)
Actually, if functional units are done in sequence, then the debugging in the second language will be trivial. After writing, testing, and debugging the Foo function in Matlab, the C++ work will be little more than transcription.
If you can interface Matlab to C++, you can even use the same tests for both codebases.
Re:Do one thing at a time. (Score:2)
Start High, Then Low (Score:4, Insightful)
Start in whatever language happens to be easiest/most high level. Easiest in that whatever helps you express your final product the fastest. Then, when this prototype is up and running, go ahead and reprogram it in C++ for speed.
Think of using the first language as a roadmap, where you can concentrate on organizing your thoughts and getting user requirements out of the way. Done purely in C++, you may be subject to premature optimization or just wasting time re-inventing constructs and concepts that are trivial in the other language.
Re:Start High, Then Low (Score:2)
Re:Start High, Then Low (Score:2)
Elegant code reduces development time.
Are you calling GNU code elegant ?
No-one I know that has to cope with GNU code would call it elegant.
Re:Start High, Then Low (Score:2)
Re:Start High, Then Low (Score:3, Informative)
Are you calling GNU code elegant ? No-one I know that has to cope with GNU code would call it elegant.
What GNU code do you mean? There are many official GNU projects, some very elegant, some rather crufty, most a mixture of both. Your comment makes no sense.
Proprietry lock-in (Score:1)
Well, starting out developing using a proprietry environment such as Matlab is not the smartest move if it's so easy to implement your code in C++. What happens if TheMathWorks double their licensing fee? Triple it? Go bust?
Using a properly-defined (ie. by an ISO/IEC standard) language is a much smarter thing to do. Choosing one with several available compilers, supported on different OS / CPU platorms helps too.
Try to make your project as independant as possible, and it will stand a much better chanc
Re:Proprietry lock-in (Score:1)
Re:Proprietry lock-in (Score:4, Interesting)
If you can save time by using Matlab, even in your very unlikely scenario, the extra cost of the software is still dwarfed by the cost of programmers time as well as the potential losses of being 2nd to market. Unless the software is prohibitively expensive(which Matlab isn't), you need to go with what can get the job done the fastest with the fewest errors.
Re:Proprietry lock-in (Score:5, Interesting)
So that is $5,000 a Year of software cost. Now the programmer will work a 35 hour work week. Now the Cheap Programmer year cost is $26,250 a year and the expensive programmer $262,500 a year. So programmers are more expensive then licenses. So if this tool can make a programmer twice as productive then it is worth the license. So unless the programmer is getting like $3.00 an hour which is less then most outsourcing. The costs to do it in C++ vs. Paying for a license is worth it.
Re:Proprietry lock-in (Score:2)
That's only true if they're developing for their own in-house work. But if they're trying to sell this product to other people, going the Matlab route just took $10,000 off their margin. If they want to make a profit, they need to sell their product for $10,000 + [developer time per unit] + [desired profit].
If they go the c++ route, they only have to sell it for [developer time per unit] + [desired profit]. The developer time might be more, but with the lower price, they have a better chance of selling m
Re:Proprietry lock-in (Score:1)
It's not circular. One cost is sunk and the other is variable. If they sell more copies they can more easily amortize the sunk cost and actually, you know, make real long term profit.
Re:Proprietry lock-in (Score:2)
In my (possibly incorrect) view, the choice seemed to be to develop using matlab and spend less time developing, or to develop in C++ and spend more time developing. I was saying that it may be cheaper on a per-unit basis to pay the develo
Re:Proprietry lock-in (Score:3, Insightful)
Re:Proprietry lock-in (Score:2)
Here's the price sheet: https://tagteamdbserver.mathworks.com/ttserverroot
RIGHT NOW, the single-copy United States price for Matlab for commercial use is $1900. The various add-on toolboxes cost anywhere from a few hundred dollars to several thousand dollars.
Those are ONE-TIME purchase prices, not annual license fees. Annual maintenance contracts, which get you upgrades as they become available, are typically around 1/5 of the purchase
Re:Proprietry lock-in (Score:1)
Your proprietry English that contains "independant" will probably go out of business and you will wither and perish.
Re:Proprietry lock-in (Score:1)
Re:Proprietry lock-in (Score:1)
GNU Octave (Score:2)
Depending on how you're using it, you could replace Matlab with GNU Octave [octave.org].
Avoiding proprietary dependencies (especially expensive ones like Matlab) is generally a good idea.
The myth of lock-in (Score:2)
Here at
Moving from one product to another is alwais costly, the cost of the licences is normally not relevant. Actually in most cases (exceptions exist, so annedotal evidence of e opposite can be presented) these costs are actually not significant.
Don't worry about the lock in, do worry about what a product can do for you.
Re:The easy way (Score:2, Informative)
Re:The easy way (Score:4, Insightful)
octave 2.9 is pretty awsome. We use it (for solving a lot of Lp problems, with some branch-and-bound), and it works beautiful.
As for the question... I would question the wisdom in abandoning octave (or matlab) at all, but if you do need to do it, do it in small steps. At least, that is the best way in my experience.
Re:The easy way (Score:2)
This should have read, "So it won't be either faster or (much) easier." This could be rewritten in ways providing a choice between "either/or" or "neither/nor" but "nor/nor" doesn't make sense. There is also the misuse of "a lot" to mean either many or much.
My own imperfect skills in grammar were not drilled into me by nuns with their rulers
Can you do modules in Matlab? (Score:1)
See whether Matlab provides something like that. If it does not., you'll be wasting a lot of time converting it all to C++ and then continuing research on a C++ base., which means half your R&D team would have to be re-educated.
http://mail.python.org/pipermail/python-list/1999- November/016220.html [python.org]
The above link should be o
Re:Can you do modules in Matlab? (Score:1)
Yes you can do this, I believe you can even call MATLAB routines from within this code. The question is, is worth it. Unless you really have multiple ways of using the same code in different ways (say an ode solver) then you just end up with one big function written in C++ and the trival code to call this function in MATLAB.
Software wants to be free (Score:3, Funny)
Choose one language for development. (Score:5, Interesting)
Political: Undoubtedly you will get some changes and fixes that are really easy in one language and a real pain for an other one. So say it takes 5 Minutes in MatLab and could take a week in C++or Vice Versa. Most people don't get this fact especially non professional programmers. So one side group will get a fast change and the other will get the slow change. Thus makes the other group feel like their side isn't as well supported thus making you look really bad.
Business: Maintaining the application will always require people with skill sets in both. Matlab is a rather uncommon skill set while as of right now C++is fairly common. But finding people willing to do both is much harder. As time goes on and as one language leaves common use finding people with these skill sets combined will be very hard and expensive to keep.
Technical: Reported bugs will be need to check on both systems and bug will appear in one system and not the other. But when a bug is reported you will need to check on both systems. And sometime you can easily fix on system and the other requires a major rework. Getting performance on one system to be equivalent to the other will be difficult.
I think you are about to enter a quagmire which you will not come out looking good in. If you do succeed you will probably get a neutral reaction to you work. So it is a Loose/Tie situation. I would spend more time descussing other options. Going one way or the other. Not 2 products that do the same thing but differently.
Re:Choose one language for development. (Score:2, Informative)
Re:Choose one language for development. (Score:2)
It seems that unless Matlab has some sort of relatively cheap VM for their code (don't think they do) then this company should just switch to C++ right way if they want to release a product and make money off of it. But I don't think that's the right answer. You mentioned how there will be different bugs and how one group will get a fast change and the other will get a slow c
This situation has its own advantages (Score:2)
Utilizing two languages in the development process guarantees that however complete the Matlab version is, you still require a port over to C++. This becomes a natural opportunity to refactor and re-analyze the original work as you proceed to your final draft.
What's astonishing to me is that your management seems to tolerate you writing the application twice. If that's really so, please tell me where to contact you
Why do this at all? (Score:5, Insightful)
the Matlab code have a facility with Matlab and are subject matter experts that are doing the heavy lifting (algorithmically speaking). Are the C++ coders the same people? If they're not, can you afford to spend the time/staff to do the porting? Should the
original code even be in Matlab in the first place?
You can call matlab libraries from C++ code, which would seem to be the best of both worlds. Then you wouldn't have to port anything.
Lastly, this is not the kind of question that will get answered well on Slashdot. People who have never used matlab will make assumptions and not understand that it is very unlikely that C++ will have the kind of simulation and and capabilities that Matlab does. Besides, a lot of the time Matlab people (scientists, engineers, quants, etc) may be comfortable working Matlab but not C++, so you do what you can to make it possible for them to work. Also, the suggestion that Mathworks will raise pricing and hold your work hostage is laughable: They already do that, their pricing is crazy.
Re:Why do this at all? (Score:1, Insightful)
You have to realize that the speed at which the developement team works will break in significantly once they start to migrate to c++ (and it will stay below the former speed !!). Matlab is a very powerful tool when it comes to numerical tasks or data evaluation. It is also very forgiving regarding "quick a
Re:Why do this at all? (Score:1)
Unless you want to distribute your application to people who don't have MATLAB. Or is the MATLAB runtime engine [mathworks.com] free to distribute?
Re:Why do this at all? (Score:2)
Absolutely correct. Coincidentally, yesterday at the bookstore I saw a book on network programming in Matlab, which was a big surprise (to my non-Matlab-using mind).
Re:Why do this at all? (Score:2)
This has to be done because not everyone is a scientist with an experimental, discovery mindset. Everyone is also not a C++ programmer (or Java, Perl, C, C#, etc.) and thus proficient at error checking and dealing with a variety of system interaction. Face it, people hire scientists to develop things no one else is doing, but who learned programming as a necessary evil. People hire professional developers to glue or reform that prototype effort into something a customer wants. I found that my college tr
Compile the Matlab (Score:4, Informative)
Re:Compile the Matlab (Score:2)
Many of the built in functions in Matlab are coded in eg C. And as you mention Matlab even has built in functionality for porting code to C from the Matlab scripting language.
I'd advice the OP to go that route. Profile your code and begin by moving over the parts that are eating the majority of your cycles. Design it similar to the
Once
Do it in C++ from the start (Score:3, Interesting)
However, having said that, I must say that I *do* write small prototypes first, only I do it in C rather than other languages. I also use plenty of small scripts, mostly in Perl, to perform auxiliary operations. But the main code that constitutes the algorithms used in the program should be prototyped as close to the end code as possible. There is no way you could develop an algorithm in Matlab or Python or Ruby and consider its testing a validation for a deliverable program written in C++.
Re:Do it in C++ from the start (Score:1)
No offensive, but if the maths your doing is easier than writing a ui then you are either doing very simple maths or very complicated user interfaces!
Seriously, if you're implementing an algorithm to solve a 2nd order differential equation using the finite element method or using the shooting
Re:Do it in C++ from the start (Score:5, Insightful)
Hard? Only if you cannot or don't want to use existing libraries for C++ [diffpack.com]. Now try to find a pre-packaged solution for "they want a button for downloading the data in the same dialog that lets them open an Excel spreadsheet" or any of the infinite other changes one always gets to do in any non-trivial GUI.
Re:Do it in C++ from the start (Score:2)
No offensive, but if the maths your doing is easier than writing a ui then you are either doing very simple maths or very complicated user interfaces!
There are lots of people here who do math/science for a living who disagree with this. Nobody codes algorithms they don't understand, and coding algorithms you undertsand well is trivial in most general purpose languages that include math libraries. Really.
It depends on what you're developing (Score:2)
Develop the algorithms in matlab. Develop the UI in C++. Use matlab to create loadable modules that can be called from your C++ program.
Matlab is not ideal for developing the UI. C++ is not ideal for developing math algorithms.
Beyond that, do what makes sense for your program and developers.
-Adam
Bass ackwards (Score:2)
I would do the UI in Matlab or at least keep the UI in Matlab because that is what the dude probably has. The thing to migrate the UI part in is Java Swing -- you can incorporate custom Java Swing widgets into a Matlab GUI.
Re:Bass ackwards...actually, retrograde (Score:1)
Use ITPP C++ library which maps perfetly to matlab (Score:2, Informative)
Been there, Done That... (Score:4, Insightful)
I would continue to develop algorithms in Matlab, and use the Matlab compiler to move the algorithms to C++ for integration with the C++ "presentation layer" code. Then compile and ship an all-C++ product.
Drop Matlab (Score:1)
We need more information (Score:2)
I don't see how to give a meaningful answer to the general questions asked here without some more context.
For what it's worth, I write high-performance, somewhat high-level maths libraries in C++ for a living. You can do a lot of things more easily in C++ than some people would expect, particularly if you have access to the right libraries (someone already mentioned diffpack, and there are also ports of BLAS and LAPACK for linear algebra, and many others). Of course a dedicated tool will usually be better
Re:We need more information (Score:2)
sqrt(x * x + y * y)
Not sure how many ways there are to do that unless you roll your own sqrt() function.
Care to expand on it?
Re:We need more information (Score:2)
That's exactly not the way to do it: consider what happens if one of x and y is much greater than the other, as for example if you have a vector very slightly misaligned with the x- or y-axis.
To avoid this problem, you can rearrange as x*sqrt(1+(y/x)*(y/x)), or the same but pulling y out, depending on which is bigger. (In practice you'd calculate y/x only once, of course.)
Re:We need more information (Score:2)
obviously calculating the subtractions first. And for 3D you just add in "+ (z2 - z1) * (z2 - z1)".
Not sure why you need to re-arrange the equation especially since the normal version
contains 2 subtractions and 2 multiplications whereas yours contains 1 division, 2 mults
and 1 addition. Can't see how that would be faster.
Re:We need more information (Score:2)
Speed isn't the point; accuracy is. I'm afraid I don't have time right now to explain the details, but please refer to a good textbook such as Numerical Recipes and you'll find all the background there.
Re:We need more information (Score:2)
Re:We need more information (Score:2)
Pythagoras is accurate. A naive numerical implementation is not.
You know, this whole discussion is exactly what I was talking about when in my original post I wrote:
Re:We need more information (Score:2)
Re:We need more information (Score:2)
The point isn't whether division is more accurate than multiplication under normal circumstances, it's the vulnerability to destructive overflow/underflow. If that happens, doing things the naive way will be very much less accurate than a proper implementation based on the alternative approach I gave.
Really, this is elementary stuff. The fact that you keep missing the point doesn't mean there isn't a point, it just means you're not sufficiently familiar with the field to understand the danger. Please go a
Re:We need more information (Score:2)
FYI I do 3D graphics programming so I do have a clue about this but I guess we'll just have to agree to disagree.
Re:We need more information (Score:2)
I could have guessed that: your focus throughout this discussion has been on speed rather than accuracy. That's fair enough in your line of work, but not really relevant to this debate, where "serious" maths appears to be the order of the day.
We'll obviously have to agree to disagree on this one, so I leave you with one final thought: if you're not missing anything and I'm the one who doesn't understand, then why does Numerical Recipies in
Don't drop MATLAB (Score:4, Interesting)
Re:Don't drop MATLAB (Score:2)
I have to agree with this statement. Of course, it all depends on the kind of math you are doing. In general, MATLAB is better for prototyping new math-intensive algorithms (e.g. matrix math) and it might make sense to have
Do the Prototype then Drop Matlab (Score:1)
I would agree with the statement that the prototype algorithms could be completed in Matlab. If you do that, then complete the algorithm development in Matlab. You really don't want to switch languages mid-way through algorithm development.
The practical problem that I have seen more than once, in a research situation, is that the researchers try to complete the application in Matlab. The result is usually a disaster for a full-fledged high-performance application. Matlab does math well, but other th
Compiler (Score:2)
Similar Situation (Score:5, Insightful)
Re:Similar Situation (Score:3, Insightful)
Then Matlab must have improved a lot since I last used it (Version 4). A problem I had was that matrices were well behaved with small test cases, but became ill conditioned when we used actual worki
Re:C++ (Score:3, Insightful)
Good question. I'll answer that if you answer this: every time I get to a street intersection, should I turn right, turn left, or go straight ahead? The answer to both is: it depends. Where do you want to go? If the argument is a basic type that will not be changed, use a value, if it needs to be changed, use a reference, if it's a large structure or array, use a pointer.
A language that ignores
Re:C++ (Score:2)
It's funny, because I think pointers are essential to programming. That's because in my software projects I usually start with a sketch of the data structures. I draw in a piece of paper all the structures (or "tables" as the database people like to call them). Then I draw the relationships among those structures, by drawing lines with arrowheads from one structure to another. That way it's immediately ob
Matlab's prices (Score:2)
Depends on Program Complexity (Score:1)
Free Matlab work-alikes? (Score:2)
There are alternatives to Matlab that are similar, and can be resold in commercial
apps without any license or royalty issues.
I would personally use Python / NumPy & SciPy / Matplotlib in a heartbeat. There are even
tutorials for people who are used to Matlab on the subtle syntax differences.
You can even use SWIG (or Boost_python) to integrate your high level code with your
low level code in the same application. You can then distribute the result on
Windows, Mac or Linux with different bundling or freezi
check out Star-P (Score:1)
Prototype in one language first (Score:1)
It also allows you to ensure that the prototype is rewritten when being implemented. It is not often that prototype design choices are the best for production, so needing to port guarantees that all code is revised, and you have a working implementation to give test results that the product sho
keep 2 languages (Score:1)
a math-centric or faff-minimising prototyping environment is crucial whilst constructing the math models which you'll later be putting into Production. you want to absolutely minimise the Drag of the tool on the thought process. you can use MatLab or Excel or a piece of paper.
then take the result as being the Specification (Logical) which will feed into your development. your Production-ready code's particular Phys
Prototype in the most straightforward language (Score:1)
This sounds like a reasonable prototyping/porting approach, really. I do much the same thing. For several years, I've been working on a programming language/calculating tool called Frink [futureboy.us], and when I'm trying to write new code that may eventually be part of Frink, say, efficiently calculating the Riemann Zeta function, or factoring large numbers, I'll usually first write the prototype function in the Frink language itself, and get it working. It's much less effort, and usually far more legible, to write