# Matt Might

Matt Might's blog

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Hello, Perceptron: An introduction to artificial neural networks

DevFeed: [Hello, Perceptron: An introduction to artificial neural networks](<https://devfeed.tech/articles/hello-perceptron-an-introduction-to-artificial-neural-networks-35235.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/hello-perceptron/>)

Published: 2023-05-05T14:05:31Z

Content type: tutorial

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [Neural Network](<https://devfeed.tech/topics/neural-network.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [Generative AI](<https://devfeed.tech/topics/generative-ai.md>), [Algorithms](<https://devfeed.tech/topics/algorithms.md>), [circuit](<https://devfeed.tech/topics/circuit.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [circuit](<https://devfeed.tech/tags/circuit.md>), [generative-ai](<https://devfeed.tech/tags/generative-ai.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [neural-networks](<https://devfeed.tech/tags/neural-networks.md>)

### AI overview

This tutorial introduces artificial neural networks through Frank Rosenblatt's perceptron. It explains how a single perceptron can be trained to mimic the AND, OR, and NOT logical functions, then examines its inability to learn XOR as motivation for multilayer neural networks.

### Source excerpt

Generative AI tools like ChatGPT and Midjournery are able to replicate (and often exceed) human-like performance on tasks like taking exams, generating text and making art. Even to seasoned programmers, their abilities can seem magical. But, obviously, there is no magic. These things are "just" artificial neural networks - circuits inspired by the architecture of biological brains. An AI-imagined image of a neural network (Midjourney) In fact, much like real brains, when broken down to their building blocks, these systems can seem "impossibly simple" relative to what they achieve. (Modern computing is also magical in that sense, in that all of what computers are able to do reduces to simple logical building blocks - gates that calculate basic operations with truth values, such as AND, OR and NOT.) The purpose of this article is to give programmers without much exposure to machine learning an understanding of the key building block powering generative AI: the artificial neuron. Toward that end, this article has three goals: to implement a perceptron - the simplest artificial neuron; to train perceptrons how to mimic AND, OR and NOT; and to describe the leap to full-fledged neural networks. Click here to read the rest of the article

## Make a fun, infinitely replayable game in 5 minutes with GPT-4

DevFeed: [Make a fun, infinitely replayable game in 5 minutes with GPT-4](<https://devfeed.tech/articles/make-a-fun-infinitely-replayable-game-in-5-minutes-with-gpt-4-35239.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/make-a-text-game-with-generative-ai/>)

Published: 2023-04-01T15:48:44Z

Content type: tutorial

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [AI Chat](<https://devfeed.tech/topics/ai-chat.md>), [Text-based user interface](<https://devfeed.tech/topics/tui.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [Image](<https://devfeed.tech/topics/image.md>)

Tags: [adventure-games](<https://devfeed.tech/tags/adventure-games.md>), [gpt-4](<https://devfeed.tech/tags/gpt-4.md>), [prompt](<https://devfeed.tech/tags/prompt.md>), [resume](<https://devfeed.tech/tags/resume.md>), [save](<https://devfeed.tech/tags/save.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

The article shows how to turn GPT-4 into a text adventure by supplying detailed world lore and a prompt that asks it to run the game. Define the player and backstory to avoid getting a random character, and add commands such as /help, /look, /inventory, and /mod to inspect the world or adjust the game. A /save command can output key facts about the current state; provide those facts in a later prompt to resume. The author says GPT-3 can use the same approach, but tends to maintain less coherent world states and produce shallower narratives than GPT-4. The article recommends richer lore for a richer game and notes that the chosen character's role can limit how much action the player gets.

### Source excerpt

Compared to prior versions, GPT-4 is more capable at writing fiction. Combined with its advances in reasoning, this allows it to maintain a consistent state in a fictional universe as it emulates a text-based adventure game like the classic Zork. In this article, I'll explain how to convert GPT-4 into a game engine for interactive text-based adventure games with just two simple steps: Create a descriptive lore to define the universe and the player Engineer a prompt to simulate a text-based adventure game You can even add a save game feature that allows you to save the state and resume play later. While GPT-3 works with these techniques, it tends to create worlds with less coherent states and the game has shallower narratives compared to GPT-4. The backstory Figuring out how to create these games emerged from my kids' bedtime. Before they go to bed, I like to spend 15-30 minutes doing something educational and entertaining, such as: reading a book or a graphic novel; doing simple crafts like paper airplanes; asking a question on their mind and searching for the result; choosing an object to have 3D printed by morning; or writing a small program or part of a larger program. Not surprisingly, generative AI expands what you can do in 15-30 minutes! For instance, this image took about 30 minutes from start to finish, combining Midjourney to generate a base image, Lensa to do touch-ups and change the background and then DALL-E to tweak parts of it and extend the borders: The opportunities for text-based gaming turn out to the just as rich! My daughter had created a fictional universe with friends at school, complete with its own lore. So, we dropped in the lore and then asked it to act like a role-playing game in that world. We ended up spending an hour exploring this world brought to life, completing the first "quest" it had imagined for us. Click here to read the rest of the article

## 26 programming languages in 25 days, Part 2: Reflections on language design

DevFeed: [26 programming languages in 25 days, Part 2: Reflections on language design](<https://devfeed.tech/articles/26-programming-languages-in-25-days-part-2-reflections-on-language-design-35233.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/26-languages-part2/>)

Published: 2022-12-31T19:36:56Z

Content type: opinion

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [Programming Languages / Compilers](<https://devfeed.tech/topics/programming-languages-compilers.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Racket](<https://devfeed.tech/topics/racket.md>), [domain-specific language](<https://devfeed.tech/topics/domain-specific-language.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Common Lisp](<https://devfeed.tech/topics/common-lisp.md>), [Haskell](<https://devfeed.tech/topics/haskell.md>), [Erlang](<https://devfeed.tech/topics/erlang.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Python](<https://devfeed.tech/topics/python.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [awk](<https://devfeed.tech/tags/awk.md>), [bash](<https://devfeed.tech/tags/bash.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [code](<https://devfeed.tech/tags/code.md>), [compilation](<https://devfeed.tech/tags/compilation.md>), [complexity](<https://devfeed.tech/tags/complexity.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [data-structures](<https://devfeed.tech/tags/data-structures.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [design](<https://devfeed.tech/tags/design.md>), [functional](<https://devfeed.tech/tags/functional.md>), [language](<https://devfeed.tech/tags/language.md>), [languages](<https://devfeed.tech/tags/languages.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-languages](<https://devfeed.tech/tags/programming-languages.md>), [puzzles](<https://devfeed.tech/tags/puzzles.md>)

### AI overview

Across 26 languages used for Advent of Code, the author found that language choice mattered less than algorithms and data structures, while functional design often made puzzle extensions easier. Syntax mattered little personally, though indentation sensitivity changed the author's preference. Neither static nor dynamic typing was considered universally superior: stricter types helped with complex nested structures and debugging, while dynamic languages sped up work on simpler data, leading the author to favor a gradual path like Racket and Typed Racket. The author prefers functional programming but would retain mutability, favor strict evaluation with laziness available as needed, and start language implementation with an interpreter while avoiding features such as `eval` that complicate compilation. Domain-specific languages worked well in their intended domains, prompting a preference for embedded DSL support. Racket with Typed Racket came closest to the author's preferred design. These are reflections from a short puzzle-solving experience, not a general comparison of all languages.

### Source excerpt

I recently wrote about completing Advent of Code 2022 using a different programming language (or two) every day for 25 days. That note focused on the strategy, tactics and logistics involved in using 26 languages in 25 days without saying much about the languages or the experience itself. Using so many languages in such a short span provided insight into tradeoffs in language design. Here are my two high-level reflections from the experience: Good program design in the first part of each puzzle - especially more functional techniques and abstractions - tended to make the second part easier. So, in general, functional languages seemed to have the advantage in the puzzles. Using better algorithms and data structures was more important than having a "faster" programming language. There was never a time where rewriting in another language felt like the right way to get better performance. Read on for more specific reflections on language design. Click here to read the rest of the article

## 26 programming languages in 25 days, Part 1: Strategy, tactics and logistics

DevFeed: [26 programming languages in 25 days, Part 1: Strategy, tactics and logistics](<https://devfeed.tech/articles/26-programming-languages-in-25-days-part-1-strategy-tactics-and-logistics-35232.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/26-languages-part1/>)

Published: 2022-12-27T23:28:42Z

Content type: tutorial

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Programming languages & frameworks](<https://devfeed.tech/topics/programming-languages-frameworks.md>), [Advent of Code](<https://devfeed.tech/topics/advent-of-code.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [advent-of-code](<https://devfeed.tech/tags/advent-of-code.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [array](<https://devfeed.tech/tags/array.md>), [arrays](<https://devfeed.tech/tags/arrays.md>), [awk](<https://devfeed.tech/tags/awk.md>), [bash](<https://devfeed.tech/tags/bash.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [experience](<https://devfeed.tech/tags/experience.md>), [language](<https://devfeed.tech/tags/language.md>), [languages](<https://devfeed.tech/tags/languages.md>), [latex](<https://devfeed.tech/tags/latex.md>), [learn](<https://devfeed.tech/tags/learn.md>), [learning](<https://devfeed.tech/tags/learning.md>), [logistics](<https://devfeed.tech/tags/logistics.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [programming-languages](<https://devfeed.tech/tags/programming-languages.md>), [puzzle](<https://devfeed.tech/tags/puzzle.md>), [puzzles](<https://devfeed.tech/tags/puzzles.md>), [strategy](<https://devfeed.tech/tags/strategy.md>)

### AI overview

The author completed Advent of Code's 25 daily puzzles in 26 languages, choosing languages around puzzle difficulty, personal experience, and expressiveness. They found the first 15 days especially suitable for trying unfamiliar languages and would save their strongest choices for later puzzles. To manage setup, they used Homebrew for most installations, vim and make as a shared environment (Visual Studio for C#), and wrote a simple file-printing program in advance to create starter projects. With one to two hours per puzzle, they planned algorithms before coding, chose a suitable language family and then a minimum viable language, and translated the solution before optimizing. They relied on familiar data structures, looked up language quirks such as truth rules and array indexing, and often hard-coded puzzle input first, adding a parser later if time allowed.

### Source excerpt

Since making a sudden leap from computer science to academic medicine about seven years ago, I haven't programmed as much. I love what I do in medicine and biology, and I love helping patients. But, I have missed programming - and programming languages. Then I came across the Advent of Code on Mastodon - a series of daily two-part puzzles for programmers that runs for 25 days. On a whim, I solved the Day 1 puzzle using awk. I solved Day 2 in TeX (which underpins LaTeX) to reboot an old skill. After that, I wondered if I could solve each of the 25 puzzles using a different programming language every day. So, I did. In the end: on 12 days, I had to learn a new programming language from scratch, and then use it to solve that day's puzzle; on 4 days, I used languages where I had very little experience; and on the other 9 days, I used languages I had known well at some point. In the end, I used 26 languages, because I combined two on Day 21 (sed and bc), turning the experience into a rapid-fire "breadth-first search" of programming language space. Learning how to learn a new language became the key meta-learning. If you'd like to try the breadth-first search yourself, I have distilled advice on the strategy, tactics and logistics involved in using a new programming language every day for 25 days. You will end up with an appreciation of the relative strengths and intended domains of different languages. Click here to read the rest of the article

## HOWTO: Get tenure

DevFeed: [HOWTO: Get tenure](<https://devfeed.tech/articles/howto-get-tenure-35241.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/tenure/>)

Published: 2015-08-18T16:33:03Z

Content type: opinion

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [Computer science](<https://devfeed.tech/topics/computer-science.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>), [data-engineering](<https://devfeed.tech/topics/data-engineering.md>), [Learning](<https://devfeed.tech/topics/learning.md>)

Tags: [academic](<https://devfeed.tech/tags/academic.md>), [advice](<https://devfeed.tech/tags/advice.md>), [article](<https://devfeed.tech/tags/article.md>), [career](<https://devfeed.tech/tags/career.md>), [computer-science](<https://devfeed.tech/tags/computer-science.md>), [consciousness](<https://devfeed.tech/tags/consciousness.md>), [deep](<https://devfeed.tech/tags/deep.md>), [experience](<https://devfeed.tech/tags/experience.md>), [general-advice](<https://devfeed.tech/tags/general-advice.md>), [medicine](<https://devfeed.tech/tags/medicine.md>), [number](<https://devfeed.tech/tags/number.md>), [office](<https://devfeed.tech/tags/office.md>), [planning](<https://devfeed.tech/tags/planning.md>), [post](<https://devfeed.tech/tags/post.md>), [posts](<https://devfeed.tech/tags/posts.md>), [science](<https://devfeed.tech/tags/science.md>), [students](<https://devfeed.tech/tags/students.md>), [thoughts](<https://devfeed.tech/tags/thoughts.md>), [unique](<https://devfeed.tech/tags/unique.md>), [work](<https://devfeed.tech/tags/work.md>)

### AI overview

The author argues that meaningful work, rather than optimizing for tenure metrics, guided his path to tenure. After a poor first year spent chasing publications and grants, he focused on problems he believed mattered; he credits that shift with improving his research outcomes. He describes his son's rare genetic disease as prompting work across computer science, biology, and medicine, while emphasizing that his family's path was highly unusual. His practical advice is to find problems where personal interests meet society's needs, invest in teaching and service, build strong collaborations, use blogging and social media to attract students, avoid letting metrics replace judgment, and protect health during the pre-tenure years. He cautions against spreading service too thin and regrets not taking a stronger stand for open access. The article presents one personal account, not a repeatable formula.

### Source excerpt

Even before I got tenure, folks have told me they're "looking forward to an academic advice post on tenure." From how to get a Ph.D. to monthly resolutions for grad students, I've found it easy to write academic posts on just about every topic. Except this one. I got tenure over a year ago, yet every time I tried to sum up my views on tenure, I froze. Every path to tenure is inherently unique and non-repeatable. How could I possibly provide general advice? Plus, I wouldn't wish an exact repeat of the last seven years of my life on even Reviewer Number 3 - for reasons that will soon be obvious. And then, while walking to work in Boston on a recent summer morning, a question on Quora gut-punched me without warning: How can I minimize my chances of having a disabled child? I don't want an autistic or Downs child, for example. I am planning on having a strong career in computer science or medicine, and I want to marry someone who is doing the same and have kids some day, but I'm terrified that they'll be severely disabled, and my wife won't agree to abort the fetus. I (maybe naively) believe in love, so I wouldn't necessarily be able to leave my wife if I truly loved her and she refused to abort. Note that this is purely hypothetical. I am only 16 years old at the moment, but I have thought about this a lot. This question burrowed deep into my consciousness, a parasite sapping my ability to think about anything else. When I got to my office, the raw response below ejected out of my brain through my fingertips. And, in the course of answering, I ended up giving general advice on tenure. I've distilled specific thoughts on my experience with tenure below as well. Click here to read the rest of the article

## Counting hash collisions with the birthday paradox

DevFeed: [Counting hash collisions with the birthday paradox](<https://devfeed.tech/articles/counting-hash-collisions-with-the-birthday-paradox-35234.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/counting-hash-collisions/>)

Published: 2015-07-17T03:33:41Z

Content type: article

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [hashing](<https://devfeed.tech/topics/hashing.md>), [hash collision](<https://devfeed.tech/topics/hash-collision.md>)

Tags: [birthday](<https://devfeed.tech/tags/birthday.md>), [geometric-series](<https://devfeed.tech/tags/geometric-series.md>), [hash](<https://devfeed.tech/tags/hash.md>), [hash-function](<https://devfeed.tech/tags/hash-function.md>), [matching](<https://devfeed.tech/tags/matching.md>)

### AI overview

For a uniform hash range of size D, the expected number of matches as n values arrive is n − D + D((D−1)/D)^n. The derivation sums each arrival's probability of matching an earlier value, 1 − ((D−1)/D)^(k−1), then simplifies the geometric series. This counts arrivals that match something already seen, not unique matched values or matching pairs: if three arrivals share one value, the second and third each count as a match, for two total.

### Source excerpt

The birthday paradox observes that in a room of 23 people, the odds that at least two people share a birthday is 50% The same logic that drives matching birthdays also drives the probability that one can find collisions with a hash function. In other words, if you have a uniform hashing function that outputs a value between 1 and 365 for any input, the probability that two hashes would collide in a set of 23 values is also 50% Another useful calculation is the expected number of collisions for a sequence of \(n\) values when the range of the hash function contains \(D\) hashes. The closed form solution is: \[ n - D + D \left( \frac{D-1}{D} \right)^n \] There are a few places online that have this (or an equivalent) closed form solution listed, but I couldn't find anywhere that included the derivation of this form, so I've rederived it and posted it here as a technical note. (My present interest in this calculation comes from the number of matches that will happen in a patient-matching network that attempts to match patients having the same disease, assuming the are \(D\) total diseases possible and \(n\) patients in the network.) Read below for the derivation in terms of generalized birthdays. Click here to read the rest of the article

## 12 resolutions for programmers

DevFeed: [12 resolutions for programmers](<https://devfeed.tech/articles/12-resolutions-for-programmers-35240.md>)

Original publisher: [Read original article](<http://matt.might.net/articles/programmers-resolutions/>)

Published: 2012-01-03T15:06:54Z

Content type: article

Language: en

Sources: [Matt Might](<https://devfeed.tech/sources/matt-might.md>)

Topics: [Learning](<https://devfeed.tech/topics/learning.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [Cryptography](<https://devfeed.tech/topics/cryptography.md>), [computational complexity](<https://devfeed.tech/topics/computational-complexity.md>), [Machine learning](<https://devfeed.tech/topics/machine-learning.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>)

Tags: [2023](<https://devfeed.tech/tags/2023.md>), [analog](<https://devfeed.tech/tags/analog.md>), [arts](<https://devfeed.tech/tags/arts.md>), [automate](<https://devfeed.tech/tags/automate.md>), [humanities](<https://devfeed.tech/tags/humanities.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [personal](<https://devfeed.tech/tags/personal.md>), [programmers](<https://devfeed.tech/tags/programmers.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [project](<https://devfeed.tech/tags/project.md>), [resolutions](<https://devfeed.tech/tags/resolutions.md>), [science](<https://devfeed.tech/tags/science.md>), [security](<https://devfeed.tech/tags/security.md>), [software](<https://devfeed.tech/tags/software.md>), [technical](<https://devfeed.tech/tags/technical.md>), [theory](<https://devfeed.tech/tags/theory.md>)

### AI overview

The article proposes twelve annually renewable, month-long challenges to help programmers avoid technical and personal stagnation: pursue an analog activity; support physical and mental health; try unfamiliar tools or habits; automate routine tasks; study mathematics and computer science theory; improve security and backups; explore arts and humanities; learn new software and a programming language; and complete a personal project. It offers practical suggestions, including setting up primary care and health tracking, experimenting with input devices or operating systems, automating tasks with scripts or smart-home tools, using unique passwords and encryption, maintaining independent backups, and writing a modest program in a new language. The author recommends reflecting after experiments and keeping useful changes. Health recommendations include seeking qualified counseling for mental health concerns.

### Source excerpt

It's important for programmers to continuously challenge themselves in order to avoid creative and technical stagnation. In the spirit of the new year, back in 2012, I compiled twelve month-sized resolutions to help avoid that stagnation. I've updated that list for 2023. Each month is an annually renewable technical or personal challenge: Go analog. Stay healthy. Embrace the uncomfortable. Automate. Learn more mathematics. Focus on security. Back up your data. Learn more theory. Engage the arts and humanities. Learn new software. Learn a new programming language. Complete a personal project. Read on for my suggestions. (If you enjoy this article, you'd likely also enjoy what every computer science major should know or possibly 12 resolutions for grad students.) Click here to read the rest of the article