😺

プログラミングの用語いくつか

2021/05/23に公開

主にJavaでの説明を目指してます。

lifetime/extent

portion of execution time when a value is present in memory

heap

stores dynamically allocated data

詳細:

Java Heap space is used by java runtime to allocate memory to Objects and JRE classes. Whenever we create an object, it’s always created in the Heap space.

Garbage Collection runs on the heap memory to free the memory used by objects that don’t have any reference. Any object created in the heap space has global access and can be referenced from anywhere of the application.

ヒープにあるオブジェクトはスレッド間でも共有される。

jar

utility to make a Java archive

JAR stands for Java ARchive. It's a file format based on the popular ZIP file format and is used for aggregating many files into one. Although JAR can be used as a general archiving tool, the primary motivation for its development was so that Java applets and their requisite components (.class files, images and sounds) can be downloaded to a browser in a single HTTP transaction, rather than opening a new connection for each piece. This greatly improves the speed with which an applet can be loaded onto a web page and begin functioning. The JAR format also supports compression, which reduces the size of the file and improves download time still further. Additionally, individual entries in a JAR file may be digitally signed by the applet author to authenticate their origin.

allocation

Upon instantiation, a range of bytes is assigned to the object

pointer arithmetic

**Using the memory address as a number **

詳細:

ポインターを利用した演算。Javaではできない。

Dereference

accessing memory location of a pointer.

詳細:

ポインタは変数のアドレスを格納している。実際の変数にアクセスする場合は、ポインタが格納しているアドレスにアクセスする。これをDereferenceという。Dereferenceして取得した値がnullだった場合、NullPointerExceptionが起こる。

Reentrant

a piece of code runs in many instances.

詳細:

A computer program or subroutine is called reentrant if multiple invocations can safely run concurrently on a single processor system, where a reentrant procedure can be interrupted in the middle of its execution and then safely be called again ("re-entered") before its previous invocations complete execution. The interruption could be caused by an internal action such as a jump or call, or by an external action such as an interrupt or signal, unlike recursion, where new invocations can only be caused by internal call.

Describes code that can be used by multiple parties simultaneously without side-effects (e.g. can be safely called by multiple threads).

https://embeddedartistry.com/fieldmanual-terms/reentrant/

idempotentは数学の文脈で見るが、reentrantはidempotentと同じように思えるので調べてみた。
reentrantは、並列して実行されてもお互いに影響し合わないようなプログラムの性質。これが性質しないような状況としては、グローバル変数がルーチン内にあって、そのせいでルーチンが外部の影響を受けている場合。idempotentは、同じ入力に対しては必ず同じ結果を返すという性質。idempotentである場合は、reentrantであると言えるが、reentrantだからと言ってidemopotentとは限らない。

ここできになるのは、reentrantとthread-safeの違いだ。

An operation is “thread-safe” if it can be performed from multiple threads safely, even if the calls happen simultaneously on multiple threads.
An operation is re-entrant if it can be performed while the operation is already in progress (perhaps in another context). This is a stronger concept than thread-safety, because the second attempt to perform the operation can even come from within the same thread.

https://devblogs.microsoft.com/oldnewthing/20040629-00/?p=38643

package/import

keywords to declare a package, import a package

static

there is always exactly one instance of it, and that belongs to the class

final

immutable primitive types: the value of the variable cannot be changed

initializer block

a block inside the class, runs upon instance initialisation

Initialization blocks are executed whenever the class is initialized and before constructors are invoked.

finalで宣言する変数への代入もこのブロック内で定義可能。

Discussion