×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

I respect others and I also respect myself. What's wrong with this?

Where do I croess the line? Where did I give out personal advice? Do I ever put out any persional judgement ? Please don't put such heavy piles on my head.

Academic discussion can end on diverse opinions, but at least both parties should respect the opposite. This is the basic rule and I didn't see any unappropriate on this rule. I response the thread seriously because I respect the people who raises questions.

For my personal limitation I can't explaine this question better and that's my sorry. Here's a link will give a better summary on the difference between C and C++
http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance.htm

I didn't see any necessarity to continue this thread anymore. It already turns into meaningless and waste resources in this forum. This certainly is not my intention.
Report

Replies, comments and Discussions:

  • 工作学习 / 专业知识杂谈 / 大家是不是都在用面向对象的编程方法? 感觉怎么样啊?
    我怎么感觉怎么这么难啊? 特别是一抽象起来
    • 这种活, 干久了, 人会傻掉的. 没意思. Coding machine 一个.
      • 您老在干什么啊?
        • 呵呵. 干革命.
          • 那做什么呢?
            • 来抢白人的饭碗, 叫他们也做一下穷鬼.
      • 这里这么热闹.有朋友能帮我搞个C的环境吗?想学习学习.谢谢了.各位前辈.
        • 找小饭吧. 他有好几个平台. 他是高手
        • 你装个visual c++6/2005就可以了
          • 学习 c 还用visual c++? 太年轻了。bordland turbo c 2.0
    • 对呀,当然要用面向对象的方法,否则干起活来不把人累死!其实OO就是为了减少编程量和复杂程度的好方法
      把一切东西都看成对象,一切用class来完成,更复杂的用design pattern来设计
      • C++除了GUI外,我还没有看见很成功的.至于ENCAPSULATION, C也可以做得很好.JAVA的思路很好,可惜太慢,而且开放性有点让人怀疑.我一直把JAVA是脚本来看的.那些设计语言的,我真是觉得很久没有什么进步.
        • 1.C++可以使用多态;2.C++可以用STL以及TEMPLATE,ACE类库支持. 就凭这这两点,对于绝大部分软件项目来说C++比纯C更合适
          • 就语言本身而言,VISUAL BASIC比什么都讨人喜欢.一个难学的语言,无论如何是不成功的.
            • 呵呵,这句话用到软件设计真是再精辟不过了。
            • 我可不觉得C++比C难多少。没有了STL,你自己用C要写很久才能写出个list/index
              • list/index is such a piece of cake for C programmer.
                • 这个就是开发效率的问题,你千辛万苦自己搞个普通的INDEX何必呢,性能估计也比不上STL,不MAKE SENSE. 再说LIST/MAP/MULTIMAP/VECTOR/QUEUE你有时间一个一个来IMPLEMENT?
                  • 千辛万苦? come on. read my message again. I am confident in my programming ability. My code is better than STL for my specific applcation for sure. And clearer because it is specific cut for my purpose.
                    • 自信的程序员太多太多,这么自信的不多见,呵呵
                  • Using the time spent on the studying of STL, you can write it. For example, sometimes you have the source of some program, you still want to write a version of yourself. For closed source libraries, I really hate it.
                    • I also have my own version of index/list, which is to operate the virtual memory/paged memory allocated myself. However, in most cases STL works better and has less coding work. It only took me 2 days to learn STL.
                      • which version of STL? Do you know most STL has bugs? Don't tell me there are no bugs in STL.
                        • I have used STL in g++2.9.6/3.2.3/3.4.3 on Sol6/7/8/9,Redhat7/8/9,Suse,UnitedLinux or Windows' STL . The STL bugs only appear in some special OS like HP-UX or exteneded version such as STLPort.
                        • 任何程序都有可能存在bug。如果STL有的东西你不用,同样的功能你就需要自己实现或者用其他的库,不要说你自己实现或者别的实现就没有bug。实际上,STL经过千锤百炼,同样功能的程序中,bug一定会少于你自己写的代码的。
                          • 经过千锤百炼 IS MS WINDOWS, BUGS IS ALMOST COUNTLESS.
                            • windows一直在加新东西进去,除了名字还叫windows以外,什么都变了。
                              • win 98 is almost obsolete.
                                • 对啊,windows是个商业性的操作系统,微软靠不停地换代来赚钱,不停地推出新版本,这样的东西怎么能和STL相比呢
                                  • STL既然不加新东西, 又如何千锤百炼了?算了,不想再说了.
                                    • 我真怀疑你用过STL没有
                                      • STL,你是用它的观点.我是SUPPORT它的VIEWPOINT,STL总要在操作系统上运行吧,如果操作系统UPDATE了,有BUG了,用STL不就死翘翘了,办法吗?等UPDATE STL?
                                        • 照你这说法你现在就别做程序员了,反正OS的BUG肯定影响你的程序,等哪一天完美无BUG的OS出来你再写程序吧。我已经开始怀疑你是否写过程序了
            • 凭什么说难学的语言就不成功呢?如果说是易学好用,VB是成功的。但就效率、性能、应用面而言,VB根本不值一提。有相当多的系统是VB根本实现不了或做不好的,比如操作系统、图形处理、大型游戏,等等。总的来说,VB只是个玩具而已。
        • 我觉得您可能是C方面的大拿,但是对OOP/Java这些东西知道的不深
        • 和匈奴打仗用骑兵,和南越国作战用山地步兵,和孙吴作战用水军。
          • 军师错也! 和匈奴打仗该用藤甲兵砍马脚,和南越国作战该用神火营放火烧山,和孙吴作战就只能用推土机了.
            • 那不还是要采用不同的东东?:)
              • 关键是要用最合适的东东.
                • 这合适学问就大了,使你自己合适呢,还是适合于外部环境呢?,若敌军都几经OO了,你还ASM死抱着不放,对你自己是合适了,可放置于大环境来说就是不合适了。是不是这道理?:)
                  • 神辫换成神枪, 东西换了, 神留着.
        • 说到我心眼里去了!一直想找一个在非gui平台用oo开发应用的人聊聊,问问他们是怎么建立对象的,至今没找到。
          • 一个人应该用“他/她”。扣10分。
            • 上帝,你是天才!
              • :)
          • 我们TEAM主要开发UNIX下的分布式服务器,全部代码都用C++的,模板,类库,STL/ACE都用
            • 有谁00过一个BRANCH,一个STORE,一台ATM,一个CUSTOMER,一个商品,一个零件,一张信用卡?这些最MAKE SENSE的OBJECT?
              • OO里面de面向对象指的是面向role,不仅仅是客观世界的完全影射。所以branch在面向对象的世界里如果没有role 的responsibility就不认为是Object.
              • 我觉得在UNIX下开发分布式程序,每一个MESSAGE就是一个CLASS,我的程序主要就是怎样处理这个CLASS,和你说一个商品,一个零件没有任何区别。我最近写的一个UNIX服务器程序就用了52个C++类和模板
                • 我可以保证:你的程序的效率绝对不高!你的程序如果要一秒钟处理几K个消息,想象一下.
                  • 以前在国内写的C++网关程序,每秒处理2000条复杂数据(xx移动自己测出来的数据).我自己写过最快的C++程序是一个基于BDB的文件存储系统,在pc服务器上每秒可以插入1万多条200字节的数据
                    • 2000条,消息有多少种呢?都是如何处理的?
                      • 一般UNIX程序员都会问程序分布在多少台服务器上而不会问多少个类,因为消息和CLASS个数并不会影响性能。不过我可以告诉你核心业务消息大概30多个,算上统计,SNMP,计费,数据追踪,信息过滤监控大概100-120种消息,用ThreadPool+MessageQueue处理
                        • 才30多个,如果消息类别多的时候,你想OO,还要PEFORMANCE就不行了.你的经验估计没有这条.用理论想想吧.要不你写个DISPATCH MESSAGE的OO程序给我看看,我倒要见识一下了.
                          • 和你讨论这个话题已经没有什么意义,不知道你有多少UNIX开发经验,总之我写UNIX服务器开发时候根本就没考虑c++还是c的问题,写到某个部分觉得哪个合适就用那个。我的代码不方便给你看,你想参考的话可以看ACE类库里面的ACE_Task类
                            另外消息只是指协议里面的一个packet, request or response.
                            如果是说class一共有400多个class
                            • 你的脾气很好,我其实早就想打住了.只是想说:这个DISPATCH我用C写过,嘿嘿,开始还想用ASM写了,其实性能影响很大.
                        • 2000条分布在多少台服务器?
        • 不会吧。很多大的EMBEDDED SYSTEM都是OO DESIGN的。
          • detail??
            • 什么样的DETAIL呀?TELECOM的不少公司项目都是C++,OO DESIGN的。可能BOOTING PART很少有C++的,但高一点的就是了。
      • 楼上六窍皆通!
        • 人有七窍,通六余一,--一窍不通?:)你可够可以的,拐着弯的骂人:)
    • 如果写过很久面向过程的程序,这个弯确实挺难转的,我看过不少senior写的java程序脱不了面向过程的思维。相反现在的学生倒没这困难,他们一开始就从OOP学起。Thinking in Java/Thinking in C++挺适合熟悉面向过程的人,值得一读
      • senior != old,就是这道理。
    • OOA/OOD/OOP的顺序很重要,另外oo需要有很长时间de公里,个人认为至少5年。
      • 在1994年,当时我的导师问过我们几个学生什么是OO,他和面向过程的分析,设计,编程有什么不同。结论:从分析设计阶段就要改变思路, 否则OOP是累赘,摆设.
        • 说的这么好,不得不顶一下。
          • 多谢,可惜不做编程很多年了。当初立志此生不再编,现在看老婆作J2EE, 手痒。
            • J2EE从很多方面来说,应该是相当的不OO吧? DB OO了吗? EJB OO了吗? Servlet OO吗? 几年前开始,很多人就努力想把Web Tie OO 化一点, HTML OO了吗? 你OOOOOOOOOOOOOO了吗?
              • What is an "Object" - Everything. From analysis, design to implemeantation, if you have an "O" at heart, you can build OO even with Forth.
              • It depends on from what level you are looking at the program - when you are too much into details, you may be lost in Hibernation, Spring, MVC framework. But....
                when you look at it from 500 metres in the sky, your view will be clear and you can see what presents the Object - so instead like someone so confused about "...Today's J2EE applications might look a lot like yesterday's procedural COBOL applications that were so derided by upstart Java developers 10 years ago...", look at those business compoments - so much like our real life business transcation model, process and components - how can one say it is not OO?.... Then look at the SOA, someone may not like it, but it tuely represents the OO concept at heart - why? It is just like entities in the real world that provide the services. What is OO ? It is OBJECT Oriented, What is an Obejct? It is Everything in the world!
    • 不一定, OO 有时是事倍功半. 但是不懂OO也是不行滴.
      • 没错,OO有时候就是包着糖衣的毒药。
      • Form a long term view OO absolutly release a lot burden for programmer provided by it's extendablity. It's also more flexiable base on using delegation
        • Right!
    • 说实在的,俺什么语言都不会,什么Business Knowleddge也没有. 至今也没搞明白为什么有人要请我. 我到底会什么? 我是谁? 我想干什么? 要往哪里去? 每天这些问题都在困扰着我. 想得头昏脑胀的时候就来这里灌水.
      • 没有电脑文凭,没受过正规训练,没有证书,没有正式的工作,没有理想,没有目标,没有人生,....., 我就一混混.
        • 老板娘看上你了
    • 我认为程序员这种活迟早会转移到印度和中国去, 所以还是考虑回流或者转行.
      • 如果你只是个人云亦云,不会独立思考的程序员.
    • Programming language doesn't change much since C became available. The key is memory management no matter it's functinal. procedual or OOP.
      • On implementation level the main difference between C AND C++ are Vrtual Table and Dynamic Binding
      • Have a look on Bjarne Stroustrup - The C++ Programming Language and GO4 Design Pattern. I didn't see any books over them so far.
      • Do not treat OO as something only happens in programming. It happens anyware if you're trying to do some abstract think.
        • I can not agree more.
      • Understanding on memeory will help you understand questions like why JAVA don't create object on stack but C++ can? What's the difference between call back and event drvien? Why java don't pick multi inheritance
        • good points
      • you really understand C/C++
      • From language aspects, there's no really OO Language or Functional Language. When we refer Java or C++ are OO Languages and C is functional language. It really means they have better support of OO Concepts
      • By direct memory control on memeory, implementing Virtual Table and Dynamic Binding, you can convert C into a simplified C++, which has a limited feather on polymophism, encapsulation and inheriance
      • You can see here. The OO is a concept which is not related what language you pick.
      • I started from C and quickly changed to C++. I didn't do any java befor, but I didn't see any difficulties on picking up any new languages. My point is focuing on OO concept and memory instead of languages
        • 佩服, 有什么好的书或online book 关于 memory managemen 谢谢
          • Sorry, I don't really have any recommandations here. The memory management scatter around into OS, compiler and programming language.
      • u must be kidding ...
        • Which part is the kidding part?
      • What a misleading statement? Did you ever hear about SmallTalk and Lisp? SmallTalk is a pure OO lanaguage and Lisp is a functional language. C is never a functiona language. Instead, it is a procedural language.
        • Sorry, you are right. C is a procedural language. What's other misled statement?
    • One of the biggest mistakes in the computer science / technology history is that C++ was a totally mis-leading name.
      • It gave people an illusion is that if you know C, then it's easy to move on to C++. In fact, it is very hard, if it is not impossible.
      • For a senior C engineer, it takes him/her many years before he/she can claims he/she is now comfortable in OOP.
      • That explains, as indicated by other folks, though C++ is better than C, in reality there are more applications implemented using C rather than C++.
      • I can't agree you on this although this rumor ever be popular. This is only an excuse for the people who's not really master C and neither get a clear OO concept
      • In the real world, C and C++ are different roles. C is faster than C++ ON SYSSTEM LEVEL for the reason that C doesn't have any the runtime feathers which are very important to C++.
        • C is faster than C++?你好像不知道C/C++都是要编译成目标码的?运行速度的快慢和编译器以及编译时的选项有关,和用C还是C++写成的有什么关系...
          • In the early days C++ is tranfered to C during compiling and in this operation C++ generate larger code.
            • 我用的第一个C++编译器就是先编译到C的。假设一个程序a.cpp,编译到a.c,再编译到目标码。你能说a.c比a.cpp快吗?
              • I can't say that because they're identical on the higher leverl. It's the different situation than my assumption.
                • so could you please explain your assumption? what do you think makes c++ slower than c?
                  • I assume that the same code wittern in C and C++. Without any optimization, C++ will produce a larger object than C and concequently the machine code is larger and need more time to excute
                    • first, larger code is not necessarily slower. second, in real world we DO enable optimization feature of compiler.
                      • That's the difference between theriotical and practial. It already beyond the scope of our discussion.
                        • 当你说C比C++快的时候你到底说的是现实中还是理论上?现实中,我没看到任何证据显示C比C++快;理论上,我也没看到任何理由说C比C++快。如果你说C比C++快是你的“感觉”,那我没有任何意见。
                          • I want to keep this discussion professional. I only provide my opinion no matter it's correct or wrong. C++ produces larger object file is a fact. Please don't shoot anything personal.
                            • 您在暗示我不professional?呵呵...professional恰恰是我想说的
                              我所认为的professional,是立论要摆事实讲道理。您说C比C++快,或者您从您的experience出发,您实际比较了C和C++的速度得出这个结论;或者您从理论出发,在逻辑上论证C应该比C++快。这两条路任何一条都可以说是professional的。
                              但遗憾的是,您只有一个opinion,和一个不相干的"fact",即C++的object file更大,这算哪门子professional?
                              只是针对这件事,没有对人。don't take it personally
                              • NO, there's no hints here. If I do offence you at any point it's my sorry and I apologize for anything it ever brougt about.
                                I can't see where is the difficultity to be understood that a bigger object file will consequently lead to a larger size of machine code. A larger-size machine code will lead to longer excution time and larger foot print in the memory
                                • A larger-size machine code will lead to longer excution time? 您该不会不知道inline function吧...在programming里空间换时间时间换空间的做法很普遍,您怎么能得出大就会慢这样的结论呢
                                  • Context switch will slow down excution. Larger object needs longer time to load, it also cause larger footprint in the memory. It will finally slow down the excution.
                                  • C++ has more hidden fields, constructor and destructor. constructor and destructor will be called during the excutiion.They become overhead during excution.
                                  • Again, during discussion, please don't mention me.It doesn't help anything, Even we can't reach out on some point this discussion will benefit a lot of people who's interested in the process of interview.
                                    • take it easy, nobody knows who you are and nobody really cares. it seems that you care so much of YOUR opinion and youself.
                                      i just wanna talk about what is correct and what is wrong. even i mentioned you i didn't mean anything and no offense intended. yes i was not serious when i mentioned you, for sure i was not judging you. but it seems that you are so serious of it and you actually crossed the line to tell me what not to do...
                                      • I respect others and I also respect myself. What's wrong with this?
                                        Where do I croess the line? Where did I give out personal advice? Do I ever put out any persional judgement ? Please don't put such heavy piles on my head.

                                        Academic discussion can end on diverse opinions, but at least both parties should respect the opposite. This is the basic rule and I didn't see any unappropriate on this rule. I response the thread seriously because I respect the people who raises questions.

                                        For my personal limitation I can't explaine this question better and that's my sorry. Here's a link will give a better summary on the difference between C and C++
                                        http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance.htm

                                        I didn't see any necessarity to continue this thread anymore. It already turns into meaningless and waste resources in this forum. This certainly is not my intention.
                  • Assume you write a public object in C++ and a structure in C with the same fields. Any C++ object has hidden fields like run-time ID and reference counter and that makes the object file of C++ BIGGER than C class file
      • Compare 2 language and draw a conclution on which one is better without any condition are childish. There's no language better than another one. Do you think English is better than Chinese?
        • English和Chinese是平行的语言,但C和C++并不是平行的关系,后者是前者的超集。
          • With new version of C++ compiler, it's not need to be transftered to C anymore
            • 不同的实现并不影响语言的特性。不管编译器怎么实现,C++都是C的超集,而不能是平行的关系
              • C++ is never to be designed to be a superset of C in purpose. Have a look on The C++ Programming Language written by Bjarne, who gives a lot of contributions of the invention of C++. It explains very clear in the book.
                • 这个问题要看你怎么样看待,C++只是在很个别的feature上不是C的超集,但在更普通的意义上上C++确是C的超集。叫这个真儿没有意义,C++是C的超集这个说法是不严谨,但并不错。
                • This is why a lot of people who wrote 5 or 6 yrs C programming but can transfter themselves to be a good C++ programmer. Concept is the key and all implementations are details. Details can never affect Concept
                • I make a revise here. In system programming level C++ can be treated as a superset to C. For general programming they're only connected on syntax, nothing else.
                  • 你扯太远了。我只想说,我们不能说英语好还是汉语好,但我们可以说,在一般意义上(不是绝对意义上),C++比C好。
                    • Can't agree on which one is better. It depends on different situations. I do agree that C++ has a better support on OO than C.
                      • 您的can't agree难道就无视条件吗?我的条件是in general
                        • What's the term of IN GENERAL? There's no such words in CS area except algorithm under the condition of considering distributed proboblity.
                        • There's a word general-purpose programming which 's out of scope of this discussion
    • 转一篇OO的小例子,和C#里的Interface有关,希望能对搂住有帮助?
      本文发表在 rolia.net 枫下论坛针对接口编程能帮助达到面向对象开发和设计中"低耦合"的要求.
      举个例子:某公司有一台特殊打印机,还可以使用一年,一年后可能换为另一种打印机,这两种打印机都特殊而贵.所以现在的程序希望换了打印机后也少量修改就可用.
      方法:
      1,定义一个打印机接口.
      2,定义打印机类A,B,分别实现此接口.
      3,定义一个工厂类,在类中可选择返回由A实现的接口,或者由B实现的接口.
      4,在程序中使用打印机时,就可以使用工厂类来调用打印机,而不需要知道具体的是什么打印机.
      如果打印机换了,只需要修改工厂类就行了.如果有一千个地方都调用过打印机,就不需要一个一个修改.修改一个地方就行了.接口充当一个隔离层的作用.

      //定义打印机接口
      interface Iprint{
      bool PrintData(string data);
      }

      //定义打印机类A,实现接口
      class PrintA:Iprint{
      public virtual bool PrintData(string data){
      //具体业务逻辑略
      }
      }

      定义打印机类B,实现接口
      class PrintB:Iprint{
      public virtual bool PrintData(string data){
      //具体业务逻辑略
      }
      }

      //定义工厂类
      class PrintFactory{
      public Iprint CreatePrint(){
      //返回一个由打机类A,或B实现的接口,比如
      return new PrintA();
      }
      }

      //通过工厂类,调用打印机
      private void button1_Click(object sender,EventArgs e){
      PrintFactory myFactory=new PrintFactory();
      Iprint myPrint=myFactory.CreatePrint();
      myPrint.PrintData("这样做很方便啊");
      }更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • This is something called system call in operating system. It is as old as C and in fact part of C/unix from very beginning.
      • 是吗,您牛呀,我主要是没学过操作系统等等,至于有多老我也不知道,我只是觉得这样使用接口是一种很有效的OO方法
    • Summary of the comparation between C++ and C from http://www.eventhelix.com/RealtimeMantra/basics/ComparingCPPAndCPerformance.htm
      本文发表在 rolia.net 枫下论坛Analysis
      This section analyses the C++ code and its C translation and identifies the performance impact.

      C++ Method Invocation All C++ methods when translated to C end up with an additional parameter. This might appear to be a big performance overhead. In reality however, the code in C will also have to access the common data structure via an array index or some other mechanism.

      Object Construction Whenever an object is constructed, C++ will invoke the constructor. Sometimes this might be an addition overhead. This overhead can be reduced by defining the constructor inline. In most cases however, the constructor is actually replacing a routine that would have been used to initialize the data structures in a conventional C program.
      If a program declares a lot of global objects, object construction can be a big overhead at program startup. C++ invokes constructors for all global objects before main() is called.


      Object Destruction

      As you can see from the C code, whenever an object goes out of scope or is explicitly deleted, C++ invokes the destructor for the object. This overhead can be reduced by only defining destructors when they are really needed (i.e. some action is required when object is deleted). Inline destructors can also be used to reduce the overhead.

      Static Access The C code above shows that static member functions and variables do not correspond to an instance of the object. Thus they are accessed without indirection of the object. This can be useful in defining methods which need C level function call conventions. One good use for static member functions is to implement interrupt service routines (ISRs). ISRs handlers typically need to be C type functions. In most implementations, C++ static functions can be directly used as ISR handlers.更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • Hopfully, this will benefit people who's going interview
    • 高人这么多啊,敬仰中.我不会OO啊,总那里入手呢?