www.digitalmars.com         C & C++   DMDScript  

D - C#

reply "Pavel Minayev" <evilone omen.ru> writes:
Does anybody has C#? If you do, could you please tell
if it has module(s) with WinAPI declarations?
Feb 07 2002
parent reply "Richard Krehbiel" <rich kastle.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a3ufj4$1o6d$1 digitaldaemon.com...
 Does anybody has C#? If you do, could you please tell
 if it has module(s) with WinAPI declarations?

Like Java, C# always and only runs code within a "virtual machine." I'm only aware of one way to link to a C# module from a C program, and that's via OLE - and you'll never ever want to code OLE in C, so just forget about it. -- Richard Krehbiel, Arlington, VA, USA rich kastle.com (work) or krehbiel3 home.com (personal)
Feb 08 2002
next sibling parent "Sean L. Palmer" <spalmer iname.com> writes:
"Richard Krehbiel" <rich kastle.com> wrote in message
news:a40njn$1r2s$1 digitaldaemon.com...
 "Pavel Minayev" <evilone omen.ru> wrote in message
 news:a3ufj4$1o6d$1 digitaldaemon.com...
 Does anybody has C#? If you do, could you please tell
 if it has module(s) with WinAPI declarations?

Like Java, C# always and only runs code within a "virtual machine." I'm only aware of one way to link to a C# module from a C program, and that's via OLE - and you'll never ever want to code OLE in C, so just forget

 it.

That's not entirely true... it's supposedly *always* JIT compiled, but the entire program is JIT compiled on run. C# runs as natively as C does, aside from the app load time hit for the JIT compiler. In fact I believe this applies to all .NET programs. Sean
Feb 08 2002
prev sibling parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Richard Krehbiel" <rich kastle.com> wrote in message
news:a40njn$1r2s$1 digitaldaemon.com...

 Like Java, C# always and only runs code within a "virtual machine."  I'm
 only aware of one way to link to a C# module from a C program, and that's
 via OLE - and you'll never ever want to code OLE in C, so just forget

 it.

I don't want to link to C# module. I want it's modules that resembe windows.h and friends in C/C++ - those that have all WinAPI functions, structures and macroses declared. I believe there are some there, aren't they? And can you share them?
Feb 08 2002
next sibling parent reply "D" <s_nudds hotmail.com> writes:
C# is not a replacement for C, but a competitor to Java.
How do you expect Microsoft to provide a secure environment for C# apps if
they
can access the Win32API?

Pavel Minayev <evilone omen.ru> wrote in message
news:a419hp$2keg$1 digitaldaemon.com...
 I don't want to link to C# module. I want it's modules that resembe
 windows.h and friends in C/C++ - those that have all WinAPI functions,
 structures and macroses declared. I believe there are some there,
 aren't they? And can you share them?

