![]() ![]() ![]() You have to implement them correctly on every operating system. There's a mountain of shortcuts - like Ctrl+A, Ctrl+X/C/V, etc. These shortcuts are OS-specific and can be overridden in the user's OS level settings - which you don't have access to from javascript. ![]() There's another keyboard shortcut to go to the start / end of a line, or the start / end of the input element. Ctrl+Left / right for moving a word at a time. If you implement your own text box using canvas, all this stuff will be broken by default. There's all sorts of very complex OS-level UX controls which hook into a text box. The appealing bit with WebAssembly is potentially that objects will have a smaller memory footprint, therefore we can push further than this 9 million LoC limit where the Chrome tab just runs out of memory, rather than having algorithmic slowdown.ĭon't do that. For text editors, I'm not sure this overhead is worth it, especially when V8 / Chrome is doing some crazy JS optimization behind the scenes. The bottleneck is serializing data back and forth between WebAssembly and JavaScript. Speaking of which, VSCode is built entirely in TypeScript and has a reputation of being a fast and snappy editor.Īt any rate, I don't buy the argument that because Rust is fast and WebAssembly is comparably fast, then it makes sense to push your data structure, especially a text buffer, down into WebAssembly. To be fair, they have other sorts of overhead and processing layers to deal with, namely building an AST with potentially thousands of layer of hierarchical / code folding. For comparison, VSCode uses a more esoteric data structure called a PieceTree but for me becomes unresponsive at 500k LoC. Moreover, even localized shifts are fast. ![]() You'd expect this array to be non linear, too. Random access for a small section of that 9 million element array is still fast. The trick is to not render everything to the DOM, just the stuff people are looking at. I focused on other optimizations and strangely my text editor is able to keep 9 million loC file ( over 500mb ) in memory. The problem is that you're going to need to get the data back out of WASM eventually, back into JavaScript and then back to the DOM. I anticipated that it would get slow, and that potentially I can push this into WebAssembly. I'm just using a giant array with one element for each line. And for trees with different internal nodes and leaves, your code will give the optimizer indigestion. You can implement all of this stuff in javascript - you just end up with much more memory indirection than you want. > Javascript has the same problem with b-trees, skip lists, ropes, gap buffers, AABB trees, and so on. In wasm I can do it in about 0.03 seconds. In rust I can replay the same trace in 0.01 seconds (100x faster), by using a skip list. The fastest JS implementation I know of takes about 1 second to replay an editing trace from a user. To me this is the big performance advantage wasm has - that we can make high performance data structures. In my experience, basically any of these data structures will run about 10-200x slower than their native counterparts. Javascript has the same problem with b-trees, skip lists, ropes, gap buffers, AABB trees, and so on. Either way, your javascript code will be slower than the C/rust equivalent because the language is less expressive. The big thing that makes javascript slow (that the optimizer can’t really fix) is complex data structures.įor example, if you want to implement an editable string, you have to do so using an array of smaller strings and hope the optimizer can figure it out, or slice() and re-join a single “immutable” string. Non-trapping float-to-int conversions: Added new conversion instructions that avoid trapping when converting a floating-point number to an integer Sign extension instructions: Added new numeric instructions for performing sign extension within integer representations. Vector instructions: Added vector type and instructions that manipulate multiple numeric values in parallel (also known as SIMD, single instruction multiple data) Multiple tables: Added the ability to use multiple tables per moduleīulk memory and table instructions: Added instructions that modify ranges of memory or table entries Table instructions: Added instructions to directly access and modify tables Reference types: Added and as new value types and respective instructions Multiple values: Generalized the result type of blocks and functions to allow for multiple values in addition, introduced the ability to have block parameters Thanks! Here's a quick summary from there, with links to the implemented proposals. ![]()
0 Comments
Leave a Reply. |