Ask a Question related to ASP.NET General, Design and Development.
-
Alan #1
Re: VB.NET or C# for new .NET porjects
Sorry, where to copy and past ?
"vishal" <vishal@vishal.com> wrote in message
news:e25wsuSIDHA.2248@TK2MSFTNGP11.phx.gbl...platform> Just Copy Paste IT. :) ;)
>
> "Alan" <alanpltse@yahoo.com.au> wrote in message
> news:epCnE1EEDHA.2500@TK2MSFTNGP11.phx.gbl...> > How to get this ?
> >> > > PART - I .NET Best Design Practices
> > >
> > > White Paper - Comparing .NET Languages C#, VC.NET & VB.NET
> > >
> > >
> > >
> > > Author: Syed Rafey Husain
> > >
> > > Last Updated: April 05, 2003
> > >
> > >
> > >
> > >
> > >
> > >
> > > Introduction. 3
> > >
> > > Why Two Old & One New Language?. 3
> > >
> > > New Language Is Required For New Platform.. 3
> > >
> > > To Get Rid Of Procedural & Early Object Orientation Era. 3
> > >
> > > Cumbersome Syntax Of VB.NET (140+ Keywords) 3
> > >
> > > Clean Syntax Of C# (77 Keywords Only) 4
> > >
> > > It Is Hard To Code With Too Many & Too Few Keywords. 4
> > >
> > > VB Developers - Always Afraid Of C++. 4
> > >
> > > Language Equations. 4
> > >
> > > VB Developers - Do not afraid of C# it is not C++. 5
> > >
> > > VB.NET & C# - A Comparative Study. 5
> > >
> > > VB.NET & C# - Comparing Keywords. 8
> > >
> > > Object-Oriented Programming. 10
> > >
> > > Exception Handling. 11
> > >
> > > Decision Structures. 12
> > >
> > > Arrays. 13
> > >
> > > Class Scope. 13
> > >
> > > Member Scope. 13
> > >
> > > Misc. Lifetime. 14
> > >
> > > Misc. 14
> > >
> > >
> > > Introduction
> > > Along with Microsoft's new development platform .NET, all Win32 era
> > > languages VB and VC++ are updated to stay compatible with .NETIsn't> fresh> > > managed execution environment and strict object orientation. While a> this> > > new development language C# is provided specifically designed to fully
> > > exploit .NET platform.
> > >
> > >
> > >
> > > This white paper is about best design practices for .NET platform. In> platform> > > PART I, we will see various language options available under .NET> has> > benefit> > > (i.e. VB.NET, VC.NET and C#) and then concluded which language will> > > the most for current and future development.
> > >
> > > Why Two Old & One New Language?
> > > Most people must have similar questions like I have that why Microsoft> > > upgraded two old languages and still one new language is provided?of> > it> > > sufficient to just upgrade VB and VC to fully leverage the potentialMicrosoft> new> > > .NET? Why another language is introduced in times when just creating a> most> > > language is no more appealing to development community? And yet still> rival> > > important questions stays in business oriented minds that Microsoft> > > has one and only one development language, that is JAVA whilefrom> on> > more> > > the other hand, rather then reducing its language fleet still adds one> > > to it!
> > >
> > > New Language Is Required For New Platform
> > > All these questions could be answered quite easily. Microsoft knewnot> backward> > the> > > start that if VB and VC++ will be upgraded for .NET while staying> > > compatible with Win32 platform, sooner or later these languages willgrown> > be> > development> > > able to keep pace with entirely new and fast growing design and> > > paradigm .NET.
> > >
> > > To Get Rid Of Procedural & Early Object Orientation Era
> > > Also Microsoft was aware of the fact that as VB.NET and VC.NET areelements> > > from procedural background (i.e. VB and C), so much proceduralto> syntax> > like> > managed> > > Win32 APIs, pointers and risky object oriented features like multiple
> > > inheritance and highly criticized templates were intermixed with these
> > > languages. Their syntax will become very cumbersome to leverage .NET> > > execution environment with strict object orientation without multiple
> > > inheritance, pointers and templates.
> > >
> > > Cumbersome Syntax Of VB.NET (140+ Keywords)
> > > One can verify this by looking at the cumbersome Object Orientation> > > of VB.NET. VB.NET keyword volume has dramatically been increased dueprone.> > keywords> > > this. Currently VB.NET has more than 140 keywords as compared to 77> > > of C#. VB.NET code has become less readable and hence more errorso> > > VB.NET is no more Visual "BASIC".NET.
> > >
> > >
> > >
> > > VC.NET has done similar addition of keywords (and VC++ developers arenumber> be> > default> > > used to it) like __gc etc. It is interesting to know that VC.NET by> > > generates un-managed code!
> > >
> > > Clean Syntax Of C# (77 Keywords Only)
> > > Due to all these reason, a clean new language is required which should> compatibility> > era.> > > free from procedural garbage of Win32 era and early object orientation> > > To realize this goal, Microsoft took a fresh start for .NET with a new
> > > language C#. C#, being a new language, has minimal backward> more> > > requirements. Its syntax is clean with minimal keywords and therefore> and> > > readable and less error prone.
> > >
> > > It Is Hard To Code With Too Many & Too Few Keywords
> > > Also it is a well established fact that, the code will be more complex> > > hard to write if it is written in a language that either uses lots of
> > > keywords (e.g. VB.NET) or very few keywords. C# supports a decent*> C++> > of> > > keywords, 77 to be exact. C# is fully object oriented language without
> > > multiple inheritance, pointers and templates.
> > >
> > > VB Developers - Always Afraid Of C++
> > > VB developers are always seemed to be afraid of and hesitant to write> > > code. Stories of dangling pointers and strange pointer notations likeconcepts> > ?or> > > & are always horrifying for VB developers.
> > >
> > >
> > >
> > > Supplementing pointers with multiple inheritances, templates OOstatement> space> > > like inheritance, overloading, overriding barely leaves a breathing> > > even for a VB guru. They are even more frightened to VC++ due to added
> > > complexity of MFC framework and ATL templates.
> > >
> > >
> > >
> > > No doubt you are playing with fire if you don't know what C++Templates> language> > will> > > eventually mean to a processor. But still C++ is the most popular> features> > > among system application developers and is THE language of choice for
> > > complex high performance development efforts.
> > >
> > > Language Equations
> > > Just to make things easy to remember, I have summarized important> > > of VB6, C++ and C# in an equation form. Here are the equations:
> > >
> > >
> > >
> > > 1.. VB = Procedures + Partial Object Orientation
> > > 2.. C++ = Procedures + Risky & Safe Object Orientation + Templates +
> > > Pointers
> > >
> > >
> > > 3.. VB.NET = Procedures + Safe Object Orientation
> > > 4.. VC.NET = Procedures + Risky & Safe Object Orientation +to> +> > > MFC + ATL
> > >
> > >
> > > 5.. C# = Only Safe Object Orientation
> > >
> > >
> > > After analyzing these equations, we can conclude that to jump from VBcan> learn> > > VB.NET or C# or VC.NET, you have to learn complete object orientation.
> > > Complete OO is alien to almost all VB Developers.
> > >
> > > To start working with any .NET language, VB6 developer must have to> > OO> > > techniques. Once accomplished in OO design patterns, a VB developerjump> has> > easily> > > easily jump to VB.NET or C# but not VC.NET.
> > >
> > >
> > >
> > > Let me explain this. As you can see from above equations, the only
> > > difference between C# and VB.NET is of syntax. So a VB developer can> > > jump to VB.NET or C#. The only thing he needs to learn is that, now he> only> > > to write for instead of For.Next to loop in C#.
> > >
> > >
> > >
> > > While same is not true for shifting from VB6 to VC.NET. There are not> > > syntactical differences but you have to learn multiple inheritance,
> > > templates, MFC, ATL etc. as well.
> > >
> > >
> > >
> > > What I want to suggest from all this is that a VB Developer shouldC#> to> not> > syntax> > > C# rather VB.NET. As I have already said, VB.NET is no more BASIC. OO> > > has made its code cumbersome. And when once you know OO techniques why> fact> > > jump to the language of the future rather than old Win32 era language.
> > >
> > > VB Developers - Do not afraid of C# it is not C++
> > > As I have already stated to move from VB6 to VB.NET or as a matter of> > find> > > any .NET language, a VB Developer must have to learn OO techniques and> > > out a way in 3000+ .NET classes. VB.NET isn't that big of a leap frommost> jump> > > since it's mostly a syntactical difference. Most VB developers do not> > version> > > to C# after learning OO techniques because they think C# is the next> > > of C++.
> > >
> > >
> > >
> > > It is a common word in VB community that C# is like C++. From thisstatement> VB> C++.> > > developers conclude that, as C# is like C++ so it must be as tough as> > > This conclusion is wrong. While I agree to the portion of thenotations> no> > that> > > C# is like C++. But it is only similar in syntax beside that, there is> > syntax> > > other similarity between the two. C# is more like VB. It offers a dot> > > notation to call objects and there are no pointers or pointerthe> inheritance,> > like> > > C++. It only offers safe object orientation without multiple> > > templates etc.
> > >
> > >
> > >
> > > I advice VB Developers to experience the ease of C# by writing code
> > > themselves. Feel the clean syntax of C# as compared to VB.NET. C# isnot> in> > > future of .NET platform. C# will eventually become major rival of JAVA> the> > > coming years.
> > >
> > > VB.NET & C# - A Comparative Study
> > > 1.. C#'s IL code is more efficient than VB.NET.
> > > 2.. I have found one interesting example of VB loose type system on> > > web. VB has a loose type system while c# has tight type system. I'mBut> > > particularly big on that but I can see it being helpful in some cases.
> > > Here's an example of what I'm talking about:
> > >
> > >
> > > Dim num as Integer
> > >
> > > Dim text as String
> > >
> > >
> > >
> > > text = "10"
> > >
> > > num = text
> > >
> > >
> > >
> > > Debug.Print num ' prints 10
> > >
> > >
> > >
> > > For example:
> > >
> > >
> > >
> > > Debug.Print num + text
> > >
> > >
> > >
> > > What would that return, 20 or "1010"? VB will return this case 20.is> and> > could> > > imagine if you where unaware of this and you were chasing a nasty bug
> > > because you were expecting "1010".
> > >
> > >
> > >
> > > In VB.NET, it will return float64. That's a big number! Our value 20> > > fit in a byte. C# has tight type system and it is explicit about data> bit> > > data types. Explicitness is a good thing when programming.
> > >
> > > 3. Comments from
> > > [url]http://www.caetano.com/richard/Articles/fog0000000031.html[/url] and
> > > [url]http://www.caetano.com/richard/Articles/fog0000000031.html[/url]. I spent a> the> > of> > > time today investigating the CIL generated by the VB.NET compiler vs.> > > CIL generated by the C# compiler. Consider the following VB.NET code:
> > >
> > > Public Function AddThreeAndSeven() As Integer
> > > Dim a As Integer = 3
> > > Dim b As Integer = 7
> > > Return a + b
> > > End Function
> > >
> > > When run through vbc.exe using release settings, this is the CIL thatlocal> > > generated:
> > >
> > > .maxstack 2
> > > .locals (int V_0, int V_1, int V_2)
> > > L_0000: ldc.i4.3
> > > L_0001: stloc.0
> > > L_0002: ldc.i4.7
> > > L_0003: stloc.2
> > > L_0004: ldloc.0
> > > L_0005: ldloc.2
> > > L_0006: add.ovf
> > > L_0007: ret
> > >
> > > Consider exactly the same function written using C#:
> > >
> > > public int AddThreeAndSeven()
> > > {
> > > int a = 3;
> > > int b = 7;
> > > return a + b;
> > > }
> > >
> > > This is the CIL that is generated:
> > >
> > > .maxstack 2
> > > .locals (int V_0, int V_1)
> > > L_0000: ldc.i4.3
> > > L_0001: stloc.0
> > > L_0002: ldc.i4.7
> > > L_0003: stloc.1
> > > L_0004: ldloc.0
> > > L_0005: ldloc.1
> > > L_0006: add
> > > L_0007: ret
> > >
> > > As you can see, the VB.NET code allocates space for an additionalC#> debug> > > variable that is never used. This is behavior is consistent between> certain> > > and release builds. I'm rather surprised by this behavior, but I'm> stack> > > that the JIT catches the unused variable and allocates space in the> guess> > > frame appropriately.
> > >
> > > 4.. C# tends to optimize better. If you ran the numbers on it, I'd> > > that resource-intensive applications would run quite a bit better inbelow.> for> > than> > parameter> > > they would in VB.NET.
> > >
> > >
> > > 5.. things that are a pain in VB, like multiple event handlers,> > > assignment (no := for out-of-order parameters), etc. If you're writing> > > the CLR, C# is a much better language.
> > >
> > >
> > >
> > >
> > >
> > >
> > > VB.NET & C# - Comparing Keywords
> > > I am not comparing all keywords, just providing a clue of syntactical
> > > difference. See MSDN for details.
> > >
> > >
> > >
> > > Learning C# keywords does not require much effort. See the chartprocedure> types)> > You> > Keywords> > > can well appretiate the elegant syntax of C# as compared to VB.NET.> > > which make VB.NET cumbersome to read are Overloads, End Try, End If,
> > > WithEvents Implements End Select etc. are not required in C#.
> > >
> > >
> > >
> > >
> > >
> > > .Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Declare a variable
> > > Private, Public, Friend, Protected, Static1, Shared, Dim
> > > declarators (keywords include user-defined types and built-in> > >
> > > Declare a named constant
> > > Const
> > > const
> > >
> > > readonly
> > >
> > > Create a new object
> > > New
> > > new
> > >
> > >
> > > CreateObject()
> > >
> > >
> > > Assign an object to an object variable
> > > =
> > > =
> > >
> > > Function/method does not return a value
> > > Sub2
> > > void
> > >
> > > Overload a function or method (Visual Basic: overload ato> or> reclaims> > > method)
> > > Overloads NEW
> > > (No language keyword required for this purpose)
> > >
> > > Refer to the current object
> > > Me3
> > > this
> > >
> > > Make a nonvirtual call to a virtual method of the current object
> > > MyClass
> > >
> > >
> > > Retrieve character from a string
> > > GetChar Function NEW
> > > []
> > >
> > > Declare a compound data type (Visual Basic: Structure)
> > > Structure <members> End Structure
> > > struct, class, interface
> > >
> > > Initialize an object (constructors)
> > > Sub New()5
> > > Constructors, or system default type constructors
> > >
> > > Terminate an object directly
> > > n/a
> > > n/a
> > >
> > > Method called by the system just before garbage collection> > an> > > object7
> > > Finalize NEW (In Visual Basic 6.0, Class_Terminate)
> > > destructor
> > >
> > > Initialize a variable where it is declared
> > > Dim x As Long = 5
> > >
> > > Dim c As New Car(FuelTypeEnum.Gas)
> > > // initialize to a value:
> > >
> > > int x = 123;
> > >
> > > // or use default constructor:
> > >
> > > int x = new int();
> > >
> > > Take the address of a function
> > > AddressOf (For class members, this operator returns a reference> a> class> > > function in the form of a delegate instance)
> > > delegate
> > >
> > > Callback
> > > n/a
> > > n/a
> > >
> > > Declare that an object can be modified asynchronously
> > > n/a
> > > volatile
> > >
> > > Force explicit declaration of variables
> > > Option Explicit
> > > n/a. (All variables must be declared prior to use)
> > >
> > > Test for an object variable that does not refer to an object
> > > obj = Nothing
> > > obj == null
> > >
> > > Value of an object variable that does not refer to an object
> > > Nothing
> > > null
> > >
> > > Test for a database null expression
> > > IsDbNull
> > > n/a
> > >
> > > Test whether a Variant variable has been initialized
> > > n/a
> > > n/a
> > >
> > > Define a default property
> > > Default NEW
> > > by using indexers
> > >
> > >
> > > Object-Oriented Programming
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Refer to a base class
> > > MyBase NEW
> > > base
> > >
> > > Declare an interface
> > > Interface NEW
> > > interface
> > >
> > > Specify an interface to be implemented
> > > Implements (statement)
> > > class C1 : I1
> > >
> > > Declare a class
> > > Class NEW <implementation>
> > > class
> > >
> > > Specify that a class can only be inherited. An instance of the> wish> > > cannot be created.
> > > MustInherit NEW
> > > abstract
> > >
> > > Specify that a class cannot be inherited
> > > NotInheritable NEW
> > > sealed
> > >
> > > Declare an enumerated type
> > > Enum <members> End Enum
> > > enum
> > >
> > > Declare a class constant
> > > Const
> > > const (Applied to a field declaration)
> > >
> > > Derive a class from a base class
> > > Inherits C2 NEW
> > > class C1 : C2
> > >
> > > Override a method
> > > Overrides NEW
> > > override
> > >
> > > Declare a method that must be implemented in a deriving class
> > > MustOverride NEW
> > > abstract
> > >
> > > Declare a method that can't be overridden
> > > NotOverridable NEW (Methods are not overridable by default.)
> > > sealed
> > >
> > > Declare a virtual method, property (Visual Basic), or property
> > > accessor (C#, C++)
> > > Overridable
> > > virtual
> > >
> > > Declare a typesafe reference to a class method
> > > Delegate NEW
> > > delegate
> > >
> > > Specify that a variable can contain an object whose events you> Basic)> > to> > WithEvents> > > handle
> > > WithEvents
> > > (Write code - no specific keyword)
> > >
> > > Specify the events for which an event procedure will be called
> > > Handles NEW (Event procedures can still be associated with a> > package> > > variable by naming pattern.)
> > > n/a
> > >
> > > Evaluate an object expression once, in order to access multiple
> > > members
> > > With objExpr <.member> <.member> End With
> > > n/a
> > >
> > >
> > > Exception Handling
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Structured exception handling
> > > Try NEW <attempt>
> > > Catch
> > > <handle errors>
> > > Finally
> > > <always execute>
> > > End Try
> > > try, catch, finally,
> > > throw
> > >
> > > C++ exception handling
> > > n/a
> > > n/a
> > >
> > >
> > > Decision Structures
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Decision structure
> > > (selection)
> > > Select Case ., Case, Case Else, End Select
> > > switch, case, default, goto, break
> > >
> > > Decision structure (if . then)
> > > If . Then, ElseIf . Then, Else, End If
> > > if, else
> > >
> > > Loop structure (conditional)
> > > While, Do [While, Until] ., Loop [While, Until]
> > > do, while, continue
> > >
> > > Loop structure
> > > (iteration)
> > > For ., [Exit For,] Next
> > >
> > > For Each ., [Exit For,] Next
> > > for, foreach
> > >
> > >
> > > Arrays
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Declare an array
> > > Dim a() As Long
> > > int[] x = new int[5];
> > >
> > > Initialize an array
> > > Dim a() As Long = {3, 4, 5}
> > > int[] x = new int[5] {1, 2, 3, 4, 5};
> > >
> > > Reallocate array
> > > Redim
> > > n/a
> > >
> > >
> > > Class Scope
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Visible outside the project or assembly
> > > Public
> > > public
> > >
> > > Invisible outside the assembly (C#/Visual Basic) or within the> > > (Java, JScript)
> > > Friend
> > > internal
> > >
> > > Visible only within the project (for nested classes, within the
> > > enclosing class)
> > > Private
> > > private
> > >
> > >
> > > Member Scope
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Accessible outside class and project (Java/JScript/C++/Visual>> > module> > > or module (Visual Basic)
> > > Public
> > > public
> > >
> > > Accessible outside the class, but within the project (C#, Visual
> > > Basic, C++) or package (Java, JScript)
> > > Friend
> > > internal
> > >
> > > Only accessible within class (Java/JScript/C++/Visual Basic) or> > members> > > (Visual Basic)
> > > Private
> > > private
> > >
> > > Only accessible to current and derived classes
> > > Protected NEW
> > > protected
> > >
> > > Specify that a function or another class has access to private> >> > > of the declaring class
> > > n/a
> > > n/a
> > >
> > > Protected inside the assembly and private to other assemblies
> > > n/a
> > > n/a
> > >
> > >
> > > Misc. Lifetime
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Preserve procedure's local variables
> > > Static11
> > > n/a
> > >
> > > Shared by all instances of a class
> > > Shared NEW
> > > static
> > >
> > >
> > > Misc.
> > > Purpose
> > > Visual Basic Keyword
> > > C# NEW Keyword
> > >
> > > Comment code
> > > '
> > >
> > > Rem
> > > //, /* */ for multiline comments
> > >
> > > /// for XML comments
> > >
> > > Case-sensitive?
> > > No
> > > Yes
> > >
> > > Call Windows API
> > > Declare <API>
> > > use Platform Invoke
> > >
> > > Declare and raise an event
> > > Event, RaiseEvent
> > > Event
> > >
> > > Threading primitives
> > > SyncLock
> > > Lock
> > >
> > > Go to
> > > Goto
> > > Goto
> > >
> > >
> > >
> > >
> > > "Rafey" <shusain@abacusoft.com> wrote in message
> > > news:e5bdaae#CHA.3208@TK2MSFTNGP11.phx.gbl...
> > > > Hello,
> > > >
> > > > What are the disadvantages of VB.NET as compared to C#.
> > > >
> > > > What C# provides which VB.NET does not.
> > > >
> > > > Should we use C# for new .NET rather ASP.NET projects.
> > > >
> > > > Thanks,
> > > > Rafey.
> > > >
> > > >
> > > >
> > >
> > >
> >
>
Alan Guest
-
Lucvdv #2
Re: VB.NET or C# for new .NET porjects
On Sun, 6 Apr 2003 16:45:54 -0700, "Steve C. Orr, MCSD"
<Steve@Orr.net> wrote:
After they read this, and if they believe it, they just might have a> Of course you can tell your programmers not to write unsafe code, but they
> might not listen. Most managers tell their programmers not to put easter
> eggs in, and not to write back doors or obvious security holes. But history
> shows programmers don't always pay much attention to such requests.
> Some project managers are more technical that others. Some come from more
> of a business background than a programming background.
> I can think of some competent project managers I've had that wouldn't know
> how to check if there was unsafe code buried deep within a large, complex
> project. If their programmers are using VB.NET then they are safe.
false feeling of safety if their programmers use VB.Net.
Take "Declare" (the VB keyword). Opinions may differ, but I'd
consider unsafe C# code safe in comparison.
Lucvdv Guest



Reply With Quote

