C++ without forward declarations?

C

collection60

Will C++ ever have Java-like multiple level compiling?

So that we can dump the old model of having to first declare then write
the code?

I find the declaration wastes so much time in coding. It's little more
than something needed for the preprocessor, apart from that it is
ancient junk. It's not needed in Java or other modern OOP languages
(Visual Basic and REALbasic), so why C++?

That's gotta be my biggest gripe with C++. The rest are just stuff I
can live with.

It would be nice if objects had a standardised implementation, also.
Some standard function we could call to get at it's class. Inbuilt
introspection, basically. Java's got introspection... I suppose you can
introspect in C++ if you are willing to do bad things to the memory and
read pointers beyond the class's bounds.
 
C

collection60

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

It's just for syntactic sugar, and it still manages to be wrong!!! Why
not just extend "." (dot) to just work with pointers or references?
That would be more like Java and better.

And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not? This virtual keyword is useless, harmful and annoying.

Why doesn't the compiler also ask me to tell it what registers to stuff
the params in? And if I don't know, it throws an error because it
secretly knew the answer already?

What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

Also, putting functions into the class shouldn't really inline it...
The "inline" keyword should do that. We already have an inline keyword
so why imply that putting it in the class does the same???? It's
redundant. The more ways you have to do the same thing the more bloated
a language becomes :(

Also, shared pointers (like what boost has got), should have been in
C++ by default, even if in the stl. And they should have been promoted
as more important to use than new/delete. new/delete are such overused
concepts, I really do my best to avoid them, but all too often I come
across libraries written by other people using them when they could
have used STL's string or container classes instead. It's annoying.

I think it should be easier to use a shared pointer than it is to do
new/delete. That would be an "implicit" recommendation to do it a
certain way. If you make one technique easier, you are basically
recommending it even if you haven't said "go down this path".

And it shouldn't be possible to use templates on templates, unless they
are typedeffed first :( Template madness really hurts the eyes.

And C++ should have specified some standardised name mangling. Because
linking C++ libraries is impossible due to Bjorne's oversight here. He
should have seen this one ahead of time... Also, the 'this' keyword
should always be the first parameter in terms of the actual stuff going
on in the registers.
 
G

Gianni Mariani

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

It's just for syntactic sugar, and it still manages to be wrong!!! Why
not just extend "." (dot) to just work with pointers or references?
That would be more like Java and better.

I'm not sure what your problem is. Please give concrete examples of
what you'd like to do bearing in mind that C++'s goals, that incidently
were very different to that of Java.
And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not? This virtual keyword is useless, harmful and annoying.

That's a great question. Both are useful. In C++ you can have both.
Why doesn't the compiler also ask me to tell it what registers to stuff
the params in? And if I don't know, it throws an error because it
secretly knew the answer already?

What are you talking about ? The "register" keyword serves a far
different purpose today than it did when compilers were less capable.
Today, the only thing you can count on is that a variable marked as a
register cannot have it's address taken at most giving the optimizer a
hint that the object is not aliased.
What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

That's nice, you're too late. You should have been around 20 years ago
when the discussions about C++ were evolving.
Also, putting functions into the class shouldn't really inline it...
The "inline" keyword should do that. We already have an inline keyword
so why imply that putting it in the class does the same???? It's
redundant. The more ways you have to do the same thing the more bloated
a language becomes :(

The meaning of "inline" and the compiler's choice to actually inline are
two very different things. You should file bugs with the compiler
vendor if you have a problem, you'll find they're very responsive.
Also, shared pointers (like what boost has got), should have been in
C++ by default, even if in the stl. And they should have been promoted
as more important to use than new/delete. new/delete are such overused
concepts, I really do my best to avoid them, but all too often I come
across libraries written by other people using them when they could
have used STL's string or container classes instead. It's annoying.

Smart pointers are relatively new. Compilers only until recently (last
6 years or so) were too buggy. You also have the option of using a
garbage collector -like in Java.
I think it should be easier to use a shared pointer than it is to do
new/delete. That would be an "implicit" recommendation to do it a
certain way. If you make one technique easier, you are basically
recommending it even if you haven't said "go down this path".

No argument. Personally, I don't like boost's shared_ptr, I prever
intrusive reference counts since they cause (imho) less issues.
And it shouldn't be possible to use templates on templates, unless they
are typedeffed first :( Template madness really hurts the eyes.

Ah - welcome to the world of programming the compiler. Templates are an
extremely powerful concept but it does need the user to think very very
differently about programming.
And C++ should have specified some standardised name mangling. Because
linking C++ libraries is impossible due to Bjorne's oversight here. He
should have seen this one ahead of time...

Not at all. There are other much easier ways to do these things that
require no knowledge of name mangling. If you look at the Austria C++
generic factory implementation. It works with dynamically linked
libraries and with absolutely no knowledge of name mangling.

.... Also, the 'this' keyword
should always be the first parameter in terms of the actual stuff going
on in the registers.

Why do you care?

C++ certainly has a number of warts, but it is a far more powerful
language than C. I have not followed JAVA recently, but in my opinion
it has much more flexibility than Java as well but that does mean you
need to put in the time to know the language. When I started messing
with C++ there were very few examples of good uses of C++ so the
learning curve was a bit longer, now that has changed, there are many
good examples of C++ applications that are very very good. The
compilers have only recently (last 2 years) caught up with the standard.

My advice to you is, don't expect C++ to be perfect, it is what it is
and the quicker you learn what it is and stop being frustrated, the
quicker you'll be up the learning curve and useful. Bitching about it
isn't going to help.

As for the perfect langauge, don't hold your breath, if C++/Java etc are
any indication, it will take a long time to get here so you had better
learn to use the tools you have. Still, that should not preclude you
from dreaming about what the perfect language looks like, just don't
expect it to appear unless you're willing to put in some serious energy.
 
M

Mathias Gaunard

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

This is actually why it is good.

It's just for syntactic sugar, and it still manages to be wrong!!!

It's not just syntactic sugar.
And I hardly see how it's wrong.

Why
not just extend "." (dot) to just work with pointers or references?

Because pointers are not objects, but pointers to objects.

That would be more like Java and better.

C++ doesn't aim to be like Java.

And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not?

First, the compiler can't know.
Second, you might want to not use virtual, even when subclassing.

This virtual keyword is useless, harmful and annoying.

It is here to provide polymorphism for those that want it.


What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

The job of a compiler isn't to guess your errors and correct them
automagically.
When errors occur, it tells you what those errors are. It can try to
guess what you did wrong, but that's it.

Also, putting functions into the class shouldn't really inline it...

It doesn't.
It is just a precondition.

The "inline" keyword should do that.

It doesn't either, it's just an advice.

Also, shared pointers (like what boost has got), should have been in
C++ by default, even if in the stl. And they should have been promoted
as more important to use than new/delete.

shared pointers are also overused.
Normally you shouldn't need to use them at all, unless you want to share
data.

new/delete are such overused
concepts, I really do my best to avoid them

Of course you should *never* use them unwrapped, that would cause
obvious exception safety problems.

, but all too often I come
across libraries written by other people using them when they could
have used STL's string or container classes instead. It's annoying.

Unfortunetely, most existing C++ code is bad, mainly because people
believe C++ is C with classes.
There is nothing the C++ language can do about it.

I think it should be easier to use a shared pointer than it is to do
new/delete. That would be an "implicit" recommendation to do it a
certain way.

An implicit recommendation is to favorize allocation on automatic memory
rather than dynamic memory allocation.


And it shouldn't be possible to use templates on templates, unless they
are typedeffed first :( Template madness really hurts the eyes.

That's a stupid idea.

And C++ should have specified some standardised name mangling. Because
linking C++ libraries is impossible due to Bjorne's oversight here. He
should have seen this one ahead of time...

It's possible.


Also, the 'this' keyword
should always be the first parameter in terms of the actual stuff going
on in the registers.

What are you talking about?
 
M

mpa

What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

http://www.cryptonomicon.com/beginning.html

That link points to an essay which everybody who doesn't understand the
essential differences between languages like Java and languages like
C++ should read.

In brief, it explains why professionals use power tools which can kill
people, and why amateurs use safe, heavily-regulated tools that aren't
the least bit dangerous -- but also can't do as much useful work.

It may also be useful to remember that without danger, there is no
romance.

--mpa
 
S

Salt_Peter

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

A reference in Java is not a reference, its a raw pointer. C++'s
reference is not reseatable because thats its purpose. Sorry, Java has
no such thing. C++ references are a Godsend.
C++ also has ways to make a pointer unseatable: int* const p (its so
nice to have choice).
It's just for syntactic sugar, and it still manages to be wrong!!! Why
not just extend "." (dot) to just work with pointers or references?
That would be more like Java and better.

No, it would be uglier. In Java, you don't know if its a pointer or an
instance.
And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not? This virtual keyword is useless, harmful and annoying.

Why doesn't the compiler also ask me to tell it what registers to stuff
the params in? And if I don't know, it throws an error because it
secretly knew the answer already?

What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

Thats a silly comment. You are suggesting that all member functions
should be virtual. What if a member function needs not be virtual? And
most don't. What if you need a static function? What if you need a
pure-virtual member function that is defined? Java does not even allow
that.
Also, putting functions into the class shouldn't really inline it...
The "inline" keyword should do that. We already have an inline keyword
so why imply that putting it in the class does the same???? It's
redundant. The more ways you have to do the same thing the more bloated
a language becomes :(

Inline is a suggestion, whether the function is defined in the
declaration is irrelevant.
Bloated? Here's bloated:
a non-optional GC, a non-optional virtual machine, a ctor that does not
support init lists, etc...
It doesn't get more bloated than that.
Also, shared pointers (like what boost has got), should have been in
C++ by default, even if in the stl. And they should have been promoted
as more important to use than new/delete. new/delete are such overused
concepts, I really do my best to avoid them, but all too often I come
across libraries written by other people using them when they could
have used STL's string or container classes instead. It's annoying.

I think it should be easier to use a shared pointer than it is to do
new/delete. That would be an "implicit" recommendation to do it a
certain way. If you make one technique easier, you are basically
recommending it even if you haven't said "go down this path".

Actually, better than new/delete and better than smart pointers is
using the stack, whenever possible. Gee, does Java have a stack? Yes,
for primitives only, lol.
And it shouldn't be possible to use templates on templates, unless they
are typedeffed first :( Template madness really hurts the eyes.

Really. In Java everything is a template. And worst still - everything
is a template based on Object.
Do you know how many programmers walk in here every week having to
unlearn that sick, bad, demented, ill-conceived and innappropriate way
to code?
In C++, templates are optional, programeable as well as inheritable.
And they are so simple to use. Complete with type-checking help from
the compiler.
And C++ should have specified some standardised name mangling. Because
linking C++ libraries is impossible due to Bjorne's oversight here. He
should have seen this one ahead of time... Also, the 'this' keyword
should always be the first parameter in terms of the actual stuff going
on in the registers.

Namespaces resolve the naming issue. Consider that C++ has a long
history and a need to keep some level of backward compatibility as well
as forward momemtum. Its far from being perfect, buts its done a superb
job so far.

And if you think Java is perfect, then go on, beleive it.
 
N

Nikolaos D. Bougalis

I normally don't respond to trolls, but it's the holidays, so... just this
once...

(e-mail address removed) spewed garbage all over the newsgroup:
It's like a crippled pointer.

Not quite. You're welcome not to use it if you don't like it.

You can't "Reseat" it like you can in Java :(

Oh. Boo hoo. It's not like Java... *cries*

It's just for syntactic sugar, and it still manages to be wrong!!!

It's not just syntactic sugar. As for it being 'wrong' do tell us, how is it
wrong exactly?

> Why
not just extend "." (dot) to just work with pointers or references?
That would be more like Java and better.

Making a single operator work on both pointers and references, hiding the
differences between the two *IS* syntactic sugar. What you just griped against.

As for your "just like Java" = "better" comment, that has got to be the
_dumbest_ thing that I have _ever_ heard.

And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not? This virtual keyword is useless, harmful and annoying.

So you don't have to worry about the overhead of 'virtual' when you don't
need it while still being able to get its benefits when you do.

What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

Just because _you_ don't understand what purpose something serves doesn't
make it stupid. Making grandiose statements about things you don't understand,
however, serves only one purpose: to advertise to everybody just _how_ stupid
you are.

Also, putting functions into the class shouldn't really inline it...

It doesn't. The compiler is free to consider inlining it regardless of where
it is.

The "inline" keyword should do that.

You do understand that 'inline' is just a hint and not a guarantee, right?

I think it should be easier to use a shared pointer than it is to do
new/delete. That would be an "implicit" recommendation to do it a
certain way. If you make one technique easier, you are basically
recommending it even if you haven't said "go down this path".

Yeah, and why don't we do away with new/delete altogether, and blah blah
blah... Oh wait... if you want Java, there's a perfect language for you. It's
called (*drumroll*) Java!

And it shouldn't be possible to use templates on templates, unless they
are typedeffed first :( Template madness really hurts the eyes.

You are, of course, welcome to do that with your own code, to avoid hurting
your beady eyes. But unless you have good _technical_ reasons for what you're
suggesting, take it elsewhere.

And C++ should have specified some standardised name mangling. Because
linking C++ libraries is impossible due to Bjorne's oversight here. He
should have seen this one ahead of time...

Having standardised name-manging is the last thing you need to worry about
for cross-linking stuff from compiler A and compiler B. You have much more
important problems to worry about. I bet that's Bjarne's fault too!

> Also, the 'this' keyword
> should always be the first parameter in terms of the actual stuff going
> on in the registers.

What are you talking about? Registers? C++ knows nothing of registers. How
arguments are passed in between functions is something that is specific to a
particular platform.

-n
 
G

Greg

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

It's just for syntactic sugar, and it still manages to be wrong!!! Why
not just extend "." (dot) to just work with pointers or references?
That would be more like Java and better.

And also, why should we even need to define something as virtual or
not? Shouldn't the compiler know if you've subclasssed a function or
not? This virtual keyword is useless, harmful and annoying.

What a stupid system, to ask the programmer to tell the compiler
something it already knows, just so it can waste his time!!! Really
stupidity. If I were the designer of C++ I'd kill the 'virtual'
keyword.

You should temper your expectations with a dose of realism. A C++
compiler has its hands full coping with naming scopes, deducing
template type arguments and verifying that each source file ends with a
new line - in other words, the stuff that matters. So there are simply
no cycles left over for the types of frivolous luxuries that you are
demanding - or anything else that would make programming in C++ more
convenient for the programmer. It's not a priority of the language, and
it should not be one of your priorities either.

I'm a bit suprised you forgot to mention the preprocessor - C++'s
ace-in-the-hole, a nearly ironclad insurance policy against any kind of
decadent feature (such as automatic "refactoring") available in other
languages, from ever spoiling C++ programmers with its usefulness.
Also, putting functions into the class shouldn't really inline it...
The "inline" keyword should do that. We already have an inline keyword
so why imply that putting it in the class does the same???? It's
redundant. The more ways you have to do the same thing the more bloated
a language becomes :(

The usual response is that the compiler is going to do whatever it
wants so to do anyway, so "inline" exists just to support the fiction
that you have some say in the decision.

Greg
 
A

andrewmcdonagh

Actually, now that I think about it... C++'s & keyword really sucks.

It's like a crippled pointer. You can't "Reseat" it like you can in
Java :(

Just to be clear...

Java's References are nothing like C++ references - the only similarity
is the name. If anything, Java References are closest to C++ pointers,
the only exception being you can't do pointer arithmetic with Java's.

Java References are essentially pointers to Java Objects.

....so you have them already in C++


snipped

Andrew
 
M

Mathias Gaunard

mpa said:
In brief, it explains why professionals use power tools which can kill
people, and why amateurs use safe, heavily-regulated tools that aren't
the least bit dangerous -- but also can't do as much useful work.


C++ isn't really dangerous.
 
Joined
Sep 21, 2013
Messages
1
Reaction score
0

>
> Will C++ ever have Java-like multiple level compiling?


Another whiny jackass to plonk.



Brian[/QUOTE]

What is multiple level compiling?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top