HNHacker News
TopNewBestAskShowJobs

soegaard

2,364 karma · joined February 19, 2007

submissionscomments
soegaard··on A 6502 disassembler with a TUI: A modern take on Regenerator
Loved the examples!
soegaard··on femtolisp: A lightweight, robust, scheme-like Lisp implementation
This is pretty small.

http://scheme.dk/blog/2006/12/self-evaluating-evaluator.html

soegaard··on Emulating Goto in Scheme with Continuations
If you are into continuations, check Friedman's papers on ReadScheme.

https://github.com/schemedoc/bibliography/blob/master/page6....

In particular look at "Programming with Continuations", "Engines Build Process Abstractions" and "Continuations and Coroutines".

soegaard··on Hoot: Scheme on WebAssembly
https://docs.racket-lang.org/rkt-tree-widget/index.html
soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
I need to study the stack-switching proposal in more detail.

However, I don't see an obvious way of attach and probe continuation marks to the continuations (including the current one).

I am not an expert in continuation marks, so I'll just link to this presentation by Matthew Flatt (which you probably already know).

https://github.com/WebAssembly/meetings/blob/main/stack/2021...

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
Yes. I am following the Scheme tradition of representing immediate values as tagged pointers. And (ref i31) is the obvious choice when using WebAssembly. I am happy you and the team added GC to WebAssembly.

Details on the representation.

https://github.com/soegaard/webracket/blob/main/compiler.rkt...

I am more or less only using the linear memory for the JavaScript FFI. FASL-encoded values are passed back and forth to JavaScript.

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
> Is Racket bytecode different?

Changes to the bytecode representation were indeed rare also in Racket.

The Whalesong project was written as part of a dissertation - and when people graduate and get jobs, projects are often abandoned.

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
I am using a similar representation of immediates as Hoot and wasm_of_ocaml.

The representation is explained here:

https://github.com/soegaard/webracket/blob/main/compiler.rkt...

Internally the compiler uses a series of passes implemented using Nanopass.

    (generate-code
     (flatten-begin
      (closure-conversion
       (anormalize
        (categorize-applications
         (assignment-conversion
          (α-rename
           (explicit-case-lambda
            (explicit-begin
             (convert-quotations
              (infer-names
               (flatten-topbegin
                (parse
                 (unexpand
                  (topexpand stx)))))))))))))))

The code generator is inspired by "Destination-driven Code Generation" by Dybvig, Hieb and Butler. There are some differences however. The code generator in the paper generates "flat" code (assembler) whereas I generate nested Web Assembly instructions.

This approach generates reasonable code without having to implement a register allocator. Also, I believe I saw a Wasm to Wasm compiler that improved register allocation (maybe it was a switch for wasm-tools?).

If (when?) WebRacket becomes a success, we can always switch out individual passes.

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
Maybe. My main problem is to get light-weight support for continuation marks.

If I need a CPS-pass for continuation marks, I might as well use it for continuations as well.

It would be great if it were possible to avoid a CPS-pass though.

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
I wouldn't say compiling full Racket to WebAssembly is impossible. But I think the consensus is that one can't add a WebAssembly backend to the compiler in the same manner as the x86 and arm backends. These backends manipulate the stack in ways WebAssembly prohibits.

This forces an Racket implementation to make continuations explicit. And that will most likely mean a WebAssembly backend will be slower than the native backends.

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
Hi All,

It's still early days for the WebRacket project.

Racket is a huge language, so be patient wrt features.

To keep motivation high I decided to implement a subset that can be used to built practical applications - and then extend the supported features from there. Hopefully, this strategy will also lead to some early adopters that can help me prioritize which features to add.

Some features are simply "more of the same". In this category falls more types of hash tables. Supporting bignums are also a matter of just doing it.

Other features require more work. I have already done some work on implementing modules in terms of linklets. When linklets/modules work, we can reuse the existing implementation of regular expressions.

Adding continuation marks and delimited continuations require adding a CPS-pass. This is certainly doable. Postponing it has been great though. Having a direct style compiler means the generated code follows the structure in the input source code. And that makes debugging easier. Now that bugs have become rarer, it makes sense to look at CPS.

Enjoy.

/Jens Axel

soegaard··on The WebRacket language is a subset of Racket that compiles to WebAssembly
No, there is nothing in common with Whalesong.

Whalesong used the built-in bytecode compiler and compiled the bytecode to JavaScript. Reusing the bytecode compiler is in principle a good idea - but each time the bytecodes are changed, Whalesong needs to be updated.

And after the move to Chez Scheme as backend, the bytecode compiler is no longer a part of the main compilation path.

soegaard··on Trump to impose tariffs on European nations over Greenland
Nato - Article 2

