473,971 Members | 12,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

From C++ to C# and back again....

I taught myself C++ a while back, but never got to
involved in actually writing applications with it. I
actually spent the last 6 years working for numerous
internet web firms as well as doing a plethora of
freelance web development work. Lately I started learning
c#. The idea is to stop using coldfusion and switch to
writing c# using asp.net. The advantage I believe is that
I can develop websites and software that reuse code and
are tied together in a Solution. This idea is very
exciting to me.

One of my other passions and interests is game
development. I've looked around at a lot of different
websites and have read over and over again that although
game development with c# is possible; it's just not
pratical, due to peformance issues brought on by
using .net, etc.

It is my understanding, however, that as a .net
application runs the called functions are compiled to
native code through the JIT compiler. Only functions that
are called are compiled, but once compiled, are not
recompiled through the life of the program. In addition to
this, the compiled code is more effecient since it is
compiled specifically for the system and processor it is
running on. And typically speaking, as a .net program
runs; it gets faster and faster (obviously hitting a
plateau when all code is compiled).

If this is the case, wouldn't a game programmed
using .net, have better performance? Isn't it possible to
still use pieces of assembly code or otherwise unsafe code
for specific functions where performance is key?

I was looking at the Mangaged C++ port of the Quake II
engine the other day and was reading that "Running Quake
II.NET in the timedemo test indicates the managed version
performs about 85% as fast as the native version."
(http://www.vertigosoftware.com/Quake2.htm). The didn't do
much explaination as to why the managed version was
slower.

C# itself doesn't seem like it was meant for game
programming. Am I right? What advantages does the C++
language have over C# that makes it better for game
programming (as far as syntax goes, not performance)?

Thank you.
Nov 16 '05
10 1237
Your last sentence, that "You may find ... that the managed code works just
fine", is so true.

I just finished a program where I was doing processing on daily stock
prices, and had 30 years of data to process. I was afraid that this thing
would take days or weeks to do its job, but the managed code could run
through the entire 3.9 million records in about 15 minutes. Rewriting it
for greater speed would have been a waste of my time. Had it taken 15 hours
to do this work, I'd be rewriting it, but at 15 minutes per run it just
doesn't merit extra effort on my part.

It all depends on what you are doing. Managed .NET code is not necessarily
"slow" code relative to your needs, it all depends on what you are doing and
what your requirements are.

On a different part of the same project, I was writing code that hit the
same data over-and-over, and there was a lot of data to hit. In this case,
the key to speed was processing chunks of data that fit into the CPU cache.
When processing 30 MB of data, the speed was 8 loops per second, when
processing 600 KB of data the speed was 2000 loops per second. The extra
hit to read the data from disk in small chunks was trivial compared to the
speedup by getting all my data into the processor's 1 MB cache. A 20 hour
(projected) processing time was cut to 20 minutes. If you see actual
numbers and have a sense for what you are trying to do, you can sometimes
get improvements like this. The two hours of coding I did to rewrite my
algorithm were paid back in my first run of the data.

I'll add one more thought ... the very biggest returns to optimization come
from finding something that you don't actually have to do, and not doing it.
Making "uselessRepetit iveRoutine()" run at maximum speed is no where near as
effective as not calling it in the first place. Every now and then, this
tip makes all the difference.

Tad

"John Puopolo" <jo**********@f astsearch.com.n ospam> wrote in message
news:eG******** ******@TK2MSFTN GP12.phx.gbl...
Hi...

I think the former would work the best. In my experience (15 yrs)
developing software, one tenet has worked well for me... "make it work -
then make it work fast."

It is very difficult if near impossible to determine where your code is
spending its time -- so the only way to know where to optimize it to write
the code (in C#), profile it, then re-write the most-used routines in
C/C++
or assembly to get the speed that you need.

You may find, however, that the managed code works just fine and that you
do
not need to use unmanaged code at all.

John Puopolo

Nov 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2178
by: Chuck Ritzke | last post by:
I keep asking myself this question as I write class modules. What's the best/smartest/most efficient way to send a large object back and forth to a class module? For example, say I have a data access module that creates a large disconnected dataset from a database. I want to pass that dataset back to the calling program. And then perhaps I want to send that dataset to another class module. At first it seems that the "object oriented"...
8
1903
by: Galahad | last post by:
Here's the question: I have a form w/ TextBox controls and a Search Button control. Once the user clicks the Search Button, they get a Modal dialog w/ a datagrid that contains their search results. They select a row and click OK. The return value of the Module triggers an method that populates the TextBoxes w/ values and disables them. After the TextBoxes are disabled, I change the text of the buton to "Search Again" since I have to...
6
2067
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I need to use parts of the tables in datagrids, and here is where my problem lies
7
2587
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently upgraded to VB.NET, and I have a lot of catching up to do. That being said, I have come a long way in a short while, however, I am stumped at the moment. I have read through days of posts, but have not been able to address my specific question, so...
7
11669
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
10
3122
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web config does specify a machinekey setting: <machineKey validationKey="447C05E8B3A71401CC4CAE5513A7F1A3494A3618EE819316AAD1D58433F236A759D66FB4154500E01EB4E1BC1DE42046E2D652D391CB8367A1649438867A02EB"...
15
2023
by: tshad | last post by:
I was looking for a way to handle refreshes (user pressed refresh button) and found a piece of code to check if a Web page was refreshed but I can't get it to work. The code is: ************************************************************ Namespace StevenBey.Web.UI Public Class Page Inherits System.Web.UI.Page
7
8370
by: mohammed.naghman | last post by:
Hi, I have 2 submit buttons in a jsp page. One of them takes me to page2.jsp and also passes the values enetered to page2.I have a link in the page2 that does a history.back to come to the previous page to make any chnages necessary. Now after making my changes, instead of going to page2.jsp if I want to submit the page, Instead of submitting the page it takes me to page2.jsp again. This problem is only with firefox. It works fine...
3
2714
by: Tom | last post by:
Basically I have a page that I load with 10 input fields. If users have JS enabled I want to hide 5 of these fields so as to reduce clutter. If the user needs these extra fields an "Add" button can be used to display the hidden fields one by one. Once the fields a filled in the user submits them for validation and if there are any error They can "Go back" to make some changes. The whole process works great in FF & Opera but IE lets me...
6
844
by: John | last post by:
Hi I have a button which calls a method which in turn calls another method, which in turn calls another method. Let's say in the third method an error occurs and it is no longer possible to continue, how can I dump everything and come out of everything waiting for the user to press the button again to do the process again? Thanks
0
10346
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11805
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11399
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11554
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10900
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10067
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7597
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
5143
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3749
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.