TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Everything Is Just Functions: 1 week with David Beazley and SICP

390 pointsby kurinikku6 months ago

31 comments

emmanueloga_6 months ago
Warning: Diving into SCIP&#x2F;Lisp&#x2F;Scheme can transform how you think about programming... food for thought is always welcomed! But applying those ideas wholesale to OOP codebases often backfires or gets pushback from teammates. Languages handle paradigms differently, and going against the grain usually leads to worse code.<p>Example: After Lisp, you might replace every for loop with forEach or chain everything through map&#x2F;reduce. But unless you’re working in a language that fully embraces functional programming, this approach can hurt both readability and performance.<p>At the end of the day, it’s grounding to remember there’s mutable memory and a CPU processing the code. These days, I find data-oriented design and “mechanical sympathy” (aligning code with hardware realities) more practical day-to-day than more abstract concepts like Church numerals.
评论 #42169778 未加载
评论 #42170173 未加载
评论 #42169977 未加载
marvinborner6 months ago
They give a nice introduction to encoding state as pure functions. In fact, there are many more purely functional encodings for all kinds of data like trees, integers, sum&#x2F;product types, images, monads, ...<p>The encodings can be a bit confusing, but really elegant and tiny at the same time. Take for example a functional implementation of the Maybe monad in javascript:<p><pre><code> Nothing = nothing =&gt; just =&gt; nothing Just = v =&gt; nothing =&gt; just =&gt; just(v) pure = Just bind = mx =&gt; f =&gt; mx(mx)(f) evalMaybe = maybe =&gt; maybe(&quot;Nothing&quot;)(v =&gt; &quot;Just &quot; + v) console.log(evalMaybe(bind(Nothing)(n =&gt; pure(n + 1)))) &#x2F;&#x2F; Nothing console.log(evalMaybe(bind(Just(42))(n =&gt; pure(n + 1)))) &#x2F;&#x2F; Just 43</code></pre>
评论 #42166841 未加载
评论 #42166688 未加载
评论 #42168370 未加载
评论 #42173549 未加载
评论 #42166462 未加载
zahlman6 months ago
I&#x27;ve watched the actual SICP lectures before (the 1986 recordings on MIT OCW). They&#x27;re often praised for the information density, but it actually still wastes a lot of time listening to students&#x27; Q&amp;A, the lecturers drawing the class&#x27; attention to various attempts at &quot;multimedia&quot; presentation in the classroom, simply not having the entire lesson plan worked out in advance (i.e., not being able to <i>preempt</i> the Q&amp;A) etc. For that matter, the sheer amount of time spent on <i>writing things on a chalkboard</i> really adds up.<p>And of course the order of the material could be debated and rearranged countless ways. One of my future planned projects is to do my own video series presenting the material according to my own sensibilities.<p>It&#x27;s nice to hear that the course apparently still stays true to its roots while using more current languages like Python. Python is designed as a pragmatic, multi-paradigm language and I think people often don&#x27;t give it enough credit for its expressive power using FP idioms (if not with complete purity).
评论 #42168073 未加载
评论 #42168455 未加载
评论 #42168226 未加载
评论 #42171050 未加载
liontwist6 months ago
The cons&#x2F;car&#x2F;cdr implementation as lambda was magical the first time I saw it. But it just shows that the language runtime must implement key&#x2F;value dictionaries and you are able to borrow that implementation to make other data structures.
评论 #42166573 未加载
评论 #42165632 未加载
评论 #42203090 未加载
gugagore6 months ago
I recently came across the notion that you <i>need</i> inductive data types (and can&#x27;t just use Church encodings) if you want to do theorem proving, like proving that `0 != 1`.<p>I threw up some content up here: <a href="https:&#x2F;&#x2F;intellec7.notion.site&#x2F;Drinking-SICP-hatorade-and-why-you-need-inductive-data-types-14121476bd0a8083b96ee8bc36a3bd94" rel="nofollow">https:&#x2F;&#x2F;intellec7.notion.site&#x2F;Drinking-SICP-hatorade-and-why...</a> , along with an unrelated criticism of SICP.<p>I&#x27;d like to better understand what the limitations are of &quot;everything is just a function&quot;.
评论 #42168230 未加载
评论 #42169475 未加载
评论 #42169214 未加载
WillAdams6 months ago
The book itself is currently being discussed at:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42157558">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=42157558</a><p>Is there a reason why the link goes to the discussion at the bottom of that page rather than the beginning?<p>Could this be folded into the other discussion? (I don&#x27;t see that the link has been posted there yet)
lifeisstillgood6 months ago
David Beazley is a bit of a legend in the python world and honestly this course seems a surprising idea but it took about two seconds thought before it seemed perfect match and Inhave signed up for the next one.<p>The relevant part is that this is basically how “software engineers continual education” is going to look like
评论 #42169118 未加载
评论 #42167617 未加载
js26 months ago
There&#x27;s a typo in the code in &quot;the substitution model&quot; section:<p><pre><code> (&quot;+&quot;, (&quot;fib&quot;, (&quot;-&quot;, &quot;n&quot;, 2)), (&quot;fib&quot;, (&quot;-&quot;, &quot;n&quot;, 1))), </code></pre> The two calls to `fib` are surely meant to be `fibonacci` since the latter is defined, but not the former. Indeed, the code is correct in the github repo:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;savarin&#x2F;pyscheme&#x2F;blob&#x2F;0f47292c8e5112425b50db19b744a50d8cabde4f&#x2F;src&#x2F;test_pyscheme.py#L27">https:&#x2F;&#x2F;github.com&#x2F;savarin&#x2F;pyscheme&#x2F;blob&#x2F;0f47292c8e5112425b5...</a>
评论 #42166831 未加载
User236 months ago
I think SICP is wonderful.<p>As I&#x27;ve learned more and studied more math though, I&#x27;ve come to the conclusion that the relation really is the more fundamental primitive. Every function can be represented as a kind of restricted relation, but the converse is not true, at least not without adding considerable extra gadgetry.<p>While of course relational databases and SQL are the best known examples of relational programming, and are highly successful, I still believe it&#x27;s a largely untapped space.<p>However, my interest currently is less in the space of programming language design and more in teaching very young children the basics of math. And for whatever reason it&#x27;s considerably easier to teach a predicate like &quot;is big&quot; as a 1-ary relation and &quot;is bigger than&quot; as a 2-ary relation than trying to capture the same concepts as functions.
asah6 months ago
Not a fan of everything-is-a-function because it&#x27;s oversimplistic and often unhelpful. Some of the issues:<p>- functions that don&#x27;t fit in cache, RAM, disk, etc.<p>- functions that have explosive big-O, including N way JOINs, search&#x2F;matching, etc.<p>- functions with side effects, including non-idempotent. Nobody thinks about side channel attacks on functions.<p>- non-deterministic functions, including ones that depend on date, time, duration, etc.<p>- functions don&#x27;t fail midway, let alone gracefully.<p>- functions don&#x27;t consume resources that affect other (cough) functions that happen to be sharing a pool of resources<p>- function arguments can be arbitrarily large or complex - IRL, there are limits and then you need pointers and then you need remote references to the web, disk, etc.<p>(tell me when to stop - I can keep going!)
评论 #42166621 未加载
评论 #42169746 未加载
评论 #42168544 未加载
评论 #42168689 未加载
bob10296 months ago
<a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=PAZTIAfaNr8" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=PAZTIAfaNr8</a>
评论 #42165268 未加载
评论 #42165614 未加载
评论 #42165201 未加载
ysofunny6 months ago
alternative take: everything is just sets<p>both can be a foundation for mathematics, and hence, a foundation for everything<p>what&#x27;s interesting is how each choice affects what logic even means?
评论 #42168681 未加载
pinerd36 months ago
Just fyi (perhaps @dang) this jumps to the Postscript of the blog post due to the anchor&#x2F;hash in the URL. I was a bit confused initially.
评论 #42168403 未加载
wslh6 months ago
&gt; Everything Is Just Functions...<p>I&#x27;d iterate on that and say: everything is just languages and dialogues, with functions being one component of them. Over time, we’ve evolved from machine languages to higher-level ones, but most popular languages today still focus on the &quot;how&quot; rather than the &quot;what&quot;.<p>Programming paradigms, even those like functional and logic programming, requires the &quot;how&quot;. My rant is this: the next major iteration(s) in programming languages should shift focus to the &quot;what&quot;. By abstracting away the &quot;how&quot;, we can reach a higher-order approach that emphasizes intent and outcomes over implementation details.<p>I don&#x27;t want to constrain this idea to Z3, LLMs, or low&#x2F;no-code platforms, but rather to emphasize the spirit of the &quot;what&quot;. It’s about enabling a mindset and tools that prioritize defining the goal, not the mechanics.<p>I know this contradicts our work as software engineers where we thrive on the &quot;how&quot;, but maybe that’s the point. By letting go of some of the control and complexity, we might unlock entirely new ways to build systems and solve problems.<p>If I should be plain realistic, I&#x27;d say that in the middle, we need to evolve by mixing both worlds while keeping our eyes on a new horizon.
评论 #42165246 未加载
评论 #42169451 未加载
评论 #42165320 未加载
hyperbovine6 months ago
Reading this brings back fond memories of taking CS61a with prof Brian Harvey at UC Berkeley some 25 years ago. Same book, same level of mind=blown, and very similar instruction style. we spent a semester instead of a week and if memory serves tuition was about the same, but they threw in some English and history courses as well :-)
评论 #42166877 未加载
评论 #42165351 未加载
评论 #42165671 未加载
behnamoh6 months ago
Shameless plug: <a href="https:&#x2F;&#x2F;aplaceofmind.notion.site&#x2F;It-s-Lambdas-All-the-Way-Down-eb33012f54bb4708af001e0214910698" rel="nofollow">https:&#x2F;&#x2F;aplaceofmind.notion.site&#x2F;It-s-Lambdas-All-the-Way-Do...</a><p>I got to the same conclusion a while ago, except that I found that it&#x27;s lambdas all the way down.
评论 #42168040 未加载
upghost6 months ago
Dave is a stellar instructor with a bottomless well of knowledge. One of the few people I go to when I have a Python question I can&#x27;t figure out. I&#x27;ve taken every course he has available: compilers, lisp, raft, and advanced python salary*. I can say definitively that my salary has doubled twice thanks to his courses, so well worth the effort from my opinion.<p>That being said... SICP, Compilers, and RAFT all left me with the gnawing feeling that there was more juice to be squeezed from computer science than I was able to understand.<p>Why were my parsers and compilers not bidirectional? Why am I writing a utilitarian OO parser for an elegant FP language? Why is there no runtime polymorphic isomorphism for my client&#x2F;server RAFT nodes?[1]<p>Drowning in my own sorrows, I began binge drinking various languages, drifting from one syntax to the next. CL, Scheme, Java, C#, Haskell, Forth, TypeScript, Clojure... ahh, long love affair with Clojure. But in the end, even Clojure, for all of its elegance, could not solve the original problem I was facing and at the end of the day in many ways was just &quot;a better Python&quot;.<p>I was nearly ready to call it quits and write my own language when all the sudden I discovered... Prolog.<p>Not just any Prolog-- Scryer Prolog. Built on rust. Uncompromising purity. And Markus Triska&#x27;s Power of Prolog videos on YouTube.[2]<p>My God. They should have sent a poet.<p>Bidirectional parsing? No-- N-dimensional parsing vis definite clause grammars, ships with standard library. First class integer constraint solvers. And it is the first language I have ever worked with that takes the notion of &quot;code is data&quot; <i>seriously</i>.<p>Scryer is still a young language, but it&#x27;s going big places. Now is a great time to get involved while the language and community is still small.<p>I will end this love letter by saying that I owe my career and much of my passion to Dave, and because of him Python is still how I earn my bread and afford expensive toys for my Yorkie.<p>You rock, Dave!<p>[*]: this was a typo, should be Advanced Python Mastery, but in my ways advanced python salary is actually more accurate, in my case anyway.<p>[1]: If issues like this don&#x27;t bother you, and you haven&#x27;t been coding for at least 10-15 years, maybe come back later. Learning Prolog and Scryer in particular is <i>really hard</i> at first, even harder than Haskell&#x2F;Clojure.<p>[2]: <a href="https:&#x2F;&#x2F;youtube.com&#x2F;@thepowerofprolog" rel="nofollow">https:&#x2F;&#x2F;youtube.com&#x2F;@thepowerofprolog</a>
评论 #42192577 未加载
fngjdflmdflg6 months ago
Surprised &quot;mind-blowing&quot; is not in the HN clickbait filter.
评论 #42167917 未加载
pjmlp6 months ago
Actually it is more like Algorithms + Data Structures = Programs.
评论 #42166286 未加载
zetranrt6 months ago
David Beazley is using Scheme! That is a nice shift towards a civilized language. I hope he scraps the scheme-in-python section, but perhaps that is intended as an exit drug for Python addicts.
评论 #42170734 未加载
shdh6 months ago
From my perspective all software is essentially applying transformation functions to some data.<p>There are externalities like networking and storage, but still data transformation in a way.
fifilura6 months ago
So an integer is represented by how deep in the stack you are?<p>How do you represent an irregular float?
评论 #42165818 未加载
Animats6 months ago
&quot;Everything is just&quot; approaches usually result in hammering things that don&#x27;t fit into fitting. That often ends badly. Computing has been through, at least:<p>- Everything is just a function (SICP)<p>- Everything is just an object (Smalltalk, and to some extent Java)<p>- Everything is just a closure (the original Common LISP object system)<p>- Everything is just a file of bytes (UNIX)<p>- Everything is just a database (IBM System&#x2F;38, Tandem)
评论 #42166225 未加载
评论 #42167436 未加载
评论 #42166849 未加载
评论 #42230269 未加载
评论 #42170062 未加载
评论 #42167755 未加载
评论 #42168165 未加载
评论 #42167841 未加载
richrichie6 months ago
Has anyone read the new SICP with Javascript as language of choice?
评论 #42165082 未加载
评论 #42165465 未加载
评论 #42165037 未加载
rockwotj6 months ago
Everything is just assembly!
vonnik6 months ago
Imagine if that statement applied to every non-digital thing as well.
elcritch6 months ago
And functions are just numbers combined with if&#x2F;else&#x27;s and a pretty name at the end of the day.<p>If this number, jump to numberA otherwise jump to this numberB. Also if numberC store numberD at numberE. ;)
tasty_freeze6 months ago
Neat article. But it was very difficult to navigate for me because 99% I use the keyboard up&#x2F;down arrows to scroll the page as I&#x27;m reading. This page swallows those keystrokes, apparently. Page up&#x2F;down work, but sometimes. I never use page up&#x2F;down while reading because I&#x27;ll be in the middle of a sentence of a paragraph at the bottom, hit page down, and now I need to scan my eyes back to the top of the page. First, it introduces a hiccup in the middle of a sentence, and secondly, because of the hiccup I often want to go back a line or two to reestablish context, but it is now offscreen. Grr.
评论 #42164986 未加载
评论 #42171501 未加载
bombela6 months ago
The link takes around 10s to render. That&#x27;s excessive for a text article.
评论 #42167913 未加载
评论 #42164834 未加载
评论 #42165692 未加载
评论 #42165207 未加载
评论 #42165226 未加载
评论 #42165497 未加载
评论 #42165892 未加载
评论 #42165233 未加载
评论 #42165205 未加载
评论 #42165564 未加载
评论 #42164869 未加载
评论 #42165732 未加载
评论 #42165383 未加载
blackeyeblitzar6 months ago
A computer fundamentally isn’t functions though. That’s not how a processor works. If functions are a useful abstraction, why haven’t functional languages taken off?
评论 #42167317 未加载
评论 #42168684 未加载
评论 #42165967 未加载
revskill6 months ago
I think it&#x27;s a cool book for students.<p>But for real world programming, the tedious ones is related to validation, parsing and other business logic.<p>So i prefer a book to help teach CS by using real world codebase to solve real world everyday problem as a software engineer instead.<p>You can have your cake and eat it.
评论 #42165474 未加载
评论 #42165602 未加载