c# is a good way to learn c

?

=?iso-8859-1?Q?Lin=F8nut?=

Greg Cox poked his little head through the XP firewall and said:
Well, yea. What do you think C++ is? Or, in other words, do you think
that the formula handling code in Excel that is written in C++ has to be
completely rewritten to make Excel .NET compatable?

No. Except you softies sound like you are taking a risk leaving the C++
code and memory leaks in place.
 
E

Ernest Borgnine

Greg said:
Given my eighteen years at Microsoft as direct experience, what you
describe sounds very likely how they will move Office into the future.

I don't think Microsoft is going to make it in the next 5 years.

I expect huge declines in their revenues as their Office product sucumbs
to Open Office.

The Australians are already cutting their food supply.
 
C

chrisv

Sean said:
Oh, and chrisv, I agree wholeheartedly with you about Jeff, so...

Cheers Jeff.

And no, I'm not running away, it's not worth my time to try and educate
someone without the ability to see their mistakes. Carry on in your happy
world, assured that you're the greatest programmer the world has ever seen.
And those of us who can actually write *useful* and easily maintainable
programs will continue to get better jobs, whilst you sit in your safe
little 13 year tenure.

*plonk*

I knew you had potential. 8)
 
G

Greg Cox

I don't think Microsoft is going to make it in the next 5 years.

I expect huge declines in their revenues as their Office product sucumbs
to Open Office.

The Australians are already cutting their food supply.

You, of course, are entitled to your opinion. My opinion is that
Microsoft is far too big, far too powerful, far too entrenched, and far
too savvy to just disappear in that short a period of time.
 
B

Bruce Wood

As for your claim that my examples aren't readable,
...I won't be blamed for your lack of effort.

Ahh. I had a feeling that you were an academic. In a world in which
money doesn't matter, I can see your point.

However, in my world money matters. Effort = time = money. Code that is
hard to read costs my business much more money than code that runs a
little slower but is easy to understand. (Note that I said "a little
slower" in order to discourage the inevitable straw-man attacks.) Every
minute I spend trying to decipher spaghetti code like yours is a minute
that my employer has paid me for doing something unproductive. Very
inefficient code, of course, costs my business more money, because it
has to blow more money on hardware. So, we don't write tight,
unreadable code, and we don't write grossly inefficient code. We shoot
for a balance between the two: whatever costs the least in the long
term.

In an academic environment, money is largely irrelevant, which means
that time is largely irrelevant, so producing readable code is also
largely irrelevant. In the business world there is tension between
time-to-market, maintenance cost, the cost for talent performance,
bugginess, software lifetime, and hardware cost. The word there is
"tension": all businesses play these things off against each other and
look for a workable balance: the least expensive balance. This means
that often code does not perform as well as it could, because
performance has been traded off for some other benefit.

In the academic world, time-to-market makes no difference, there is no
maintenance, and software lifetime is irrelevant unless it's an area of
study. That leaves only performance and (the related) hardware cost as
hard considerations, and performance and bugginess as points of pride.
Naturally, academics produce (and value) different code from that which
business users produce (and value).

That's why I liked the Big Ball of Mud academic paper that I posted
earlier. It was the first attempt I'd ever seen on the part of
academics to examine business practices on their own merits, rather
than throught the academic lens. What a pity that they later dumbed it
down for their academic audience.

The great failing I saw during my time in academia was the arrogance
that permeates university computing departments (I can't vouch for
other departments): the assumption that business programmers who make
compromises and ultimately produce large messy systems do so because
they're morons who don't know how to code.

The reality is quite different.

It's easy to produce beautiful little jewels of programs (within the
confines of your personal aesthetics, of course) if you drastically
limit the problem domain. Jeff posted a compact (unreadable) C++
program for doing something-or-other with HTML. (No, I didn't read it
through. My employer doesn't pay me to pore over code samples from
newsgroups unless I'm helping someone solve a problem.) The interesting
point, though is that he solved a well-defined problem within a tiny
problem domain. That's the kind of stuff we pay academics to produce.
Good on him. :)

