Live data from Hacker News

I keep bouncing off the Scheme language

sicpers.info

21–30 of 91 posts

Re: I keep bouncing off the Scheme language

#21
post #6

I was the same way (and still am somewhat, I can't get hygenic macros into my head) but due to the differences between Scheme and Common Lisp. What helped me was writing imperative code that Scheme people would surely scoff at, and gradually using more and more Scheme features as I kept writing. Then I refactored the whole codebase to look like the final few hundred lines.

Oh, kinda like how I learned Emacs: use it "wrong" for years, treating it as a sort of weird archaic Notepad++, then gradually discover features, master the keybindings, and learn to program Emacs Lisp over time until my proficiency, and the utility the editor provided to me, grew.

these days i'm seriously considering switching to zed tho

Re: I keep bouncing off the Scheme language

#22
post #19

scheme is great, but the dx of some implementations is not. i’m on guile scheme due to guix, and frankly, i’m hating it a quite bit. stack traces are esoteric and error messages entirely unhelpful, documentation masquerades as deep but is indeed inconsistent and prosaic, mixing styles of reference, explanation, and how-to willy-nilly, (compare with Dybvig’s The Scheme Programming Language, which is focused and consis…

I am only amateur level with scheme but these are common to other scheme implementations. SRFIs are semi-standardized core libraries that work mostly the same in all implementations. I believe the record-type and records generally are one of these SRFIs, and it’s based on a chapter in SICP (several show up as sections of the book where students implement things that would be language feature in a larger env)

All the Lisp implementations seem to have pretty cryptic seeming errors, but it also seems to be very informative to those who know how to parse the call stack and how to expand/dig down in the built in debuggers. This is likely because of the same idea as those record-types, much of the language is built in the same lisp you’re running - so the error messages go a few levels lower level than you would expect. It’s not just a C syntax error type explanation, but rather you get some error about a bad call to a function you’ve never heard of running below that feature we normally associate with being a core function

Re: I keep bouncing off the Scheme language

#23
> Obviously an LLM generated the code, but I felt comfortable following along and understood what it was doing, reading and Trusting the Tests. [...] My difficulty is with thinking the way that lets me write Scheme.

There's your problem, right there. Vibe-coding is sabotaging learning before you even start.

You can learn some things by reading good code, but there's no substitute for the exercise of thinking through problems yourself. (Also, an LLM won't necessarily give you good code.)

First learn paint fence, Daniel-san. Not watch third-hand videos spliced together of other people painting the fence, and thinking you'll understand much of anything about it.

> I have the ALGOL neurotype.

Good news! Scheme started as a block-structured imperative "algorithmic" language in the spirit of ALGOL. Just with more parentheses.

Write as if in ALGOL, but using Scheme's comparable syntax and language features. And lots of parentheses.

Don't get confused by CS professors showing you pure-functional features, the metacircular evaluator, recursive programming, syntax extension and language-oriented programming, etc. You can come back to that.

Just start coding ALGOL-style in Scheme. You'll accomplish something in an hour.

Once you see it's easy, and are comfortable with that part, then the next thing you do, to get more idiomatic is one of the following, then do the other one:

* Try to get more functional, by eliminating some of the mutations of variables in your code. For example, if you're using `set!` a lot, can you eliminate them by, for example, making them arguments in a named-`let` recursion. (Or, instead of named-`let`, spell out the recursive functions, like some intro CS professors will want you to do, but that can obscure things that are obvious once you see the named-`let` lexical structure.)

* Try to get more language-oriented, by making a little domain-specific language, maybe with `syntax-rules`, `syntax-case`, or `syntax-parse`.

One more tip, for anyone coming from C, C++, Rust, etc., who may like trying to know the cost of everything: If you get hung up on high-level language features like GC, and not knowing which of a number of ways of doing something, is the right (performant) way, try not to. But if you want an intuition (that might be a lie), imagine that needless mutations or allocations may be more expensive than finding a different way to do it. And each FFI call has very expensive overhead. At one point that I had to make highly performant code, I made a little tool, to help confirm my intuitions: https://www.neilvandyke.org/racket/shootout/ There's also a statistical profiler in Racket now, and you can even (with work) rig it up in production systems, for measuring real-world workloads, which I used to guide optimizing performance of a large and complicated system.

Re: I keep bouncing off the Scheme language

#24
post #3

Is it possible you're too stupid to write scheme? Because that's where I think I am, I've also tried and failed to write it a few times.

I don't know you, but it seems very unlikely. scheme is a little different because it doesn't really encode or enforce 'standard patterns' that serve as mold that we pour code into. that probably means that its not quite as clear where to start. but at least in r4rs-land its based on a very small number of general simple primitives.

I think it's refreshing change of perspective, and certainly worth pursuing if you're interested at all in in building programming structures rather than just using them. but if its not at all to your taste I wouldn't beat yourself up about it.

Re: I keep bouncing off the Scheme language

#25
post #19

scheme is great, but the dx of some implementations is not. i’m on guile scheme due to guix, and frankly, i’m hating it a quite bit. stack traces are esoteric and error messages entirely unhelpful, documentation masquerades as deep but is indeed inconsistent and prosaic, mixing styles of reference, explanation, and how-to willy-nilly, (compare with Dybvig’s The Scheme Programming Language, which is focused and consis…

I explored migrating from NixOS to Guix, and I also hit the wall with the quirks of Guile Scheme. Architecturally, I find a Guix much clearer API than NixOS and aspire to the peace of mind that would come with a compiled system configuration. When I leaned into LLM's for support and they were substantially less effective at getting me over the line, not just conceptually but being able to close their parens properly. I ultimately decided to bail on the experiment, but it left me sad because my hunch was that if Guix were in nearly any other non-lispy language I'd have stuck through it.

Re: I keep bouncing off the Scheme language

#26
> When I think about a programming problem, I think in terms of the sequence of instructions I need the computer to do, and the memory locations that can hold the information the computer needs to track.

You’re almost there. Just stop thinking about the sequence of instructions. Focus on the information half (the values) that you need to produce.

Re: I keep bouncing off the Scheme language

#29
If solutions come naturally to you in OOP, why not just roll with it?

Personally I find it easiest do design data flows: think about what we need in order to compute the result. The less I have to think about state the better. Functional patterns fall out and it feels simple and easy to me, so I do it. I'm way over the phase I thought that's somehow cooler than the OOP folks, however.

Re: I keep bouncing off the Scheme language

#30
post #14

I think that it helps a lot to have a daily practice of using a language for small things. In much that same way that many people do the daily wordle or crossword, I do the daily leetcode. I flip a coin and solve it first in either C++ or Python, then re-write my solution in the other one. Usually it takes me around 20 minutes to solve it in either language, and 5 minutes to re-solve it in either language. Recently I…

How did you arrive at C++ and Python? Yes I'm aware they have many structural and aesthetic differences, but why would you not choose a language with a different paradigm—functional, logical, even procedural, etc?
Post reply on HN