Why I'm no longer giving up on C#
mat-mcloughlin.github.io
mat-mcloughlin.github.io
I love C#, I'm quite fond of Visual Studio and Xamarin Studio, but I dread nearly all the auxiliary MS libraries, like WCF, ASP.NET MVC, MSMQ, WCF Data Services, MSTest, and so on. WPF (MS's most recent UI framework) is an odd one out though, cause it kicks butt. Must've been a different team. But yeah, it's terribly platform-specific so not very useful in web tech.
I never understood why so many C# programmers automatically default to these MS technologies without even looking around. This bugs the crap out of me, because the attitude gives C# (and other .NET languages) a bad name undeservedly, and it really limits further development of the ecosystem. Which is a shame, because as this blog post points out, there's a good bunch of really good .NET open source out there.
I very much miss ServiceStack in the list, though. ServiceStack must be the best designed API/backend framework that I've ever used, in any language. The moment you want to handle more than a few URL requests, it beats Nancy hands down. Stuff gets clearer, there's less magic, and somehow you also end up with less code.
Many C# programmers are C# programmers because they (or, in many cases, their employers) default to MS technologies without even looking around.
How were the early adopters of those unproven technologies not "treating their client/employer as their personal playing field to try out the latest buzz"?
In general, .NET shops are more risk adverse than "open source" shops. Some reasons are cultural, some are business. I think Microsoft is trying to change this as they're clearly growing tired of their own developer base being reluctant to adopt their own technologies.
Of course there are going to be exceptions to this but as a general rule, taking into account all dimensions of the decision, the default stack is the rational choice.
http://www.twilio.com/blog/2013/07/billing-incident-post-mor...
http://github.com/clotheshorse/destrier
works similarly in that you can map output to POCOs, but will also let you do more complex querying and CrUD operations.
Are you going to build an editor/generator for VS?
The speed comes from dynamically emiting IL for the object population methods.
Some things this has that PetaPoco doesn't are expression visitors for the where clauses and the concept of referenced objects or child collections.
But what exactly is wrong with MVC and Web API? I actually like those. They are modern and open source. Some of the MVC 4 project templates come with DotNetOpenAuth and provide a fully functional social login system by only adding the client keys. Outside of Mono support, I don't see other advantages of Nany or ServiceStack over MVC / WebAPI.
I could do this all day. You end up fighting the framework using MVC / WebAPI, once you build an app or service with Nancy or ServiceStack, you will be like "wow why was I using the MS stuff so long..."
Indeed, if libraries were designed with F# in mind, they'd allow even more expressive code. The downside with F# is that libraries usually take advantage of C#-specific hacks and workarounds due to C#'s limited type system and expressiveness.
But in general, I've found that even if you aren't gonna commit to F#, using F# as a "better C#" still results in a lot less code.
Doesn't quite lay out how this makes C# a better choice than the other languages mentioned at the start of the article.
Get["/"] = _ => "Hello World!";
Or even the class declaration: public class SampleModule : Nancy.NancyModule
My RSI is starting to flare again...I imagine there's some sort of causal relationship between ultra-powerful IDEs and languages that are verbose. The question is: are the IDEs powerful because the languages require them to be OR did the language evolve to become more verbose due to the IDE eliminating most of the pain associated with verbosity? Both? Neither?
I type even less on RubyMine. Try it out, it's free for the first 30 days and then it is fairly priced.
The first example in Python would be some variant of
@get('/')
def whatever():
return "Hello World!"
Or in Ruby: get "/" do
"Hello World!"
end
Or in Go: http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello World!")
})
These other languages, all popular on HN, are nearly identical to the C#, or even longer in a couple of cases. You'd have to go with a project-specific macro package on a Lisp to get much terser.The second C# is also quite terse, IMHO. What would you have preferred? The equivalent Python would be something like
__all__ = ['SampleModule']
class SampleModule(nancy.NancyModule):
pass
which, even if you want to say well, no one in real life uses __all__ (which isn't correct) is still nearly the same length. I don't quite remember the Ruby off the top of my head, but it, too, is similar, as would be Perl.Older C# versions could be verbose, but this seems quite terse to me.
I call BS. The same things are just as lengthy in most languages you'd use.
And there's nothing there that does not need to be. You still get the "class" signifier in Python or Ruby, and even more BS on Javascript (the huge word: "prototype").
The only thing that COULD be missing is the "public" modifier, if things were public by default.