Hacker News new | ask | show | jobs
by sharmi 1069 days ago
There are multiple responses to the above parent noting how readable the above line of code is and yet how it might go wrong.

The first pitfall of using english as a programming language that occurs to me (as a totally Cobol ignorant person):

* Human languages tend to be nebulous around the edges and fluid, often with single word taking up multiple meanings and same function done by multiple words. There are multiple ways to express the same concept. This allows for the language to change and evolve with the times.

* OTOH programming languages need to be specific and exact for the computer to be able to interpret it and ensure it functions as expected across devices and over time.

This means to make English function as a programming language, we will have to take the existing language, whittle down most of the senses and many words, assign one function to one word and use a very trimmed down and reduced version of English.

Now you will have to know two forms of English * The human one * The computer-compatible one

Worse, our human version of the language can often trip up our computer-compatible one. I imagine even debugging would be harder, because when you look into the code, the brain would see perfectly good english and not register any issue with punctuation or tokens as expected by the interpreter.

Consider the below version.

   MULTIPLY TAXRATE FROM STATE(43) WITH BALANCE GIVING SALES-TAX-AMOUNT.
I have made 3 changes here, which might or might not work with COBOL (I am Cobol ignorant ;) ). But if a person tries to find the changes or debug, it would difficult for the human brain to register what is wrong as this is perfectly good english.
1 comments

> I have made 3 changes here, which might or might not work with COBOL (I am Cobol ignorant ;) ).

I've never used COBOL before, but this thread and your post made me curious and I installed GNU Cobol and found a sample program that demonstrates a few language features.

After playing around with it a little, I think I've understood that "OF" is like a struct element (or object property) accessor, the parens are an array index, and the hyphen is a syntactically significant part of the identifier. "BY" is apparently a mandatory part of the multiplication operator.

Conclusion: each of your three changes (while, as you said, perfectly reasonable from the English language point of view) would indeed break the COBOL code!

By the way, I remember this being a bit of an issue when I tried programming in HyperTalk: on occasion I would unintentionally come up with an English synonym for some natural-language HyperTalk code, and it wouldn't be valid HyperTalk.

The existence of Gnu COBOL:
Furthermore, vim turned out to have a built-in COBOL syntax highlighting mode which was activated when I opened the source first!