Is there a way to unify these? i.e, just one parser that works for all languages that want to implement JS tooling.
Is there a way to unify these? i.e, just one parser that works for all languages that want to implement JS tooling.
> Everything in esbuild is written from scratch.
> There are a lot of performance benefits with writing everything yourself instead of using 3rd-party libraries. You can have performance in mind from the beginning, you can make sure everything uses consistent data structures to avoid expensive conversions, and you can make wide architectural changes whenever necessary. The drawback is of course that it's a lot of work.
> For example, many bundlers use the official TypeScript compiler as a parser. But it was built to serve the goals of the TypeScript compiler team and they do not have performance as a top priority. Their code makes pretty heavy use of megamorphic object shapes and unnecessary dynamic property accesses (both well-known JavaScript speed bumps). And the TypeScript parser appears to still run the type checker even when type checking is disabled. None of these are an issue with esbuild's custom TypeScript parser.
In my production experience correctness always trumps speed.
And language parsing is not a trivial task. Not every programmer can write a program to do it well (and fast). I know that so far I am not one of the programmers who can, for example.
I prefer to defer to the expertise of those who do it for a living and/or their academic pursuits (as long as they write clean and maintainable code).
So while the general point you quoted can absolutely be viable in many situations -- I've wrote stuff from scratch no small amount of times so I definitely can relate -- the original point here was language parsing where I believe your (and Evan's) take is prioritizing idealism to reality. And the reality is, most programmers aren't good with this stuff, and that's okay.
As for him and esbuild, I only have huge respect to show. But he's one of the few, not one of the many. He should be doing that and he did it very well (I use esbuild and adore it).
I understand where you are coming from, I'm not suggesting this is some widely applicable principle (perhaps the emphasis in my previous comment was suggestive of that).
Absolutism never works in this arena: code reuse and libraries will always have it's place, and can have their own advantages (e.g shared correctness), but sometimes tearing it all down and writing from scratch also has it's place, and I think it is undervalued by comparison - Although I agree it takes a certain kind of person with not only enough experience and wisdom but a level of care and attention to detail that few are capable of.