racket / htdp

Other
91 stars 69 forks source link

Checked signatures for BSL? #176

Closed jestarray closed 1 year ago

jestarray commented 1 year ago

So it seems that the German version of HTDP, "Dein Programm!" introduces signatures at a beginner level. I notice these signatures are available in ASL as noted here: https://docs.racket-lang.org/htdp-langs/advanced.html#%28form._%28%28lib._lang%2Fhtdp-advanced..rkt%29._~3a%29%29

but I was wondering if I could use them earlier in BSL, just like the german version, without needing to jump language levels. Maybe an option to turn it on or require it?

image

mfelleisen commented 1 year ago

I have contemplated this issue time and again. The first four levels of the teaching languages are tied to HtDP/2e. Without adding material on checked signatures to HtDP/2e readers (students and instructors) would get confusing error messages, because adding signatures as syntax turns small syntactic mistakes into seemingly well-formed programs .. that trigger unexplained run-time errors. -- ASL is a language that we disconnected from HtDP/2e, which is why the checked signatures are available.

In principle, one might be able to add an option to the DrRacket menu-based languages. But, we're in the process of replacing those with#lang htdp/bsl etc.

Now to the pedagogy of checked signatures. According to Northeastern's Co-op department (in the College of Computer Science) industry beginners tend to get started on untyped languages. This holds for 60-70& of the positions they observe. So a separate motivation for not including signatures is that students should understand that it takes a mental discipline to work in such seemingly "simple" languages (think Python or JavaScript).

I have wanted checked signatures to motivate types for a second-tier HtDP (second course, not using Java), for which I have tons of ideas. But HtDP/2e is so over-loaded that I haven't found the right path yet.

jestarray commented 1 year ago

In principle, one might be able to add an option to the DrRacket menu-based languages. But, we're in the process of replacing those with#lang htdp/bsl etc.

On the topic of this, what is lacking in the #lang htdp/*sl? Or is it pretty usable today? I recall the stepper does not work well with it last time I heard.

jbclements commented 1 year ago

Actually, @mikesperber did a ton of work on it last year, and the stepper now works pretty well for the #lang htdp/*sl languages. I think one remaining problematic area is the printout of test case failures, which IIRC currently goes to the console, rather than getting captured and displayed correctly.

mfelleisen commented 1 year ago

As @jbclements writes, the languages are very usable. I recommend you start using them.

Even a couple of years ago when I taught our "CS!" I used the #lang languages (as instructor) and it worked well most of the time. But @mikesperber s improvements have made a ton of difference and I haven't used the menu-based languages in 2 years or so.

jestarray commented 1 year ago

@mfelleisen not sure if this is a bug but #lang htdp/asl does not have the debug button on the top right, while the menu based one does have a debug button on the top right! (I'm on Racket v8.5)

Trying it now also and for UX wise my only complaint is:

Check failures:
        Actual value 2 differs from 4, the expected value.
at line 6, column 0(this should be colored blue)

clickable links should be colored in blue text but everything else seems pretty good :+1: , so I'll move to it, thanks!

mfelleisen commented 1 year ago

Indeed, this is a bug. @mikesperber

jestarray commented 1 year ago
; assignment01.rkt using #lang line

#lang htdp/bsl
(define ASSIGNMENT# #i0.1)
; (check-expect (myadd1 4) 5)

(define (myadd1 n)
  (+ 1 n))

@jbclements Do you know how I would tie in the #lang htdp/bsl with racket/handin server? I currently have a checker.rkt:

  (check: :language  '(module lang/htdp-beginner)
          :create-text? #t
          ...)

and I get:

submit error: Error in your code --
make-evaluator: disallowed reader module path: (submod htdp/bsl reader)

If its :language (module htdp/bsl) I get:

submit error: Error in your code --
make-module-evaluator: module code used `lang/htdp-beginner' for a language, expecting `htdp/bsl'

Relevant docs: https://docs.racket-lang.org/handin-server/Checker.html#%28form._%28%28lib._handin-server%2Fchecker..rkt%29._check~3a%29%29

jestarray commented 1 year ago

sidenote, I just found out you can use checked signatures by (require lang/htdp-advanced) ! Sadly there isn't an Image type built in and I'm not sure if I want to introduce the any type %s so quick.

; in menu selected BSL context
(require lang/htdp-advanced)

(: double (Number -> String))
(check-expect (double 4) 8)
(define (double n)
  (* n 2))
mikesperber commented 1 year ago

Actually, @mikesperber did a ton of work on it last year, and the stepper now works pretty well for the #lang htdp/*sl languages. I think one remaining problematic area is the printout of test case failures, which IIRC currently goes to the console, rather than getting captured and displayed correctly.

Test-case failures get displayed correctly.

The top remaining issue on my list is that coverage annotations are not provided by default. (You can turn them on explicitly though.)

On my plate is also some way to provide the configurability we used to have with the teaching languages via options in the source files itself. Presumably, this could also provide signatures.

mikesperber commented 1 year ago

sidenote, I just found out you can use checked signatures by (require lang/htdp-advanced) ! Sadly there isn't an Image type built in and I'm not sure if I want to introduce the any type %s so quick.

; in menu selected BSL context
(require lang/htdp-advanced)

(: double (Number -> String))
(check-expect (double 4) 8)
(define (double n)
  (* n 2))

There are image-related signature definitions for the DeinProgramm languages here:

https://github.com/racket/deinprogramm/blob/master/deinprogramm/deinprogramm/sdp/image.rkt

These should be trivial to port to the HtDP languages.

mikesperber commented 1 year ago

Indeed, this is a bug. @mikesperber

Logged this as #177.

mikesperber commented 1 year ago

Checked signatures have been in *SL for a while now, so closing this.