473,790 Members | 2,850 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++: Is it a powerful language?

Why is C++ a powerful language? Does it fit for engineering purpose? I
mean, for doing matrices manipulation, numerical computing, solving
equations, and, eventually, for file streaming. Should I migrate
direct for C++, by-passing the C?

Thanks,
Jul 22 '05 #1
19 1724
Roberto Dias wrote:
Why is C++ a powerful language?
Yes.
Does it fit for engineering purpose? I
mean, for doing matrices manipulation, numerical computing, solving
equations,
You'll need a good math library, the standard libraries for C and C++
are notably lacking in rigorous numerical functions (like matrices,
etc..) but there are some out there.
eventually, for file streaming.
This sort of operatal application is what C and C++ excel at.
Should I migrate
direct for C++, by-passing the C?


If you're working on an implementation that has a good C++ compiler]
existant (and most "general purpose" processosrs do), I would say yes.
There's no real advantage of C and a lot of strong reasons to do C++.
The performance is going to be the same, but the code will be easier
and more maintainable in C++.

The only argument for C is for certain embedded implementations where
only a minimal C implentation is practica.
Jul 22 '05 #2
Roberto Dias wrote:
Why is C++ a powerful language?
Because it was designed as such.
Does it fit for engineering purpose?
It does. Or, rather, it is. Whatever.
I
mean, for doing matrices manipulation, numerical computing, solving
equations, and, eventually, for file streaming. Should I migrate
direct for C++, by-passing the C?


I don't know if you should _migrate_ (from where?), but if you do migrate,
you do not need to study C as a pre-requisite. Knowing the differences
between them helps, and knowing C as a language can be useful sometimes,
but you can definitely pick that all up along the migration path.

V
Jul 22 '05 #3
> Why is C++ a powerful language?

It's getting compiled to "C" and not much is getting added. (Pointers
to functions of structures, which are classes in C++ ...)
Does it fit for engineering purpose? I
mean, for doing matrices manipulation, numerical computing, solving
equations, and, eventually, for file streaming. Should I migrate
direct for C++, by-passing the C?


lol. You can write C++ programs, and if speed is a problem, you can
use C functions in your classes like:

// esternal "C" compiling of this function
extern"C"
{
DoExternFastMat h()
{}
}

// C++ class wrapper that calls a fast function
class A
{

inline DoSomeFastMath( )
{
DoExternFastMat h();
}
}

You can write crappy C++ code, you can do this in C, in FORTRAN and in
ASM.
If you need samples about slow and buggy, code, let me know. I've got
lot's if it ;)

-Gernot
Jul 22 '05 #4
Gernot Frisch wrote:
Why is C++ a powerful language?

It's getting compiled to "C"


What are you talking about?
and not much is getting added. (Pointers
to functions of structures, which are classes in C++ ...)

Does it fit for engineering purpose? I
mean, for doing matrices manipulation, numerical computing, solving
equations, and, eventually, for file streaming. Should I migrate
direct for C++, by-passing the C?

lol. You can write C++ programs, and if speed is a problem, you can
use C functions


Why would it be necessary? You seem to have a perverted view of what
makes a program fast.
[...]

Jul 22 '05 #5
> I don't know if you should _migrate_ (from where?), but if you do
migrate,
you do not need to study C as a pre-requisite. Knowing the
differences
between them helps, and knowing C as a language can be useful
sometimes,
but you can definitely pick that all up along the migration path.


Indeed, I read the book "Teach yourself "C" in 21 days" (in 5 days)
and there was a small topic about C++ in the end. So, I wrote "C++"
like:
for (int i; ...)
and
class A
{
public:
void foo();
}

until I got a job, doing C++ programming. Where suddenly I had to
reqrite a template list container. It looked so cryptic to me back
then...
If I can give one advice: Start C++ by learning C++. Noothing more,
nothing less. Every other thing you learn dueing your learning process
will spoil your code-style and result in curses when maintaining old
code.

Just my 0.02$,
Gernot
Jul 22 '05 #6

"Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag
news:rI******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Gernot Frisch wrote:
Why is C++ a powerful language?

It's getting compiled to "C"


What are you talking about?


class A
{
void foo();
}

gets:
struct A
{
void* vtable[];
}
A__foo();
A.vtable[0] = A__foo();

am I wrong??

lol. You can write C++ programs, and if speed is a problem, you can
use C functions


Why would it be necessary? You seem to have a perverted view of
what
makes a program fast.


Well, using class functions will result in a vtable lookup for the
function. It's not much time, but it _is_ time. When programming for
mobile devices some critical sections can be speed up by leaving this.
Not nic style, however - avoid wherever possible.
As said: Most time it's not the language that makes a program slow,
it's the programmer.

Jul 22 '05 #7
Gernot Frisch wrote:
"Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag
news:rI******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Gernot Frisch wrote:
Why is C++ a powerful language?
It's getting compiled to "C"
What are you talking about?

class A
{
void foo();
}

;
gets:
struct A
{
void* vtable[];
}
A__foo();
A.vtable[0] = A__foo();

am I wrong??
Hell, yes. What vtable? In fact, in most cases there would be no 'foo'
because the function can never be called -- it's private and the class
has no other members or friends. So, there will be no function _at_all_.
lol. You can write C++ programs, and if speed is a problem, you can
use C functions


Why would it be necessary? You seem to have a perverted view of
what
makes a program fast.

Well, using class functions will result in a vtable lookup for the
function.


