c# is a good way to learn c

J

Jeff_Relf

Hi Sean_Hederman ( and Tom, Olaf ),
Re: Why I don't like the higher level tools in C++ and C#,
You asked me: << So, if you want to draw a rectangle to the screen,
you directly manipulate the screen buffer I take it ? >>

Try to follow the bouncing ball... will ya ?
The comparison was:
C vs the higher level General_Purpose_Tools found in C++ and C#.

Obviously, I link with stuff like Direct_Draw_7 and OLE sometimes.

In Microsoft C++ 7.1, I use these macros for drawing lines:
#define mt( x, y ) MoveToEx( DC, x, y, 0 )
#define lt( x, y ) LineTo( DC, x, y )

And, while the higher level Tools found in C# don't apeal to me,
the lower level tools, like macros, are oddly Verboten .

For example, how would you write this high/low byte swapper in C # ?
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 ; }

LoopTo() and ER(), shown below, are the Tools I prefer,
but C# doesn't allow macros like that.
So how would you write this in C# ?
// Because NNTP servers require newsgroup lists
// to be case sensitive with no spaces
// LowerCaseNG() converts: Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy
// to: alt.os.windows-xp,comp.os.linux.advocacy

#define LOOP while ( 1 )
#define \
LoopTo( StopCond ) \
while ( Ch && ( Ch = ( uchar ) * ++ P \
, Ch2 = ( uchar ) P [ 1 ] \
, Ch ) \
&& ! ( StopCond ) )

typedef char * LnP ; // The name LnP comes from a naming convention I use.

int rv ; // Although it's a global, rv is what I call a Super_Temp.

// ER() and er() are shorthand for Bigg_ER() and Small_er()

__int64 ER( __int64 X, __int64 Y ) { return X > Y ? X : Y ; }
__int64 er ( __int64 X, __int64 Y ) { return X < Y ? X : Y ; }

LnP LowerCaseNG ( LnP Mixed ) { static LnP B; static int Sz_B ;
rv = ER( 200, strlen ( Mixed ) + 1 );
if ( Sz_B != rv ) { free ( B ); B = ( LnP ) malloc( Sz_B = rv ); }
LnP P = Mixed, D = B - 1 ; int Ch = * P --, Ch2 = 0 ;
LoopTo ( 0 ) if ( Ch > 32 && Ch < 128 ) * ++ D = tolower ( Ch );
* ++ D = 0 ; return B ; }

