c# is a good way to learn c

  • Thread starter Thread starter Montrose...
  • Start date Start date
Alex said:
This is terrible, unmaintainable code.

You've been trolled by the Relf troll. As he's already been informed
of his idiocy, there's really no reason why you should not place him
in your bozo bin. Nothing you say will help him understand, believe
me.
 
Sean Hederman poked his little head through the XP firewall and said:
[Snip]
PS: Personaly I would program in Assembler, because that would prove my
real
skill and I love doing it,

You love programming Assembler? I've done it, I'm glad I did it, and I'm
very, very happy I don't have to do it again (touch wood).

You said "touch wood".

Truthfully, though, a knowledge of assembler is very useful when your
debugging takes you into library or system routines for which you don't have
the source code.

Believe it or not, if you do it right, you can gradually build up a speed in
coding assembler that is surprising.

But I've forgotten much of what I knew about masm.
 
billwg poked his little head through the XP firewall and said:
Heavens, nut, you're totally missing the boat! Too much time spent
defending the OSS initiatives probably.

Get real.
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.

Don't be stupid.
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.

Actually, my first look, if I owned such a company, would be in the
open-source arena.
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.

I thought Java was first created for embedded devices, and then found that
other niche later.
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.

I would suspect you are right.
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.

Nah, I'd just grab an open-source library. Whether I was using C++,
C, Python, Perl, or even Tcl/Tk.
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.

I hope it works better than the plumbing in Visual Studio and MFC.
.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.

That's cool, but sometimes you need to know about the plumbing, too.

It is dependent, to some extent, what your application domain is.

Anyone who thinks one paradigm fits the entire world of software development
has a simple view of this world.
 
Sean Hederman poked his little head through the XP firewall and said:
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.

It also excludes that we are not now proficient in C#. We are proficient in
C++.
Unless there's serious resource constraints/portability requirements, C#
should be able to do that easily.

Cool. We already done it with C++.
 
Alex poked his little head through the XP firewall and said:

I don't have any source myself, but google for "Visual COBOL". Or
"object-oriented COBOL".
 
Linønut said:
Truthfully, though, a knowledge of assembler is very useful when your
debugging takes you into library or system routines for which you don't
have
the source code.

Believe it or not, if you do it right, you can gradually build up a speed
in
coding assembler that is surprising.

Never got particularly quick in it, merely somewhat competant.
But I've forgotten much of what I knew about masm.

I used to use TASM and DJGPP. Ah, the memories...
 
Linønut said:
billwg poked his little head through the XP firewall and said: [Snip]
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.

I hope it works better than the plumbing in Visual Studio and MFC.

Much, much, much better.
That's cool, but sometimes you need to know about the plumbing, too.

I couldn't agree more. However, knowing about the plumbing doesn't mean you
need to *do* plumbing.
It is dependent, to some extent, what your application domain is.

Anyone who thinks one paradigm fits the entire world of software
development
has a simple view of this world.

Again, couldn't agree more.
 
Linønut said:
Alex poked his little head through the XP firewall and said:


I don't have any source myself, but google for "Visual COBOL". Or
"object-oriented COBOL".

I think there's also a version of COBOL for .NET, believe it or not.
 
Believe it or not, if you do it right, you can gradually build up a speed
Never got particularly quick in it, merely somewhat competant.


I used to use TASM and DJGPP. Ah, the memories...
I prefered TASM :-) Over MASM but I knew both.
I was very saddened that C took over and assembler was forgotten and not
included with the C compiler anymore, but then again this is life.
Later I discovered tha assembler still exist but integrated in the C
language. :-)
But I never used it only in my current company I had to resourt on using MMX
assembler to speed up image processing of our X-ray scanner.

But currently I do not really have a need for that, the current processors
are very fast and there is no real speed gain anymore.
Speed is currently gained in other factors like hyper threading nowadays.
 
If you want the best code, if you want code that can stand the test
of time, you need MS C++ 7.1 ( which is, de facto, the latest C from
Microsoft ).
....
If you're not picky, or you just don't have the experience under your
belt, you can go with C#, Java... or even HTML, for that matter.

It sounds to me as though you don't have much experience. :)

