它一般被認為可以令製作流程更順暢,但這概念是否每一處也適用哩?讓我們聽一聽反對的聲音吧。綜合各人的要點:
- 把電腦語言可視化不是一種萬靈丹。
- 用於非實時的 Rendering 還不錯,但用於講求高效率的實時 Rendering 就會帶來問題。
- 經可視化工具產生的 Shader 一般都比手寫的來得低效。
- 太容易去讓美術師建造數以千計獨一無二互相無關的 Shader,使後期整理成為惡夢。
- 削弱美術師和程式設計師之間的溝通。
記錄我的編程新思維
Interesting acrobatics, but I am a KISS fan.當然,流行/藝術派與實際派的存在都是有意義的;否則編程世界不是一團糟就是停滯不前。
I prefer not to mandate a C++ black belt (with several Dans on occassion) on coworkers who try to understand and modify my code, so thanks but I'll pass.
Is there anything in the above code that cannot be done in plain C in a way that 90% of the dev population can understand and 80% can modify/extend without a mistake?
Why do architects feel so compelled to save the world by providing infrastructure and plumbing for everything conceivable under the sun?
What about memoization? If I am in such a corner case where caching the results of a function call will *actually* improve performance, what makes you think I would opt for an obscure and totally incomprehensible generic template that I cannot understand or debug, rather than a custom-tailored, totally non-reusable, top-performing, totally understandable and debugable solution?
Don't get me wrong, I am not an anti-STL, do-it-yourself (CMyHashTable, CMyDynamicArray, CMyOS) gangho. I am just a KISS fan (including the rock band). If something can be done in a way that is simpler, easier to understand, debug and extend, then I prefer the simpler way.
I just get so frustrated when people do all this acrobatic stuff in production code just because (a) they can do it (b) it's cool to do it, without thinking back a lil'bit or actually having mastered the 'tools' they are using.
A similar example is 'patternitis'. I have seen countless C++ freshmen reading the GangOf4 Design Patterns book and then creating a total mess in everything, like deciding to implement the Visitor pattern on a problem that required Composite and ended up coding a third pattern alltogether from the same book, still naming the classes CVisitorXYZ (probably they opened the book on the wrong page at some point).
I have met exactly 1 guy (I called him the "Professor") who knew C++ well enough and had the knowledge to apply the patterns where they ought to be applied. His code was a masterpiece, it worked like a breeze, but when he left, none else in the house could figure things out.
So what's the point with these Lambda stuff really? Increase the expression of the language? Are we doing poetry or software? Why should we turn simple code that everyone understands into more and more elegant and concise code that only few can understand and make it work?
I have been coding in C (drivers) and C++ for 15 years and not once was I trapped because I was missing lambda expressions or similar syntactic gizmos.
So what's the point really? Please enlighten me. I don't say that *I* am right and *YOU* are wrong. I am saying that I don't see, I don't understand the positive value that these things bring in that far outweighs the problems they cause by complicating the language.
| Adobe Reader 9 | Foxit Reader 2.2 | |
| 啟動須時 (秒) | 21 | 7 |
| 記憶體用量 | 74MB | 25MB |
class Texture {
public:
friend class IResourceLoader;
uint width() const { return mWidth; }
uint height() const { return mHeight; }
private:
uint mWidth;
uint mHeight;
};
class IResourceLoader {};
class JpegLoader : public IResourceLoader {
void load() {
// ...
mTexture.mWidth = 128; // Compiler error!!
}
};
// Texture.h
class Texture {
public:
friend class IResourceLoader;
uint width() const { return mWidth; }
uint height() const { return mHeight; }
// We declare a templated inner class here (but not defined yet)
templateclass PrivateAccessor;
private:
uint mWidth;
uint mHeight;
};
class IResourceLoader {};
// JpegLoader.cpp
// Define Texture::PrivateAccessor here, access what ever you want
template<>
class Texture::PrivateAccessor{
public:
static size_t& width(Texture& texture) {
return texture.mWidth;
}
static size_t& height(Texture& texture) {
return texture.mHeight;
}
};
typedef Texture::PrivateAccessorAccessor;
void JpegLoader::load() {
// ...
Accessor::width(mTexture) = 128; // Ok! no problem
Accessor::height(mTexture) = 128;
}