c++是让人变语言的奴隶,c是让语言变人的奴隶。

不同视角、不同观点、深度探讨,禁止人品和道德攻击
回复
至高之光
帖子: 77
注册时间: 2007-06-25 22:12

#76

帖子 至高之光 » 2007-07-30 17:16

[quote=ubuntutu]楼主用C或C++估计连一句弱智的输出都没写过 连你这样的人都在用ubuntu 难怪最近都在说linux用户水平低 估计像你这样水平的人多了 只是你有勇气 敢卖弄无知啊 佩服
[/quote]

鄙人愚见:这位的话,个人完全无视:这一句就让人生气。现在都生产方式多样化至如此份上,还有人说要所谓“水平”高。标准的农家学派的思想。既然要推广 Ubuntu,就要接受“水平”低的用户。不是所有人都要知道编程。你用电脑,你造吗?谁都没资格说谁水平低。

[quote=zhuqin_83]这丫头就知道幸灾乐祸,我看了都很气愤。[/quote]

鄙人愚见:上回在网上好像看到这位作 7.04 的小白鼠就被幸灾乐祸。这位怎么总是见到这样的场面……
附:SCIM 五笔码表太不行,下学期一定要换。连“幸灾乐祸”都没。

回答楼主问题:个人认为现在这样讨论,大家都是语言的奴隶。语言是实现目标的工具。你要写一个加法程序,你考虑 C 还是 C++ 吗?要我,我还 PRINT A + B 呢!两者有区别就感性认识,要用的、常用的深入了解。人其实是自己的奴隶。
头像
speme
帖子: 723
注册时间: 2005-10-02 8:22
联系:

#77

帖子 speme » 2007-08-04 17:18

至高之光 写了:人其实是自己的奴隶。
这句深刻.
sleets
帖子: 18
注册时间: 2006-06-07 20:51

#78

帖子 sleets » 2007-08-05 23:39

我估计这里大部分都不能说同时理解了c和c++的精神,就发表评论。(包括我)

现实中基本所有的操作系统都是c写的, 大部分的影响深远的程序也是c写的。

相对来说: c++看重的是逻辑, c要兼顾逻辑和硬件。
xhsh
帖子: 318
注册时间: 2007-06-21 2:52

Re: c++是让人变语言的奴隶,c是让语言变人的奴隶。

#79

帖子 xhsh » 2007-08-07 21:00

eexpress 写了:赞成的举手。
那你的意思是,c比c++更好?

如果这样,正好,我还没学c++呢,哈哈
qiu_923
帖子: 250
注册时间: 2007-05-06 10:39

#80

帖子 qiu_923 » 2007-08-07 21:34

意志要坚定
头像
weaveol
帖子: 10
注册时间: 2007-07-24 22:54
来自: 火星
联系:

#81

帖子 weaveol » 2007-08-07 21:50

楼上才是正解.....
Weave Us The Sunshine,Weave Us The Hope Of A New Tomorrow.
evaxige
帖子: 4
注册时间: 2006-11-02 9:57

补充一些资料

#82

帖子 evaxige » 2007-08-09 13:11

===============C版的HelloWorld=================

代码: 全选

#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
来自: 上海
联系:

#83

帖子 danielwyo » 2007-08-09 16:06

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


希望那些只会评论些抽象概念的人还有评论不带具体论证却只会自命清高的人, 能够指出具体的可以讨论的东西来.
讨论些有实质内容的东西更加有意义, 不是吗?
Love in' Littlewhite
头像
danielwyo
帖子: 66
注册时间: 2007-02-15 20:58
来自: 上海
联系:

#84

帖子 danielwyo » 2007-08-09 16:15

===============C版的HelloWorld=================
代码:
#include <stdio.h>

int main ( void )
{
printf ( "Hello, World\n" );

return 0;
}


这样的代码其实不仅仅是C的, C++也可以这样.
既然都有同样的代码实现, 进行语言本身的比较, 应该也用同样的代码, 不能把iostream都包进来进行比较.

否则这个比较就有失公正了, 不是吗?
Love in' Littlewhite
头像
danielwyo
帖子: 66
注册时间: 2007-02-15 20:58
来自: 上海
联系:

#85

帖子 danielwyo » 2007-08-09 16:25

有些人不拿出具体的论证, 却只会说, 某某软件是使用某种语言做的, 就说明某种语言是优秀的, 而别的语言是差的, 这没有任何意义.

大家都喜欢拿GTK来说事, 因为它证明了C语言也可以实现OO, 其实就算是使用汇编语言, 也可以实现优秀的代码, 但是这在生产效率上来说, 并不合理. 而且, 在事实上, GTK已经成为一种多样化的平台了, 而不是单纯一种C语言的库, 如gtkmm, java-gnome, PyGTK等等, 都是官方认可的.
Love in' Littlewhite
3162073
帖子: 14
注册时间: 2007-05-10 23:10

#86

帖子 3162073 » 2007-08-10 16:17

我承认,现在拿C去抨击C++效率有点太吹毛求疵了....还是参照物的问题~,跟JAVA比,那C++的效率真是没得说..
3162073
帖子: 14
注册时间: 2007-05-10 23:10

#87

帖子 3162073 » 2007-08-10 16:18

上面编译是 要带上-static 参数~ 这样更公平点
至高之光
帖子: 77
注册时间: 2007-06-25 22:12

#88

帖子 至高之光 » 2007-08-11 18:16

danielwyo 写了:有些人不拿出具体的论证, 却只会说, 某某软件是使用某种语言做的, 就说明某种语言是优秀的, 而别的语言是差的, 这没有任何意义.

大家都喜欢拿GTK来说事, 因为它证明了C语言也可以实现OO, 其实就算是使用汇编语言, 也可以实现优秀的代码, 但是这在生产效率上来说, 并不合理. 而且, 在事实上, GTK已经成为一种多样化的平台了, 而不是单纯一种C语言的库, 如gtkmm, java-gnome, PyGTK等等, 都是官方认可的.
赞成,语言是表现形式。
PS SCIM五笔太垃圾……无98就算了,词库小得可以……
头像
qkthomas
帖子: 503
注册时间: 2006-12-16 22:05
来自: 肇庆

#89

帖子 qkthomas » 2007-08-11 18:35

用c#,2个也不是
neocorleone
帖子: 196
注册时间: 2007-06-06 14:24

#90

帖子 neocorleone » 2007-08-12 10:05

楼上的说得好阿,不知道楼主是怎么想的,楼上的竟然被禁了,难道这块地方也不是一片净土。
C是面向过程,C++是面向对象,写大的程序,哪个有优势!
回复