The "best" code? The best code can be simply defined as follows: The
code that gets the job done, within the constraints imposed by the
problem domain, does not bring the system to its knees, and can be
understood and maintained by programmers who don't charge an arm and a
leg for their time.

Often all of these things are competing requirements. You can tune the
living crap out of a program, make it run like lightning, but the only
people who will understand what's going on are C gurus with 10 years of
experience. So, you have a technically great product that costs a
fortune to maintain because the people you have to hire to maintain it
cost a fortune.

Or, you can develop a VB app that does the same thing, that an
entry-level programmer could understand, but which gobbles tons of
memory, pins the CPU, and takes ten times longer to execute.

What most businesses want, whether they are selling software or
developing in-house, is something in between. They don't want piggish
software, but then neither do they want to be forced to hire geniuses
at $200K a year.

Sometimes, the requirements for speed and efficiency require that
businesses throw lots of money at their wizard programmers. Certain
domains require this (device drivers, medical equipment, communications
equipment, etc.). Most domains don't.

"Better code," then, depends upon the context in which that code is to
be used and maintained. In my environment, which is in-house
development for a milling company, my reaction to a devilishly tricky,
but lightning-fast business analysis program would be to toss it in the
trash and write a new one that was much slower but also much more
easily maintained. My company wants people here focused on solving new
business problems, not tweaking and tuning what we have until it's a
jewel of efficiency, and then spending big bucks maintaining the
result. Other companies do want that efficiency, even if it costs... it
all depends upon the problem domain.
 
Sean Hederman poked his little head through the XP firewall and said:
I couldn't agree more. However, knowing about the plumbing doesn't mean you
need to *do* plumbing.

True. However, sometimes the plumbing is fun. I spent my Christmas
vacaction working out some rather puzzling problems in my socket & thread
code. Actually got to the point where I was a bit anxious (when I was
supposed to be relaxing!) Then I broke through the wall and got it all
basically working, and that was a great feeling, and I feel good knowing I
might well have a library that is about as fast as it could possibly be, and
it is cross-platform, safe to use, and fairly easy to use (if your app fits
the model the library supports).

Now, if I had to go this level all the time, I would definitely not get my
projects done on time, because I'd probably be in a sanitarium, gibbering.

In fact, my mental infrastructure is at a bit of an ebb right now, which is
probably why I'm hanging around here.

Thanks for the good conversation!
 
In comp.os.linux.advocacy, Alex
<[email protected]>
wrote
Hello Jeff,



This is not good C++. Never was, never will be.
It may or may not be good C.

Highly debatable that it's good C. But this *is* RelfCode(tm)
we're discussing here. ;-)
And, while the higher level Tools found in C# don't apeal to me,
the lower level tools, like macros, are oddly Verboten .
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# ?
#define LOOP while ( 1 )
#define \
LoopTo( StopCond ) \
while ( Ch && ( Ch = ( uchar ) * ++ P \
, Ch2 = ( uchar ) P [ 1 ] \
, Ch ) \
&& ! ( StopCond ) )

Gaak!

What's wrong with templates and inline functions?

Nothing. He just likes macros.

Lots of macros.

A plethora of inlined constructs to insert where his mind pleases.
This is terrible, unmaintainable code.

He doesn't seem to have a problem with it. :-) Job security,
in a way.

I certainly wouldn't want to have to touch it, though, at least,
not on a maintenance basis. It's horrible, but there are
people who like to watch films of traffic accidents, too.
It may be accepted in comp.os.linux.advocacy (I wouldn't know,
I don't frequent that group)

Hah! The only reason one sees total dead silence as a response
is because most of us generally have recognized RelfCode(tm)
for what it is, and have kerplonked him low in the scorefile.

Me, I just find him a challenge. Not entirely sure why.
but try posting it in comp.lang.c++.moderated and see the
reaction it will evoke.

I would hope the moderators have very strong stomachs. (Not
that RelfCode(tm) wouldn't even win the Obfuscated C++ contest --
if there is one. It's not artistic enough. :-) )
I don't know who your employer is but I would like mine
to be so lenient.

At some point one would hope for an employer that can at least
attempt to read C++ code, Java code -- heck, *any* code, or
maybe run a code analyzer to find the more common bugs.
More readable to who?

It's a code word. As far as we can tell, "readable" to Jeff
means "totally incomprehensible but it fits on a small screen
during munging" to everyone else. (I base this on Jeff
working on someone else's code -- he used STL, and Jeff decided
to, erm, "improve" it by moving whitespace around.)
Cute rewriting of C++ syntax is universally considered
as bad practice.

You mean like

#define Begin {
#define End ;}
#define While while(
#define Do ) {
#define Do2 {
#define Done ;}
#define Done2 );
#define Procedure
#define Function

? :-)

