all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: zimoun <zimon.toutoune@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Guile debugger workgroup?
Date: Sun, 27 Nov 2022 13:04:22 +0100	[thread overview]
Message-ID: <86o7ss1u49.fsf@gmail.com> (raw)
In-Reply-To: <87fse69czr.fsf@gnu.org>

Hi Ludo,

On Sat, 26 Nov 2022 at 12:22, Ludovic Courtès <ludo@gnu.org> wrote:

> Well, Guile has a debugger that lets you do that (modulo inlining etc.,
> as with any other compiler), and Geiser is not Visual Studio™ but it
> does a good job.

And you wrote elsewhere in the thread:

        It may be more of a limitation of Geiser than of Guile.  I find
        it more useful in “typical” imperative ELisp code than in
        functional Scheme code, but it’d be nice to have either way!

        <https://yhetil.org/guix/87pmd993i4.fsf@gnu.org>

Maybe I am wrong or miss some Guile features.  From my experience, the
issue is not the way that the information is presented or how we
interact with it (Geiser or else) but, instead, the issue is the
availability of such information.  And that is one limitation of Guile,
IMHO.

> Also, I think I mentioned before that I almost never use breakpoints on
> Guile code—not because of some deficiency of the debugger, not (just)
> because I’m silly or inexperienced, but because it’s rarely the right
> tool for the job.

That’s interesting. :-) Well, so you are using the good ol’ way putting
’pk’ here or there, right?  One thing when debugging is to inspect the
current state of the program; what are the values of this or that, then
after running this other, etc.  And, ’pk’ is the poor man
breakpoint. :-)


> I believe this is largely due to (1) writing functional code, and (2)
> doing live programming at the REPL.  Why would you use breakpoints when
> you can just call the relevant procedures on some input to see how they
> behave?

Well, I do not think you are not using breakpoint with Guile because the
code is functional style.  My guess is more that you have built your way
around the limitations of the Guile debugger.

For what this example is worth, I know people with 30+ years of
experience programming highly optimized C code and they never used GDB
or Valgrind or strace or else for debugging.  Doing all debugging with
plain ’printf’.  Well, because when they started, GDB and friends were
less efficient, other folk around were not used to these tools, etc.
And so they took habits without.


> So I think you won’t convince people to pick Guile for their project by
> selling it as a C/C++/Python drop-in replacement.  Guile is about
> functional programming and live coding so the set of tools differs.

Racket is an example of functional programming and live coding.  Haskell
is another; it is functional programming and if I might, I would
recommend to give a look at the interactive GHCi debugger [1].

Back to the initial example [2].  Racket is able to set breakpoints at
various places, as shown in the short demo [3].  Well, I am not able to
do that with Guile.

--8<---------------cut here---------------start------------->8---
$ cat -n my-target.scm
     1	;#lang racket
     2	
     3	(define (mutate-once x)
     4	  (let ((once "once")
     5	        (dash "-"))
     6	    (string-append x dash once)))
     7	
     8	(define (mutate-twice x)
     9	  (let* ((dash "-")
    10	         (twice "twice")
    11	         (stuff (string-append twice dash)))
    12	  (string-append "twice-" x)))
    13	
    14	(define (do-something-with x)
    15	  (string-length x))
    16	
    17	(define (example x)
    18	  (let* ((my-target "something")
    19	         (my-target (mutate-once my-target))
    20	         (my-target (mutate-twice my-target)))
    21	    (do-something-with my-target)))
--8<---------------cut here---------------end--------------->8---

then,