main() {
printf( "%s"
, LowerCaseNG ( "Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy" ); LOOP; }

Except for the main() part, the code above is from:
http://www.Cotse.NET/users/jeffrelf/X.CPP

Re: My comment that I don't like the look of String, cout or the STL,

You told me: << Good one. Haven't laughed that hard for a while.
If someone told me some drek like that in an interview,
it'd be sayonara baby, call me when you're mature enough to actually solve
the problems that confront our customers at a reasonable price. >>

Nice delusion, but you're not my employer.

I delivered code just yesterday to a Banking School in Madison Wisconsin.
( I'm the coder, not the designer )
I've held the same job since mid 1993... how about you ?
Only coding has paid my rent ever since the start of 1982... how about you ?
I've never been fired or sued... how about you ?
Being employed has never been a concern of mine... how about you ?

Re: http://www.Cotse.NET/users/jeffrelf/X.CPP

You asked me: << Why didn't you include your:
#define LOOP while ( 1 )
#define Loop( N ) int J = - 1, LLL = N ; while ( ++ J < LLL )
#define LoopXx( Xx ) Xx##P P = 0 ; int J = -1 ; \
Xx##A BB = Xx.BB, EE = Xx.PP + 1, PP = BB - 1 ; \
if ( BB ) while ( ++ J, P = * ++ PP, PP < EE )

or any other of the staggeringly bad C++ code in your example.
Frankly, the only time I've ever seen worse C coding
is in the Obfuscated C contests, and they're trying to write bad code,
not proclaiming it as good code.
One of my developers writes uncommented spaghetti crap like that
and I'd fire them on the spot. >>

Loop() is great shorthand, much better than for(;;) or whatever it is you use.

I only care about what makes my code more readable,
your delusions about being my employer don't interest me in the least.
 
B

billwg

Linønut said:
"inhouse line of business applications" -- can you give me some examples of
such applications, as I'm not familiar with this particular application
niche.
Heavens, nut, you're totally missing the boat! Too much time spent
defending the OSS initiatives probably.

This kind of stuff is the mainstay of programming and the reason that
Microsoft and Sun and IBM and all the others are so filthy rich while
you get assigned to documentation duties.

As an example, take a company that wants to automate their accounts
payable system for reimbursing salesmen for their excessive travel and
entertainment account expenses. They will do an "inhouse business
application" using their own staff, if the company is large enough, or a
local "consultant" if they don't have their own staff.

The system would be designed with a database piece, e-mail notification
piece, website webform piece, etc. These are the kinds of applications
that Java was created for and is principally used for and also where
..NET mostly lives.

What Microsoft has done is flesh out the java language, which was sort
of a subset of C++ to begin with, a little, but mostly the .NET
framework means the System namespace functions that make it so easy for
an applications person to conjure up a highly functional business app.
You have to see it to understand it.

If you are familiar with C++ in system situations, as you say, think
about what it takes to connect a program to a database, authenticating
the user and keeping him in a safe sandbox, querying for necessary
information and presenting it for edit/create/update. It takes some
code and takes some iterations and takes some time, no matter how great
you are at C++ and the interfaces you have to access.

With .NET and C# or VB.NET (doesn't matter, they are the same thing in
the end) you just graphically access a data connection and stored
procedure and whatever presentation controls make sense, dragging them
onto the form and giving them names if you don't like DataConnection1,
and DataAdapter2, and suchlike naming. The .NET plumbing is
automatically hooked up by simple wizard-generated code and you are
ready to test.

..NET goes beyond java in dumbing down the computer science to a point
where it is simple rote actions and all you need to know is application
dependent information, such as what you want the application to do
vis-a-vis the business. This so-called business logic still needs to be
directly coded into the application's forms or modules, but you can get
away with knowing next to nothing at all about the plumbing behind the
scenes.
 
B

billwg

Jeff_Relf said:
Hi Olaf_Baeyens, Re: My comment that experienced C coders
don't require weeks just to create a button,

You told me: << I was making it sounding a little bit more dramatic. :)
I was not referring to the button itself, but about the code behind that
button that should interoperate with the user interface.
E.g. active feed-back like a status bar, progress bar. >>

It takes years to really perfect code,
because testing dwarfs the time it took to bang out the code.

During those years, short-sighted compromises,
like using C#, Java, COM or HTML, can come back to bite you,
...beacuse the C++ guy could sneek up behind you and offer a better product.
A lot of hypothetical results and not much logic there, Jeff.

With C# the button is already designed and you just drag it into the
product from a list and place it on a form that uses it. The code
behind it is mostly there automatically. You can give it a name that
you like, else the IDE will give it a unique name anyway. It likes to
start with Button1.
 
J

Jeff_Relf

Hi Linonut, Re: Why you don't use your real name,

I use my real name, and, although I have written some embarrassing stuff,
I can't think of who'd care about that or why.

Also, I barely remember what spam is, I get so little of it.

On_the_fly e-mail aliases via Cotse.NET kills spam dead.
Aliases allow me to precisely identify all senders,
....I kill the sender's alias if he bothers me.

My hyper_custom e-mail client, X.EXE, automatically assigns aliases.

Firefox, of course, blocks all pop-ups and makes Flash Click_to_play.
 
J

Jeff_Relf

Hi Olaf_Baeyens, Re: Pete's: << begin virus.scr Olaf Baeyens wrote: >>,
Ya told me: << Odd that the " virus.scr Olaf Baeyens wrote " part
ended up as an attachment in Outlook express. >>

That's an Outlook flaw. I recomend that you use 40tude_Dialog instead.

You asked me: << And who is JBailo ??? >>

I have No idea, but I think he's the Don Quixote of Linuxdom.
His/Her real name is Joan_Fickle_Bailo .
I love his posts because he's the only one 'round here that talks about:
Food, music, sex, jokes, computers, physics, Seattle, securities, etc.

Everyone else is too worried about being Off_Topic .

Re: Peter_Kolemann's insane posts, You asked: <<
But the real message would have looked like this I assume: ... >>

Use Google's advanced search to find Pete's:
and then click the link that shows you the Original article.
 
O

Olaf Baeyens

Outlook flaw or not, his mesages are the only ones that I cannot read.
And I am not going to decode every message he sends.

But I am wondering why the "virus.scr" part is included in the text?
A "virus"= something bad.
A ".scr" = screen saver on Windows machines.

