Well presented. I clicked the link and spent my loading-spinner time thinking thoughts along the lines of "This is silly. Why would anybody build a C# IDE to compete with VS.NET + ReSharper? Surely nobody would ever use anything but that??? I can't believe that anybody would be cheap enough to..."
... 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.
To be fair, the SharpDevelop people did just that and it's actually quite good. Of course it doesn't measure up to VS.Net but if VS.Net didn't exist it would be really impressive.
But I read it as CSS hell. Maybe SharpShell? Anyways, both are better than the original IMHO.
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 =)
Nice to see another entrant in this space, offering functionality beyond LINQPad⁰ and the old SnippetCompiler¹. Microsoft has experimented with a REPL of their own² but there's nothing official yet.
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.
The sweet spot between a more full featured IDE like VS, LINQPad, or SharpDevelop and a REPL environment has not been explored very much so far. Even ScriptCS is more of one-off execution kind of setup, although they do have a REPL.
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.
A combined REPL and editor for C# looks useful. I will try it next time I have some spare time.
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.
These tools straddle some Venn circles, so the developer pitch can be confusing.
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.
Not very often you find a hedge fund behind an open source project. I guess it makes sense really, as many quants will be happy to mess around in a python shell, having a C# shell will probably play nicer with the rest of the companies infrastructure.
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.
wow, didn't know that. thanks for putting together that list - maybe we should start a list somewhere where people can add, this is definitely super interesting.
Scriptcs is out there for quite some time now. http://scriptcs.net/ it also has the motto "Unleash your C# from Visual Studio."
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.
The point of scripting is to do things quickly at the expense of possibly being ugly. Most of the things we do in the UNIX shell are one-off local stuff. I want to rename all file extensions in a directory. I want to find a regex in files ending with .c and .h excluding the .svn and .git directories. Etc etc.
So I'm sorry but a "scripting" language whose print operator is longer than 5 chars is not a scripting language :)
hey, I'm the developer of CShell, nice for this project to get some love. I'm aware of some of the shortcomings. Will definitely read you guy's comments and see what I can do.
First of all, let me say this is something I've wanted for a while, so good job and thank you to the author.
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?
I'm getting "(35,0): error CS1525: Unexpected symbol `static'" trying to run Tutorial.csx (when MyMath is uncommented), whether running the entire script or just the class and the MyMath.Fibonacci call alone, by Run Selection (then it's "Unexpected symbol `MyMath'").
public static class Foo
{
public static string B;
}
Foo.B = "5";
After fiddling around for a short while I got an index out of range exception and it crashed. It seems like a good idea, but the execution is not that powerful yet. Not stable, so I'll pass for the time being.
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)
the thing is you can't really mix class definitions and straight scripting lines in one execution. So what you need to do, is execute the class first and then execute the other part.
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
>
I mean this as truly constructive criticism. There are several spelling errors on the site that made me want to cringe.
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.
This is exactly what i need to test out if some code behaves how i want it to, without having to create a new test, open a new project or running code in actual project.
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.
Wouldn't that more or less be the Immediate Window that Visual Studio already has? Other than the multiple lines you mention. :)
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.
I highly recommend buying a LINQPad licence. I use it several times a day now and it's so much better with the extra features.
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.
If your language has you type more because it has a static ype system then it's just poor at inferring types and/or it's syntax has you write out things that it could infer anyway. You may have to write types in C# from time to time, but often you don't have to:
// 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.
They are doing a hack for top-level functions - they're adding "using" for static classes so you can pull all the static methods of a class into the local namespace. Don't see how that would help for dictionaries, though.
The ugly part of the dictionary is the type parameters, but I can't see a workaround for that without some really hard type-inferencing for all generics. I mean, you'd have to infer the type-parameters of a generic class based on the type-parameter of the IEnumerable passed into its constructor (dictionary takes an IEnumerable of KeyValuePairs of TKey, TValue). That's a little messy.
The tuples should get a type inferred, then the array, then that can pass the type to createdict and all good. And the array could be removed if there was some other sort of list-like literal. This might be really difficult to implement in the C# compiler, for all I know.
More likely, they'll graft in yet another special rule in the compiler (not accessible to user code!), just as they did with other collections, foreach, async, etc. I find it ugly that the compiler is happy to use static duck typing when convenient, but such a feature isn't exposed in the language.
Unexpected conversions can add bugs. Putting a string into a table that was implicitely integer - if your string doesn't start with digits it gets converted to zero. Was that what you intended? Did you think the table would hold a string?
Type inference in C# with the var keyword doesn't work like a dynamic language like javascript. It works by simply using var as a placeholder for whatever type the right hand side returns, which is determined at compile time.
So the type depends upon the initial values, which might not be representative of your full intent? A list of strings doesn't guarantee you won't want later to put something else in there.
I guess you'd just have to declare it explicitly in that case.
But you could explicitly declare the string table and still try to put an integer into it. Your example isn't an issue of type inference, it's an issue with the developer not properly tracking what variables store what types in his/her own code.
Yep, like if you wanted to put a list behind an IEnumerable interface or something like that, instead of an actual list. It's just a very useful shortcut for the thing you want to do 90% of the time.
The only built-in implicit conversions in C# are for numerics, and there isn't a loss in precision for those (with the exception of int/uint/long/ulong -> float and long/ulong -> double, where there is a loss of precision).
It depends. I mostly use PowerShell when trying out things with .NET, sometimes before or while I'm implementing them in C# as well. But depending on what I want to do, LINQ is a very nice thing to have, even though PowerShell has similar capabilities with the pipeline. (Can't really point to anything specific right now – there are instances when I prefer PowerShell and those where I prefer LINQ.)
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.
... 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!