Talk:Computer program: Difference between revisions

Content deleted Content added
 
(16 intermediate revisions by 6 users not shown)
Line 54:
}}<!-- 13:49 June 30, 2019 (UTC), Sam Sailor added [[Template:Oca]] -->
<!-- Update the bot settings if you move the page, see WP:POSTMOVE. -->
 
== Correct results for Prolog numeric grade example ==
 
The displayed results for Prolog's numeric grade example is not what the user would expect. The article says the results will display: X = 'A'. The expected results should display: X = 4. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 19:59, 16 August 2023 (UTC)
 
:The example in its current form has two relations, which can be queried in isolation, or which can be queried in combination (like a join in a relational database). For example:
<syntaxhighlight lang="prolog">
numeric_grade('A', 4).
numeric_grade('B', 3).
numeric_grade('C', 2).
numeric_grade('D', 1).
numeric_grade('F', 0).
numeric_grade(X, -1) :- not X = 'A', not X = 'B', not X = 'C', not X = 'D', not X = 'F'.
grade('The Student', 'A').
?- grade('The Student', X), numeric_grade(X, Y).
X = 'A',
Y = 4
</syntaxhighlight>
:Alternatively, the query could be used to define a new relation, which gives the grade of a student as a number:
<syntaxhighlight lang="prolog">
numeric_grade('A', 4).
numeric_grade('B', 3).
numeric_grade('C', 2).
numeric_grade('D', 1).
numeric_grade('F', 0).
numeric_grade(X, -1) :- not X = 'A', not X = 'B', not X = 'C', not X = 'D', not X = 'F'.
grade_as_number(Student, Number) :-
grade(Student, Letter), numeric_grade(Letter, Number).
grade('The Student', 'A').
?- grade_as_number('The Student', Number).
Number = 4
</syntaxhighlight> [[User:Robert Kowalski|Robert Kowalski]] ([[User talk:Robert Kowalski|talk]]) 08:18, 18 August 2023 (UTC)
 
Followup: It would be nice to learn Prolog's syntax for forming functions. Could this example be converted to a function? If so, then how would the the driver program execute it? [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 20:33, 16 August 2023 (UTC)
 
: Here is the example in [[Ciao (programming language) | Ciao]] Prolog's functional syntax:
 
<syntaxhighlight lang="prolog">
numeric_grade('A') := 4.
numeric_grade('B') := 3.
numeric_grade('C') := 2.
numeric_grade('D') := 1.
numeric_grade('F') := 0.
numeric_grade(X) := -1 :- X \= 'A', X \= 'B', X \= 'C', X \= 'D', X \= 'F'.
grade_as_number(Student) := numeric_grade(grade(Student)).
grade('The Student') := 'A'.
grade(bob) := good.
 
?- ~grade_as_number(Student) = Number.
Number = 4,
Student = 'The Student' ;
 
Number = -1,
Student = bob
</syntaxhighlight>
 
:Just for fun, the query asks for all input-output pairs that satisfy the functional relationship "grade_as_number". Good for debugging.
 
:Ciao executes the functional program by transforming it into the relational representation, with the value of the function as the last argument of the relation.
 
