There is LilyPond which does what you are looking for.
It was first released on 1996, but it still gets updates.
LilyPond is a computer program and file format for music engraving.
One of LilyPond's major goals is to produce scores that are engravedwith traditional layout rules, reflecting the era when scores wereengraved by hand.
LilyPond is cross-platform, and is available for several commonoperating systems; released under the terms of the GNU General PublicLicense, LilyPond is free software.
Wikipedia On the Wiki page
, there is a nice example with some code and the outcome, but it's too big to post here.
We have had many questions tagged lilypond in this site, so you can look through these to get a general idea.
There is also ABC Notation , which is text-based notation (not exactly coding), like: X:1T:Speed the PloughM:4/4C:
Trad.
K:
G|:GABc dedB|dedB dedB|c2ec B2dB|c2A2 A2BA| GABc dedB|dedB dedB|c2ec B2dB|A2F2 G4:||:g2gf gdBd|g2f2 e2d2|c2ec
B2dB|c2A2 A2df| g2gf g2Bd|g2f2 e2d2|c2ec B2dB|A2F2 G4:| and gets you the result:
music.stackexchange.com/users/7356/Shevliaskovic
I have not personally used any of them yet, but there are multiple packages for typesetting music with LaTeX .
music.stackexchange.com/users/10660/ojdo
As mentioned previously, LilyPond might meet your specifications.
For one thing, its input is text form, something which some people equate with "programming"
(for example, the answer proposing MusicXML does not make any sense without that assumption).
For another, one of its implementation languages is Scheme (more exactly, Guile), and Scheme is immediately accessible in its source files as an extension language useful for algorithmic programming.
One example of mixing music and programming is in this unrelated answer to a StackExchange question.
Sorry for not linking to LilyPond and Guile, but my reputation allows only for 2 links, so I had to be selective.
music.stackexchange.com/users/25380/user25380
An older option is MUP , which has been kicking around since 1995 and is now open-source freeware.
It takes in an input file that looks like this and outputs a PostScript file that looks like this .
Note, however, that PostScript is something of an older file format, and you may need to download an extra piece of software to view the files and/or convert them to a different format.
On Mac OS, the built-in "Preview" application will do it, but I'm not sure what the equivalent software would be on a Windows or Linux system.
music.stackexchange.com/users/21557/Michael Seifert
MusicXML, in any text editor, is my favorite way to "code" music.
A tutorial can be found here .
When your code is complete, you can import it into almost any music editing software such as MuseScore, Sibelius, or Noteflight.
music.stackexchange.com/users/25260/OldBunny2800
Trinket allows you to write music with code.
It's rather small at the moment
but it works well for smaller projects.
I haven't noticed any development though in the last few months
so I'm not sure if they mean to continue it.
music.stackexchange.com/users/10339/codedude
I saw a recent notation software product that seemed to offer a novel and concise way to code your music notation. I can't find it so I'm reaching out for your help.
What music notation software allows you to code the notation?
music.stackexchange.com
<notation><software>
music.stackexchange.com/questions/40415
music.stackexchange.com/users/5806/rpeg
Notation software that allows you to code the notation includes LilyPond.  LilyPond is cross-platform, and is available for several commonoperating systems; released under the terms of the GNU General PublicLicense, LilyPond is free software.  Others are MUP, MusicXML and Trinket. There are maycomputer program and file format for music engraving. 
LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules. Trinket  allows you to write music with code. MusicXML, in any text editor, is my favorite way to "code" music and an older option is  MUP