Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: introspecti...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 65 of 103 Topic 2681 of 3037
Post > Topic >>

Re: introspection in SML

by Rainer Joswig <joswig@[EMAIL PROTECTED] > Dec 11, 2007 at 07:57 PM

In article <fjmhhd$29k$1@[EMAIL PROTECTED]
>,
 Vesa Karvonen <vesa.karvonen@[EMAIL PROTECTED]
> wrote:

> Paul Rubin <http://phr.cx@[EMAIL
PROTECTED]
> wrote:
> [...]
> > That snipped an im****tant part of Michele's reason for liking
debuggers:
> 
> >     When I was mostly working with code written by myself, using
> >     incremental development I did not feel the need for a debugger;
> >     however once I started using large frameworks I found out the
> >     debugger to be invaluable as an exploratory tool, to see exactly
> >     what was happening under the carpet in framework code.
> 
> Note that I'm not arguing that debuggers wouldn't be useful.  My point
> is that it is typically more productive (in the long run) to avoid
> using debuggers and instead invest on types, tests, assertions,
> logging, etc...  These are things that can (and usually do) make it
> easier to work with the program over time.

When I see an 'error', you want to see it directly in the program.
All the other stuff is some kind of pre- or post-mortem
analysis.

> 
> > I find them completely indispensable for that purpose as well.  It's
> > extremely common to have to dive into a large unfamiliar program in
> > order to add a feature (not necessarily fix a bug).
> 
> Yes, I know from experience (of both adding features and fixing bugs).
> 
> > In order to add the feature you have to find the part of the code that
> > has to do with youe functionality
> 
> In my experience, typically the fastest way to find a good place to
start
> looking at the code is to use grep --- not a debugger.

Most Lisp environments record source locations. No need for grep.

>  For example, if
> the program has a GUI, you just grep for labels you can see in the
> relevant widgets.

If you'd use, say, LispWorks, you directly inspect windows and
their contents. From there you get to source code or
you can invoke functions on the objects from the REPL.

>  If the program outputs a log, you can grep for log
> messages.  If the program produces some other kind of output, you grep
for
> matches from that output.  Usually it takes but a few seconds to find a
> good place to start looking at the code.
> 
> Debuggers become (really) useful only after you know a good place for a
> breakpoint.

If I'm interested, I can force the program anytime
into the debugger.

>  A good place for a breakpoint is (very) near, just before,
> the place you ultimately want to look at.  Before you know such a good
> place for a breakpoint, the debugger is typically mostly useless in a
> large program, because it is typically prohibitively time consuming to
> (single) step through the execution of a large program.

That's why you step selectively.
 
> > and have an understanding of what the program actually does in order
to
> > get there,
> 
> For this a good log can be very useful.  In the absence of a good log,
you
> might be able to get an execution trace automatically with a relatively
> small effort.
> 
> A useful "static" technique for getting a "big picture" of a large
program
> is to print out a dependency graph.
> 
> If you are fixing a bug, then in most cases with SML, you should be
> getting an exception.  With SML/MLton, you can easily get the exception
> history (stack trace) in such a case and that usually gets you very
close
> to the problem.

With a usual Lisp environment you can inspect the stack trace,
fix the error and retry or continue - without stopping the program.
 
> > what's in the data structures, etc.
> 
> Static types make this significantly easier...

significant easier than what?
 
> > It's FAR easier to do that by running the program under a debugger,
> > poking around to see what it's doing, what kinds of args get passed,
> > etc., than to either stare at the code statically
> 
> ...With MLton compiled programs, for example, I can nowadays just place
> the cursor on a variable and see the type of that variable, which
> typically gives a good idea of what kind of data actually gets passed.
> With MLton compiled programs, one can also easily jump through all the
> uses and the definition of any binding, which typically gives you a good
> idea of what the purpose of a particular variable, parameter, or
function
> is, for example.

Yeah, and with an interactive environment you see the real data, too.
 
> > or go through a million compile-and-trace cycles adding and removing
> > print statements.
> 
> But that would be silly.  Instead of adding and removing print
> statements, you should create (or just use --- it probably already
> exists for your language) a simple logging facility (roughly a page of
> code) that lets you add concise logging statements to your code and
> leave them there without harm.  Furthermore, whenever you learn a key
> invariant that might be violated by the program, you should add an
> assertion to the program to check the invariant or change the program
> to enforce the invariant through static types.
> 
> Again, compared to using a debugger, if you do this well, this has the
> benefit that your program becomes easier to maintain over time.

This is orthogonal to using a debugger.
 
> > Maybe test driven development works ok for writing new code when you
> > keep the whole design in your head as you develop.  For the far more
> > common task of maintaining legacy code, debuggers (for me anyway) are
> > almost impossible to live without.
> 
> Does the legacy code you are maintaining come with a useful test
> suite?  Does it make good use of a logging facility?  Is it written in
> a safe statically typed language?  Does the code use assertions to
> enforce invariants that are not enforced by static types?  Can you see
> the exact types of variables in your IDE?  Can you trivially and
> accurately browse through all uses of any binding?  Can you get data
> such as call graphs and stack traces from your program?  Can you get a
> dependency graph from your program?  Is the program mostly written
> avoiding side-effects?  Does the language make it easy to avoid using
> mutable data structures?
> 
> It is easy to use legacy code as an excuse.  It is that badly written
code
> that nobody wants to touch or even to look at.  Justifying the use of
> wasteful programming practices using "legacy code" as an argument is a
> mistake.  If you can't make sense out of code without a debugger, the
> problem is with the code.  Fix the code or find another job if you are
not
> allowed to fix it.
> 
> In my experience, debuggers also don't get you very far when you are
> working with non-trivial algorithms and data structures.  Then you
> really need to understand the algorithms, data structures, their
> invariants and variants, because extrapolating such information from
> particular runs is typically extremely difficult.  In the worse case
> you just keep on "fixing" symptoms, probably even breaking the code
> yourself, because you don't actually understand the program.
> 
> Debuggers aren't magical.  A debugger cannot tell you what the code is
> supposed to do.