No, it won't. I guess it's back to textbooks for you. Or just compile
your program to get an ASM output and analyse it.
It's not much time, but it _is_ time. When programming for
mobile devices some critical sections can be speed up by leaving this.
Not nic style, however - avoid wherever possible.
As said: Most time it's not the language that makes a program slow,
it's the programmer.


<shrug>
Jul 22 '05 #8
Gernot Frisch wrote:

"Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag
news:rI******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Gernot Frisch wrote:
Why is C++ a powerful language?
It's getting compiled to "C"
What are you talking about?


class A
{
void foo();
}

gets:
struct A
{
void* vtable[];
}
A__foo();
A.vtable[0] = A__foo();

am I wrong??


Yes and no.
It could be that way, it need not be that way.
Actually: Nowhere it is written down, that C++ *has to be compiled* to C.
It can be done, it has been done, but most compilers actually don't do it.
lol. You can write C++ programs, and if speed is a problem, you can
use C functions


Why would it be necessary? You seem to have a perverted view of
what
makes a program fast.


Well, using class functions will result in a vtable lookup for the
function. It's not much time, but it _is_ time.


Only in the case of polymorphism (if I assume at the moment that the
compiler is indeed using a vtable for virtual functions). Ordinary
function calls are resolved the same way as C functions would.

But in case of virtual functions: Well, you don't make functions
virtual just for fun. There is a reason for it. And the reason is
polymorphism. Now if you try to implement polymorphism in C (that
is without virtual functions) you end up with something either
very similar to what the C++ compiler does or with something that
is
a) harder to maintain
b) slower then what the C++ compiler can do.

So in case of ordinary function calls there is no difference to C.
In case of polymorphic function calls, C++ can do better then an
average C programmer does. At best C++ and C are on an equal scale,
but C++ is never slower then C.

--
Karl Heinz Buchegger
kb******@gascad .at
Jul 22 '05 #9

"Gernot Frisch" <Me@Privacy.net > wrote in message
news:35******** *****@individua l.net...

"Victor Bazarov" <v.********@com Acast.net> schrieb im Newsbeitrag
news:rI******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Gernot Frisch wrote:
Why is C++ a powerful language?
It's getting compiled to "C"


What are you talking about?


class A
{
void foo();
}

gets:
struct A
{
void* vtable[];
}
A__foo();
A.vtable[0] = A__foo();

am I wrong??

lol. You can write C++ programs, and if speed is a problem, you can
use C functions


Why would it be necessary? You seem to have a perverted view of
what
makes a program fast.


Well, using class functions will result in a vtable lookup for the
function. It's not much time, but it _is_ time. When programming for
mobile devices some critical sections can be speed up by leaving this.
Not nic style, however - avoid wherever possible.
As said: Most time it's not the language that makes a program slow,
it's the programmer.


Oh, my goodness. Which C++ books have you been reading?
You have some serious misconceptions. I suggest a visit
to www.accu.org and a perusal of the book reviews, followed
by selection and study of one or more of the recommended
books.

-Mike
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2485
by: Brian Kelley | last post by:
def res(): try: a = 1 return finally: print "do I get here?" res() outputs "do I get here?"
7
4314
by: Dan V. | last post by:
Still struggling with css. Anyone know how to put a tope background colour (matches the right part of the banner image) that stretches to the max. size of the window like the main div? My header has a big black 'box' at the top right. I would like to keep black as the main background colour of the header div though. Unless someone knows another way to make my header look good. Please see: http://officeactivate.com/schuit/
8
3625
by: Huihong | last post by:
Please check out our newly released source code search engine here, http://www.codase.com e.g., search socket method call, http://www.codase.com/search/call?name=socket&owner=&lang=*&type=&parameters=&obj= Rather than treating code as text, Codase understands programming languages, and treats code as code, the way it's supposed to be. This unique and syntax-aware approach provides the most accurate and detailed search results with...
2
1214
by: Atlantis11500 | last post by:
Hi guys, as I have downloaded the latest beta2 version of VC 2005. I found that the IDE is not as powerful as vc#. My question is whether vc has lost the important position?
4
1560
by: PontiMax | last post by:
Hi. Not sure whether this is the right group but I am looking for some powerful asp.net grid control. The grid should be editable, allow some header adjustments (e.g. multi-part row and column headers) and... it should be fast! ;-) Seriously: I've bought a grid control that is very capable - but the sluggish response time is agony... :-(
2
1122
by: PyPK | last post by:
Is there a Command line parser in python that can: 1. resolve conflicts 2. specify something like requires 3. and smart for ex: python test.py --a --b --c --d Case 1: If 'a' is an option 'b' or 'c' cannot be specified.
9
2727
by: Frederick Gotham | last post by:
Let's assume that we're working on the following system: CHAR_BIT == 8 sizeof( char* ) == 4 (i.e. 32-Bit) Furthermore, lets assume that the memory addresses are distributed as follows: 0x00000000 through 0xFFFFFFFE : Valid byte addresses
28
2642
by: steve yee | last post by:
i think c should adapt c++ template standard, as well as namespace. if so, c can replace c++ in many cases.
3
2533
by: aspmonger | last post by:
Hello, I really believe that IE 6 has a new (intentional?) bug that severely limits the capability of dhtml and cross domain scripting. Yesterday, I read an interesting article about the subject and it only supported my claim. The article explained why Microsoft will not be letting the IE DHTML Implementation get any more powerful than it already is. Microsoft has realized that an experienced DHTML developer can create a web application that...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.