This question pertains to computer science and standardization of ambiguous symbol and signal representation in programming languages in general, but I only know the very little C that I know, so I am posting here.

My goal with studying C is for it to be an entry point to the world of programming, so that I can move on to some assembly language down the road. Eventually, I want to understand where human abstraction begins/ends and hardware circuitry takes over and what that border looks like.

A few months ago, I was playing around with assigning hex values corresponding to the alphabetical characters that I wanted to have printed on screen and passing that to, say, printf. This was fun, because 1. it made my terminal look like a hacker’s screen (gibberish) in one of those generic “hacker” images and 2. it simply was interesting (and provocating) to realize how far away from the machine a function such as printf is. (Which lead me down the rabbit hole of looking through related libraries to see if I can find what printf does under the hood…)

A program I’m writing, which trims text from stdin by removing user specified characters, needed a little touch-up, so I looked at the code yesterday for the first time in a few months. I wanted to clear the screen when the program runs and when the program ends, giving it a “feel” of opening and closing a window, without diving into ncurses. (A colleague who is not at all technologically inclined complained about them not understanding what to do with the program, even though all instructions are displayed on screen. Maybe clearing whatever “garbage” is on screen before the program runs will help, I thought.) So last night I learned about yet another standardization: ANSI escape codes. It didn’t take long before I learned how to clear the screen with

printf("\x1b[1;1H\x1b[2J");

and I felt like this is for real now. I’m so cool. :3 :3 :3

But the following thoughts/questions still bother me:

  1. Before I knew anything about programming or electronics, I only cared about one thing: something works or it doesn’t. Now that I know a teeny tiny bit of programming and what not, I can’t stop thinking about how brittle and arduous the journey must have been for the programmers and computer scientist during the 20th century before we had internationally acknowledged standardizations. Portability (or the lack thereof) much?!

  2. I know that I am getting way ahead of my beginner self, but regardless of whether I’m using ANSI escape codes or hex entries in the ASCII table, I still feel like a “fraud” in relation to my ultimate goals. It still feels like a HUGE abstraction from what’s going on under the hood. Especially when I/we use standardized representations of signals like ANSI or ASCII. Or even the language C itself. How many layers does printf("\x1b[1;1H\x1b[2J"); pass before finally hitting the first conductor that leads to whatever transistor is first in line?

  • Blue_Morpho@lemmy.world
    link
    fedilink
    arrow-up
    10
    ·
    5 days ago

    If you’re feeling too abstracted from the hardware, get an esp32 for $10. When you write C for the esp32, anything you don’t write yourself will be from an imported library where you can immediately see the source code. I’d recommend one of the learning kits that come with a breadboard, leds, etc so you don’t have to do any soldering or scrounge wires to get something more than the debug output. Or even better get an esp32 yellow display for $30 that comes with an lcd pre wired to the esp32 in an all in one package.

    Modern build environments have so much automated that it’s hard to get to the source of what something like printf() is doing.

    As to how things were before standards, in a way it was easier because you did whatever you wanted without worrying about how anyone else might do it.