Join 3,572 readers in helping fund MetaFilter (Hide)


Scripter needs to learn a "real" language.
June 11, 2008 4:37 PM   Subscribe

Help a Perl/Python guy learn C#

I want to learn C#/ASP.NET. The problem is that I'm a scripter by heart (Perl/Python/PHP/Javascript). I learn by coming up with an idea for a program and figuring out how to do it (via docs, reference). I like the O'reilly "Cookbook" series.

Every time I read a C#/ASP.NET book, I look at the examples and think, "I could write this faster and simpler in Perl". Does anyone have ideas/resources/examples/books/projects that would be good for C# but bad in a scripting language? I need some motivation/enlightenment!

I've been trying to learn C# on and off for the past year or so, help!
posted by wongcorgi to Computers & Internet (15 answers total) 9 users marked this as a favorite
 
Well, I'd say Python is more of a "real" language than C#. Is there a particular reason you want to learn C#, or are you trying to increase your employability?
posted by AaRdVarK at 4:47 PM on June 11, 2008


Write a GUI application using straight Win32 - no fancy WFC or windows forms or anything.

You may not be seeing the appeal of C# for server-side code in conjunction with ASP.NET because it isn't really there.
posted by GuyZero at 4:49 PM on June 11, 2008


Its a "open more options for employment" more than anything.
posted by wongcorgi at 5:22 PM on June 11, 2008


In my opinion, you won't really see the big benefits of C#, Java, and other big heavyweight languages until you write code on a large team with a big codebase. Scripting languages are great when you're working by yourself on a quick project, but when you're on a big team with other programmers of differing backgrounds and skill levels, it can be nice to have more structure.

One way to appreciate C# on large projects might be to find a large open source project in C# and try making some changes to the code. That might give you a feel for some of the "safety net" that C# has that might be lacking in other languages.
posted by burnmp3s at 5:35 PM on June 11, 2008


Every time I read a C#/ASP.NET book, I look at the examples and think, "I could write this faster and simpler in Perl".

That's kind of the point of Perl, and I'm sure Larry Wall would be pleased to hear you say that. It's actually the point of scripting languages in general, actually.

But what you lose in quick whipitupitude by moving to a more verbose language, you tend to gain in maintainability and readability - especially for large code bases, as burnmp3s points out. Perl source code often tends to be somewhat write-only.
posted by flabdablet at 5:52 PM on June 11, 2008


The other advantage, which I have encountered as a C/Java guy learning Python, is static type checking. No more waiting for your program to poop out during testing - it poops out during compilation which takes a lot less time.
posted by GuyZero at 5:58 PM on June 11, 2008


Recommendations, even though I only get the idea of the language and not necessarily the nooks and crannies which, in agreement with burnmp3s, cannot really be gained until employment in some project (I am looking for an internship around Ypsilanti, Ann Arbor, MI if anyone is offering):

C# Station has a fabulous breakdown of key concepts of the language. Probably will be a nice reference page to goto whenever you need it.

An experienced programmer recommended to me the book C# In-Depth, which I was able to understand pretty well (even though I am not finished with it. I will likely read it twice and by the end of that, I should have a solid foundation in it, just not the ability to think and make apps). The book also brings a novice up to speed on the latest and greatest features of the language.

IMHO: C#, and especially with the latest pieces of 'snytax sugar' within C# 3-3.5, is a rather beautiful balanced structured language compared with previous ones I have tried to work with (BASIC and PASCAL notably, which I somehow was able to take classes in high school for in 2004-2005). Complimentary to that is the Visual C# Express/Studio "Designer" to drag and drop elements of an app on a prototypical window. I find that just awesome (I can make a 'stereotypical' Windows App: one that looks like it can do something but instead does nothing... XD)

Hope this helps!!!
posted by JoeXIII007 at 8:04 PM on June 11, 2008 [1 favorite]


Wow, lots of bias in this thread.

Alright, so here's the deal. PHP, Python and C# are all popular, modern languages which support the object-oriented programming paradigm. If you are working with skilled programmers whose aim it is to write solid, well-designed and maintainable code, the results in all three will be similar (with some differences, e.g., due to slightly different object models, C#'s static type checking, Python's better support of lambda calculus, and the underlying frameworks, etc.)

What you really should be interested in then, is learning to use practices that will allow you to write better code, in any language. To this end, I've read the following: As you read these, think of situations where applying the patterns outlined would improve your code. What are the advantages and drawbacks associated with the pattern?

To learn C#, I would suggest that you try implementing some of the patterns (especially those in the Design Patterns book) to do simple tasks. As an example, write a business object (J2EE) that uses a singleton database abstraction layer (Singleton: Design Patterns). Once you've done that, try using N-tier or model-view-controller architecture to create a simple application that lets you keep tracking of something or other in the database.

Doing this will allow you to go beyond merely being a scripter, and will greatly improve your employability. If you were to do similar things in all 3 languages, you'd be one of the few people I know (I am not in this list) to speak about more than one programming language's advantages and drawbacks in any educated way. By applying actual patterns and such in C#, you'll go from some guy who knows how to code, to someone who has experience with enterprise-level programming.

