The Monaco Code Editor
microsoft.github.io
microsoft.github.io
To be fair I haven't caught up with their current versions (I'm a vimmer, I just tried them) but I think I tried Atom after the React move.
It isn't pleasant to use on my personal laptop (MBA with 4GB RAM) where I frequently switch projects.
While I am a happy Atom user, I am disappointed with performance; I think there's an order-of-magnitude jump in overall speed that the editor could really use.
I understand that Atom is doing a lot, but if you need 16 GB of RAM to run your text editor, this simply means that the developers have not been using the right data structures to manage the state of the application or maybe the new code editors have an implementation of an AI coding for you so you can outsource yourself.
e.g. live libclang-based code completion for Emacs: https://github.com/Sarcasm/irony-mode
I don't think that's a fair assessment given the what is now minimum expectations around syntax highlighting, syntax/grammar validation, autocomplete, etc. We're no longer dealing with "plain text".
My Visual Studio doesn't need 16 GB of ram... I have enough with 4 on Windows ;)
Atom is at a fundamental disadvantage - it's built on a much more complicated and abstracted stack of technologies. Javascript engines do spectacular things these days but they have a harder job to do than executing compiled lisp, and that's before you look at the whole of the rest of the stack involved.
Editor for Middle Aged Computer Scientists
Escape-Meta-Alt-Control-Shift
Tt's still my favourite, though.
I had no issues whatsoever.
Interestingly enough, Atom seems to really struggle on my Windows laptop, it's often incredibly choppy. It actually runs better in a Linux VM than natively on Windows.
"Why all these web workers and why should I care?"
"A: Language services create web workers to compute heavy stuff outside the UI thread. They cost hardly anything in terms of resource overhead and you shouldn't worry too much about them, as long as you get them to work (see above the cross-domain case)."
Maybe that's part of the reason?
I'm working on the editor since almost 5 years now. Phew, time flies.
There is no silver bullet, we mostly try to keep all computations limited to the viewport size (if you have 20 lines visible, then typing, colorizing, painting a frame, etc. should all end up being computed with loops covering those 20 lines and not the entire buffer size).
We also use extensively the profilers, and most recently (last month) I learned about this great tool called IR Hydra[1]. The gains from eliminating bailouts in the hot code paths are probably too small to notice (5-10% per render), but I like to think that everything adds up.
We use translate3d for scrolling (except in Firefox which has a known bug[2]) and that brings down the browser painting times considerably when scrolling.
I've also found insertAdjacentHTML to be the fastest way to create dom nodes (from big fat strings) across all browsers.
Sort of silly to mention, but we use binary search a lot :).
[1] https://top.fse.guru/nodejs-a-quick-optimization-advice-7353...
In what kind of world is that a sensible metric to decide if a function can be inlined?
I mean, why would they fix it with high priority if the engine already has reasonable performance and the benchmarks are happy as well?
> Graph generation: Crankshaft builds the Hydrogen control flow graph using the AST, scope info, and type feedback data extracted from the full-compiled code. Inlining also happens at this stage. Hydrogen is Crankshaft's high-level architecture-independent intermediate representation.
> Inlining: Performed during the graph generation phase. The inlining heuristic is very simple: basically, if the function being called is known, and it is safe to inline, the function will be inlined. Large functions (>600 source characters including whitespace or 196 AST nodes) will not be inlined. Cumulatively, a total of 196 AST nodes can be inlined in a single function.
So they do use AST nodes as a heuristic; I don't really understand why they would also use "source characters including whitespace" though.
Guess I better keep my comments outside the function body from now on when possible.
It looks like you're adding and removing line divs, did you run benchmarks on trying to reuse the line divs and change the contents of them?
By using translate3D you're not using the browser's native scrolling correct? Are you using an open source library to replace the scrollbar? What was the actual performance benefit of using translate3D vs native scrolling?
I've actually never tried to compute a diff and apply it inside a line, maybe I'll try it tomorrow :). A line is basically a list of spans, each having a certain class name and a certain text content. I've just always assumed that iterating over the previous spans, adjusting their class names, adjusting their text content, appending new spans or removing extra left overs would be slower than a big fat innerHTML call (given that each dom read/write access leaves the JS VM and I always thought there's a certain penalty associated with each dom call). But I will definitely try it out!
Here is what we do now - https://github.com/Microsoft/vscode/blob/master/src/vs/edito...
[It might not be the best method, but it was guided by measuring]:
* if there is no overlap between frames (e.g. you jump to a completely different location), the whole thing does a single innerHTML call
* otherwise:
* all the old lines that leave the viewport are removed via multiple domNode.removeChild
* all the new lines that enter the viewport are added via a single domNode.insertAdjacentHTML
* all the old lines that have changed are parsed in one single off-dom innerHTML and then cherry picked via multiple domNode.replaceChild
That is what I could come up with in my attempts to minimize the count of dom calls and not pay for reparsing/repainting the entire viewport on each frame. Maybe there are better ways?
If I remember correctly, we ended up not using native browser scrolling for multiple reasons:
* [if we would not set scrollTop ourselves] the browser would just happily jump to a certain scrollTop, painting nothing (white), then we'd get an `onscroll` and we'd be able to paint the lines. But you'd always get this white flash.
* if we would set scrollTop ourselves:
* AFAIK setting the scrollTop causes a stop the world sort of synchronous layout - I don't know why
* We wanted to have an overview ruler that sits inside the scrollbar and highlights things (find matches, diffs, etc.)
* IE has or had a limit around 2.5M px. That meant we would have had to do something special anyways around 80.000 lines @ 19px line height
The scrollbars are custom implemented (https://github.com/Microsoft/vscode/tree/master/src/vs/base/...). Quick tip: do not implement custom scrollbars.
PS:
Some anecdotal evidence I got that making less calls with larger chunks of data might be better was when I was investigating why creating an editor buffer was slow for very large files (100k+ lines). One of the first things the model (buffer) code did was to split the text into an array of lines.
I implemented this as any sane person would, with a nice for loop, iterating over the string, grabbing the character code at each offset and checking if it was \r or \n or a \r followed by a \n. I would then remember the last cut off index and do a simple substring to extract each line, building an array of lines. I thought that must be the best way one could possibly do this (I don't know a better way than a for loop even in C++).
If I remember correctly, that was taking 50ms in some browser for a pretty large string. I replaced that simple for loop with a lame split with a regex! - /\r\n|\r|\n/ - and the time dropped to 3ms. I can only think that looping in C++ must be a lot better than looping in JS [here's the code today - https://github.com/Microsoft/vscode/blob/master/src/vs/edito...]
I'm maintaining a web spreadsheet that supports 10s of thousands of rows and have spent a lot of time on optimization. We have to handle some richer content (i.e. contact pictures) so simple spans aren't always sufficient.
The way we're doing the rendering each cell is its own div and we reuse divs as they scroll out of the viewport (changing their top position). Previously I was using innerHTML on each div but I found that constructing the dom nodes manually (document.createTextNode, etc) and then doing a dom.appendChild turned out to he slightly faster (full "wipe" = 16% lower render time). I then cached those prebuilt DOM nodes and then doing a full wipe ended up being 3x faster.
So there was a small speedup on initial scroll and then when you're scrolling around and seeing rows/cells that you've seen before there's a large speedup. Not sure if that's helpful, but maybe worth investigating.
And yes, I know what you mean about scroll events not getting called synchronously. There seems to be a difference in how some browsers handle scrolling vs painting. I actually filed a bug with Chrome (https://bugs.chromium.org/p/chromium/issues/detail?id=619796...) as they introduced an issue in Jan 2015 that I just discovered.
And yes, I really don't want to implement custom scrollbars so I'm hoping to get optimized enough to not need them... we'll see though.
In our framework, we have an option to yank complex components out of the DOM and replace them with empty containers. And when they scroll back into view, we put them back (and activate them if they are newly rendered).
Wasn't this part of the motivation for Java? I seem to recall reading something about the heinousness of debugging a half dozen different platform-specific scrollbar implementations...
Thanks for all the info, this is awesome. :)
If you're curious to see the difference, compare the running time of `wc` vs. `wc -l` on large / many files (you might have to force the locale to C for wc -l to hit the fast path).
And now we're painting our own scroll bars and simulate mouse wheel interactions (which then probably still invoke some legacy scroll bar based facility internally in the OS):
https://github.com/Microsoft/vscode/blob/master/src/vs/base/...
And obviously creating issues on the github repo for things you're missing is a big help for me. I try to have a fast turnaround on these things.
I remember reading that the Atom Vim authors believed separating the two was a mistake; they were too intertwined. As much as I'd like to have it be a separate project and not think about it, apparently that doesn't work so well...
Speaking about syntax/text highlighting in HTML ...
In Sciter I've added an option [1] to mark character runs without creating tons of heavy weight DOM elements (The Monaco uses <span>'s for that). Plus an option to style those run marks in CSS:
plaintext > text::mark(keyword) { color: blue; }
plaintext > text::mark(symbol) { color: brown; }
Editor's DOM model in Sciter's case is a flat list of <text> elements representing each line. <plaintext>
<text>first line</text>
<text>first line</text>
...
</plaintext>
In fact such marks are needed not only for syntax colorizing but for other things like misspelling
highlighting, text found highlighting and other cases where you need to highlight text but DOM change is highly non-desirable.[1] Tokenizer + ::mark() = syntax colorizer : http://sciter.com/tokenizer-mark-syntax-colorizer/
It could also be that mobile CSS has its own quirks so different implementation can be used, again, not a DOM expert here.
Please help us out and contribute a PR. Here[1] is where we register the C language and point to the cpp colorizer. And here[2] is the cpp colorizer. Please go ahead and try the C++ colorizer out at the Monarch playground[3] and edit it to make it colorize only C keywords, etc. Here[4] are the steps for adding a new colorizer.
Looking forward for a contribution on this :).
[1] https://github.com/Microsoft/monaco-languages/blob/master/sr...
[2] https://github.com/Microsoft/monaco-languages/blob/master/sr...
[3] https://microsoft.github.io/monaco-editor/monarch.html
[4] https://github.com/Microsoft/monaco-languages#dev-adding-a-n...
My comment was more that the C example code is actually C++.
I had a quick look at their C++ word list [0] and it looks like _Imaginary and _Complex and _Bool are the only missing C99 keywords. Feel free to make a PR if you want them added :)
[0] https://github.com/Microsoft/monaco-languages/blob/master/sr...
Either way, it's definitely one of the better performing code editors in JS/Browser usage. For that matter VS Code works surprisingly well compared to Brackets and Atom.
A quick test shows that Monaco does work on iOS, although there's apparently no selection support within the editor. Surprisingly, double space produces "." as it should, but it seems iOS autocompletion doesn't work (not sure if it can be enabled).
If you have the chance and the time, I would very much appreciate a PR to fix some of the input handling quirks you're seeing on iOS. We are not experts in everything, and I have come to appreciate the amazing world of OSS :). e.g. Recently, we've gotten an amazing PR [1] that fixes a lot of the input handling for CJK languages, which I would have had no chance to fix by myself.
Also, any plans to add intellisense support for other languages?
[0]: https://ace.c9.io/
This is sort of what we do when diffing:
* when we need to compare two buffers, we represent them as two arrays of lines
* we then proceed to trim() each line in both arrays
* we then use a greedy optimization where the first N and the last M lines that are equal (post trimming) in both arrays are dropped from further computation
* we then run a LCS algorithm over the remaining lines to find the diffs
It is important to note that the same two arrays of lines can have multiple equal longest common substrings. This method [1] could get some love and could try to recover in some of these cases.
[1] https://github.com/Microsoft/vscode/blob/5b9ec15ce526decc5dd...
... turns out there's a similar package for Atom: https://atom.io/packages/split-diff
1. http://unix.stackexchange.com/questions/1386/comparing-two-f...
EDIT: I'm actually getting downvoted. This statement is just made in jest people, chill :)
If I use Edge exclusively in screenshots, people assume it's not cross-browser, it's not cross-platform, Microsoft is out of touch with other developers, Microsoft's living in a bubble, etc.
If I use other browsers for screenshots, I get comments like this.
As @dangrossman replied, we all use whatever browser we want for day to day browsing.
As a professional web dev, I make a habit of cycling through the modern browsers because it's just a good practice. I was the annoying guy in my dev team (not Microsoft, a financial services company) in the early 2000's that tested everything in Firefox when everyone else just wanted to use IE6 all the time. I'm typing this in Edge now, last week was a Chrome week.
[please don't downvote the parent comment]
I'm ok with whatever browser works for him, and I will choose whatever browser works for me if IE/Chrome/Firefox does not perform optimally to my own standards.
Perhaps one token screenshot to get the message across isn't a bad idea, especially if everything else is chrome - webdevs sometimes seem to think chrome is good enough for everyone, and if there are compat issues in modern sites, it tends to be due to chrome-specific design (IME, but I bet if you've got a particularly windows or apple focus things may be different).
Most people don't realize how things have changed/are changing on a daily basis.
It wasn't just me, there were also Canon and Epson reps there. Being that we were all basically coworkers (as we had the same jobs), we were very jovial toward each other, but customers would often remark that we should be more hostile toward each other, usually in jest -- still it made me realize how little they understood our day to day jobs, and how little people consider pragmatism in their observances.
I especially enjoy debugging the editor in Edge's F12 Tools, because Edge's debugger is built with the monaco editor ;).
I might need to integrate an editor for a custom DSL into a webapp soon, and Monaco could of course be an interesting alternative to codemirror or ACE.
The monaco-typescript [2] plugin shows how a lot of the language API can be used.
[1] https://microsoft.github.io/monaco-editor/playground.html#ex...
[2] https://github.com/Microsoft/monaco-typescript/blob/master/s...
[1] https://github.com/Microsoft/vscode/wiki/How-to-Contribute
i.e. Pick 'javascript', it shows JS below... but says 'less'.
Still waiting to be able to have decent by 1970 standards code diff on their site.
Startups can merely fully dedicate themselves to exploring new spaces that open up because they're not burdened by things such as being already occupied with doing something, especially something that's profitable.
So when something new appears like VR/AR a startup can jump right in at first opportunity without having to think too much about it. This has the potential to be an advantage and means that startups are "faster" (really just earlier) to certain things.
Github is a profitable business that has nothing to do with editors, so I'd argue that it's not a startup anyway, certainly not in any far that gives them advantage in developing editors or IDEs.
Quite frankly I really don't get why they even bother. It doesn't differentiate their actual business in any useful way and it doesn't make money. In the meantime they're actually facing competition from Gitlab, a company that's adding features so powerful you can and other people have build entire business around them.
I've asked this in the past and all that I could gather was, this is about mindshare.
With regards to GitLab, if they (GitHub) aren't talking about them in weekly meetings, they really should; because last week was the first time that I really thought GitHub, may be in serious trouble. With GitLab's recent UI changes, it looks like they are finally finding their UI groove. It's still rough in some areas, but it looks like they have the resources to improve things.
I don't necessary think GitLab, will be the ones that will usurp GitHub, but what I think GitLab can and probably will do, is seriously devalue GitHub's value proposition. That is, turn Git hosting into a commodity product.
Linkedin says GitHub has 501-1000 employees and if I've read things correctly, they have 2 people working on their search. This means they are dedicating 0.4% of their man power to maintaining and advancing their search technology. Search is one of the things that Enterprise will actually pay for, if it works well.
If history has shown us anything, Microsoft is not shy about creating loss leaders, to get people to use complimentary products in their portfolio. GitHub's entire business model right now, revolves around hosting code. Microsoft and Atlassian have complimentary products that can see Git Hosting become a loss leader, that is, a commodity product.
Other than "Social programming", I really don't know what else GitHub is focused on. And unless I'm really out of touch with today's programmers, I would say 80% of programmers, program because it pays well and not because they are passionate about programming. What I think the vast majority of programmers want, is to be able to leave work on time and this is where I think GitHub should really be throwing resources at. And I'm not sure how a free editor is going to convince people that they need/want to host and pay for code hosting.
They also already have a ton of it. If they want to grab more mindshare, they should significantly improve their education offering. The free plan is nice but doesn't make anyone (want to) use it. They're a few systems for assignments that use SVN to submit assignments, the ones I've used at university all sucked. Create a significantly better solution here and every single computer science student becomes aware of Github.
In any case working on mindshare is an investment in the future, if you're ahead of your competition and can maintain your position relative to them it makes sense to work on mindshare. This is not the case for Github at least not anymore.
- A new version of atom is released and the top voted comment is "Why is it so slow compared to vscode".
- A new version of vscode is releases and the top voted comment is "Why is atom so slow compared to vscode"
With Coco-cola, you are reinforcing an intangible belief, plus your target audience is pretty diverse and suggestible (not the smartest). Mindshare also works with Apple, since they also have a very diverse and suggestible consumer base.
The atom editor is a power tool and its job, is not to help you watch a movie, satisfy a craving, etc. Its purpose is to help you be more productive and when it comes to productivity, it can be measured and this is where Microsoft really threw a wrench into their plans.
Starting the atom editor wasn't a bad move, but with Microsoft's current strategy with vscode, I would think it's time to cut your losses and focus on more immediate needs, like fending off GitLab and hardening your core competencies.
I don't know how many people, out of their 500+ plus employees are working on atom, but I would have to imagine, using their resources to make an enterprise grade issue tracking and wiki/content management system would be a wiser choice.
[1] http://www.foxnews.com/story/2006/04/11/microsoft-readies-mo...
And Visual Studio Code includes the R support out of the box: https://code.visualstudio.com/docs/languages/overview
You can do that in Go, NodeJS, Python... Etc.
I'm guessing you glanced at the page and thought the editors were screenshots.