Business programmers, however, are faced with large, poorly defined
problem domains. On top of being poorly defined (and no, there's no way
to clearly define them), they're constantly changing. Today's great
design is tomorrow's dead end, and there's no way around that, either.
Yes, we could sit in a corner and design some beautiful little jewel of
a program that solves one particular little problem within the
business, but then the business would effectively be paying $100,000
for a program that would give them $10,000 of benefit, and while we're
producing that one beautiful little program, we let hundreds of
thousands of dollars of benefit go by the wayside in the form of other
things we could have been producing. So, the business loses twice: it
pays big bucks to solve a problem that didn't need such an expensive
solution, and tied up its programming staff on one problem while there
were lots of other, more important (in monetary terms) things to do
Anyone who did that in my company would be sidelined and then
downsized, simply because the company would be realizing anything close
to a return on their investment.

There are different pressures in business and different needs. That's
why we need Visual Studio IDEs, piggish, inefficient application
servers, layers upon layers of class hierarchy as support, _and_
academics like Jeff and the folks in Redmond coming up with canned
solutions for us: because we're doing things far, far more complex than
academics are doing, and it's all we can do--even with all of these
tools and all of this support--to keep on top of constantly changing
business needs. Why do you think that Microsoft became the software
giant that it is? Yes, a big part of it was marketing, but not all of
it. MS understands business programming needs much better than, say,
Apple ever did. MS software isn't pretty, but it addresses needs that
academics don't recognize. In business, the best software is that which
saves the most money, either in the short term or the long term
(ideally both). Academics don't "get" this because they're using a
different yardstick to measure success. Gates, for all of his flaws (we
all love to hate him, don't we? :) uses the correct yardstick to appeal
to a business audience and deliver stuff that business needs.

Comparisons are odious, but IMHO Jeff has, with the code he posted,
house-trained a puppy. Congratulations. I'm fighting a hydra, and every
time I slice off a head, two grow back. He can, if he wishes, claim
that I'm having such difficulty because I'm a dolt, and all I have to
do in order to succeed is adopt his solution and scale it up, but
you'll pardon me if I don't buy that for a minute. :)
 
?

=?iso-8859-1?Q?Lin=F8nut?=

Greg Cox poked his little head through the XP firewall and said:
You, of course, are entitled to your opinion. My opinion is that
Microsoft is far too big, far too powerful, far too entrenched, and far
too savvy to just disappear in that short a period of time.

I hope IBM does Microsoft the courtesy of a reach-around.
 
T

The Ghost In The Machine

In comp.os.linux.advocacy, Jeff_Relf
<[email protected]>
wrote
Hi Sean_Hederman, Sorry about my late reply,
but there are only so many hours in a day, ya know.

The following code Should work in MS_CPP_7_1,
but it doesn't due to a ( ¿ unreported ) bug in MS_CPP_7_1:

typedef unsigned __int8 * uint_8_P ;
__int32 Swap_32 ( __int32 X ) { uint_8_P P = ( uint_8_P ) & X + 4 ;
return * -- P << 24 | * -- P << 16 | * -- P << 8 | * -- P ; }

Hm...where to start?

[1] __int8 isn't exactly standard.
[2] The expression

* -- P << 24 | * -- P << 16 | * -- P << 8 | * -- P

can be evaluated in any order the compiler chooses, as '|' is
commutative (a|b == b|a) and associative (a|(b|c) == (a|b)|c).
(If overloaded, of course, things get interesting. I'd
frankly have to research it.) Of course, because of the side
effects, the commutativity sort of goes out the window, but
AFAIK (Kelsey, are you still with us or have you given up on
this thread? :) ) expressions of this sort are undefined for
precisely this reason.

[3] Endianity yet again rears its head. However, this is probably
outside of the code you're presenting here.
As I said in another post,
the execution should go left to right but it doesn't
instead it does a P -= 4 first thing.

Probably because of code motion. The compiler has that option:

int a[10][10];

for(int i = 0; i < 10; i ++)
{
int j = 1;

a[j] = 0;
}

will probably move the 'j' assignment outside of the loop,
for example.
An interesting anomaly is how this works ( rv is an int ):
( rv = * -- P << 24 ) | ( rv = * -- P << 16 )
but this does not: ( * -- P << 24 ) | ( * -- P << 16 )

Looks like you're fighting the optimizer, then.
As for your:
int swapped = System.Net.IPAddress.NetworkToHostOrder( unswapped );

X.CPP does it like this:
Host_IP.sin_port = htons( Port = Serv->Port );

But that's not what I'd use to convert a .WAV file.
At any rate, it was just a trivial quiz.

