The first example in the lanuage introduction (https://homepages.cwi.nl/~steven/abc/):
HOW TO RETURN words document:
PUT {} IN collection
FOR line IN document:
FOR word IN split line:
IF word not.in collection:
INSERT word IN collection
RETURN collection
In Python it would be: def words(document):
collection = set()
for line in document:
for word in line.split():
if word not in collection:
collection.add(word)
return collection
I kept the splitting by line and "if word not in collection:" in there even though they don't have an impact on the outcome. I have the feeling that even in the original example they have only been put there to show the language constructs, not to do anything useful. If one wanted to optimize it, it could all be collapsed to just "return set(text.split())", but that would not show off the language features.ABC uses 225 chars, Python 218 chars. 3% less.
So one could say Python is 3% more efficient than ABC.
“HOW TO RETURN” for something as common as “def” is crazy!
Well, not as bad as something like
which some languages these days are coming up with.public static function words(string $document): array {While I agree, at least here every word, though is verbose, at least means something, whereas “HOW TO RETURN” carries no more meaning than “def”.
As I understand it, "RETURN" means that the function will return something. And that when you define a function that returns nothing, but only does something, you just use "HOW TO".
I guess it's a shortening of "here's how to return the words in a document".
I think def is good though. I guess with new fangled prompt engineering you could use the english version.
> public static function words(string $document): array {
>, though is verbose, at least means something
I disagree, it is hardly verbose. there can be further detailing of the input and return value of the function beyond a simple type. Java didn't go far enough, not by a long shot - we need hardcore painstaking, completely brutal typing. Such typing will be highly beneficial for software reliability - you're not against reliability are you?
Reminds me if tabloid language, were the translation would be :
DISCOVER HOW TO words WITH document
DISCOVER THE SHOCKING TRUTH ABOUT HOW TO hello WITH name: PRINT "hello " + nameI think:
DISCOVER THE SHOCKING TRUTH ABOUT HOW TO hello WITH name: YOU WON'T WANT TO MISS "hello " + nameI love programming in listicle:
HERE ARE THE TOP 10 fibbonacci_numbers:
YOU WON'T BELIEVE n := 6