Drawbacks of developing ASP.NET and ASP.NET MVC apps in F#? - asp.net

I would like to try developing ASP.NET and ASP.NET MVC apps in F#. I enjoy using functional langauges, and to my mind the functional paradigm fits better with HTTP and the web than imperative programming (though of course F# can do both).
I am only intending on trying F# for some personal projects, though I hope that eventually F# will be seen as a valid alternative to C# for suitable commercial ASP.NET projects.
What pitfalls and rough edges are there currently for using F# with ASP.NET? One obvious disadvantage is that F# is much more obscure than C#, so there are less code samples and experienced programmers for F#.
What other potential issues should I be aware of?

Personally I am a big fan of F#. My NDjango parser/rendering engine is written in F#.
But trying to do everything in F# can be difficult. To add to your list of the things which are not there yet:
There is no support for visual
designers - neither webforms nor
winforms. You can write the
appropriate code manually, of course
No Code Completion
Debugging in F# can be a challenge, in particular because of anonymous closures
Compiler Diagnostics can be misleading because of type inference - one typo can have profound impact in far away places
My biggest pet peeve is the 'file order matter' rule. You have to specify the order in which the files will be compiled
By no means this is a complete list. On the other end one might hope that some of these points will be addressed in final release.
Despite of all of the listed (and unlisted) problems I enjoy programming in F# - sometimes it gives a very refreshing perspective on the coding and I already started using some of the tricks inspired by F# in my C# code.
Just do not go crazy in it

Is this a home project or a work thing? If it's for work, you need to consider the ability of somebody else to drop in and maintain your code - there aren't too many F# developers out there when compared to competent C# people.

mmmmm f#, the other white meat that dare speak its name. Go for it, F# as Mr Kay would say "its the future!". As for the pitfall...puh!, what pitfalls, you just create stuff that works without chuff and Objects.
C# is great and it has its place. But as you correctly pointed out it does not suite web programming. In that matter neither does the event smoke and mirrors that ASP.net provides.
Go lower. Think HttpHandlers and REST. You don't need the MVC stuff. Its and Idea and not a product.
The front end GUI has nothing to do with the backend. Do you really need ASP.net? JSON/REST/POX.....develop your middle layer with these in mind and you should be ok. Stay away from WCF its propriety and nasty.
as for the comment of maintainable code. Trail blaze. why be what you don't want to be. If they don't think like you, then do you want them around?
When I work on projects the ideas drive the product not the technology and certainly not the masses or the mob. Large organizations cater for the mob for one reason only, and it has nothing to do with advancing the art and all about the Euro.
Messages and pipes are what I would use in this current climate. Events are great when the environment supports it, but does the async nature of the web lend itself to thinking of a processing pipe with clock ticks and checking if things have been done.
.Net good for one thing. middle layer with DB and logic. As for the front. Use something else. More webby.
Why just F# bring in the whole shooting match of best in class. plenty to choose from php, python, ruby,clojure, haskell etc....
F# is more than what it is, but what it represents, an old way of thinking in new and desperate times of multi-core multi-threading, multi-process.
As a song I once listened to said "I don't care about their different thoughts
Different thoughts are good for me"

http://codebetter.com/blogs/matthew.podwysocki/archive/2008/10/06/asp-net-mvc-with-nhaml-f-edition.aspx
http://cs.hubfs.net/forums/thread/6270.aspx

Related

What is the fastest way for a new programmer to learn ASP.net?

