41 ms·
Given that our deployment platform was Linux (for a .Net Core 3.0 project), I was determined to use Linux and VS Code for development. That was a fail; the verb
by jeswin 7y ago
Given that our deployment platform was Linux (for a .Net Core 3.0 project), I was determined to use Linux and VS Code for development. That was a fail; the verbose nature of C# and the Framework APIs make it impossible to be productive without significant help from a full-fledged IDE like Visual Studio. One might think the verbosity can be reduced by clever coding (and adopting a functional style), but that's not so easy. If you're writing a Web App/Service, the Framework APIs and most popular libraries will nudge you strongly to use Dependency Injection throughout the app and implement everything as a class and to extract interfaces out of it.
My wishlist for C# is short:
- Allow functions outside of classes
- Structural typing
- Files and directories already provide excellent namespacing. Adopt it instead of forcing namespace declarations
Btw, Linux as a deployment platform works quite well.
- denisw 7y agoIf you install the VS Code's C# extension, you should be getting autocomplete and quick fixes such as adding impport statements automatically. https://code.visualstudio.com/docs/languages/csharp https://code.visualstudio.com/docs/languages/csharp
- james_s_tayler 7y agoIt's still nowhere near the same level of experience that Rider or VS offer.
- rraghur 7y agoI use VSCode with C# extension. THe only thing I missed was the additional analysis and quick fixes that full VS provides. However, that got sorted out by installing Roslynator in VS Code (works on linux too) and I couldn't be happier.
- wayneftw 7y agoThank goodness that VSCode is a different experience! VS and Rider are a pain in the ass to setup and maintain and VSCode provides the essential UX better than just about anything else at this time. I can have VSCode installed and running with my personal settings on any OS within 2 minutes flat. I don't have to find a secret license key, login with any account, or pick through a list of 100 features in the installer. Then, once it's installed, well VSCode is just a better experience for the basic act of editing source code. Multiple cursors, quickly opening files by typing the name (without having to type a greater than sign followed by a space first every time like you do in VS), sane default keyboard shortcuts for managing/splitting documents and so on... Plus, it's got way better facilities for working with front-end web code than VS ever had and some other major features such as remote editing oh and one other little thing: it's fully cross-platform. And that's the reason for VSCodes wild success. Let's hope Microsoft never fucks it up by trying to glom the rest of their Azure/Microsoft Account crap onto it too much. Luckily, I don't have to work on anything that needs a designer anymore, like WinForms, but if I did I would certainly install VS. Even then - I think I'd only use VS for the designer and go back to VSCode for everything else. (And I love Windows and I used to love VS, having used both of them for 30 years and 15 years respectively.) But the VSCode team also covered a lot of ground faster than VS ever did, adding feature after feature. So, what do you want for C#? I'm certain that we'll be getting it soon.
- apk-d 7y agoI've been using VSCode for C# daily for a year or two. I'm considering switching to a non-electron editor because of how slow and sluggish it is, including IntelliSense, refactoring, syntax highlighting and the latency and frame rate of actual rendering (huge drain on the battery if you have one). The editor doesn't (seem to) support language-integrated syntax highlighting, so no ambiguous language features get recognized and there's plenty of bugs (such as with around the C#7 ValueTuple syntax feature). The C# extension tends to freeze a couple of times a day. One feature that excels out of nowhere is the search functionality which greps entire folders almost instantly, probably because the functionality is delegated to a separate (native, I presume) process. JSON-with-schema-based configuration is something more software should have. The editor also starts pretty fast but most features are delegated to extensions which load (ultra)lazily and aren't usable for a few (5-30) seconds.
- com2kid 7y ago> Luckily, I don't have to work on anything that needs a designer anymore, like WinForms, but if I did I would certainly install VS. Even then - I think I'd only use VS for the designer and go back to VSCode for everything else. (And I love Windows and I used to love VS, having used both of them for 30 years and 15 years respectively.) The WinForms designer is wonderful. I can throw up an ugly CRUD app that works so insanely fast with it. The web-equivalents are horrible. Everyone is trying to make a rich web app to write rich web apps and IMHO they are all targeting way too low on the "technical ability" scale for their users. Though web is harder, since apps need to be responsive, and cross plat, and automating code gen of CSS that does that cannot be easy, and having a form designer UI expose settings for how a UI resizes itself doesn't sound like a UX challenge I'd want to tackle.
- wokwokwok 7y agoOh no, don’t do that. The vscode integration is barely beyond autocomplete, and it uses more memory than rider does. The c# story for vscode still has a long way to go before it’s even close to feature parity. (...and yes, if you scrabble enough plugins you can get more features, but you get more crashes and even more memory slurping. :/)
- manigandham 7y agoWhat do you mean? The official C# support is from the Omnisharp plugin [1]. Omnisharp is the official .NET cross-platform development support system and is used across many different interfaces (VSCode, Atom, Sublime, etc). It's powered by Roslyn [2], the C# compiler platform, and can use the same packages for analyzers and autofixes that VS uses. It also has official debugging support. This is way beyond autocomplete. 1. https://github.com/OmniSharp/omnisharp-vscode https://github.com/OmniSharp/omnisharp-vscode 2. https://github.com/OmniSharp/omnisharp-roslyn https://github.com/OmniSharp/omnisharp-roslyn
- wokwokwok 7y agoI don’t know what to say; except, yes, and the experience on atom, sublime and the other tools that use omnisharp is terrible. It’s not unusable, but for example, I can’t refactor my code base without it crashing, and forget any advanced features like jump to symbol or extract class. The only feature that works reliably for me is autocomplete. I can only speak for personal experience; omnisharp on Windows and Mac, on .net core (or heaven forbid you use something non standard like unity3d) ... It’s just terrible. Perhaps your combination of platform / project is a different story, but I try it again every few months, and bluntly, rider is just better at everything. Visual studio on windows is also excellent, and the tooling is usually tighter (rider usually lags when new stuff like .net core 3 comes out, and the azure function integration is a bit spotty because it uses the core tools). /shrug Tldr; my experience, on multiple platforms on multiple projects has been simply negative every time I’ve used it. Ymmv.
- samuell 7y agoI can second that. Worked better on Xubuntu/VSCode than on Windows/VSCode even. Really smooth in fact, with intellisense/autocompletion and more just working. Then, I used it only on small CLI apps so far.
- pjmlp 7y agoI find the verbosity complain rather strange. Then again, I rather use maintainable programming languages, instead of writing hieroglyphs.
- mariusmg 7y ago>Btw, Linux as a deployment platform works quite well. What are you using in production for Linux ? Kestrel + Nginx ? Any problems encountered with this setup ?
- enlyth 7y agoI am using nginx as a reverse proxy to kestrel in production on one of my projects and it seems to be working great so far
- sword_smith 7y agoThis setup is also what Google Cloud is using for their App Engine.
- Topgamer7 7y agoYeah I do the same, lets me do seamless deploys. I spin up the new version, change the nginx config, then tear down the old one.
- manigandham 7y agoWe run Kestrel directly facing the internet serving http2 traffic across billions of requests per day with no issue. No need for Nginx.
- deskamess 7y agoWhich Linux distro are you going with? Any recommendations for/against distributions.
- manigandham 7y agoWe deploy our apps as containers on top of the standard dotnet images: https://hub.docker.com/_/microsoft-dotnet-core-aspnet/ https://hub.docker.com/_/microsoft-dotnet-core-aspnet/ The default uses debian but they have ubuntu and alpine variants too. We stick with the defaults and don't have any preference for distro.
- manigandham 7y agoAre you making interfaces for everything? Just register and use the class with constructor injection. All those layers of indirection just waste time. What would change with functions outside of classes? You already have anonymous functions/lambdas, static classes and extension methods if it's about instantiation overhead, and local (nested) functions. Can you explain a scenario where this doesn't work for you? For namespace declarations, you can just use the same namespace on all classes if you want to keep it simple, and that kind of flexibility isn't available if you use file structure.
- sword_smith 7y agoIt would seem to me that you wouldn't be able to mock all the classes if you followed this strategy.
- manigandham 7y agoWell do you really need to mock everything? And if so, how is that different than any other stack? Most of the time this is just "enterprise patterns" without any thought about whether it's worth it. I've seen too many small LOB apps that have 5 tiers of code for no reason.
- FpUser 7y agoI am seeing it all the time when consulting for companies. Their developers just love taking relatively small things and turning it into multilayered monster with insane amount of dependencies for code, development building pipelines and deployment.
- gnud 7y agoI see that too - but I also see plenty of completely un-testable code, because the controller constantly reads from AppSettings, or creates a new database connection directly, or similar issues. For small applications, instead of going full on DI, I sometimes just make a few simple public static properties, that I initialize on program startup. Then you can initialize them differently in your test harness. This is a lot easier to understand if you're not an expert in the chosen DI framework or app framework.
- tonyedgecombe 7y agoI keep coming back for a look every time there is a major release but it always seems quite cumbersome to me despite the fact I work in C# everyday. I ran through the Razor pages tutorial yesterday and I was surprised how heavy it all felt, I was expecting something like Flask or Sinatra. I'm a big fan of IDEs, I couldn't imagine using C# without one.
- thrower123 7y agoI've been quite happy using Nancy for the past several years. At the time we made the switch, it wasn't possible to use WebApi or MVC in a self-hosted OWIN web server, and our application had lifecycle constraints that made trying to run it out of IIS impractical. But I've come to really like the way Nancy has explicit API routes, compared to the implicit conventional style, or slapping attributes all over everything. You can avoid a lot of the magical action-at-a-distance middleware behavior that seems to be increasingly common as well.
- deleted 7y ago[deleted]
- codeulike 7y ago- Allow functions outside of classes What do you mean? Isn't that just anonymous functions?
- oblio 7y agoHe wants top level functions. He wants to not have to write classes if he thinks the domain doesn't need modelling as objects.
- arethuza 7y agoYou can have static classes that can contain nothing but static members - so effectively a namespace with no instantiation of that class allowed so no objects.
- oblio 7y agoI know, but many people dislike boilerplate code.
- manigandham 7y agoYou can use a static class though. It's 1 class that then just behaves like a namespace and doesn't need any object modeling.
- jmkni 7y agoYou could create an F# class library, put your functions in there, and then call them from C#?
- e12e 7y agoThey probably wants to not have to write classes if he thinks the domain doesn't need modelling as classes. Objects are just initialized memory with a vtable, or actors that sends and receives messages...
- surban 7y ago> My wishlist for C# is short: [...] F# provides all of them, is shipped with .Net Core 3.0 and also works great on Linux.
- tonyedgecombe 7y agoIt doesn't give you structural typing, it's still normative: https://stackoverflow.com/a/3137561/57094 https://stackoverflow.com/a/3137561/57094
- goto11 7y agoNominative, not normative. Nominative means "by name", i.e. you reference types by names. A structural type (aka anonymous type) does not have a name, so cannot be referenced.
- tonyedgecombe 7y agoYes, I meant nominative.
- mmavnn 7y agoIt also has syntax for structural typing where needed.
- nbevans 7y agohttps://www.infoq.com/news/2019/01/fsharp-4.6-preview/ https://www.infoq.com/news/2019/01/fsharp-4.6-preview/
- jeswin 7y agoWorks for personal projects and is certainly a joyful experience. But recruiting developers is near impossible - which is key for the kind of projects/companies I work with.
- FpUser 7y ago
- gtsteve 7y agoIf you'd like to develop on Linux, I suggest trying Jetbrains Rider. It's as good as VS in most cases, and better in several. I've used it as my primary IDE for most of this year.
- jmkni 7y ago+1 for Rider. It's basically ReSharper.
- pjmlp 7y agoIncluding resource usage! As anything on top of InteliJ.
- lultimouomo 7y agoJetBrains stuff does feel sluggish and occasionally hangs on my 2016 XPS-13 with 8G of ram. It gets the job done, but it's not pleasant. On my new Ryzen 3600 with 32G of ram it runs smooth. So if you go for JetBrains, I definitely advise not to cheap out on the hardware. Rider on Linux was very good for me, working on C# azure functions.
- pjmlp 7y ago32G?!? Where does one find such employers??? Not to mention how crazy it sounds having 32GB for an IDE. Visual Studio, Netbeans and Eclipse run perfectly fine with 8 GB.
- jmkni 7y agoIn my current role, I was given a laptop with 8GB. An additional 24GB mysteriously found it's way in there after a couple of days...
- simonh 7y agoI had a 32GB dev machine in my last job at a bank. 8GB is barely enough to run a full-on IDE, but if you also need to run wireshark, Geneos, outlook, big-ass excell sheets, several browsers with over a dozen tabs each, a bunch of communications tools, other office apps etc, etc, I'd regularly go above 20GB memory usage. I was working app support really, with a fair bit of dev work as well, so needed to run a ton of different tools.
- jayd16 7y agoThe closest you'll get to free floating functions are methods in a static class. The static classes essentially become namespaces. Then with static using directives, you don't need to spell out the namespaces. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-static https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... You can even put every global function into a single class but still organize your code across multiple files by making them all part of the same partial class. I personally wouldn't organize my code this way, but it seems like you can achieve what you want today with minimal effort.
- jeswin 7y ago> Then with static using directives, you don't need to spell out the namespaces. Static using directives! Certainly a useful tool, thank you. I had been away from the .Net universe for a while and I think I have some more catching up to do. Some of the newer changes in C# help a lot with reducing code heft, even though it makes the language more complex. However, the Framework seems to be headed in the opposite direction when it comes to simplicity. Here's for example the IOptions pattern: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options https://docs.microsoft.com/en-us/aspnet/core/fundamentals/co...
- thomasz 7y agoThe asp configuration thing is complicated but powerful. If you don't want that, you can just use ``Environment.GetEnvironmentVariable`` and be done with it.
- shhsshs 7y agoPlus it’s barely any extra work to load settings from environment variables. And it lets you write code agnostic to where the settings are coming from, and then choose to load them from environment variables, a file, hard coded values, etc. Makes testing easier too because you don’t have to write a fixture around your settings. Just build the class with known setting values without writing code purely for testing.
- 7y ago
- SideburnsOfDoom 7y ago> Allow functions outside of classes Why? You can put them in a static class, and if C# ever had this feature, it would just be syntactic sugar for a hidden static class. But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design. > Adopt (files and dirs) instead of forcing namespace declarations Likewise. > Structural typing Like "dynamic" in C# 4 ? Been there, done that and it didn't take off really. It's useful for some interop cases and that's about it. Strong types, with type inference is more suited to the language design. https://stackoverflow.com/questions/2690623/what-is-the-dynamic-type-in-c-sharp-4-0-used-for https://stackoverflow.com/questions/2690623/what-is-the-dyna... https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/types/using-type-dynamic https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
- pjc50 7y ago> But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design. That's what the Powershell integration is for.
- SideburnsOfDoom 7y ago> That's what the Powershell integration is for. And projects such as scriptcs and cake http://scriptcs.net/ http://scriptcs.net/ https://cakebuild.net/ https://cakebuild.net/
- jeswin 7y ago> But that would mean optimising for "hello world" and other small script scenarios, which isn't a goal of the language design. Fairly complex programs can be written with just plain functions, all of them elegantly starting off column 0 instead of being tabbed for namespaces and classes. It works especially well with directory structure based namespaces. eg: Microsoft's own TypeScript. > Like "dynamic" in C# 4 ? No not dynamic, I wouldn't use that very much either. https://en.wikipedia.org/wiki/Structural_type_system https://en.wikipedia.org/wiki/Structural_type_system
- Digit-Al 7y agoI don't believe you will ever get functions outside of classes in C#. It is antithetical to the entire ethos of the environment.
- gameswithgo 7y agoyou can just make a public static class FUNCTIONS and then use a static use at the top of each file, then pretend.
- rafaelvasco 7y agoThank god we won't. Functions outside classes never did make sense to me. People love to hate classes sometimes. For me, everything starts at classes and structs;
- gameswithgo 7y agoin C# you can make a static class, and then put functions in it. When you do this, the class is nothing more than a namespace. But the class is already in a namespace. So you now have a redundant namespace. It isn't a big deal but its a bit silly to have to do that, when writing static functions.
- rafaelvasco 7y agoYeah I agree. I really like static classes, but I've seen them being overused; As long as it doesn't causes performance problems I'm good with it. In fact calling static methods is faster;
- jopx 7y ago> Allow functions outside of classes Mads Torgersen did a proposal related to this, it's in the C# Version Planing as version X.X, so maybe in the future we're going to have those capabilities. https://github.com/dotnet/csharplang/issues/2765 https://github.com/dotnet/csharplang/issues/2765
- contravariant 7y agoI find structural typing is mostly necessary when someone messed up and used a class where an interface should have been used. I'm now currently in the position of having to decide whether it's better to accept defeat or use T4 or similar to write the 1000+ line wrapper class to undo the mistake... You'd think Microsoft would at least remember to do dependency inversion through interfaces in their own C# code.
- LeonB 7y agoI wrote a tool, NimbleText which is free and good and lightweight for these one off 1000-line code generation scenarios. See https://nimbletext.com/live https://nimbletext.com/live or email me for help (support at nimbletext)
- hudo 7y ago> - Allow functions outside of classes use a delegate for this:) Btw, for dev on Mac I use Jetbrains Rider, its like VS with Resharper or even better. Its also available on Linux. Otherwise, for smaller (micro)services, VS Code works fine. As soon as you start fighting with Code, maybe your solution is too big?
- moron4hire 7y agoYou can get most of the way to functions outside of a class with "using static". I often do "using static System.Math;" to have bare may functions. Also often do the same with System.Console. I'm not sure what your thoughts are on Structural Typing, but I've found liberal use of extension methods on interfaces to be a really useful way to get lots of functionality on a wide variety of types. As for your comment on namespaces, I cannot agree. Again extension methods would not be anywhere near as useful if one can't arbitrarily add code to any namespace, without needing to adhere to a file system structure.
- txdv 7y agocan't you just put static functions inside of a static class and use them with "using static StaticClassName"?
- louthy 7y ago> and adopting a functional style Although this won't solve all of your problems, if you can't use F# and want to use a more functional style, then this will help [1]. disclaimer: I'm the author https://github.com/louthy/language-ext https://github.com/louthy/language-ext
- commanderjroc 7y ago> Given that our deployment platform was Linux (for a .Net Core 3.0 project), I was determined to use Linux and VS Code for development. That was a fail; the verbose nature of C# and the Framework APIs make it impossible to be productive without significant help from a full-fledged IDE like Visual Studio. I have had and continue to have the opposite experience of you. I use Ubuntu with VS Code and a few C# plugins that have greatly allowed me to navigate the .NET Core framework and write code with minimal references. Even, with Visual Studio (unless you use R#), you will always run into issues where you aren't sure where the function or class lives. That's why you go read the documentation or ask SO. The more you write webapi's the easier it is. > Structural Typing Dynamic was the closest to it, but it has significant performance issues. Tuples and structs do exist also. > Allow functions outside of classes No. > Verbosity in C# ???? > most popular libraries will nudge you strongly to use Dependency Injection throughout the app and implement everything as a class and to extract interfaces out of it. You do realize C# is mostly a strong Object Oriented language hence why they (the libraries) urge you to do that. If you want functional so much use F#.