 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 17/04/2012 12:47, Invisible a écrit :
>
> Still, it does answer something I've always wondered about: What *is*
> the C calling convention? Apparently it's to pass all function arguments
> and function results via the stack, and also to store all local
> variables on the stack. (By contrast, if you're coding in assembly,
> usually you pass everything in registers. Apparently C doesn't do this.)
C cannot assume a single processor, hence cannot have a set of registers
for arguments.
(on a M68000, what would you do if your functions has more than 16
arguments (D0-D7 and A0-A7) ? And on that small i286, more than 4 16 bits ?)
Not only does everything goes on the stack, but the alignment on the
stack is also sensible to the compiler (and the ABI mode).
(and in C, there is sometimes a difference in the stacking of arguments
when K&R or ANSI prototype has been provided (or not, in which case K&R
is assumed); C++ does not have that issue, as prototype is mandatory)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"You make a new type by declaring a class."
Wrong.
"A class is just a collection of variables - often of different types -
combined with a set of related functions."
It might be more accurate to say that an /object/ is a collection of
variables. At any rate, "collection" usually means something more
specific in this case.
"A class enables you to encapsulate, or bundle, these variables parts
and various functions into one collection, which is called an object."
Where do I start?
I'm pretty sure "encapsulate" doesn't mean what you think it means. :-P
A "collection" usually refers to a group of objects, which isn't what
you're talking about.
And finally, this is perhaps the most vague definition of an object I've
ever heard. :-P
The next goes on to explain that classes are good because everything
related to a thing is in one place. (Like you couldn't just write all
the code together if it wasn't for classes.) Obviously this /isn't/
what's so special about classes. The /actual/ benefits don't appear to
be mentioned.
I'm going to stop now, because otherwise I'll just go on forever... >_<
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> It's when I see things like this that I'm glad I use Haskell, not some
> low-level performance-oriented language that doesn't mind giving you
> garbage results if it makes the code 0.02% faster...
Has Haskell ever been used for something where the execution speed is
actually important? :-)
If Haskell had a decent IDE and easy documented access to the rest of
the system I might consider using it. But then F# exists already and I
haven't paid much attention to that so far...
I think you need to be working with very specific types of problems to
warrant using Haskell, which isn't to say nobody uses it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Orchid Win7 v1 <voi### [at] dev null> wrote:
> Then there's a cryptic reference to the fact that iostream and
> iostream.h aren't the same, but the differences are "subtle, exotic, and
> beyond the scope of an introductory primer".
One is standard, the other isn't. What is there more to explain?
> (Incidentally, the table of contents runs to 21 pages. I always feel
> that if the table of contents /itself/ merits another table of contents,
> you're doing it wrong.)
I have sometimes seen the opposite extreme: A doorstopper book with
a laughably small table of contents which isn't very helpful.
> Anyway, apparently main() must always return int. It is against the ANSI
> standard for it to return void. (No mention of it having parameters.
> Indeed, even the return value is described as an "obscure feature which
> we won't make use of".)
I don't think it would have been very hard to say something like "the
return value is used by the operating system as a success/failure value"
and then explain that 0 means success and other values can be used as a
failure code. (It is actually important to know this especially when
creating a command-line program. The return value of main() is
significant.)
> Then there's some mumbo-jumbo about how you can use cout "to do
> addition", and how when you do count << 8+5, then "8+5 is passed to
> cout, but 13 is what is actually printed". Nice, clear explanation,
> that. :-P
Actually "8+5" is not being passed to cout. cout is getting one single
integral value. (Basically invariably this value will be calculated by
the compiler at compile time.) Anyways, it's not like it's important.
> And then it starts talking about types. Apparently C++ adds a new "bool"
> type, which is supposed to be 1 byte.
I don't think the standard defines the size of bool. Most compilers
probably make it 1.
> Apparently "char" doesn't mean
> character at all, it means a 1-byte integer (and by default, a signed one).
The standard only guarantees that sizeof(char) is 1, but not that char
is 1 byte. (It is possible for char to be larger in some systems. It just
means that everything else is then a multiple of that size.)
The standard also lets the signedness of char as implementation-defined.
(In most practical systems it's signed.)
(Curiously, "char" and "signed char" are two *different* types in C and
C++ even if "char" is signed, while for example "int" and "signed int" are
completely synonymous and the "signed" keyword is redundant in the latter
case. This comes from the prehistoric dark ages of C.)
> Now, this I did not know, but: There is a long int, and a short int. And
> then there's just int. I had always thought these were three different
> sizes of integer. But it appears that actually, long int is one size,
> short int is another size, and plain int refers to whichever one the
> compiler writer chose on a whim. So there's only actually two integer
> sizes, and plain int means "I don't care".
Nope. The standard does not say that. The only thing the standard says
is that:
sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
and that sizeof(char) = 1 (which does not mean "1 byte", but "1 indexable
memory unit".)
(Yes, it is possible and standard-conforming for char to be as large
as long.)
In practice in most 32-bit systems short will be 16 bits and int/long
will be 32 bits. In most 64-bit systems it will be the same except that
long will be 64 bits.
Curiously, the new standard specifically states that the new "long long"
type has to be at least 64 bits. (The new standard also defines official
typedefs for integrals of specific sizes.)
> The book suggests "never use int, always use short int or long int". If
> the table is to be believed, long int is 32-bits. Christ knows what you
> do if you want more bits than that...
"Never use int" is a silly thing to say.
If you need an integral that's the natural word size of the target system,
use int. If you need an integral with a specific number of bits, use one
of the new standard typedefs. Use "long long" for an integral of at least
64 bits (at least if your compiler supports C++11). There's no standard
support for larger integrals (because they are not supported by CPUs).
> The book casually mentions something which /seems/ to be claiming that
> variables are not initialised to anything in particular unless you
> specifically request this. That's interesting; I didn't know that.
C hackers don't want the extra clock cycle to initialize a variable
which will be immediately assigned a new value anyways.
As a side effect you get all kinds of weird behavior if you forget to
initialize a variable.
> Apparently assigning a double to an int is only a /warning/, not a
> compile-time error. The book helpfully fails to specify how the
> conversion is actually done.
The integral part of the value is assigned to the int.
> is a perfectly valid statement in C++. On the other hand, it also means that
> while (x[i] = y[i--]) ;
> is perfectly valid. You sick, sick people.
I think that's Undefined Behavior because the same variable is being
modified and referenced more than once in the same expression.
Even if it isn't UB, better not do it like that.
> In most programming languages, performing division promotes integers to
> reals. But not in C++, apparently.
C is a wrapper around assembly, and assembly supports integral division.
Hence dividing integers performs integral division. Oftentimes you *want*
integral division (in which case promoting to floating point would be an
enormous waste of resources).
If you really want promotion to floating point, then you have to cast
explicitly.
> At this point, we
> are told that there's two ways to convert something to an double:
> double x = (double)y;
> double x = static_cast<double>y;
> Apparently the former is bad, and the latter is good. No indication as
> to why, it just is.
The former casts *anything* into a double, while the latter casts only
compatible types. (Which means that the latter will give you a compiler
error if you try to cast from an incompatible type by mistake.)
> This being C++, some insane wacko
> thought that having c++ and ++c would be a good idea, and wouldn't be
> confusing in any way.
Who gets confused? I don't.
There's certainly a big difference between eg:
while(c++ < 10) std::cout << c << "\n";
and
while(++c < 10) std::cout << c << "\n";
If you don't want to made the increment "inline" like that, the
alternative is more verbose.
> Next we learn that false=0, and true /= 0. (Christ, I'm /never/ going to
> remember that!) Apparently there's a new bool type, but details are thin
> as to what the exact significance of this is.
You are never going to remember that 0 is false?
> Then we learn about if/then, if/then/else, and finally ?: is
> demonstrated, without once mentioning how it's different from
> if/then/else. (I.e., it only works on expressions, not statements. Oh,
> but wait! Silly me, statements /are/ expressions...)
?: cannot contain blocks of code, and both branches much evaluate to
the same type. No such limitation for if/then/else.
> Bizarrely, if you don't specify a return type, it defaults to int. Not,
> say, void. :-o
Not in standard C++ (where it's an error).
> Then we learn about global variables. Apparently if you write a variable
> outside of any block, it's global. No word on exactly when it's
> initialised, or precisely what "global" actually means. For example, I'm
> /guessing/ the variable is only in-scope /below/ the line where it's
> defined. That's how functions work, after all.
If you define a variable (or function) in the global namespace, it will
be visible in the entire program. (Yes, you can access it from a different
compilation unit. You just need to declare it with "extern" in that other
compilation unit to do that.)
The problem with global variables is, obviously, name clashes. You'll
start getting weird linker errors about duplicate names if you make a habit
of using lots of globals (and then happen to use the same name in two
compilation units).
(Also, from a design point of view, global variables decrease abstraction,
which is bad.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 01:44 PM, scott wrote:
>> It's when I see things like this that I'm glad I use Haskell, not some
>> low-level performance-oriented language that doesn't mind giving you
>> garbage results if it makes the code 0.02% faster...
>
> Has Haskell ever been used for something where the execution speed is
> actually important? :-)
Well... The Haskell compiler itself. The Darcs source control system.
Several web frameworks / web servers. (If you believe the hype, some of
these web servers rival Apache in terms of performance.)
If there's one thing Haskell lacks, it's a "killer application". There's
nothing I can really point at which demonstrates either the speed or
usefulness of Haskell. The best I can do is some microbenchmarks on the
language shootout.
> If Haskell had a decent IDE and easy documented access to the rest of
> the system I might consider using it. But then F# exists already and I
> haven't paid much attention to that so far...
Haskell has /an/ IDE... I'm not sure it warrants the description of
"decent" yet though. Last time I tried it, it had reached the stage of
"kinda clunky, but basically usable".
http://antimatroid.files.wordpress.com/2010/07/leksah.png
If by "easy access to the rest of the system" you mean "it works great
on POSIX systems", then yeah, sure. :-) Oh, wait, you meant Windows, the
platform that 98% of the entire world uses? Sorry, no luck.
(OK, that's a slight exaggeration. The basic system works flawlessly on
all popular platforms. But if you want to talk to the outside world, you
end up needing to know very low level system calls.)
If you want /documentation/... then yeah, I see why you're not using
Haskell.
In short, in terms of how nicely it's all packaged up, Haskell just
can't compete with the might of Java or F# or Erlang or whatever.
Haskell is a hobby project put together by a few dozen open-source
developers from around the world. It's got nothing on Microsoft or
Oracle or Ericsson.
> I think you need to be working with very specific types of problems to
> warrant using Haskell, which isn't to say nobody uses it.
What, you mean like programs involving complex data manipulations?
Problems where you want to actually get the correct answer? Problems
where you'd like to be able to still understand the code in two years'
time? Because, to me, that sounds like a pretty /huge/ problem domain. ;-)
It's sad, really. You can use C or Java or whatever, which is horrible
to code in but lets you actually get stuff done. Or you can code in
Haskell, which is a joyful celebration of how programming should be, but
then it's a nightmare to actually interact with the outside world... I
keep hoping that some day this situation will be fixed. But I doubt it.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> "Note that inline functions can bring a heavy cost. If the function
> is called 10 times, the inline code is copied into the calling functions
> each of those 10 times. The tiny improvement in speed you might achieve
> is more than swamped by the increase in the size of the executable
> program.
He seems to think that the 'inline' keyword forces the compiler to inline.
It doesn't. The compiler is completely free to not inline it, if it decides
that it would be detrimental.
As for increasing the size of the executable, who cares? If the executable
gets a few hundreds of bytes larger, big deal.
The 'inline' keyword has a secondary, but much more important role,
though: It's an instruction for the compiler that says, basically, "if
this function appears in more than one compilation unit, don't give me
a linker error; instead merge them into one".
Anyways, 'inline' should usually only be used for very short functions
that are absolutely crucial for speed. Otherwise there's little benefit.
> Now, I'm used to programming languages where the decision to inline
> something or not is down to the compiler. It's not something an
> application programmer would ever have to worry about. And it seems that
> the inline directive is only a "hint" in C++ anyway, so I have to
> wonder, whether this particular directive is now obsolete.
Some newer compilers (such as the newest version of gcc) are able to
inline functions between compilation units. However, this is a rare,
quite advanced feature. (AFAIK only gcc implements this so far.)
Traditionally, if you need a short function to be as fast as possible,
you need to define it in the module's header file, and then it *must* be
declared 'inline' (or else you'll get linker errors).
> I love the dire warnings that you could use a number less than 15,
> because otherwise the program might consume a vast amount of memory.
> (For goodness' sake, how much RAM does 15 stack frames take up?!)
That would probably be 15^2. The author might have been using a 16-bit
DOS compiler.
> "Recursion is not used often in C++ programming, but it can be a
> powerful and elegant tool for certain needs. Recursion is a tricky part
> of advanced programming. It is presented here because it can be useful
> to understand the fundamentals of how it works, but don't worry too much
> if you don't fully understand all the details."
> In other words, yet again, "now you know how this works, you don't need
> to actually use it".
Recursion is often handy to implement algorithms that are very recursive
in nature, but one should be careful to not use too much stack space.
(Generally speaking C++ compilers do not perform tail recursion
optimizations. I'm not completely sure why.)
If your recursion depth is O(log n), then it's usually safe. If it starts
being O(n), then it's more worrisome. (Well, depending on the expected
amount of data, of course.)
Usually recursion is also slower than an equivalent iterative solution
(*especially* if the iterative solution works with O(1) extra memory.)
> "Registers are a special area of memory built right into the CPU."
> Erm...
Even C programmers stopped worrying about CPU registers somewhere in the
early 80's. In C++ they have never been an issue. It's a headache of the
compiler, not the programmer.
> Still, it does answer something I've always wondered about: What *is*
> the C calling convention?
It actually depends on the OS.
You don't need to worry about calling conventions unless you are
implementing something really, *really* low-level. Machine-code level.
(One example would be if you are writing a compiler.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Warp
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 10:03:32
Message: <4f8d7834@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> When I looked at my function, I found I'd written "it->second;" rather
> than "return it->second;". Not only is this apparently legal, it doesn't
> even generate a compile-time /warning/.
What compiler would that be?
int test()
{
}
test.cc:3:13: warning: no return statement in function returning non-void
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 02:40 PM, Warp wrote:
> Orchid Win7 v1<voi### [at] dev null> wrote:
>> Then there's a cryptic reference to the fact that iostream and
>> iostream.h aren't the same, but the differences are "subtle, exotic, and
>> beyond the scope of an introductory primer".
>
> One is standard, the other isn't. What is there more to explain?
The book doesn't actually mention this fact. It seems to suggest that
you just use whichever one you fancy. And then says something about "but
we're going to use iostream.h for compatibility reasons".
So I'm presuming iostream is the standards-compliant one?
>> Anyway, apparently main() must always return int. It is against the ANSI
>> standard for it to return void. (No mention of it having parameters.
>> Indeed, even the return value is described as an "obscure feature which
>> we won't make use of".)
>
> I don't think it would have been very hard to say something like "the
> return value is used by the operating system as a success/failure value"
> and then explain that 0 means success and other values can be used as a
> failure code. (It is actually important to know this especially when
> creating a command-line program. The return value of main() is
> significant.)
Yeah, an exit code is not exactly an "obscure feature". I can understand
the book not using it, but that doesn't mean the same as being useless.
>> Then there's some mumbo-jumbo about how you can use cout "to do
>> addition", and how when you do count<< 8+5, then "8+5 is passed to
>> cout, but 13 is what is actually printed". Nice, clear explanation,
>> that. :-P
>
> Actually "8+5" is not being passed to cout.
Quite. The text completely fails to explain what's /actually/ happening.
A bit later on it starts talking about how "the compiler" calls XYZ when
you do ABC. Obviously, the compiler doesn't call anything; it just
generates code. :-P
> Anyways, it's not like it's important.
It is if you want to form an understanding of what the stuff you're
typing in actually /means/. The text makes it sound like adding is
somehow special to cout, which clearly it isn't. You can do this with
/any/ function call.
>> And then it starts talking about types. Apparently C++ adds a new "bool"
>> type, which is supposed to be 1 byte.
>
> I don't think the standard defines the size of bool. Most compilers
> probably make it 1.
I have a sinking feeling you're right.
>> Apparently "char" doesn't mean
>> character at all, it means a 1-byte integer (and by default, a signed one).
>
> The standard only guarantees that sizeof(char) is 1, but not that char
> is 1 byte. (It is possible for char to be larger in some systems. It just
> means that everything else is then a multiple of that size.)
>
> The standard also lets the signedness of char as implementation-defined.
> (In most practical systems it's signed.)
Oh... goodie.
> (Curiously, "char" and "signed char" are two *different* types in C and
> C++ even if "char" is signed, while for example "int" and "signed int" are
> completely synonymous and the "signed" keyword is redundant in the latter
> case. This comes from the prehistoric dark ages of C.)
Wait... I didn't even know you could /do/ that! o_O
> Nope. The standard does not say that. The only thing the standard says
> is that:
>
> sizeof(char)<= sizeof(short)<= sizeof(int)<= sizeof(long)
>
> and that sizeof(char) = 1 (which does not mean "1 byte", but "1 indexable
> memory unit".)
>
> (Yes, it is possible and standard-conforming for char to be as large
> as long.)
>
> In practice in most 32-bit systems short will be 16 bits and int/long
> will be 32 bits. In most 64-bit systems it will be the same except that
> long will be 64 bits.
>
> Curiously, the new standard specifically states that the new "long long"
> type has to be at least 64 bits. (The new standard also defines official
> typedefs for integrals of specific sizes.)
Ouch. My head.
> "Never use int" is a silly thing to say.
>
> If you need an integral that's the natural word size of the target system,
> use int. If you need an integral with a specific number of bits, use one
> of the new standard typedefs.
Now /that/ actually makes sense. Where are these typedefs located? Do
you have to include them specifically, or...?
> Use "long long" for an integral of at least
> 64 bits (at least if your compiler supports C++11). There's no standard
> support for larger integrals (because they are not supported by CPUs).
Not supported _yet_. ;-)
> C hackers don't want the extra clock cycle to initialize a variable
> which will be immediately assigned a new value anyways.
I figured.
> As a side effect you get all kinds of weird behavior if you forget to
> initialize a variable.
Yeah, it's great, isn't it? ;-)
I had hoped for maybe a compile-time warning. I haven't actually tried
it to see if I get one though...
(Java actually refuses to compile your code if it can't satisfy itself
that /every/ variable is initialised. Which gets annoying when every
variable /is/ initialised before use, but the compiler can't prove it...)
>> Apparently assigning a double to an int is only a /warning/, not a
>> compile-time error. The book helpfully fails to specify how the
>> conversion is actually done.
>
> The integral part of the value is assigned to the int.
So... it always rounds towards zero?
>> is a perfectly valid statement in C++. On the other hand, it also means that
>
>> while (x[i] = y[i--]) ;
>
>> is perfectly valid. You sick, sick people.
>
> I think that's Undefined Behavior because the same variable is being
> modified and referenced more than once in the same expression.
Aren't expressions guaranteed to execute left-to-right?
> Even if it isn't UB, better not do it like that.
But that's just it. All C programmers always code in this kind of style.
It's part of what makes C so terrifying to try to read.
>> In most programming languages, performing division promotes integers to
>> reals. But not in C++, apparently.
>
> C is a wrapper around assembly, and assembly supports integral division.
> Hence dividing integers performs integral division. Oftentimes you *want*
> integral division
Most languages seem to provide a separate operator for that. But sure, OK.
>> At this point, we
>> are told that there's two ways to convert something to an double:
>
>> double x = (double)y;
>
>> double x = static_cast<double>y;
>
>> Apparently the former is bad, and the latter is good. No indication as
>> to why, it just is.
>
> The former casts *anything* into a double, while the latter casts only
> compatible types. (Which means that the latter will give you a compiler
> error if you try to cast from an incompatible type by mistake.)
Now why the hell they couldn't just /say/ that I don't know...
>> Next we learn that false=0, and true /= 0. (Christ, I'm /never/ going to
>> remember that!) Apparently there's a new bool type, but details are thin
>> as to what the exact significance of this is.
>
> You are never going to remember that 0 is false?
I know that zero is one thing, and everything else is the other thing.
But I always struggle to remember whether zero means true or false. The
solution, of course, is to never ever use integers as bools.
>> Then we learn about if/then, if/then/else, and finally ?: is
>> demonstrated, without once mentioning how it's different from
>> if/then/else. (I.e., it only works on expressions, not statements. Oh,
>> but wait! Silly me, statements /are/ expressions...)
>
> ?: cannot contain blocks of code, and both branches much evaluate to
> the same type. No such limitation for if/then/else.
Quite. The book doesn't bother mentioning any of that.
>> Bizarrely, if you don't specify a return type, it defaults to int. Not,
>> say, void. :-o
>
> Not in standard C++ (where it's an error).
Oh thank god!
>> Then we learn about global variables. Apparently if you write a variable
>> outside of any block, it's global. No word on exactly when it's
>> initialised, or precisely what "global" actually means. For example, I'm
>> /guessing/ the variable is only in-scope /below/ the line where it's
>> defined. That's how functions work, after all.
>
> If you define a variable (or function) in the global namespace, it will
> be visible in the entire program. (Yes, you can access it from a different
> compilation unit. You just need to declare it with "extern" in that other
> compilation unit to do that.)
>
> The problem with global variables is, obviously, name clashes. You'll
> start getting weird linker errors about duplicate names if you make a habit
> of using lots of globals (and then happen to use the same name in two
> compilation units).
From what I'm seeing, just having multiple compilation units is a
nightmare. (That's one of the reasons I'm reading this book. I'm hoping
it's going to explain how to do this stuff properly.)
> (Also, from a design point of view, global variables decrease abstraction,
> which is bad.)
From a design point of view, global variables are a terrible idea. But
that the book bothers to explain why.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 03:03 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> When I looked at my function, I found I'd written "it->second;" rather
>> than "return it->second;". Not only is this apparently legal, it doesn't
>> even generate a compile-time /warning/.
>
> What compiler would that be?
>
> int test()
> {
> }
>
> test.cc:3:13: warning: no return statement in function returning non-void
#include <iostream>
#include <string>
std::string test()
{
}
int main()
{
std::cout << test();
return 0;
}
orphi@linux-z30b:~/Work/Logic-01> make Test
g++ Test.cpp -o Test
orphi@linux-z30b:~/Work/Logic-01> ./Test
Segmentation fault
orphi@linux-z30b:~/Work/Logic-01> g++ --version
g++ (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 03:00 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> "Note that inline functions can bring a heavy cost. If the function
>> is called 10 times, the inline code is copied into the calling functions
>> each of those 10 times. The tiny improvement in speed you might achieve
>> is more than swamped by the increase in the size of the executable
>> program.
>
> He seems to think that the 'inline' keyword forces the compiler to inline.
> It doesn't. The compiler is completely free to not inline it, if it decides
> that it would be detrimental.
He even /says/ that a few paragraphs later. "Inline is a hint, which the
compiler may ignore."
> As for increasing the size of the executable, who cares? If the executable
> gets a few hundreds of bytes larger, big deal.
Yeah, that's the really puzzling bit. I mean, unless the function is
huge [which is a bad idea anyway], or is called from a bazillion places,
why would inlining it "bring its own performance costs"? I don't get that.
> The 'inline' keyword has a secondary, but much more important role,
> though: It's an instruction for the compiler that says, basically, "if
> this function appears in more than one compilation unit, don't give me
> a linker error; instead merge them into one".
OK, /that/ sounds rather more significant.
> Anyways, 'inline' should usually only be used for very short functions
> that are absolutely crucial for speed. Otherwise there's little benefit.
The book claims that if you write a function body inside a class
definition, that makes the method inline. Is this true? I thought there
was no difference either way...
>> Now, I'm used to programming languages where the decision to inline
>> something or not is down to the compiler. It's not something an
>> application programmer would ever have to worry about. And it seems that
>> the inline directive is only a "hint" in C++ anyway, so I have to
>> wonder, whether this particular directive is now obsolete.
>
> Some newer compilers (such as the newest version of gcc) are able to
> inline functions between compilation units. However, this is a rare,
> quite advanced feature. (AFAIK only gcc implements this so far.)
OK. Presumably /within/ a single compilation unit it's already going to
inline anything it thinks is worth it though. (?)
> Traditionally, if you need a short function to be as fast as possible,
> you need to define it in the module's header file, and then it *must* be
> declared 'inline' (or else you'll get linker errors).
Right.
>> I love the dire warnings that you could use a number less than 15,
>> because otherwise the program might consume a vast amount of memory.
>> (For goodness' sake, how much RAM does 15 stack frames take up?!)
>
> That would probably be 15^2. The author might have been using a 16-bit
> DOS compiler.
He does mention DOS several times, yes.
Even so, there might be 15^2 function calls, but only at most 15 of them
will be /active/ simultaneously - which means only 15 stack frames at
once. No?
>> In other words, yet again, "now you know how this works, you don't need
>> to actually use it".
>
> Recursion is often handy to implement algorithms that are very recursive
> in nature, but one should be careful to not use too much stack space.
> Usually recursion is also slower than an equivalent iterative solution
> (*especially* if the iterative solution works with O(1) extra memory.)
Well, yes. As I understand it, by default C++ doesn't reserve a whole
lot of stack space, so you're likely to overflow it quite quickly. And
as you say, being non-recursive means you skip all the overhead of
jumping into and out of functions, which is faster. (It probably enables
more compiler optimisations too, I wouldn't wonder...)
>> Still, it does answer something I've always wondered about: What *is*
>> the C calling convention?
>
> It actually depends on the OS.
>
> You don't need to worry about calling conventions unless you are
> implementing something really, *really* low-level. Machine-code level.
> (One example would be if you are writing a compiler.)
I'm a curious soul. I think to have some idea how things work, even if I
don't know all of the details... ;-)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> Now /that/ actually makes sense. Where are these typedefs located? Do
> you have to include them specifically, or...?
IIRC they are in <cstdint>.
> I had hoped for maybe a compile-time warning. I haven't actually tried
> it to see if I get one though...
Some compilers will give you a warning if they think that a variable
is being used uninitialized, but given that the general problem of
determining that is unsolvable, it's not fool-proof.
There are some tools (such as valgrind) that will tell you at runtime.
> Aren't expressions guaranteed to execute left-to-right?
Expressions with side-effects can happen in any order. The compiler is
free to optimize expressions in any way it likes (as long as the result
is always the same if the expression had no multiple side-effects on the
same variable).
For example, if you do a "table[i++] = i;" the compiler can decide to
increment the 'i' before it assigns it to that location, or after the
entire statement is done. The general solution to that is: Don't do it.
> > Even if it isn't UB, better not do it like that.
> But that's just it. All C programmers always code in this kind of style.
> It's part of what makes C so terrifying to try to read.
C programmers (at least competent ones) do not have multiple side-effects
on the same variable inside the same expression. They may have multiple
side-effects on *different* variables, which is ok. For example:
while(*dest++ = *src++) {}
There are two side-effects there, but they are operating on different
variables, so there's no ambiguity.
> I know that zero is one thing, and everything else is the other thing.
> But I always struggle to remember whether zero means true or false. The
> solution, of course, is to never ever use integers as bools.
What do you think this will print?
bool b = true;
std::cout << b << std::endl;
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> I think you need to be working with very specific types of problems to
>> warrant using Haskell, which isn't to say nobody uses it.
>
> What, you mean like programs involving complex data manipulations?
> Problems where you want to actually get the correct answer? Problems
> where you'd like to be able to still understand the code in two years'
> time? Because, to me, that sounds like a pretty /huge/ problem domain. ;-)
Give a specific example then, of a real commercial problem where
selecting Haskell would be the best choice. I'm not saying none exist,
just wondering exactly what type of software problem Haskell would excel
at. Presumably it's not making a 3D game or an application that is
mostly GUI.
> It's sad, really. You can use C or Java or whatever, which is horrible
> to code in but lets you actually get stuff done. Or you can code in
> Haskell, which is a joyful celebration of how programming should be, but
> then it's a nightmare to actually interact with the outside world... I
> keep hoping that some day this situation will be fixed. But I doubt it.
In the end companies that are trying to make money will just use
whichever system lets them solve the problems as quickly as possible.
This results in all manner of different languages being used (even
Haskell!). But I think the reason you imagine C++/Java/C# being so
popular is that the huge markets of software don't match with Haskell.
Desktop software needs a familiar GUI and easy documented access to
APIs. Apps for phones need good access to hardware (and usually the OS
maker has chosen a language for you). Games need high performance and
good access to hardware APIs.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> > As for increasing the size of the executable, who cares? If the executable
> > gets a few hundreds of bytes larger, big deal.
> Yeah, that's the really puzzling bit. I mean, unless the function is
> huge [which is a bad idea anyway], or is called from a bazillion places,
> why would inlining it "bring its own performance costs"? I don't get that.
In fact, inlining can actually sometimes reduce the size of the executable
(because a function call may be replaced with an expression that gets
calculated at compile time and optimized away).
> > Anyways, 'inline' should usually only be used for very short functions
> > that are absolutely crucial for speed. Otherwise there's little benefit.
> The book claims that if you write a function body inside a class
> definition, that makes the method inline. Is this true? I thought there
> was no difference either way...
A function definition inside a class definition is implicitly 'inline'
(without having to explicitly use the keyword; you could specify it, but
it would be redundant.)
Likewise template functions are implicitly 'inline' without having to
explicitly say so.
> Even so, there might be 15^2 function calls, but only at most 15 of them
> will be /active/ simultaneously - which means only 15 stack frames at
> once. No?
You may be right.
> Well, yes. As I understand it, by default C++ doesn't reserve a whole
> lot of stack space, so you're likely to overflow it quite quickly.
It depends on the OS. (In most unixes you can actually set how much
stack is given to a process.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Warp
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 10:36:45
Message: <4f8d7ffd@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> orphi@linux-z30b:~/Work/Logic-01> make Test
> g++ Test.cpp -o Test
You need to put a "CXXFLAGS=-Wall -O2" in your Makefile. (With Gnu make
that's probably the only think that you need to put there.)
Of compile it directly with "g++ -Wall -O3 Test.cpp -o Test".
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 03:26 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> Now /that/ actually makes sense. Where are these typedefs located? Do
>> you have to include them specifically, or...?
>
> IIRC they are in<cstdint>.
A quick Google search indicates that cstdint defines std::int8_t,
std::int16_t and so on, plus uint versions (presumably unsigned). It
also defines std::int_fast8_t and friends, std::int_least8_t and so on,
a std::intmax_t and a std::intintptr_t.
>> I had hoped for maybe a compile-time warning. I haven't actually tried
>> it to see if I get one though...
>
> Some compilers will give you a warning if they think that a variable
> is being used uninitialized, but given that the general problem of
> determining that is unsolvable, it's not fool-proof.
>
> There are some tools (such as valgrind) that will tell you at runtime.
I may yet end up having to investigate valgrind. It seems it's the only
reliable way to discover if your code leaks memory...
>> Aren't expressions guaranteed to execute left-to-right?
>
> Expressions with side-effects can happen in any order. The compiler is
> free to optimize expressions in any way it likes (as long as the result
> is always the same if the expression had no multiple side-effects on the
> same variable).
I see. So that's why programs tend to break if you turn the optimisation
settings up too high?
>> But that's just it. All C programmers always code in this kind of style.
>> It's part of what makes C so terrifying to try to read.
>
> C programmers (at least competent ones) do not have multiple side-effects
> on the same variable inside the same expression. They may have multiple
> side-effects on *different* variables, which is ok. For example:
>
> while(*dest++ = *src++) {}
>
> There are two side-effects there, but they are operating on different
> variables, so there's no ambiguity.
It still makes my head hurt. >_<
> What do you think this will print?
>
> bool b = true;
> std::cout<< b<< std::endl;
Well, I guess now that C++ has /names/ for true and false, I don't have
to worry about it.
Is bool still regarded as an alias to an integer type? Or does it really
get treated as a separate, distinct type?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> why would inlining it "bring its own performance costs"? I don't get that.
>
> In fact, inlining can actually sometimes reduce the size of the executable
> (because a function call may be replaced with an expression that gets
> calculated at compile time and optimized away).
That's what I figured.
>> The book claims that if you write a function body inside a class
>> definition, that makes the method inline. Is this true? I thought there
>> was no difference either way...
>
> A function definition inside a class definition is implicitly 'inline'
> (without having to explicitly use the keyword; you could specify it, but
> it would be redundant.)
Hmm, OK. So is it a good idea to include simple accessor methods in a
header file then? (The book seems to suggest it is.)
> Likewise template functions are implicitly 'inline' without having to
> explicitly say so.
Well, by definition a template generates a new copy of the function each
time you use it, no?
>> Even so, there might be 15^2 function calls, but only at most 15 of them
>> will be /active/ simultaneously - which means only 15 stack frames at
>> once. No?
>
> You may be right.
I usually am. :^)
>> Well, yes. As I understand it, by default C++ doesn't reserve a whole
>> lot of stack space, so you're likely to overflow it quite quickly.
>
> It depends on the OS. (In most unixes you can actually set how much
> stack is given to a process.)
Yeah, I should think most times you can throw a compiler switch, or ask
the OS to reserve more at run-time.
PS. I can't believe I just wrote "I usually am". Heh.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> > Likewise template functions are implicitly 'inline' without having to
> > explicitly say so.
> Well, by definition a template generates a new copy of the function each
> time you use it, no?
No. A new version is created for each used *type*.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 04:06 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>>> Likewise template functions are implicitly 'inline' without having to
>>> explicitly say so.
>
>> Well, by definition a template generates a new copy of the function each
>> time you use it, no?
>
> No. A new version is created for each used *type*.
Oh, I see. I'm still thinking of macro expansion, aren't I? OK.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> What, you mean like programs involving complex data manipulations?
>> Problems where you want to actually get the correct answer? Problems
>> where you'd like to be able to still understand the code in two years'
>> time? Because, to me, that sounds like a pretty /huge/ problem domain.
>> ;-)
>
> Give a specific example then, of a real commercial problem where
> selecting Haskell would be the best choice. I'm not saying none exist,
> just wondering exactly what type of software problem Haskell would excel
> at. Presumably it's not making a 3D game or an application that is
> mostly GUI.
> In the end companies that are trying to make money will just use
> whichever system lets them solve the problems as quickly as possible.
> This results in all manner of different languages being used (even
> Haskell!). But I think the reason you imagine C++/Java/C# being so
> popular is that the huge markets of software don't match with Haskell.
> Desktop software needs a familiar GUI and easy documented access to
> APIs. Apps for phones need good access to hardware (and usually the OS
> maker has chosen a language for you). Games need high performance and
> good access to hardware APIs.
I think /everybody/ wants to write code which is robust, reliable,
portable and maintainable. The problem, as you say, is that usually
getting access to the native resources is usually a highER priority than
writing beautiful code.
If you release a Windows application which requires you to install GTK
before it will work, nobody is going to care how beautiful the code is.
(Except your dev team.) They're all going to think it looks like crap.
And if you release an application written in low-level C and structured
like spaghetti, nobody will care as long as it actually works reasonably
well and it looks nice.
A guess fundamentally, if you write your application in C or C++, then
you can use any code library that has ever been written, interface with
any system, do absolutely anything you want. If you write your
application in Haskell... then in theory you can do the same. In
reality, it's going to take forever to write bindings to an external
library, and because the binding is so low-level, you lose most if not
all of the benefits of Haskell anyway.
If there ever comes a day when Haskell ships out of the door with
top-quality libraries for doing most or all of the things that a typical
developer would want to get done, then maybe Haskell will start to
become popular. I don't see that day being particularly soon.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 03:36 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> orphi@linux-z30b:~/Work/Logic-01> make Test
>> g++ Test.cpp -o Test
>
> You need to put a "CXXFLAGS=-Wall -O2" in your Makefile.
OK, /now/ I at least get a warning.
I'm still a bit baffled that this is a valid thing to do, however...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> If there ever comes a day when Haskell ships out of the door with
> top-quality libraries for doing most or all of the things that a typical
> developer would want to get done, then maybe Haskell will start to
> become popular.
The problem is that F# exists already, and I guess you wouldn't call it
"popular" in the way that you would like Haskell to become. So Haskell
would need to become, in some way, superior to F# in order to become
popular.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 04:49 PM, scott wrote:
>> If there ever comes a day when Haskell ships out of the door with
>> top-quality libraries for doing most or all of the things that a typical
>> developer would want to get done, then maybe Haskell will start to
>> become popular.
>
> The problem is that F# exists already, and I guess you wouldn't call it
> "popular" in the way that you would like Haskell to become. So Haskell
> would need to become, in some way, superior to F# in order to become
> popular.
Haskell is /already/ superior to F#. ;-)
For a start, F# is functional in the same way that C++ is
object-oriented. I.e., not very. F# is a normal OO language with a few
slightly functional ideas bolted on the side as an afterthought.
But in all seriousness: Haskell will never be popular. Writing clean,
maintainable code just isn't a high priority. Bashing out code as fast
as possible is a high priority. Producing six point-releases per
calendar month is a high priority. Being paid per LoC is a high
priority. Nobody will ever want to use Haskell.
Still, at least if Haskell shipped with decent libraries, *I* could
still enjoy using it. :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Warp
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 12:07:21
Message: <4f8d9539@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> For a start, F# is functional in the same way that C++ is
> object-oriented. I.e., not very. F# is a normal OO language with a few
> slightly functional ideas bolted on the side as an afterthought.
When will we see the Haskell# language?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> ...and then I feel depressed because I'm the only person in the UK who
> programs in Haskell
you and at least Simon Peyton Jones.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 15:26:59
Message: <4f8dc403@news.povray.org>
|
|
 |
|  |
|  |
|
 |
scott escreveu:
> If Haskell had a decent IDE and easy documented access to the rest of
> the system I might consider using it. But then F# exists already and I
> haven't paid much attention to that so far...
IDEs are only really useful for OO languages. You know, you have a
variable holding an instance of a class, then you type "." and get a
list of methods available... no such thing in functional programming
where the order is reversed: you have a function and want to apply
arguments to it. You may list arguments that match that function
definition and you may even know their types (assuming "intellisense"
got type inference), but most likely you're not directly applying those
arguments to the function, but applying some other function to it first.
It sounds too much of hassle to use "intellisense" in those situations...
I fear IDEs are really only useful at getting away with lesser
languages' weaknesses, AKA boilerplate cruft to make the compiler happy.
In Java, most of the IDE is used not just for that but also to handle
all the xml needed, since it's the only DSL known to java-heads...
so, all that would seem to rest of usefulness for an IDE is project
management. Here too it proves pretty useless as it's only really
needed to manage huge bloated projects full of boilerplate and xml.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Warp
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 15:51:14
Message: <4f8dc9b2@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> I'm still a bit baffled that this is a valid thing to do, however...
There's some baggage from C that would have better been dropped, but
as you may know, backwards compatibility can be a real b***h sometimes...
It can be argued using the same logic as with uninitialized variables,
though: There are situations where execution never reaches the end of the
function, and hence having a 'return' statement there would be useless.
In most situations putting such a useless 'return' there is only a minor
inconvenience, but in theory it could be more complicated. Also, it makes
the function larger, so the 80's C hackers didn't like that (in the same
way as they didn't like the idea of spending a clock cycle to initialize
a variable with a value that would immediately be overwritten anyways).
This would be an example of such a function:
std::string foo(int parameter)
{
assert(parameter >= 0 && parameter < 4);
switch(parameter)
{
case 0: return "Hello";
case 1: return "there";
case 2: return "world";
case 3: return "!";
}
// Execution will *never* reach here
// It's valid to omit a 'return'
}
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Le Forgeron
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 17 Apr 2012 16:46:16
Message: <4f8dd698$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Le 17/04/2012 21:51, Warp nous fit lire :
> the 80's C hackers didn't like that (in the same
> way as they didn't like the idea of spending a clock cycle to initialize
> a variable with a value that would immediately be overwritten anyways).
It was a time where memory access was done by putting the address on the
address bus, and the data was read/write on the data bus (and a wire was
dedicated to indicate if it was a read or write).
A time in which the memory respond time was faster than the CPU clock.
A time you could know the number of cycles to perform an addition, a
multiplication or a division (on integer). And gains a few cycles by
reordering expression.
A time I remember!
And it cost one cycle (may be a bit more, I do not remember the timing
for a move.l) to write a zero to a data bus-wide variable, but as many
cycles for an array. You do not want to waste 40 cycles to erase an
array of 40 int.
You already wasted a cycle to increase the stack usage, and by entering
a function you wasted a few more cycle saving a few registers on it too.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 17/04/2012 14:13, Invisible a écrit :
> Obviously this /isn't/ what's so special about classes. The /actual/
> benefits don't appear to be mentioned.
The benefit of class over a simple struct/collection is in the
private/protected parts, and the mandatory centralisation of the
prototypes of all related functions (until you start playing with
friend, but that's another story).
The point in class is to separate the interface (how the outside world
see me and use me) from the implementation (how I do it internally).
Once exposed, the public interface must remain (it can be expanded, but
not changed drastically).
The implementation can be changed at any time.
And then we are going to enter some holy wars about automatic getter &
setter, and static member in class.
--
A good Manager will take you
through the forest, no mater what.
A Leader will take time to climb on a
Tree and say 'This is the wrong forest'.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 08:09 PM, nemesis wrote:
> Invisible escreveu:
>> ...and then I feel depressed because I'm the only person in the UK who
>> programs in Haskell
>
> you and at least Simon Peyton Jones.
Yeah - I should go visit that guy sometime...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 17/04/2012 05:07 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> For a start, F# is functional in the same way that C++ is
>> object-oriented. I.e., not very. F# is a normal OO language with a few
>> slightly functional ideas bolted on the side as an afterthought.
>
> When will we see the Haskell# language?
Well, a while back somebody did do a Haskell to .NET bridge for their
PhD thesis.
(A /bridge/ is of course not the same thing as compiling to CIL. The
Haskell stuff runs as normal, it's just that it can "talk to" stuff
running on the .NET platform.)
Naturally, being a PhD thesis, it's proof-of-concept, not
production-grade. And, I would imagine, no longer maintained. (Not that
I suppose the /code/ was ever publicly released. The /thesis/ was, but I
don't know about the runnable code.)
In a similar vein, one of the experimental Haskell compilers has a
JavaScript back-end. As in, you write your Haskell program, compile it,
and you get (several KB of) normal JavaScript which will run in any web
browser. Again, not exactly production-grade, but interesting.
I think somebody somewhere once had a Haskell to Java compiler. (Or,
more likely, a "small subset of Haskell to Java compiler".) Highly
unfinished, of course.
Perhaps it would make an interesting research project... Maybe I should
look up how either Java bytecodes or the CIL works, and write some code
to target it.
Naturally, being able to run on either the JVM or the CLR wouldn't be
interesting unless it's also simple and easy to access the existing
class libraries. And that's another interesting project.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 18 Apr 2012 04:04:14
Message: <4f8e757e@news.povray.org>
|
|
 |
|  |
|  |
|
 |
On 17/04/2012 08:51 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> I'm still a bit baffled that this is a valid thing to do, however...
>
> There's some baggage from C that would have better been dropped, but
> as you may know, backwards compatibility can be a real b***h sometimes...
Don't we all know it. ;-)
(Haskell isn't as ancient as C, so fortunately it has much less of this.
It /does/ have it, however...)
> It can be argued using the same logic as with uninitialized variables,
> though: There are situations where execution never reaches the end of the
> function, and hence having a 'return' statement there would be useless.
Sure. But like I said, the Java compiler seems to detect this. If
doesn't just look at a function and say "does it contain a return
statement somewhere?" It actually statically analyses every possible
flow of control, and checks that every individual one ends with a return
(or throws an exception, which is also a valid way to terminate a function).
Of course, it's not perfect. Plausibly you could have if branches such
that a particular sequence of branches is impossible due to the
conditions in those branches, but the compiler wouldn't "see" that and
would still insist that you have a branch that doesn't terminate
properly. But I haven't seen that happen yet.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 18/04/2012 07:24 AM, Le_Forgeron wrote:
> Le 17/04/2012 14:13, Invisible a écrit :
>> Obviously this /isn't/ what's so special about classes. The /actual/
>> benefits don't appear to be mentioned.
>
> The benefit of class over a simple struct/collection is in the
> private/protected parts, and the mandatory centralisation of the
> prototypes of all related functions.
Indeed. Anybody who knows any OO theory will understand this. But,
unfortunately, anyone who reads this book will have no idea.
Hey Warp, you ever think about writing a book? I bet you could do a
better job than this idiot...
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 18 Apr 2012 05:36:14
Message: <4f8e8b0e@news.povray.org>
|
|
 |
|  |
|  |
|
 |
> IDEs are only really useful for OO languages.
I do not agree.
> You know, you have a
> variable holding an instance of a class, then you type "." and get a
> list of methods available... no such thing in functional programming
> where the order is reversed: you have a function and want to apply
> arguments to it. You may list arguments that match that function
> definition and you may even know their types (assuming "intellisense"
> got type inference), but most likely you're not directly applying those
> arguments to the function, but applying some other function to it first.
> It sounds too much of hassle to use "intellisense" in those situations...
Did you know that there's a program called Djinn which can take any
Haskell type signature and generate Haskell source code for it, if it's
possible to write it without recursion?
Of course, there's usually more than one possible expression for a given
type signature. So the code you get may well not be the code you
actually wanted. But still, it's interesting that just a type signature
is sometimes enough to generate useful, runnable code. (Try doing /that/
in a normal programming language...)
> I fear IDEs are really only useful at getting away with lesser
> languages' weaknesses
>
> so, all that would seem to rest of usefulness for an IDE is project
> management.
I do not agree.
Consider the things that a typical IDE does:
- Syntax highlighting. Bracket pairing.
- Generate parts of an expression as you type. (E.g., generate the
matching close bracket, generate the "then" and "else" keywords when you
type "if".)
- Highlight any syntax errors, mismatched brackets, unused variables.
- Allow you to compile the whole project with one keypress.
- Highlight the line of source code that the compiler is complaining about.
- Display a summary of what entities are defined in each file, what
their types are, whether they're public or private, etc.
- Let you navigate to each entity in the list.
- Run the document extraction tool.
- Take you to the documentation for a given entity (regardless of
whether its in your project or an installed 3rd party library).
- Easily launch your application.
- Run your test suite and log the results.
- Integrate with your source control system. Show interactive diffs.
Show the history tree. Manage commits and reverts and branches.
- Integrate with the debugger. Let you single-step through your code.
Let you create watches, inspect variables in scope, drill down through
complex data structures.
Tell me, how do any of these things stop being useful if your
programming language isn't object-oriented?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Warp
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 18 Apr 2012 07:13:35
Message: <4f8ea1df@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> > It can be argued using the same logic as with uninitialized variables,
> > though: There are situations where execution never reaches the end of the
> > function, and hence having a 'return' statement there would be useless.
> Sure. But like I said, the Java compiler seems to detect this.
But the C++ compiler cannot break the standard by making the situation
an error. It can only issue a warning.
(And besides, any kind of detection of this cannot be 100% accurate,
as the problem "will this line of code ever be reached?" is unsolvable
in the general case.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le_Forgeron <lef### [at] free fr> wrote:
> The benefit of class over a simple struct/collection is in the
> private/protected parts, and the mandatory centralisation of the
> prototypes of all related functions (until you start playing with
> friend, but that's another story).
Well, classes also support inheritance and dynamic binding, which
is sometimes useful.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> Hey Warp, you ever think about writing a book? I bet you could do a
> better job than this idiot...
There already exist good books.
If you want to read something actually useful about C++, try the
"Effective" book series by Scott Meyers (or at the very least "Effective
C++" and "More Effective C++"). They actually contain some competent and
easy to understand information.
"Effetive STL" is probably also good.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Invisible
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 18 Apr 2012 08:04:12
Message: <4f8eadbc@news.povray.org>
|
|
 |
|  |
|  |
|
 |
On 18/04/2012 12:13 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>>> It can be argued using the same logic as with uninitialized variables,
>>> though: There are situations where execution never reaches the end of the
>>> function, and hence having a 'return' statement there would be useless.
>
>> Sure. But like I said, the Java compiler seems to detect this.
>
> But the C++ compiler cannot break the standard by making the situation
> an error. It can only issue a warning.
Sure. I understand that. The problem is that the standard requires this
to be permissible. I was just pointing out that "because it's impossible
to detect" is not a valid reason for the standard being written this
way. (Backwards compatibility is, of course.)
> (And besides, any kind of detection of this cannot be 100% accurate,
> as the problem "will this line of code ever be reached?" is unsolvable
> in the general case.)
Sure.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 18/04/2012 12:17 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> Hey Warp, you ever think about writing a book? I bet you could do a
>> better job than this idiot...
>
> There already exist good books.
Well, I guess.
> If you want to read something actually useful about C++, try the
> "Effective" book series by Scott Meyers (or at the very least "Effective
> C++" and "More Effective C++"). They actually contain some competent and
> easy to understand information.
>
> "Effetive STL" is probably also good.
Noted.
(Basically the only reason I'm persisting with this poorly written and
probably outdated text is that we've already bought it. But I'm thinking
it might be better to just save myself the trouble and go read a real
explanation...)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible escreveu:
>> IDEs are only really useful for OO languages.
>
> I do not agree.
>
>> You know, you have a
>> variable holding an instance of a class, then you type "." and get a
>> list of methods available... no such thing in functional programming
>> where the order is reversed: you have a function and want to apply
>> arguments to it. You may list arguments that match that function
>> definition and you may even know their types (assuming "intellisense"
>> got type inference), but most likely you're not directly applying those
>> arguments to the function, but applying some other function to it first.
>> It sounds too much of hassle to use "intellisense" in those situations...
>
> Did you know that there's a program called Djinn which can take any
> Haskell type signature and generate Haskell source code for it, if it's
> possible to write it without recursion?
>
> Of course, there's usually more than one possible expression for a given
> type signature. So the code you get may well not be the code you
> actually wanted. But still, it's interesting that just a type signature
> is sometimes enough to generate useful, runnable code. (Try doing /that/
> in a normal programming language...)
AFAIK, the hindley-milner type system is turing complete, so it's not
surprising at all. So, if you want you may indeed just provide
mind-boggling complex types and let djinn extract the program behaviour
from that, just as a C++ programmer can go overkill and write with
templates a compile-time lisp interpreter and run factorial 100 on it
and just output
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
at run-time.
It's all feasible, just not very useful.
>> I fear IDEs are really only useful at getting away with lesser
>> languages' weaknesses
>>
>> so, all that would seem to rest of usefulness for an IDE is project
>> management.
>
> I do not agree.
>
> Consider the things that a typical IDE does:
>
> - Syntax highlighting. Bracket pairing.
>
> - Generate parts of an expression as you type. (E.g., generate the
> matching close bracket, generate the "then" and "else" keywords when you
> type "if".)
all common features of the most featureless text editors out there
besides scumbag notepad.
> - Highlight any syntax errors, mismatched brackets, unused variables.
that requires a bit more working, specially unused variables.
Mismatched brackets is a (mis)feature of languages that are not lisp. ;)
> - Allow you to compile the whole project with one keypress.
that's only useful for languages still in the old edit-compile-test
cycle... ;)
in any case, even humble C can do that, provided a Makefile is ready.
heck, Makefiles are language-agnostic even...
> - Highlight the line of source code that the compiler is complaining about.
emacs and vim both allow that kind of integration with external tools
such as compilers... I'm sure other featureful text editors too.
> - Display a summary of what entities are defined in each file, what
> their types are, whether they're public or private, etc.
For C/C++ that's as easy as simply taking a look at each header file. :)
> - Let you navigate to each entity in the list.
ever heard of exhuberant C-tags? I'm sure it got support for haskell
too, and is such a tool that generates for a codebase a tags file and
lets you navigate through source code using those tags. Support for it
in both emacs and vim at least.
> - Run the document extraction tool.
what's wrong with man? ;)
> - Take you to the documentation for a given entity (regardless of
> whether its in your project or an installed 3rd party library).
>
> - Easily launch your application.
like ./out ?
> - Run your test suite and log the results.
like ./test > log.txt ?
> - Integrate with your source control system. Show interactive diffs.
> Show the history tree. Manage commits and reverts and branches.
well, I'm stopping now. It's clear you're just a button masher who
enjoys mashing buttons than simply harnessing from an integrated textual
development environment.
> - Integrate with the debugger. Let you single-step through your code.
> Let you create watches, inspect variables in scope, drill down through
> complex data structures.
you are not even talking like a haskeller anymore! Is there such a
haskell debugger? Last time I heard, debugging and lazy evaluation were
at odds...
> Tell me, how do any of these things stop being useful if your
> programming language isn't object-oriented?
They are all very useful and none requiring a bloated and costly IDE.
Intellisense is the only really thing useful in such IDEs, and, like I
said, it's only really useful for OO languages.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Did you know that there's a program called Djinn which can take any
>> Haskell type signature and generate Haskell source code for it, if
>> it's possible to write it without recursion?
>
> AFAIK, the hindley-milner type system is turing complete, so it's not
> surprising at all.
Basic Hindley-Milner isn't Turing-complete, no. Add a few extensions and
it can be /made/ Turing-complete, however.
> So, if you want you may indeed just provide
> mind-boggling complex types and let djinn extract the program behaviour
> from that, just as a C++ programmer can go overkill and write with
> templates a compile-time lisp interpreter
>
> It's all feasible, just not very useful.
Not really.
Suppose I have two Maybe values, and I want a utility function to pick
the first one which has a value in it. I run Djinn and say
select ? Maybe x -> Maybe x -> Maybe x
It immediately replies
select a b =
case a of
Nothing -> b
Just c -> Just c
which is the correct way to do this. (Although ever so slightly more
verbose than necessary.)
Now actually there are /several/ possible functions with this type
signature, and in a sense it's just a fluke that Djinn happens to have
picked the one I wanted. However, this is not exactly a "mind-boggling
complex type". Actually it's a pretty damned /simple/ type. :-P
So far I've fed all sorts of stuff into Djinn, and mostly it produces
the code I wanted. The killer limitation is that it can't handle
recursion. You can't have recursive types, you can't generate recursive
code. That's a pretty big limitation. But for simple boilerplate that
just involves lots of type conversions, it works great!
>> - Allow you to compile the whole project with one keypress.
>
> that's only useful for languages still in the old edit-compile-test
> cycle... ;)
Compiling a program is a useful way to check for errors, even if you
don't intend to actually /run/ it. (Well, it is if you aren't coding in
C anyway...)
> in any case, even humble C can do that, provided a Makefile is ready.
> heck, Makefiles are language-agnostic even...
Makefiles only work on Unix. :-P But hey, you can write a simple script
to build your project under Windows.
The /real/ problem, of course, is that you have to open a command
window, CD to the right folder, and type in "make program1" or whatever.
This takes significantly longer than pressing F7 (or whatever).
Heck, KDevelop lets you have the terminal window embedded right there in
the text editor, and it /still/ takes longer switching back and forth
between windows than it would to just jab a key.
>> - Display a summary of what entities are defined in each file, what
>> their types are, whether they're public or private, etc.
>
> For C/C++ that's as easy as simply taking a look at each header file. :)
...and skipping over all the preprocessor directives, comments, inline
functions, and other cruft. :-P
>> - Let you navigate to each entity in the list.
>
> ever heard of exhuberant C-tags?
What are "tags"?
>> - Run the document extraction tool.
>
> what's wrong with man? ;)
Oh Jesus, where do I even *start* with that??
>> - Easily launch your application.
>
> like ./out ?
Sure, once you take your hands off the keyboard and onto the mouse to
switch from the text editor window to the command prompt window. :-P
> well, I'm stopping now.
...that's not what it looks like from here. ;-)
>> - Integrate with the debugger. Let you single-step through your code.
>> Let you create watches, inspect variables in scope, drill down through
>> complex data structures.
>
> you are not even talking like a haskeller anymore! Is there such a
> haskell debugger?
Yes, there is. OK, it doesn't actually /frigging work properly/, but it
exists. And has a horrifyingly bad UI, BTW. Mainly because trying to do
interactive program exploration using a CLI is really unintuitive.
>> Tell me, how do any of these things stop being useful if your
>> programming language isn't object-oriented?
>
> They are all very useful and none requiring a bloated and costly IDE.
> Intellisense is the only really thing useful in such IDEs, and, like I
> said, it's only really useful for OO languages.
Bloated I'll give you. But costly? Do you have any idea how many free
IDEs there are?
Basically, what you've just said is "you can recreate some of the
features of an /integrated/ development environment by manually linking
tools together yourself". Sure, you can, it's just harder.
For the most part, I use a non-integrated development environment when
I'm coding Haskell. That doesn't mean I don't see the value in something
like Leksah.
An IDE is way, way more than just code completion.
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Francois Labreque
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 09:00:44
Message: <4f900c7c$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Le 2012-04-19 04:17, Invisible a écrit :
>> in any case, even humble C can do that, provided a Makefile is ready.
>> heck, Makefiles are language-agnostic even...
>
> Makefiles only work on Unix. :-P But hey, you can write a simple script
> to build your project under Windows.
WAT?
http://gnuwin32.sourceforge.net/packages/make.htm
http://msdn.microsoft.com/en-us/library/dd9y37ha%28VS.71%29.aspx
>
> The /real/ problem, of course, is that you have to open a command
> window, CD to the right folder, and type in "make program1" or whatever.
> This takes significantly longer than pressing F7 (or whatever).
>
Which you only have to do once... After that you only need to hit
ALT-TAB and the up arrow.
> Heck, KDevelop lets you have the terminal window embedded right there in
> the text editor, and it /still/ takes longer switching back and forth
> between windows than it would to just jab a key.
>
Starting notepad++ and a command prompt take significantly less time
than starting any IDE. So you still have quite a few
"F7-is-faster-than-alt-tab" to do before you catch up...
>>> - Easily launch your application.
>>
>> like ./out ?
>
> Sure, once you take your hands off the keyboard and onto the mouse to
> switch from the text editor window to the command prompt window. :-P
>
As mentioned previously, ALT-TAB. Much faster - and a lot easier on
your elbow and shoulder tendons - than lifting your right hand going
over the numeric keypad and using the mouse.
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* gmail.com */}camera{orthographic location<6,1.25,-6>look_at a }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> in any case, even humble C can do that, provided a Makefile is ready.
>>> heck, Makefiles are language-agnostic even...
>>
>> Makefiles only work on Unix. :-P But hey, you can write a simple script
>> to build your project under Windows.
>
> WAT?
To tell you the truth, I don't even /like/ Make all that much. (I think
it's the tab characters. Or the slightly clunky way it deals with
targets that aren't files.) I only really use it for building C, because
it's either that or work out how to invoke the compiler manually...
But as I say, a tiny amount of shell scripting will automate most tasks,
without the need for Make.
>> The /real/ problem, of course, is that you have to open a command
>> window, CD to the right folder, and type in "make program1" or whatever.
>> This takes significantly longer than pressing F7 (or whatever).
>
> Which you only have to do once... After that you only need to hit
> ALT-TAB and the up arrow.
That works great - /until/ your command history has more than one
command in it. E.g., if you use the same window to run the compiler, run
the main program, and control your SCM. Then you end up jabbing up-arrow
endlessly, or executing the wrong command, or both. Very annoying.
(I wonder why nobody has yet thought of making an editor where you can
add buttons to the toolbar and kind arbitrary commands to them? You
could even give them keyboard shortcuts...)
> Starting notepad++ and a command prompt take significantly less time
> than starting any IDE.
Depends on the IDE. Some are slower than others. I do take your point
though - some of them do take an absurd amount of time to start. Then
again, "you only do that once". :-P
>> Sure, once you take your hands off the keyboard and onto the mouse to
>> switch from the text editor window to the command prompt window. :-P
>>
>
> As mentioned previously, ALT-TAB. Much faster.
And if in the middle of your coding session, you quickly switch to your
email client to check something, next time you try to use Alt+Tab, it
takes you to the wrong window.
It sounds trivial, but it's really very, very annoying.
(It becomes even more fun when what you're working on involves more
windows. E.g., right now I'm writing some TeX, so I have my text editor
open, my command window open, and my DVI window open. You can 100%
guarantee that almost every time I change window I change to the wrong
one...)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 13:08:09
Message: <4f904679@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Francois Labreque escreveu:
> Le 2012-04-19 04:17, Invisible a écrit :
>>> in any case, even humble C can do that, provided a Makefile is ready.
>>> heck, Makefiles are language-agnostic even...
>>
>> Makefiles only work on Unix. :-P But hey, you can write a simple script
>> to build your project under Windows.
>
> WAT?
>
> http://gnuwin32.sourceforge.net/packages/make.htm
> http://msdn.microsoft.com/en-us/library/dd9y37ha%28VS.71%29.aspx
>
>>
>> The /real/ problem, of course, is that you have to open a command
>> window, CD to the right folder, and type in "make program1" or whatever.
>> This takes significantly longer than pressing F7 (or whatever).
>>
>
> Which you only have to do once... After that you only need to hit
> ALT-TAB and the up arrow.
>
>> Heck, KDevelop lets you have the terminal window embedded right there in
>> the text editor, and it /still/ takes longer switching back and forth
>> between windows than it would to just jab a key.
>>
>
> Starting notepad++ and a command prompt take significantly less time
> than starting any IDE. So you still have quite a few
> "F7-is-faster-than-alt-tab" to do before you catch up...
>
>>>> - Easily launch your application.
>>>
>>> like ./out ?
>>
>> Sure, once you take your hands off the keyboard and onto the mouse to
>> switch from the text editor window to the command prompt window. :-P
>>
>
> As mentioned previously, ALT-TAB. Much faster - and a lot easier on
> your elbow and shoulder tendons - than lifting your right hand going
> over the numeric keypad and using the mouse.
thank you ?)
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 13:14:29
Message: <4f9047f5@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Invisible escreveu:
> But as I say, a tiny amount of shell scripting will automate most tasks,
> without the need for Make.
yes. It's easy to rewrite Make from scratch for your every projects.
BTW, do your scripts handle automatic compilation of only the parts that
were last updated?
> That works great - /until/ your command history has more than one
> command in it. E.g., if you use the same window to run the compiler, run
> the main program, and control your SCM. Then you end up jabbing up-arrow
> endlessly, or executing the wrong command, or both. Very annoying.
ctrl+Rghc
ctrl+Rmain
etc
oh, sorry. Forgot you use a lameass DOS command prompt...
> (I wonder why nobody has yet thought of making an editor where you can
> add buttons to the toolbar and kind arbitrary commands to them? You
> could even give them keyboard shortcuts...)
emacs can do that. And any decent text editor allows you to bind some
keyboard shortcut to some command.
>>> Sure, once you take your hands off the keyboard and onto the mouse to
>>> switch from the text editor window to the command prompt window. :-P
>>>
>>
>> As mentioned previously, ALT-TAB. Much faster.
>
> And if in the middle of your coding session, you quickly switch to your
> email client to check something, next time you try to use Alt+Tab, it
> takes you to the wrong window.
it`s much easier when you it all on the command-line. ;)
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid Win7 v1
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 15:10:47
Message: <4f906337$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
On 19/04/2012 06:14 PM, nemesis wrote:
> Invisible escreveu:
>> But as I say, a tiny amount of shell scripting will automate most
>> tasks, without the need for Make.
>
> yes. It's easy to rewrite Make from scratch for your every projects.
>
> BTW, do your scripts handle automatic compilation of only the parts that
> were last updated?
No, my compiler does that. :-P
Besides, compiling the entire thing takes less than 400 ms. Why would I
care about speeding up compilation?
> oh, sorry. Forgot you use a lameass DOS command prompt...
There's a DOS command prompt that /isn't/ lame?
>> (I wonder why nobody has yet thought of making an editor where you can
>> add buttons to the toolbar and kind arbitrary commands to them? You
>> could even give them keyboard shortcuts...)
>
> emacs can do that.
Emacs doesn't even have a GUI yet. :-P
> And any decent text editor allows you to bind some
> keyboard shortcut to some command.
I've yet to find one, but OK.
>>> As mentioned previously, ALT-TAB. Much faster.
>>
>> And if in the middle of your coding session, you quickly switch to
>> your email client to check something, next time you try to use
>> Alt+Tab, it takes you to the wrong window.
>
> it`s much easier when you it all on the command-line. ;)
Yeah. That way you can't look at more than one file at once. Oh, wait...
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 15:32:29
Message: <4f90684d@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Orchid Win7 v1 escreveu:
> On 19/04/2012 06:14 PM, nemesis wrote:
>> BTW, do your scripts handle automatic compilation of only the parts that
>> were last updated?
>
> No, my compiler does that. :-P
so, all your programs are some monolithic piece of software with all
parts compiled in one go?
>> oh, sorry. Forgot you use a lameass DOS command prompt...
>
> There's a DOS command prompt that /isn't/ lame?
No, but there's at least powershell, which is lame *and* heavy.
>>> (I wonder why nobody has yet thought of making an editor where you can
>>> add buttons to the toolbar and kind arbitrary commands to them? You
>>> could even give them keyboard shortcuts...)
>>
>> emacs can do that.
>
> Emacs doesn't even have a GUI yet. :-P
it's GUI is useful enough to have buttons per-mode and to write a web
browser for.
>> And any decent text editor allows you to bind some
>> keyboard shortcut to some command.
>
> I've yet to find one, but OK.
you should look at any editor aside notepad.
>> it`s much easier when you it all on the command-line. ;)
>
> Yeah. That way you can't look at more than one file at once. Oh, wait...
you're nuts. Any decent editor has support for several file buffers.
You may navigate them through with file buffer lists or tag files...
--
a game sig: http://tinyurl.com/d3rxz9
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid Win7 v1
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 15:56:16
Message: <4f906de0$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>>> BTW, do your scripts handle automatic compilation of only the parts that
>>> were last updated?
>>
>> No, my compiler does that. :-P
>
> so, all your programs are some monolithic piece of software with all
> parts compiled in one go?
Yes. Why?
>>> And any decent text editor allows you to bind some
>>> keyboard shortcut to some command.
>>
>> I've yet to find one, but OK.
>
> you should look at any editor aside notepad.
To be fair, SciTE allows you to define what F5, F7 and Ctrl+F7 do. (But
only once per file-extension.) Sadly it doesn't let you do "when I press
F7, compile THAT file, not the file I'm currently editing".
>>> it`s much easier when you it all on the command-line. ;)
>>
>> Yeah. That way you can't look at more than one file at once. Oh, wait...
>
> you're nuts. Any decent editor has support for several file buffers.
Any decent GUI-mode text editor, yes. On the a text terminal, you can't
do that.
(Correction: Emacs can do it. And it looks awful.)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 18/04/2012 12:17 PM, Warp wrote:
> If you want to read something actually useful about C++, try the
> "Effective" book series by Scott Meyers (or at the very least "Effective
> C++" and "More Effective C++"). They actually contain some competent and
> easy to understand information.
>
> "Effetive STL" is probably also good.
I had a look at Effective C++ on Amazon. They let you look at a handful
of pages before you buy it. By doing so, I already learned more about
C++ in a few pages than anything the naff book I'm currently reading
taught me.
On the other hand, it appears to be aimed at people who already know the
C++ language. That isn't really me, yet. I know some of the syntax, but
certainly not all of it, or what all of it actually does.
I'll see what kind of prices I can find for it...
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: nemesis
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 16:31:36
Message: <4f907628@news.povray.org>
|
|
 |
|  |
|  |
|
 |
Orchid Win7 v1 escreveu:
>>>> BTW, do your scripts handle automatic compilation of only the parts
>>>> that
>>>> were last updated?
>>>
>>> No, my compiler does that. :-P
>>
>> so, all your programs are some monolithic piece of software with all
>> parts compiled in one go?
>
> Yes. Why?
because it's both wrong and dumb.
>>>> And any decent text editor allows you to bind some
>>>> keyboard shortcut to some command.
>>>
>>> I've yet to find one, but OK.
>>
>> you should look at any editor aside notepad.
>
> To be fair, SciTE allows you to define what F5, F7 and Ctrl+F7 do. (But
> only once per file-extension.) Sadly it doesn't let you do "when I press
> F7, compile THAT file, not the file I'm currently editing".
yeah, while we're at it, it should also guess that THAT file is the
right file you have in mind...
>>>> it`s much easier when you it all on the command-line. ;)
>>>
>>> Yeah. That way you can't look at more than one file at once. Oh, wait...
>>
>> you're nuts. Any decent editor has support for several file buffers.
>
> Any decent GUI-mode text editor, yes. On the a text terminal, you can't
> do that.
>
> (Correction: Emacs can do it. And it looks awful.)
emacs, vi, pico etc...
it may look awful, but it behaves great. Ever heard "don't judge a book
by its cover"?
Post a reply to this message
|
 |
|  |
|  |
|
 |
From: Orchid Win7 v1
Subject: Re: Teach yourself C++ in 21 strange malfunctions
Date: 19 Apr 2012 16:54:07
Message: <4f907b6f$1@news.povray.org>
|
|
 |
|  |
|  |
|
 |
>>> so, all your programs are some monolithic piece of software with all
>>> parts compiled in one go?
>>
>> Yes. Why?
>
> because it's both wrong and dumb.
That's right up there with saying that Haskell is better than C because
C is both wrong and dumb. Yeah, it's true, but it won't convince anybody...
>>> you should look at any editor aside notepad.
>>
>> To be fair, SciTE allows you to define what F5, F7 and Ctrl+F7 do.
>> (But only once per file-extension.) Sadly it doesn't let you do "when
>> I press F7, compile THAT file, not the file I'm currently editing".
>
> yeah, while we're at it, it should also guess that THAT file is the
> right file you have in mind...
How hard would it be to allow each directory to contain a file saying
what commands each key should be bound to? Or a text box to let you
change it just for this session? Or *something*...
>>> you're nuts. Any decent editor has support for several file buffers.
>>
>> Any decent GUI-mode text editor, yes. On the a text terminal, you
>> can't do that.
>>
>> (Correction: Emacs can do it. And it looks awful.)
>
> emacs, vi, pico etc...
>
> it may look awful, but it behaves great. Ever heard "don't judge a book
> by its cover"?
The whole point of a text editor is for looking at text. Why make it
look awful when you can make it look good? Why make your job harder when
you can make it easier?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |