Live data from Hacker News

The Languages of English, Math, and Programming

github.com

31–40 of 49 posts

Re: The Languages of English, Math, and Programming

#31
post #11

I took a Udacity class by Norvig [1] and my abilities as a programmer clearly were improved afterward. His code here demonstrates why. It is both shorter and much easier to understand than anything the LLMs generated. It is not always as efficient as the LLMs (who often skip the third loop by calculating the last factor), but it is definitely the code I would prefer to work with in most situations. [1] https://www.ud…

Single handedly most important class in my career back in the day. It took me 3 months to really grok and generalize the Qpig algorithm, even my professors couldn't explain it. It's amazing how he never used the words "AI" once in this course despite the fact that it is a straight up AI course. I revisit the course notes at least once a year and I still walk away with something new every time.

I've recommended his book PAIP despite the AI in the title because you can take it as about the craft of programming (I mean things like style and efficiency, not the bare beginning of being able to code at all) -- using old-fashioned AI as the subject matter. To learn better coding you gotta code something.

https://github.com/norvig/paip-lisp

Re: The Languages of English, Math, and Programming

#33
post #11

Earlier quoted context omitted.

Single handedly most important class in my career back in the day. It took me 3 months to really grok and generalize the Qpig algorithm, even my professors couldn't explain it. It's amazing how he never used the words "AI" once in this course despite the fact that it is a straight up AI course. I revisit the course notes at least once a year and I still walk away with something new every time.

I've recommended his book PAIP despite the AI in the title because you can take it as about the craft of programming (I mean things like style and efficiency, not the bare beginning of being able to code at all) -- using old-fashioned AI as the subject matter. To learn better coding you gotta code something. https://github.com/norvig/paip-lisp

Yes, this book is an incredible gem. Hard to believe that one human wrote it. I've been attempting to mine its secrets for a long time. Sometimes it makes me a little embarassed that I've probably spent more time trying to understand it than he spent researching/writing it but I am appreciative that it exists.

But it's especially great if you want to appreciate PN's code more. He actually offers explanations of choices for his distinctive style of coding here. His 6 rules for good code are particularly good. He says they are for good lisp but I think they broadly apply to any language:

https://github.com/norvig/paip-lisp/blob/main/docs/chapter3....

*Edit:* After reading this book I am often really surprised that this book is not referenced as often or more often than SICP is. Not the time or place for a soapbox rant but SICP is often cited as landmark functional programming text when in fact it is largely advocating OO practices implemented in scheme, whereas PAIP really demonstrates full power FP programming on display (type system independent), and where OO practices such as CLOS are used he is quite explicit about it.

Re: The Languages of English, Math, and Programming

#35

> The language that a problem-solver uses matters! Because the "intelligence" is borrowed from language (lower entropy)

What are your thoughts on https://news.ycombinator.com/item?id=41868884

An analogy https://youtu.be/5H8aRCyEGnU

Re: The Languages of English, Math, and Programming

#36
post #9

It's worth noting that math and programming do not appear to be considered "languages" by much of the academic and/or neuroscientific literature; see [0] on the front page right now and my comments regarding the same [1]. [0] https://news.ycombinator.com/item?id=41868884 [1] https://news.ycombinator.com/item?id=41892701

> It's worth noting that math and programming do not appear to be considered "languages" by much of the academic

There is math term "formal language", and both math and programming perfectly fit into it: https://en.wikipedia.org/wiki/Formal_language

Re: The Languages of English, Math, and Programming

#37
When an author writes things like:

"But some of them forgot that 1 could be a factor of 108"

I struggle to take them seriously. The anthropomorphization of AI into something that can "know" or "forget" is ridiculous and shows a serious lack of caution and thinking when working with them.

Likewise it leads people into wasting time on "prompt engineering" exercises that produce overfit and worthless solutions to trivial problems because it makes them feel like they're revealing "hidden knowledge."

Genuinely disappointing use of human time and of commercial electricity.

Re: The Languages of English, Math, and Programming

#38
post #25

What about o1? I think the world is sleeping on o1. Recently I misread a leetcode/neetcode problem (so I was curious that my version of the problem with an extra constraint could be solved in a different way). And 4o hallucinated incorrectly and double downed when asked follow up questions - but o1 solved it the first time what seemed like easily. It really is a major step forward.

So... Can you enlighten us how it went?

Re: The Languages of English, Math, and Programming

#39

I'm just here to point out that since Python 3.10, you don't need to import anything from typing anymore, you could use the built-in types for annotation: from math import prod from itertools import combinations def find_products(k=3, N=108) -> set[tuple[int, ...]]: """A list of all ways in which `k` distinct positive integers have a product of `N`.""" factors = {i for i in range(1, N + 1) if N % i == 0} return {ints…

The typing version is still useful when you want to communicate that the result conforms to a certain interface, which doesn't include mutability in the case of Set, but not the exact type.

Edit: I see that he imported the typing Set, which is deprecated, instead of collections.abc.Set, which is still useful, so your comment is correct.

Re: The Languages of English, Math, and Programming

#40

I took a Udacity class by Norvig [1] and my abilities as a programmer clearly were improved afterward. His code here demonstrates why. It is both shorter and much easier to understand than anything the LLMs generated. It is not always as efficient as the LLMs (who often skip the third loop by calculating the last factor), but it is definitely the code I would prefer to work with in most situations. [1] https://www.ud…

Working extensively in SQL for a while also gives you another perspective of programming. There is just no way you can write this with a for loop in SQL since it does not (generally) have for loops.

  WITH all_numbers AS
  (
      SELECT generate_series as n
      FROM generate_series(1, 108) as n
  ),
  divisors AS
  (
      SELECT *
      FROM all_numbers
      WHERE 108 % n = 0
  ),
  permutations as
  (
      SELECT a.n as n1, b.n as n2, c.n as n3
      FROM divisors as a
        CROSS JOIN divisors as b
        CROSS JOIN divisors as c
  ) 
  SELECT *
  FROM permutations
  WHERE n1 * n2 * n3 =  108
      AND n1 
https://codapi.org/embed/?sandbox=duckdb&code=data%3A%3Bbase...
Post reply on HN