The comparison of PLC to an embedded controller is valid, but are aimed af a different goal. PLCs use a similar type of single-chip microcontroller internally - probably programmed in C, to handle the PLC control language.
A PLC uses an embedded micro to perform its magic.
PLCs have a powerful, easy to learn language and control set, but are strictly constrained with the scope of functions they can perform.
For example, a PLC would be unsuitable to write a text editor!
Coding in C or assembler typically runs an order of magnitude faster and uses less memory than a higher level interpreted or tokenised language like the PLC, BASIC or Pascal etc.
C or C++ are probably as tight/close as you can get to assembler/machine code.
Other languages tend to carry some overhead baggage... and are usually written in C as it turns out !
The source code of a higher level interpreted BASIC, can be re-downloaded intact, while the tokenised PLC or Pascal code can re-download the tokens - to reconstruct the strictly defined source. if the source environment or language version has changed, the old tokens may not match the new development environmen, so you’re out of luck.
In old school BASIC, the closest you can get to the hardware is with those old PEEK and POKE instructions and ASM blocks.
C or other ‘compiled’ languages are converted (compiled) to pure binary machine code (assembler-like) and ‘linked’ before being uploaded to the chip, hence there is only ever machine code available in the target chip to ‘download’ back again... the source code is gone unless you saved it previously, and then it needs to recompiled into binary machine code again - before upload to the chip.
Machine code is typically 80-90% smaller than the required ‘source code’ - hence uses less memory in the target cpu.
Because chips are ‘so fast’ nowadays, they can execute those ‘slower languages’ (interpreted or tokenised) - so quickly that the speed difference* is negligible to the result for the application at hand. Same for memory... newer ARM and other chips have on-chip, or support much larger memory than a small 8-bitter like the basic Arduinos.
- e.g an Arduino UNO or MEGA clocked at 16MHz can execute about 4 million machine code instructions per second.
An ESP or ARM could be clocked at 80 or 300MHz, giving ~20-70 million machine code instructions each second. And they likely have much more memory available.
—NEXT TIME—
The next thing to consider is ‘blocking’ vs ‘non-blocking’ code.
No matter how fast your chipset is, it will be effectively stopped if you implement blocking code styles or structures.