开发者

Sockets in C++ and Java [closed]

As it currently stands, this question is not a good 开发者_运维技巧fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I was wondering whether networking is easier in Java or C++. Because I know in Java networking with sockets and such is incredibly easy, such as doing the following:

Socket s= new Socket();
s.connect(new SocketAddress("localhost",8888));

and if it is significantly harder in C++ that heavily influences my decision. Thanks in advance!


Building working socket code in Java is easier than in C++. Building "good" socket code in either depends more on the developer's experience and skill than on the language. C++ has Boost.Asio that makes this a bit easier.


I would suggest that Java is generally easier for beginners. C++ is easier it you want to do low level programming e.g. with pointers.

In Java I would do

Socket s = new Socket("localhost",8888);

which is even easier.


C++ is conceptually more difficult than java, at least you should deal with pointers.. Most of the people has difficulties to understand pointer concept.. Also, you should allocate and free memory, if you use C++, thanks to Java GC it saves you from this burden. I think this is the most superior future of Java against C++ or C.

And your specific question, Java has built-in socket libraries, you do not need a third party for socket operations..

To sum up, C++ is harder and more difficult than java.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