| |
 |
|
| Computers Forum Index » Computer Languages (Misc) » New release of the Dynace OO extension to C... |
|
Page 6 of 8 Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8 Next |
|
| Author |
Message |
| bartc... |
Posted: Wed Jul 22, 2009 2:59 pm |
|
|
|
Guest
|
"Juha Nieminen" <nospam at (no spam) thanks.invalid> wrote in message
news:zzB9m.41$qS6.6 at (no spam) read4.inet.fi...
Quote: bartc wrote:
You almost persuaded me to have another look at C++ myself. Almost, then
I realised that as soon as I had another look at it's ghastly syntax and
general incomprehensibility, I would go back to C with considerable
relief.
I honestly can't understand what you are talking about. I'm sorry, but
it just sounds like you are being really prejudiced.
A little.
Quote: Consider this small program:
//----------------------------------------------------------------------
#include <algorithm
int main()
{
int table1[] = { 5, 3, 10, 35, 4, 1, 40, 1, 8, 3 };
double table2[] = { 20.2, 24.6, 12, 1, -4.2, 5.5, -20, 20.2, 1, 0 };
std::sort(table1, table1 + 10);
std::sort(table2, table2 + 10);
// print the tables here, or whatever
}
//----------------------------------------------------------------------
Even though the standard C library also provides a sorting utility
(qsort), consider how much more code you have to write in order to use
it. (Also consider how much more inefficient it will be because of that.)
Exactly what is so "ghastly" and "incomprehensible" here? To me this
looks very simple and straightforward (well, assuming you understand
what "table1 + 10" means, but that should be rather obvious to an
experienced C programmer). Definitely much simpler than the equivalent C
program.
Like I said, you make an excellent case for C++. Maybe you should write a
book.
I first came across C++ source when trying to decode MFC header files, and
decided they weren't designed to be understood by a mere human (possibly
they weren't).
More typical C++ does still appear much more intimidating than your simple
example (some of us just can't grok classes and object hierarchies and
what-not).
I understand that much of the power of C++ is the ability to define all
these neat extensions and datatypes, and make them appear as though they are
built-in to the language.
The trouble is the language used for defining them (with the necessary bells
and whistles) is the same language used for everyday programming, with
considerable cross-over. It seems like a language-implementation language,
used as it's own language, if that makes sense..
--
Bartc |
|
|
| Back to top |
|
|
|
| Vladimir Jovic... |
Posted: Wed Jul 22, 2009 3:36 pm |
|
|
|
Guest
|
Juha Nieminen wrote:
Quote: bartc wrote:
You almost persuaded me to have another look at C++ myself. Almost, then
I realised that as soon as I had another look at it's ghastly syntax and
general incomprehensibility, I would go back to C with considerable relief.
I honestly can't understand what you are talking about. I'm sorry, but
it just sounds like you are being really prejudiced. It sounds like
immediately when you see some extra angle brackets (<something>) or
double colons (:  you immediately give up telling yourself that "this
is incomprehensible", without even seriously wanting to give it a try.
He probably thinks of something like this (a random example from the
boost library) :
template<
class Archive,
class Key,
class HashFcn,
class EqualKey,
class Allocator
Archive & ar,
BOOST_STD_EXTENSION_NAMESPACE::hash_map<
Key, HashFcn, EqualKey, Allocator
Quote: &t,
const unsigned int file_version
){
boost::serialization::stl::load_hash_collection<
Archive,
BOOST_STD_EXTENSION_NAMESPACE::hash_map<
Key, HashFcn, EqualKey, Allocator
Quote: ,
boost::serialization::stl::archive_input_unique
Archive,
BOOST_STD_EXTENSION_NAMESPACE::hash_map<
Key, HashFcn, EqualKey, Allocator
Doesn't look good, does it?
Quote: There are quite many things which are vastly simpler to express in C++
than in C. Just as a fair example of a feature provided by both
languages, let's take sorting. Consider this small program:
Using these library is nice, as you said |
|
|
| Back to top |
|
|
|
| Bo Persson... |
Posted: Wed Jul 22, 2009 5:23 pm |
|
|
|
Guest
|
bartc wrote:
Quote: "Juha Nieminen" <nospam at (no spam) thanks.invalid> wrote in message
Consider this small program:
//----------------------------------------------------------------------
#include <algorithm
int main()
{
int table1[] = { 5, 3, 10, 35, 4, 1, 40, 1, 8, 3 };
double table2[] = { 20.2, 24.6, 12, 1, -4.2, 5.5, -20, 20.2, 1,
0 }; std::sort(table1, table1 + 10);
std::sort(table2, table2 + 10);
// print the tables here, or whatever
}
//----------------------------------------------------------------------
Even though the standard C library also provides a sorting utility
(qsort), consider how much more code you have to write in order to
use it. (Also consider how much more inefficient it will be
because of that.) Exactly what is so "ghastly" and
"incomprehensible" here? To me
this looks very simple and straightforward (well, assuming you
understand what "table1 + 10" means, but that should be rather
obvious to an experienced C programmer). Definitely much simpler
than the equivalent C program.
Like I said, you make an excellent case for C++. Maybe you should
write a book.
I first came across C++ source when trying to decode MFC header
files, and decided they weren't designed to be understood by a mere
human (possibly they weren't).
That is generally considered horrible C++ code, partly because it
wants to be compatible with ancient pre-standard extensions used to
code Windows 9x and even Windows 3.x.
No-one understands that code. Not even Microsoft!
Quote:
More typical C++ does still appear much more intimidating than your
simple example (some of us just can't grok classes and object
hierarchies and what-not).
I understand that much of the power of C++ is the ability to define
all these neat extensions and datatypes, and make them appear as
though they are built-in to the language.
The trouble is the language used for defining them (with the
necessary bells and whistles) is the same language used for
everyday programming, with considerable cross-over. It seems like a
language-implementation language, used as it's own language, if
that makes sense..
That's not the trouble, that's the beauty of the language. It is
entirely by design that many standard features are described with a
library interface, using core language features that are available to
everyone. No magic involved!
This means that you and I can also write code like what's in the
standard library, without first having to be a compiler writer. That
is extremely useful!
Bo Persson |
|
|
| Back to top |
|
|
|
| Juha Nieminen... |
Posted: Wed Jul 22, 2009 6:04 pm |
|
|
|
Guest
|
Vladimir Jovic wrote:
Quote: He probably thinks of something like this (a random example from the
boost library) :
Of course you can write very complex and obfuscated code, and in
complicated situations you may even have to, but this is so in any
language (very definitely including C).
But even if the code is complex by necessity, if it's well-written, an
experienced programmer will see past the amalgamation of "random"
symbols and actually understand what's going on. It's only to the
untrained eye that the code might look like random garbage.
It's a bit like complicated regular expressions: To the untrained eye
it looks just like incomprehensible garbage, but someone experienced in
regular expressions will see what's going on. (Well, the difference
being that C++ is much easier to read than regular expressions... )
It's not like C would be somehow better than C++ in this regard. If
you look at the innards of some complex C libraries, you'll see really
hard-to-understand code with eg. tons of complex pointer arithmetic and
other such things. |
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Thu Jul 23, 2009 3:31 am |
|
|
|
Guest
|
"Ian Collins" <ian-news at (no spam) hotmail.com> wrote in message
news:7co7v7F28he98U2 at (no spam) mid.individual.net...
Quote: BGB / cr88192 wrote:
"Jerry Coffin" <jerryvcoffin at (no spam) yahoo.com> wrote:
The same happens with things like closing files and telling a GUI
system you no longer need a handle to a resource. In theory, you
_could_ do all these manually, and you can even do so in fact for
programs that are really trivial. For a program of any size or
complexity, however, remains a mostly theoretical possibility.
as noted, in my case all this has not really been a problem...
granted, I very rarely do my memory-management directly with malloc/free
either (most often, I build my own memory mangagers which either build on
top of them, or do their basic allocation directly with mmap or
VirtualAlloc...).
many of these, in turn, support various, typically specialized,
approaches to memory management.
I also have a "general purpose" garbage collector, which I usually treat
about like a malloc/free implementation, but I leave it up to the GC to
deal with cases where the memory lifetime is not obvious.
Memory is only one resource a programme has to manage.
it is, however, the main resource, and about the only resource whose
management becomes an application-scale issue...
in my experience, nearly every other resource, such as:
FILE handles;
GUI-related handles (GDI+, ...);
....
can be more or less entirely confined to small sections of code, and "never
seen again".
granted, I guess is a sufficiently complex GUI-based app, widgets/... could
become a significant issue, just in my experience, I deal with all this so
little that its effects are negligible (GUI is not a significant focus of my
projects...).
FWIW, even then, I typically do my own widgets, so widgets are basically
just memory objects like any other memory objects...
|
|
|
| Back to top |
|
|
|
| Ian Collins... |
Posted: Thu Jul 23, 2009 5:18 am |
|
|
|
Guest
|
BGB / cr88192 wrote:
Quote: "Ian Collins" <ian-news at (no spam) hotmail.com> wrote in message
news:7co7v7F28he98U2 at (no spam) mid.individual.net...
BGB / cr88192 wrote:
"Jerry Coffin" <jerryvcoffin at (no spam) yahoo.com> wrote:
The same happens with things like closing files and telling a GUI
system you no longer need a handle to a resource. In theory, you
_could_ do all these manually, and you can even do so in fact for
programs that are really trivial. For a program of any size or
complexity, however, remains a mostly theoretical possibility.
as noted, in my case all this has not really been a problem...
granted, I very rarely do my memory-management directly with malloc/free
either (most often, I build my own memory mangagers which either build on
top of them, or do their basic allocation directly with mmap or
VirtualAlloc...).
many of these, in turn, support various, typically specialized,
approaches to memory management.
I also have a "general purpose" garbage collector, which I usually treat
about like a malloc/free implementation, but I leave it up to the GC to
deal with cases where the memory lifetime is not obvious.
Memory is only one resource a programme has to manage.
it is, however, the main resource, and about the only resource whose
management becomes an application-scale issue...
in my experience, nearly every other resource, such as:
FILE handles;
GUI-related handles (GDI+, ...);
....
can be more or less entirely confined to small sections of code, and "never
seen again".
That's a pretty small experience!
Please don't quote sigs.
--
Ian Collins |
|
|
| Back to top |
|
|
|
| Richard Herring... |
Posted: Thu Jul 23, 2009 1:59 pm |
|
|
|
Guest
|
In message <h485cg$j18$1 at (no spam) news.albasani.net>, BGB / cr88192
<cr88192 at (no spam) hotmail.com> writes
Quote:
"Richard Herring" <junk at (no spam) [127.0.0.1]> wrote in message
news:UACdN5CuOuZKFw45 at (no spam) baesystems.com...
In message <h45854$v96$1 at (no spam) news.albasani.net>, BGB / cr88192
cr88192 at (no spam) hotmail.com> writes
[big snip]
Quote: stack objects don't need to be freed,
The _memory_ occupied by stack objects doesn't need to be freed.
But any other resources they allocate still need to be deallocated.
Perhaps I should have written "any other resources they represent" to
make it clearer.
Quote:
stack objects typically don't need to allocate memory or resources either
(instead, any such reasources would be allocated and freed by the parent
function...).
And how does the "parent function" manage those resources? If the
lifetime of the resource is the duration of the function call, a stack
object is precisely what it uses to track that resource. The stack
object may not itself perform the allocation, but it's
Quote:
and due to other reasons, one knows
when a stack object goes out of scope, making it trivial in this case to
call the destructor
See other examples in this thread where it's not so trivial, because error
handling means you have to abandon normal processing and still return
cleanly.
most cases it is either trivial, or the function is in need of being split
apart into smaller functions (AKA: the result of bad coding...).
(in the rare case where stack-based objects actually
need them, which personally I have not really seen, since they are
typically
transient pass-by-value types...).
Like FILE* ?
FILE is an allocated type, not a stack-based type.
I said FILE *, not FILE.
FILE * is precisely an example of a resource handle which may be
stack-based:
int update_file(char * filename)
{
FILE * file = fopen(filename", "r+");
/* do stuff to the file */
return fclose(file);
}
In this case the handle happens to be a pointer, but there are plenty of
other instances where resources are represented by opaque handle types.
--
Richard Herring |
|
|
| Back to top |
|
|
|
| Richard Herring... |
Posted: Thu Jul 23, 2009 2:19 pm |
|
|
|
Guest
|
In message <UNPNeKDUSDaKFwww at (no spam) baesystems.com>, Richard Herring
<junk at (no spam) [127.0.0.1]> writes
Quote: In message <h485cg$j18$1 at (no spam) news.albasani.net>, BGB / cr88192
cr88192 at (no spam) hotmail.com> writes
"Richard Herring" <junk at (no spam) [127.0.0.1]> wrote in message
news:UACdN5CuOuZKFw45 at (no spam) baesystems.com...
In message <h45854$v96$1 at (no spam) news.albasani.net>, BGB / cr88192
cr88192 at (no spam) hotmail.com> writes
[big snip]
stack objects don't need to be freed,
The _memory_ occupied by stack objects doesn't need to be freed.
But any other resources they allocate still need to be deallocated.
Perhaps I should have written "any other resources they represent" to
make it clearer.
stack objects typically don't need to allocate memory or resources either
(instead, any such reasources would be allocated and freed by the parent
function...).
And how does the "parent function" manage those resources? If the
lifetime of the resource is the duration of the function call, a stack
object is precisely what it uses to track that resource. The stack
object may not itself perform the allocation, but it's
still responsible for tracking and eventually releasing it.
[pressed "post" too soon!]
Quote:
and due to other reasons, one knows
when a stack object goes out of scope, making it trivial in this case to
call the destructor
See other examples in this thread where it's not so trivial, because error
handling means you have to abandon normal processing and still return
cleanly.
most cases it is either trivial, or the function is in need of being split
apart into smaller functions (AKA: the result of bad coding...).
(in the rare case where stack-based objects actually
need them, which personally I have not really seen, since they are
typically
transient pass-by-value types...).
Like FILE* ?
FILE is an allocated type, not a stack-based type.
I said FILE *, not FILE.
FILE * is precisely an example of a resource handle which may be
stack-based:
int update_file(char * filename)
{
FILE * file = fopen(filename", "r+");
/* do stuff to the file */
return fclose(file);
}
In this case the handle happens to be a pointer, but there are plenty
of other instances where resources are represented by opaque handle
types.
--
Richard Herring |
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Thu Jul 23, 2009 6:14 pm |
|
|
|
Guest
|
"Richard Herring" <junk at (no spam) [127.0.0.1]> wrote in message
news:UNPNeKDUSDaKFwww at (no spam) baesystems.com...
Quote: In message <h485cg$j18$1 at (no spam) news.albasani.net>, BGB / cr88192
cr88192 at (no spam) hotmail.com> writes
"Richard Herring" <junk at (no spam) [127.0.0.1]> wrote in message
news:UACdN5CuOuZKFw45 at (no spam) baesystems.com...
In message <h45854$v96$1 at (no spam) news.albasani.net>, BGB / cr88192
cr88192 at (no spam) hotmail.com> writes
[big snip]
stack objects don't need to be freed,
The _memory_ occupied by stack objects doesn't need to be freed.
But any other resources they allocate still need to be deallocated.
Perhaps I should have written "any other resources they represent" to make
it clearer.
stack objects typically don't need to allocate memory or resources either
(instead, any such reasources would be allocated and freed by the parent
function...).
And how does the "parent function" manage those resources? If the lifetime
of the resource is the duration of the function call, a stack object is
precisely what it uses to track that resource. The stack object may not
itself perform the allocation, but it's
hmm...
I think, typically, "variables" and "stack objects" are considered as
different...
Quote:
and due to other reasons, one knows
when a stack object goes out of scope, making it trivial in this case to
call the destructor
See other examples in this thread where it's not so trivial, because
error
handling means you have to abandon normal processing and still return
cleanly.
most cases it is either trivial, or the function is in need of being split
apart into smaller functions (AKA: the result of bad coding...).
(in the rare case where stack-based objects actually
need them, which personally I have not really seen, since they are
typically
transient pass-by-value types...).
Like FILE* ?
FILE is an allocated type, not a stack-based type.
I said FILE *, not FILE.
FILE * is precisely an example of a resource handle which may be
stack-based:
int update_file(char * filename)
{
FILE * file = fopen(filename", "r+");
/* do stuff to the file */
return fclose(file);
}
In this case the handle happens to be a pointer, but there are plenty of
other instances where resources are represented by opaque handle types.
yep...
they are opened and closed easy enough, so no big deal in this case...
typically, I don't keep file handles open for any length of time, but almost
always do file-access in a controlled way, and in short bursts.
granted, there are a rare few places which violate this rule (my dynamic
read/write ZIP library, which as far as I remember, keeps the file open for
as long as the ZIP-file is mounted...).
if needed though, it could be made to do IO in bursts.
from what I can tell, burst IO also seems to avoid an issue that AFAIK
exists in XP's filesystem code (or similar), which is that after a long time
of very dense random IO, fread/fwrite seem to stop working...
this bug had started showing up before when using on-disk tree structures
and doing tests involving adding lots of keys...
another partial solution seems to be to do most small-scale IO in buffers,
and occasionally commit these buffers to disk...
but, in general, I have not done this sort of dense IO...
|
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Thu Jul 23, 2009 6:21 pm |
|
|
|
Guest
|
"Ian Collins" <ian-news at (no spam) hotmail.com> wrote in message
news:7cq99nF28np4sU2 at (no spam) mid.individual.net...
Quote: BGB / cr88192 wrote:
"Ian Collins" <ian-news at (no spam) hotmail.com> wrote in message
news:7co7v7F28he98U2 at (no spam) mid.individual.net...
BGB / cr88192 wrote:
"Jerry Coffin" <jerryvcoffin at (no spam) yahoo.com> wrote:
The same happens with things like closing files and telling a GUI
system you no longer need a handle to a resource. In theory, you
_could_ do all these manually, and you can even do so in fact for
programs that are really trivial. For a program of any size or
complexity, however, remains a mostly theoretical possibility.
as noted, in my case all this has not really been a problem...
granted, I very rarely do my memory-management directly with
malloc/free either (most often, I build my own memory mangagers which
either build on top of them, or do their basic allocation directly with
mmap or VirtualAlloc...).
many of these, in turn, support various, typically specialized,
approaches to memory management.
I also have a "general purpose" garbage collector, which I usually
treat about like a malloc/free implementation, but I leave it up to the
GC to deal with cases where the memory lifetime is not obvious.
Memory is only one resource a programme has to manage.
it is, however, the main resource, and about the only resource whose
management becomes an application-scale issue...
in my experience, nearly every other resource, such as:
FILE handles;
GUI-related handles (GDI+, ...);
....
can be more or less entirely confined to small sections of code, and
"never seen again".
That's a pretty small experience!
note that, in my definitions, "small" may mean several kLOC at a time...
but, if the entire project is in the 500+ kLOC range, who really keeps exact
count?...
the point though, is that unlike memory, FILE and GDI handles are not likely
to go wandering about the codebase in any IMO "sanely" written app, but are
likely to be confined to small regions, for example, one of the
code-sections providing GDI-based UI elements, ... |
|
|
| Back to top |
|
|
|
| Ian Collins... |
Posted: Thu Jul 23, 2009 11:11 pm |
|
|
|
Guest
|
BGB / cr88192 wrote:
Quote: "Ian Collins" <ian-news at (no spam) hotmail.com> wrote:
BGB / cr88192 wrote:
another, far lesser cost, is when writing libraries which are essentially
a large amount on thin wrapper code which needs to use C-based input and
exporting a C-based API, in which case, one would end up having to use
'extern "C"' in nearly every source file for wrapping nearly all of the
code, in which case the inconvinience of this wraping/... is not likely
to pay for the gain in convinience of having used C++ in this situation.
No, one would use 'extern "C"' where appropriate in the headers. The
source files are unaffected.
AFAIK, both the declarations of the functions in the header, as well as
their implementation as functions, have to be wrapped...
No, only the declarations.
Quote: I would think it would be the same as things like "__declspec(dllexport)",
which have to be done in both places, otherwise the compiler gets angry...
What's that?
--
Ian Collins |
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Fri Jul 24, 2009 3:19 am |
|
|
|
Guest
|
"Ian Collins" <ian-news at (no spam) hotmail.com> wrote in message
news:7crqvkF28np4sU3 at (no spam) mid.individual.net...
Quote: BGB / cr88192 wrote:
"Ian Collins" <ian-news at (no spam) hotmail.com> wrote:
BGB / cr88192 wrote:
another, far lesser cost, is when writing libraries which are
essentially a large amount on thin wrapper code which needs to use
C-based input and exporting a C-based API, in which case, one would end
up having to use 'extern "C"' in nearly every source file for wrapping
nearly all of the code, in which case the inconvinience of this
wraping/... is not likely to pay for the gain in convinience of having
used C++ in this situation.
No, one would use 'extern "C"' where appropriate in the headers. The
source files are unaffected.
AFAIK, both the declarations of the functions in the header, as well as
their implementation as functions, have to be wrapped...
No, only the declarations.
ok.
Quote: I would think it would be the same as things like
"__declspec(dllexport)", which have to be done in both places, otherwise
the compiler gets angry...
What's that?
MSVC magic for making functions be externally visible when building DLL's...
it is one of several ways to do DLL's (with MSVC...).
the main alternative is to make a ".def" file and individually name each DLL
export (in the C++ case, you have to know and enter the mangled name...).
Linux-style shared objects are more convinient, since it is not necessary to
identify which particular symbols are exports...
typically, the __declspec keyword is wrapped in a macro, so for example:
BGBDY_API
WINAPI
GLAPI
....
the reason each library ends up with a different macro, is due to some
funkiness about how the declspec works (one has to use a different modifier
inside and outside the library), but inside the DLL the modifier is needed
both on the prototype and the declaration, ...
this means using a per-library macro, and some preprocessor magic, to make
sure the correct modifiers are used in the correct places, ...
or, in short, writing DLL's is a hassle on multiple levels...
it is actually much less annoying with GCC though (such as with Cygwin or
MinGW), since GCC will go and make DLL's act like shared objects (namely,
DLL exports and imports are implicit).
or such...
|
|
|
| Back to top |
|
|
|
| Marco... |
Posted: Sat Jul 25, 2009 3:09 pm |
|
|
|
Guest
|
On Jul 19, 2:48 pm, ld <Laurent.Den... at (no spam) gmail.com> wrote:
thank you (merci) - interesting read
I would argue that anyone using the C preprocessor or any other
preprocessor to create new syntax is essentially creating a new
language (that just happens to be very portable).
COS and Dynace fall into this category. |
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Sun Jul 26, 2009 1:07 am |
|
|
|
Guest
|
"Marco" <prenom_nomus at (no spam) yahoo.com> wrote in message
news:430fc26e-bd0d-4060-ad9f-2bff68727e99 at (no spam) j9g2000prh.googlegroups.com...
On Jul 19, 2:48 pm, ld <Laurent.Den... at (no spam) gmail.com> wrote:
<--
thank you (merci) - interesting read
I would argue that anyone using the C preprocessor or any other
preprocessor to create new syntax is essentially creating a new
language (that just happens to be very portable).
COS and Dynace fall into this category.
-->
agreed...
it is worth noting that, in the case of my object system, I am not presently
using any preprocessing, rather, it is pure API calls...
granted, syntactic nicety is not the primary concern here... |
|
|
| Back to top |
|
|
|
| BGB / cr88192... |
Posted: Sat Aug 01, 2009 3:18 am |
|
|
|
Guest
|
"Juha Nieminen" <nospam at (no spam) thanks.invalid> wrote in message
news:w0Hcm.217$sW4.146 at (no spam) read4.inet.fi...
Quote: BGB / cr88192 wrote:
you seem to be opposing "coding conventions".
coding conventions can be more or less equated with code being well
written...
I'm not opposing coding conventions. I use lots of coding conventions
when I develop programs.
What I oppose are coding conventions which exist solely to get around
limitations of the language. These tend to make programs more complex
than they need to be.
Yes, I readily admit that programming in C++ is in no way free of
necessary coding conventions which exist because of the limitations of
C++ (compared to many higher-level languages). My point is, however,
that in well-written C++ *less* coding conventions of this type are
needed compared to C, making development simpler. Also, many of these
coding conventions are more familiar to most experienced C++ programmers
and can be seen much more easily (eg. because they are used by the C++
standard libraries and such). In C most of these coding conventions are
quite programmer-specific.
actually, I refer to what you call "programmer specific" as "style"...
different programmers use different styles, yes, this much is granted.
however, the point is that one recognize the various common styles, and use
a style as appropriate for the code in question.
I have my own style as well, which is sort of a combination of the Linux
kernel, id, and OpenGL styles, or, another way: the Torvalds, John Carmack,
and SGI styles...
one can adhere to certain styles, such that their code looks nice and
pleasing...
so, beyond specific for particular coding conventions, style also
encompasses matters like variable naming, the use of whitespace and other
formatting issues, ...
it is also a good way to spot "outsiders"...
if (...) {
....
"WTF is this?... go away weirdo..."
Quote: why should one worry about more vs less conventions?...
Because more coding conventions makes the program more difficult to
read and understand.
personally, I don't see it this way.
the style and conventions are a good portion of the readability, IMO...
Quote: A coding convention is kind of "metalanguage" in the sense that you
are writing in your own "subset" of the programming language. You use a
kind of "meta-C" on top of the bare C programming language, for the
purpose of avoiding pitfalls and errors (such as memory leaks, etc).
granted...
Quote: The problem is that your "metalanguage" might not be immediately
obvious to someone reading your code and who doesn't know about your
coding conventions.
hence, "outsiders"...
they are, naturally enough, to be viewed with suspicion, as they are bent on
fouling up ones' code with their ways...
Quote: When these extra coding conventions are *not needed* (rather than
intentionally avoided), the code tends to be more straightforward and
simpler, without any hidden "metalanguage" being used.
not sure why...
my main reason for not going through all of the usual conventions is when
quickly beating together something under the "make it work" goal...
but typically, this sort of code tends to be ugly, buggy, and just generally
horrid...
and so, later, I clean it up...
it is like being in a store, and noticing all the terribly ill-behaved
children, and then being reminded of a certain rule: "children should be
seen but not heard"...
impulsive behavior and noise one year, is fornication and moral depravity
the next...
"he who spares the rod hates his son."
....
or such... |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Mon Nov 23, 2009 6:23 pm
|
|