Agreed, that's going to leave a bit of a mess.
Don't take my word for it, c.l.c++.m (see above) is
a great resource - you have Stroustrup, Sutter,
Alexandrescu and their peers actively participating
in discussions there and offering ego-less advice.

Do they do STL in there?
Standards, conventions and idioms are good for a reason.
Any C and C++ programmer should recognize for(;;) at a glance.

I'll admit "pure" STL might frown on that, replacing it
with std::generate(), std::transform(), or std::for_each(),
but old habits die hard... :-)
 
Bruce said:
What most businesses want, whether they are selling software or
developing in-house, is something in between. They don't want piggish
software, but then neither do they want to be forced to hire geniuses
at $200K a year.

The folly of it all is that because they think there is some way out of
good solid work that they will spend $2 million or $200 million on
"application servers" that promise to deliver everythign with 'easy to
use' GUI interfaces, only to find that once you leave the seminar and
try to code something up with it, it's a hopeless mismash, slow and
cumbersome...of course, by then the IT Managers who bought it have gone
on to promtions because of their "cost-saving" decisions...

If they had spent the money on salaries to "gurus" -- that is, someone
above the moron level --they would get much greater return. But where
is the IT Leader who can speak up and say "hey, we should hire smart
people; most of them like to work, and will do a better job than all the
snake oil Big Software companies with their Pretty Sales Reps and UML
diagrams, and will create efficient, well writen code, if only we let
them have free sodas" ???
 
There are myriad problems with this.

1. There is only a limited number of gurus to go around.
2. Most gurus don't like writing boring business software.
3. This presumes that the hiring managers can tell which hires are
worth spending money on and which aren't. There is an equal number of
"snake oil salesmen" in the ranks of interviewees as there are selling
big software packages. I have many times worked for companies that
spent big bucks on "gurus" who were, in fact, total idiots who knew how
to sell themselves in an interview.
4. Today's stock-and-trade tools are yesterday's "snake oil." I
remember when relational databases were "snake oil" crap. Now we
wouldn't do without them. Yes, IT managers often fall for hype.
However, just as often "gurus" are stuck in the past. How many really
smart guys have you met who insist on writing everything in C and sneer
at modern tools? How effective do you think they are at writing the
kind of software businesses need?
5. One of those very, very smart gurus can write me up a business
report in C that is a model of beautiful design, all in only a couple
of days. Some jackass fresh out of college can cook up the same thing
in VB in two hours, and it interoperates neatly with all of MS's stuff,
to boot. Yes, the code is crap (I hate VB), yes, it could be much more
efficient (.NET practically guarantees bloat), but I'm going to throw
it away next month and ask for a different one. Who should I hire, do
you think? Different skill sets and languages lend themselves to
different problems. (I wouldn't hire the VB jackass to program a CAT
scanner, for example.)

I used to write real-time, multi-tasking software for telephone
switches. I absolutely do _not_ try to program business apps the same
way. My old job required hyper-efficient code, fine tuning, attention
to memory consumption, and estensive unit testing. My new job requires
short development cycles: get the product on the business user's desk
_fast_ without killing his PC or the network. It's a completely
different way of thinking.

I will give you one thing, though: my new company would do well to
search out someone who _really knows_ Microsoft's development world,
and pay that person a high salary to help the rest of us get up to
speed on architecture and design decisions in the context of MS's long
term plans.

Some guy who writes elegant C code would be utterly useless to us,
apart from his basic thinking skills and attention to detail.

Similarly, the aforementioned MS guru would completely suck writing
code in my old job, where picky attention to tiny details was the order
of the day, and you built every line of code by hand, counting CPU
cycles as you went. As I said: different domains, different skill sets.

