I am sorry if this is an inappropriate place to put this post, if so
please delete it.
I am wondering about a few things. Do you guys recommend learning C as
a second language, as someone who already knows java very well. And
what is the best way to learn C, books, tutorials, or what?
Thanks, any response would be great.
Mar 10 '06
26 3000
On 2006-03-11, Keith Thompson <ks***@mib.or g> wrote: If I might summarize:
Richard G. Riley really likes debuggers. Not everyone else likes them as much as Richard does.
I believe that covers all the relevant points.
Next?
Very droll.
But not at all what the crux of this is about : what its about is a
one way of working which can dramatically speed up ones familiarity
with a system. I find it terrifying that there seems to be a fair
number of programmers here who think a debugger is "only for finding bugs"
: it is a limited and naive view.
Inserting printfs, asserts and so forth is time consuming, messes up
the code, limits one to what the programmer wanted you to see at
"write time", and is a colossal source of heisenbugs. Unless you're
perfect that is : which some here have indeed claimed to be.
And for using such a tool to be called "bizarre" is bizarre in
itself. Yes, yes, I know what Kernighan said : good on him.
The entire thread started with discussing how a new programmer could
familiarise himself with bulding & architecting apps : I'm afraid that
"look at the source code" simply isnt a credible answer. One learns by
doing and examining a running system compiled with debug is one of the
most productive tools in the trainers arsenal.
Next?
On 11 Mar 2006 23:19:50 GMT, in comp.lang.c , "Richard G. Riley"
<rg****@gmail.c om> wrote: with a system. I find it terrifying that there seems to be a fair number of programmers here who think a debugger is "only for finding bugs" : it is a limited and naive view.
is this thread still going, or has my newsprovider regurgitated it?
Either way, i find it terrifying that someone thinks a debugger is for
programme analysis and testing. Yike.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Keith Thompson wrote:
.... snip ... If I might summarize:
Richard G. Riley really likes debuggers. Not everyone else likes them as much as Richard does.
I believe that covers all the relevant points.
Which buggers?
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>
Richard G. Riley wrote: On 2006-03-11, Keith Thompson <ks***@mib.or g> wrote:
If I might summarize:
Richard G. Riley really likes debuggers. Not everyone else likes them as much as Richard does.
I believe that covers all the relevant points.
Next?
Very droll.
But not at all what the crux of this is about : what its about is a one way of working which can dramatically speed up ones familiarity with a system. I find it terrifying that there seems to be a fair number of programmers here who think a debugger is "only for finding bugs" : it is a limited and naive view.
There is the middle ground, read the code first and step tough bits you
can't sus out in the debugger. A decent source browser (one that gives
you callers and callees) is a better tool for the job, it gives you an
overview of the code, rather than the details of one part of it.
Using a debugger as the main tool for familiarising one's self with a
large body of code is a bit like using a microscope to read a book.
--
Ian Collins.
Richard G. Riley wrote: On 2006-03-11, Nick Keighley <ni************ ******@hotmail. com> wrote: Richard G. Riley wrote: "Nick"poste d the following on 2006-03-11: > Richard G. Riley wrote: >> "Chris"post ed the following on 2006-03-10: >> > Richard G. Riley wrote: >> >> "Nick"poste d the following on 2006-03-10:
[ a long debate partly about using a debugger to analyse existing,
working
applications. Richard G. Riley thinks it's a good idea. I (Nick
Keighley) don't]
ok. This is *way* off topic. It has gone on too long. And the post has
grown
to gigantic proportions. I'm *really* going to stop now (I think I said
that
before...).
We are both probably frustratrated that the other doesn't seem to
understand our perefectly reasonable point of view. And everyone else
on
clc is probably even more frustrated that we both keep banging on.
What I do find odd is that we have drawn opposite conclusions for the
same
reason. Neither of us likes doing things manually that can be automated
(sign of a good programmer). So Richard objects to using printf() (or
custom
logger) because it is manual, error prone and may disturb the program,
and prefers using a debugger to achieve the same end. I object to the
use
of a debugger ***for exactly the same reasons*** !
<snip>
I find [a debugger] a good teaching tool to get people up to speed with an app and its internal data structures : modify on the fly, symbol tables etc. Cant do that with a print out or printfs.
I have *never* had any desire to do these things. Find the bug. Fix the bug. Why would you want to modify things on-the-fly?!
Modify data to test or force a state. Its a basic of debugger use : you can force your hand to avoid having to wait for a certain random data suite to trigger the bug.
e.g someone says I'm getting a divide by zero somewhere near func().
go to func in debugger, force a zero into the divisor and see why the checks arent stopping it. Simple example.
no. Put an assert() in. A modified variable is just for today. An
approriate
assert() lasts forever. Next year when someone casts doubt on the same
function, you simply look at the func() source code and say "nope,
can't
be a divide by zero because there's an assert() to check for that". Fix
it
once, never touch it again.
<snip> >> I fail to see how analysing existing, successful apps can be anything >> other than beneficial. It doesnt take away the donkey work of learning >> the lanugage basics, but it can make text book "science" much more >> accessible and "real". I cant imagine becoming a programmer without >> such practice, guidance and "practical training". Its the same in all >> walks of life. > > I think I'll give up here. My point wasn't that important. Just trying > to make the point that different people do thinks in different ways. Linux > is not the only platform. Not everyone uses debuggers the way you do
Nobody said it was : you came flying in with that.
riight
You did. Look at the thread. The OP mentioned Linux : I said it was a good idea for what he wanted to do : you came in with "hold on hold on lets not start an OS war here".
a debugger war is much more fun...
<snip> > Maybe I'll even get my debugger out and step through a program > sometime to see if it brings me any insights. Maybe you should try > a "debugger free day" and try and see what you have to do to manage > without. Try reasoning about the program. Consider invariants and > post/pre conditions. Try adding asserts etc.
If you recall I did mention that a home brew logging system is prefential to printf :
where did the words "homebrew logging system" appear in the paragraph above? I did write a fairly blunt paragraph here. And then thought better of it. Do you know what an invarient is? Design by contract?
I used those words. Its when you wrap whatever underlying logging system is convenient to you in a fairly generic calling interface : so you could log to files, text consoles, window systems whatever without changing the calling code.
I note you didn't say if you knew what "Design by Contract" meant.
<snip> A debugger isnt the only tool : and I never said it was. What it can do is allow you to see the flow of an application while watching live data, allow you to modify that data
never felt the need. Not since compilers got fast enough to run during the day.
I really dont understand this. What has that got to do with a debugger?
I've modified variables using the debugger (the "debugger" actually had
toggle switches...) when the run time of the compiler was significant.
If it
took hours to recompile your code then machine code patches and
register
hacking was acceptable. It is no longer necessary (well, sometimes).
<snip> and to examine and ensure data typing is consistant from skillful use of register/pointer/memory examinations : it is why they exist.
you examine registers? On a deeply embedded system, ok. But a server? I also mentioned memory and pointers. And yes I do. Very useful in debugging big C systems.
wow. Culture Shockville. To my shame I couldn't even tell you what
registers
my platform has without STFWing. Ok that's a project for today.
<snip> The whole crux here is you doubting that stepping an existing app can help a user understand it : after many, many and varied projects on various platforms in various languages I find it incredulous how you could doubt this would be beneficial. In order to even put in these printfs() you need some understanding of whats going :
<snip>
I'd say the same went (in spades) for stepping. You've got to know where to step. There's source code, case tools, source browsers, source code. I've even resorted to grep to find callers of functions.
grep is ok : if I dont have a decent IDE I use something like emacs tags. I have used grep in about 15 years :)
ok it's a tool of desparation. You * never* use grep?!
<snip>
--
Nick Keighley
Testing can show the presense of bugs, but not their absence.
-- Dijkstra
On 2006-03-12, Ian Collins <ia******@hotma il.com> wrote: Richard G. Riley wrote: On 2006-03-11, Keith Thompson <ks***@mib.or g> wrote:
If I might summarize:
Richard G. Riley really likes debuggers. Not everyone else likes them as much as Richard does.
I believe that covers all the relevant points.
Next?
Very droll.
But not at all what the crux of this is about : what its about is a one way of working which can dramatically speed up ones familiarity with a system. I find it terrifying that there seems to be a fair number of programmers here who think a debugger is "only for finding bugs" : it is a limited and naive view. There is the middle ground, read the code first and step tough bits you can't sus out in the debugger. A decent source browser (one that
gives
100% of course. *Nothing* is as good as a good clear printout for an
overview and a familiarity. Hell, I print out man pages still.
you callers and callees) is a better tool for the job, it gives you an overview of the code, rather than the details of one part of it.
Using a debugger as the main tool for familiarising one's self with a large body of code is a bit like using a microscope to read a book.
I'm afraid that due to some of the replies I might have become a bit
exasperated and come across as a bit of a fanatic :(
But to close and to summarise some points which a lot of posters dont
seem to be aware of - or at least it appears that way from their
"debuggers are only occasional useful" replies -
1) A debugger can give you that high level overview too
2) It has cross reference facilities for definition finding
3) Ability to give symbolic representation to data
4) Ability to tweak at runtime to force unlikely conditions
5) Abilitiy to see entire dataset : not that determined useful by the
original programmer
6) Watchpoints & HW breakpoints to isolate required conditions.
7) Shows types : reveals bad casts & conversions very quickly in the
datawindow.
There are more. A good print out is good if for nothing else than
sitting on the jacks having a read :) Or annotation. The combo of a
good debugger with the experience of how to use it and possibly a
profiler is nirvana for a C programmer working on a large project.
I've seen old systems where the code is simply unreadable :
multistatements per line, single letter variable names, cast city :
code like this can be a nightmare to read from a printout - it is
useful to watch the program run. Yes, printfs* can be useful if
you have the knowledge and the facility to insert them.
(*) Or home brew multi-platform/interface compatible logging system
like Linux's klogd.
One last point about your microscope comment : this is only true if
you *step* every line. You dont. You place strategic break points at
the page or chapter you are interested in : after all, a C program is
hardly a novel - thought it is a schematic :)
And to anyone that got this far that isnt totally bored by the whole
thing : consider this. You see a function in a source browser :
are you not interested in HOW it was called? Why it was called? You can
guess from 30000 pages of printout or from a call hierachy in a source
analysys tool or IDE : but its 2 seconds work to set a break point
there and examine a few call stacks.
Yes, I'm an advocate. And astonished by the claims of some who say
they havent used a debugger more than twice in over 20 years of C programming.
On 2006-03-12, Nick Keighley <ni************ ******@hotmail. com> wrote: no. Put an assert() in. A modified variable is just for today. An approriate assert() lasts forever. Next year when someone casts doubt on the same function, you simply look at the func() source code and say "nope, can't be a divide by zero because there's an assert() to check for that". Fix it once, never touch it again.
Thats not the example I gave. I gave the example to force the divide
by zero error : with no added code which changes the footprint between
runtime and debug models. To expand a bit, I might want to check a
deeply embedded function can handle an integer limit or a null
pointer. One very important issue
here is that I dont do this all the time - only when its deep in a
system where a quick glance cant quarentee the absence of such
"limits". I might want to call "convertBitmap( )" with option 3 for GIF
since the test data framework didnt incude that option. Or 6 which is
not yet implemented.
Bottom line is that also, some systems dont want to exit : they want
to handle the assert condition more generously. assert is one up from
printf mind you. At least you can compile it out without running
around changing all your source. Not that I agree with code footprint
which is different between "real" and "developmen t".
Also, how many times have we found
assert(a++);
as opposed to "assert(a); a++" in some remote rarely called routine?
Bad? Yes. But shit happens.
If what you want is required then yes, an assert is useful. a debugger war is much more fun...
It can be.. (ps this is far from OT : it is about using C language mechanisms
for debugging aid which overrule the need for a HW/SW debugger). If it
was in the std group then yes.
<snip>
>> > Maybe I'll even get my debugger out and step through a program >> > sometime to see if it brings me any insights. Maybe you should try >> > a "debugger free day" and try and see what you have to do to manage >> > without. Try reasoning about the program. Consider invariants and >> > post/pre conditions. Try adding asserts etc. >> >> If you recall I did mention that a home brew logging system is >> prefential to printf : > > where did the words "homebrew logging system" appear in the paragraph > above? I did write a fairly blunt paragraph here. And then thought > better of it. Do you know what an invarient is? Design by contract? I used those words. Its when you wrap whatever underlying logging system is convenient to you in a fairly generic calling interface : so you could log to files, text consoles, window systems whatever without changing the calling code.
I note you didn't say if you knew what "Design by Contract" meant.
It has nothing to do with what I am advocating here. And so I wont get
dragged into a terminology war. I'm not talking about designing
anything here. And if I wanted to bluff, google is a mere keypress away
:-;
Remember that the crux of this is that I'm saying it can be
advantageous for someone wanting to familiarise themself with a system
to see it runing under a good debugger. You claimed this as "bizarre".
<snip>
>> A debugger isnt the only tool : and I never said it was. What it >> can do is allow you to see the flow of an application while watching >> live data, allow you to modify that data > > never felt the need. Not since compilers got fast enough to run during > the day. I really dont understand this. What has that got to do with a debugger?
I've modified variables using the debugger (the "debugger" actually had
toggle switches...) when the run time of the compiler was significant. If it took hours to recompile your code then machine code patches and register hacking was acceptable. It is no longer necessary (well, sometimes).
You must work on very small systems. I would never counter someone
modifying code here there and everywhere to *find* a bug when you can
get the same effect in less time without modifying the code.
What are toggle switches? What is a machine code patch in this
context? I would rarely advocate register hacking : the whole point of
a debugger is that it gives symbolic access to your system variables
and messing with registers is not required.
<snip>
>> and to examine and ensure >> data typing is consistant from skillful use of register/pointer/memory >> examinations : it is why they exist. > > you examine registers? On a deeply embedded system, ok. But a >> server? I also mentioned memory and pointers. And yes I do. Very useful in debugging big C systems.
wow. Culture Shockville. To my shame I couldn't even tell you what registers my platform has without STFWing. Ok that's a project for today.
<snip>
>> The whole crux here is you doubting >> that stepping an existing app can help a user understand it : after >> many, many and varied projects on various platforms in various >> languages I find it incredulous how you could doubt this would be >> beneficial. In order to even put in these printfs() you need some >> understanding of whats going : <snip> > I'd say the same went (in spades) for stepping. You've got to know > where > to step. There's source code, case tools, source browsers, source code. > I've even resorted to grep to find callers of functions.
grep is ok : if I dont have a decent IDE I use something like emacs tags. I have used grep in about 15 years :)
ok it's a tool of desparation. You * never* use grep?!
I used it today to find where a certain daemon was in a boot hierarchy
: nice.
OK, lets call it a day.
<snip>
-- Nick Keighley
Testing can show the presense of bugs, but not their absence. -- Dijkstra This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ron Stephens |
last post by:
The newly rechristened Python Learning Foundation is a web site
dedicated to the assistance of people learning the Python programming
language. Features include:
1. Daily lists of new and recent Python-related web articles,
Sourceforge projects, and Vaults of Parnassus listings. These are
generated using Hans Nowak's Python web spider, mygale.py, and are
automatically updated each day. (You can visit Han's interesting blog
at <a href =...
|
by: Jhon smith |
last post by:
Hi,all,I was just wondering if I am likly to have any problems trying to
learn C from older books,I have some from the late 80`s,mid/late 90`s.
I am using Dev-C++ on the pc windows platform,But I have noticed small
differnces in the books such as,int main(),main(void),fprintf,and
others,just wondering if these older books are still worth trying to learn
from as Im on a very tight budget and can`t really afford any thing else,or
are they...
|
by: Christian Blackburn |
last post by:
Hi Gang,
I saw this for sale online: Microsoft Visual Basic.NET Deluxe Learning
Edition Version 2003. I'm wondering is the CD that's bundled with the
learning edition just a digitized version of the book or is it an
interactive tutorial?
Thanks,
Christian Blackburn
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej and
I was wondering if anyone here would be able to give me some tips for
young players such as myself, for learning the language.
Is this the best Newsgroup for support with JAVA?
|
by: Max |
last post by:
On monday I start a semester course in Python (the alternative was
Java). I was looking through the course outline and noticed the following:
1) UserDict is used. This is deprecated, right?
2) There is no mention of list comprehensions, but map and filter are
taught early and then revisited later. I don't think this is good: list
comprehensions are, IMO, one of Python's great features, Psyco prefers
them, they're more pythonic, and map...
| |
by: utab |
last post by:
Dear,
I have experince in C( numerical projects, like engineering problems,
scientific applications) I have the basic notion of C++ also, I have
read Accelerated C++ until Chapter 7, however it seems that it
discusses the std and the other part of the language with your own
abstractions. Is that better to read a book first on the basic concepts
of C++ language (but not the C part) that gives the basics as if the
reader is a beginner...
|
by: bokiteam |
last post by:
Hi All,
Here is my idea to save learning time - Personal learning book.
What we really need is somebody really familiar our learning
experience, and then takes the example to teach us.
Save the learning time.
For example, a person David who understands JAVA, VB, C programming, he
doesn't want to pay too much time to study a C# programming book. If
|
by: arnuld |
last post by:
hai all,
i am standing on a "crossroad to C++". I am here in front of you as i
have a problem. i will be brief. Please do not think: "arnuld is sick",
i am really struggling & doing hard-work to become a Modern C++
Programmer & i am feeling as if i am standing on a crossroad. i am
asking because every time i made a decision on my own, in my past, i
always ran into huge wastage of time, money & effort. that is why i am
posting it here:
|
by: LK~ICT |
last post by:
Sri Lanka rural e-learning project seeks corporate support
Dec 04, 2007 (LBO) - A Sri Lankan e-learning initiative for rural
students is seeking corporate sector support to expand and cover 400
computer centers around the island, its designers said.
The Shilpa Sayura project initiated by eFusion, a local software
company, is a learning tool for rural students who do not have the
necessary number of teachers and lack resources to...
|
by: John Salerno |
last post by:
Just something that crosses my mind every time I delve into "Learning
Python" each night. Does anyone see any value in learning Python when you
don't need to for school, work, or any other reason? I mean, sure, there's
value in learning anything at any time, but for something like a programming
language, I can't help but feel that I will be mostly unable to use what I
learn simply because I have no reason to use it.
The *process* of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |