总会有必须知道机器架构编写code?总会有、架构、机器、code

2023-09-09 21:15:55 作者:亅,你的怀抱太不现实ˇ

比方说,我的Java编程或Python或C ++的一个简单的问题,可能是建立一个TCP / UDP echo服务的阶乘或计算。难道我有理会架构的详细信息,也就是说,如果是32位或64位?

Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit?

恕我直言,除非我编程是与相当低层次的东西,那么我不必如果打扰它的32位或64位。我在哪里的问题呢?还是我纠正???

IMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64 bit. Where am I going wrong? Or am I correct???

推荐答案

正确大多数情况下

运行时间/语言/编译器将抽象的这些细节,除非你直接用字大小或二进制处理处于较低水平。

The runtime/language/compiler will abstract those details unless you are dealing directly with word sizes or binary at a low level.

即使byteorder是由内核中的网卡/网络堆栈抽象。它被翻译为您服务。当C语言编程插座,你有时不得不将数据发送到处理字节顺序为网络......但是,这并不担心32位或64位的差异。

Even byteorder is abstracted by the NIC/Network stack in the kernel. It is translated for you. When programming sockets in C, you do sometimes have to deal with byte ordering for the network when sending data ... but that doesn't concern 32 or 64 bit differences.

在处理二进制数据的斑点处理,从一个架构映射到另一个(作为覆盖到C结构为例)可能会导致问题,因为其他人所说的,但是这就是为什么我们开发了基于角色的架构独立的协议和等等。

When dealing with blobs of binary data, mapping them from one architecture to another (as an overlay to a C struct for example) can cause problems as others have mentioned, but this is why we develop architecture independent protocols based on characters and so on.

在-其实类似的事情在虚拟机Java运行抽象机器又迈进了一步!

In-fact things like Java run in a virtual machine that abstracts the machine another step!

了解了一下关于指令集的架构,以及如何将语法编译,可以帮助您了解的平台,并编写更干净,更严格的code。我知道我龇牙咧嘴,在一些旧的C code编译器学习后!

Knowing a bit about the instruction set of the architecture, and how the syntax is compiled to that can help you understand the platform and write cleaner, tighter code. I know I grimace at some old C code after studying compilers!