I want to learn ASP.net 3.5 effectively, but I have no fluent knowledge of any other languages.
Now the scenario is that span of time is very less and in short time I have to be upgraded with ASP.net skills.
So I am interested in fast and effective way to learn ASP.net 3.5.
I have to start from scratch.
Please..please........I want solution as soon as possible.........
And please mention good books and online material.
Thanks.Waiting for reply.
First thing is to drop statements like: "I want solution as soon as possible". To learn something new takes time and you'll need to cool down before getting results.
I strongly recommend you to build something for yourself. This way you can deal with new requirements and schedule pressure. During this process, you'll need to see how other people do same thing, and then to download some sample codes.
EDIT: I think you should start doing that every application does: trying to access a database and changing data. This path will lead you to know more about Entity Data Model and LINQ. So you can go to code your front-end. You can take a look at NerdDinner website for MVC samples.
There are plenty of good tutorials at asp.net/learn.
If you're interested in ASP.NET MVC (Microsoft's latest web UI framework) then there's a good set of tutorials at asp.net/learn/mvc/#MVC_Overview
It might be worth mentioning that you have a choice of programming languages to use; VB.NET or C#. If you are new to programming then you might want to spend some time getting comfortable with one of these initially, as well as familiarising yourself with the underlying .NET Framework.
If you can provide more details about what you need to achieve, as well as your programming background then people will be able to provide advice that is more specific to your situation.
It takes about ten years, as does learning anything worthwhile.
The best way to learn a new set of development skills is total immersion in a project. Build your own website and follow along with a book or two, make some mistakes and fix them, and in general endure all the rough-and-tumble that development involves. Along the way, make sure you're investing good time in writing solid unit tests, so that you understand what they're for and why you should be writing them.
If you've never programmed before, this is going to be rather challenging as a first project. ASP.NET MVC requires understanding, if not fluency, of many different pieces of web development. But dedication, persistence, and curiosity will be enough to win out here.
I think reading a good book while implementing some basic website will be your best approach.
My personal favorite, with good inside examples and good practices is Pro ASP.NET MVC
Get a book like ASP.NET 2.0 Website Programming from Wrox Press and work your way through it from beginning to end. Immerse yourself this this project, follow all the steps and understand every step along the way.
Microsoft offers 2 distinct Web development systems - "Classic" ASP.NET WebForms, and MVC. In my opinion MVC is more "pure" to the web philosophy but is trickier to learn, the controls aren't as rich and varied, and there are fewer resources to help you. WebForms have been around much longer, there are thousands of books and helpful sites, and there are probably more job opportunities.
Good luck. If you're smart and work really hard, you should have no trouble.
Saying you want to learn ASP.NET from scratch is like saying you want to learn to build a house. You can get a book that shows you how to saw lumber or nail boards together -- but there's a lot more to building a house than any book can effectively communicate.
Learning a specific control or a narrow skill can be done in a few days, but really learning ASP.NET from beginning to end is a multi-year project -- particularly if you have to learn the language too. Learning C# well could take a year by itself.
Experience is the best teacher. If you can get a mentor of some kind involved, that's even better (just like how carpenters need to apprentice for some time before they're ready to build a house by themselves).
In all seriousness, start with at least 3 years at university doing a computer science/engineering course of some description.
There is no fast and "effective" way of learning to program and being any good at it. There's a lot, lot more to software development than just the code as anyone who has been doing it for any length of time (and cares about their craft) will attest to.
Can you define what exactly do you mean by "learn effectively"? Do you mean that you want to be able to write code like Jon Skeet at the end? Or do you mean that you should be able to handle the job of a junior developer? There is a lot of room between those, to say nothing of you not stating how you learn best: Do you absorb information best from reading, seeing, doing, or some other format of data? How good are your Google skills? How well do you know of MSDN and the massive amount of information contained within?
Scott Gutherie's blog may not be a bad idea for another resource to consider. Another point to consider is however fast you want to learn 3.5, there will soon be a 4.0 that may be out sometime this year as part of Visual Studio 2010.

ASP.NET Continuous learning

