Blogs

SpringSource Blog

Scripted: A JavaScript editor from VMware

aclement

The first version of the Scripted code editor has been released this week on github: https://github.com/scripted-editor/scripted.

Although Scripted is a general purpose code editor, the initial focus is building a great JavaScript editing experience. Scripted itself is built entirely in JavaScript and HTML/CSS. It is a browser-based editor that runs locally on a developer's machine with a Node.js instance being used to serve the editor code and perform the editor operations. The only pre-req for running Scripted is that you have a recent version of Node.js installed (we are testing with Node 0.8.11 right now). Scripted reuses the editor component from Eclipse Orion.

 

Scripted in Action:


 

Why create Scripted?

Scripted is the result of some internal prototyping and investigative work exploring different strategies for future tools. The driving factors for exploring this space were really two-fold:

Firstly we are seeing a number of users choosing not to use an IDE but instead to go with a simpler lightweight editor (vim, Sublime, textmate). Developers typically have a set of tools they are very familiar with for common tasks (e.g. command line git) and don't feel the need to learn how to use those tools through some other user interface. These developers want tools that start pretty much instantly and continue to be extremely responsive during operation. At the moment, however, when choosing to give up the IDE they also seem to be giving up those benefits they've gotten used to like great content assist, fast navigation and early error indication. Scripted offers something lightweight and fast, also supporting key IDE facilities developers can't live without – facilities like content assist and understanding of common module systems. Those are the key focus of Scripted.

Secondly we are seeing a rise in the popularity of Cloud IDEs and the notion of Cloud workspaces. Developers connect to some remote system to do their development work and typically these tools (e.g. the Cloud9 IDE and eXo Cloud IDE) are offering a browser-based editing experience. The users workspace sits on the remote system. This kind of setup can work well for some teams although in our experience we've found there is still some need for an offline development mode as developers are not yet Internet connected 100% of the time and also it can be hard to get them to give up 'full control' and host their files remotely. In following the browser-based editing model and hosting the server locally Scripted is offering something that can meet developers needs now, but that will also enable the use of cloud workspaces in the future by simply deploying the server remotely.

Fundamentally we felt many of the existing JavaScript tools were lacking in some key areas and, given our background in language tooling, we wanted to see if we could build a lightweight tool to address those needs.
 

A focus on JavaScript

JavaScript continues to increase in popularity. No longer just for client side programming, frameworks like Node.js have enabled it to be used for full end-to-end solutions. This is why we chose to focus on JavaScript as a first priority for Scripted. Of course there are related languages we are also interested in (e.g. CoffeeScript, the recently announced TypeScript) but for now the common denominator is JavaScript. We wanted to build a great experience for one language rather than a not-so-great experience across a number of languages.
 

The feature set

  • Fast startup, lightweight.
  • Syntax highlighting for JavaScript, HTML and CSS.
  • Errors and warnings:
    • JSLint is integrated to provide error/warning markers on JavaScript code.
    • AMD and CommonJS module resolution: there is basic resolution where unresolved references will be marked as errors.
  • Content assist:
    • Basic content assist for HTML, CSS
    • For JavaScript, content assist is driven by a type inferencing engine which is aware of AMD/CommonJS module dependencies and also uses JSDoc comments to help it understand the code.
  • Hovers: hovering over a JavaScript identifier will bring up the inferred type signature.
  • Navigation: press F8 on an identifier (that the inferencer has recognized) and the editor will navigate to the declaration. This also works on module identifiers (e.g. in define() clauses)
  • Formatting: JSbeautify is integrated
  • Sidepanel: alongside the main editor a sidepanel can be opened – currently this can be used to host a second editor.
  • Key binding to external command: Key bindings in the editor can invoke external commands (less, mvn, etc)

There is much more detail on these features in the wiki documentation.

 

Using Scripted to develop Scripted

Scripted is 100% JavaScript, HTML and CSS. As such it is a perfect codebase on which to use the Scripted editor. For our other tools projects, we don't typically use the tools themselves in our day-to-day work; instead we develop them for use by others. At VMware we are using Scripted to develop Scripted – and nothing gets bugs fixed faster than when the developers themselves are constantly hitting them!

 