Feb 10 2002
parent reply "Mike Greenly" <mike mikegreenly.com> writes:
You can link directly to any Windows native dll, also the Common Language
Runtime (Microsoft's VM) allows managed code to freely interact with
unmanaged code.  It is possible to use and manipulate unmanaged memory from
C#, it uses the same pointer notation as C/C++.

It's NOT possible to create a native exe/dll with C#.  Even if you don't use
the .NET framework as your run time library the assembly created at compile
time is not native it needs the shell host (the CLR tied into the windows
shell) to load and run.

Has anyone wrapped the WinApi for easy consumption by C# apps?  Not that
I've run across yet, but I have seen small pieces wrapped here and there...
I've even wrapped a few pieces for my own consumtion, but I would not
recomend doing it just because your not willing to learn the .Net Framework.
With no hard numbers to back it up... I'm guessing my code output has
tripled using the .Net Framework vs. C++ Standard Libs.


"D" <s_nudds hotmail.com> wrote in message
news:a45fso$1mta$1 digitaldaemon.com...
 C# is not a replacement for C, but a competitor to Java.
 How do you expect Microsoft to provide a secure environment for C# apps if
 they
 can access the Win32API?

 Pavel Minayev <evilone omen.ru> wrote in message
 news:a419hp$2keg$1 digitaldaemon.com...
 I don't want to link to C# module. I want it's modules that resembe
 windows.h and friends in C/C++ - those that have all WinAPI functions,
 structures and macroses declared. I believe there are some there,
 aren't they? And can you share them?


Feb 10 2002
parent reply "Pavel Minayev" <evilone omen.ru> writes:
"Mike Greenly" <mike mikegreenly.com> wrote in message
news:a461oc$1u00$1 digitaldaemon.com...
 You can link directly to any Windows native dll, also the Common Language

 Has anyone wrapped the WinApi for easy consumption by C# apps?  Not that
 I've run across yet, but I have seen small pieces wrapped here and

You mean that Micro$oft didn't provide API declarations with C# ???
Feb 10 2002
parent reply "Walter" <walter digitalmars.com> writes:
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a46991$218s$1 digitaldaemon.com...
 "Mike Greenly" <mike mikegreenly.com> wrote in message
 news:a461oc$1u00$1 digitaldaemon.com...
 You can link directly to any Windows native dll, also the Common


 Has anyone wrapped the WinApi for easy consumption by C# apps?  Not that
 I've run across yet, but I have seen small pieces wrapped here and

You mean that Micro$oft didn't provide API declarations with C# ???

That pretty much lets that implementation of C# out of being a systems programming language.
Feb 10 2002
next sibling parent "D" <s_nudds hotmail.com> writes:
C# and the other .net lanaguages are intended for web component and network
based distributed program development.

System secutity requirements are such that Win32 API access is to be
avoided.

You can't provide security without restricting the programmer.

Do you want security?  Or do you want foolishness?

Walter <walter digitalmars.com> wrote in message
news:a46hpg$24mn$1 digitaldaemon.com...
 You mean that Micro$oft didn't provide API declarations with C# ???

That pretty much lets that implementation of C# out of being a systems programming language.

Feb 11 2002
prev sibling parent johnwhited hotmail.com writes:
What does make C# unusable for systems programming is all the marshalling that's
done between trusted and untrusted interface done via COM+. Another thing that
makes it unusable is the garbage collection. It's actually broke - since somehow
it slipped that GC allocated objects in VM should also be garbage collected. 

In article <a46hpg$24mn$1 digitaldaemon.com>, Walter says...
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a46991$218s$1 digitaldaemon.com...
 "Mike Greenly" <mike mikegreenly.com> wrote in message
 news:a461oc$1u00$1 digitaldaemon.com...
 You can link directly to any Windows native dll, also the Common


 Has anyone wrapped the WinApi for easy consumption by C# apps?  Not that
 I've run across yet, but I have seen small pieces wrapped here and

You mean that Micro$oft didn't provide API declarations with C# ???

That pretty much lets that implementation of C# out of being a systems programming language.

Nov 14 2002
prev sibling parent reply "J. Daniel Smith" <j_daniel_smith deja.com> writes:
You don't (can't) do traditional Win32 API programming in C#; instead, there
is a whole new set of class libraries.

   Dan

"Pavel Minayev" <evilone omen.ru> wrote in message
news:a419hp$2keg$1 digitaldaemon.com...
 "Richard Krehbiel" <rich kastle.com> wrote in message
 news:a40njn$1r2s$1 digitaldaemon.com...

 Like Java, C# always and only runs code within a "virtual machine."  I'm
 only aware of one way to link to a C# module from a C program, and


 via OLE - and you'll never ever want to code OLE in C, so just forget

 it.

I don't want to link to C# module. I want it's modules that resembe windows.h and friends in C/C++ - those that have all WinAPI functions, structures and macroses declared. I believe there are some there, aren't they? And can you share them?

Feb 11 2002
parent reply johnwhited hotmail.com writes:
I'm just now browsing over the pretty stale articles here in the newsgroup.

You can do traditional win32 programming in C# - it's just a real pain. For
instance, I had to bring in all the APIs for registering a service since I find
the managed interfaces to be real garbage.

In article <a48kqp$ir$1 digitaldaemon.com>, J. Daniel Smith says...
You don't (can't) do traditional Win32 API programming in C#; instead, there
is a whole new set of class libraries.

   Dan

