Archived

This topic is now archived and is closed to further replies.

DorRaba

DirectX - VB.NET vs C++

Recommended Posts

DorRaba    122
this is a question I have no answer... is there any difference now when VB.NET has arrived between VB.NET and C++ speed when using DirectX, is there any difference between the performance of DirectX managed and un-managed code, what should I use and with what should I program a DirectX game?

Share this post


Link to post
Share on other sites
Imperil    100
quote:
Original post by DorRaba
this is a question I have no answer... is there any difference now when VB.NET has arrived between VB.NET and C++ speed when using DirectX, is there any difference between the performance of DirectX managed and un-managed code, what should I use and with what should I program a DirectX game?


Managed DirectX runs at about 95-98% of the speed of unmanaged.

BUT

That being said, VB.NET is slower than both C++ and C# as it is not meant for 3D calculations and hardcore math.


If you are going to use managed DX I would use C#, if you are going to use unmanaged DX than use C++.

Share this post


Link to post
Share on other sites
DorRaba    122
I understood that VB.NET is now faster and can work with high speed using directX9, and I wanted to know, what is C# is it like C/C++ or what?

Share this post


Link to post
Share on other sites
atcdevil    145
C# is Microsoft''s answer to Java. At first glance C# seems very similar to Java, moreso than it is to C/C++. But I haven''t had any more than a first glance, so I can''t say more.

If you type in C# in the search function you''ll find a billion discussions on C#.

Share this post


Link to post
Share on other sites
Imperil    100
quote:
Original post by atcdevil
C# is Microsoft's answer to Java. At first glance C# seems very similar to Java, moreso than it is to C/C++. But I haven't had any more than a first glance, so I can't say more.

If you type in C# in the search function you'll find a billion discussions on C#.



wow these misunderstandings come up a lot on these forums =]

C# has nothing to do with Microsoft and Java. Microsoft has released J# which is the answer to Java.

C# was built by Andres in order to have a language specifically meant for development on Windows Longhorn and future managed Windows OS's, it has nothing to do with Java.

Java programmers that want to use .NET can use J# if they want.

[edited by - Imperil on January 18, 2004 2:14:17 PM]

Share this post


Link to post
Share on other sites
Imperil    100
quote:
Original post by DorRaba
I understood that VB.NET is now faster and can work with high speed using directX9, and I wanted to know, what is C# is it like C/C++ or what?


Yes VB.NET is faster than it was, but still falls far behind.

The MSIL code it produces when compiled is very similar to C#, but lacks in two areas and makes execution speed about half that of a C# program.

Basically you want to look at it like this:

Unmanaged C++ (can''t touch this for speed on our current OS)
Managed C# (95-98% of the performance of unmanaged C++)
Managed C++ (85-95% of the performance of unmanaged C++.. I have no idea why sometimes the performance hit is so drastic but I do know it is being optomized non stop)
Managed VB.NET (65-75% of the performance of unmanaged C++)
Unmanaged VB (35-55% of the performance of unmanaged C++)

So yes as you can see VB did step it up HUGE in performance in the last revision, but it still can''t compete with C++ and C#.

It seems odd though, because Microsoft stated that the .NET languages would produce the same MSIL code, and we are seeing different results altogether.

Share this post


Link to post
Share on other sites
Imperil    100
quote:
Original post by alexmoura
imperil, can I ask where you got those results from?


Reports, benchmarking, and testing.

I have my own benchmarks that we had to perform at work, plus there are various released ones online.

I posted on on the forums a couple days back but I forget the link and I''m not sure which post it was on.. it was a posting on C# and it had various benchmarks between all languages.

I will try ot dig it up for you.

Share this post


Link to post
Share on other sites
Hog    122
If you want to get into graphics seriously then I guess C++ is the answer.

If you're interest is as a hobby, just for fun or for non power intensive programs than VB.NET would suit just fine

[edited by - hog on January 18, 2004 7:10:30 PM]

[edited by - hog on January 18, 2004 7:11:09 PM]

