OT - Programming Languages

Jan 28, 2015 188 Replies
Saved reading

Ah, just remembered (because I've just been editong one), there's another place its relevant - Makefiles. Commands after a target match have to be TAB indented. Thats using a TAB character, not 8 spaces which you often end up with after copy & pasting |-:

Gordon

There was/is a standard set of test programs that a compiler must be able to compile if its to claim to meet the standard, but I am not sure if they got any more validation than that. C was (at least in the

80's/90's viewed with much suspicion in UK defence circles), just because of its lack of readability.

Yes very much so - hence why things like C++ were used sparingly since it was far harder to mentally "count the cycles"

Alas most^h^h^h^h all the CORAL compilers I have used tend to fall into that category as well! (not to mention frequently being the slowest thing you can do with a VAX short of rolling it up hill).

One I've not heard of - but since it was "invented" in 1986 and I started programming almost 10 years earlier, it's no surprise (to me, anyway!)

So for a bit of fun in my BASIC:

// Langton's ant

// The rules are simple: Our ant starts in the middle then: // At a white square, turn right, flip the square colour, // move forward 1 square. // At a black square, turn left, flip the square colour, // move forward 1 square.

x = gwidth / 2 y = gheight / 2 direction = 0

cls

cycle

if getpixel (x, y) = black then direction = direction + 1 if direction = 4 then direction = 0 colour = white plot (x, y) else direction = direction - 1 if direction = -1 then direction = 3 colour = black plot (x, y) endif

proc updateAnt

update repeat

def proc updateAnt switch (direction) case 0 y = y + 1 endcase

case 1 x = x + 1 endcase

case 2 y = y - 1 endcase

case 3 x = x - 1 endcase

endswitch endproc

Seems to produce the desired output.

Note: spaced indentation is not significant, nor forced. It's there for my convenience, not the computers!

That's quite a good one - nice and simple. Doesn't need an array if the display device can be read back (not always possible or very inneficient on some modern systems!)

Gordon

It was quite entertaining attempting to coach a tech pubs department through producing a coding standards document - this was where they did not trust engineers to use word processors, so you would give them a document produced in a word processor. They would ignore the the fact that someone already had a file with the whole thing in it, and then re-key the whole thing into their own incompatible system - while at the same time correcting all the "errors" in the snippets of program code left in by those illiterate engineers ;-)

I think it was about iteration six or seven when they agreed that they would use our document if we let them put their own front pages on it!

Excuse me? Once you were past the label and continuation columns, whitespace was completely irrelevant to FORTRAN. (Hence the ambiguity of DO 10 I = 1.10 vs DO10I=1,10 - One is the Fortran equivalent of the C "float do10i = 1.10", the other is the equivalent of "for (i=1; i

Mrrabbitthevicar

Mr Rab bit the Vicar. Mr Rabbit the Vicar.

You patient person. I would have jumped up and down with rage by then.

You can download a reduced version of MS's tools for free. (they seem to encourage people to learn Windows development). You can have a reasonable, if slightly dated C; a fairly good C++; and of course their own C# - which is easier to learn.

And to be honest now I'm working on Android I really miss MS's tools.

And their documentation. When I want to open a file I just want to know how to do it. I don't _need_ to know how the FS does it under the hood, and sometime I find I have to reverse engineer the source just to get the interface :(

Andy

Well, there are two ways of looking at that. I actually used FORTRAN (maybe we called it Fortran by then; I'm not sure) in the late 1980s, & often ran into syntax errors caused by overtyping past column 72.

OTOH, "Consistently separating words by spaces became a general custom about the tenth century A. D., and lasted until about 1957, when FORTRAN abandoned the practice." It used to be the case that if you called a variable DODO, the compiler would parse it as DO DO & your program would be dead as a....

Note that "Guy" & "Guido" are the same...

I never use makefiles, or make. I just bung it all into Xcode and let it worry about figuring out how to build stuff.

And my tab chars are five, not eight spaces long.

My editor converts them to spaces anyway. That is the only sensible use for a tab character.

I'd just call it a pile of .....

I also used Fortran, but didn't see any advantage over basic. I felt learning Pascal and then C was more useful.

Guido works for Google now ...

I don't recall such problems with any of the compilers I used. It would have been FORTRAN77 by then - earlier compilers were less forgiving.

That is incorrect at least in correctly implemented FORTRAN compilers there are no reserved words and as such you could have coding horrors that used any reserved word you liked in any position no matter how crazy for example the arithmetic statement function:

FORMAT(A4)= A4+1.0

Lurking at the top of deliberately obfuscated code. It did crash some weaker compilers but it should not crash any of the mainstream ones.

Or equally unwise but still syntactically valid

IF (IF .EQ. THEN) IF = IF*THEN

Or the malformed DO loop that was actually typed in as

DO 13 I = 1.3

Spaces are insignificant and the mistake is full stop "." vs comma ",". It set variable DO13I = 1.3 instead of looping to 13 3 times. This text ambiguity led to the loss of Mariner 1 in 1963 see 6.8 Warning at

formatting link

Or the "reserved words" section at:

formatting link

Defensive programming practice in later years used IMPLICIT to prevent accidental assignments to typos from getting through unnoticed.

Bringing to mind the ancient example from BASIC...

FORK = 10 TOMATOES

Cheers

What's interesting about that (to someone who wrote a BASIC interpreter anyway!) is that in ye olde days the BASIC code was stored as the text you type in, then parsed and intrepreted at RUN time.

So you have fun like that, and:

REMARKABLE PROGRAM

... STEPTOE

etc.

BASICs got faster when they started to do more syntax checking on entry and tokenisation - which saved memory on the newer microprocessors and reduced the run-time overhead. Then the LIST command is essentially a de-tokenizer and as such the output then tends to be at the whim of the programmer who wrote the interpreter.

But not all BASICs do this - some tokenize and preserve spaces - leading to horrible program listings as the (BASIC) programmer tries to make their program go faster by eliminating spaces, using short variable names and so on. I'm sure that's one of the things that contributed to the current dislike of BASIC.

Gordon

So you press Tab and get five spaces (or up to five presumably if in-between tab stops).

What happens if you press Delete or Backspace when positioned at either end of one of those groups of five spaces; does it delete just one space or all five?

How about navigating across such a group; does it need one Cursor Left or Right, or five?

If your editor really does just convert to multiple spaces, then that would drive me up the wall.

(FWIW my own editor keeps tabs as tabs but displays them as four spaces. That can be varied to any tab spacing with a single key press. That's a lot harder to do once tabs are converted to actual spaces.)

For a taste of real programming, ie. using text editors and producing text output on a console, then perhaps Python is the best of a bad bunch, at least to get started.

For things that might be more interesting to young people as graphics, games, audio and networking, then it gets rapidly complicated. Then maybe some hand-holding development system such as have been mentioned can come in useful.

As for the Raspberry Pi, that's good for someone who intends to learn how to battle Linux to get even the simplest thing done!

(That was my experience anyway: the first day was spent getting a display that wasn't over-scanned, under-scanned, not too low a resolution and not too high, something I hadn't needed to worry about since the 80s. This involved taking out the SD card, and editing the CONFIG.TXT file on a PC (ie. a real computer), before trying again with a different bunch of numbers.)

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required