--8<---------------cut here---------------start------------->8---
$ guix repl
GNU Guile 3.0.8
Copyright (C) 1995-2021 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guix-user)> (load "my-target.scm")
scheme@(guix-user)> ,break-at-source "my-target.scm" 17
While executing meta-command:
No procedures found at ~a:~a. "my-target.scm" 17
scheme@(guix-user)> ,break-at-source "/home/simon/tmp/my-target.scm" 17
While executing meta-command:
No procedures found at ~a:~a. "/home/simon/tmp/my-target.scm" 17
scheme@(guix-user)> (example #t)
$1 = 20
scheme@(guix-user)> ,break example
Trap 2: Breakpoint at #<procedure example (a)>.
scheme@(guix-user)> (example #t)
$2 = 20
scheme@(guix-user)>
--8<---------------cut here---------------end--------------->8---

How can I enter in the debugger?  Do I only enter on error?  Well, I end
to put ’pk’ here and there to inspect the code.  Poor experience. :-)

Just to compare with Haskell (functional style, where it is hard nor
impossible to put equivalent of ’pk’ here or there :-)) – the code is
the equivalent as above.

--8<---------------cut here---------------start------------->8---
     1	mutate_once x = x ++ dash ++ once
     2	  where
     3	    once = "once"
     4	    dash = "-"
     5	
     6	mutate_twice x = stuff ++ x
     7	  where
     8	    dash = "-"
     9	    twice = "once"
    10	    stuff = twice ++ dash
    11	
    12	do_something_with x = length x
    13	
    14	example x = do_something_with my_target
    15	  where
    16	    my_target = mutate_twice my_target
    17	      where
    18	        my_target = mutate_once my_target
    19	          where
    20	            my_target = "something"
--8<---------------cut here---------------end--------------->8---

then,

--8<---------------cut here---------------start------------->8---
$ guix shell ghc gcc-toolchain -- ghci
GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
Prelude> :load my-target.hs
[1 of 1] Compiling Main             ( my-target.hs, interpreted )
Ok, one module loaded.
*Main> :break 14
Breakpoint 0 activated at my-target.hs:14:13-39
*Main> example True
Stopped in Main.example, my-target.hs:14:13-39
_result :: Int = _
my_target :: [Char] = _
[my-target.hs:14:13-39] *Main> :list
13  
14  example x = do_something_with my_target
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
15    where
[my-target.hs:14:13-39] *Main> :break 18
Breakpoint 1 activated at my-target.hs:18:21-41
[my-target.hs:14:13-39] *Main> :continue
Stopped in Main.example.my_target.my_target, my-target.hs:18:21-41
_result :: [Char] = _
my_target :: [Char] = _
[my-target.hs:18:21-41] *Main> :list
17        where
18          my_target = mutate_once my_target
                        ^^^^^^^^^^^^^^^^^^^^^
19            where
[my-target.hs:18:21-41] *Main> my_target
"something"
[my-target.hs:18:21-41] *Main>
--8<---------------cut here---------------end--------------->8---


Well, again maybe I miss how to use the Guile debugger.  From my small
experience, I have hard time to debug and inspect Guile code.


1: <https://downloads.haskell.org/~ghc/9.4.3/docs/users_guide/ghci.html#the-ghci-debugger>
2: <https://yhetil.org/guix/87y1s82o23.fsf@gmail.com>
3: Short video demoing (link will be dead after 2022-12-07)
   https://filesender.renater.fr/?s=download&token=92d4312a-91b4-402e-898a-40ce01a5c3ed


