What's the Most Concise, Human-Understandable Practical Language?

  • (10 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

139 Replies - 5766 Views - Last Post: 19 May 2020 - 05:32 AM

#1 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

What's the Most Concise, Human-Understandable Practical Language?

Posted 13 May 2020 - 11:35 PM

Here's my fantasy rewrite of some Javascript.

Which one do you find more understandable? Which one's function and structure is more instantly obvious? Be honest.

JS
var home = {
	cit : "Boston",
	get City () {
		return this.cit;
	},
	set City(val) {
		this.cit = val;
	}
};



Fantasy Rewrite
home
	City 'Boston'


That's sort of what i'm looking for. Notice the lack of punctuation. Notice judicious use of whitespace as syntax. Notice how the getter, setter, variable, and default value are all encapsulated into two words.

What language is like that?


What's "Human understandable"?
I mean, easy to understand at a glance.

Here's [url="https://aplwiki.com/wiki/Conway%27s_Game_of_Life"]Game of Life in APL[/url]. Extremely concise! And totally NOT human-understandable. Seeking characters found on a normal keyboard.

{≢⍸⍵}⌺3 3∊¨3+0,¨⊢


Here's the [url="https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29"]Whitespace language[/url]. Extremely concise, and totally NOT human-understandable.

   
   
   


By "human-understandable", i DON'T mean "natural language" or "sounds like spoken English". I mean, provided you have learned the special programming syntax, and that learning that syntax is no more challenging or time-consuming than learning, say, Python.


What's "Concise"?
Here's some COBOL. Very human understandable. But not concise:

ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.


What's "Practical"
By "practical" i mean, it's a wise choice for real-world programming. Ie, not just an academic experiment. It has community, tools, rich programming features.... things a language needs to be usable for real projects.

This post has been edited by johnywhy: 13 May 2020 - 11:37 PM


Is This A Good Question/Topic? 0
  • +

Replies To: What's the Most Concise, Human-Understandable Practical Language?

#2 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6901
  • View blog
  • Posts: 28,559
  • Joined: 12-December 12

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 03:11 AM

You mention the Whitespace language, have a look through the other esoteric languages. None of them will have large communities or rich feature sets.

Otherwise, Python is the cleanest, practical, syntax that I am familiar with.
Was This Post Helpful? 2
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15743
  • View blog
  • Posts: 63,068
  • Joined: 12-June 08

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 06:58 AM

Quote

JS
var home = {
	cit : "Boston",
	get City () {
		return this.cit;
	},
	set City(val) {
		this.cit = val;
	}
};



Fantasy Rewrite
home
	City 'Boston'



Quote

Which one do you find more understandable?
While not a fan of class expressions, the first.

Quote

Which one's function and structure is more instantly obvious?
The first has information that is immediately apparent. If going into this with no prior knowledge I clearly see a plethora of things:

variables,
OOP has a high probability of being a thing,
string-like-things exist,
how assignment works,
that scope exists,
that 'get' and 'set' are probably keywords,
functions can have parameters,
functions can return values,
terminator lines

The secondary option has substantially less information. Without knowing the previous example I would not know if 'home' was a variable, relationship between lines (if there is one), or relationship of the white spaces to the line or the line above.
Was This Post Helpful? 2
  • +
  • -

#4 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6901
  • View blog
  • Posts: 28,559
  • Joined: 12-December 12

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 07:25 AM

In C# we can do

public string City { get; set; } = "Boston";

Was This Post Helpful? 1
  • +
  • -

#5 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 1027
  • View blog
  • Posts: 3,951
  • Joined: 13-June 14

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 11:39 AM

I quite like Lisp, because there's very little syntax - basically all you have are s-expressions. Ok, it takes some getting used to if you've programmed in a more traditional language (like I suspect most people!). Looking for a practical Lisp? Clojure of course.
Was This Post Helpful? 3
  • +
  • -

#6 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 12:52 PM

View Postandrewsw, on 14 May 2020 - 07:25 AM, said:

In C# we can do

public string City { get; set; } = "Boston";

thanks, but you're missing the "home" object.
What happens if you leave out the `public` attribute?

This post has been edited by johnywhy: 14 May 2020 - 12:52 PM

Was This Post Helpful? 0
  • +
  • -

#7 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 01:06 PM

View Postndc85430, on 14 May 2020 - 11:39 AM, said:

Looking for a practical Lisp? Clojure of course.


Is there a way to write Clojure without all the cruft :)

