Is setup and loop provided for convenience? Arduino sketches usually feature a setup and loop function. Are these functions only provided for convenience or do they actually have special purposes? (e.g.: are some operations disallowed or allowed in setup and loop)

Are these two pieces of code equivalent:

Classic

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}


Without loop

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    while(true) {
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
        delay(1000);
    }
}


void loop() {
}


Is it possible to write code without either setup or loop, providing, for example, a main method or other entry point?
Those pieces of code are pretty much the same.

If you look at the Arduino source code you'll see:

setup();

for (;;) {
  loop();
  if (serialEventRun) serialEventRun();
}


(I'm not sure what serialEventRun() does.)

I don't think you can 'overload' the main function declaration. Also note that the main function calls init, which e.g. configures the timers, so millis() etc. will work.