"Pavel Minayev" <evilone omen.ru> wrote in message
news:a419hp$2keg$1 digitaldaemon.com...
 "Richard Krehbiel" <rich kastle.com> wrote in message
 news:a40njn$1r2s$1 digitaldaemon.com...

 Like Java, C# always and only runs code within a "virtual machine."  I'm
 only aware of one way to link to a C# module from a C program, and


 via OLE - and you'll never ever want to code OLE in C, so just forget

 it.

I don't want to link to C# module. I want it's modules that resembe windows.h and friends in C/C++ - those that have all WinAPI functions, structures and macroses declared. I believe there are some there, aren't they? And can you share them?


Nov 14 2002
parent reply "David Crowell" <dave davidcrowell.com> writes:
Just to clarify a bit...

C# does allow calling unmanaged code, and any DLL, winapi or not.  However
this will effect what security contexts it can run under.  You can't do it
from, say, a web application on a hosting account.  You won't have the
priveleges.

My opinion:

I like the C# language, and I like the framework for web work, but the
performance for Winforms applications is bad.  I'm used to VB (5 & 6), and
.NET Winforms applications have horrible startup times (while they are
JITed, and while the 8MB of runtime is mapped into virtual memory).

On a busy website, a pre-jitted copy is always available, and the runtime
doesn't unload from memory, so this isn't an issue.

Walter is correct, C#, in its current incarnation, is not usable as a
systems programming language.  I'd really like to see a native code C#
compiler with a smaller, optional library.

Until then, I hope D matures.

Dave
www.davidcrowell.com

<johnwhited hotmail.com> wrote in message
news:ar0rbp$1u1t$1 digitaldaemon.com...
 I'm just now browsing over the pretty stale articles here in the

 You can do traditional win32 programming in C# - it's just a real pain.

 instance, I had to bring in all the APIs for registering a service since I

 the managed interfaces to be real garbage.

 In article <a48kqp$ir$1 digitaldaemon.com>, J. Daniel Smith says...
You don't (can't) do traditional Win32 API programming in C#; instead,


is a whole new set of class libraries.

   Dan


Nov 14 2002
parent reply johnwhited hotmail.com writes:
You can actually turn off all security checking allowing even the web page to
run untrusted code.  Also, you can use other COM libraries that do windowing and
get reasonable performance by writing a custom marshaller that's extremely
optimized if that's really your only complaint about C#.

As far as the loading/unloading behavior, the only way to even get marginal
performance is to keep an extra reference on all components you use in your C#
web application.  Otherwise, it'll get finalized and unloaded as the app domain
goes away.

Just to be clear, I don't think C# is a systems programming language. It's too
fat and it actually is missing some important features for what it was
originally geared (web services).

I can see several things D could add to make it much more popular.

In article <ar1cde$2gtr$1 digitaldaemon.com>, David Crowell says...
Just to clarify a bit...

C# does allow calling unmanaged code, and any DLL, winapi or not.  However
this will effect what security contexts it can run under.  You can't do it
from, say, a web application on a hosting account.  You won't have the
priveleges.

My opinion:

I like the C# language, and I like the framework for web work, but the
performance for Winforms applications is bad.  I'm used to VB (5 & 6), and
.NET Winforms applications have horrible startup times (while they are
JITed, and while the 8MB of runtime is mapped into virtual memory).

On a busy website, a pre-jitted copy is always available, and the runtime
doesn't unload from memory, so this isn't an issue.

Walter is correct, C#, in its current incarnation, is not usable as a
systems programming language.  I'd really like to see a native code C#
compiler with a smaller, optional library.

Until then, I hope D matures.

Dave
www.davidcrowell.com

<johnwhited hotmail.com> wrote in message
news:ar0rbp$1u1t$1 digitaldaemon.com...
 I'm just now browsing over the pretty stale articles here in the

 You can do traditional win32 programming in C# - it's just a real pain.

 instance, I had to bring in all the APIs for registering a service since I

 the managed interfaces to be real garbage.

 In article <a48kqp$ir$1 digitaldaemon.com>, J. Daniel Smith says...
You don't (can't) do traditional Win32 API programming in C#; instead,


is a whole new set of class libraries.

   Dan



Nov 14 2002
parent "Walter" <walter digitalmars.com> writes:
<johnwhited hotmail.com> wrote in message
news:ar23qu$731$1 digitaldaemon.com...
 I can see several things D could add to make it much more popular.

Post a list!
Nov 15 2002