6 ms·
Seems like transcompilation is an area where you really DON'T want be overfocusing on performance. Correctness is king here. I mean, compiler bugs are hard.
by ajross 8y ago
Seems like transcompilation is an area where you really DON'T want be overfocusing on performance. Correctness is king here. I mean, compiler bugs are hard. Really hard. Deep voodoo hard. No one who's ever dealt with a significant code generation bug on a large project ever wants to repeat that experience.
That's not to say that babel isn't too slow or that this project isn't correct, just that it would scare me to try to work with it. Does babel have a regression suite? Does this pass it?
- peterhunt 8y agoJs packing performance (including compilation) is probably the slowest part of the iteration cycle for frontend devs today. When combined with Babel’s and ecmas extensive test suites I think something like this could be wildly successful.
- rcavezza 8y agoCan you elaborate more on this? I've worked with very large codebases in React and Angular and have not seen this issue. I'm guessing it's either because all of my applications were able to hot-reload or we're not thinking of the same thing.
- the_mitsuhiko 8y agoI don’t know if we’re doing something wrong but initial startup time on sentry’s webpack setup is something like 30 seconds and iterative changes around 5 seconds. Still beats our rust or python iteration times though :)
- orf 8y agoHave you looked into why the Sentry Django app takes so long to boot? Are you doing queries on app init or something?
- peterhunt 8y agoa lot of codebases don't support hot reload, but even the ones that do often require multi-second incremental compile times during hot reload if they're big enough [1]. [1] current project is very slow w/ 250kloc (2.5mm kloc w/ dependencies). even seen it be slow on my last project which was only 40kloc.
- mort96 8y agoJust using tsc to compile a hello world with 7 tokens takes over a second in my experience. Sure, most of that is initialization, but compare that to the C and C++ world, where GCC spends tens of milliseconds at most compiling hello world. Hot reloading _helps_, but it's definitely an issue that javascript tooling spends seconds on tasks other languages' tooling spends tens or hundreds of milliseconds on. (The issue isn't just limited to tsc either; just starting the build system can take a decent amount of time with webpack, while make or cmake starts in milliseconds.)
- empath75 8y agoIf you want bug free code, rust is as good a choice as any to write it in.
- tzjmetron 8y agoWhoooosh.
- nkcmr 8y agoWhat part of rust prevents the writing of bugs? I understand it helps you avoid unsafe memory operations, but to say it gives you “bug free” code seems like an falsehood.
- richardwhiuk 8y agoYou can mark values (e.g. Error conditions) as Must Use. This, along with structured enumerated types, means that you can't forget to handle error conditions. Other bugs such as the goto fail bug are eliminated by dead code spotting and consistent formatting. You can write bugs in Rust but they tend to be business logic bugs, or incorrect explicit decisions.
- the_mitsuhiko 8y agoDoesn’t “as good as any” just mean “not worse than any other language”?
- pasta1212 8y agoYes, but why would you say it in the negative form? Both forms mean it’s a tie or better.
- steveklabnik 8y agoRust can not guarantee correctness, but it is a focus in some sense. Strong static typing, robust error handling... you can encode a lot of invariants in the type system. Especially compared to something dynamically typed, like JavaScript. It’s not a proof assistant, but every bit helps!
- polskibus 8y agoThe slower the build the more developer's focus fades away whether he wants it or not. I'd say performance of build tools is at least as important as their correctness :) compiler bug can be fixed but developers' focus not very much.
- jasonkester 8y agoBut you're talking about a step that javascript developers want to inflict on themselves every time they change anything. If the time to do that is not exactly zero, it will kill productivity [1]. [1] Naturally excluding the 18 hours of productivity that will have been killed getting said unnecessary javascript->javascript build system set up and running in the first place.
- swsieber 8y agoIt's a trade off. People aren't stupid or masochistic for making it.
- the_mitsuhiko 8y agoIt uses the tc39 testsuite for verification: https://github.com/tc39/test262 https://github.com/tc39/test262
- hzoo 8y agoIf you can use test262's test suite you should be good, it looks like they are referring to Babel's tests for some of the features? example https://github.com/swc-project/swc/pull/86 https://github.com/swc-project/swc/pull/86, I just checked really quick though. In terms of perf, I'm sure rust will be much faster than JS. And this project's main goal is to be a faster version than Babel. I would suggest the perf test would be different though because it's testing code I would consider not to be representative of what Babel actually runs on. Example with the transform test: https://github.com/swc-project/swc/blob/222bdc191fcab77143197fb0da455c9905d1f983/ecmascript/transforms/benches/bench.rs#L21 https://github.com/swc-project/swc/blob/222bdc191fcab7714319... it's a very small file with minimal transforms even necessary at all. And the parser test is for all minified js files, none of which are written in ES6+ https://github.com/swc-project/swc/blob/master/ecmascript/parser/benches/bench.rs https://github.com/swc-project/swc/blob/master/ecmascript/pa.... Currently it's not really testing ES6+, just how at a baseline it's much faster to process a ES5 file, so it's possible that it might be even faster. edit: I will note that Babel does a lot more than what this project is doing currently (plugins, other proposals, ts/flow, sourcemaps, etc) but this is more about what could be so if people are willing to more on this effort in the long run (with funding/support/people) it could be super useful! I'm curious about how that will work when our project has such a struggle with contributors and Babel itself is written in JS. (I work on Babel :D)
- moron4hire 8y agoI'm sorry, but I'm kind of tired of the idea that some problems are "deep voodoo hard". It casts it in an inaccessible light, creating a culture that new folks internalize, guiding then away from ever even trying. Unless we're talking about "understanding neural network internals", which is a big open problem, there just really aren't "black magic" problems inherent to particular subjects. It's almost always poor spec definition or poor code design, if there are any hand-waivey bits to be found. If anything, compiler design (along with other subjects like text editor development) is a very deeply studied, very well understood, very well documented field. It should be easier than any other fields less central to computer science and software development, just on account of not being so thoroughly studied. EDIT: fixed autocorrect problems
- tedunangst 8y agoHe didn't say compilers were voodoo. Diagnosing subtle bugs in a complex code generator transformer is voodoo. If you haven't written the compiler, but are just an end user, I'd say that's a fair assessment. It's a lot of work to identify what went wrong.
- chrisseaton 8y agoMany people working on compilers will have a PhD in the subject. It's an area where it definitely takes many years to get up to speed. As you said yourself it's deeply studied, and studying all that work takes ages. Compilers are also definitely not well documented. I think they're rather notoriously undocumented with much of our knowledge of the subject passed on orally and existing only in the knowledge of people working in the field. For example a couple of years ago I went looking for details of a very common compiler technique, called safepoints, used in many major industrial compilers today, and found that there was essentially no written information on them at all. That's pretty extraordinary.
- hyperpape 8y agoTwo thoughts: 1. Safepoints are kind of off-topic, because they're part of the interplay between a complex optimizing compiler and the garbage collector/runtime. Babel and its ilk are source-source compilers targeting a language that doesn't have manual memory management. To my mind, that makes things much simpler. 2. How long ago were you searching for safepoint info? I've collected several articles and talks relating to safepoints. I don't know of anything that discusses safepoints in a way that you could implement them from scratch just based on the discussion, but they're tied to a complex part of the runtime, so any example/tutorial code would probably be parochial to a particular VM.