You wouldn't want to use htons() anyway for that. ntohs(), maybe,
and only if you know you want to convert it. (Network-order is
big-endian.)
By the way, you keep insisting that I care only about fast code,
and I keep insisting that I care only about results.
Code is what it does. Are you projecting ? I imagine so.

As for your claim that my examples aren't readable,
...I won't be blamed for your lack of effort.

Admittedly, you've, erm, impressed us with the readability
of your code. I think Kelsey has, too -- but I know whose
code I'd prefer to maintain. :)
 
C

chrisv

Bruce said:
you'll pardon me if I don't buy that for a minute.

The Relf troll thanks you for feeding it. Now, pardon me while I
*plonk* you, for being stupid-enough to think that the troll hasn't
heard it all before.
 
G

gerry

That wasn't any plonk.
I hadn't seen your previous posts and thought 'Relf' was some new acronym I
wasn't familiar with.
Although something tells me, now that I have seen your posts, that it just
might end up being some type of acronym in the future.
btw i was referring to guitarist keith relf of the yardbirds
 
T

The Ghost In The Machine

In comp.os.linux.advocacy, Sean Hederman
<[email protected]>
wrote

For the record:

32 = 0x00000020
536870912 = 0x20000000
538976288 = 0x20202020

Interesting glitch.

[snip for brevity]
I know Modula-2 well thanks. If you want to write Modula-2 then do so.

Uh...you sure you want him to be writing code in *three* languages? :)
(He already mangles C/C++ -- which for purposes of this discussion
is pretty much one language, the way Jeff uses it! -- and, presumably,
Visual Basic, which is apparently an adjunct to his X.CPP.)
My
point about the differentiating on casing is not whether *you* understand it
or not, but whether anyone else might get confused. It seems a brilliant
example of deliberately trying to confuse a casual reader.

Actually, in his case it's probably more like trying to
squish as much code in his screen as will uncomfortably
fit, readability be damned.

Probably not a bad thing for him -- but to the rest of us,
it looks like parrot droppings.
Strange, you #define C to be like Basic/Modula-2 and then you say you don't
like Basic. A little cognitive dissonance there I see.

Not sure it's anything near like Basic. It's probably more like
Relfic -- a language that nobody else has ever invented. :)

AIUI, he's unemployed. I wonder why...
I shouldn't have to spend hours poring over your code to
find out what it does. Good code is more like an essay.
Clear, commented, and well laid out. Yours is quite
clearly none of those things.

There's at least one court ruling (I'd have to find it) that
states that a certain subset of code (relating to crypto)
is free speech -- and any code could be construed as a medium of
communication both to computer and to developer. Certainly
good code should be clear to both; of course, code is always
clear to the computer (as the computer only reads machine
code anyway) but when was the last time you or I actually
wanted to pore over core dumps? :)

So we use automated translators -- compilers -- to make our
wishes known, and sometimes the translation goes very badly
awry -- Jeff's "Swap_32()" being a case in point. In Jeff's
case it's probably because of a misuse of the language.
 
G

Greg Cox

=?iso-8859-1?Q? said:
Greg Cox poked his little head through the XP firewall and said:


No. Except you softies sound like you are taking a risk leaving the C++
code and memory leaks in place.

To be accurate, I'm an ex-softie...

As to the rest, what are you talking about? Are you actually saying it
would be better to dump a million lines of existing C++ code with 99%+
of the bugs already fixed and rewrite from scratch rather than reuse the
code and spend resources fixing the remaining bugs?
 
S

Sean Hederman

message [Snip]
For the record:
32 = 0x00000020
536870912 = 0x20000000
538976288 = 0x20202020

Interesting glitch.

Yeah, I saw that when I ran it, I just the assumed result was a mistake in
Relfies code. Couldn't be bothered to load another C++ compiler to check
this; Can you confirm it's okay on non-MS compilers? If so that's a pretty
shocking MS C++ bug, no matter how much Relf abuses the edges of the C++
standard.
[snip for brevity]
Uh...you sure you want him to be writing code in *three* languages? :)
(He already mangles C/C++ -- which for purposes of this discussion
is pretty much one language, the way Jeff uses it! -- and, presumably,
Visual Basic, which is apparently an adjunct to his X.CPP.) ....
Actually, in his case it's probably more like trying to
squish as much code in his screen as will uncomfortably
fit, readability be damned.