Cheers,
simon


  parent reply	other threads:[~2022-11-27 12:44 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27  3:41 [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell' Maxim Cournoyer
2022-10-27  3:50 ` [bug#58812] [PATCH 1/5] Makefile.am: Sort EXTRA_DIST entries Maxim Cournoyer
2022-10-27  3:50   ` [bug#58812] [PATCH 2/5] tests: Add a tests/utils.sh support file Maxim Cournoyer
2022-11-09 21:07     ` [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell' Ludovic Courtès
2022-11-10  3:38       ` Maxim Cournoyer
2022-11-10  4:23       ` [bug#59164] [PATCH v2 1/4] Makefile.am: Sort EXTRA_DIST entries Maxim Cournoyer
2022-11-10  4:23         ` [bug#59161] [PATCH v2 2/4] install: Validate symlink target in evaluate-populate-directive Maxim Cournoyer
2022-11-10  4:23         ` [bug#59162] [PATCH v2 3/4] guix: shell: Add '--symlink' option Maxim Cournoyer
2022-11-10  4:23         ` [bug#59163] [PATCH v2 4/4] shell: Detect --symlink spec problems early Maxim Cournoyer
2022-10-27  3:50   ` [bug#58812] [PATCH 3/5] install: Validate symlink target in evaluate-populate-directive Maxim Cournoyer
2022-11-09 21:06     ` [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell' Ludovic Courtès
2022-11-10  3:37       ` Maxim Cournoyer
2022-11-17 17:37         ` [bug#59164] Coding style: similarly-named variables Ludovic Courtès
2022-11-17 18:44           ` [bug#58812] " zimoun
2022-11-18 17:02             ` Maxim Cournoyer
2022-11-21 15:02               ` zimoun
2022-11-21 15:52                 ` [bug#59164] " zimoun
2022-11-21 20:55                 ` Maxim Cournoyer
2022-11-22 14:35                   ` [bug#59164] " zimoun
2022-11-25 15:23                     ` Guile debugger workgroup? (was: Coding style: similarly-named variables) Maxim Cournoyer
2022-11-26 11:22                       ` Guile debugger workgroup? Ludovic Courtès
2022-11-27  3:16                         ` Maxim Cournoyer
2022-11-28 10:53                           ` Ludovic Courtès
2022-11-28 13:41                             ` Attila Lendvai
2022-11-28 14:50                               ` Maxim Cournoyer
2022-11-29  8:46                               ` Ludovic Courtès
2022-11-30  3:44                                 ` Attila Lendvai
2022-11-27 12:04                         ` zimoun [this message]
2022-11-28  0:27                           ` Maxim Cournoyer
2022-11-28 11:06                           ` Ludovic Courtès
2022-11-28 12:31                             ` zimoun
2022-11-27 20:46                         ` Attila Lendvai
2022-11-28  0:41                           ` David Pirotte
2022-11-28  0:45                             ` David Pirotte
2022-11-28  2:06                           ` Maxim Cournoyer
2022-11-28  7:22                             ` Joshua Branson
2022-11-28 11:09                           ` Ludovic Courtès
2022-11-28 14:12                             ` Attila Lendvai
2022-11-29  8:54                               ` Ludovic Courtès
2022-11-28 12:24                       ` Guile debugger workgroup? (was: Coding style: similarly-named variables) Csepp
2022-11-30  7:09                       ` Guile debugger workgroup? Jannneke Nieuwenhuizen
2022-11-26 14:47                     ` [bug#58812] [bug#59164] Coding style: similarly-named variables Ludovic Courtès
2022-11-17 20:34           ` Maxim Cournoyer
2022-11-20 10:46             ` [bug#58812] " Ludovic Courtès
2022-10-27  3:50   ` [bug#58812] [PATCH 4/5] guix: shell: Add '--symlink' option Maxim Cournoyer
2022-11-09 20:58     ` [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell' Ludovic Courtès
2022-11-10  3:10       ` Maxim Cournoyer
2022-11-10 14:17         ` Ludovic Courtès
2022-11-10 14:49           ` Maxim Cournoyer
2022-11-10 15:16             ` Maxim Cournoyer
2022-11-14  9:18               ` Ludovic Courtès
2022-11-10 16:05           ` [bug#58812] [PATCH v3 1/4] Makefile.am: Sort EXTRA_DIST entries Maxim Cournoyer
2022-11-10 16:05             ` [bug#58812] [PATCH v3 2/4] install: Validate symlink target in evaluate-populate-directive Maxim Cournoyer
2022-11-10 16:05             ` [bug#58812] [PATCH v3 3/4] guix: shell: Add '--symlink' option Maxim Cournoyer
2022-11-10 16:05             ` [bug#58812] [PATCH v3 4/4] shell: Detect --symlink spec problems early Maxim Cournoyer
2022-11-16 19:03       ` [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell' zimoun
2022-11-16 19:34         ` Maxim Cournoyer
2022-10-27  3:51   ` [bug#58812] [PATCH 5/5] shell: Detect --symlink spec problems early Maxim Cournoyer
2022-11-15 21:24 ` bug#58812: [PATCH v3 1/4] " Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86o7ss1u49.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.