The computing world has become so diverse that there is plenty of room
for the guys building little jewels of programs in C, and plenty of
room for the guys building business apps using Visual Studio, ADO.NET,
and SQL Server using drag-and-drop. We need them all, but for different
domains and different reasons. Gone are the days when one person could
do it all, where one skill set was enough to get you any "computer job"
anywhere you wanted to work.

Whether you like it or not, you're specialized, so don't go sneering at
some other guy with a different speciality just because he can't match
you in your domain. That kind of dismissive attitude toward other skill
sets is the refuge of the insecure.

Similarly, get used to what I call the 10 / 80 / 10 rule: 10% of the
programmers out there are "gurus" in some area who are leading the way
and understand what's what. 80% of the programmers out there understand
the basics and can get the job done. 10% of the programmers out there
have no idea what they're doing: they just copy and paste and then
tweak it until it works. In every industry you have to deal with all of
these types of people. If you're in the top 10% and you let the other
90% get to you then you _will_ go nuts. Guaranteed.
 
Bruce said:
There are myriad problems with this.

1. There is only a limited number of gurus to go around.

I think there are more than you might imagine; alternatively, there are
a lot of generally bright people who might find 'guruing' attractive if
IT management weren't always in the process of *dumbing* down IT work.
2. Most gurus don't like writing boring business software.

A guru is someone who would find a way to make it exciting. What would
turn the guru off is higher-ups who want to constantly kill ideas to
make it more exciting and innovative. For example, the web services/SOA
model could be applied to *so* much of business processing and it should be!
3. This presumes that the hiring managers can tell which hires are
worth spending money on and which aren't. There is an equal number of
"snake oil salesmen" in the ranks of interviewees as there are selling
big software packages. I have many times worked for companies that
spent big bucks on "gurus" who were, in fact, total idiots who knew how
to sell themselves in an interview.

It's always hard to find the Real Thing; but, I find that a company with
a glossy brochure and slick app server finds it easier to gain entry
than a person who wants to apply some real skills to the problem.
Reason: glossy brochures don't threaten the Estblishment. Smart people
do...
4. Today's stock-and-trade tools are yesterday's "snake oil." I
remember when relational databases were "snake oil" crap. Now we
wouldn't do without them. Yes, IT managers often fall for hype.
However, just as often "gurus" are stuck in the past. How many really
smart guys have you met who insist on writing everything in C and sneer
at modern tools?
Many...

How effective do you think they are at writing the
kind of software businesses need?

They would be excellent if given the chance to do it "their way".
5. One of those very, very smart gurus can write me up a business
report in C that is a model of beautiful design, all in only a couple
of days. Some jackass fresh out of college can cook up the same thing
in VB in two hours, and it interoperates neatly with all of MS's stuff,
to boot. Yes, the code is crap (I hate VB), yes, it could be much more
efficient (.NET practically guarantees bloat), but I'm going to throw
it away next month and ask for a different one. Who should I hire, do
you think? Different skill sets and languages lend themselves to
different problems. (I wouldn't hire the VB jackass to program a CAT
scanner, for example.)

The issue is the 'next time'. The c guy would find a way to abstract
and reuse his methods -- so he would constantly decrease his programming
turnaround time, and increase program speed and efficiency.

The VB would be static -- it will always take 2 hours and it will never
run any faster...

I used to write real-time, multi-tasking software for telephone
switches. I absolutely do _not_ try to program business apps the same
way.

I absolutely would. The realtime/SOA paradigm shift in business has
been a long time coming...business cannot and should not be doing even
the simpliest accounting in terms of years or months...it should be in
seconds....
My old job required hyper-efficient code, fine tuning, attention
to memory consumption, and estensive unit testing. My new job requires
short development cycles: get the product on the business user's desk
_fast_ without killing his PC or the network. It's a completely
different way of thinking.

And it's a great way of thinking...
I will give you one thing, though: my new company would do well to
search out someone who _really knows_ Microsoft's development world,
and pay that person a high salary to help the rest of us get up to
speed on architecture and design decisions in the context of MS's long
term plans.

You could substitute "linux kernel" for M$....

Some guy who writes elegant C code would be utterly useless to us,
apart from his basic thinking skills and attention to detail.

That is where we differ...