(ns clojure.examples.hello
	(:gen-class))

(defn hello-world [username]
(println (format "Hello, %s" username)))

(hello-world "Jack")
https://www.tutorialspoint.com/clojure/clojure_basic_syntax.htm


Eg, whitespace syntax instead of parens? Seems noisy to have to put parens around everything, including the entire call.
`format` is more verbosity than i'd like. Looking for something like:
hello-world
    log 'Hello, ' .

hello-world 'Jack'

This post has been edited by johnywhy: 14 May 2020 - 07:20 PM

Was This Post Helpful? 0
  • +
  • -

#8 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 01:14 PM

View Postmodi123_1, on 14 May 2020 - 06:58 AM, said:

While not a fan of class expressions, the first.

Is there a concise way to implement the same thing in JS without a class expression?
Was This Post Helpful? 0
  • +
  • -

#9 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 01:26 PM

View Postmodi123_1, on 14 May 2020 - 06:58 AM, said:

Quote

JS
var home = {
	cit : "Boston",
	get City () {
		return this.cit;
	},
	set City(val) {
		this.cit = val;
	}
};



Fantasy Rewrite
home
	City 'Boston'



The first has information that is immediately apparent. If going into this with no prior knowledge I clearly see a plethora of things:

variables
You mean `home`? How does knowing that help you?

Quote

OOP has a high probability of being a thing,
i don't understand what that means.

Quote

string-like-things exist,
exist?

Quote

how assignment works,
you mean the getter and setter? How does that help you in this example?

Quote

that scope exists,
How does the JS version indicate scope?

Quote

that 'get' and 'set' are probably keywords,
Doesn't the 2nd example make those keywords superfluous?

Quote

terminator lines
You mean the closing-curlies?
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15743
  • View blog
  • Posts: 63,068
  • Joined: 12-June 08

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 02:20 PM

*
POPULAR

Yes, in a vacuum reading, and more importantly understanding, an unexplained code snippet peepers need clues on what is going on. Things you find superfluous in the JS example are actually super duper important and show volumes over your idealized approach.
Was This Post Helpful? 6
  • +
  • -

#11 ge∅   User is offline

  • D.I.C Lover

Reputation: 318
  • View blog
  • Posts: 1,335
  • Joined: 21-November 13

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 04:16 PM

home
	City 'Boston'

is actually more equivalent to
var home = {
    City : "Boston"
};



You can't define a useful getter/setter in your light syntax at all. It is too ambiguous.

I was super hyped about sweetJS for defining macros and operators in JS, and I would have recommended it to you, but I realised it was renaming all the variables (and not just the ones involved in your transformation, ALL of them) which makes it utterly useless for me.

I regret that it is so difficult tu use utf-8 characters in code. I would love to be able to define operators with them.

This post has been edited by ge∅: 14 May 2020 - 04:18 PM

Was This Post Helpful? 2
  • +
  • -

#12 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 06:15 PM

View Postge∅, on 14 May 2020 - 04:16 PM, said:

You can't define a useful getter/setter in your light syntax at all. It is too ambiguous.

I'm guessing you mean that my lite syntax doesn't give ability to define special processing for the get or set, correct?

Ok, fair enuf, but the JS example i'm comparing to doesn't do any special processing. So it's equivalent to your code, right?
var home = {
    City : "Boston"
};


Here's a fantasy example with processing on the get/set:
JS:
var home = {
	cit : "Boston",
	get City () {
		return this.cit.toLowerCase();
	},
	set City(val) {
		this.cit = 'City: ' + val;
	}
};


Lite:
home
    City "Boston"
        .toLowerCase
        'City: ' .


Is there any ambiguity here?

