がついてお知りにな機械のコンピュータ-アーキテクチャ記コードについて教えてください。

StackOverflow https://stackoverflow.com/questions/1046068

質問

ということかんのプログラミングJavaやPython、C++のための簡単な問題が構築TCP/UDPのechoサーバーや計算の要因.なんでわざわざして建築についての詳細は、の場合は32または64ビット?

まぁいっというかなり低レベルもしないわざわざその32または64ビット.明日へ向かって走れは間違いだったのか?または私は正確ですか???

役に立ちましたか?

解決

修正のためのほとんどの場合において

ランタイム/言語/コンパイラの抽象者詳細ない限り、直接対応言葉のサイズはバイナリするものです。

もbyteorderが抽象化により、NIC/ネットワークスタックを含んでいます。で翻訳します。グソケットCいものとしてのバイト順序は、ネットワークデータの送信時に...な懸念32または64ビット。

を扱う時に用途にでも便のバイナリデータマッピングしてからコンピュータ-アーキテクチャは他のものとして、オーバーレイCの構造体)の問題を引き起こす可能性がありとてものの、その開発と建築独立したプロトコルに基づく文字です。

とのようなJava実行される仮想マシンが 講演概要集機械 他のステップ!

知ることは少 の命令セットの建築がどのよう書式で作成することを理解できるように支援し、プラットフォームと書きクリーナー厳します。思いgrimaceであCコードを学んだ後、コンパイラでコンパイル!

他のヒント

るかを知ることも、仕事でどのように仮想機械製作所で作品をお使いのプラットフォーム、そしてどのようなC++を構築しま換会は常にあなたをより善いプログラマーで参りますので、ご理解の程、何か物事を行います。

必要なものを理解することができたような気のような記憶をどのキャッシュ-ヒントは、なぜそばには影響します。ついて把握しておく必要があるものの実施かもしれまでのみ使用、またはインタフェースレベルの高い方法であるかを知ることで作品となくやっているので最高です。

パケットの作業が必要かデータを保存することがでプラットフォームでどのように送ることのネットワークを異なるプラットフォームが方法を変更データの読み込み(リトルエンディアンらしさ).

コンパイラを使プラットフォームのん作成のものではないでどんなこだわり標準コードは、こちらをクリックして下さいを無視できるほうものとし、コンパイラは鞭どのようなのです。

などにより,no.かを知る必要があり、低レベルのものですが、 な痛みを知る.

私は、Java言語仕様で最後に見た時は、それは整数ボクシングのセクションでとんでもない落とし穴が含まれています。

Integer a = 100;
Integer b = 100;

System.out.println(a == b);

これは、true印刷することが保証されます。

Integer a = 300;
Integer b = 300;

System.out.println(a == b);

<=>印刷することが保証されていないこと。これは、ランタイムに依存しています。スペックは完全にオープン、それを残しました。 (文字列リテラルが抑留されている方法に類似した)「インターン」オブジェクト-128と127リターンの間にint型をボクシングが、言語ランタイムの実装者は、彼らが望むなら、その上限を引き上げることが奨励されているためにです。

私は個人的に非常識な決定としてあることを考えると、私は以来、彼らはそれを修正しました願っています(一度書けばどこでも動く?)

おすすめの必要。

できる驚くべきこれらの低レベルの詳細は突然飛び出し、食い込みます。たとえば、Javaの標準化 double する64ビット.しかし、LinuxのJVMの"拡張精密モードの場合、ダブルは80ビットなどではCPUするものとする。これは次のコードは失敗する場合があり:

double x = fun1();
double y = x;

System.out.println(fun2(x));

assert( y == x );

でyを強制的に登録のメモリへと切り捨てから80 64ビット.

In Java and Python, architecture details are abstracted away so that it is in fact more or less impossible to write architecture-dependant code.

With C++, this is an entirely different matter - you can certainly write code that does not depend on architecture details, but you have be careful to avoid pitfalls, specifically concerning basic data types that are are architecture-dependant, such as int.

As long as you do things correctly, you almost never need to know for most languages. On many, you never need to know, as the language behavior doesn't vary (Java, for example, specifies the runtime behavior precisely).

In C++ and C, doing things correctly includes not making assumptions about int. Don't put pointers in int, and when you're doing anything with memory sizes or addresses use size_t and ptrdiff_t. Don't count on the size of data types: int must be at least 16 bits, almost always is 32, and may be 64 on some architectures. Don't assume that floating-point arithmetic will be done in exactly the same way on different machines (the IEEE standards have some leeway in them).

Pretty much all OSes that support networking will give you some way to deal with possible endianness problems. Use them. Use language facilities like isalpha() to classify characters, rather than arithmetic operations on characters (which might be something weird like EBCDIC). (Of course, it's now more usual to use wchar_t as character type, and use Unicode internally.)

If you are programming in Python or in Java, the interpreter and the virtual machine respectively abstract this layer of the architecture. You then need not to worry if it's running on a 32 or 64 bits architecture.

The same cannot be said for C++, in which you'll have to ask yourself sometimes if you are running on a 32 or 64 bits machine

You will need to care about "endian-ness" only if you send and receive raw C structs over the wire like

ret = send(socket, &myStruct, sizeof(myStruct));

However this is not a recommended practice.

It's recommended that you define a protocol between the parties such it doesn't matter the parties' machine architectures.

In C++, you have to be very careful if you want to write code that works indifferently on 32 or 64 bits. Many people wrongly assume that int can store a pointer, for example.

With java and .net you don't really have to bother with it unless you are doing very low level stuff like twiddling bits. If you are using c, c++, fortran you might get by but I would actually recommend using things like "stdint.h" where you use definitive declares like uint64_t and uint32_t so as to be explicit. Also, you will need to build with particularly libraries depending on how you are linking, for example a 64 bit system might use gcc in a default 64 bit compile mode.

A 32 bit machine will allow you to have a maximum of 4 GB of addressable virtual memory. (In practice, it's even less than that, usually 2 GB or 3 GB depending on the OS and various linker options.) On a 64 bit machine, you can have a HUGE virtual address space (in any practical sense, limited only by disk) and a pretty damn big RAM.

So if you are expecting 6GB data sets for some computation (let's say something that needs incoherent access and can't just be streamed a bit at a time), on a 64 bit architecture you could just read it into RAM and do your stuff, whereas on a 32 bit architecture you need a fundamentally different way to approach it, since you simply do not have the option of keeping the entire data set resident.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top