# Jovial

Jovial is an old language that was originally developed for programming avionics and other real-time systems.

Jovial is essentially a dead language. The code of this example was modeled after samples from the 1961 Jovial report. I make this claim despite the fact that you can go on-line and find up-to-date Jovial support pages, and ads for Linux-based Jovial compilers.

If you really want a Jovial compiler you can get one. It might be expensive and you might have to go through a lot of rigamarole to get it, but a current Jovial compiler for modern PCs does indeed exist. However, the cost of such a compiler is beyond the resources of this little archive. It's probably also beyond the resources of the average programmer. So unless you've got a government contract, getting a Jovial compiler is probably not in your future.

The code in this example has never been run, and probably does not work. However, it does show the flavor of the Jovial language.

START

''////////////////////////////////////////////////////////// ''

''// Name: Peter M. Maurer ''

''// Program: Sieve of Eratosthenes ''

''// Due: Never ''

''// Language: Jovial ''

''////////////////////////////////////////////////////////// ''

FILE MYOUTPUT ... \$ ''Insufficient information to complete this declaration''

PROC SIEVEE \$

'' define the sieve data structure ''

ARRAY CANDIDATES 1000 B \$

FOR I =0,1,999 \$

BEGIN

'' everything is potentially prime until proven otherwise ''

CANDIDATES(\$I\$) = 1\$

END

'' Neither 1 nor 0 is prime, so flag them off ''

CANDIDATES(\$0\$) = 0\$

CANDIDATES(\$1\$) = 0\$

'' start the sieve with the integer 0 ''

FOR I = 0\$

BEGIN

IF I GE 1000\$

GOTO DONE\$

'' advance to the next un-crossed out number. ''

'' this number must be a prime ''

NEXTI.  IF I LS 1000 AND Candidates(\$I\$) EQ 0 \$

BEGIN

I = I + 1 \$

GOTO NEXTI \$

END

'' insure against running off the end of the data structure ''

IF I LT 1000 \$

BEGIN

'' cross out all multiples of the prime, starting with 2*p. ''

FOR J=2 \$

FOR K=0 \$

BEGIN

K = J * I \$

IF K GT 999 \$

CANDIDATES(\$K\$) = 0 \$

J = J + 1 \$

END

'' advance to the next candidate ''

ADV.        I = I + 1 \$

END

END

'' all uncrossed-out numbers are prime (and only those numbers) ''

'' print all primes ''

DONE. OPEN OUTPUT MYOUTPUT \$

FOR I=0,1,999\$

BEGIN

IF CANDIDATES(\$I\$) NQ 0\$

BEGIN

OUTPUT MYOUTPUT I \$ '' probably not correct ''

END

END

TERM\$