I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training.
Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals?
Thanks
1) Read the Code of popular Open Source Projects. There are a few that have some really good practices in place.
I recommend checking out BlogEngine.NET. Also if you're more ambitious, I'd suggest looking at the code for ASP.NET MVC 1.0.
2) Sometimes you need to "get back to the basics" when you've been working with a particular framework since a much earlier version. In this case, it can be really useful to pick up a book that covers some of the newer features.
Here's a good book that shows of some of the new features in C# 3.0:
C# 3.0 Design Patterns
3) It may seem odd, but reading up on other languages/platforms (such as Ruby on Rails) will help you in the way you design your classes and code by taking tips of the good and bad of different platforms and combining them.
4) Read some books on general best practices and development methodologies.
Some of these books I recommend are:
The Pragmatic Programmer: From Journeyman to Master
Practices of an Agile Developer: Working in the Real World
Code Complete: A Practical Handbook of Software Construction
I'm in the same boat; been a .Net developer for 6 years. While I do have a CS degree, I don't have any formal training in ASP.Net; I learn it on the job as projects come up.
I found the best way to figure out what to learn is to keep your eye on .Net developer blogs. Some I follow:
David Hayden http://www.davidhayden.com/blog.aspx
CodingHorror.com (you might be familiar with it ;-)
Scott Hanselman http://www.hanselman.com/blog/
Usually from reading their blogs, I pick up on what the latest .Net solutions that are out there and point me in the direction of new tech I should look into further.
Overall though, I can only give you the advice I give junior devs at my company; realize you can't possibly be expected to know everything but always be eager to learn. Good luck!
I can absolutely identify. I've been programming since 1997 and really don't have any formal training to speak of. With regards to ASP.NET, everything I've learned has been through open code (Community Server, BlogEngine.NET, the other ASP.NET Starter Kits), books, LearnVisualStudio.net, and constantly being thrown in the fire.
I have a MASSIVE inferiority complex as I'm always wondering "did I do this the smart way or the inexperienced way". All I know is that my customers are happy, the errors that occur are few and are fixed quickly, and I keep getting work.
Luckily I have a passion for my work and that's what drives me to keep improving (slow though it may be).
If you're a "people person" then I think user group meetings are a great resource. I'm a bit of an introvert and unless someone who's smart reaches across and shakes my hand, I pretty much rely on the speaker's presentation to teach me something new. Probably not the best way to go and also probably why I don't go that much.
But again, I would stress the open projects, especially Community Server.
Seek out people better than you and learn from them.
Take some classes or join a user group.
If you are looking at conferences, consider finding a local Code Camp. These conferences are often very low key, but have excellent information content. They involve local presenters and attendees so you can build up your contacts and a set of people you can run things past when you need help. In addition, you might want to find (or start) a local .NET group where you can learn together. These can be hard to get off the ground, but when done well can be an excellent source of community learning.
Look for interesting ways to break your established patters - even at a loss of productivity.
Otherwise, it sounds like you are already in a pretty good spot. You can deliver on current requirements and sound like you can pick up new tricks when needed.
Really, the best way to learn new techniques is to work on a different project - even if that means changing jobs. If you have relevant and continuous experience since 2001, you should be able to pick your projects.
I've been coding PHP on a current project and it's been an interesting break from webforms. If anything, I'm getting good perspective on both models and really looking forward to doing some work in MVC.
I'll probably get some -1's for this, but as a fellow ASP.NET developer I don't think you really need to learn ALL that the framework has to offer. The reason I say that is that over the years my LACK of knowledge of all the cute little conveniences of ASP.NET has caused me to write better performing and more robust web apps for Windows. Balanced design patterns (separation of concerns) WITHOUT OVERDOING IT will make more of a "better" ASP.NET web app than using all of the controls and tools that come with the framework.
Case in point is the ajax stuff you get with ASP.NET, and also data binding. Since ASP.NET was late in the game with Ajax, I started off with my own ajax wrapper (based on an early ajax book) and then moving to jQuery. My co-workers all swear by the UpdatePanels and 3rd party controls, and quite often the user experience ends up worse and more confusing than a regular post back (and then we have to inject javascript to make it perform better and more seemlessly). As far as data binding, I've yet to find a canned control (from Microsoft or any 3rd party) that handles 2-way binding better than the framework Rick Strahl came up with back in the 1.1 days. We built a framework on top of a paper and some base classes he released, and I've yet to see something that I think handles data binding any better in ASP.NET (well...besides WPF/Silverlight...those frameworks really nailed it IMO).
So, to me, the path to upgrading your ASP.NET skills is to come up with some good ways to separate your business logic into logical components in the cleanest possible way, and learn the hell out of C# and JavaScript (and/or a JS wrapper library like jQuery). For me, coming from a LAMP background before learning ASP.NET, I absolutely love C# and Visual Studio, but I'm not such a huge fan of the high level ASP.NET controls.
This is a pretty broad question, and hard to address. I perceive myself in a similar space to you, so I guess I can elaborate on what I've been focusing on to improve as a developer which might be of some help.
I mostly write business and commerce related web apps, and my focus has been on a developing a solid understanding of separation of concerns, domain driven design, and enterprise design patterns.
Some books on general software design which I found revelatory were Code Complete by Steve McConnell and Head First Design Patterns by Freeman & Freeman.
I read SO, Code Better, DDD Step by Step, and a number of other blogs regularly.
Dissect well written code from others, and learn from them. Learn from your peers. If you're in a stifling work environment that doesn't give you the opportunity to grow as a developer, consider looking for a new job.
Learn a new language in a completely different framework - I've been teaching myself Ruby on Rails at home and it has given me an interesting perspective on the ASP.NET work that I do commercially.
Given that you're an ASP.NET web developer, learning MVC.NET will certainly help you to think about front-end development in a new, refreshing way.
If you can afford the money and time (or can get your company to pay for it), take a course at DevelopMentor. They have courses across the country and all year round. They are generally a week long and are in depth.