And a "virus.scr" seems to look like a screen saver containing a virus from
the point of simple user view.
Especially when found in the attachment and when clicked has a attachment
filename: "virus.scr Olaf Baeyens wrote"

Unless it is his intention to scare people or shock people, it is not a very
wise choice to keep it like that even when it is a bug in Outlook express.
 
J

Jeff_Relf

Hi billwg, Re: How a C++ coder could easily beat a C# coder,
You told me: << A lot of hypothetical results and not much logic there, Jeff.
With C# the button is already designed
and you just drag it into the product
from a list and place it on a form that uses it.
The code behind it is mostly there automatically.
You can give it a name that you like,
else the IDE will give it a unique name anyway.
It likes to start with Button1. >>

C#'s dialog editor stinks.
Your Button1, for example, is just a window of the BUTTON class,
and it doesn't scale well to different screens.

Fonts are often too small or too large,
and text often doesn't fit inside the Button1, for example.

My X.CPP employs only one window, created by a call to CreateWindowExA().
The window is always maximized, with only Win_XP's Start bar showing,
it has no pop-ups as a rule.

Black is always the background color, even when highlighting,

The font is always 80 columns, monospaced,
with nothing automatically wrapped, as a rule
....wrapping is done only by hand.

Of course X has no editor at the moment, it uses Visual_Studio,
so who am I to talk ?

But just the Idea of writting my own editor,
using only one window, appeals to me.
 
J

Jeff_Relf

Hi Olaf_Baeyens, Re: Peter_Kolemann's tolling,
You told me: << Outlook flaw or not,
his mesages are the only ones that I cannot read.
And I am not going to decode every message he sends. >>

You're not missing anything trust me. He does that to annoy people.
He redirects people's relies to him to parts unknown for the same reason.

You asked me: <<
But I am wondering why the "virus.scr" part is included in the text ?
A "virus"= something bad. A ".scr" = screen saver on Windows machines.

And a "virus.scr" seems to look like
a screen saver containing a virus from the point of simple user view.
Especially when found in the attachment
and when clicked has a attachment filename: "virus.scr Olaf Baeyens wrote"

Unless it is his intention to scare people or shock people,
it is not a very wise choice to keep it like that
even when it is a bug in Outlook express. >>

People tell him that all the time,
that's about that only thing he enjoys talking about,
....you just made his day.
 
C

chrisv

Olaf said:
Unless it is his intention to scare people or shock people, it is not a very
wise choice to keep it like that even when it is a bug in Outlook express.

Idiot. It's obviously intentional.
 
T

Tom Shelton

Tom Shelton poked his little head through the XP firewall and said:


Actually, this looks pretty neat, much cleaner-looking than defining
const MyProperty & operator = (int i) and operator int ().

I assume C# allows statement such as:

a = b = c = d;

Yes...
 
S

Sean Hederman

Jeff_Relf said:
For example, how would you write this high/low byte swapper in C # ?
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 ; }

Ummm, actually it does nothing of the sort. Swapping the high and low bytes
of the number 32 gives me 536870912, and your result is 538976288. And in C#
the code would be:
int swapped = System.Net.IPAddress.NetworkToHostOrder(unswapped);

So, not only is your code wrong, but I can get the *correct* result in one
line. Oh and by the way I tested NetworkToHostOrder and it *does* swap the
bytes correctly.

