Simon Willison’s Weblog

Subscribe
Atom feed for programming

152 items tagged “programming”

2024

My preferred approach in many projects is to do some unit testing, but not a ton, early on in the project and wait until the core APIs and concepts of a module have crystallized.

At that point I then test the API exhaustively with integrations tests.

In my experience, these integration tests are much more useful than unit tests, because they remain stable and useful even as you change the implementation around. They aren’t as tied to the current codebase, but rather express higher level invariants that survive refactors much more readily.

Carson Gross

# 26th November 2024, 4:50 am / testing, programming

As a junior engineer, there's simply no substitute for getting the first 100K lines of code under your belt. The "start over each day" method will help get you to those 100K lines faster.

You might think covering the same ground multiple times isn't as valuable as getting 100K diverse lines of code. I disagree. Solving the same problem repeatedly is actually really beneficial for retaining knowledge of patterns you figure out.

You only need 5K perfect lines to see all the major patterns once. The other 95K lines are repetition to rewire your neurons.

Grant Slatton

# 11th November 2024, 3:32 am / programming

When presented with a difficult task, I ask myself: “what if I didn’t do this at all?”. Most of the time, this is a stupid question, and I have to do the thing. But ~5% of the time, I realize that I can completely skip some work.

Evan Hahn

# 1st July 2024, 8:42 pm / productivity, programming

Programming mantras are proverbs (via) I like this idea from Luke Plant that the best way to think about mantras like "Don’t Repeat Yourself" is to think of them as proverbs that can be accompanied by an equal and opposite proverb.

DRY, "Don't Repeat Yourself" matches with WET, "Write Everything Twice".

Proverbs as tools for thinking, not laws to be followed.

# 17th May 2024, 12:10 pm / lukeplant, programming

It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter.

Nathaniel Borenstein

# 8th May 2024, 8:24 pm / ethics, programming

It's hard to overstate the value of LLM support when coding for fun in an unfamiliar language. [...] This example is totally trivial in hindsight, but might have taken me a couple mins to figure out otherwise. This is a bigger deal than it seems! Papercuts add up fast and prevent flow. (A lot of being a senior engineer is just being proficient enough to avoid papercuts).

Geoffrey Litt

# 18th March 2024, 6:16 pm / geoffrey-litt, programming, ai, llms

scriptisto (via) This is really clever. “scriptisto is tool to enable writing one file scripts in languages that require compilation, dependencies fetching or preprocessing.”

You start your file with a “#!/usr/bin/env scriptisto” shebang line, then drop in a specially formatted block that tells it which compiler (if any) to use and how to build the tool. The rest of the file can then be written in any of the dozen-plus included languages... or you can create your own template to support something else.

The end result is you can now write a one-off tool in pretty much anything and have it execute as if it was a single built executable.

# 6th February 2024, 4:49 am / programming

Find a level of abstraction that works for what you need to do. When you have trouble there, look beneath that abstraction. You won’t be seeing how things really work, you’ll be seeing a lower-level abstraction that could be helpful. Sometimes what you need will be an abstraction one level up. Is your Python loop too slow? Perhaps you need a C loop. Or perhaps you need numpy array operations.

You (probably) don’t need to learn C.

Ned Batchelder

# 24th January 2024, 6:25 pm / programming, python, ned-batchelder, abstractions, c

2023

This is what I constantly tell my students: The hard part about doing a tech product for the most part isn't the what beginners think makes tech hard — the hard part is wrangling systemic complexity in a good, sustainable and reliable way.

Many non-tech people e.g. look at programmers and think the hard part is knowing what this garble of weird text means. But this is the easy part. And if you are a person who would think it is hard, you probably don't know about all the demons out there that will come to haunt you if you don't build a foundation that helps you actively keeping them away.

atoav

# 30th November 2023, 9:18 pm / programming

A Coder Considers the Waning Days of the Craft (via) James Somers in the New Yorker, talking about the impact of GPT-4 on programming as a profession. Despite the headline this piece is a nuanced take on this subject, which I found myself mostly agreeing with.

I particularly liked this bit, which reflects my most optimistic viewpoint: I think AI assisted programming is going to shave a lot of the frustration off learning to code, which I hope brings many more people into the fold:

What I learned was that programming is not really about knowledge or skill but simply about patience, or maybe obsession. Programmers are people who can endure an endless parade of tedious obstacles.

# 14th November 2023, 4:36 am / programming, new-yorker, chatgpt, ai, llms

2020

elite-source.asm—annotated source code for Elite on the BBC Micro (via) Mark Moxon has annotated every single line of the source code for Elite on the BBC Micro, and his annotations are so clear and in-depth that I can follow it despite knowing next to nothing about assembly code (and certainly nothing about writing it for the BBC).

# 28th September 2020, 2:30 am / programming, retro

2018

Interviewing a developer for whom English wasn’t his first language and he kept calling legacy code “legendary code” and now that’s all I want to write.

Mark Norman Francis

# 17th July 2018, 5:43 pm / programming

