I have been reading a book that focuses on understanding the intrinsic types
of C++ in depth. The author's mentality is this: "Understand the intrinsic
types, then learn the std types as needed later", but I have been reading
the stroustrup (spelling?) book and he says that it is much better to learn
the standard library first as a beginner, and then worry about the intrinsic
types afterwards.
So there is no doubt that you need to have a full comprehension of both, but
as a general rule, which should be relied upon more? For example, in many
cases you can use an array to hold a data set, but you could also use a
standard container, say the set is of a static size now, so an array would
seem like the best choice (speed/size), but for extendibility and
maintenance, wouldn't an object be a better choice?
TIA,
Jeremy 5 3924
"Jeremy Cowles" <jeremy.cowle s[nosp@m]asifl.com> wrote... I have been reading a book that focuses on understanding the intrinsic
types of C++ in depth. The author's mentality is this: "Understand the intrinsic types, then learn the std types as needed later", but I have been reading the stroustrup (spelling?)
His name is spelled beginning with a capital 's': Stroustrup.
book and he says that it is much better to learn the standard library first as a beginner, and then worry about the
intrinsic types afterwards.
There are intrinsic types and there are intrinsic types. Understanding
of 'int', 'char', 'short', 'long', their unsigned equivalents, 'bool',
'float' and 'double', is important very soon. Understanding pointers and
references is also important, although somewhat more advanced. You may
put arrays aside for a little bit, until you're comfortable with pointers
and some simple standard containers (vectors and strings).
So there is no doubt that you need to have a full comprehension of both,
but as a general rule, which should be relied upon more?
It is not the right question to ask. Should you rely more on your legs
or on your arms? When learning to drive, should you learn to brake first
or to steer? Like in many other areas, both are equally important.
For example, in many cases you can use an array to hold a data set, but you could also use a standard container, say the set is of a static size now, so an array would seem like the best choice (speed/size), but for extendibility and maintenance, wouldn't an object be a better choice?
The answer is extremely simple and extremely complex: it depends. What
kind of data is the set of? Does its size change dynamically? Do you
perform more of random look-ups or just iterate through it? Et cetera.
Victor
"Jeremy Cowles" <jeremy.cowle s[nosp@m]asifl.com> wrote in message news:<zi******* *************@t wister.tampabay .rr.com>... I have been reading a book that focuses on understanding the intrinsic types of C++ in depth. The author's mentality is this: "Understand the intrinsic types, then learn the std types as needed later"
Dinosaurs became extinct. That attitude will do the same in due
course.
but I have been reading the stroustrup (spelling?) book and he says that it is much better to learn the standard library first as a beginner, and then worry about the intrinsic types afterwards.
So there is no doubt that you need to have a full comprehension of both, but as a general rule, which should be relied upon more? For example, in many cases you can use an array to hold a data set, but you could also use a standard container, say the set is of a static size now, so an array would seem like the best choice (speed/size), but for extendibility and maintenance, wouldn't an object be a better choice?
Yes. Maintenance and clarity are always important. If your code is any
good, at some point in the future someone will want its functionality
extended. And it may well be some other programmer who has to do that.
Size and speed are never an issue unless and until such time as you
have proved that you cannot meet your (or your customer's)
requirements without making the code faster / smaller.
GJD
"Gavin Deane" <de*********@ho tmail.com> wrote in message
news:6d******** *************** ***@posting.goo gle.com... Size and speed are never an issue unless and until such time as you have proved that you cannot meet your (or your customer's) requirements without making the code faster / smaller.
Not necessarily. Sometimes it will be clear from the outset that for a
particular application speed is more important than size, or size is more
important than speed, and your design will reflect this.
"Bob Jacobs" <ne****@robertj acobs.fsnet.co. uk> wrote in message news:<bh******* ***@newsg4.svr. pol.co.uk>... "Gavin Deane" <de*********@ho tmail.com> wrote in message news:6d******** *************** ***@posting.goo gle.com... Size and speed are never an issue unless and until such time as you have proved that you cannot meet your (or your customer's) requirements without making the code faster / smaller.
Not necessarily. Sometimes it will be clear from the outset that for a particular application speed is more important than size, or size is more important than speed, and your design will reflect this.
Fair point. But I think I can wriggle out of it :)
In such cases I would still initially concentrate on producing clear,
understandable and correct code. The I would take that code and
optimise it as necessary. I think it is important to get the code
working first. If you optimise something before it works correctly,
you run the risk of needing to make a change later that slows / bloats
the code unacceptably. Your earlier effort is effectively wasted.
You are quite right that there are times when design decisions will be
influenced by speed / size requirements. But those decisions will
probably be more fundamental that the OP's example of "should I use an
array or container."
GJD
"Gavin Deane" <de*********@ho tmail.com> wrote in message
news:6d******** *************** ***@posting.goo gle.com... "Bob Jacobs" <ne****@robertj acobs.fsnet.co. uk> wrote in message
news:<bh******* ***@newsg4.svr. pol.co.uk>... "Gavin Deane" <de*********@ho tmail.com> wrote in message news:6d******** *************** ***@posting.goo gle.com... Size and speed are never an issue unless and until such time as you have proved that you cannot meet your (or your customer's) requirements without making the code faster / smaller.
Not necessarily. Sometimes it will be clear from the outset that for a particular application speed is more important than size, or size is
more important than speed, and your design will reflect this.
Fair point. But I think I can wriggle out of it :)
In such cases I would still initially concentrate on producing clear, understandable and correct code.
Of course, but it's not an either-or. You should have clear understandable
code either way.
The I would take that code and optimise it as necessary. I think it is important to get the code working first.
We're talking about two different things. You're talking about optimisation
and I'm talking design. I just felt it was worth correcting your statement
that size and speed are never an issue until you've shown that a requirement
can't be met. Size and/or speed are often an issue right from day one, which
is why I said that your design will, if required, take this into account. It
would be foolhardy to design without considering speed if speed happens to
be important, and then to go back and rework after testing to put right what
you should have done at the design stage anyway. And it would cripple most
projects to do so. But this, as I said, is design not optimisation.
If you optimise something before it works correctly, you run the risk of needing to make a change later that slows / bloats the code unacceptably. Your earlier effort is effectively wasted.
Design /and/ have it working correctly, then optimise.
You are quite right that there are times when design decisions will be influenced by speed / size requirements. But those decisions will probably be more fundamental that the OP's example of "should I use an array or container."
Quite possibly. I suspect we're in agreement, it was the use of never in
your original statement that I thought needed correcting ;-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ernesto |
last post by:
Hi everybody:
I have the following typedefs:
typedef unsigned char UCHAR;
typedef unsigned char BYTE;
I am implementing a class String with the following operators overloaded:
String& operator+ (const UCHAR& myChar);
|
by: xmail123 |
last post by:
Hi,
As was pointed out whatever you return from a WebMethod needs to be
serializable to SOAP. An ArrayList is not serializable. I will be
needing to return other data types from web methods. Is there a
document, or can some one list those types that are not serializable
and the syntax for converting them?
Thanks
|
by: Zach |
last post by:
When it is being said that, "value types are created on the stack or inline as part of an
object". If a value type is created in an object, and that object is being
called, the value type in that object, is still created on the stack, I
would say, so I don't understand this inline business. Apart from the fact
that it is my understanding that "inline" as it exists in C++ doesn't exist in C#. Could someone please shed some light on this...
|
by: Edward Diener |
last post by:
In the doc regarding __value classes, under Primitive Types, I read:
"Generally, the C++ types and their __value class equivalents are
interchangeable in Managed Extensions."
What exactly does this mean ?
Does it mean that one can pass or return a C++ primitive to a function for
the equivalent __value class and vice-versa ?
Does this mean that one can assign the value of a C++ primitive type to the
|
by: Alek Davis |
last post by:
Hi,
Is it possible to access intrinsic ASP objects, such as Request, from a .NET
class. Say, I have a .NET library exposed via a COM or COM+ wrapper. Can
this library retrieve the request info (basically, server variables exposed
via the Request object), when it is invoked from a traditional ASP (not
ASP.NET) application? Any ideas? Thanks in advance.
Alek
| |
by: Gary Nastrasio |
last post by:
If I compile with /clr:safe, which is exactly meant by saying I can't
use "Native Types" in my code? Is a native type something such as
float, short, or int?
Thanks,
Gary
|
by: Steven Livingstone |
last post by:
I've just blogged some stuff on Nullable types in net 2.0.
http://stevenr2.blogspot.com/2006/01/nullable-types-and-null-coalescing.html
Question however as to why you can't simply get an implcit conversion from a
..Net value type to to a Sql Server data type rather than having to use null
cheked and DBNull.Value ?
Does anyone have some explanation as to why this is so tricky as to be
included?
|
by: ballpointpenthief |
last post by:
At the moment, I only write functions which accept pointers as
arguments in order to change a value, but I've realised it would often
be a lot more effiecient to pass a pointer rather than an actual
object.
I know this question is a bit vague, but I was wondering about any
rules / guidelines / style issues, for when to use pointers, and when
not to, in your function parameters?
I'm also interested in any grey areas, or even off-topic...
|
by: simudream |
last post by:
//hi maybe helpful others can look at this code and
//tell me why the class code won't behave like
//intrinsic types with post and pre increment
//Version: 1.00
#include <iostream>
using std::cout;
using std::endl;
using std::ostream;
|
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...
|
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...
| |
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...
|
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,...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |