The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] where did "main" come from?
@ 2020-05-22 18:43 Lawrence Stewart
  2020-05-22 20:01 ` Michael Kjörling
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lawrence Stewart @ 2020-05-22 18:43 UTC (permalink / raw)
  To: The Eunuchs Hysterical Society

C main programs define “main”.
This also seems to be true of B main programs, according to the Johnson/Kernighan manual
The 1967 Martin Richards BCPL manual doesn’t explain how programs get started
The 1974 update from Martin Richards says there should be an OS addendum that explains this.
The 1974 University of Essex BCPL manual says to use START
The 1979 Parc Alto BCPL manual uses Main and I think that must be unchanged from 1972.
The AMSTRAD BCPL guide from 1986 uses start()


So who started “main” and when?  I can’t find an online copy of the Bell Laboratories BCPL manual (Canaday/Thompson) from 1969 or anything about how to use BCPL on Multics or CTSS.

-L


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 18:43 [TUHS] where did "main" come from? Lawrence Stewart
@ 2020-05-22 20:01 ` Michael Kjörling
  2020-05-22 21:52 ` Clem Cole
  2020-05-22 22:08 ` Charles Anthony
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Kjörling @ 2020-05-22 20:01 UTC (permalink / raw)
  To: tuhs

On 22 May 2020 14:43 -0400, from stewart@serissa.com (Lawrence Stewart):
> C main programs define “main”.

I don't have a ready answer to your question where that name came
from, but it's worth remembering (and easy to forget) that main()
isn't the actual starting point of execution of a C program. Rather,
the starting point is a function within the C library, which does some
early setup work and then ultimately calls main() and takes care of
passing the return value from main() back to the operating system (see
[1] for Linux, for example).

This is perhaps most obvious in C programs for Microsoft Windows,
which don't have the traditional main() but do have a WinMain() in its
place.

It looks like at least glibc uses _start as the actual entry point
[2]. In turn, on x86-64 (and very likely also on other architectures),
that calls __libc_start_main(), which in turn calls main() via a
function pointer passed to it.

 [1]: https://refspecs.linuxbase.org/LSB_3.1.0/LSB-generic/LSB-generic/baselib---libc-start-main-.html
 [2]: https://blogs.oracle.com/linux/hello-from-a-libc-free-world-part-1-v2

-- 
Michael Kjörling • https://michael.kjorling.se • michael@kjorling.se
 “Remember when, on the Internet, nobody cared that you were a dog?”


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 18:43 [TUHS] where did "main" come from? Lawrence Stewart
  2020-05-22 20:01 ` Michael Kjörling
@ 2020-05-22 21:52 ` Clem Cole
  2020-05-22 22:00   ` Rob Pike
  2020-05-22 23:33   ` Toby Thain
  2020-05-22 22:08 ` Charles Anthony
  2 siblings, 2 replies; 7+ messages in thread
From: Clem Cole @ 2020-05-22 21:52 UTC (permalink / raw)
  To: Lawrence Stewart; +Cc: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

It's interesting, I was thinking about this the other day too.   I
remember talking about the 'main program' in Fortran when I was learning.
I never thought about it when I saw it in C, other than, ok that's how you
pass command line args, which I thought was really clean.   I remember TOPS
and TSS you had to go rummaging around to get to them.

As for your BCPL question, START() was way I learned it.  I think I first
saw it on the 360s or maybe the 1108; but really never did much it until I
saw the first Altos.

Clem

On Fri, May 22, 2020 at 2:53 PM Lawrence Stewart <stewart@serissa.com>
wrote:

> C main programs define “main”.
> This also seems to be true of B main programs, according to the
> Johnson/Kernighan manual
> The 1967 Martin Richards BCPL manual doesn’t explain how programs get
> started
> The 1974 update from Martin Richards says there should be an OS addendum
> that explains this.
> The 1974 University of Essex BCPL manual says to use START
> The 1979 Parc Alto BCPL manual uses Main and I think that must be
> unchanged from 1972.
> The AMSTRAD BCPL guide from 1986 uses start()
>
>
> So who started “main” and when?  I can’t find an online copy of the Bell
> Laboratories BCPL manual (Canaday/Thompson) from 1969 or anything about how
> to use BCPL on Multics or CTSS.
>
> -L
>
>

[-- Attachment #2: Type: text/html, Size: 2071 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 21:52 ` Clem Cole
@ 2020-05-22 22:00   ` Rob Pike
  2020-05-22 23:33   ` Toby Thain
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Pike @ 2020-05-22 22:00 UTC (permalink / raw)
  To: Clem Cole; +Cc: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