The Parties will contribute toward the further development of peaceful and friendly international relations by strengthening their free institutions, by bringing about a better understanding of the principles upon which these institutions are founded, and by promoting conditions of stability and well-being. They will seek to eliminate conflict in their international economic policies and will encourage economic collaboration between any or all of them.

soegaard··on Racket v9.0
A wonderful video!
soegaard··on Racket v9.0
From the Idris 2 documentation:

    >> Can Idris 2 compile itself?
    > Yes, Idris 2 is implemented in Idris 2. By default, it targets Chez Scheme, 
    > so you can bootstrap from the generated Scheme code, as described in Section 
    > Getting Started.
Also, check this talk:

https://www.youtube.com/watch?v=h9YAOaBWuIk

soegaard··on Racket v9.0
Go to racket-mode.com for the very nice Emacs-integration.
soegaard··on Structure and Interpretation of Classical Mechanics (2014)
I think, this is the best way of running the SICM programs.
soegaard··on Practical Scheme
Mock-up?
soegaard··on Show HN: Kent Dybvig's Scheme Machine in 400 Lines of C (Heap-Memory Model)
Even MIT Scheme was used with SICP, the Scheme implementation in the book is different from MIT Scheme.

MIT Scheme was for a long period one of the leading Scheme implementations. It lacks support for Apple Silicon, so it is not as popular now, as it once was.

https://www.gnu.org/software/mit-scheme/

soegaard··on RacketCon (fifteenth) October 4-5, 2025
The stream is now live.
soegaard··on RacketCon (fifteenth) October 4-5, 2025
Livestream available.
soegaard··on Scm2wasm: A Scheme to WASM compiler in 600 lines of C, making use of WASM GC
Node.
soegaard··on Scream cipher
The identifier `->` is already used for type annotations.
soegaard··on Ultrasonic Chef's Knife
When a large force is applied unintentionally to a finger we have the problem. With a dull knife you need to apply a larger force than with a sharp knife. [The video illustrates this with breaking the skin of the tomato.] For a normal cut this is not a problem.

But - if the knife slips and a large force is applied at the same time - then you will get a large cut.

If the knife slips and a small force is applied, you will get a smaller cut.

If the probability of slipping is the same for sharp and dull knifes, then due to the forces applied, the cuts you get with a sharp knife are less dangerous.

soegaard··on Novo Nordisk offers Ozempic at $499/month to eligible US cash-paying customers
The US list prices are, well, a complicated matter. For non-US readers, it is important to note that 80% of the customers (who has insurance) don't pay the list price, but rather an much more reasonable over-the-counter price.

Due to the system of insurance companies and PBMs in the US the list price is often high.

When PBMs a are negotiating with the pharmaceutical companies, they have an incentive to keep a high list price. Let's say the PBMs and a pharmaceutical company negotiates for the price of a drug X.

If the pharmaceutical company lowers the price of the drug X, and there are other comparable drugs from other companies on the market, then there is a risk that the PBM simply drops the drug X from their lists. Instead, they make a better deal (for them) on drug Y.

For the company producing X, being omitted from the insurance companies lists, is bad business.

As an outsider, it is difficult to understand that the US keeps the private insurance layer and the PBMS.

Now - the insurance companies also don't pay list prices. They get a rebate. But they - and here my memory fails me - the get some money from ... the government based on the list price.

Look at the congress hearings on the high medicine prices on YouTube.

soegaard··on Pseudo, a Common Lisp macro for pseudocode expressions
Similar idea: https://www.youtube.com/watch?v=ueGC3xVcDlc William Bowman: First class Prompt Engineering with llm lang! (This is a bad idea.) (RacketCon)
soegaard··on Extending Emacs with Fennel (2024)
/u/ashton314

Look for `define-syntax`.

https://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_i... https://www.r6rs.org/final/html/r6rs/r6rs-Z-H-13.html

soegaard··on Extending Emacs with Fennel (2024)
The name `macro-expand` is from Common Lisp.

Scheme R5RS, R6RS and R7RS all have macro systems. In R5RS has a pattern/template based system (syntax-rules). In R6RS the system has both patterns, templates and procedural macros.

The most modern system is Racket though. See `syntax-parse`.

soegaard··on Bayeux Tapestry Will Return to the U.K. In 950 Years
If you happen to be in Nordjylland, Denmark then you can also see the recreation:

https://www.boerglumkloster.dk/hvad-kan-jeg-se/bayeux-tapete...

soegaard··on c4wa – C compiler for Web Assembly
I think, the author's goal was to produce wasm-code that had the same structure as the original C. Thus it makes sense to turn off the advanced optimizations.
← PreviousPage 2 of 18Next →