Share this post


Link to post
Share on other sites
alexmoura    450
quote:
Original post by Imperil
quote:
Original post by alexmoura
imperil, can I ask where you got those results from?


Reports, benchmarking, and testing.

I have my own benchmarks that we had to perform at work, plus there are various released ones online.

I posted on on the forums a couple days back but I forget the link and I''m not sure which post it was on.. it was a posting on C# and it had various benchmarks between all languages.

I will try ot dig it up for you.



If you could I''d be thankfull - I''m just curious - The only benchmarks I''ve seen so far only put vb noticeably behind C# in file IO while using the compatibility layer.

Share this post


Link to post
Share on other sites
Imperil    100
quote:
Original post by alexmoura
quote:
Original post by Imperil
quote:
Original post by alexmoura
imperil, can I ask where you got those results from?


Reports, benchmarking, and testing.

I have my own benchmarks that we had to perform at work, plus there are various released ones online.

I posted on on the forums a couple days back but I forget the link and I''m not sure which post it was on.. it was a posting on C# and it had various benchmarks between all languages.

I will try ot dig it up for you.



If you could I''d be thankfull - I''m just curious - The only benchmarks I''ve seen so far only put vb noticeably behind C# in file IO while using the compatibility layer.



You are correct, it is the IO system that gives VB.NET the huge hit.

http://img.osnews.com/img/5602/results.jpg

I can''t find the link to the other benchmark, but I can tell you that most of the benchmarking I do myself at work. Usually when a new language/version is released I will run a set of benchmarks on it and analyze the data to determine productivity/performance ratio.

Share this post


Link to post
Share on other sites
Jontay    122
I''m fairly new at directX and I have found that purchasing a few books help immensely. The microsoft SDK example I''ve looked at seem poorly commented, but one could probably learn it through the examples, tutorials, and a lot of work.

Share this post


Link to post
Share on other sites
alexmoura    450
quote:
Original post by Imperil
quote:
Original post by alexmoura


If you could I''d be thankfull - I''m just curious - The only benchmarks I''ve seen so far only put vb noticeably behind C# in file IO while using the compatibility layer.



You are correct, it is the IO system that gives VB.NET the huge hit.

http://img.osnews.com/img/5602/results.jpg

I can''t find the link to the other benchmark, but I can tell you that most of the benchmarking I do myself at work. Usually when a new language/version is released I will run a set of benchmarks on it and analyze the data to determine productivity/performance ratio.


The thing being that you don''t need to use the VB file IO, it''s there mostly for compatibility issues for people who are upgrading code from VB6.

Anyway, thanks.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Show me C# code that runs 20% faster than it''s VB.NET version.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
There are cases where the VB.NET compiler does add a few (2 or 3) more opcodes than the C# compliler(see last paragraph). However, VB.NET is not inherintly slower than C#. That is a popular misconception.

As you have demonstrated, the major source for the misjudged opinion originated from IO tests pitting C# with .Net file io functions against VB with compatability io functions. Not a fair test at all. Re-running the test having VB use the .Net file io functions results in similiar performance.

Also of note, VB.NET does do integer bound checking, especially on for-loops by default, whereas C# does not. This is an option for building, that can be turned on or off depending on the need for performance in the code, but having it on, will result in more ILCODE being produced.

Share this post


Link to post
Share on other sites
GamerSg    378
I also don''t think VB.NET should be any slower than C# unless it is a language feature of VB that is causing slowdown
(Eg: In Java all Objects are allocated on the heap).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
C++ and C# are faster than VB in terms of (Native)code execution. The .Net has nothing to do with the speed of the language. .Net allows you to write platform independent application from the same code. This code is compiled into MSIL, which is stored in an assembly. When this code is executed (either in its own right if it is an executable, or when it is used from other code) it must first be compiled into native code using a JIT compiler. The native code is executed in the context of the managed CLR, along with any other running applications or processes.