The computing world has become so diverse that there is plenty of room
for the guys building little jewels of programs in C, and plenty of
room for the guys building business apps using Visual Studio, ADO.NET,
and SQL Server using drag-and-drop. We need them all, but for different
domains and different reasons. Gone are the days when one person could
do it all, where one skill set was enough to get you any "computer job"
anywhere you wanted to work.

Whether you like it or not, you're specialized, so don't go sneering at
some other guy with a different speciality just because he can't match
you in your domain. That kind of dismissive attitude toward other skill
sets is the refuge of the insecure.

That is the 'ecosystem' argument...and I agree with it...my diatribe is
that the 'intelligence' has been slowly squeezed out of the IT/Web
industry by people who think that writing an application generator or
server is what it's all about. It's not...it's about constant and rapid
change and the ability to modify and perfect at all levels...in any case

Similarly, get used to what I call the 10 / 80 / 10 rule: 10% of the
programmers out there are "gurus" in some area who are leading the way
and understand what's what. 80% of the programmers out there understand
the basics and can get the job done. 10% of the programmers out there
have no idea what they're doing: they just copy and paste and then
tweak it until it works. In every industry you have to deal with all of
these types of people. If you're in the top 10% and you let the other
90% get to you then you _will_ go nuts. Guaranteed.

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

Graphical: SuperGravity (formerly: Gravity from Microplanet).
Console: SLRN (not to be outfeatured by anyone)
 
Hi Alex, Re:
#define mt( x, y ) MoveToEx( DC, x, y, 0 )
#define lt( x, y ) LineTo( DC, x, y )

You told me: << This is not good C++. Never was, never will be.
It may or may not be good C. >>

It makes my code less verbose. You say it's bad... but you can't say why.

Re: The following two macros, which I use a lot, and which C# can't do:
#define LOOP while ( 1 )
#define \
LoopTo( StopCond ) \
while ( Ch && ( Ch =3D ( uchar ) * ++ P \
, Ch2 =3D ( uchar ) P [ 1 ] \
, Ch ) \
&& ! ( StopCond ) )

You told me: << Gaak !
What's wrong with templates and inline functions ? >>

What inline function acts like while() ?

Did you bother to look at the code ? No-o-o you did not.

Re: My LowerCaseNG ( LnP Mixed ) code,

You told me: << This is terrible, unmaintainable code.
It may be accepted in comp.os.linux.advocacy
( I wouldn't know, I don't frequent that group )
but try posting it in comp.lang.c++.moderated
and see the reaction it will evoke. >>

Without even going to c.l.c++.m,
I'm sure that Stroustrup, Sutter, Alexandrescu have nothing to say,
that's why the group is moderated, to coverup that fact.

Although all code requires an investment to learn,
my code is very maintainable, I say.

You added: << I don't know who your employer is
but I would like mine to be so lenient. >>

I have the feeling that your employer is just as off as you are.

Re: My comment that Loop() is more readable than for(;;),
#define Loop( N ) int J = - 1, LLL = N ; while ( ++ J < LLL )

You told me: << More readable to who ?
Cute rewriting of C++ syntax is universally considered as bad practice. >>

Loop() is more readable to anyone than for(;;)
at least to anyone who invests the few minutes it takes to learn it.

Loop() does not change C's syntax.
 
"Better code," then, depends upon the context in which that code is to
be used and maintained. In my environment, which is in-house
development for a milling company, my reaction to a devilishly tricky,
but lightning-fast business analysis program would be to toss it in the
trash and write a new one that was much slower but also much more
easily maintained. My company wants people here focused on solving new
business problems, not tweaking and tuning what we have until it's a
jewel of efficiency, and then spending big bucks maintaining the
result. Other companies do want that efficiency, even if it costs... it
all depends upon the problem domain.
So you can optimize for speed, and you can optimize for functionality and
you can optimize for fast changes and optimize for readibility and optimize
for group usage. :-)

Optimize for speed is nice for OS kernal and image processing tools.
Optimizing for functionality is for example adding plug-ins to extend the
program.
Optimize for fast changes could be a tax payment software that must change
every year according to the new rules.
Optimize for readability for other people for example if the program is
created by a contractor, and next time he is unavailable, someone else must
be able to extend the program.
Optimize for group usage, is to make other people use your library to
develop their programs.

Most of the times it is imposible to have all of those in one program.
 
Back
Top