After joining the Labs I mentioned to Dennis that the idea of "main" did
not appear in the semi-formal specification of C in the back of the first
edition of The C Programming Language. (It obviously appears in the front
half.) He was very surprised, but maybe it's an indication that the idea of
"main" was already part of the culture. I first encountered it in the
phrase PROCEDURE OPTIONS MAIN that begins every PL/I program. PL/I was
defined in the early 1960's.

-rob

[-- Attachment #2: Type: text/html, Size: 563 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 18:43 [TUHS] where did "main" come from? Lawrence Stewart
  2020-05-22 20:01 ` Michael Kjörling
  2020-05-22 21:52 ` Clem Cole
@ 2020-05-22 22:08 ` Charles Anthony
  2 siblings, 0 replies; 7+ messages in thread
From: Charles Anthony @ 2020-05-22 22:08 UTC (permalink / raw)
  To: Lawrence Stewart; +Cc: The Eunuchs Hysterical Society

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]

On Fri, May 22, 2020 at 11:54 AM Lawrence Stewart <stewart@serissa.com>
wrote:

>  I can’t find an online copy of the Bell Laboratories BCPL manual
> (Canaday/Thompson) from 1969 or anything about how to use BCPL on Multics
> or CTSS.


In general, Multics does not have a concept of "main"; the entry point of a
program is the name of the program. Looking at the Multics runoff sources
(written in BCPL) we see in the segment runoff_driver.bcpl:

external
     $(   RunoffCommand = "runoff"
...


let RunoffCommand () be main
     $(   MONITOR := Open (StreamName + Write, "error_output")        //
 Errors, etc. written here.
...

BCPL replaces the name RunoffCommand with runoff during compilation; the
compiled segment runoff_driver will have an entry point "runoff". Entering
the command "runoff" will search segments in the search path for that entry
point.

Since segments can have multiple entry points, the idea of "main" (or
"start" or "start_") as the defining entry point is not meaningful in
Multics.

The Multics C compiler (based on PCC) does have a  concept of main; the C
linker aliases that to the segment name, making the entry point name the
same as the segment name. Thus compiling and linking foo.c generates a
segment foo with an entry point foo, which points to main. (Actually, it
aliases it to the C runtime library initialization which calls main.)

-- Charles
-- Charles

[-- Attachment #2: Type: text/html, Size: 2068 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 21:52 ` Clem Cole
  2020-05-22 22:00   ` Rob Pike
@ 2020-05-22 23:33   ` Toby Thain
  2020-05-22 23:58     ` Win Treese
  1 sibling, 1 reply; 7+ messages in thread
From: Toby Thain @ 2020-05-22 23:33 UTC (permalink / raw)
  To: tuhs

On 2020-05-22 5:52 PM, Clem Cole wrote:
> It's interesting, I was thinking about this the other day too.   I
> remember talking about the 'main program' in Fortran when I was
> learning.  I never thought about it when I saw it in C, other than, ok
> that's how you pass command line args, which I thought was really
> clean.   I remember TOPS and TSS you had to go rummaging around to get
> to them.  
> 
> As for your BCPL question, START() was way I learned it.  I think I
> first saw it on the 360s or maybe the 1108; but really never did much it
> until I saw the first Altos. 

This chart could lead to some predictable conclusions, don't know if
they are correct:

https://books.google.com/ngrams/graph?content=main+program&year_start=1930&year_end=2008&corpus=17&smoothing=3&share=&direct_url=t1%3B%2Cmain%20program%3B%2Cc0


> 
> Clem  
> 
> On Fri, May 22, 2020 at 2:53 PM Lawrence Stewart <stewart@serissa.com
> <mailto:stewart@serissa.com>> wrote:
> 
>     C main programs define “main”.
>     This also seems to be true of B main programs, according to the
>     Johnson/Kernighan manual
>     The 1967 Martin Richards BCPL manual doesn’t explain how programs
>     get started
>     The 1974 update from Martin Richards says there should be an OS
>     addendum that explains this.
>     The 1974 University of Essex BCPL manual says to use START
>     The 1979 Parc Alto BCPL manual uses Main and I think that must be
>     unchanged from 1972.
>     The AMSTRAD BCPL guide from 1986 uses start()
> 
> 
>     So who started “main” and when?  I can’t find an online copy of the
>     Bell Laboratories BCPL manual (Canaday/Thompson) from 1969 or
>     anything about how to use BCPL on Multics or CTSS.
> 
>     -L
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [TUHS] where did "main" come from?
  2020-05-22 23:33   ` Toby Thain
@ 2020-05-22 23:58     ` Win Treese
  0 siblings, 0 replies; 7+ messages in thread
From: Win Treese @ 2020-05-22 23:58 UTC (permalink / raw)
  To: TUHS main list



> On May 22, 2020, at 7:33 PM, Toby Thain <toby@telegraphics.com.au> wrote:
> 
>> As for your BCPL question, START() was way I learned it.  I think I
>> first saw it on the 360s or maybe the 1108; but really never did much it
>> until I saw the first Altos. 
> 
> This chart could lead to some predictable conclusions, don't know if
> they are correct:
> 
> https://books.google.com/ngrams/graph?content=main+program&year_start=1930&year_end=2008&corpus=17&smoothing=3&share=&direct_url=t1%3B%2Cmain%20program%3B%2Cc0

This is straying way off topic, but I thought it would be interesting to look at a couple of older sources about it, say, from the late 1940s when there were computers with programs.

A search on Google Books in the date range 1800-1950 gives a lot of hits (at least 10 screens worth). Since it’s Google, your results may vary, but here are the first few I got:

- US Congress hearings on National Health Program, 1946: "Any discussion on either the main program or the amendment to…” Fair enough. Got the phrase, it’s in the range. Just not relevant to the current investigation.

- C Programming: Test Your Skills by Ashok Kamthane, dated by Google Books to 1900

- Information Circular, dated 1925, with the excerpt starting “It consists of a main program, two subroutine subprograms, A macro-flow chart of the program is shown on figure A-1”. Which seems odd, because that pretty clearly isn’t really from 1925. So I clicked through the document, which turns out to be Information Circular 1601: Corrosion Resistance of Metals in Hot Brines: A Literature Review” published by the US Bureau of Mines in 1973.
It also does not have the excerpt in the document.

- Programming Techniques Through C: A Beginners Companion by M. G. Venkateshmurthy, dated 1900.

- Technical Bulletin, Issues 206-216, dated 1922 with the excerpt "The main program (MAIN) will be discussed first and then each of the subroutines called by the main program. Sometimes the subroutines called by the main program call other subroutines.”. Clicking through to it gives the response “No results in this book for ‘main program’”. This turns out to be incorrect, because somewhere between the Google Books server and my Safari browser the search string was mishandled. Changing it in the search box gives 3 snippets referencing “main program”, and the document is apparently about a FORTRAN program compiled with the CDC6400 FTN version 3 compiler. However, nothing more than the snippets is available and the 1922 date is obviously wrong.

Remaining items on the first page are similarly clearly misdated or about non-computer main programs.

No one said archival research is easy, but Google Books does present itself as having better data than it delivers.

- Win



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-22 23:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 18:43 [TUHS] where did "main" come from? Lawrence Stewart
2020-05-22 20:01 ` Michael Kjörling
2020-05-22 21:52 ` Clem Cole
2020-05-22 22:00   ` Rob Pike
2020-05-22 23:33   ` Toby Thain
2020-05-22 23:58     ` Win Treese
2020-05-22 22:08 ` Charles Anthony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).