[Mono-list] C# Unsafe Code (was evangelizing mono)
Richard Norman
Jazzynupe@sbcglobal.net
Wed, 18 Feb 2004 23:13:25 -0800
This is a multi-part message in MIME format.
------=_NextPart_000_0201_01C3F674.CF9BF690
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
I did not mean to suggest that the CLI was better or worse, what I was =
trying to refer to was the "unsafe" keyword. If I remember correctly =
Java "frowned" on this capability (direct pointer manipulation).
=20
But besides that, just some of the nice features of C# make it worth =
while. I didn't mean to start the wars again :-) ... more or less, =
citing some information I read on various sites and documentation. I =
have not tried or used "unsafe" code at all. but it stands to reason =
that if you bypass the GC management and manipulation, you get "close to =
the metal" type of performance. But again, I will say that I have not =
tried it myself.
=20
Here are some examples of what I am referring to in a few web sites.
=20
http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp=
/Q_20831609.html
=20
http://www.codeproject.com/csharp/unsafe.asp
=20
http://www.codesta.com/knowledge/technical/csharp_clr/page_03.jsp
=20
http://www.yasd.com/tutorials/c_sharp/chap17_1.htm =
<http://www.yasd.com/tutorials/c_sharp/chap17_2.htm>=20
=20
http://authors.aspalliance.com/gaurav/unsafe_program.aspx
=20
http://www.google.com/search?q=3D%2B%22C%23%22+%2Bunsafe =
<http://www.google.com/search?q=3D%2B%22C%23%22+%2Bunsafe&hl=3Den&lr=3D&i=
e=3DUTF-8&oe=3DUTF-8&start=3D0&sa=3DN> =
&hl=3Den&lr=3D&ie=3DUTF-8&oe=3DUTF-8&start=3D0&sa=3DN
=20
Hopefully this clarifies what I was saying a little bit. ( Watch our for =
Line Wraps)
=20
Sincerely,
=20
Richard Norman
Web/Application Developer
=20
<http://www.jazzynupe.net/> http://www.Jazzynupe.net
<http://jazzynupe.no-ip.com/> http://Jazzynupe.no-ip.com/
=20
=20
*****************************************************
Message: 2
Subject: Re: [Mono-list] FW: evangelizing mono
From: Jakub Hegenbart <kyosuke@seznam.cz>
To: mono-list@lists.ximian.com
Date: Wed, 18 Feb 2004 15:44:42 +0100
V =C3=84=E2=80=9A=C3=82=C5=A1t, 17. 02. 2004 v 11:59, Radu-Adrian =
Popescu p=C3=84=E2=80=9A=C3=82=C3=84=C2=B9=C3=84=E2=80=9Ee:
> I think you're plain wrong calling C# bare metal performance when=20
> you've used that exact phrase to describe C++'s performance.
> I'm not Java against .NET here, but:
> Like it or not, the JVM's performance is superior to that of the .NET=20
> VM, and it sometimes outperforms even C++ native code. This is not=20
> FUD, it's not lets-do-it-this-way-cos-it-will-prove-me-right=20
> benchmarking, it's due to the differences in the way some code you=20
> wrote runs: compiled once to native code versus compiled to byte-code=20
> and then re-compiled and profiled and adjusted multiple times during=20
> run-time.
> This performance improvement has often been noticed when doing stuff=20
> like regexp or xml.
> I don't really see any reason the .NET VM would not achieve this state =
> of the art, but it's just not there yet. Naturally there's loads of=20
> other areas where .NET is faster than Java, take for one GUI=20
> applications. But that's a corner-case (no, don't start cursing, it's=20
> probably more important than regexp or recursive methods) compared to=20
> the raw ability of dynamically re-writing and optimising pieces of=20
> code. And hey, let's not forget Java/IBM's SWT :-)
>=20
> Cheers,
Yes, today's JVM is an amazing thing. Even if it consumes more memory =
than C#, C++ and C apps (but not much more than C#!), the speed is =
amazing if you imagine the level of abstraction it allows while staying =
almost at par with native compiled code.
The CLI might be technologially more advance by the means of the IL =
expressivness, but ain ll the implementations (even in Mono :), there =
are still many things to improve. (Having said that, there were many =
things done already. Thanks, Ximian!) CLI needs a few more years. And =
yes, Java's denial of AOT compilation might really be compensated by =
dynamic recompilation features more than adequately.=20
For an server app, it doesn't matter how fast it starts (well, ALMOST =
doesnt :). The only important thing is how fast it runs and even if Gtk#
+ C# responds faster than Swing-based Java GUI on my Linux-powered
notebook, how can it be that JVM (Sun JVM 1.4.2) is some 20% slower than
C++ (GCC 3.2 -O switch) on an equivalent piece of code, while C# (Mono
0.30) is twice that slow? (I wrote some simple code to prove late/early =
binding calls efficiency and the results were exactly the same for both =
version on all three languages.)
For me, personally, the most beautiful things on Mono are its GPLness =
and ust (althougn not explicit) anti-MS-monopoly orientation (the second =
goes for Java as well of course). That doesn't mean i'm an anti-MS =
zealot, that means that i just happen to like alternatives :) If the =
language behind CLR was Java, i wouldn't mind.
And with Mono, the "bare metal performace" still lies far ahead. Which =
is nothing wrong - it would be if it stayed this way but i strongly =
diselieve that Mono won't develop. The momentum seems to be there =
already.=20
Just my humble opinion. Competition is good! (somebody should finally =
exlain it to the Redmond company :)
Jakub Hegenbart
------=_NextPart_000_0201_01C3F674.CF9BF690
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2800.1400" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial>I did not mean =
to suggest=20
that the CLI was better or worse, what I was trying to refer to was the =
"unsafe"=20
keyword. If I remember correctly Java "frowned" on this capability =
(direct=20
pointer manipulation).</FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial>But besides =
that, just some=20
of the nice features of C# make it worth while. I didn't mean to start =
the wars=20
again :-) ... more or less, citing some information I read on various =
sites and=20
documentation. I have not tried or used "unsafe" code at all. but it =
stands to=20
reason that if you bypass the GC management and manipulation, you get =
"close to=20
the metal" type of performance. But again, I will say that I have not =
tried it=20
myself.</FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial>Here are some =
examples of=20
what I am referring to in a few web sites.</FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://www.experts-exchange.com/Programming/Programming_Languages=
/C_Sharp/Q_20831609.html">http://www.experts-exchange.com/Programming/Pro=
gramming_Languages/C_Sharp/Q_20831609.html</A></FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://www.codeproject.com/csharp/unsafe.asp">http://www.codeproj=
ect.com/csharp/unsafe.asp</A></FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://www.codesta.com/knowledge/technical/csharp_clr/page_03.jsp=
">http://www.codesta.com/knowledge/technical/csharp_clr/page_03.jsp</A></=
FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://www.yasd.com/tutorials/c_sharp/chap17_1.htm">http://www.ya=
sd.com/tutorials/c_sharp/chap17_1.htm</A><A=20
href=3D"http://www.yasd.com/tutorials/c_sharp/chap17_2.htm"></A></FONT></=
SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://authors.aspalliance.com/gaurav/unsafe_program.aspx">http:/=
/authors.aspalliance.com/gaurav/unsafe_program.aspx</A></FONT></SPAN></DI=
V>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial><A=20
href=3D"http://www.google.com/search?q=3D%2B%22C%23%22+%2Bunsafe&hl=3D=
en&lr=3D&ie=3DUTF-8&oe=3DUTF-8&start=3D0&sa=3DN">http=
://www.google.com/search?q=3D%2B%22C%23%22+%2Bunsafe&hl=3Den&lr=3D=
&ie=3DUTF-8&oe=3DUTF-8&start=3D0&sa=3DN</A></FONT></SPAN>=
</DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT face=3DArial>Hopefully this =
clarifies=20
what I was saying a little bit. ( Watch our for Line =
Wraps)</FONT></SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004><FONT =
face=3DArial></FONT></SPAN> </DIV>
<DIV><SPAN class=3D793390205-19022004>
<DIV align=3Dleft><FONT face=3DArial>Sincerely,</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial></FONT> </DIV>
<DIV align=3Dleft><FONT face=3DArial>Richard Norman</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial>Web/Application =
Developer</FONT></DIV>
<DIV align=3Dleft><FONT face=3DArial></FONT> </DIV>
<DIV align=3Dleft><A href=3D"http://www.jazzynupe.net/"><FONT=20
face=3DArial>http://www.Jazzynupe.net</FONT></A></DIV>
<DIV align=3Dleft><A href=3D"http://jazzynupe.no-ip.com/"><FONT=20
face=3DArial>http://Jazzynupe.no-ip.com/</FONT></A></DIV>
<DIV align=3Dleft><FONT face=3DArial size=3D2></FONT> </DIV><FONT=20
face=3DArial></FONT></SPAN></DIV>
<DIV><FONT face=3DArial></FONT> </DIV>
<DIV><SPAN class=3D793390205-19022004><FONT=20
face=3DArial>*****************************************************</FONT>=
</SPAN></DIV>
<DIV><SPAN class=3D793390205-19022004>
<P>Message: 2</P>
<P>Subject: Re: [Mono-list] FW: evangelizing mono</P>
<P>From: Jakub Hegenbart <kyosuke@seznam.cz></P>
<P>To: mono-list@lists.ximian.com</P>
<P>Date: Wed, 18 Feb 2004 15:44:42 +0100</P>
<P>V =C3=84=E2=80=9A=C3=82=C5=A1t, 17. 02. 2004 v 11:59, Radu-Adrian =
Popescu p<FONT=20
face=3D"Courier New">=C3=84=E2=80=9A=C3=82=C3=84</FONT>=C2=B9=C3=84<FONT =
face=3D"Courier New">=E2=80=9E</FONT>e:</P>
<P>> I think you're plain wrong calling C# bare metal performance =
when </P>
<P>> you've used that exact phrase to describe C++'s performance.</P>
<P>> I'm not Java against .NET here, but:</P>
<P>> Like it or not, the JVM's performance is superior to that of the =
.NET=20
</P>
<P>> VM, and it sometimes outperforms even C++ native code. This is =
not </P>
<P>> FUD, it's not lets-do-it-this-way-cos-it-will-prove-me-right =
</P>
<P>> benchmarking, it's due to the differences in the way some code =
you </P>
<P>> wrote runs: compiled once to native code versus compiled to =
byte-code=20
</P>
<P>> and then re-compiled and profiled and adjusted multiple times =
during=20
</P>
<P>> run-time.</P>
<P>> This performance improvement has often been noticed when doing =
stuff=20
</P>
<P>> like regexp or xml.</P>
<P>> I don't really see any reason the .NET VM would not achieve this =
state=20
</P>
<P>> of the art, but it's just not there yet. Naturally there's loads =
of </P>
<P>> other areas where .NET is faster than Java, take for one GUI =
</P>
<P>> applications. But that's a corner-case (no, don't start cursing, =
it's=20
</P>
<P>> probably more important than regexp or recursive methods) =
compared to=20
</P>
<P>> the raw ability of dynamically re-writing and optimising pieces =
of </P>
<P>> code. And hey, let's not forget Java/IBM's SWT :-)</P>
<P>> </P>
<P>> Cheers,</P>
<P>Yes, today's JVM is an amazing thing. Even if it consumes more memory =
than=20
C#, C++ and C apps (but not much more than C#!), the speed is amazing if =
you=20
imagine the level of abstraction it allows while staying almost at par =
with=20
native compiled code.</P>
<P>The CLI might be technologially more advance by the means of the IL=20
expressivness, but ain ll the implementations (even in Mono :), there =
are still=20
many things to improve. (Having said that, there were many things done =
already.=20
Thanks, Ximian!) CLI needs a few more years. And yes, Java's denial of =
AOT=20
compilation might really be compensated by dynamic recompilation =
features more=20
than adequately. </P>
<P>For an server app, it doesn't matter how fast it starts (well, ALMOST =
doesnt=20
:). The only important thing is how fast it runs and even if Gtk#</P>
<P>+ C# responds faster than Swing-based Java GUI on my =
Linux-powered</P>
<P>notebook, how can it be that JVM (Sun JVM 1.4.2) is some 20% slower =
than</P>
<P>C++ (GCC 3.2 -O switch) on an equivalent piece of code, while C# =
(Mono</P>
<P>0.30) is twice that slow? (I wrote some simple code to prove =
late/early=20
binding calls efficiency and the results were exactly the same for both =
version=20
on all three languages.)</P>
<P>For me, personally, the most beautiful things on Mono are its GPLness =
and ust=20
(althougn not explicit) anti-MS-monopoly orientation (the second goes =
for Java=20
as well of course). That doesn't mean i'm an anti-MS zealot, that means =
that i=20
just happen to like alternatives :) If the language behind CLR was Java, =
i=20
wouldn't mind.</P>
<P>And with Mono, the "bare metal performace" still lies far ahead. =
Which is=20
nothing wrong - it would be if it stayed this way but i strongly =
diselieve that=20
Mono won't develop. The momentum seems to be there already. </P>
<P>Just my humble opinion. Competition is good! (somebody should finally =
exlain=20
it to the Redmond company :)</P>
<P>Jakub Hegenbart</P></SPAN></DIV></BODY></HTML>
------=_NextPart_000_0201_01C3F674.CF9BF690--