Skip to main content

Notice

If you are using a Hotmail or Outlook email address, please change it now, as Microsoft is rejecting all email from our service outright.
Topic: How much useful is C++ in algorithm research? (Read 10726 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How much useful is C++ in algorithm research?

Reply #25
When dist10 (iso demonstration code) was written, there was no C++ compliant compiler.

Even today, you can be quite sure that someone has a C compliant compiler, but you can not be sure about C++ compliance.

How much useful is C++ in algorithm research?

Reply #26
Quote
Probably not. A C-only compiler might be able to optimize more easily than a C++ one because it could make assumptions the latter cannot.

Actually, it's mostly the opposite. For example, the use of the 'const' keyword helps compilers optimizing. That one was added in C99, but still in C++ you can overload finctions based on const so that each version is as fast as possible given how it will be used.

How much useful is C++ in algorithm research?

Reply #27
Quote
When dist10 (iso demonstration code) was written, there was no C++ compliant compiler.

Even today, you can be quite sure that someone has a C compliant compiler, but you can not be sure about C++ compliance.

Discussion is silly. For "algorithm research" there's nearly no difference between C++ and C.
Both are relatively useless for an effective research. When testing algorithms, you don't
want to care about memory management, pointers etc.

For "algorithm research" engineers typically use programs like Mathematica or Mathlab.
Often you find the test examples as *.m files. There are a lot of powerful library functions,
you can use this within some seconds. Programming that in C or C++ will take weeks or
months.
Diocletian

Time Travel Agency
Book a journey to the Diocletian Palace. Not today!

How much useful is C++ in algorithm research?

Reply #28
Quote
For "algorithm research" engineers typically use programs like Mathematica or Mathlab.
Often you find the test examples as *.m files. There are a lot of powerful library functions,
you can use this within some seconds. Programming that in C or C++ will take weeks or
months.

This is not entirely true.

For signal processing purposes, Matlab is great, of course.  Digital filter design, matrix operations, plotting (and many more things) are straightforward.

However, as soon as you need iterative algorithms with simple operations (those which can't be parallelized into big matrices), the M scripts become awfully slow (~ 3000 times slower than C) !  For such algorithms I think experimenting in either Quickbasic (QB != VB) or C, is better (depending on your experience).

For algorithms which do few maths and manipulate a lot of data, Java might be a good choice for experimenting:  hashtables and a lot of primitives are already there for you.

Of course, this all depends a lot on which languages you're comfortable with.

How much useful is C++ in algorithm research?

Reply #29
I remember people still using Fortran to design algorithms.

Why didn't anyone mention Pascal? It's much better than QBasic.
ruxvilti'a

How much useful is C++ in algorithm research?

Reply #30
Quote
I remember people still using Fortran to design algorithms.

Why didn't anyone mention Pascal? It's much better than QBasic.

You're right, the Borland Turbo Pascal was a great environment !

I was not talking about QBasic though, but about the "pro" version which QuickBasic.  With the latter you could create EXE files, and the interpretor mode was much faster than in QBasic.

To draw a vertical greyscale gradient on the screen, just use:

Code: [Select]
screen 13 : cls
for i% = 0 to 63
  OUT &H3C8, i%  ' palette index
  OUT &H3C9, i%  ' RED component
  OUT &H3C9, i%  ' GREEN component
  OUT &H3C9, i%  ' BLUE component
next i%
for y%=0 to 199
  line(0,y%)-(319,y%),y% mod 64
next y%


All this, by heart..  Ah, memories 

How much useful is C++ in algorithm research?

Reply #31
I don't understand why people would hate c++.  I'm just getting into it, but already it seems much improved over plain c.  Take stupid things like I/O.  Why should i have to specify the data type I'm going to print TWICE within each printf statement (once as %c/d/lf etc and again when the actual variable is loaded).  c++ wisely gets rid of that.  Likewise why should there be completely different commands for dealing with strings vs everything else?

Maybe it gets worse once you're in deeper, but c++ just seems better thought out to me.

How much useful is C++ in algorithm research?

Reply #32
Oh yes, it makes much more sense to do IO with overloaded freaking BITSHIFT operators whilst at the same time, making any formatting of the output a huge pain in the rear.  I swear to God, somebody was on 'shrooms when they came up with that revealation.  OTOH, Saying that C++ is better than C is probably true.  The single line // comments were definately a nice addition.  But it's also like saying "sleeping on a bed of rocks is much less painful than sleeping on a bed of nails."

Now, to be fair, I'm only this ornery about C++ because I've had to use it a lot lately.  Also, of the thirty or so languages I've had contact with over the years, there's been only two that I actually liked, and of the remainder, only a few that I didn't actively hate and bitch about.
I am *expanding!*  It is so much *squishy* to *smell* you!  *Campers* are the best!  I have *anticipation* and then what?  Better parties in *the middle* for sure.
http://www.phong.org/

How much useful is C++ in algorithm research?

Reply #33
Quote
Why didn't anyone mention Pascal? It's much better than QBasic.

I'd consider and have used Delphi (Object Pascal) for professional work.

IMHO Object Pascal is a lot cleaner than C++

How much useful is C++ in algorithm research?

Reply #34
Most of the algorithm books were published at a time when C++ was not a stable language. For what it's worth, many of these algorithms would have been published originally in Fortran or PL/I, which were the linguae francae of the development community before C came along. The same is true of the JPG source code: at the time it was written, the C++ standard was evolving rapidly, and C++ compilers were not available on many DSP and embedded controller platforms.

There is absolutely no reason that C++ code should run any slower than C code, given that C is an almost strict subset of C++.

BC 5.1 is based on very old compiler technology. Although Borland compilers used to compete well with Microsoft compilers, they have been stagnant for quite some time. The bottom line, BC compiler optimization is very poor compared to current generation Microsoft compilers (particularly wrt/ floating point optimizatons, and instruction scheduling optimizations).

How much useful is C++ in algorithm research?

Reply #35
Quote
Oh yes, it makes much more sense to do IO with overloaded freaking BITSHIFT operators whilst at the same time, making any formatting of the output a huge pain in the rear.  I swear to God, somebody was on 'shrooms when they came up with that revealation. 

It makes sense when you realize what problem they were trying to solve with all that crap.  They wanted a typesafe replacement for printf that could do some compile-time error checking.  With printf, you have no way to check at compile time whether the arguments passed to it are of the correct type, or even if you have passed the right number of arguments.  The new IO constructs fix this (in the most longwinded way possible).

I agree that the standard IO stuff is way too complicated when working with simple strings;  I still use printf in these cases.  However, one really cool thing is that since you can overload the bitshift operators for your own classes, you can do stuff like this:

cout << myObject;

And not with just cout, but with anything that can take an ostream. 


The bitshift operators were chosen simply because they look pretty and for most objects there is no obvious bitshift operation that can be performed.  It's also in keeping with C++ style to further obfuscate code by overloading yet another operator.

How much useful is C++ in algorithm research?

Reply #36
Quote
There is absolutely no reason that C++ code should run any slower than C code, given that C is an almost strict subset of C++.


That would depends on how you write the code in C++.. There is a lot of what NOT to do in C++ for algorithms.

 
SimplePortal 1.0.0 RC1 © 2008-2020