Probably not a bad thing for him -- but to the rest of us,
it looks like parrot droppings. ....
Not sure it's anything near like Basic. It's probably more like
Relfic -- a language that nobody else has ever invented. :)

Who woulda thunk that a major MS semi-fan like me would have so much in
common with a raving linux fundi ? ;-)
There's at least one court ruling (I'd have to find it) that
states that a certain subset of code (relating to crypto)
is free speech -- and any code could be construed as a medium of
communication both to computer and to developer. Certainly
good code should be clear to both; of course, code is always
clear to the computer (as the computer only reads machine
code anyway) but when was the last time you or I actually
wanted to pore over core dumps? :)

So we use automated translators -- compilers -- to make our
wishes known, and sometimes the translation goes very badly
awry -- Jeff's "Swap_32()" being a case in point. In Jeff's
case it's probably because of a misuse of the language.

Does this mean I can sue Jeff for abusing my First Amendment rights? Oh,
bugger, I'm not American dammit. I'd be interested in reading that ruling if
you manage to find it though, sounds interesting.
 
S

Sean Hederman

chrisv said:
I knew you had potential. 8)

Thanks. Hate giving up on a cause no matter how hopeless, but there's a
limit y'know? Used to spend ages bashing my head against a twit called
Boatwright years ago in a non-programming forum. Feels the same. At the end
of the day I have a sore head and the nitwit is still a nitwit.
 
S

Sean Hederman

Linønut said:
I hope IBM does Microsoft the courtesy of a reach-around.

It would be ironic and quite funny, but I doubt it for the following
reasons:
1- It would be really silly for MS to get shafted by the same strategy that
they used to shaft Big Blue, specially whilst some of the participants are
still around.
2 - IBM is moving more to services-based solutions whilst MS are more
product-based. Only thing that'll seriously impact MS will be the
commoditisation of their core products (see OpenOffice/Linux for potential
here).
3 - Assumes that MS is a stationary target. It's not. They're moving pretty
hard. I'm not 100% sure where yet, but they are moving. I *think* they're
moving to truly implement the Sun "network is the computer" vision, but
we'll see.
4- I always assumed that the reason for IBM's support of Linux was as an
upgrade path to AIX (see the efforts they made to make the 2 interoperable).
However this doesn't seem to be the case anymore, since IBM are loading
their top-end servers with Linux too. Interesting, and I assume just
reinforces the whole IBM -> services thing. I know this isn't a real point,
but I'm tired and I wanted to say this.
5 - Resurgent MS security initiatives. Whether these actually combine to
produce an OS/platform more secure than Linux in the long-term is in the
air, but given Linux's lack of desktop penetration, a perception that MS is
more (or as) secure could be a killer to one of Linux's main
differentiators.

Things for
1 - MS's biggest potential problem is twofold: the high complexity of the
installed products, and the expectation of backwards compatibility. These
two could easily combine to make the maintenance requirements be the driving
part of MS's business. It's already evident to some degree or another in
some of their longer running products, but not too serious yet.
2 - "What the hell do I develop for?" syndrome. COM? COM+? .NET? 1.0, 1.1,
2.0? Win32? WinFX?
3 - Maybe there's more money in services than in products. Long-term this is
virtually assured.
4 - OSS commoditises core MS product lines. Already happenning with browser,
possible with office productivity, still "almost there" with OS. We'll see,
but this one's a giant-killer.
5 - Google-like killer app wipes out one of MS's core lines, whilst at the
same time other companies/governments line up for the kill.

The fact of the matter is that MS isn't going anywhere, and any hopes in
that direction are premature in the extreme. Now just reread that sentence
and replace "MS" with Linux. Cool. Now with "Java". Right. Now with "Cobol".
Aw crap.
 
J

Jeff_Relf

Hi Gerry, Re: The name Relf, You told me: <<
I hadn't seen your previous posts and thought 'Relf'
was some new acronym I wasn't familiar with.
Although something tells me, now that I have seen your posts,
that it just might end up being some type of acronym in the future.
btw I was referring to guitarist keith relf of the yardbirds. >>

Hmm... now ya got me thinking,
How about, R.E.L.F., Raging Elephants Looking ****ed.
 
J

Jeff_Relf

Hey Spooky ! ( Mr. Coders_Are_Friends_of_Mine_and_Relf_is_No_Coder )

Hederman has me plonked and you, knowning better,
are telling him I'm unemployed.

