8 ms·
CShell: A simple, yet powerful, C# scripting IDE
- NicoJuicy 13y agoI should look into it, but it seems to support multiple lines. So the ideal use case would be to add a seperate window into Visual Studio
- cyphax 13y agoWouldn'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. This seems like a useful tool!
- sitharus 13y agoThe immediate window is fairly limited. It can't evaluate lambdas for example, so you can't quickly write linq. Possibly more like linqpad?
- rikkus 13y agoI 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.
- bjoerns 13y agothis is pretty cool, thanks for sharing! will see if I can integrate this with Excel-DNA.
- V-2 13y agoWhat "I/O error occurred"? I mean the IntelliSense hint on the screenshot.
- mattmanser 13y agoLooks to me like the description of `System.IO.IOException`, which is the possible exception. 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!
- V-2 13y agoGood point, I might go ahead and make a patch.
- billpg 13y agoThat's what an IOException means. I suspect the hint text stems from a very minimal XML parse of the documentation.
- iamsalman 13y agoThis may be useful for loading GBs of data and it's quick exploration but I am wondering if there are any other uses for it besides that?
- rtpg 13y agowell it's as useful as any other REPL ;) 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.
- QuadDamaged 13y agoA C# REPL is welcome indeed, but C# is still too verbose for its own good. The F# REPL is much more useful when exploring dataset.
- pjmlp 13y agoAlthough it could be improved with intellisense.
- ahy1 13y agoA 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 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.
- deleted 13y ago[deleted]
- fish2000 13y agoThese 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.
- jasonkester 13y agoWell 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. Well done!
- codexon 13y agoThe title would have been better if it said C# REPL. Then you wouldn't have experienced that confusion.
- Pxtl 13y agoTo 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.
- NKCSS 13y agoVery cool and useful, thanks!
- xiaq 13y agoMono has had a C# repl for quite some time: http://www.mono-project.com/CsharpRepl http://www.mono-project.com/CsharpRepl Good to see the same thing coming to vanilla .Net!
- xedarius 13y agoNot 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.
- deleted 13y ago[deleted]
- jimmcslim 13y agoThere are a few hedge funds that are quite happy to contribute open-source to the world. Blue Mountain Capital for example; https://github.com/BlueMountainCapital 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/ 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 ;-)
- bjoerns 13y agowow, 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.
- echion 13y agoAgreed - here's another one (I am not affiliated): https://github.com/renshawbay/ https://github.com/renshawbay/
- deleted 13y ago[deleted]
- Systemic33 13y agoThis 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.
- bruceboughton 13y agoI've just started using scriptcs (http://scriptcs.net/ http://scriptcs.net/) and this looks pretty similar. I'm not sure about the name. CShell implies C not C#.
- CmonDev 13y agoSeems dead - last commit ~1 year ago?
- mariusmg 13y agoAs much as i like C#, static typed languages are inadequate when using them in shell. You really don't want to type all that. Powershell has access to the BCL and can do all that with a nicer syntax when using it in the shell.
- ygra 13y agoIt 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.
- TheAnimus 13y ago>static typed languages are inadequate when using them in shell. You really don't want to type all that I'm not sure I understand, what is wrong with dynamic in C#? You've got the anonymous types for quick data structures.
- deleted 13y ago[deleted]
- zeugmasyllepsis 13y agoScala, OCaml/F#, and Haskell beg to differ.
- aroberge 13y agoDid you even look at the link? It is about a REPL for C#.
- alkonaut 13y agoIf 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.
- blunte 13y agoI guess I'm old. My first thought was http://en.wikipedia.org/wiki/C_shell http://en.wikipedia.org/wiki/C_shell
- jjoergensen 13y agoIt probably should have been named CSShell :-)
- egeozcan 13y agoBut 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 =)
- Pxtl 13y agoSharpShell would be a great name - fun alliteration and pretty clear what it's for.
- lukebuehler 13y agoI like it, will consider it. The naming is a bit unhappy, I agree.
- maw 13y agoAnd considered it harmful.
- dllthomas 13y agoI must be old, too.
- rjfwhite 13y agoUnity3D port anybody?
- dukeNukem64 13y agoSimilar: https://github.com/drew-r/maverick https://github.com/drew-r/maverick 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.
- stinos 13y agoAlso see http://www.hanselman.com/blog/ProjectlessScriptedCWithScriptCSAndRoslyn.aspx http://www.hanselman.com/blog/ProjectlessScriptedCWithScript... - no REPL though, although that would be easy to create since there's a SrciptingEngine for C# (http://blogs.msdn.com/b/csharpfaq/archive/2011/12/02/introduction-to-the-roslyn-scripting-api.aspx http://blogs.msdn.com/b/csharpfaq/archive/2011/12/02/introdu...)
- jimueller 13y agoScriptCS does have REPL. Maybe it didn't at the time of that article. http://scriptcs.net/ http://scriptcs.net/
- mojuba 13y agoThe 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 :)
- hrjet 13y agoAlso, I like Scala REPL's automatic labels for the results. scala > 7 * 7 res0:Int = 49 scala > res0 - 9 res1:Int = 40 Saves a lot of typing.
- egeozcan 13y agoAction<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.
- cadab 13y agoI want this, but with nuget support. LinqPad seems about the best option, but i don't need all the SQL/Database stuff that comes with it.
- guiomie 13y agoFirst 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?
- V-2 13y agoSame here. No idea. If there were any docs (other than the "tutorial" itself) I'd try to look it up :))
- lukebuehler 13y agoYep, I see the tutorial is not clear, will change it. 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);
- V-2 13y agoI'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"; doesn't work either ("Unexpected symbol `Foo'"). I really don't get how to use that thing.
- V-2 13y agoAfter 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)
- ahmett 13y agoScriptcs is out there for quite some time now. http://scriptcs.net/ 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.
- S_A_P 13y agoI 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.
- j_s 13y agoNice 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. ⁰ https://www.linqpad.net/CodeSnippetIDE.aspx https://www.linqpad.net/CodeSnippetIDE.aspx ¹ http://www.sliver.com/dotnet/SnippetCompiler/ http://www.sliver.com/dotnet/SnippetCompiler/ ² http://stackoverflow.com/questions/1187423/anders-hejlsbergs-c-sharp-4-0-repl http://stackoverflow.com/questions/1187423/anders-hejlsbergs... ³ http://tirania.org/blog/archive/2008/Sep-08.html http://tirania.org/blog/archive/2008/Sep-08.html ⁴ http://www.csscript.net/index.html http://www.csscript.net/index.html ⁵ https://github.com/scriptcs/scriptcs https://github.com/scriptcs/scriptcs
- lukebuehler 13y agoThe 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.
- ufmace 13y agoJust tried it out, and it looks pretty awesome - I always wanted a real REPL for C#.
- lukebuehler 13y agohey, 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.
- uggedal 13y agoWhy don't people do a quick search before naming things: http://en.m.wikipedia.org/wiki/C_shell http://en.m.wikipedia.org/wiki/C_shell
- thwarted 13y agoMaybe it really means "C Sharp Hell".
- Pxtl 13y ago... you know that whole PowerShell thing MS made? They should've just skipped that and made this. Hot damn, neat!