I am a decent programmer. I know a decent amount of computer science theory, I can type correct code fairly easy. I don’t let my classes expand too much. But I still struggle some with math, and I have a tendency to have too many cross-dependencies in my code.
I used to think I was...
I’ve been learning more and more about what a compiler actually does lately, as well as looking at some very basic levels of assembly. So maybe I can shed a little bit of light on why things are the way they are. That doesn’t mean you have to like it! But at least it will make a bit more sense.
You write your source code, you give it to the compiler, and it makes sure you’ve given it code that will actually run. Then it creates highly-optimized code to be run by your specific processor, in assembly or machine code or whatever. The catch here is that processors don’t always work the same way, so the compiled code is limited to whatever platform it was originally compiled for. As a side note, I would think that’s why you pretty much only see source code available as a download for Linux programs (on the web, anyway) - you’d need to compile it for your specific distribution to make sure it works properly.
It doesn’t have to be like that, though - for example, Java (traditionally) achieves its multi-platform status by compiling its code for the Java Virtual Machine to run however needed on the platform it’s deployed to. Unfortunately, that means forgoing most of the optimization done by a regular compiler. Enter the Just-In-Time compiler, which takes the same Java bytecode as the JVM would. Instead of acting as a middleman, it compiles the bytecode into platform specific machine code (with, I assume, appropriate optimization) at runtime. Sadly, most of the time I see “JIT Compiler” listed as an option in an Android app, it tends to have a huge warning attached (“this will either be really fast or break everything, depending on your phone”). So I guess it’s a work-in-progress.
Anyway, so that’s why you have platforms and code that won’t run anywhere. And, while I’m no expert, I’d say that’s probably how web browsers manage to achieve some semblance of standard-ness. If I’m right, the browser would be kind of a middleman for your code the same way the JVM or a JIT compiler are for Java bytecode. Honestly, you’re the web developer - you tell me how browsers work!