Probably sounds a bit stupid but I'm getting confused moving from Classic ASP to ASP.net.
After looking at the two different variants of the language, VB or C#, I have decided to go with C#. I was reading another StackOverflow answer that explained moving from VBScript to C# was easier to learn coming from VBScript.
So, I thought I'd hit W3schools to learn some basics on C# but got confused when I was given the options; Web Pages, MVC or Web Forms. Would somebody please explain the differences and which one would suit me best?
I have been coding in classic ASP/VBScript for many years, building all kinds of web application, some big, some small, and I do not want to use any software like Visual Studio, I just want to write code. I currently use Dreamweaver just for coding.
For a move from classic ASP to a .NET web platform, I would suggest going with ASP.NET/MVC.
WebForms are an abstraction that was created to make VB6 programmers comfortable with working on the web and it is a very leaky abstraction. It uses an event model and an idea of PostBacks that simply is not part of how the web really works. It has limitations that will not be familiar or make much sense at first (you can only have one form on a page, for example). As such MVC will be much more familiar.
I suggest that you watch this video by asp.net official developers as well as other relevant videos at the migrating section
Here's another good video produced to help programmers to choose the programming model (webforms, webpages or mvc, tools, etc)
Although w3schools has several good examples, it has several inconsistencies as well as incorrect information. Good alternatives for w3schools include MDN and IE Reference API (as the name implies, it's aimed to IE, and it's a good reference for when something works in other browsers but not in IE)
I have inherited a really awful webforms application that is all kinds of bad--an untestable hairy mess of datasets and Page_Load events. Object oriented? N-tier? Unit tests? source control? All academic niceties to the team that built this mess.
It started life as an asp classic app, got mostly ported to VB.NET. Management denied my request to "nuke the entire site from orbit" and start over.
[Insert discourse on how ASP.NET MVC is absolutely, positively the only sane way to to .net websites anymore]
I know we might be able to interoperate between the legacy webforms and mvc. The question is, can we leave the legacy code in VB and build the new stuff in C#? I want to force the conversion to C# so the team doesn't fall back into bad habits.
Is there an MVC 2 Areas strategy that we could use here?
I'm not surprised the idea of a total rewrite was shot down. In general that is a recipe for delay and more bugs, regardless of how buggy the current project.
As far as I know it depends on the kind of project. If the existing project is a web application then no you can not. You could reference external libraries built in C# due to the CLR, however, you will not be able to bake C# code right into the project. This is done all the time and is mostly acceptable.
If the existing project is a web site project then I would have to say yes you can. However, you should not willingly do this unless there is an absolute need to do so. This is just asking for a difficult to maintain project and essentially requires you to do a lot of management in the web.config. I would strongly advise against doing this.
site reference: http://timheuer.com/blog/archive/2007/02/28/14002.aspx
I think you should be able to put this method together with those from the Google search mentioned by an earlier poster. Its going to take a bit of work though.
Additionally, coding practices are pretty much entirely unrelated to the language and from my experience working with mostly web forms and a little MVC, both have their time and place. I would look at laying down a set of practices that must be followed and enforce them using code reviews. Any new code you write would be kept clean and tight while you can also update old code to use standards.
I'm intrigued by your implication that the team's bad habits are caused by use of VB. There are plenty of bad habits in any language: the trick is not to switch language, but to learn good habits.
Anyone's post about this kind of thing is going to be opinion - and in my opinion you'd be better off teaching them to program properly in VB than making them learn a new language that they may struggle with. I've seen great, stable, maintainable VB code and I've seen horrendous, messy C# code. Try not associate a programming language with the quality of output of a team that happens to be using it.
(For the record, I develop in both VB and C# and would always choose C# given the choice - but not because I think I write better code in C#.)
It is possible, essentially by making all the views, etc. in the MVC project embeddable, adding it as a reference to the VB.Net project and then registering the routes.
It's a bit more complicated that that, Matt Honeycutt has a series of posts roughly outlining how he did it here:
http://trycatchfail.com/blog/post/ASPNET-MVC-3-Razor-C-and-VBNET-WebForms-A-Tale-of-Black-Magic-Voodoo.aspx
I am looking to switch to C#. I come from a C / C++ background but C# is a little different for me. I am switching mainly because of Silverlight and MVVM; all examples are in C#. Any information is in C# and I am confused when I read through it all.
What is a good place to start learning C# when starting with existing C / C++ knowledge?
Start writing code in C# ASAP. Only way to learn the language is to write it. You already understand VB.NET. You've got a huge lead on anyone new to .NET.
Take a smallish application you've written in VB.NET and methodically change it over to C#.
You'll learn the syntax, etc. quickly.
Write all of your future projects in C#. Just force yourself into the change and you'll do fine.
Read the best C# books. :)
The Wikipedia article "C Sharp (programming language)" is a decent introduction to C# as a language.
Shortly after learning VB.NET I decided I'd rather be coding C#. I learned it by reading a couple of books and working on a project. Slowly, I got my coworkers converted over to the language from VB.NET as well. The languages are very similar, some code conversion is just a matter of changing syntax.
However, if you've ever worked with a true VB'er you will see VB specific functions used in their code that'll make you scratch your head. There are string handling functions and casting functions for example that you will have to convert. Also, C# has no RaiseEvent. Events take a little more effort to understand in C# because you need to wrap your mind around delegates (C++ function pointers/callbacks). As others have said, if you are coming from C++ this shouldn't be too difficult.
Many people go on about needing to work on a project to understand a language, which I agree with. However, there are features of languages which you will never know about if you don't pick up a couple of books and read about them. I've been able to show my coworkers many useful techniques just by reading a couple of books.
Lastly, C# is a great language. I was very skeptical when I first started using .NET, but now I know that MS got the right talent together for that framework and language.
Good luck.
As you know C++ (as you wrote in the question) and VB.Net (as you mentioned in the title), C# won't be hard for you if do know them both well. If this is the case, just grab any source in C#, and read it.
By the way, the article from wikipedia is a very nice intro.
One thing that may work for you is to use a converter
Write your desired code in VB.
Paste small pieces of code you don't know how to write in C# into http://converter.telerik.com/ and convert.
Manually type the result into your C# project.
Gradually, reduce your reliance on converter as you become more familiar with language.
That is enough to get you started, however C# has language features that VB does not, or VB offers in a way that is so wordy that no one really uses it.
The more features you will come across as you look at code examples from around the web (like on stack overflow), and you need to either look up syntax or function manually, or convert from C# back to vb to understand what it is doing (use same converter). Or, just paste it in and see what it does.
I think I'm leaning toward C# and .net as a concentration language for learning web development. I would like to learn good programming fundamentals and I've looked at pretty much everything else. The four I've narrowed it down to have been C#, Python, Ruby and PHP. Is there a reason to stay away from C# (and I don't think the cost issue would really apply to my solo-developer situation but I could be totally wrong). Any thoughts?
I realize that these are all great languages so I'm not trying to ask which is the best overall. However, would Ruby be a viable alternative for a first language or does it have too much "magic under the hood" coupled with Rails, and unorthodox methodologies? I do like what I've seen with the language.
This is likely to result in a flamewar but I think C# is a pretty good language to start with for Web Development.
It is a full featured object oriented language and is statically typed and compiled. It's very well documented and has a huge developer community.
If you absolutely have to run on Linux/Apache and do not want to use Mono, that would be a reason not to use C#. Other than that, I don't think there is a compelling reason not to, particularly with ASP.NET MVC, which lets you move away from the WebForms model.
This is not to say that WebForms is necessarily bad but some might object to WebForms as it introduces abstractions that are not inherent in other web development platforms.
If you go with C# for web development, depending on your experience with web technology, I'd heartily recommend starting with ASP.NET MVC before ASP.NET Web Forms.
ASP.NET Web Forms is the original style of building ASP.NET applications, and tries to abstract a lot of the details. It allows you to build applications without realising what's happening under the hood (post data, state management). In my opinion, these abstractions although making things easy at first begin to "leak" when you get into more complicated scenarios (as this tutorial proves).
ASP.NET MVC on the other hand makes it easier to build web sites that are a lot "closer to the metal" while still keeping you productive. If you want absolute control over the resulting HTML and aren't afraid of things like cookies, form tags, post and query string data, then you might enjoy ASP.NET MVC a lot more.
Of course it would be beneficial to know both. But if I was starting now, I'd probably start with MVC and move to Forms (then realise how bad it is and move back :)).
There are no "best language over all". You use one tool for the purpose it has been made, that's why there are several tools.
Since your question is "why not learn C#", I'd say :
If you plan to work with other OS then Windows (Mono cannot compare).
If work in an env or with people not .net friendly (e.g : bank, scientists)
If you work in an env or with people that are expert in another good tech (never underestimate the use of a good master).
If you think Free Software matters so much that using a MS product is not worth it.
If you don't like MS Visual Studio (working in c# without a good IDE is a pain).
If You plan to program something that .net is not suited for (e.g embedded devices, scripting, real-time, fault tolerant system, AI, etc).
If you are a web dev and can't afford a Windows Server Licence.
If you want to learn programming with the very basics, including simple functions and quick and dirty scripts.
Now, I program in Php, Python, Java and C#. Python is my language of choice, but c# is really the first MS programming tool that seduced me : it's clean and efficient. Really, it's about what you want to do, not a question of religion.
Make YOUR choice.
That's said, C# sucks and Python rocks.
I agree C# is a pretty complete language, it's syntax is clean and extensible. There's a huge amount of web resource already available, but and it's a big but, it effectively ties you to windows as your platform. For web especially that's an important consideration. On the desktop windows is king, but for web servers the market it isn't nearly so dominant.
Another side issue, if you're looking at rich media on the web you have to consider Flash and/or Silverlight. If you go C# then you're someway to using Silverlight without learning a different language.
Don't worry about the cost. The compiler is free to use, along with the rest of the Fx SDK, and you can even download Visual Studio for free.
The disadvantage to learning C# is that it ties you to a proprietary platform and software stack. Now, there is Mono, which does a good job of implementing much of C# and .Net, but the primary and most complete implementation is Microsoft's which is non-free.
I have not used C# enough to debate it's technical merits with respect to Ruby or Python. I can say, however, that learning to use and even contribute back to free software can be quite educational, in addition to the other benefits (discussed in length elsewhere) that free software provides.
c# is a good language to start with because:
It is a very good and very clean language
It has an excellent library (.NET framework). This is one of the most important things to consider when choosing a language.
It is very popular, you'll always be able to find the answer you are looking for from the community.
If you know c#, you pretty much know VB.NET.
c# is syntactically similar to Java. Learning c# won't teach you Java's libraries, but it will significantly reduce the learning curve if you want to enter the Java camp.
c# is syntactically similar to c++. Again, it uses a different library and unlike c++ you get memory management; but the learning curve should be somewhat reduced if you decide to play with c++.
As for the web...
ASP.NET webforms does a lot of magic for you. ASP.NET MVC (just released) does almost no magic for you. For learning, MVC is the better choice.
C# is a great language to use. And since you are using it via the web and not desktop applications for example, you don't have to worry about being multi-platform since the code is run on your server and the output delivered to the clients. With that said, you will have to find Windows hosting (which can sometimes be a bit more expensive) or use mono (which isn't exactly the most updated software out there). The downsides are minimal though, grab a copy of the express edition and go for it!
I think the cost of deployment might be a different thing, i.e. if your project needs to scale horizontally, and add more servers to load balance or even for geographically distributed servers. Usually the windows hosting will run a bit more than linux (without even considering the flame wars reasons).
C# is fine for starting if you are doing web development. However, I recommend that you don't start programming with web development. Web development is hard to get right. Way harder than little command line things. I recommend that you get some good experience programming for the command line, and then move up to GUI, and then move on to the web. The web has a whole bunch of things you have to worry about. You have to know 3 languages (HTML, JS, C#(or insert your server side language here)). Plus you have to worry about all the browser quirks and stuff. And that's without even getting into databases. Which is usually used in most web applications, but opens up a whole other can of worms.
Considering all the answers so far, I thought I'd look at all four languages mentioned.
While I've done a lot of development in PHP, and sadly continue to do so, I think PHP was never a great language (though it had a few great elements) and these days there's not much point picking it up. It remains extremely easy to get into but I think in general, PHP is a "bad habit".
Python is a great language, but to me, Ruby is all that Python is and a bit more. Personally I would go for Ruby.
C# is also a great language, but while I haven't used C# enough to say anything with confidence, I feel that Ruby is a better choice.
No reason in particular to stay away from C#. It's as good a language as any. Stackoverflow uses it for example, so it works on a successful website, and you can get jobs programming in it.
The proprietary thing would be a consideration if you were programming as a hobby or off your own limited budget, or you wanted to contribute to the development of the compiler/language. I'm guessing neither of these are the case. (Edit: as others have pointed out, open source environments for C# exist.)
It depends on a couple of things. C# and .Net is populate and th tools are really very easy (complared to Java! Java developer talking here...) but Windows Hosting is expensive vs LAMP (which include Ruby, Python and PHP).
For me it all depends on the tool that you want to use. For web services etc I would use C# but for a simple website PHP since its easy.
It also depends on the job market of your location... here in South Africa you get alot more C# jobs and not much PHP etc. Off course if your a freelance you will struggle to find work.
For me Ruby again is good for my own person stuff but you don't get any Ruby jobs here.
My advice? Learn the differences for yourself. Play around with both of them. If you have a project in mind, write a prototype for it in them. You'll always be at the mercy of other peoples' biases otherwise.
ASP.net (C#) and Ruby on Rails are used in high-profile sites, so you can't go too wrong with either one. Might I also suggest that you try out Python programming with django? It's what I tend to prefer for web programming.
I'm a C# .Net developer and I think it's great, but I'll highlight a danger in the Asp.Net WebForms. It is unlike the majority of other web frameworks and does A LOT of magic under the covers. As others have said ASP.Net MVC is probably more inline with other web frameworks (Rails for example). Web Forms abstracts a lot of the nuts and bolts of webdev away which If you want to be web developer you'll end up needing to know. So yes C# is great but I'd start with MVC and then look at web forms possibly. Also looking at other languages and frameworks is highly encouraged there's always stuff to learn.
Commercially I am a C# developer. I love C#. C# is a great strongly typed language. With Resharper installed I can build my ideas in code rapidly and flex it to my will.
When I go home each evening I use Ruby. Even though I have no refactoring support (snif.) I find I am much more productive in Ruby than in C#.
I worked writing a large ASP.Net application for a couple of years. We implemented MVC to try to detangle the view from the model. It always felt like I was fighting the framework, not working with it. The latest .Net frameworks for doing web application are based on Rails... just a couple of years behind. I love the language. I love the CLR. I'm not too keen on .Net.
I find the ruby community to be friendly and vibrant. The rails open source community produces loads of tutorials and plugins that make getting up to speed easy and putting your application together simple.
Another thing to consider (as far as choosing a language to learn) is that ruby is an Object Oriented language. Even classes are objects. C# is a Class Oriented language, ie. it provides you one way to create objects.. define a class first. (not totally true.. you can generate assemblies in memory using codedom.. but that is by no means easy).
This may seem like a subtle point, but there is a difference.. and until you get experience with an OO language like ruby or smalltalk it's not obvious what that is. Once you have felt the freedom of building objects by mixing in functionality at runtime etc. you find that all the 'work-around's you had to do in C# disappear. Not having the safety net of interfaces does seems scary at first.
In all, I'd learn ruby..
If you are new to programming (totally) I'd start with http://pine.fm/LearnToProgram/
Then I would learn BDD (RSpec) and get test infected as soon as possible.
Then I'd consume rails tutorials and screen casts until my eyes popped
The only problem is .. if you start with ruby then later go to C# you'll find yourself going "Aaaaagh! This would be so much easier to do in ruby" all the time. I know I do.
It really depends on what you are trying to achieve. I program in both and to be brutally honest, if you are trying to make a career out of programming, I get paid twice as much for .NET programming. The types of clients that I do PHP dev work for are not the types that pay a lot (PHP is often chosen based on saving some $$$). .NET seems to be much more entrenched in larger corporations.
Just my observation...
No disadvantages really except that you will be unwelcome in those social groups (and even geographical regions) that pose themselves against the "evil Microsoft".
The language (better .NET platform) is quite good. One important thing is that it is being very actively developed causing some people trouble keeping up. But I'd rather have rapid development compared to year-long stagnation.
You might consider checking what employers in your area prefer as a technology stack.
Considering licensing costs you can consider the following: If it is a small site you can use Visual Studio Express/SQL Server Express for free and it will be sufficient. If you come up with some major heavy trafficked project you will likely to find a way to make revenues and cover licensing costs.
Learning C# is great in 2009.
Way back in the day, when I entered the professional world, the language landscape was very different. I coded professionally in C and Modula 3 (Pascal replacement language).
My point is that I would plan for the technical landscape to change over time, and plan for that in your professional career development.
Learning multiple platforms is a great way to accomplish this. For example, you could have C#/.NET as your primary skill, but also work with JAVA. When a new platform emerges, you could add it as your transition or backup skillset.
I am fresh out of college (passed in 07) and have been working on a Windows Forms project since then.
I have a decent understanding of C# (not all the features of the language only the ones that i got to use in the project) and am very interested in learning ASP .NET
Would it be better to start learning ASP .NET and pick up C# as i go along or do i first master the language and then start with ASP .NET
EDIT: I am talking about the 3.5 version of the .NET framework
You're conflating some terminology. C# is a language. ASP.NET is a way to use a language (typically, C# or VB.NET) to create web-pages. So if your two interests are C# and ASP.NET....
Do ASP.NET in C#.
You can quite easily pickup C# and ASP.Net at the same time. You might want to consider learning ASP.Net MVC, as well as/instead of "normal" ASP.Net.
I was a straight VB6 developer when I started transitioning to VB.Net. I'd only done desktop applications - not a single thing in the web world. I started learning ASP.Net (job required it) and decided, at the same time, to switch to C#.
Re-did a couple of small applications that I'd previously written in VB6 and VB.Net in C# and just went on from there.
I agree with most of the people here: Learn ASP.NET and C# at the same time. You'll have to - your code-behinds will be either VB.NET or C# anyway. Also check out MVC, and LINQ.
But, and here's the big thing, learn standards compliant HTML too! Most of the drag and drop controls in visual studio do horrible horrible things to HTML (gridview, I'm looking at you). If you follow proper HTML standards you'll also use learn what controls are more useful (repeater) than others when developing clean websites.
You should be fine to learn C# while working on an ASP.NET project. I will advise that if you're already pretty familiar with the Web, you'll probably find working with the ASP.NET MVC framework more enjoyable. ASP.NET takes some liberties with the page lifecycle in an attempt to make web pages programmed more like desktop applications. Personally, I think this makes ASP.NET hard to use, but then my background is in Perl and PHP.
When I learned asp.net and C# I learned them at the same time but separately. I got a good book about ASP.net with C# and I also got a book just about C#. I found that helped. It sounds like you already use C# so it shouldn't be a problem for you.
As others mentioned, another thing to consider is asp.net webforms vs asp.net MVC. If your background is winforms then webforms will make sense. If your background is php or a non event driven framework then MVC will probably make more sense.
MVC is the 'hot' new thing everyone is talking about with asp.net these days. However, realistically there are a lot more resources, tutorials and code samples for webforms. I'm sure that will change as MVC comes out of beta and gets used more.
As far as I'm concerned, the only true way to learn is by doing. Hit the official ASP.Net site and download the tutorials and working through them.
Remember ASP.Net is NOT a language but a way of hooking up HTML to your C#/VB.Net code. Have fun!
Since you already have some experience in C#, I would recommend that you dive right into an ASP.NET project. ASP.NET will present learning opportunities on the web side of things although webforms abstracts out much (maybe too much) of how the web works. Moving from winforms to webforms will help you be able to just jump right in but you will eventually want to look into MVC or another web framework (maybe PHP or even classic ASP).