ASP.NET Model View Presenter project structure

I am just starting a new ASP.NET project and using the MVP pattern. I did consider the MS MVC but it is not released yet and would be a big learning curve for some people on the team, so I opted for MVP now and possibly future projects MVC.
Anyway, it seems I will have a single Controller/Presenter class for every webform I have it the project. This is a lot of extra classes, essentially doubling the number of files in the web project. Is this how other people structure MVP or what are the alternatives?
This seems to be a common misconception -> "More files/classes == more complex"
The reason we chose to follow a UI separation pattern is to help separate concerns, make code easier and cheaper to change and maintain and (big, important and) we can unit test the complex parts and still keep the UI layer slim.
I'm going with the beta ASP MVC. The reason being, that while it is still only a beta (PDC very soon, that may have an impact on release and we've had 5 preview releases) it has a better framework to support this style than I could write in a reasonable time frame.
You could of course go with another framework, like castle monorail.
I think a lot of it depends but in most cases that is really the way it ends up going.
I personally use a n-tier architecture with data, business, presentation code. (Who knows what actual format I follow). I do get a lot more files than if I did everything in the aspx, but the code is much easier to manage.
To your question - I have seen many different takes on MVP and seen nothing that reduces the number of files, and I can't think of a way to reduce the number of files.
In my experience, I have reused view interfaces and even code behinds where the view structure is identical, but presenting different data. And you could also think of reusing the controllers where applicable.
I think it is worthwhile to note that having more files will be a natural consequence of moving to a more agile and test-drive development and developers will find it more and more natural as they go. (Just like some of us find it very natural having lots of methods inside a single file...)

Figuring out the right language for the job: branching out from C#

