c++是让人变语言的奴隶,c是让语言变人的奴隶。
-
- 帖子: 77
- 注册时间: 2007-06-25 22:12
[quote=ubuntutu]楼主用C或C++估计连一句弱智的输出都没写过 连你这样的人都在用ubuntu 难怪最近都在说linux用户水平低 估计像你这样水平的人多了 只是你有勇气 敢卖弄无知啊 佩服
[/quote]
鄙人愚见:这位的话,个人完全无视:这一句就让人生气。现在都生产方式多样化至如此份上,还有人说要所谓“水平”高。标准的农家学派的思想。既然要推广 Ubuntu,就要接受“水平”低的用户。不是所有人都要知道编程。你用电脑,你造吗?谁都没资格说谁水平低。
[quote=zhuqin_83]这丫头就知道幸灾乐祸,我看了都很气愤。[/quote]
鄙人愚见:上回在网上好像看到这位作 7.04 的小白鼠就被幸灾乐祸。这位怎么总是见到这样的场面……
附:SCIM 五笔码表太不行,下学期一定要换。连“幸灾乐祸”都没。
回答楼主问题:个人认为现在这样讨论,大家都是语言的奴隶。语言是实现目标的工具。你要写一个加法程序,你考虑 C 还是 C++ 吗?要我,我还 PRINT A + B 呢!两者有区别就感性认识,要用的、常用的深入了解。人其实是自己的奴隶。
[/quote]
鄙人愚见:这位的话,个人完全无视:这一句就让人生气。现在都生产方式多样化至如此份上,还有人说要所谓“水平”高。标准的农家学派的思想。既然要推广 Ubuntu,就要接受“水平”低的用户。不是所有人都要知道编程。你用电脑,你造吗?谁都没资格说谁水平低。
[quote=zhuqin_83]这丫头就知道幸灾乐祸,我看了都很气愤。[/quote]
鄙人愚见:上回在网上好像看到这位作 7.04 的小白鼠就被幸灾乐祸。这位怎么总是见到这样的场面……
附:SCIM 五笔码表太不行,下学期一定要换。连“幸灾乐祸”都没。
回答楼主问题:个人认为现在这样讨论,大家都是语言的奴隶。语言是实现目标的工具。你要写一个加法程序,你考虑 C 还是 C++ 吗?要我,我还 PRINT A + B 呢!两者有区别就感性认识,要用的、常用的深入了解。人其实是自己的奴隶。
-
- 帖子: 18
- 注册时间: 2006-06-07 20:51
-
- 帖子: 318
- 注册时间: 2007-06-21 2:52
Re: c++是让人变语言的奴隶,c是让语言变人的奴隶。
那你的意思是,c比c++更好?eexpress 写了:赞成的举手。
如果这样,正好,我还没学c++呢,哈哈
- weaveol
- 帖子: 10
- 注册时间: 2007-07-24 22:54
- 来自: 火星
- 联系:
-
- 帖子: 4
- 注册时间: 2006-11-02 9:57
补充一些资料
===============C版的HelloWorld=================
================与之对应的汇编代码================
===============C++版的HelloWorld==============
===============与之相对应的汇编代码===============
=================================================
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
=================================================
ThinkPad T40 2373 MU2 + Ubuntu 7.04 + Windows XP
代码: 全选
#include <stdio.h>
int main ( void )
{
printf ( "Hello, World\n" );
return 0;
}
代码: 全选
.file "hello-c.c"
.section .rodata
.LC0:
.string "Hello, World"
.text
.globl main
.type main, @function
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
movl $.LC0, (%esp)
call puts
movl $0, %eax
addl $4, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.size main, .-main
.ident "GCC: (GNU) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)"
.section .note.GNU-stack,"",@progbits
===============C++版的HelloWorld==============
代码: 全选
#include <iostream>
using namespace std;
int main ( void )
{
cout << "Hello, World\n" << endl;
return 0;
}
代码: 全选
.file "hello.cpp"
.section .ctors,"aw",@progbits
.align 4
.long _GLOBAL__I_main
.text
.align 2
.type _Z41__static_initialization_and_destruction_0ii, @function
_Z41__static_initialization_and_destruction_0ii:
.LFB1409:
pushl %ebp
.LCFI0:
movl %esp, %ebp
.LCFI1:
subl $24, %esp
.LCFI2:
movl %eax, -4(%ebp)
movl %edx, -8(%ebp)
cmpl $1, -4(%ebp)
jne .L5
cmpl $65535, -8(%ebp)
jne .L5
movl $_ZSt8__ioinit, (%esp)
call _ZNSt8ios_base4InitC1Ev
movl $__dso_handle, 8(%esp)
movl $0, 4(%esp)
movl $__tcf_0, (%esp)
call __cxa_atexit
.L5:
leave
ret
.LFE1409:
.size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
.globl __gxx_personality_v0
.align 2
.type _GLOBAL__I_main, @function
_GLOBAL__I_main:
.LFB1411:
pushl %ebp
.LCFI3:
movl %esp, %ebp
.LCFI4:
subl $8, %esp
.LCFI5:
movl $65535, %edx
movl $1, %eax
call _Z41__static_initialization_and_destruction_0ii
leave
ret
.LFE1411:
.size _GLOBAL__I_main, .-_GLOBAL__I_main
.align 2
.type __tcf_0, @function
__tcf_0:
.LFB1410:
pushl %ebp
.LCFI6:
movl %esp, %ebp
.LCFI7:
subl $8, %esp
.LCFI8:
movl $_ZSt8__ioinit, (%esp)
call _ZNSt8ios_base4InitD1Ev
leave
ret
.LFE1410:
.size __tcf_0, .-__tcf_0
.section .rodata
.LC0:
.string "Hello, World\n"
.text
.align 2
.globl main
.type main, @function
main:
.LFB1401:
leal 4(%esp), %ecx
.LCFI9:
andl $-16, %esp
pushl -4(%ecx)
.LCFI10:
pushl %ebp
.LCFI11:
movl %esp, %ebp
.LCFI12:
pushl %ecx
.LCFI13:
subl $20, %esp
.LCFI14:
movl $.LC0, 4(%esp)
movl $_ZSt4cout, (%esp)
call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, 4(%esp)
movl %eax, (%esp)
call _ZNSolsEPFRSoS_E
movl $0, %eax
addl $20, %esp
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.LFE1401:
.size main, .-main
.local _ZSt8__ioinit
.comm _ZSt8__ioinit,1,1
.weakref _Z20__gthrw_pthread_oncePiPFvvE,pthread_once
.weakref _Z27__gthrw_pthread_getspecificj,pthread_getspecific
.weakref _Z27__gthrw_pthread_setspecificjPKv,pthread_setspecific
.weakref _Z22__gthrw_pthread_createPmPK14pthread_attr_tPFPvS3_ES3_,pthread_create
.weakref _Z22__gthrw_pthread_cancelm,pthread_cancel
.weakref _Z26__gthrw_pthread_mutex_lockP15pthread_mutex_t,pthread_mutex_lock
.weakref _Z29__gthrw_pthread_mutex_trylockP15pthread_mutex_t,pthread_mutex_trylock
.weakref _Z28__gthrw_pthread_mutex_unlockP15pthread_mutex_t,pthread_mutex_unlock
.weakref _Z26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t,pthread_mutex_init
.weakref _Z26__gthrw_pthread_key_createPjPFvPvE,pthread_key_create
.weakref _Z26__gthrw_pthread_key_deletej,pthread_key_delete
.weakref _Z30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t,pthread_mutexattr_init
.weakref _Z33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti,pthread_mutexattr_settype
.weakref _Z33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t,pthread_mutexattr_destroy
.section .eh_frame,"a",@progbits
.Lframe1:
.long .LECIE1-.LSCIE1
.LSCIE1:
.long 0x0
.byte 0x1
.string "zP"
.uleb128 0x1
.sleb128 -4
.byte 0x8
.uleb128 0x5
.byte 0x0
.long __gxx_personality_v0
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.byte 0x88
.uleb128 0x1
.align 4
.LECIE1:
.LSFDE1:
.long .LEFDE1-.LASFDE1
.LASFDE1:
.long .LASFDE1-.Lframe1
.long .LFB1409
.long .LFE1409-.LFB1409
.uleb128 0x0
.byte 0x4
.long .LCFI0-.LFB1409
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI1-.LCFI0
.byte 0xd
.uleb128 0x5
.align 4
.LEFDE1:
.LSFDE3:
.long .LEFDE3-.LASFDE3
.LASFDE3:
.long .LASFDE3-.Lframe1
.long .LFB1411
.long .LFE1411-.LFB1411
.uleb128 0x0
.byte 0x4
.long .LCFI3-.LFB1411
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI4-.LCFI3
.byte 0xd
.uleb128 0x5
.align 4
.LEFDE3:
.LSFDE5:
.long .LEFDE5-.LASFDE5
.LASFDE5:
.long .LASFDE5-.Lframe1
.long .LFB1410
.long .LFE1410-.LFB1410
.uleb128 0x0
.byte 0x4
.long .LCFI6-.LFB1410
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI7-.LCFI6
.byte 0xd
.uleb128 0x5
.align 4
.LEFDE5:
.LSFDE7:
.long .LEFDE7-.LASFDE7
.LASFDE7:
.long .LASFDE7-.Lframe1
.long .LFB1401
.long .LFE1401-.LFB1401
.uleb128 0x0
.byte 0x4
.long .LCFI9-.LFB1401
.byte 0xc
.uleb128 0x1
.uleb128 0x0
.byte 0x9
.uleb128 0x4
.uleb128 0x1
.byte 0x4
.long .LCFI10-.LCFI9
.byte 0xc
.uleb128 0x4
.uleb128 0x4
.byte 0x4
.long .LCFI11-.LCFI10
.byte 0xe
.uleb128 0x8
.byte 0x85
.uleb128 0x2
.byte 0x4
.long .LCFI12-.LCFI11
.byte 0xd
.uleb128 0x5
.byte 0x4
.long .LCFI13-.LCFI12
.byte 0x84
.uleb128 0x3
.align 4
.LEFDE7:
.ident "GCC: (GNU) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)"
.section .note.GNU-stack,"",@progbits
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
=================================================
ThinkPad T40 2373 MU2 + Ubuntu 7.04 + Windows XP
- danielwyo
- 帖子: 66
- 注册时间: 2007-02-15 20:58
- 来自: 上海
- 联系:
evaxige:
C++在单纯的汇编翻译上, 确实没有C来得纯粹, 你举的例子很好, 在这方面C++确实没有C优秀(不过这里有点不公平, 你的C代码编译选项是最简化的,而C++代码却没有加上优化,当然了,就算加上优化,C++也比不上C的纯粹). 但这仅仅是一个方面, 而在更加广阔的工业代码中, C++却比C更加有优势, 能够实现更加合理的代码, 而不是纠缠于细节之中.
===============C版的字符串连接=================
char* strSrc1 = "hello";
char* strSrc2 = "world";
int nLength = strlen(strSrc1) + strlen(strSrc2)+1;
char* strDest = malloc(nLength );
memset(strDest, 0, nLength);
strcat(strDest, strSrc1);
strcat(strDest, strSrc2 );
printf(strDest); /*helloworld*/
================C++版的字符串连接================
std::string strSrc1 = "hello";
std::string strSrc2 = "world";
std::string strDest = strSrc1 + strSrc2;
std::cout<<strDest; //helloworld
希望那些只会评论些抽象概念的人还有评论不带具体论证却只会自命清高的人, 能够指出具体的可以讨论的东西来.
讨论些有实质内容的东西更加有意义, 不是吗?
C++在单纯的汇编翻译上, 确实没有C来得纯粹, 你举的例子很好, 在这方面C++确实没有C优秀(不过这里有点不公平, 你的C代码编译选项是最简化的,而C++代码却没有加上优化,当然了,就算加上优化,C++也比不上C的纯粹). 但这仅仅是一个方面, 而在更加广阔的工业代码中, C++却比C更加有优势, 能够实现更加合理的代码, 而不是纠缠于细节之中.
===============C版的字符串连接=================
char* strSrc1 = "hello";
char* strSrc2 = "world";
int nLength = strlen(strSrc1) + strlen(strSrc2)+1;
char* strDest = malloc(nLength );
memset(strDest, 0, nLength);
strcat(strDest, strSrc1);
strcat(strDest, strSrc2 );
printf(strDest); /*helloworld*/
================C++版的字符串连接================
std::string strSrc1 = "hello";
std::string strSrc2 = "world";
std::string strDest = strSrc1 + strSrc2;
std::cout<<strDest; //helloworld
希望那些只会评论些抽象概念的人还有评论不带具体论证却只会自命清高的人, 能够指出具体的可以讨论的东西来.
讨论些有实质内容的东西更加有意义, 不是吗?
Love in' Littlewhite
- danielwyo
- 帖子: 66
- 注册时间: 2007-02-15 20:58
- 来自: 上海
- 联系:
- danielwyo
- 帖子: 66
- 注册时间: 2007-02-15 20:58
- 来自: 上海
- 联系:
-
- 帖子: 14
- 注册时间: 2007-05-10 23:10
-
- 帖子: 77
- 注册时间: 2007-06-25 22:12
- qkthomas
- 帖子: 503
- 注册时间: 2006-12-16 22:05
- 来自: 肇庆
-
- 帖子: 196
- 注册时间: 2007-06-06 14:24