Rules in this lite syntax:
- get and set are expected to be defined in order, so you don't have to say `get` or `set`.
- Default value is written after the member name.
- "private" variable is unstated
- Write the processing methods or functions for get and set without mentioning the "private" variable. It's assumed.
- . Dot is an alias for the parameter passed into set by the caller.
- Eliminate `+` with a rule that says "a string followed by a value is assumed to be a concatenation."
object
    member defaultValue
        getProcessing
        setProcessing


Quote

sweetJS was renaming all the variables (and not just the ones involved in your transformation, ALL of them) which makes it utterly useless

Why? If you never look at it's output, who cares?

Is this what you're referring to? [url]https://youtu.be/dxaCWhDFAl4?t=1105[/url]

I'm thinking SweetJS might be a tool one could use to implement my fantasy syntax. Here's a SweetJS macro definition and usage:

macro foo {
    rule { $x plus $y } => {
        $x + $y
        }
    }

foo 5 plus 6
[url="https://youtu.be/dxaCWhDFAl4?t=591"][url]https://youtu.be/dxaCWhDFAl4?t=591[/url][/url]

Quote

I regret that it is so difficult tu use utf-8 characters in code. I would love to be able to define operators with them.

How's related? You're referencing the APL example?

This post has been edited by johnywhy: 14 May 2020 - 07:51 PM

Was This Post Helpful? 0
  • +
  • -

#13 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 07:08 PM

View Postmodi123_1, on 14 May 2020 - 02:20 PM, said:

an unexplained code snippet peepers need clues on what is going on. Things you find superfluous in the JS example are actually super duper important

unclear to me why it's needed or important, as i explain in my responses, above, to your specific critiques.

thanks
Was This Post Helpful? 0
  • +
  • -

#14 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 1027
  • View blog
  • Posts: 3,951
  • Joined: 13-June 14

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 10:40 PM

View Postjohnywhy, on 14 May 2020 - 09:06 PM, said:

Is there a way to write Clojure without all the cruft :)/>
...

Eg, whitespace syntax instead of parens?


I think you're missing the point really. Lisps treat code as data - that is, Lisp programs are written in terms of data structures (e.g. (str "foo" "bar") is a list containing the function str and its two arguments), which are then evaluated.

I think you're probably worrying about the wrong things in general. Language syntax is just something you get used to over time so that it doesn't really bother you after a while. It is there for a reason - remember that it has to be parsed by a machine, so needs to be structured in some way that makes easy, while still being readable by humans.
Was This Post Helpful? 3
  • +
  • -

#15 johnywhy   User is offline

  • D.I.C Head

Reputation: -4
  • View blog
  • Posts: 153
  • Joined: 07-April 20

Re: What's the Most Concise, Human-Understandable Practical Language?

Posted 14 May 2020 - 11:29 PM

View Postndc85430, on 14 May 2020 - 10:40 PM, said:

(str "foo" "bar") is a list containing the function str and its two arguments), which are then evaluated.


Where's the evaluation?

Quote

I think you're probably worrying about the wrong things in general. Language syntax is just something you get used to over time so that it doesn't really bother you after a while.


We have a different view of what we consider acceptable in a language. There are all sorts of programming languages, with all sorts of syntax. According to you, there's no difference so it doesn't matter which one you use.

I strongly disagree. For one thing, languages are designed in specific ways, for specific purposes. They aren't all the same. For another thing, I'm not keen on using a language "that you get used to over time so that it doesn't really bother you after a while". I find it hard to comprehend that point of view. i prefer to choose a language that's a pleasure to use.

Quote

it has to be parsed by a machine, so needs to be structured in some way that makes easy


:D We have to make things "easy" for the computer? :D

No, we don't have to make code "easy" for computers. Just non-ambiguous and operational. Computers are supposed to make things easier for humans, not the other way around. i prefer to let the computer do the "hard work" of interpreting my code. The computer won't mind.

cheers!

This post has been edited by johnywhy: 15 May 2020 - 12:04 AM

Was This Post Helpful? 0
  • +
  • -

  • (10 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »