From: Malcolm McLean on 7 Dec 2009 05:53 "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message news > "Malcolm McLean" <regniztar(a)btinternet.com> writes: > >> "Bill Cunningham" <nospam(a)nspam.invalid> wrote in message news: >>> One reason why I am so attracted to C and not just markup languages >>> scripts and java is that C is for designing OS's. What exactley is it >>> about C that makes it good to right operating systems? >>> >> It's very close to assembler. With a few exceptions, all C constructs >> compile to a few machine language instructions. So it's easy in C to keep >> control of how much time your program is taking to execute. >> Since operating systems have to be efficient, this is very valuable. > > Actually, this closeness prevents the compiler to implement most > optimization algorithms that high llevel programming language > compilers can implement, which leads to less efficient code, as soon > as you get out of the microbenchmark. > C won't optimise behind your back, but it won't pessimise either. As a general rule, you are right, it's a lot cheaper to have optimisation done by machine than by hand. However the exception is code in which the investment per line is very high. We're still not at the stage where machines can consistently beat human programmers. We probably are now at the stage where C compilers can beat human assembly-language writers, however.
From: Chris M. Thomasson on 7 Dec 2009 06:09 "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message news:87ocmbf837.fsf(a)galatea.local... > "Chris M. Thomasson" <no(a)spam.invalid> writes: > >> Why do I like C: >> >> http://groups.google.com/group/comp.lang.c/browse_frm/thread/b11dafcbe1079934 > > In Common Lisp, you just use (declare (dynamic-extend <variable>)), > and the compiler implements this "region" allocation (or any other > similar scheme) automatically. That's great! However, I don't use Lisp. Quite frankly, I cannot really use a HLL to do the type of work I am interested in. They are just not flexible enough. C is a perfect medium for me. It saves me the pain of coding everything in assembly language, yet it still allows me enough wiggle room to get the job done. Perhaps it's just because I don't have the proper experience in HLL's. For instance, how could I ensure that memory is aligned to a boundary such that I can steal enough bits in a pointer to embed some meta-data? This can be really important for some algorithms. I don't know how to do that in a HLL. I am also not sure how to efficiently implement a Judy Array in a HLL: http://judy.sourceforge.net/doc/shop_interm.pdf Not sure if a HLL can come close to a C implementation! Humm...
From: bartc on 7 Dec 2009 07:56 "Chris M. Thomasson" <no(a)spam.invalid> wrote in message news:wm5Tm.41628$cd7.2227(a)newsfe04.iad... > "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message > news:87ocmbf837.fsf(a)galatea.local... >> "Chris M. Thomasson" <no(a)spam.invalid> writes: >> >>> Why do I like C: >>> >>> http://groups.google.com/group/comp.lang.c/browse_frm/thread/b11dafcbe1079934 >> >> In Common Lisp, you just use (declare (dynamic-extend <variable>)), >> and the compiler implements this "region" allocation (or any other >> similar scheme) automatically. > > That's great! However, I don't use Lisp. You should; Lisp is magical. No matter how obscure the requirement, there always seems to exist some one-liner like this to solve the problem. > how to do that in a HLL. I am also not sure how to efficiently implement a > Judy Array in a HLL: In Lisp, almost certainly there will be something like (declare judy-array m n). At least, that's the impression I get. -- Bartc
From: Pascal J. Bourguignon on 7 Dec 2009 08:26 "James" <no(a)spam.invalid> writes: > "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message > news:87k4wzf72o.fsf(a)galatea.local... >> "James" <no(a)spam.invalid> writes: > [...] > > > Thanks for the info. > > > > >>> Can I write a high-performance JVM in Logo? >> >> Yes. > > Okay. But, I still can't quite see how a JVM written in Logo would out > perform, or even perform as good as, a JVM written in C++ and assembly > language. E.g., SUN's HotSpot JVM. > > > What am I missing? We are actually talking of meta programming, and code generation here. It is better to use a high level programming language (including Logo) to generate efficient, application specific code, than to try to have a C compiler do that, given the features of C that prevents it to do a good job. In a way, in this class of application, what I'm saying is that you will get a more efficient program by writting it in assembler rather than in C, on one hand, and that on the other hand you want to retain the advantages of having your assembler code not written by hand, but generated automatically, and specifically, for this application. So you get the best of both worlds. >> A typical example is Squeak. The virtual machine of Squeak is >> implemented in Smalltalk, and it is so fast that multimedia >> applications with 3D and sound are implemented on it (always in >> Smalltalk). > > Is it good enough to create a modern FPS game? Something along the > lines of Crysis: > > http://www.gametrailers.com/video/e3-09-crysis-2/50066 Of course! See for example Naugty Dog's Jak and Daxter game. -- __Pascal Bourguignon__
From: Chris M. Thomasson on 7 Dec 2009 09:03
"Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message news:874oo2gbj6.fsf(a)galatea.local... > "James" <no(a)spam.invalid> writes: > >> "Pascal J. Bourguignon" <pjb(a)informatimago.com> wrote in message >> news:87k4wzf72o.fsf(a)galatea.local... >>> "James" <no(a)spam.invalid> writes: >> [...] >> >> >> Thanks for the info. >> >> >> >> >>>> Can I write a high-performance JVM in Logo? >>> >>> Yes. >> >> Okay. But, I still can't quite see how a JVM written in Logo would out >> perform, or even perform as good as, a JVM written in C++ and assembly >> language. E.g., SUN's HotSpot JVM. >> >> >> What am I missing? > > We are actually talking of meta programming, and code generation here. > It is better to use a high level programming language (including Logo) > to generate efficient, application specific code, than to try to have > a C compiler do that, given the features of C that prevents it to do a > good job. > > In a way, in this class of application, what I'm saying is that you > will get a more efficient program by writting it in assembler rather > than in C, on one hand, and that on the other hand you want to retain > the advantages of having your assembler code not written by hand, but > generated automatically, and specifically, for this application. So > you get the best of both worlds. Can you think of a reason why Sun would choose C++ to create HotSpot? >>> A typical example is Squeak. The virtual machine of Squeak is >>> implemented in Smalltalk, and it is so fast that multimedia >>> applications with 3D and sound are implemented on it (always in >>> Smalltalk). >> >> Is it good enough to create a modern FPS game? Something along the >> lines of Crysis: >> >> http://www.gametrailers.com/video/e3-09-crysis-2/50066 > > Of course! IMHO, comparing Jak and Daxter to a game like Crysis is basically like comparing the speed of light with the speed of a snail crawling up a steep hill of rock salt. |