<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: functional-programming</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/functional-programming.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2025-12-17T23:23:35+00:00</updated><author><name>Simon Willison</name></author><entry><title>AoAH Day 15: Porting a complete HTML5 parser and browser test suite</title><link href="https://simonwillison.net/2025/Dec/17/vibespiling/#atom-tag" rel="alternate"/><published>2025-12-17T23:23:35+00:00</published><updated>2025-12-17T23:23:35+00:00</updated><id>https://simonwillison.net/2025/Dec/17/vibespiling/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://anil.recoil.org/notes/aoah-2025-15"&gt;AoAH Day 15: Porting a complete HTML5 parser and browser test suite&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anil Madhavapeddy is running an &lt;a href="https://anil.recoil.org/notes/aoah-2025"&gt;Advent of Agentic Humps&lt;/a&gt; this year, building a new useful OCaml library every day for most of December.&lt;/p&gt;
&lt;p&gt;Inspired by Emil Stenström's &lt;a href="https://simonwillison.net/2025/Dec/14/justhtml/"&gt;JustHTML&lt;/a&gt; and my own coding agent &lt;a href="https://simonwillison.net/2025/Dec/15/porting-justhtml/"&gt;port of that to JavaScript&lt;/a&gt; he coined the term &lt;strong&gt;vibespiling&lt;/strong&gt; for AI-powered porting and transpiling of code from one language to another and had a go at building an HTML5 parser in OCaml, resulting in &lt;a href="https://tangled.org/anil.recoil.org/ocaml-html5rw"&gt;html5rw&lt;/a&gt; which passes the same &lt;a href="https://github.com/html5lib/html5lib-tests"&gt;html5lib-tests&lt;/a&gt; suite that Emil and myself used for our projects.&lt;/p&gt;
&lt;p&gt;Anil's thoughts on the copyright and ethical aspects of this are worth quoting in full:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The question of copyright and licensing is difficult. I definitely did &lt;em&gt;some&lt;/em&gt; editing by hand, and a fair bit of prompting that resulted in targeted code edits, but the vast amount of architectural logic came from JustHTML. So I opted to make the &lt;a href="https://tangled.org/anil.recoil.org/ocaml-html5rw/blob/main/LICENSE.md"&gt;LICENSE a joint one&lt;/a&gt; with &lt;a href="https://friendlybit.com"&gt;Emil Stenström&lt;/a&gt;. I did not follow the transitive dependency through to the Rust one, which I probably should.&lt;/p&gt;
&lt;p&gt;I'm also extremely uncertain about every releasing this library to the central opam repository, especially as there are &lt;a href="https://github.com/aantron/lambdasoup"&gt;excellent HTML5 parsers&lt;/a&gt; already available. I haven't checked if those pass the HTML5 test suite, because this is wandering into the agents &lt;em&gt;vs&lt;/em&gt; humans territory that I ruled out in my &lt;a href="https://anil.recoil.org/notes/aoah-2025#groundrules-for-the-advent-of-agentic-humps"&gt;groundrules&lt;/a&gt;. Whether or not this agentic code is better or not is a moot point if releasing it drives away the human maintainers who are the source of creativity in the code!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I decided to &lt;a href="https://github.com/simonw/justjshtml/commit/106289acee29045cc5afe9732915357063dfc37a"&gt;credit Emil in the same way&lt;/a&gt; for my own vibespiled project.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/avsm/status/2000979482744607216"&gt;@avsm&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/definitions"&gt;definitions&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai-assisted-programming"&gt;ai-assisted-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai-ethics"&gt;ai-ethics&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/vibe-coding"&gt;vibe-coding&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ocaml"&gt;ocaml&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/vibe-porting"&gt;vibe-porting&lt;/a&gt;&lt;/p&gt;



</summary><category term="definitions"/><category term="functional-programming"/><category term="ai"/><category term="generative-ai"/><category term="llms"/><category term="ai-assisted-programming"/><category term="ai-ethics"/><category term="vibe-coding"/><category term="ocaml"/><category term="vibe-porting"/></entry><entry><title>Statically Typed Functional Programming with Python 3.12</title><link href="https://simonwillison.net/2024/May/26/statically-typed-functional-programming-with-python-312/#atom-tag" rel="alternate"/><published>2024-05-26T08:12:05+00:00</published><updated>2024-05-26T08:12:05+00:00</updated><id>https://simonwillison.net/2024/May/26/statically-typed-functional-programming-with-python-312/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://wickstrom.tech/2024-05-23-statically-typed-functional-programming-python-312.html"&gt;Statically Typed Functional Programming with Python 3.12&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Oskar Wickström builds a simple expression evaluator that demonstrates some new patterns enabled by Python 3.12, incorporating the match operator, generic types and type aliases.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/hphovk/statically_typed_functional"&gt;Lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;&lt;/p&gt;