Nobody said that. With who are you argueing?

>  At most they can show you what the program does at
> run-time.

Well, that's something which static analysis does not provide.

>  I say "at most", because there are programs that can be
> difficult to run productively under a debugger
> (e.g. concurrent/parallel programs, interactive real-time programs
> (e.g. games)) --- especially unless you already *exactly* know where
> to put the breakpoint (if you don't put the breakpoint at the right
> place, you'll only make it next to impossible to run the program).
> 
> -Vesa Karvonen

You might want sometime to catch up with the Smalltalk 80 environment.

-- 
http://lispm.dyndns.org/
 




 103 Posts in Topic:
introspection in SML
"michele.simionato@[  2007-12-01 22:57:46 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-02 12:29:39 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-12 04:29:43 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 12:09:12 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-12 19:54:28 
Re: introspection in SML
George Neuner <gneuner  2007-12-13 01:15:15 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-13 03:48:06 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-13 12:30:35 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 12:09:24 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-13 19:17:57 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 20:25:28 
.net
Joachim Durchholz <jo@  2007-12-14 10:54:42 
Re: .net
Jon Harrop <usenet@[EM  2007-12-14 10:45:26 
Re: .net
Joachim Durchholz <jo@  2007-12-14 21:30:03 
Re: .net
Jon Harrop <usenet@[EM  2007-12-14 21:55:11 
Re: .net
Paul Rubin <http://phr  2007-12-14 14:45:47 
Re: introspection in SML
George Neuner <gneuner  2007-12-13 14:23:15 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-13 11:56:14 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-14 03:43:12 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-14 09:48:46 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-15 03:22:38 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-14 19:30:15 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 00:15:30 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-16 03:19:46 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 04:32:16 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-16 16:58:45 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-16 21:26:46 
Re: introspection in SML
"michele.simionato@[  2007-12-02 05:53:58 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-02 19:21:18 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 09:13:44 
Re: introspection in SML
stephen@[EMAIL PROTECTED]  2007-12-17 00:34:20 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-17 13:42:35 
Re: introspection in SML
"michele.simionato@[  2007-12-02 22:33:29 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 08:47:26 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 13:27:12 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 15:42:47 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-04 16:06:56 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 18:35:13 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 20:37:24 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 20:26:57 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 21:46:16 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 21:49:25 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 22:59:39 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 23:24:15 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-05 00:48:18 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 15:18:29 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-05 18:26:05 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 17:43:26 
Re: introspection in SML
George Neuner <gneuner  2007-12-06 01:55:46 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 14:49:44 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-05 07:01:35 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 18:23:23 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-04 20:50:35 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 08:44:08 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 10:04:33 
Re: introspection in SML
"michele.simionato@[  2007-12-04 02:35:04 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-04 10:50:40 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-04 15:00:59 
Re: introspection in SML
"michele.simionato@[  2007-12-04 22:10:33 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-04 22:55:22 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 07:58:10 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-05 00:25:34 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 17:31:25 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-11 18:21:58 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 19:57:41 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 20:26:45 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 21:41:51 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-11 22:14:00 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-11 23:43:34 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-14 14:32:06 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-11 20:19:53 
Re: introspection in SML
Joachim Durchholz <jo@  2007-12-12 13:40:03 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-05 22:38:17 
Re: introspection in SML
"michele.simionato@[  2007-12-05 08:22:07 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-11 16:38:54 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-12 01:55:14 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-11 17:22:20 
Re: introspection in SML
Rainer Joswig <joswig@  2007-12-12 02:32:44 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 08:04:13 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-11 23:37:53 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 09:23:57 
Re: introspection in SML
"michele.simionato@[  2007-12-11 22:53:33 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-12 08:34:11 
Re: introspection in SML
Vesa Karvonen <vesa.ka  2007-12-12 08:59:00 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 00:01:43 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 00:12:41 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 09:24:36 
Re: introspection in SML
"michele.simionato@[  2007-12-12 00:50:11 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 01:05:12 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 13:23:56 
Re: introspection in SML
"michele.simionato@[  2007-12-12 01:16:11 
Re: introspection in SML
"michele.simionato@[  2007-12-12 04:39:28 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 13:10:31 
Re: introspection in SML
"michele.simionato@[  2007-12-12 05:48:51 
Re: introspection in SML
Jon Harrop <usenet@[EM  2007-12-12 15:49:28 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 07:50:27 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 17:26:12 
Re: introspection in SML
Paul Rubin <http://phr  2007-12-12 11:47:44 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 22:59:03 
Re: introspection in SML
rossberg@[EMAIL PROTECTED  2007-12-12 09:13:50 
Re: introspection in SML
Pascal Costanza <pc@[E  2007-12-12 20:27:50 
Re: introspection in SML
Florian Weimer <fw@[EM  2007-12-15 13:50:58 
Re: introspection in SML
Philippa Cowderoy <fli  2007-12-16 22:06:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 13:57:11 CDT 2008.