Last week the .NET Twitterverse erupted when a developer from Harrisburg, PA named Justin Rusbatch released Compilify. Compilify is a simple web-based utility that allows you to write C# and then run it from your web browser. Justin deployed the site on AppHarbor so we reached out to him to learn more about it.
Tell us a little bit about Compilify...
JR: Compilify (pronounced “compile-ify”) is site for people can experiment with, collaborate on, and share C# code. Any errors will be displayed as you type and with the click of a button you can compile and execute your code. Each snippet can be saved and shared with others via a unique URL.
Compilify makes the .NET compiler completely portable and accessible through a fast, simple interface that fosters sharing and collaboration. It’s not an IDE in your browser, nor will it ever be. It’s simpler than that. You shouldn’t need to launch an IDE or create a new console project to experiment with a new idea that only takes a few lines of code. A developer’s time is incredibly valuable. Spending too much time thinking about a problem without actually trying solutions results in over-engineered solutions and -- if left untreated -- can lead to analysis paralysis.
Compilify is the tool you will reach for when you don’t have time to deal with a full IDE!
It also has a lot of potential as an educational tool for people who don’t know C# but want to try it. Downloading, installing, and launching Visual Studio can intimidate new developers. Some developers might not install Visual Studio because of all the other applications that it install with it. Compilify lets users get their hands dirty without needing to install anything. Not even a browser plugin.
As I was watching the tweets about Compilify on Thursday, there was one in particular that jumped out and grabbed my attention:
“just wrote and compiled C# from my droid!” -- @SpoonTheGreater
I’ll pause for a moment so you can reflect on how incredibly awesome that is.
Have you calmed down a little bit? Good, prepare to get excited again. Compilify lets you write, compile, and execute C#, quickly and easily, from any platform with a web browser without installing anything!
What inspired you to build Compilify?
JR: Compilify was inspired by many things. One of the primary sources of inspiration was the C# Interactive window that the Roslyn CTP brings to Visual Studio. This window provides a REPL environment that can be used to execute statements against the projects they’re developing and receive immediate results. The driving goal behind Compilify is to bring that same interactive environment to the web.
What technologies are you using?
JR: The website itself is an ASP.NET MVC4 project.
When I started the project, I decided to use Redis for queueing code execution and messaging between the web application and the workers. Initially I was going to use it as the primary data store for the application, but after a few days I decided to switch to another NoSQL solution that would be supplemented by Redis. I decided to go with MongoDB for this because of its availability as an add-on service through AppHarbor.
SignalR is currently being used as a message relay. After a worker finishes executing a user’s code, the result is published to a Redis pub/sub channel that the web application is subscribed to. SignalR is then used to "push" that result to the client that originally sent the code. I have plans to implement features that make more use of SignalR in the future.
Which tools or frameworks did you like most?
JR: Booksleeve, the Redis client I chose. Up-to-date documentation was a little sparse, but the API was straightforward once I figured out the basics. I love simple and straightforward libraries.
What was something unexpected you learned while building it?
JR: The whole project was an awesome learning experience. I’ve been excited to play with Roslyn since I attended a session on the future of C# and VB by Anders Hejlsberg at Build conference last September. But, until Compilify, I didn’t have a good use case for it aside from the tutorials that come with it.
Protecting myself from the code submitted by users was the most challenging part of the project. Developers are extremely clever and creative, so offering to execute their code for them is a little risky. A majority of my time working on the site was spent making the site as secure and stable as I could, without making the users feel like they didn’t have enough permissions for the site to be useful. I think I’ve reached a good balance at this point. A huge resource for me while working on securing the application was a blog post by Filip Ekberg describing his efforts at building an IRC bot based on Roslyn.
It’s my understanding that the Roslyn team is working to make this easier in future releases.
What advice would you give to other developers running their apps on AppHarbor?
JR: Take advantage of the add-ons. There are a lot of great tools available as add-ons for little or no cost that can be integrated seamlessly through AppHarbor.
What are your plans for Compilify in the future?
JR: I’m really excited about Compilify’s future. There’s still a lot of unrealized potential for Roslyn My to-do list includes (in no particular order):
- Allow class declarations (this might even be implemented by the time this is posted).
- Provide the ability to import/export snippets to/from other popular pastebins.
- Provide more details about errors in the code, without being distracting.
- Add more features to facilitate collaboration, including the ability for multiple users to edit the same snippet simultaneously.
- Results as you type, like validation errors are displayed now.
- Possibly add support VB and F#. Maybe. Frankly, I’m always writing in C#, so it really depends on how many users want support for the other languages.
I’m also eager to hear suggestions from users. This is an open source project, so feel free to submit enhancements via the issues list or pull requests!
Where can people contribute to the project?
JR: The source code for Compilify.net is available on GitHub under the MIT license.
Where can people find you on the internet?
JR: I’m on Twitter and GitHub