idiom

Sep. 20th, 2021 06:16 pm
totient: (plug)
[personal profile] totient
Programming languages, like human languages, have idioms; if you use constructions that other people are familiar with you are more likely to be understood, separately from the grammar of the language. This doesn't sound so useful -- wouldn't it be better to just make everything straightforward -- but in coding just as in conversation sometimes you want to express a complex or subtle concept. More importantly, though, idiom helps keep multiple programmers aligned with how the code is expected to work -- so long as they're all using the language in the same way.

Recently I was brought on to a project at work to audit it for places where the code wasn't doing what we thought it was doing. This is not so simple as just reading through 25,000 lines of code written by six authors because that's too much to keep in your head at once. But a first read through did turn up a small handful of places where a data structure did things that were far away from usual coding idiom. One bit in particular did some things that I found surprising and thought would be especially likely to give rise to misunderstandings. Today I went through and looked at the code that used that data structure and sure enough, it expected the data structure to work according to the usual idiom and not the strange one. Clearing up the misconception won't be too hard and maybe the program will work better once I do. Hopefully I can do that in a way that makes it less likely that someone else will have the same misunderstanding in the future.

Date: 2021-09-23 04:51 pm (UTC)
vettecat: (Default)
From: [personal profile] vettecat
Glad you were able to figure it out!

Profile

totient: (Default)
phi

December 2025

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 1st, 2026 11:54 am
Powered by Dreamwidth Studios