Jump to content

Recommended Posts

Which example is more readable and "human-friendly"?

 

Meta [
	Title:   {FizzBuzz math "game"}
	Author:  "Kaj de Vos"
	Rights:  "Copyright (c) 2021 Kaj de Vos"
	License: {
		PD/CC0
		http://creativecommons.org/publicdomain/zero/1.0/
	}
	Notes: {
		https://wiki.c2.com/?FizzBuzzTest
		https://www.rosettacode.org/wiki/FizzBuzz
	}
]

For counter 100 [
	Third?: unless modulo counter 3 [write "Fizz"]

	Any [
		unless modulo counter 5 [write "Buzz"]
		third?
		write counter
	]
	Write " "
]
Write new-line

or

For number 100 [
  p: 0
	
  unless modulo number 3 [p: 1 write "Fizz"]
  unless modulo number 5 [p: 1 write "Buzz"]

  if p = 0 [write number]

  Write " "
]
Write new-line

1, 2 or none? ;) 

 

maybe this one?

For number 100 [
  p: 0
	
  unless modulo number 3 [p: 1 write "Fizz"]
  unless modulo number 5 [p: 1 write "Buzz"]

  unless p [write number]

  Write " "
]
Write new-line

 

Edited by zbyti
Link to comment
Share on other sites

I think Zbyti's version follows the Principle of Least Surprise. I optimise my programs heavily with REBOL constructs that are elegant and that I know to generate efficient code, but not all of them are available in other languages. I want the examples to show off Meta's strengths, but in beginners' guides I will start with simpler constructs.

 

Many REBOL examples are different because they disregard efficiency. I think they make too much use of the dynamic features of the language. I inherited that attitude from Atari.

Link to comment
Share on other sites

38 minutes ago, Kaj de Vos said:

Many REBOL examples are different because they disregard efficiency. I think they make too much use of the dynamic features of the language. I inherited that attitude from Atari.

Many programmers like to feel smart by writing very dense code and like in their eyes "elegant solutions". In many software houses such approach is considered a "bad habit" leading to "write-only code". Such code is hard to read for the ones who didn't write it, require compilation of the code in the head, is hard to modify and makes life harder for new programmers. While languages nowadays are very powerful and flexible it also takes experience not to use all the fancy features the language provides. 

Link to comment
Share on other sites

I think my last example shows a problem in trying to talk to the computer with too many words:

 

[unless modulo number "works" do something] in other words: do something if something happens.

 

unless p I'm reading - do something if something didn't happen.

Edited by zbyti
Link to comment
Share on other sites

I think what we are missing is comments !!!

yes, that age old thing that many programmers just don't do.

 

As this is a new language, adding a comment alongside each line of code will help explain not

just what the program is doing, but also give insights on how the language works

  • Like 1
Link to comment
Share on other sites

In the end, these problems are caused because our brains are limited. A language that can express more concepts in the same space is said to be more expressive. Thus, bigger challenges fit in your head when the programs are smaller.

 

It seems to be a problem of communication between human and machine, but the machine actually concurs. It, too, is limited, and smaller programs perform better.

Link to comment
Share on other sites

2 minutes ago, TGB1718 said:

I think what we are missing is comments !!!

yes, that age old thing that many programmers just don't do.

 

As this is a new language, adding a comment alongside each line of code will help explain not

just what the program is doing, but also give insights on how the language works

This example is ten lines and is compared with equivalent versions in hundreds of other languages. That should be enough for such an example.

 

As I said, in beginners' guides I will build it up as simple as possible, keeping the feedback here in mind.

Link to comment
Share on other sites

22 minutes ago, ilmenit said:

Many programmers like to feel smart by writing very dense code and like in their eyes "elegant solutions". In many software houses such approach is considered a "bad habit" leading to "write-only code". Such code is hard to read for the ones who didn't write it, require compilation of the code in the head, is hard to modify and makes life harder for new programmers. While languages nowadays are very powerful and flexible it also takes experience not to use all the fancy features the language provides. 

Meta is not APL:

https://www.rosettacode.org/wiki/FizzBuzz#APL

or K:

https://www.rosettacode.org/wiki/FizzBuzz#K

 

Meta is deliberately designed to be more verbose, literally. That's why I claim it to be closer to natural language. It is designed to work at a similar verbosity as human language.

Link to comment
Share on other sites

4 minutes ago, zbyti said:

I think that symbolic languages are more exact and does not get the brain involved in understanding words but only problems.

Meta is just as exact. It's Lisp with types added. But it tries to use real English words instead of weird abbreviations, and only the math symbols that many people are familiar with.

Link to comment
Share on other sites

1 minute ago, zbyti said:

I think that symbolic languages are more exact and does not get the brain involved in understanding words but only problems.

If I'm correct, adults usually do not read single letters in words but read familiar words as a symbols, leading to these tasks like "count the Fs" or https://www.lookhuman.com/design/58406-if-you-can-read-this-you-are-smart/tshirt (while in case of children just learning it's an issue). 

 

Link to comment
Share on other sites

28 minutes ago, Kaj de Vos said:

In the end, these problems are caused because our brains are limited. A language that can express more concepts in the same space is said to be more expressive. Thus, bigger challenges fit in your head when the programs are smaller.

 

It seems to be a problem of communication between human and machine, but the machine actually concurs. It, too, is limited, and smaller programs perform better.

I read the biography of Stanisław Ulam and there was a discussion about what language is better and mor suitable for certain things. The gentlemen knew 3 languages then, maybe four (Latin?).

 

If I'm not mistaken they found German more suitable for mathematics than Polish, I don't remember what they said about the French language ;)

Link to comment
Share on other sites

9 minutes ago, ilmenit said:

If I'm correct, adults usually do not read single letters in words but read familiar words as a symbols, leading to these tasks like "count the Fs" or https://www.lookhuman.com/design/58406-if-you-can-read-this-you-are-smart/tshirt (while in case of children just learning it's an issue). 

 

yes, I think this only happens if the words are relatively small in number and are used frequently - such as key words in programming languages.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...