awesome-falsehood: Curated list of falsehoods programmers believe in (via) I really like the general category of “falsehoods programmers believe”, and Kevin Deldyckehas done an outstanding job curating this collection. Categories covered include date and time, email, human identity, geography, addresses, internationalization and more. This is a particularly good example of the “awesome lists” format in that each link is accompanied by a useful description.

# 8th April 2018, 7:57 pm / programming, internationalisation

Code is like a poem; it's not just something we write to reach some practical result. Sometimes people that are far from the Redis philosophy suggest using other code written by other authors (frequently in other languages) in order to implement something Redis currently lacks. But to us this is like if Shakespeare decided to end Enrico IV using the Paradiso from the Divina Commedia. Is using any external code a bad idea? Not at all. Like in "One Thousand and One Nights" smaller self contained stories are embedded in a bigger story, we'll be happy to use beautiful self contained libraries when needed. At the same time, when writing the Redis story we're trying to write smaller stories that will fit in to other code.

The Redis Manifesto

# 2nd March 2018, 7:11 pm / programming, redis

By far the most important lesson I took out of this game is that whenever there's behavior that needs to be repeated around to multiple types of entities, it's better to default to copypasting it than to abstracting/generalizing it too early.

This is a very very hard thing to do in practice. As programmers we're sort of wired to see repetition and want to get rid of it as fast as possible, but I've found that that impulse generally creates more problems than it solves. The main problem it creates is that early generalizations are often wrong, and when a generalization is wrong it ossifies the structure of the code around it in a way that is harder to fix and change than if it wasn't there in the first place.

SSYGEN

# 26th February 2018, 5:23 am / programming

2016

What’s the cheapest or free stack solution to deploy and experiment with a realtime application in 2016?

Heroku have a good free tier, and comprehensive support for deploying both Python and Node.js. If you are mainly interested in realtime I would suggest starting out with Node.js on Heroku. Depending on the complexity of your project you might even be able to use raw Node.js without adding something like Express.

[... 81 words]

2015

Are traditional web frameworks and languages like RubyOnRail, Spring Boot and PHP dying now when new fast reactive pure JavaScript frameworks and services like Meteor, Node, Angular 2.0 and Firebase are breaking ground?

No.

[... 40 words]

2014

Have you ever experienced a boost in productivity by switching to a different programming language?

Switching from PHP to Python (over a decade ago now) dramatically improved my productivity as a programmer.

[... 38 words]

How does one decide which Javascript framework (e.g. Node, Backbone, Angular) to use on any given project?

If you are just learning JavaScript, I suggest trying to work without any frameworks or libraries at all. Starting with something like Angular will make it much harder for you to learn the core language and browser APIs.

[... 137 words]

2013

Is there an application like Duolingo, but for math?

Khan Academy have a points, levels and achievements system for mathematics that is similar to the method used by duolingo.

[... 35 words]

Is there a substantial difference between using a Mac or a Windows machine for web development (particularly RoR)?

No matter if you are on Mac or Windows you should be using a Linux virtual machine for development, ideally running the same operating system as you deployment environment (I like Ubuntu for this). Vagrant is a popular tool for managing this kind of setup.

[... 151 words]

Is greater comfort with Windows a good enough reason to switch from PHP to ASP.NET?

Learning Linux really isn’t that hard, and it will dramatically increase your potential horizons as a programmer. Install Ubuntu on a virtual machine on your laptop and start running through some tutorials.

[... 53 words]

Which format for API documentation programmers prefer: PDF or Web?

HTML is a better format for documentation than PDF.

[... 160 words]

Log Management: What is the complexity behind Loggly and similar services?

Pricing isn’t about how hard it is to build something (and building a reliable, highly-scalable centralized log search and archiving system isn’t trivial). It’s about how much value it provides to the customer.

[... 204 words]

What is the ways to view the examples without download the example files in github?

If you can view the file on raw.github.com you can drop the first dot to view it on rawgithub.com—a free proxy service.

[... 107 words]

Using AWS, as my cloud, what is left for me to work on? Is it enough for me to just write the html+css code and programming language code (python)? Or do I stil have to work with mysql and backend stuff? I am pretty new at programming, so I hope it i...

Using a cloud server platform like Amazon EC2 unfortunately will not protect you from needing to understand basic server adminstration—it’s not that different from running your own physical server, except that if you screw up the configuration it’s much easier to throw everything away and start from scratch.

[... 134 words]

Why doesn’t Google use their resources to improve coding languages?

Google invest vast resources in to language improvements, and have been doing so for over a decade now. Just off the top of my head...

[... 184 words]

Which is more productive for a professional software engineer: Sublime Text or Notepad++?

Sublime Text 2. It is cross-platform and hence won’t lock you in to Windows.

[... 33 words]

What computers do Google engineers use when doing heavy programming?

Loads of people at Google use Macs. Google as a company is way too smart to stop using a good product just because it is produced by a competitor.

[... 45 words]

How can I convince my boss that I should dedicate time to clean an important part of our code base?

It sounds like your boss needs to learn about the concept of Technical Debt: http://www.codinghorror.com/blog...

[... 42 words]