Further more, if you use C++ using un-managed code (that is not using the .Net framework) it should be alot faster than C# because the code isn''t compiled (re-compliled) before execution.





Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
C# is not meant just for Windows or Windoes Longhorn! The .Net framework will soon be availble to other platforms including Linux, Unix BeOS and others. C# was built from the ground up to with the .Net framewrok in mind. It is the only language that can use 100% of the framwork.

I agree, it is not Microsoft''s answer to Java. Although, it does address some of the issues that Java does cover like garbase collection and platform-independence.

You guys need to read some books from the pros instead of relying so much on information available on the web. I recommend books from WROX press. Those guys are top notch.

Share this post


Link to post
Share on other sites
Fidelio66    164
You guys do realise that the .NET framework license says: You may not disclose the results of any benchmark test of the .NET Framework component of the OS Components to any third party without Microsoft''s prior written approval.

Share this post


Link to post
Share on other sites
Etnu    880
C# is just one (of several) languages that can be compiled into .Net CLR.

The idea behind .net is similiar to Java, in that programmers can write platform-independent code, that will be optimized by the virtual machine for the particular system they''re running on.

How well that works is debatable, but it''s likely the future of generic / desktop applications, so it''s important to understand how it works.

It''s not really suitable for 3D, due to the speed advantages that can be gained when you''re writing platform-specific, fully compiled code, but it can be used for less computationally expensive games and for virtually any other application that isn''t so speed-critical.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
http://blogs.msdn.com/csharpfaq/archive/2004/03/11/87816.aspx

What are the advantages of C# over VB.NET and vice versa?
The choice between C# and VB.NET is largely one of subjective preference. Some people like C#''s terse syntax, others like VB.NET''s natural language, case-insensitive approach. Both have access to the same framework libraries. Both will perform largely equivalently (with a few small differences which are unlikely to affect most people, assuming VB.NET is used with Option Strict on). Learning the .NET framework itself is a much bigger issue than learning either of the languages, and it''s perfectly possible to become fluent in both - so don''t worry too much about which to plump for. There are, however, a few actual differences which may affect your decision:

VB.NET Advantages
Support for optional parameters - very handy for some COM interoperability
Support for late binding with Option Strict off - type safety at compile time goes out of the window, but legacy libraries which don''t have strongly typed interfaces become easier to use.
Support for named indexers (aka properties with parameters).
Various legacy VB functions (provided in the Microsoft.VisualBasic namespace, and can be used by other languages with a reference to the Microsoft.VisualBasic.dll). Many of these can be harmful to performance if used unwisely, however, and many people believe they should be avoided for the most part.
The with construct: it''s a matter of debate as to whether this is an advantage or not, but it''s certainly a difference.
Simpler (in expression - perhaps more complicated in understanding) event handling, where a method can declare that it handles an event, rather than the handler having to be set up in code.
The ability to implement interfaces with methods of different names. (Arguably this makes it harder to find the implementation of an interface, however.)
Catch ... When ... clauses, which allow exceptions to be filtered based on runtime expressions rather than just by type.
The VB.NET part of Visual Studio .NET compiles your code in the background. While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.
C# Advantages
XML documentation generated from source code comments. (This is coming in VB.NET with Whidbey (the code name for the next version of Visual Studio and .NET), and there are tools which will do it with existing VB.NET code already.)
Operator overloading - again, coming to VB.NET in Whidbey.
Language support for unsigned types (you can use them from VB.NET, but they aren''t in the language itself). Again, support for these is coming to VB.NET in Whidbey.
The using statement, which makes unmanaged resource disposal simple.
Explicit interface implementation, where an interface which is already implemented in a base class can be reimplemented separately in a derived class. Arguably this makes the class harder to understand, in the same way that member hiding normally does.
Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies). Note that unsafe code is still managed code, i.e. it is compiled to IL, JITted, and run within the CLR.
Despite the fact that the above list appears to favour VB.NET (if you don''t mind waiting for Whidbey), many people prefer C#''s terse syntax enough to make them use C# instead.

Share this post


Link to post
Share on other sites