To expand entirely too much on my well-meaning shitpost:
You can make a beep with a computer with simple programs in lots and lots of ways! Some of them are certainly more interesting than others. This “hello world” variant should work in basically any language you can use to write a console program on the desktop. Printing the BEL character (escape code '\a') to the terminal exactly like this is probably one of the first ways I ever deliberately made a program make sound, I think a friend and I even had some goofy C or C++ program that would beep repeatedly this way with some pseudo-musical timing by just using spin-wait delays.
If one’s goal is to build specific effects or tools for audio processing, there are lots of awesome environments where this is going to be a lot less work than other ways you can go about it. Many of these will let you learn programming while also getting to do real-time audio stuff, visual programming, etc. out of the box, and that is very satisfying and can be very productive. But I think that if one’s goal is to learn to program, C can be a great place to start. It has relatively few syntax elements, it allows very direct manipulation of memory and files, it challenges and teaches valuable techniques through its constraints. It is also scurrying around somewhere underneath the feet of basically any other programming environment you come across. Writing software you will some day be well-served, especially if you want to involve real-time signal processing, by having a working knowledge of C. There is a learning curve as far as understanding the language building blocks but that’s true in every language or environment.
My immediate reaction to the sentiment that audio programming in C is too complicated for beginners to learn to make something musical before getting frustrated was “what’s the simplest C program I can write that makes a sound?” and I think that this would be a super fun way to structure a C tutorial – every program somehow makes sound, either by playing it directly, by creating a file, or other means. You can also use a lot of great libraries for abstracting away a lot of the complicated bits that you don’t want to deal with, nowadays there are even pretty good package managers for writing C/C++ programs. Here is an example I set up which uses Conan to install the cross-platform PortAudio library, then build the paex_sine.c example file to play a 5 second (loud! turn your volume down) sine wave. This should work on any platform as long as you have a C compiler and Python installed. That is easier said than done on some platforms but still I think fairly comparable to setup procedures for most programming languages. This also hides a fair number of details that it is also important for beginners to understand that don’t directly relate to the programming part – invoking the compiler, including and linking, etc. – but I think these can also be learned incrementally side-by-side with the actual programming part.
There is something really special about programming C or assembler that is hard to separate from how I think about software. Especially on a platform like a microcontroller with no operating system where nothing is write protected and writing to some addresses can do something tangible, there is a feeling of glimpsing what the machine actually is, encountering at once its elegance and power and fragility and capability for self-destruction, making lights blink and steppers step and BEEPS! I would most likely not have learned “how to program” in any practical sense, or at least would have had a much different path there, had it not been for my early experiences programming C. I value that a lot and having some of those engrossing experiences is something I wish for all programmers, beginners or otherwise.
That said, I frequently prefer to actually try and do music things inside environments where the hard work of building the tool, or at least the workshop, has been underway for a while – there is a framework in place where I can focus on “application logic”. Thankfully there are tons of platforms now where this is possible, and many of them can be easily extended in C, enjoying immediate interaction with the data without having to lay the groundwork first. On the other hand, living in a software environment you built yourself in some way is wonderful, the feeling of knowing roughly where to find things, or of understanding at a glance the complicated chain of events that would result in the bug you’re looking at, and feeling like you know where the secret tunnels go.
My first encounter with the concept of a computer program as something that could be written was stumbling across AppleScript on what I’m almost certain was called a Macintosh SE II, but Google seems unconvinced that such a model existed. Perhaps it was an SE/30? I had no clue what I was looking at, or what a “syntax error” was, which was all I could get it to say for a long time. I was looking for video games. I guess I came back to it enough times that I eventually figured out there was a record button, which would convert whatever else you were doing on the computer into text! From that I figured out some basics about available commands, and I managed to program it to, like, open a folder and slide the window around the outer edge of the screen. This would have all been copy-pasting and editing stuff the macro recorder spat out, I don’t think I had any concept of flow control until several years (and programming languages?) later. My parents seemed confused, but supportive.
After that I feel like K-12 was only occasionally punctuated by intervals in which I was not farting around trying to teach myself to program something. Misadventures included: endless if-else trees of Visual Basic dialog boxes composing a short and deeply uninteresting choose-your-own-adventure text game, being given and reading the first chapter of a half dozen or so different books on C++ before getting bored, a stream of harebrained toy programs, failing to understand some web tutorials on SDL and OpenGL in service of some nebulous fantasies about making video games, really bad Geocities-cliche type websites making prominent use of <embed src="ff3_kefka.mid"> and bearing no regard for the idea of a “closing tag”.
In retrospect I think I was a pretty awful and unfocused learner and absorbed way less from these experiences than I could have, not for a lack of trying on other people’s part. When I was introduced to microcontroller programming in high school something clicked, I started to understand why C was designed this way, which I don’t think had really been conveyed in the course of my earlier attempts to learn C++. After that I started to get more serious about it, went to college, yada yada.