[Snip a whole bunch of crappy macro-infested spaghetti code]
main() {
printf( "%s"
, LowerCaseNG ( "Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy" ); LOOP; }

string name = "Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy";
Console.Write(name.ToLower());
Except for the main() part, the code above is from:
http://www.Cotse.NET/users/jeffrelf/X.CPP

Re: My comment that I don't like the look of String, cout or the STL,

You told me: << Good one. Haven't laughed that hard for a while.
If someone told me some drek like that in an interview,
it'd be sayonara baby, call me when you're mature enough to actually
solve
the problems that confront our customers at a reasonable price. >>

Nice delusion, but you're not my employer.

I delivered code just yesterday to a Banking School in Madison Wisconsin.
( I'm the coder, not the designer )
I've held the same job since mid 1993... how about you ?

Nope, been headhunted 4 times in that period though.
Only coding has paid my rent ever since the start of 1982... how about you
?

Coding is my sole means of support, has been since I left varsity, and I
live a very comfortable life, if that's what you're asking.
I've never been fired or sued... how about you ?
Being employed has never been a concern of mine... how about you ?

Nope and nope.

[Snip more "code"]
Loop() is great shorthand, much better than for(;;) or whatever it is you
use.

Um, and having LOOP and Loop defined? You don't think that's a bad idea.
Look, if you want to write BASIC, it's much easier just to get a BASIC
compiler than to try to #define C++ into it.
I only care about what makes my code more readable,

You honestly believe that drek is readable? No comments, spaghetti code,
#define abuse that should be criminal, and non-semantic variable names.
 
T

Tukla Ratte

Montrose... said:
I thouroughly agree.

I can easily see a 'tipping point' for c# where java will all but be
eradicated.

It won't be any time soon, though. After all, COBOL is still being used
for a lot of new development, and Java is getting to be just as embedded.
 
S

Sean Hederman

Linønut said:
Sean Hederman poked his little head through the XP firewall and said:

Because it doesn't guarantee slower development and more bugs, in our
hands.

Never once had a dangling pointer, unreclaimed memory, or a buffer overflow
then? C# has an easier syntax with less typing for the most part, so
logically if one was as proficient in C# as in C++, one's productivity would
be higher. This excludes the various visual designers and the powerful
libraries.
Also, we aren't doing "standard Windows business apps", we're doing
client/server stuff on a small network and reading information of off
ancient hardware.

Unless there's serious resource constraints/portability requirements, C#
should be able to do that easily.
 
T

Tukla Ratte

Tried a couple of other newsreaders, didn't like them. Got any good
suggestions that run on Windows?

I used Forte Free Agent for many years, even after I'd switched to
Linux (ran it under Win4Lin). Of course, I don't use killfiles....
 
A

American Pope

Sean said:
Ummm, actually it does nothing of the sort. Swapping the high and low bytes
of the number 32 gives me 536870912, and your result is 538976288. And in C#
the code would be:
int swapped = System.Net.IPAddress.NetworkToHostOrder(unswapped);

The one thing that Relf's code does has hands down is speed.

For example, he built a search module that can find all matches in < 1ms.

I rewrote the search in c#.net, c#.mono (run on Linux) and java (run on
windows/linux).

In each case the search was from one ( ~10ms ) to two orders of
magnitude ( ~100ms ) ( java being the fastest and c#.mono being the
slowest ). .Net's problems with Regex have been documented around the
web. And when I looked at the mono source code it was using a modified
verion of a standard text search algorithm, whereas Relf had written his
own search...my guess is that he used a far less efficient algorithm.

In a situation where you want to substitute the .Net libraries for c,
you then have to accept order of magnatude decrease in performance?!


So, not only is your code wrong, but I can get the *correct* result in one
line. Oh and by the way I tested NetworkToHostOrder and it *does* swap the
bytes correctly.

[Snip a whole bunch of crappy macro-infested spaghetti code]
main() {
printf( "%s"
, LowerCaseNG ( "Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy" ); LOOP; }


string name = "Alt.OS.Windows-XP, Comp.OS.Linux.Advocacy";
Console.Write(name.ToLower());

Except for the main() part, the code above is from:
http://www.Cotse.NET/users/jeffrelf/X.CPP

Re: My comment that I don't like the look of String, cout or the STL,

You told me: << Good one. Haven't laughed that hard for a while.
If someone told me some drek like that in an interview,
it'd be sayonara baby, call me when you're mature enough to actually
solve
the problems that confront our customers at a reasonable price. >>

Nice delusion, but you're not my employer.

I delivered code just yesterday to a Banking School in Madison Wisconsin.
( I'm the coder, not the designer )
I've held the same job since mid 1993... how about you ?


Nope, been headhunted 4 times in that period though.

Only coding has paid my rent ever since the start of 1982... how about you
?


Coding is my sole means of support, has been since I left varsity, and I
live a very comfortable life, if that's what you're asking.

I've never been fired or sued... how about you ?
Being employed has never been a concern of mine... how about you ?


Nope and nope.

[Snip more "code"]
Loop() is great shorthand, much better than for(;;) or whatever it is you
use.


Um, and having LOOP and Loop defined? You don't think that's a bad idea.
Look, if you want to write BASIC, it's much easier just to get a BASIC
compiler than to try to #define C++ into it.

I only care about what makes my code more readable,


You honestly believe that drek is readable? No comments, spaghetti code,
#define abuse that should be criminal, and non-semantic variable names.

your delusions about being my employer don't interest me in the least.
 

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