HN user

soegaard

2,332 karma
Posts66
Comments501
View on HN
soegaard.github.io 3mo ago

Show HN: Command line tool for viewing files in color

soegaard
1pts0
boxcast.tv 9mo ago

RacketCon 2025 – Live Stream

soegaard
3pts0
con.racket-lang.org 9mo ago

RacketCon (fifteenth) October 4-5, 2025

soegaard
9pts5
www.youtube.com 1y ago

Freespin [video]

soegaard
1pts1
www.pagetable.com 1y ago

How MOS 6502 Illegal Opcodes Work (2008)

soegaard
66pts17
developer.apple.com 1y ago

Apple Documentation Archive

soegaard
2pts1
lambdaland.org 1y ago

Should programming languages be safe or powerful?

soegaard
92pts132
github.com 1y ago

PR #6 – Fixed some UI issues

soegaard
2pts0
matt.might.net 1y ago

The CRAPL: An academic-strength open-source license

soegaard
2pts0
www.youtube.com 1y ago

Making 8-Bit Music from Scratch at the Commodore 64 Basic Prompt – Linus Akesson [video]

soegaard
7pts4
erambler.co.uk 1y ago

Learning to Code Without Mathematics

soegaard
1pts0
www.cs.umd.edu 2y ago

Practically Accurate Floating-Point Math [pdf]

soegaard
1pts0
jeapostrophe.github.io 2y ago

The Skyline Problem in Racket

soegaard
5pts4
penrose.cs.cmu.edu 2y ago

Penrose – Tool for Diagrams

soegaard
27pts15
lambdaland.org 2y ago

Towards Fearless Macros – Ashton Wiersdorf

soegaard
2pts0
blog.racket-lang.org 2y ago

Racket v8.13

soegaard
28pts6
en.wikipedia.org 2y ago

Texas Instruments signing key controversy (2009)

soegaard
2pts0
cisco.github.io 2y ago

Chez Scheme Version 10.0.0

soegaard
5pts4
www.theguardian.com 2y ago

EU states accuse TfL [Transport of London] of data breach

soegaard
17pts0
www.semafor.com 2y ago

Elon Musk, Sam Altman, and OpenAI

soegaard
2pts1
education.ti.com 2y ago

Solution 26370: Removing a new Texas Instruments calculator from the package

soegaard
58pts48
status.skypack.dev 2y ago

Ask HN: Is Skypack in Maintenance Mode?

soegaard
2pts3
pavpanchekha.com 3y ago

An Accurate Quadratic Formula

soegaard
5pts0
racket.discourse.group 3y ago

Racket version 8.9 has been released

soegaard
8pts0
github.com 3y ago

Ingored

soegaard
2pts2
www.cut-the-knot.org 3y ago

Pythagorean Theorem via Geometric Progression

soegaard
1pts1
news.ycombinator.com 3y ago

Ask HN: Dead Comments

soegaard
3pts1
soegaard.github.io 3y ago

Convex Hulls – The Metapict Blog

soegaard
41pts14
soegaard.github.io 3y ago

Show HN: Metapict – TikZ like figures using Racket

soegaard
71pts16
cs.uwaterloo.ca 3y ago

Teach Yourself Racket (A Flânerie by Prabhakar Ragde)

soegaard
4pts0

I LOATHE the fact that you traverse lists and vectors in completely different ways

In Racket:

    (for ([x xs]) (displayln x))
This works for `xs` being a sequence, which includes lists and vectors.

Making the type explicit generates faster code:

    (for ([x (in-list   xs)]) (displayln x))
    (for ([x (in-vector xs)]) (displayln x))

FWIW if you are looking for examples of WebAssembly written in the textual format, take a look at:

https://raw.githubusercontent.com/soegaard/webracket/refs/he...

As a small example, here is a definition of `$car` which extracts the first value from a pair.

    (func $car (type $Prim1) 
               (param $v (ref eq)) 
               (result (ref eq))
      (if (result (ref eq)) 
          (ref.test (ref $Pair) (local.get $v))
          (then (struct.get $Pair $a (ref.cast (ref $Pair) (local.get $v))))
          (else (call $raise-pair-expected (local.get $v))
                (unreachable))))

An Incremental Approach to Compiler Construction

Abdulaziz Ghuloum

http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf

Abstract

Compilers are perceived to be magical artifacts, carefully crafted by the wizards, and unfathomable by the mere mortals. Books on compilers are better described as wizard-talk: written by and for a clique of all-knowing practitioners. Real-life compilers are too complex to serve as an educational tool. And the gap between real-life compilers and the educational toy compilers is too wide. The novice compiler writer stands puzzled facing an impenetrable barrier, “better write an interpreter instead.”

The goal of this paper is to break that barrier. We show that building a compiler can be as easy as building an interpreter. The compiler we construct accepts a large subset of the Scheme programming language and produces assembly code for the Intel-x86 architecture, the dominant architecture of personal computing. The development of the compiler is broken into many small incremental steps. Every step yields a fully working compiler for a progressively expanding subset of Scheme. Every compiler step produces real assembly code that can be assembled then executed directly by the hardware. We assume that the reader is familiar with the basic computer architecture: its components and execution model. Detailed knowledge of the Intel-x86 architecture is not required.

The development of the compiler is described in detail in an extended tutorial. Supporting material for the tutorial such as an automated testing facility coupled with a comprehensive test suite are provided with the tutorial. It is our hope that current and future implementors of Scheme find in this paper the motivation for developing high-performance compilers and the means for achieving that goal.

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.

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.

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.

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

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.

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.

Racket v9.0 8 months ago

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