Translation guide
A subprogram is a self-contained unit of code within a larger program, such as a function, subroutine, or procedure. In Japanese, the most common term is サブプログラム, but depending on context, more specific words like 関数 (function) or サブルーチン (subroutine) may be used.
The learner wants to refer to any self-contained code unit (function, procedure, subroutine) in a program.
A direct loanword from English, widely understood in programming contexts. It is a general term covering functions, subroutines, and procedures.
このサブプログラムはメインプログラムから呼び出されます。
This subprogram is called from the main program.
A less common Japanese translation using 副 (sub-) and プログラム (program). It is understood but sounds more formal or technical.
副プログラムの設計について議論する。
Discuss the design of subprograms.
The learner specifically means a subprogram that computes and returns a value, like a mathematical function.
The standard term for a function in programming. It implies a subprogram that returns a value. Used in most programming languages.
この関数は整数を返します。
This function returns an integer.
The learner means a subprogram that performs a task but may not return a value, often called a subroutine or procedure.
The standard loanword for subroutine. It is used in many programming contexts, especially older or procedural languages.
サブルーチンを呼び出してデータを処理する。
Call a subroutine to process the data.
A Japanese translation for 'procedure'. It is used in some academic or older texts but is less common in modern programming jargon.
The learner means a subprogram that belongs to a class or object.
The standard term for a method in object-oriented programming. It is a function associated with an object.
このクラスには3つのメソッドがあります。
This class has three methods.
サブプログラム is a broad term that encompasses both functions and subroutines. 関数 specifically implies a return value, while サブルーチン may or may not return a value. In modern programming, 関数 is often used even for subroutines that don't return a value (e.g., void functions).
C言語では、すべてのサブプログラムは関数として定義されます。
In C, all subprograms are defined as functions.
In many modern programming contexts, 関数 is the default term for any named block of code, even if it doesn't return a value. Unless you need to emphasize the distinction, 関数 is safe.
In procedural programming, procedures are the basic unit.