... and then I arrived at a page that spent ten seconds clearly explaining exactly why I would want to use this thing even though I have VS.NET already installed on my machine.
A lot of open source & developer-facing small product sites in the world would be well served to read the contents of this page and study exactly what the author did there.
Well done!
By the way, this is really useful. Loaded all our app libraries and works like a charm. I feel much more productive now except for the fact that it made me comment on HN =)
Mono's REPL³ (MIT X11/GNU GPL; 2008) still has some rough edges on Windows. CS-Script⁴ (MIT; 2009) seems to have received the widest use but was hampered by a weird license until recently. Microsoft MVPs have stepped into the ring with scriptcs⁵ (Apache; 2013) based on the brand new Roslyn tech.
⁰ https://www.linqpad.net/CodeSnippetIDE.aspx
¹ http://www.sliver.com/dotnet/SnippetCompiler/
² http://stackoverflow.com/questions/1187423/anders-hejlsbergs...
³ http://tirania.org/blog/archive/2008/Sep-08.html
Filling this gap is what I tried to achieve with CShell. When I started, the Mono REPL was quite a bit ahead of Roslyn still, but now Roslyn overtook it. I'm planning to switch to Roslyn for the execution engine and use NRefactory for the code completion still (especially now that Roslyn is open source).
Where I want CShell to go, is it being a light-weight IDE with a focus on iterative execution. I use LINQPad evey day for DB stuff for example, but when I want to write progressing code, usually exploring some kind of data space - where I test each line, plot some charts, look at the data the variables contain - then there's no real competitor so far for C#. Either you have Matlab, R one one side, or linear code execution environments on the other.
The name is confusing. A C shell already exists (http://en.wikipedia.org/wiki/C_shell). An alternative name could be CSharpShell. Btw, while googling that name, I found CsharpRepl, which seems to be a somewhat similar tool.
For example, I make use of both ipython and bpython, both of which I refer to as either shells or REPLs; though neither program is a proper shell (in the /bin/chsh sense), and though people also call them “interpreters” (technically, the python interpreter still interprets), “environments” (vague) or even “IDEs” (wat?) – the concept behind the tools is popular and well-understood.
Personally I think it’s particularly funny to call these Enhanced REPL Shell Interpreter Environments (or what have you) “IDEs” and lump them in with Eclipse or Visual Studio or those other behemoth coding tools; I like bpython and ipython for the myriad ways they are un-Eclipse-y, and if I did C# I would presumably get into CSharp for the same reasons. All of which, like many bicycle-shed innovations, are mere matters of taste.
Blue Mountain Capital for example;
https://github.com/BlueMountainCapital
One of their projects is Deedle; an F#/C#-equivalent of the Python 'Pandas' data frame package. Which would in fact make a nice complement to CShell I imagine.
Jane Street would be another choice: http://janestreet.github.io/
Their work on OCaml is currently trending on HN.
There are others I am sure, don't have any links handy.
Who'd a thunk it, hedge funds occasionally produce some social good ;-)
It provides you proper scripting abilities by using other libraries, writing classes in the REPL and scripting, like proper scripting languages. CShell just seemed like a windowed application whereas Scriptcs also runs on Unix environment with Mono I guess.
So I'm sorry but a "scripting" language whose print operator is longer than 5 chars is not a scripting language :)
Action<object> print = Console.WriteLine;
I mean, it's not perfect but you can also create a .Dump() extension method for all objects like Linqpad does. It comes really handy. scala > 7 * 7
res0:Int = 49
scala > res0 - 9
res1:Int = 40
Saves a lot of typing.Provides a Lua REPL with access to the .NET framework. Also allows you to run mini-apps made up of a combination of C# 'scripts' and Lua scripts.
When I try the Tutorial.csx, I can't get this snippet to work:
static class MyMath { public static long Fibonacci(long n) { //anything more than 48 will result in a stack overflow. if (n >= 48) throw new ArgumentException("Enter a number less than 48"); if (n == 0) return 0; if (n == 1) return 1; return Fibonacci(n - 1) + Fibonacci(n - 2); } }
// Now the method can be called like so: MyMath.Fibonacci(12);
It gives me : "(14,0): error CS1525: Unexpected symbol `MyMath'" in the repl, anyone knows why?
Anyhow what you need to do is simply select line 35-45 with your cursor, then press Alt+Enter.
And then, after that, execute MyMath.Fibonacci(12);
I'm not sure about the name. CShell implies C not C#.
public static class Foo { public static string B; } Foo.B = "5";
doesn't work either ("Unexpected symbol `Foo'").
I really don't get how to use that thing.
Error 2014-05-09 15:42:45.8796 AppBootstrapper Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at CShell.Modules.Repl.Controls.CSRepl.ShowPreviousCommand() in c:\Users\luke\Dev\GitHub\CShell\Src\CShell\Modules\Repl\Controls\CSRepl.xaml.cs:line 241 at CShell.Modules.Repl.Controls.CSRepl.TextAreaOnPreviewKeyDown(Object sender, KeyEventArgs keyEventArgs) in c:\Users\luke\Dev\GitHub\CShell\Src\CShell\Modules\Repl\Controls\CSRepl.xaml.cs:line 377 at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey) at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers) at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
For the MyMath example you'd just select the lines for that class, press Alt+Enter. And then run: > MyMath.Fibonacci(12);
With your example, you would enter following in the REPL: > public static class Foo { public static string B; } > Foo.B = "hi" > Foo.B hi >
It allows you to use C# without any fluff right in a console like environment caled a read-eval-print-loop (REPL).
CShell is a project sponsored and maintained by Arnova Asset Management Ltd., a quant hege fund, which uses CShell daily for their research. The main contributor from Arnova is @lukebuehler.
That said I like this idea and look forward to trying it.
Good to see the same thing coming to vanilla .Net!
Though for things like Python the REPL serves for me mainly as a 'figure out what type this thing is here' and 'does this work'... things that static typing solve pretty well.
I took a look at this to see if it can replace LinqPad, which is similar. LinqPad allows for more than C# alone (VB.net, SQL, C# and F#) but it has no code completion (unless you buy it) which CShell does have.
This seems like a useful tool!
My favourite feature is the ability to point it at a DLL which has an entity data model in it - and then work with that model 'live' as if you were inside app code.
Normally, to do that, you'd have to put a breakpoint in your app and use VS's Immediate window - which doesn't support useful stuff like lambdas.
Possibly more like linqpad?
They should've just skipped that and made this. Hot damn, neat!
I would guess the tool tips are slightly broken in that it doesn't list the exception class name or put it on a new line.
There you go, simple thing to contribute a fix for!
Powershell has access to the BCL and can do all that with a nicer syntax when using it in the shell.
// This an array of integers.
var x = new[]{1, 2, 3};
// This is a list of integers.
var y = x.ToList();
// This is an anonymous type.
var pet = new { Age = 10, Name = "Fluffy" };
Zero type names there. Not all types can be inferred by literals though, most annoyingly dictionaries:
var myDict = new Dictionary<string, string>{ { "test", "test" }, { "test2", "test2" } };
although I'm sure that could also have been created without typing out the name if you really wanted.
One major reason might be speed, though. PowerShell can be very slow on large-ish data sets. And var in C# saves you from a lot of type-typing.
I'm not sure I understand, what is wrong with dynamic in C#? You've got the anonymous types for quick data structures.