John Carmack - C/asm

Started by
47 comments, last by ao 23 years, 9 months ago
quote:Original post by David M.

MadKeithV--I''ve never used templates or anything like that. I just tried using classes for my interfaces once, and...well, I wasn''t all that impressed, to say the least. I couldn''t see how I was stepping into the "next phase" of programming, as my peers like to shove down my throat.


Perhaps your programming practices are already well-structured and lend themselves to code reuse, genericity, polymorphism, encapsulation/data hiding, and the many other benefits that C++ encourages you to use through explicit language features. There''s no reason you couldn''t do all this in C. But if you''re not using some of the above paradigms, there will undoubtedly be times when you might find your work was made easier, quicker, or less error-prone if you were.

quote:
What really bugs me, as I''ve probably said before, is when people tell me there are things I just "can''t do" in C Classic. They like to tell me that they''re technologically "ahead" of me. Well, pffft, I say.


I agree: anything that can be done in C++, can be done in ASM. It may not be as obvious to someone glancing through the code But it can be done. I don''t think it''s as easy to do though.

quote:That is, I believe that `smart programmer'' trumps `smart language'' every time.


This is true, but it''s not really the point.

Smart programmer with dumb language is probably marginally better
than dumb programmer with smart language.

However, smart programmer with smart language is going to be able
to accomplish more than either of the above.

And this is what C++ is about. It''s a powerful tool, slightly harder than C to use well, but eventually allows you to build up and manage complex systems more quickly and easily, in most people''s opinions. It just provides some short cuts and syntactical encouragement to some good programming paradigms.

quote:
Now, another thing I don''t like is having all my private functions and variables in the header file. I prefer to have the interface in the header file, and the implementation in the C file. I don''t know why, exactly--it''s just a, um, snobby aesthetic thing of mine.


This makes sense to me too, and I consider it something of a discrepancy in C++, although only a minor one. In this way, C can actually seem better than C++ for data hiding and encapsulation in some cases. Certain ''private'' functions that don''t need to act on private class members, I just make as static non-member functions in the class implementation file so no-one else ever knows they exist.
Advertisement
quote:Original post by MadKeithV

Some points:
1. I''m a Catholic, so be careful what you say about Christians and not liking em.


Sorry...no offense...I''m just talking about things like this: "I''m better than you because I take Communion every day"; "I''m better than you because I don''t use wine for Communion"; "I''m better than you because I wear a head covering"; "I''m better than you because I can speak in tongues"; "I''m better than you because I pray to saints"; "I''m better than you because I don''t use electricity"; and on and on and on and on. In my church and others, there''s a lot of unproductive bickering and nagging of this variety. I get tired of it.

quote:2. C++ is a HARD language. Anyone who claims anything else does NOT know C++, they only think they do.


Well, that''s another thing: People keep telling me that C++ is "a lot easier than C", and I could never figure out why. To me, it looks like C with a load of unnecessary complexity hung on the side. (That''s *just* an opinion, nothing more--so nobody shoot me, okay?)
No jihads in my forum. Get back on topic or it''s closed.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
The best advice is to use whatever language you are comfortable using. However, be aware that the reason C++ is popular and the reason some people prefer it over C is because of the additional features and capabilities it provides. Granted, it takes additional effort to learn to use these features, but they just become another tool in your arsenal to use to program.

Take STL for example. You can do anything you want with or without STL, but if you take the time to learn STL, you will be able to utilize the features and functionality offered to your advantage.

To say C is better than C++ or vice versa is a waste of time. They are tools. Learn them and love them. I will say that to close your eyes to new languages and language features is naive. Programming is about technology, and technolgy changes very rapidly. Learn as much as you can...Knowledge is power!
quote:Original post by David M.
"I''m better than you because I pray to saints";


<- Look at my rating

Ps: This last anonymous poster : that looks a LOT like another post I once made elsewhere on this forum, apart from the STL part . Guess I''m rubbing off on people.




Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
quote:Original post by blue-lightning

I wish the ANSI C++ standard was more volatile. I want subfunctions (functions defined inside of functions). It would be so cool if the local variables of the parent function became global variables to the inside function. I know how to do it in asm, but C++ doesn''t let me do it.


The reason you can''t have functions inside of function with C has to do with it''s philosphy on lexical scope (i.e. it don''t) If you want functions inside of functions use pascal (or delphi)
BTW this is one of the fundamental reasons why C code is _always_ faster than pascal code, less on the stack for each function call becuase it doesn''t have to keep track of local variable scope...

PS I think it''s lexical scope, but it may be the other one... forgot what it''s called
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by Magmai Kai Holmlor

The reason you can''t have functions inside of function with C has to do with it''s philosphy on lexical scope (i.e. it don''t) If you want functions inside of functions use pascal (or delphi)
BTW this is one of the fundamental reasons why C code is _always_ faster than pascal code, less on the stack for each function call becuase it doesn''t have to keep track of local variable scope...


Er, this really isn''t true. A ''local function'' definition would be exactly the same (in terms of size and speed) in compiled code as any other function, just as member functions are exactly the same as non-member functions. The only difference would be the visibility of that function to other functions, which is only a factor at compile time.

As for the ''philosophy'', 2 things contradict your view: Firstly, you can declare local classes. Secondly, with a standards-compliant compiler those classes can have member functions which you could consider to be ''local functions''. You can overload the local class''s operator() to simulate a function call, giving what is effectively a local function. It''s just a shame it''s a bit of a hack.

And as for C code -always- being faster than Pascal code, I think that is wrong too. As far as I know, the Pascal calling convention (and thus, stack management) is almost identical to that of C and C++, except back-to-front.

Can you substantiate your claims?
quote:
As far as I know, the Pascal calling convention (and thus, stack management) is almost identical to that of C and C++, except back-to-front.


Correct me if I''m wrong, but I thought C/C++ also passed arguments right to left.

In any case, I''d imagine Carmack has probably just stayed with pure C because he''s productive in it and he knows it well. Learning to use the new features of C++ correctly takes a bit of time.
quote:Original post by TheGoop
Learning to use the new features of C++ correctly takes a bit of time.


Hmm, now there''s a lovely understatement
It took me about 4 years.




Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~
ERROR: Your beta-version of Life1.0 has expired. Please upgrade to the full version. All important functions will be disabled from now on.
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.

This topic is closed to new replies.

Advertisement