> you would have to have really compelling reasons to start with C++ and not JavaScript and WebGL. And that's coming from someone who actually likes C++ and used to write it professionally.

As someone working in game programming a long time and now also spending more time in machine learning, I must disagree. I suppose I can see your implied point about getting started quickly or something like that, but there's really few compelling reasons to do graphics programming in JavaScript professionally. As a hobby or for a web-based project like a tutorial site, sure, JavaScript and WebGL make perfect sense. For most professional uses though, I can't agree.

Writing a decent performing and well-architected graphics engine is much more than just using an API like OpenGL, WebGL, or any of the successors or predecessors. Further, writing a graphics engine is not about creating an efficient island, but rather a piece of a larger eco-system. Consider that quite often some of the biggest hinderances to graphics performance are creating the data to actually be rendered (ex: via the game update), sending the data to the GPU efficiently, and still getting all kinds of other program logic to run before you even have a frame or want to display a frame. It would be a long post to go into all the details, so forgive me for oversimplifying. Among many things vital to graphics programming that C and C++ provide that JavaScript doesn't or either fails to do well:

- Control of memory allocations and memory shape/characteristics

- Maximizing cache lines (due to architecture, memory footprint, etc.)

- Multi-threading, concurrency, parallel processing

- Data pipelining

- Predictable execution

- Fast, efficient, correct math (or possibility thereof)

- Compilation tweaking/assembler output tweaking

- Efficient IO

- Fast compression/decompression algorithms

- Integration with existing toolchains for graphics including middleware, apps, and shader languages

JavaScript has made great strides in some of these areas and certainly things like web asm help. Nevertheless, most JavaScript runtimes people are using are wholly unsuitable for professional graphics programming. This is akin to people who used to say that you can write a professional game in BASIC or later, Visual Basic. Yes, it's true you can, but should you do it or start there? Probably not if your goal is to learn professional graphics programming. Have people taken such routes and become awesome programmers? Sure, but there are just as many people who never learn, grow, and develop nasty habits that are harder to unlearn than learning the difficult stuff.

If your goal is having fun and learning a few things before moving on to C++, dabble in some JS graphics programming, but since you called our professional programming as no longer being compelling to start, I have to point out that this is both wrong and bad advice to someone new. If you are struggling with the concepts, you will struggle in any language. If you personally need instant gratification and a self-esteem boost, from this point of view JS might not be bad for learning, but it won't teach you a lot of vital things and will encourage some horrific practices. The presence of GC and the lack of a proper parallel and concurrent programming model poison the experience quite a bit.

Ironically, other languages that are more friendly to parallelism and concurrency tend to be better than C, C++, and JS. A lot of the realities of graphics programming are simply caused by historical reasons, market dominance of things like x86 and companies such as nVidia, and existing knowledge, code, and toolchains. Functional languages for instance in many ways have the potential to be better suited to take advantage of the direction we're headed in with regard to numbers of cores, Moore's Law (or diminishing of), GPU design, memory architecture, and so on, but this is just hypothetical mostly. Given JavaScript is hardly known for its ability to deal with concurrency and parallelism in most contexts (no, nodejs doesn't count), again I have to find the above dubious considering you mention the future WRT nVidia.

Of course in the end, you can use things like transpiling, engines that may or might compile to JS as a runtime target, and so on and getting a running product that might be decent in the eye of the beholder. Personally, I've dabbled in JS enough to write a high-performance Voxel engine many years ago when I thought about making a game in JS as well as a skeleton of a 3D adventure game engine for a contract. I was productive enough but ran up against walls that weren't worth working around or just made things feel so kneecapped that I wondered why I was even using JS at all in its current state. The old adage holds that in the end, you can write anything in any language, but there is indeed value of selecting the best tool for the job. Even just making something run and at a reduced frame rate typically is something fundamentally different than being THE language for graphics programming.

In truth, when I first saw JS in the 90s, I thought there was no way it would reasonably do anything in 3D. Things are getting better, but I think you are dramatically underselling what people use and exists today in a professional environment. Your comment about 400 lines of code being that impressive and small seems to also hint you haven't dabbled that much in the area professionally. While your links are just fine and the above shader toy link is indeed impressive in the context of now, personally I was much more blown away when I dabbled in the demo scene and saw what people were doing with an Atari ST, Amiga, and PCs with no GPUs and on systems with less power than today's fitness trackers.

Anyway, I can't think of many compelling reasons to start in JS when IMO, it's better to learn to do things the proper way even if they can be a bit rough and punishing. JS will surely be more productive at the beginning, but also skip teaching you vital things you need to know as well as some of the fundamental primitives of graphics programming. This is the real world and no one in a professional environment cares if you are awesome in JS but don't understand the tools and best practices people actually use industry-wide. Moreover, you won't get far if you can't be productive from your first day because you tried to take the easy way out. If anything, just comparing the amount of resources for JS vs. C/C++, especially from professional vendors like nVidia, Microsoft, AMD, and so on makes me think at best, JS as a starting language for graphics programming only holds for web programmers. If anything this seems to makes things an extra layer of difficult.