One thing that's nice about C#, by the way, is that of the code I've seen (relatively little, honestly), most of it is far better designed than what I've seen in PHP. PHP has only recently gotten to a point where people with solid backgrounds in software design are getting into the language and doing great things with it. C#, since it's specifically designed to compete with enterprise-level languages like Java, has had that kind of maturity from the beginning.
posted by !Jim at 8:23 PM on June 11, 2008 [3 favorites]


Also, by the way, if after learning C#, you still hate it (nothing wrong with that), then just keep looking for jobs in languages you like, because they are certainly out there.
posted by !Jim at 8:24 PM on June 11, 2008


I learned C# cuz my buddy got me a job at his company. I came from a PHP, Perl, and Shell background and C# + ASP.NET is freaking great. Working in a real IDE like Visual Studio makes me feel like all those years I spent in living in text editors were like living in a cave. Stepping line by line through a program during execution? Being able to pause execution, bringing your mouse over a variable or object, and viewing its contents????? I was shocked and amazed.

But as for learning it, I've never been good at learning from books and websites either. I just got thrown into the environment and it was either sink or swim. How about you figure out something you like or might need, maybe some kind of kind file management system for your MP3's and videos and just write it from scratch? No better way to learn than giving yourself a problem to solve.
posted by exhilaration at 8:46 PM on June 11, 2008 [1 favorite]


I'd like to echo !Jim's comments, and add that the most important book I've come across is Martin Fowler's Refactoring, which teaches you techniques for improving the design and maintainability of your existing code. I've been programming with C# for ~2 years coming from a background in C, Perl and TCL, and that book (along with the Gang of Four's Design Patterns) really helped me to develop good OO programming habits.

Also, try to find yourself a copy of ReSharper plug-in for Visual Studio (assuming you want to use that). It is, by far, the most powerful and elegant coding/refactoring tool I have ever used.
posted by JohnFredra at 9:40 PM on June 11, 2008


Learning a .NET language implicitly means learning the .NET Framework/Base Class Library. Have you heard of IronPython? It's basically a version of Python that compiles down to MSIL, the same byte code that C# compiles to. You have access in IronPython to all the same libraries that C# has. You might consider using IronPython to get a feel for the tooling and the Framework without leaving the comfort of Python. Since it's a .NET language, you could do all your ASP.NET in IronPython.

As far as getting your head around ASP.NET (WebForms in particular)-- you need consider it wasn't designed to be the simplest solution. It was designed to present a development environment that acted just like a Windows development environment. That is -- you drag a button on to a page, click it, and get a Button_Click event handler, just like when making a Windows Forms app. Understanding this is critical to getting your head wrapped around ASP.NET WebForms. That said, ASP.NET MVC is an alternative in development (betas are available to download) which allow you to "get close to the metal", using the MVC pattern rather than a "Windows App pattern".
posted by rdhatt at 11:15 PM on June 11, 2008


Another vote for learning things like design patterns.

This is a site I've used a lot, and it has C# examples. I'm mostly a C++ developer but once you know enough languages, it's largely a matter of having a reference for learning the syntax and API for the most popular ones, and lookup things as you need them. It's more useful to know techniques like patterns in order to really move forward in marketability.

http://www.dofactory.com/Patterns/Patterns.aspx
posted by hungrysquirrels at 3:37 AM on June 12, 2008


I learn by coming up with an idea for a program and figuring out how to do it (via docs, reference).

Part of that probably means you'll want to download the free Visual Studio versions from Microsoft and play with them yourself.

Keep in mind that the world you're delving into isn't about doing things the best way or even the right way--it's about doing things the same way. Sometimes the same way is the best way, sometimes it isn't. There can be a lot of OO shibboleths, fashion trends and flavors-of-the-month involved.

Whether there is a real ROI on doing things this way is a discussion for another thread, my opinion is that that's situational, and I'm kind of agnostic on the issue. But you're absolutely spot on that learning about it improves your marketability.

(And yes, somewhere in an alternate universe, a lot of people are using perl on day-to-day sized projects and getting more things done faster, better and cheaper. That's not the one we live in, however.)
posted by gimonca at 7:34 AM on June 12, 2008


Every time I read a C#/ASP.NET book, I look at the examples and think, "I could write this faster and simpler in Perl".

That's because you already know it! Show me some Java code from a book, and I could probably write that same Java program with half the code. Examples in books are sometimes more verbose then they need to be because the author is trying to illustrate language features you might actually need some time, but not in toy projects.

Really, you ought to learn C# and Java and Ruby and throw in come C++ and Assembler while you're at it. Good programmers can switch between languages on a whim, even if they have a favorite.
posted by delmoi at 11:28 AM on June 13, 2008


« Older I want to buy the Leaflet-o-Ma...   |  My Toshiba Satellite laptop ha... Newer »
This thread is closed to new comments.