You think I'm lying when I repeatedly tell you that
only coding has paid my rent since the start of 1982 ?

I delivered code to paying customers 2 hours ago...
What about you, Mr. Coders_Are_Friends_of_Mine_and_Relf_is_No_Coder ! ? ?

And, No, I'm not being rhetorical here... I want an answer... Mr. Dodger.

You concluded: <<
So we use automated translators -- compilers -- to make our
wishes known, and sometimes the translation goes very badly awry
-- Jeff's "Swap_32()" being a case in point.
In Jeff's case it's probably because of a misuse of the language.

Well, Mr. Coders_Are_Friends_of_Mine_and_Relf_is_No_Coder,
do you think you could compile the code below and tell me the result ?

typedef unsigned char * uint_8_P ;
int Swap_32 ( int X ) { uint_8_P P = ( uint_8_P ) & X + 4 ;
return * -- P << 24 | * -- P << 16 | * -- P << 8 | * -- P ; }
main() { printf( "%x", Swap_32( 0x84838281 ) ); }
 
J

Jeff_Relf

Hi Spooky, Now you are Really pissing me off.

Acording to MS_CPP_7_1's documentation,
the following code is executed left to right O N L Y !
return * -- P << 24 | * -- P << 16 | * -- P << 8 | * -- P ;

It's called Precedence... look it up.
http://msdn.microsoft.com/library/d...s/vclang/html/_pluslang_c.2b2b_.operators.asp

Operator |
Name Bitwise inclusive OR
Associativity Left to right

Re: Why the code above doesn't work in MS_CPP_7_1,
You told me: <<
Probably because of code motion. The compiler has that option: ... >>

No... No... No... I has to follow the left to right standard.
It's a bug in MS_CPP_7_1,
try it with your gcc compiler and tell me the result.

Here's a hint, you don't have to use my __int8:

typedef unsigned char * uint_8_P ;

int Swap_32 ( int X ) { uint_8_P P = ( uint_8_P ) & X + 4 ;
return * -- P << 24 | * -- P << 16 | * -- P << 8 | * -- P ; }
main() { printf( "%x", Swap_32( 0x84838281 ) ); }


Re: How this works ( rv is an int ):
( rv = * -- P << 24 ) | ( rv = * -- P << 16 )
but this does not: ( * -- P << 24 ) | ( * -- P << 16 )

You told me: << Looks like you're fighting the optimizer, then. >>

What optimizer ? I'm looking at this in the debugger... of course.

Re: X.CPP's Host_IP.sin_port = htons( Port = Serv->Port );

You told me: << You wouldn't want to use htons() anyway for that.
ntohs(), maybe, and only if you know you want to convert it.
( Network-order is big-endian. ) >>

The code above works... I've connected to tons of servers with it.

You concluded: <<
Admittedly, you've, erm, impressed us with the readability of your code.
I think Kelsey has, too -- but I know whose code I'd prefer to maintain.
:) >>

I wouldn't want you anywhere near my code.
 
J

Jeff_Relf

Hi Bruce_Wood, Re: Your long essay about
why you think my code is too academic for the commercial world,

I'm both commercial and academic.
For example, I delivered code to paying customers not 3 hours ago.
But my customers are all professors, FDIC regulators and the like.

I've been involved in Computer_Based_Training, most of my career.
For example, training Boeing's customers, both piolots and mechanics.

You concluded: <<
Comparisons are odious, but IMHO Jeff has, with the code he posted,
house-trained a puppy. Congratulations. I'm fighting a hydra,
and every time I slice off a head, two grow back.
He can, if he wishes, claim that I'm having such difficulty
because I'm a dolt, and all I have to do in order to succeed
is adopt his solution and scale it up,
but you'll pardon me if I don't buy that for a minute. :) >>

The HTM_TXT.CPP code that I showed
is a Tiny piece of Simple code from my hyper_custom newsreader, X.CPP .
If it's a hydra you want, look at X.CPP .

You pass HTM_TXT.EXE a .HTML file and it spits out a .TXT file.
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.EXE
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.CPP
http://www.Cotse.NET/users/jeffrelf/HTM_TXT.VCPROJ

These are tags: <! Comment --> <Alpha> </Alpha>
But, due to the leading space, < Alpha> is not.
&Unknown is also sent through untranslated, for obvious reasons.

Pardon me if that was beyond you,
but please don't blame me for your lack of effort/literacy.
 

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

Top