Getting started with Scripted

The github landing page includes a getting started video:

But the basic steps are as follows:

  1. Ensure you have node installed
  2. Grab the latest packaged version (0.2.0) from here:
    scripted_v0.2.0.zip 
  3. Unzip it
  4. Ensure the scripts in the bin folder are executable (if on linux/mac) with:
    chmod 755 bin/*
  5. Add the bin folder to your path:

    Mac/Linux
    export PATH=<pathToUnzipLocationOrClone>/bin:$PATH

    Win:

    set PATH=<pathToUnzipLocationOrClone>\bin;%PATH%
     

  6. Start using it, launch it like you launch 'vi' with 'scr' or 'scripted'

    scr foo.js

Scripted will try to infer your project root at startup. It does this by searching for a close .git or .project file in the hierarchy. If you have none it will work in single file mode. To tell Scripted where the root is, you can create a simple (empty) .scripted file at the root. Scripted needs to know the root because, of course, some operations (like content assist, dependency resolution, search) happen in the context of a project.
 

The technology

As previously mentioned the server side technology is Node.js, but it really is a very small amount of server code. Underpinning the inferencing engine is some server side JS we have written for analyzing module dependencies.

On the client side we did not want to reinvent the wheel for the editor technology and so chose to use the editor from Eclipse Orion. This provides a nice fast editing experience that is very familiar to anyone who has used the editor in 'full eclipse' – it shares many of the same behaviours and key bindings. Where possible the work we have done on features like content assist is being contributed back to the Orion project. Any JavaScript that needs to be parsed is passed through our recoverable derivative of the Esprima parser. When a developer is actively editing a file, the code is usually in an unfinished state and so a recoverable parser that can return a decent AST even when there are errors is very important.

 

What next?

We are currently at an early stage (version 0.2.0), our future plans include:

  • Even smarter inferencing, leading to better content assist and easier navigation.
  • More panes for the side panel. Currently there is just an editor pane but we intend to include search results panes, documentation, git information panes, perhaps code preview and simulated code execution panes. The intention will be for Scripted to try and automatically manage these where possible, so all the content on screen is kept relevant to the task at hand.
  • Simple plugin system.
  • Debugging. Exploring integration with tools like Chrome Dev Tools and node inspector.

 

We decided to open source early to get feedback. If you want to help us shape the editor, please join in the discussion. There is a scripted-dev google group for discussing it and a jira issuetracker for logging bugs, enhancement requests and voting on existing issues to ensure they are prioritized appropriately. If you want to start hacking on the codebase yourself we are definitely open to submissions – see the github page for more information.

Please try it out! https://github.com/scripted-editor/scripted

Similar Posts

Share this Post
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Slashdot
  • Technorati
  • Twitter
 

35 responses


  1. Hi guys,

    It would be really good if you share screen record of installation.

    Installation 6th Step is not properly described.

    Thanks & Regards
    Anil


  2. Testing


  3. While this is a really promising app, good for the reasons of web access and Awesome features in terms of navigation and inferencing data type, there are a couple of comparisons that are inevitable:

    1) jsbin.com does a pretty good job at that and @rem is a proudly maintaining and updating it, and I must say very efficaciously.
    2) jsbin has all the features except for navigation and data inferencing, so I think you are doing a good job there.
    3)jsfiddle is also a great resource of the like
    4) The greatest point of win of jsbin/jsfiddle is that it does not require clients to install anything. Which in your case is an important limitation.

    Why should I have to install node (that too latest version, which might keep changing as the product evolves) to be able to use such a beautiful app.

    While I understand that it might be okay for you to ask me to install something like node to use it, many might not appreciate it.
    Also going forward when you integrate Ruby, Python, Erlang and more complicated interpreter dependent languages, you cannot keep asking consumers to upgrade and/or install your version of the underlying s/w.

    Arguments:
    1) Not every JS dev needs node to shine
    2) Not every Ruby dev needs latest version of ruby or some specific set of packages to use it wonderfully
    3) Not every python dev needs to have a brilliant armoury of packages installed

    If I do JS, native JS might be enough for around 50% of me-kinda people(Personal opinion on the fraction)

    What I am saying is you should consider providing system level requirements from the server end, going forward, as you start more herculean tasks on this.

    As of now it might be ok, since you are beginning to make a revolution, but down the road, definitely try to move towards systems independent app.


  4. I'd be interested in seeing how this compares to Adobe Brackets.


  5. @Anil,

    To launch scripted, just type this on the command line:

    scr

    Does that answer your question?


  6. @Anil,

    Oops…silly comment reader. I wanted to write this:

    scr file_name

    but the file_name part was stripped out since I originally write it using angle brackets.


  7. @Andrew

    Yes. Thanks for the update.Started using it. Sure will share feedback.


  8. Hi @Arindam

    Scripted actually ended up in this current form after a couple of prototypes. We did have a variant that was more traditional client/server setup: remote server that you connect to and you just need your browser. That was more akin to a jsbin/jsfiddle type setup. We got very little traction though – we got a few users expressing interest in trying it out before we built it but once it was available they didn't really bother.

    A combination of factors I'm sure – people are busy and I think it was also the idea of giving up their familiar local workspace (with all those little tools they've collected over the years). The benefits of the tool, with the inferencing and module system awareness, weren't enough for them to make the push and upload their workspaces.

    The architecture we have now works for those users comfortable on their local machine (who don't mind installing Node.js) but allows us at some point to go 'system independent' as you say, by pushing that server remotely – it is certainly a use case we'll be exploring. So far, though, we are getting much more interest and feedback on this setup than the Cloud workspace setup the earlier prototype supported.


  9. @Corey

    In some respects Scripted is similar to Brackets as it is a desktop app for JS development that is itself exploiting web technologies (JS front end) , and also like Brackets we are sitting somewhere between basic editors and full blown IDEs. However, there are some key differences in terms of tech and I think where we are focusing our efforts.

    From a tech point of view we are full JS end to end (our server being a Node app), we're also using the Eclipse Orion editor rather than codemirror. In terms of the software functionality, for showing contextual information we are going to use our side panel where Brackets is using the inline quick edit model but that isn't where we are placing the most investment at the moment. Our investment is in integrating tools that give you early error indication (like jslint) and in understanding the source structure, using our recoverable JS parser. Most importantly right now is that we have some understanding of projects using AMD/CommonJS structures. We're focusing on smarter inferencing and better content assist for JS mainly because those are the real pain points we are having as programmers working in JS. We'll continue to push in this direction.


  10. Hi Andy

    I uploaded your video to YouTube, since it is easier to see it there :)

    http://www.youtube.com/watch?v=Czkr_04DZ1s

    You probably should upload it to an account that you control (and let me know if you do so that I can remove this one)


  11. any eclipse plugin? Does this integrate with notepad ?

    these are the 2 ides i mostly use.. i prefer continueing to use them…


  12. How download on Windows?


  13. @Dinis – thanks! We do have a SpringSource channel, I might try to get a copy in there.

    @Ravi – there is no eclipse plugin. It runs in a browser so you could feasibly run it inside the browser 'view' in an eclipse configuration. This is kind of an experiment separate to our eclipse plugin work. There is no integration with notepad, this is purely a browser based thing.

    @Dfh – Do the instructions in the blog article not work for you? If the step is different on windows (e.g. setting up the path in step 5), that is indicated in the text.


  14. Hey!?!??! Where my question!!!??!?!?!? CRY!!!!!!!!!!!!!!!!!!!!!!!


  15. I want push button like on sourceforge, and get zip file with js programm.


  16. Hey

    I am trying to use scripted to open javascript files that are present in twitter bootstrap. But whenever a js file has dependency on any other js files the editor starts showing up red crosses for variables that were defined in the other js file.


  17. @atin,

    Try using the /*global */ directive. Any variable names listed there will not be underlined. Eg-

    /*global require define bootstrap*/

    This should remove the kinds of error markers you are describing.


  18. @dgh

    > I want push button like on sourceforge, and get zip file with js programm.

    If you want to do that you can go to:

    https://github.com/scripted-editor/scripted/downloads

    and press 'Download as zip' or 'Download as tar.gz'

    Here is a direct link to the zip button:

    https://github.com/scripted-editor/scripted/zipball/master


  19. @Andrew
    Thanks for the suggestion. Will this fix content assist as well for the variables defined elsewhere. Sorry I am away from my dev box or else would have tested it myself.


  20. @atin,

    Yes, using /*global */ will make these variables available in content assist as well, but the inferencer will not be able to determine their type or their properties. We are working on tracking down global dependencies in order to get this working, but this feature is not yet implemented.


  21. Thanks @Andrew, appreciate the help.


  22. Just added some comments on my use of Scripted to create a mobile site at : http://diniscruz.blogspot.co.uk/2012/10/using-scripted-js-editor-from-vmware-to.html

    Thanks again for publishing this


  23. Perhaps a dumb question, but…

    I'm trying to set font_size in Scripted on *Windows.* No '.scripted' file, just 'scripted,' but putting, say, font_size:14 in this file doesn't seem to work. Any advice?

    Thanks very much!


  24. @k dev,

    The file needs to be called '.scripted' (with the .) in order for it to be considered a preferences file.


  25. @aclement -

    It looks like node is on the horizon for Brackets (I believe a port already exists). Brackets itself is JS end-to-end, but it has a CEF shell for local install, though I've seen a lot of postings about moving it to node-webkit. I believe the community has already included JSLint/Hint support. So, I'm not really seeing many differences other than CodeMirror2/3 vs Orion.

    I'm interested in hearing more detail regarding the reason for focusing first on CommonJS. It's purely my opinion, but I don't see why CommonJS would be a top priority, especially with V8 implementing more and more of ES6 every day. It seems like it's still emerging to me. Again, just an opinion.

    Personally, I'd rather see more emphasis on making plugin creation simpler for the masses. I believe there is a sizable community of JS developers who would contribute plugins if it were easy enough to get the basics completed.

    Just my 2 cents.


  26. @corey

    perhaps I didn't sell the focus quite right in that first comment. We are attempting to build great content assist/navigation – and feeding into the inferencing engine that enables that is knowledge of the module system being used (whatever that is). AMD/CommonJS were first because we hit those on our client and server code and we felt they would also benefit many other developers in the same situation. Whatever the next module system is that needs us to understand it, we can quickly code up support for it and plug it into the inferencer.

    Re: plugins

    Yes, I agree. Hopefully we can get something defined here soon.


  27. @aclement

    I see, that makes more sense to me now. Thanks for clarifying!


  28. Can you please show how to configure the .scripted file to customize the tab size?

    Thanks.


  29. Hi Glen,

    Until recently that kind of configuration was only possible for the formatter. But with the fix for https://issuetracker.springsource.com/browse/SCRIPTED-158 you can now configure whether spaces or tabs are used and the size, you will just need to download something newer than the 0.2 release. You can always grab a copy of master from here: https://github.com/scripted-editor/scripted/archive/master.zip

    The issue I referenced also describes what to put into the .scripted file to configure it.

    cheers,
    Andy


  30. super! like cloud9 ide?


  31. I've been fiddling with this for over an hour, still can't get anything more than "Internet Explorer cannot display the webpage". I've poured over the instructions, google forum, and these comments…. Nothing works.

    Uninstalling…

    Let me know when you get this working.


  32. @Colyn,

    Sorry you've had some difficulties with Scripted. Internet Explorer does not support Scripted. Our primary supported browsers are Firefox and Chrome.


  33. internet explorer is absolutely the worst for rendering. im not surprised about the difficulties, unfortunately..


  34. This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. Sense helpful ;)


  35. how could so many people be wrong without anyone telling them for so long? I believe that the whole thing was made up, but then again i'm no specialist…

11 trackbacks

Leave a Reply