Monday, 6 August 2012

How does O2 compare with LinqPAD

(just got this question on this reddit thread, and here is my answer) 

There are a number of similarities, specially in the capability of quickly running C# scripts. Most of the differences come from the fact that they have are different approaches and development histories. LinqPAD (I think) was developed to help improving the execution and visualization of LINQ Queries, where the O2 Platform (and its REPL environment) was created to help to script application security analysis, and eventually O2 evolved into a full scripting and application development environment.
I can't really talk for LinqPAD (since I'm not part of it development team), but here is where I think O2 Platform provides extra value:
  • O2 tries to integrate with as many tools as possible, in fact you can consume LinqPAD from O2:
  • O2 is Open Source and has AutoCompletion support (which LinqPAD has on the paid-for-version)
  • O2's scripts are designed to create mini-tools. I.e. the idea is that once you finished a script you package it as a stand-alone script (with *.h2 extension) or an .exe. In fact the O2 Platform, is basically a collection of tools, GUIs, technology, and APIs developed using this C# REPL environment. For example the main O2 REPL environment exposes a WinForm's Panel Control which is 'feed' to the script so that it can be used while developing a GUI (with 1 line change to use Form Control and make it a stand-alone tool))
  • One core idea of the O2 REPL environment is that it should be used everywhere, since it provides real time feedback/coding-loop while developing or testing new ideas. For example I have already used it for:
  • The REPL environment can also be used to expose (or debug) objects on applications being developed. There is an 'Script_Me(...)' extension method that open up a new WinForms window with the 1st parameter (the 'this' value) being 'feed' to the REPL environment.
  • In fact I develop O2 in O2 :) , and I frankly find VisualStudio really painful to use (and slow). Although now that there is an O2 VisualStudio Extension that allows the REPL of VisualStudio itself, this might improve. You can download it from : O2 Platform for VisualStudio 2010
    • .... I really like the concept of '...the IDE is the Application...' where you also have real time REPL environments in IDEs or tools that provide rich funcionality
  • Using this REPL environment I also developed this pretty cool PoC Real-Time Vulnerability Feedback in VisualStudio which is closer to how I think we need to provide security information to developers (when compared with what we do now which is an out-of-band process)
  • Included in the O2's REPL environment is an Fluent API, which Is called Fluent# and is available at CodePlexor NUGet (note that these are a bit out of date with the current distribution of O2). This API really makes the O2's REPL environment powerful since you can execute quite complex tasks with only a few lines of code (its still C# , but there is extended use of C# Extension Methods to reduce the amount of code needed). You will see the Fluent# APIs in action, on most (if not all) O2 scripts.
    • Of Fluent# APIs and Extension Methods, I would stand out the Reflection and the WinForms APIs. The reflection one will give you easy access to any .Net assembly, class, method, property, field, enum (on disk or in memory) regardless of its public/private/internal status. The WinForms one will give you a thread-safe (very important feature) way to create and manipulate WinForm controls (if you look at the code behind most O2 scripts (including the C# REPL environment) you will see this API in action
  • Another powerful capability that you get from the O2 REPL environment is that the return value is viewed in a PropertyGrid which allows for a very organic growth of the script under development (although this might be a case of the workflow I use with O2 since LinqPAD result window is also quite mature and powerful)
  • A very powerful capability of O2's REPL environment which is hard to understand until experienced, is its data consumption and analysis capabilities. Due to .Net's powerful serialization and XML support, it is possible to script (and visualize) multiple data-transformations (with all steps stored as .NET Serialized objects)
  • There are many more features that exist in O2's and its REPL environment, and the best way for me to help you is if you have a particular problem that you are trying to so solve, please post the details here and I'll point you to the right direction (or to an existing script)
I would like to stress that that I don't view O2 as a competitor / replacement for LinqPAD!
If anything I want to make LinqPAD better and be able to integrate it's capabilities with other tools. My objective with O2 is not to invent all wheels, but to use the best possible technology to solve the problem at hand.
For example here is what I think LinqPAD does better: * it is more focused and mature * there is a better GUI to provide examples (we're trying to create a similar cook-book style for O2) * the tabbed interface for scripts allows for multiple script development in the same GUI * the GUI looks better, is more complete and shows its age (in a good way) * there are a couple more scripting options * built-in visualizers for LINQ queries * better help and support website
Finally, since the O2 Platform and its C# REPL environment are Open Source (https://github.com/o2platform), if you have some cycles we could do with some help :)