For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > June 2007 > Tightest integration of C++ and C#









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tightest integration of C++ and C#
2b|!2b==?

2007-06-28, 7:11 pm

Die-hard C++ enthusiast hear (only been recently converted - actually
dragged kicking and screaming to ASP.net).

I have loads of C++ libraries - what is the technology/methodolgy that
provides the tightest integration of C++ and the .Net languages (C#
especially - since that is my target language)

BTW, preference is given to methodologies/technologies that involve the
least learning curve (from a seasoned C++ programmers point of view).
Mike

2007-06-28, 7:11 pm

you know there is C++.NET right? Though I don't know C++, I'm assuming you
can still use what you have and just call them from the C# app.

Again, I don't know C++ to save my life, just .NET so I may be wrong. But
there is a C++.NET


http://msdn2.microsoft.com/en-us/visualc/default.aspx



"2b|!2b==?" <root@your.box.com> wrote in message
news:IIidnUuVUuntQB7bnZ2dnUVZ8t6pnZ2d@bt
.com...
> Die-hard C++ enthusiast hear (only been recently converted - actually
> dragged kicking and screaming to ASP.net).
>
> I have loads of C++ libraries - what is the technology/methodolgy that
> provides the tightest integration of C++ and the .Net languages (C#
> especially - since that is my target language)
>
> BTW, preference is given to methodologies/technologies that involve the
> least learning curve (from a seasoned C++ programmers point of view).



bruce barker

2007-06-28, 7:11 pm

the best is managed C++ as you can add C# entry points and ref .net
objects directly.

the second best is use simple objects and use pinvoke from c# to call
the C++ code. if you use winapi standard entry points, you can just use
C# declarations to call the libraries.

the last is to use com. this requires discipline in C# to release ref
counters when done (the GC will do it automactally but usually not soon
enough).

there are 4 learning curves:

the .net runtime library which is huge (quick transition if you have
done java).

the asp.net page model and events handling. this is really a stateless
request response model. a class instance is created and destroyed for
each request. (a button click is really a request). also as all requests
are handled by the same application, but seperate threads, statics need
be avoided. also as a single request may change threads, no thread local
storage should be used.

html/css - enough said.

ajax/javascript (WEB 2.0). this is turning into the most important new
technology for web pages.


note: there is probably no advantage in using C++ on a website, release
the blanket.

-- bruce (sqlwork.com)


2b|!2b==? wrote:
> Die-hard C++ enthusiast hear (only been recently converted - actually
> dragged kicking and screaming to ASP.net).
>
> I have loads of C++ libraries - what is the technology/methodolgy that
> provides the tightest integration of C++ and the .Net languages (C#
> especially - since that is my target language)
>
> BTW, preference is given to methodologies/technologies that involve the
> least learning curve (from a seasoned C++ programmers point of view).

2b|!2b==?

2007-06-28, 7:11 pm

> 2b|!2b==? wrote:
>

Top posted comments moved down here ... |
V

bruce barker wrote:
[color=darkred]
> the best is managed C++ as you can add C# entry points and ref .net
> objects directly.
>


Erm, no thanks. I have resisted Microsoft forcibly over the years
because of they are (or have been) extremely keen on vendor "lock in"
and non-portable code. I think even the great Redmond company have
realized the futility of this approach in todays open standards world -
and AFAIk, they've canned this silly language along with its bizzare
non-standard "C++" syntax.

> the second best is use simple objects and use pinvoke from c# to call
> the C++ code. if you use winapi standard entry points, you can just use
> C# declarations to call the libraries.
>


This looks like the most viable option - although I was (somehow) hoping
I could get around marshalling large chunks of data around.

> the last is to use com. this requires discipline in C# to release ref
> counters when done (the GC will do it automactally but usually not soon
> enough).
>


Also a potential contender as I can easily right ATL COM wrappers around
my C++ classes), I was hoping this would provide tighter integration -
since the (C#) syntax i've seen so far looked less "exotic" ...., still
I guess I'll have to weigh up the Pros and con's (i.e. workload) between
the COM wrappers and Pinvoke approach.

> there are 4 learning curves:
>
> the .net runtime library which is huge (quick transition if you have
> done java).
>


Yeah C# is (mostly) Java and C++ repackaged and branded as a new language :P
I've done some Java programming in the past and had to do a "double
take" when I first saw a C# code snippet.

> the asp.net page model and events handling. this is really a stateless
> request response model. a class instance is created and destroyed for
> each request. (a button click is really a request). also as all requests
> are handled by the same application, but seperate threads, statics need
> be avoided. also as a single request may change threads, no thread local
> storage should be used.
>

Ok, so there is more to it than simple wrapping the classes up. Since
state must somehow be maintained. For "heavy" objects - you can't go
about creating them from scratch at each request - there must be a way
of creating object pools or something similar server side ...

> html/css - enough said.
>
> ajax/javascript (WEB 2.0). this is turning into the most important new
> technology for web pages.
>
>
> note: there is probably no advantage in using C++ on a website, release
> the blanket.


True, apart from the fact that I have over 10 years worth of custom
business logic in C++ libraries (where it is likely to stay) - until
decompiling code from compiled .Net binaries requires AT LEAST some
effort. At the moment decompilation/deobfuscation (even to the point of
recovering source code comments) is almost TRIVIAL.
>
> -- bruce (sqlwork.com)
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com