C++ template metaprogramming in C#?

P

Phlip

Joe said:
I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:
http://en.wikipedia.org/wiki/Template_metaprogramming.

This newsgroup is only qualified to discuss C++. You'd get the best answer
for that _side_ of this question on a CSharp newsgroup.

And note that template metaprogramming is very hard, so you might also need
to consider programming time instead of execution time.
 
J

Joe Greer

Hi,

I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:
http://en.wikipedia.org/wiki/Template_metaprogramming.

Thanks to all.

My recollection is that the latest .NET and C# support generics and call
them templates, but it isn't quite as flexible as the C++ template
mechanism. Some consider it a good thing while others consider it a bad
thing. In any case, I doubt the experience in one will transfer all that
well to the other. Your favorite C# newsgroup will have more details of
the .NET stuff.

joe
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Hi,

I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:
http://en.wikipedia.org/wiki/Template_metaprogramming.

C# has generics, which provide some of the functionality of templates
(however not the interesting ones IMO). There are a number of articles
comparing templates and generics, but it can be hard to understand the
difference if you don't know templates.

If you google for "generics templates compare" or something like that
you should find some articles to read.
 
P

Phlip

Joe said:
For information to all of you C++ lovers:

http://blogs.msdn.com/csharpfaq/archive/2004/03/12/88913.aspx

Template metaprogramming

C++ templates are sometimes used for a technique known as template
metaprogramming. There is no way to do this in C#.

Template metaprogramming is the standard answer to the FAQ "How do we use
C++ to crunch a lot of numbers?" That's why I answered with it. You would
use MT to write data engines, such as the innards of a Regexp system, or a
data mining engine, or a system to rotate 3D objects.

When you start a project, you cannot select your language based on asking a
newsgroup "which one is faster?" Each newsgroup will naturally declare
their own language is faster! You need to look at many other factors,
beginning with what languages you are familiar with. C++ without MT is
still faster than any C#. But the speed of C++ will not help you if you
take too long to learn the language. Depending on your project, the speed
of C# might do fine.

Next, you need to look at what libraries and tools are available, and how
close they come to your project. You need to audition these, and determine
if a solution for your problem is already available, off the shelf.
 
I

iu2

Hi,

I found a concept named template metaprogramming that can be used in C+
+ code at compile-time. I am a beginner at C++. But I am a programmer
on the .NET platform. Do you know if template metaprogramming is
supported in C# (.NET)? For reference I found it:http://en.wikipedia.org/wiki/Template_metaprogramming.

Thanks to all.

In case you would like to know, metaprogramming is an essential and a
very powerful capability of other programming languages, most notably
Lisp (although it is not called 'metaprogramming' but simply, macros).
 
P

Phlip

iu2 said:
In case you would like to know, metaprogramming is an essential and a
very powerful capability of other programming languages, most notably
Lisp (although it is not called 'metaprogramming' but simply, macros).

Like I said elsewhere, each language has a different capacity to scrunch
down on its own template system's output opcodes. C++ has a remarkably
competitive ability there. So don't look to other template/macro/meta
systems to provide speed. Some provide remarkable slowness! (-;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top