</summary><category term="functional-programming"/><category term="python"/></entry><entry><title>On Endings: Why &amp; How We Retired Elm at Culture Amp</title><link href="https://simonwillison.net/2023/Apr/10/how-we-retired-elm-at-culture-amp/#atom-tag" rel="alternate"/><published>2023-04-10T02:11:46+00:00</published><updated>2023-04-10T02:11:46+00:00</updated><id>https://simonwillison.net/2023/Apr/10/how-we-retired-elm-at-culture-amp/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://kevinyank.com/posts/on-endings-why-how-we-retired-elm-at-culture-amp/"&gt;On Endings: Why &amp;amp; How We Retired Elm at Culture Amp&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Culture Amp made extensive use of Elm—a ML-like functional language that compiles to JavaScript—between 2016 and 2020 while building their company’s frontend. They eventually decided to move away from it, for reasons described at length in this post primarily relating to its integration with React. This piece is worth reading mainly as a thoughtful approach to engineering management challenge of deprecating a well-loved piece of technology from the recommended stack at a company.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/pvrcob/on_endings_why_how_we_retired_elm_at"&gt;lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/kevin-yank"&gt;kevin-yank&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/management"&gt;management&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/react"&gt;react&lt;/a&gt;&lt;/p&gt;



</summary><category term="functional-programming"/><category term="javascript"/><category term="kevin-yank"/><category term="management"/><category term="react"/></entry><entry><title>Better Python Object Serialization</title><link href="https://simonwillison.net/2020/Jan/7/better-python-object-serialization/#atom-tag" rel="alternate"/><published>2020-01-07T20:35:22+00:00</published><updated>2020-01-07T20:35:22+00:00</updated><id>https://simonwillison.net/2020/Jan/7/better-python-object-serialization/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://hynek.me/articles/serialization/"&gt;Better Python Object Serialization&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
TIL about functions.singledispatch, a decorator which makes it easy to create Python functions with implementations that vary based on the type of their arguments and which can have additional implementations registered after the fact—great for things like custom JSON serialization.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/json"&gt;json&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/serialization"&gt;serialization&lt;/a&gt;&lt;/p&gt;



</summary><category term="functional-programming"/><category term="json"/><category term="python"/><category term="serialization"/></entry><entry><title>Quoting Brian Goetz</title><link href="https://simonwillison.net/2011/Aug/19/peek/#atom-tag" rel="alternate"/><published>2011-08-19T12:20:00+00:00</published><updated>2011-08-19T12:20:00+00:00</updated><id>https://simonwillison.net/2011/Aug/19/peek/#atom-tag</id><summary type="html">
    &lt;blockquote cite="http://mail.openjdk.java.net/pipermail/lambda-dev/2011-August/003877.html"&gt;&lt;p&gt;There is plenty of evidence in the ecosystem to support the hypothesis that, if given the tools to do so easily, object-oriented programmers are ready to embrace functional techniques (such as immutability) and work them into an object-oriented view of the world, and will write better, less error-prone code as a result. Simply put, we believe the best thing we can do for Java developers is to give them a gentle push towards a more functional style of programming.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p class="cite"&gt;&amp;mdash; &lt;a href="http://mail.openjdk.java.net/pipermail/lambda-dev/2011-August/003877.html"&gt;Brian Goetz&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/java"&gt;java&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/recovered"&gt;recovered&lt;/a&gt;&lt;/p&gt;



</summary><category term="functional-programming"/><category term="java"/><category term="recovered"/></entry><entry><title>php: rfc: closures</title><link href="https://simonwillison.net/2008/Jul/19/closures/#atom-tag" rel="alternate"/><published>2008-07-19T22:58:45+00:00</published><updated>2008-07-19T22:58:45+00:00</updated><id>https://simonwillison.net/2008/Jul/19/closures/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://wiki.php.net/rfc/closures"&gt;php: rfc: closures&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I never thought I’d see the day, but a patch adding closures to PHP has been both proposed and accepted! Looks like a solid implementation—the syntax is similar to JavaScript but makes explicit which variables are to be captured. As with much of PHP, values are copied in to the closure by default but you can use an ampersand to specify JavaScript-style pass-by-reference instead.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://www.sitepoint.com/blogs/2008/07/16/keeping-current-with-php/"&gt;Keeping Current With PHP&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/closures"&gt;closures&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/php"&gt;php&lt;/a&gt;&lt;/p&gt;



</summary><category term="closures"/><category term="functional-programming"/><category term="javascript"/><category term="php"/></entry><entry><title>In praise of functional programming</title><link href="https://simonwillison.net/2003/Apr/29/functionalProgramming/#atom-tag" rel="alternate"/><published>2003-04-29T23:57:55+00:00</published><updated>2003-04-29T23:57:55+00:00</updated><id>https://simonwillison.net/2003/Apr/29/functionalProgramming/#atom-tag</id><summary type="html">
    &lt;p&gt;Via &lt;a href="http://bitworking.org/news/Snippets"&gt;Joe Gregorio&lt;/a&gt;, Functional programming in Python &lt;a href="http://www-106.ibm.com/developerworks/library/l-prog.html" title="Making more out of your favorite scripting language"&gt;Part 1&lt;/a&gt; and &lt;a href="http://www-106.ibm.com/developerworks/library/l-prog2.html" title="Wading into functional programming?"&gt;Part 2&lt;/a&gt;. I'm reading &lt;a href="http://mitpress.mit.edu/sicp/"&gt;Structure and Interpretation of Computer Programs&lt;/a&gt; at the moment (available for free online, but I've got a library copy) and it has been getting me seriously interested in the functional programming paradigm. It's also by far the most enlightening (in terms of "wow, that really makes sense") computer science text book I've ever read. There's something naturally elegant about the functional style, probably thanks to the encapsulation encouraged by the lack of global variables and the extensive use of recursion in functional code examples. It's definitely true that exposure to a variety of programming styles encourages you to think about problems in different ways.&lt;/p&gt;
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/functional-programming"&gt;functional-programming&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="functional-programming"/><category term="python"/></entry></feed>