Byte杂志C++调查报告

本文是BYTE对若干开发者、公司技术负责人的调查报告,个人认为很值得一读。可惜我时间紧迫,无法为大家翻译,深表抱歉.

 

Whither Now C++?

Oh the shame of it all! After years of being the language for real programming, C++ has lost its throne as being the most popular serious language to, God help us, Java.

The Evans Data Corporation predicts that sometime in 2002, about 55% of North American developers will spend at least some time working in Java.

That popularity is coming at the expense of C/C++ and Visual Basic. Throwing salt into the wound, by 2002, Evans Data predicts that only about 51% of programmers to still be working in C and C++ and their numbers will be declining fast.

What happened?

The Waning of C++

To find out, I went to the programmers and developers in the trenches. I spoke to dyed-in-the-wool C++ programmers who are now at least beginning to consider the alternatives. This is their story.

David W. Methvin, noted technology author and consultant, speaks for many when he says of C++, "If I never have to write another line of C/C++ code I would be a happy man. The meat of the C++ language has evolved into a monster, but worse yet the trimmings now outweigh the beef. Win32/MFC/ATL/COM all try to layer more abstractions onto the low-level language but they're a nightmare to learn and use, especially if you try to use them together and need to convert between disparate data representations. NuMega's BoundsChecker helps, but often even Microsoft sample code won't pass through it without complaint so you have to wonder when the creators can't get it right."

Not everyone would go so far as Methvin does though. Mark Bartosik, Principal Software Engineer at Michael Larkin Enterprises, agrees that, "There are many libraries for C++, and C++ can interface to many other languages notably C. This is both an advantage and a disadvantage. The language 'bindings' are not always ideal, this is where a lot of bugs creep in."

But, he believes C++'s real problem isn't the language or the libraries, it's the programmers. He explains, there are three classes of C++ programmer: C programmers; traditional programmers, whose understanding of the language comes from the Annotated Reference Manual (ARM) who don't use templates; and modern C++ programmers. Larkin says, "For the later category C++ offers extremely robust, expressive, powerful, efficient means to write high-quality reliable code. These programmers will be making the maximum use of templates, STL, and other template libraries. They are generally ve

阅读终点,创作起航,您可以撰写心得或摘录文章要点写篇博文。去创作
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
以下是Byte Stuffing算法的C实现示例: ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #define FLAG 0x7E // 帧头和帧尾标志 #define ESC 0x7D // 转义字符 // 对数据进行字节填充 void byteStuffing(unsigned char* data, int len, unsigned char* stuffedData, int* stuffedLen) { int i, j; unsigned char byte; unsigned char* pos = stuffedData; // 添加帧头 *pos++ = FLAG; for(i = 0; i < len; i++) { byte = data[i]; if(byte == FLAG) { // 如果是帧头或帧尾,则需要进行字节填充 *pos++ = ESC; *pos++ = byte ^ 0x20; } else if(byte == ESC) { // 如果是转义字符,则也需要进行字节填充 *pos++ = ESC; *pos++ = byte ^ 0x20; } else { // 其他情况直接拷贝 *pos++ = byte; } } // 添加帧尾 *pos++ = FLAG; *stuffedLen = pos - stuffedData; } // 对数据进行字节反填充 void byteUnstuffing(unsigned char* stuffedData, int len, unsigned char* data, int* dataLen) { int i, j; unsigned char byte; unsigned char* pos = data; // 跳过帧头 pos++; len--; for(i = 0; i < len; i++) { byte = *stuffedData++; if(byte == ESC) { // 如果是转义字符,则进行反填充 byte = *stuffedData++ ^ 0x20; } *pos++ = byte; } // 跳过帧尾 pos--; *dataLen = pos - data; } int main() { unsigned char data[] = {0x7E, 0x01, 0x02, 0x7D, 0x7E, 0x03, 0x7D, 0x7D, 0x04, 0x7E}; int len = sizeof(data) / sizeof(data[0]); unsigned char stuffedData[2 * len]; int stuffedLen; byteStuffing(data, len, stuffedData, &stuffedLen); printf("Stuffed Data: "); for(int i = 0; i < stuffedLen; i++) { printf("%02X ", stuffedData[i]); } printf("\n"); unsigned char unstuffData[len]; int unstuffLen; byteUnstuffing(stuffedData, stuffedLen, unstuffData, &unstuffLen); printf("Unstuff Data: "); for(int i = 0; i < unstuffLen; i++) { printf("%02X ", unstuffData[i]); } printf("\n"); return 0; } ``` 输出结果: ``` Stuffed Data: 7E 01 02 7D 5E 7E 03 7D 5D 04 7E Unstuff Data: 7E 01 02 7D 7E 03 7D 7D 04 7E ``` 可以看到,字节填充和反填充都能正常工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

myan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值