I work in a Microsoft environment, so I can use my C# hammer on any nails I come across. That being said, what languages (compiled, interpreted, scripting, functional, any types!) complement knowing C#, and for what purposes? For example, I've moved a lot of script functionality away from compiled console apps and into Powershell scripts. If you're an MS developer, have you found a niche in your world for other languages like F#, IronRuby, IronPython, or something similar, and what niche do they fill?
Note: this question is directed at the Microsoft dev people since I can't run off and start installing LAMP stacks around my company, and therefore having to support it forever. :) However, feel free to mention any other languages that you found interesting to fulfill a certain task/role in your world apart from your main language.
Python/Perl/Ruby/PowerShell are great supplements to C#/VB.NET. If your boss hands you a text file and says insert it into the database once or twice, then any of Perl/Python/Ruby (I'm not sure about powershell but I imagine it is not that much more difficult) should be fine to parse it. Either way, for your main applications you will probably be stuck in C#. You can use one of the more dynamic languages to do code generation in C#.
Since you are in a Microsoft Environment, probably your best chance at getting your solution accepted is PowerShell. Next to that I'd say IronPython or something else that integrates with the CLR. But main issue is that for someone else to maintain what you do, they would have to know whatever language you are using. MS in the future has plans to use PowerShell a lot more, so it is probably easier to justify PowerShell then say Python/Perl/Ruby.
If you are just processing a text file for one time use. Or creating a one time code generator to generate all the code and then intend to maintain the generated code, then it doesn't matter. You are the one who will consume the results and if you save time using Perl then more power to you. But if you are doing something that will be used over and over again (like an active code generator where you change the templates and run the generator instead of maintaining the generated code) then other developers working on what you did will need to know the language you used. It is much harder to argue learning Perl/Ruby/Python in a Microsoft Shop. But PowerShell seems like the easier argument. I think the MS grand plan is that eventually applications will expose more functionality for power shell through commandlets. Assuming this happens then PowerShell is even more of a no-brainer because it will expose tons of scriptable functionality that you won't get any other way.
A nice scripting language is always a good tool to have on you belt. See Ruby, or Python.
I use python for prototyping, since there's almost no turn around time between edits and actually running the new version of the code. I may even end up using it for a real project - the more I use it, the more I like it.
It will take some getting used to as a C# programmer, though - the indentation-defines-structure system it uses is a little weird at first.
Since you are in a MS shop, I would suggest PowerShell as a decent scripting language to learn. It plays well with C#.
I'm a big fan of Ruby too.
I'd like to second or third python. Specifically, IronPython (ttp://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython) lets you learn python but also gives you access to the .net framework goodies.
It's quite nice for scripting-related tasks so it'll probably be useful for your day-to-day coding life, and also a nice way to muck around in an experimental coding/prototyping way.
While it's a bit of a fringe language, I'm compelled to mention Erlang. Erlang is an excellent language to have in your toolbox since it's unusual strengths tend to compliment other programming platforms. Erlang is very useful for building distributed, concurrent, fault-tolerant systems. It's used a lot in the instant-messaging and telephony world where there's a need for distributed, yet interconnected architectures.
Maybe play around with Boo and see what you think.
Boo at Codehaus.org
Boo at Wikipedia
If your using the .Net framework the language is really not important as the compiler and interpreter create the same IL code in any case.
If you step away from the .Net world, I am of the opinion that development tools and languages are a tool box. I strive to use the right tools for the job at hand, taking into consideration what the skill base of the other developers are and what direction a company is seeking of course (I'm a consultant).
I'm with jjnguy. Try one of the scripting languages. Plus as a bonus, when you learn Ruby/PythonPearl, etc...it's a gateway drug...err language to developing for other environments.
Trying out languages outside of your normal toolbox will give you new ways of approaching things in your current favorite language. Even if you don't use them for serious projects languages like Perl (for data mangling), Lisp (functional programming), and Javascript (prototype based programming) will teach you new ways to think about problems in your current language.
As a web developer by trade, you might look into the XSLT/XPath family as for certain types of XML processing they can be very powerful tools.
Granted, in C# 3.x Linq2Xml exposes some similar functionality inline.
XSLT, however, can be a powerful way to separate data from presentation in your apps.
I am very interested in F# and some of the other new languages in the CLR/DLR. The DLR languages might be a lot better for your UI, because they don't make you cast a lot of stupid things.
However, I think that it is important to keep in mind tha learning a new language, especially in a new area, like functional programming, is always a good way to re-train your mind so that you are exposed to new concepts and you can code better in your language of choice, even if you never use those new languages.
Check out Boo - it runs on top of the .NET stack, but its syntax is more like Python.
To learn a new language that complements C#, I'd go with C++. You can use it in a 'way better than p/invoke' style to get access to unmanaged code from your C# apps. You can then start using it to write the memory-constrained apps, and/or performance-critical bits in, if you find some of your .NET applications start hogging all the RAM and/or CPU or just generally aren't as fast as you'd like.

How should you go about learning ASP.NET after life as a ColdFusion developer?

As someone who has spent around 10 years programming web applications with Adobe's ColdFusion, I have decided to add ASP.NET as a string to my bow.
For someone who has spent so long with CF and the underlying Java, ASP.NET seems a little alien to me. How should I go about getting up to speed with ASP.NET so that I can be truly dangerous with it? Do I need to know C# at any great amount of detail?
I want to be in a position where I can build basic web apps fairly quickly so I can learn more doing the tricky stuff.
I'm only maybe six months down the same path, but here are some thoughts from my experience so far:
The C# language shouldn't give you much problem if you have very much experience with Java at all (or even CFScript). As a reference, though, when I was starting, I found csharp-station a good primer for language basics. It won't help you much as far as the ASP.NET side goes; but it is good for syntax. More you'll be familiarizing yourself with the .NET libraries. The IDE actually can be an enormous help here.
Here are the three biggest differences I found making the transition:
ASP.NET Server Controls - In ColdFusion, you really have pretty
direct control over the HTML; you
work very closely with the page.
This isn't so much the case in
ASP.NET. The server controls are
meant to relieve you of a lot of the
tedium, but at a cost of maybe some
direct control. As a CF programmer,
I'm very particular about what gets
actually output to the browser; and
at first ASP.NET frustrated me
because it spits out a lot of extra
code. Still, the controls are
really powerful, and it pays to
familiarize yourself with them.
Form and validation controls,
especially, save you from a lot of
the tedium in CF of handling post
back and validation. W3Schools
actually has a decent list of web
server controls.
The page model - ColdFusion is pretty agnostic in terms of page
flow. ASP.NET is very much geared
towards using post backs, and is
very event driven. If you're not
using a framework with CF (e.g.
Model Glue), this may be foreign to
you. .NET takes care of handling a
lot of the post back behavior for
you. Also, not to say that
ColdFusion can't be object and
function driven by good use of
CFC's, but ASP.NET really tries to
push you down the OO path compared
to CF in my experience.
Database access - Using ASP.NET really made me appreciate how
powerful cfquery really is. The
csharp-station site also has a good
tutorial on working with the native
.NET db tools. I haven't worked on
enough projects yet to start looking
around for DB access extensions; I'm
pretty sure Jeff recommended
something that they used for
building this site, so you might
check that out. Otherwise, I really
suggest you familiarize yourself
with the DataSet object. It's
somewhat similar to a query object
in CF, and lets you run query of
queries, etc... Looping over
queries in CF is very common, but it
doesn't happen nearly as much in
ASP.NET because of data binding.
Microsoft has a video called ASP.NET for ColdFusion developers you may be interested in.
Edit, here's another
ADO.NET is a core concept, and I would really recommend taking a course in it. Having a qualified instructor explain exactly what the differences are between a DataSet, DataReader (and so forth -- there are a lot of different data access object types) is invaluable. Not to mention you'll better understand the appropriate time and place to use each; and you can ask questions and get immediate answers in a classroom setting.
I took an ADO.NET class (one night a week, about 8 weeks) at my local university for around $400. Even if my company hadn't paid for it, I would have been happy to, and I can highly recommend anyone trying to learn .NET do the same.

Resources