== Prolog example use of word "clause" ==
Line 262 ⟶ 203:
::/2 yes, per my library example. [[Object file]] and [[object file]] are other examples of software that is not necessarily a computer program. ~[[User:Kvng|Kvng]] ([[User talk:Kvng|talk]]) 15:01, 14 June 2025 (UTC)
:::Yes, object files and other libraries are ready to be linked. Whereas they are not source code, they are computer programs. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 16:20, 14 June 2025 (UTC)
:::Followup: In "Comparative Programming Languages, Third Edition", the authors write, {{tq|"A computer is a tool that solves problems by means of programs (or software) written in a programming language."}} In the Implementation section is written, {{tq|"Execution of a program written in an imperative language, such as Pascal, Ada, or C++, normally takes place by translating (compiling) the source program into an equivalent machine code program. This machine code is then executed."}} In the Separate Compilation section is written, {{tq|"Packages ... can be compiled separately..."}} In "C How to Program, Second Edition", the author writes, {{tq|"The compiler translates the C program into machine language code (also referred to as object code)."}} Later it says, {{tq|"The fourth phase is called linking. C programs typically contain references to functions defined elsewhere such as in the standard libaries or in the libraries of a group of programmers working on a particular project."}} It also says, {{tq|"A linker links the object code with the code for the missing functions to produce an executable."}} Therefore, computer programs (also called software) are written in a programming language that gets translated to another computer program called machine language. Large computer programs may be separated into object code files for convenience. The entire library is then compiled to an executable computer program. Software (also called computer programs) can exist at different levels. At each level, it's still called software -- it's still called computer programs. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 21:40, 14 June 2025 (UTC)
::::You're really straining to interpret this source to say what you want it to say. ~[[User:Kvng|Kvng]] ([[User talk:Kvng|talk]]) 15:54, 2 July 2025 (UTC)
: {{strike|'''merge'''}} Software is a type of thing, a bit like metal is a type of substance. A computer program is a bundle of software and other resources needed to perform some task on a computer. So, a computer program contains software, but can also contain other things, like graphics or data for the task. They are not quite the same thing, but it is reasonable to have one WP article that covers both topics as long as the distinction is covered in the article. The merged article will still need some work as both articles include some misconceptions. — [[User:GhostInTheMachine|GhostInTheMachine]] <sup>[[User talk:GhostInTheMachine|talk to me]]</sup> 07:36, 23 June 2025 (UTC)
::# Regarding "metal is a type of substance": I agree. Dictionary.com says, "[metal is] any of a class of elementary substances ... which are characterized by [additional attributes]". The set of metals is a subset of the set of substances. Therefore, metals have all the properties of substances, plus additional properties that other substances don't have.
::# Regarding "a computer program contains software, but can also contain other things, like graphics or data for the task.": I disagree. The set of computer programs is not a subset of the set of software. Computer programs do have all the properties of software -- they are the instructions for the CPU. However, they don't have additional attributes. Therefore, the set of computer programs equals the set of software. Likewise, the set of software equals the set of computer programs.
::# On the other hand, graphic files are bytes stored in files. They probably don't have any instructions for the CPU. Likewise, data for the task are bytes stored in files.
::# Both graphics files and data for the task may contain embedded, auxiliary instructions for the CPU. Therefore, those isolated blocks are computer programs/software. But not the whole file. I would be confusing my reader if I were to write, "Attached is your graphics file computer program." Instead, I would write, "Attached is your graphics file which loads into the computer program."
::[[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 13:22, 23 June 2025 (UTC)
::: Oh dear. Having written a fair bit of the stuff, I do know that a '''computer program''' may contain non-software components. Casual use may equate the terms, in much the same way that WWW and Internet are often treated as synonyms, but at a technical level they are not the same thing — [[User:GhostInTheMachine|GhostInTheMachine]] <sup>[[User talk:GhostInTheMachine|talk to me]]</sup> 15:18, 23 June 2025 (UTC)
::::You didn't refute my claims that graphics files and data for the tasks are not computer programs. Yes, WWW and Internet are synonyms. Regarding {{tq|"I do know that a '''computer program''' may contain non-software components."}}: Please be technical. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 16:09, 23 June 2025 (UTC)
::::Additional thought: The Internet is a web of networks scattered throughout the wide world. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 16:24, 23 June 2025 (UTC)
 
:In summary, at this point, you have my contention that software is a subset of a computer program because a library is software but not a computer program and we have [[User:GhostInTheMachine|GhostInTheMachine]]'s contention that a computer program is a superset of software because it can contain images and other ancillary data needed to perform its function. We haven't heard anything more from other participants {{u|Kri}} or {{u|RastaKins}}. ~[[User:Kvng|Kvng]] ([[User talk:Kvng|talk]]) 15:54, 2 July 2025 (UTC)
::In "C How to Program, Second Edition", the author writes, {{tq|C programs typically contain references to functions defined elsewhere such as in the standard library or in the libraries of a group of programmers working on a particular project."}} It also says, {{tq|"A linker links the object code with the code for the missing functions to produce an executable."}} These two sentences indicate the author believes that libraries and computer programs are the same thing. Please:
::# Disagree with my indication and explain why.
::# Quote a sentence or two from a reliable source that indicate a library of functions isn't a computer program.
::Also, GhostinTheMachine has not refuted my claims that graphics files and data for the task are not computer programs. Also, I challenged GhostinTheMachine to be technical regarding the {{tq|I do know that a '''computer program''' may contain non-software components}} claim. No technical explanation was provided. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 16:39, 2 July 2025 (UTC)
::The [[software]] article will probably survive because [[Wikipedia:Be_Afraid|many editors have contributed to it]], and that's okay. However, I'm not going to let a [[semantic argument]] insult my intelligence. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 17:05, 2 July 2025 (UTC)
:::The new quotes do not clearly support your position IMO - the word ''software'' does not appear in them. We need a [[WP:CONSENSUS|consensus of editors]] to proceed with the merge. That does not mean you need to get my agreement to proceed but we do need to hear from other editors who see it the way you do and that has not happened. ~[[User:Kvng|Kvng]] ([[User talk:Kvng|talk]]) 14:57, 12 July 2025 (UTC)
* '''oppose''' — revisited both articles, so reversing my comment. Both articles need some work, so any attempt to merge them will probably prove troublesome and most likely impossible — [[User:GhostInTheMachine|GhostInTheMachine]] <sup>[[User talk:GhostInTheMachine|talk to me]]</sup> 16:05, 24 July 2025 (UTC)
 
== AmE vs BrE ==
 
The British traditional spelling of "program" is "programme". This is the only exception, computer program. The rest are programme in British English. Program is the British spelling in sense of computer programming. [[User:Dotsenter21|Dotsenter21]] ([[User talk:Dotsenter21|talk]]) 01:10, 19 June 2025 (UTC)
 
:Somewhere, I remember reading that Wikipedia doesn't care which English spelling is used, as long as the entire article is consistent. Also, the first major edit of the article should start the consistency. [[User:Timhowardriley|Timhowardriley]] ([[User talk:Timhowardriley|talk]]) 06:15, 19 June 2025 (UTC)