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

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

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

#31 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 15 May 2020 - 02:54 PM

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

By "easy," I mean polynomial time solvable (the usual notion of easy in computing).


That's very contextual. "Easy" is an idiomatic term, and i am skeptical that you'll find any computing-related textbook, tutorial, or documentation making that claim, outside of your very specific computer-science domain.

If you can claim contextual justification for "easy", then programming languages can also claim contextual justification for syntax.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

In particular, practical algorithms to solve the CFG membership problem are reasonably efficient with runtimes of O(|w|^3 * |G|) or better, where w is the input string and G is the grammar. Note that the constant associated with the Big-O expression is not a prohibitive factor.

i believe you!

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

Quote

If i can look at code and understand it, then a compiler/interpreter/parser/transpiler can be written to understand it too.

This is a pretty broad claim. Even if true, the effort to design the grammar, lexer, and parser for a programming language is quite significant.


It depends on the code and the rules! With what code and rules do you mean? You're making a non-specific generalization. Define "significant".

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

Even in toy languages in compilers courses, where the languages are context-free, the grammars are ambiguous. Think about grammars governing mathematical expressions.

Can you share a simple example?

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

A grammar G is unambiguuous if for every string w generated by G, there exists a unique left-most derivation of w using the rules of G. A grammar that is not unambiguous is said to be ambiguous.

Thank you for the definition! I guess that means you're not going to talk about my specific code example.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

Quote

How long is "forever", exactly? Compile time is a matter of amount and complexity of the code, complexity of the rules, speed of the compiler, speed of the hardware, and the patience of the programmer. I didn't notice you quantify any of these.


I quantified CSG membership as PSPACE-complete. That is a *very* strong notion of hardness. Note that (the decision variant of) traveling-salesman is only NP-Complete (which is still quite hard). You are welcome to try and solve PSPACE-Complete problems efficiently. A polynomial time algorithm for a PSPACE-Complete problem would actually resolve the P = NP problem.

Thank you for defining "forever" :D

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

syntax does not have to be miserable for the developer and cited Python as an example of this.

Great! We agree! I'm going to assert that Python isn't the ultimate most concise possible human-understandable language in 2020, with reasonable compile times.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

View PostOrnstein, on 15 May 2020 - 02:18 AM, said:

So you may want to consider the difficulty or feasibility of a language that bridges this gap between non-intuitive mathematical models and such, which can for example be used by a compiler to process higher-level logical concepts - and intuitive human language/interpretation/etc.

I shall consider it :) But it sounds someone may be misunderstanding me. In my OP, i said:

Quote

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.


View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

If you are claiming that compiler optimizations overcome the "mathematical limitations" as you describe them, then what you are saying is that the "mathematical limitations" were not correct and there is a mathematical proof of this. In which case, that would be a very nice result. :)


Not exactly sure what you're saying, but i'm not claiming i can suspend the laws of physics or math. Only that the rules in my example code would be a piece of cake for a not-very-advanced parser.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

some rigorous background on how programming languages are developed would add a lot to your discussions.

Discussing the actual code samples under discussion would add a lot to your discussions.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

I perceive the point of discussion here really to be the following: what are properties of programming languages that make them useful and easy to use for developers working on real-world projects?

That's your interest. That's not why i started this thread, and no such question appears in my OP. You're redirecting the thread into an area that YOU want to talk about.

This post has been edited by johnywhy: 15 May 2020 - 05:13 PM

Was This Post Helpful? -1
  • +
  • -

#32 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 15 May 2020 - 03:08 PM

Quote

i haven't decided that. We'd have to look at specific code samples.


If programming is remotely like maths, and I thinks it is, you can't make up a general rule out of a set of examples.

Quote

Stuck?


Yeah

function sayfoo () {
    console.log("foo");
};

class T {
    static foo = sayfoo;
}



Can't do that. You needed to write
function sayfoo () {
    console.log("foo");
};

class T {};

Object.defineProperty(T, "foo", {value: sayfoo})


What's the point of using the class syntax at all if you can't use it? And I'm still incapable of using private methods. Babel doesn't compile them.


Quote

if i understand that youtube excerpt (which is doubtful), it sounds like sweetJS only renames variables when they conflict with variable-names in the macro definition.


I gave it a try

operator ~ right 20 = (l, r) => {
  return #`compose(${l}, ${r})`;
};

const compose = (...fs) => input => fs.reduceRight((x, f) => f(x), input);

const f = x => x + 1;
const g = x => x * 2;
const h = x => x - 5;

const a = f ~ g ~ h ;

/* output

const compose_4 = (...fs_9) => input_10 => fs_9.reduceRight((x_11, f_12) => f_12(x_11), input_10);
const f_5 = x_13 => x_13 + 1;
const g_6 = x_14 => x_14 * 2;
const h_7 = x_15 => x_15 - 5;
const a_8 = compose_4(f_5, compose_4(g_6, h_7));

*/


I mean no... just no. And, like, you can't choose a UTF-8 character for operator. They say it's everything you want except brackets, it's not true.
Was This Post Helpful? 2
  • +
  • -

#33 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 15 May 2020 - 03:16 PM

I also tried, just in case
operator ~ right 20 = (l, r) => {
  return #`(...xs) => ${l}(${r}(...xs))`;
};

const f = x => x + 1;
const g = x => x * 2;
const h = x => x - 5;

const a = f ~ g ~ h ;


/* output

const f_4 = x_8 => x_8 + 1;
const g_5 = x_9 => x_9 * 2;
const h_6 = x_10 => x_10 - 5;
const a_7 = (...xs_11) => f_4(((...xs_12) => g_5(h_6(...xs_12)))(...xs_11));

*/


Was This Post Helpful? 2
  • +
  • -

#34 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12761
  • View blog
  • Posts: 45,947
  • Joined: 27-December 08

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

Posted 15 May 2020 - 03:18 PM

View Postjohnywhy, on 15 May 2020 - 05:54 PM, said:

That's very contextual. "Easy" is an idiomatic term, and i am skeptical that you'll find any computing-related textbook, tutorial, or documentation making that claim, outside of your very specific computer-science domain.

If you can claim contextual justification for "easy", then programming languages can also claim contextual justification for syntax.

Quote

That's very contextual. "Easy" is an idiomatic term, and i am skeptical that you'll find any computing-related textbook, tutorial, or documentation making that claim, outside of your very specific computer-science domain.


No, this is a standard convention in computer science... Sometimes folks are *more* restrictive about the degree of the polynomial or the size of the constant associated with Big-O (as may very well be important for implementing said algorithms in practice). But polynomial time is what folks mean by easy.

Please do feel free to refer to literally any data structures, algorithms, or theory of computation text. And no, "algorithms" is not a narrow field in CS. Literally, that is what CS is about...


Quote

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

Quote

If i can look at code and understand it, then a compiler/interpreter/parser/transpiler can be written to understand it too.

This is a pretty broad claim. Even if true, the effort to design the grammar, lexer, and parser for a programming language is quite significant.


It depends on the code and the rules! With what code and rules do you mean? You're making a non-specific generalization. Define "significant".


Spend some time learning about compilers and writing one. Then come back and address this.


Quote

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

Even in toy languages in compilers courses, where the languages are context-free, the grammars are ambiguous. Think about grammars governing mathematical expressions.

Can you share a simple example?


Sure.

E -> number
E -> (E)
E -> E + E
E -> E - E
E -> E * E
E -> E / E



I will leave it to you as an exercise to find two left derivations for number + number + number.




Quote

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

So you may want to consider the difficulty or feasibility of a language that bridges this gap between non-intuitive mathematical models and such, which can for example be used by a compiler to process higher-level logical concepts - and intuitive human language/interpretation/etc.

I shall consider it :)/> But it sounds like you may be misunderstanding me. In my OP, i said:

Quote

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.


FYI- I never said this. Another member did. Kindly, please don't put words in my mouth. :)



Quote

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

I perceive the point of discussion here really to be the following: what are properties of programming languages that make them useful and easy to use for developers working on real-world projects?

That's your interest. That's not why i started this thread, and no such question appears in my OP. You're redirecting the thread into an area that YOU want to talk about.


Is this not what the discussion has been about over the last two pages? If one is interested in "the best" object, it is worthwhile to have precise notions of "good."


By the way, I might suggest taking a deep breath and trying to interact with folks in a more constructive manner. The tone of your posts comes across as rude and inflammatory. I don't think folks on this thread are trying to antagonize you (at least, I have not). I believe jon.kiparsky has already mentioned this to you.

If you (or really, anyone for that matter) wants to direct the discussion to a place of antagonism and rudeness, this thread will be closed.
Was This Post Helpful? 1
  • +
  • -

#35 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 15 May 2020 - 03:18 PM

View Postjon.kiparsky, on 15 May 2020 - 11:24 AM, said:

Quote

I don't need theory to tell me when code is easy to read and write.


Possibly not, but unless you have some concrete understanding about what "easy to read and write" means, you're not going to be able to calibrate your understanding with others.

The specific code examples and accompanying rules i shared "calibrate your understanding with others" (if you mean, "communicate my specific code and proposed parser-rules to others").


Quote

Define unambiguous.

Syntax which adheres to either no explicit parser rule, or code which fulfills more than one explicit parser rule.


Quote

Quote

- Define "harder". Oh yeah, it means "forever". Two very unambiguous terms :D/>/>
Which fantasy syntax that i shared is "more expressive"? Or are you actually not talking about my actual sample code, and just, um what's the word, intellectual something-something...


let's try to dial back the snark just a little bit.

Ok, sorry about "intellectual something-something", i'll delete it.

However, i started this thread to discuss actual code, actual languages. If someone wants to bring theory into the conversation, great! But if they don't bring those comments back to specifics in the OP, then i don't personally find it so relevant.

I realized "forever" isn't actually ambiguous, it's meaningless and impossible in the context of compiler times. Very ironic, when mingled with computer science theore.

This post has been edited by johnywhy: 15 May 2020 - 11:07 PM

Was This Post Helpful? -1
  • +
  • -

#36 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 15 May 2020 - 03:26 PM

View Postndc85430, on 15 May 2020 - 11:47 AM, said:

View Postjohnywhy, on 15 May 2020 - 07:29 AM, said:

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?


You can read about how Clojure evaluates code...

I just meant, where in your code example is the evaluation happening. I believe the answer is: It isn't shown. It seemed you were saying "Here's an example of concise code", but without the evaluation shown it's hard to judge.

i shared in a previous comment a longer Clojure example (with evaluation shown), and my fantasy concise rewrite of it.
Was This Post Helpful? 0
  • +
  • -

#37 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 15 May 2020 - 03:36 PM

View Postandrewsw, on 15 May 2020 - 01:20 PM, said:

As you extend your language presumably you will want some way to distinguish between private and public members, properties and methods, data types, and different operators. You will need to introduce more syntax, without using cryptic symbols, hopefully, or overusing symbols. You might consider introducing some keywords.

Thanks for that! I'm definitely interested in addressing all common, reasonable programming patterns and structures.

- private and public members: All variables will be private, but can be accessed if fully-qualified:
myModule.myVar
myObject.myVar

- properties and methods: If there's no executable code under an identifier, it's not a method.

- data types: implicit and strongly-typed. The first time a value is assigned, that becomes the type.

- different operators: ?

- You will need to introduce more syntax: It's a completely different syntax.

- Without using cryptic symbols: Yep-- except for the most common things.

- consider introducing some keywords: Trying to avoid it.
Was This Post Helpful? 0
  • +
  • -

#38 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 15 May 2020 - 03:45 PM

View Postge∅, on 15 May 2020 - 02:15 PM, said:

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


Quote

Eliminate `+` with a rule that says "a string followed by a value is assumed to be a concatenation."


This rule means that in the above code your JIT compiler needs to check if toLowerCase is a variable name

- Actually, that rule refers to the `setter`. You're talking about the `getter`.
- Rule: variable-names don't start with dot. But even if it did, so?

No JIT compiler, it gets transpiled.

Quote

should also check if toLowerCase is a function

- Yes. So? Names will be checked up the hierarchy of precedence: function, property, built-in, custom, defined locally, defined externally, etc. Doesn't require a super-computer. Yes, does require the programmer to know what they're doing-- i'm ok with that.

Quote

How slow do you think your language is going to be to execute?

it won't, it will be transpiled.

Quote

lack of parents also means that functions are always executed when they are referenced

won't be executed at all, will be transpiled.

This post has been edited by johnywhy: 15 May 2020 - 03:46 PM

Was This Post Helpful? 0
  • +
  • -

#39 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 15 May 2020 - 04:07 PM

I don't understand.

If you compute `home.City` and the definition of the getter is `.toLowerCase` and not `.toLowerCase()` then the output should be a function, not a string in lowercase. If you want `.toLowercase` to be run without brackets when one computes `hone.City`, it means you execute functions every time you reference them, or maybe you have yet another rule that is different for getters (the getter must return a function that is implicitly executed?). I would not like to learn your language. How do you even look up the documentation of such a language? What should the user type in a search field to get the definition of stuff that don't have a keyword or a specific syntax, that changes behaviour depending on the context?

I think I'm starting to understand what you mean by "the user knows what they're doing", it's like an app with zero UI and you have to remember macros and... OMG you're designing vi, but as a programming language O_O
Was This Post Helpful? 3
  • +
  • -

#40 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 15 May 2020 - 04:45 PM

View Postge∅, on 15 May 2020 - 03:08 PM, said:

Quote

We'd have to look at specific code samples.
If programming is remotely like maths, and I thinks it is, you can't make up a general rule out of a set of examples.

You might be right! We'd have to test your theory by looking at some specific code samples :D/>

Quote

What's the point of using the class syntax at all if you can't use it? And I'm still incapable of using private methods. Babel doesn't compile them.

If i understand correctly, a static method in a class isn't really a "method", it's a function which can only return something. Am i close? Thank goodness that's outside the concerns of my lite syntax. If you're requesting that my lite syntax allow you to create static methods on classes, i'll try! :)/>

what's this?
operator ~ right 20 

Was This Post Helpful? 0
  • +
  • -

#41 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 15 May 2020 - 05:11 PM

Quote

what's this?
operator ~ right 20 

You can lookup sweetJS operators here.

`~` is the operator I implemented (because sweetJS won't accept . I should be using ∘ I guess but bullet points are easier to type)

Apart from the problem with variables, I am not sure it's possible to group the output of multiple binary operators: `a b c` will give you `compose(a, compose(b, c))` instead of `compose(a, b, c)`, which is ultimately the same thing but is also wasteful. I didn't take the time to look that up because if I don't get a clean output it's not worth it (for me).
Was This Post Helpful? 0
  • +
  • -

#42 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 15 May 2020 - 05:15 PM

View Postmacosxnerd101, on 15 May 2020 - 03:18 PM, said:

this is a standard convention in computer science

That exactly what i meant. Imo, someone coding a webpage isn't doing computer science. My OP is from the perspective of a programmer choosing a language, not a compiler designer.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

E -> number

I will leave it to you as an exercise to find two left derivations for `number + number + number`

If i understood your notation, i might be able to.

Quote

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

...consider the difficulty or feasibility of a language that bridges this gap between ...
FYI- I never said this. Another member did. Kindly, please don't put words in my mouth.

i was quoting you quoting them. Sorry if i didn't enter the attribution correctly. i fixed it.

View Postmacosxnerd101, on 15 May 2020 - 08:16 AM, said:

If one is interested in "the best" object, it is worthwhile to have precise notions of "good."

I completely agree, which is why i provided rough, plain English definitions of my terms in the OP, with code examples and counter-examples. It seems your comments haven't addressed the notions of "good", but rather "feasible".

I don't mean to be rude, sorry if it reads that way. I promise i shall be aware of my tone. I hope you don't consider disagreement and debate to be rude.

This post has been edited by johnywhy: 15 May 2020 - 05:17 PM

Was This Post Helpful? 1
  • +
  • -

#43 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12761
  • View blog
  • Posts: 45,947
  • Joined: 27-December 08

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

Posted 15 May 2020 - 05:24 PM

Quote

That exactly what i meant. Imo, someone coding a webpage isn't doing computer science.


Programming language design *is* computer science, though. If you prefer to use the phrase "efficiently computable" rather than "polynomial time computable," I'm happy to do so.


Quote

If i understood your notation, i might be able to.


The notation is pretty standard for writing grammars. I have an old tutorial, which is probably a good starting place. It does assume some familiarity with regular expressions and finite state machines, and it does link to a previous tutorial on that for readers who aren't familiar with these topics.


Quote

It seems your comments haven't addressed the notions of "good", but rather "feasible".


From a previous post:

View Postmacosxnerd101, on 15 May 2020 - 11:16 AM, said:

Programming language design is a bit out of my wheelhouse, and I am really only qualified to address expressive power in a meaningful way.



I tend to be hesitant to address topics where I am not qualified to do so.


Quote

I don't mean to be rude, sorry if it reads that way. I promise i shall be aware of my tone. I hope you don't consider disagreement and debate to be rude.


It isn't so much about what you have to say, as the way you are saying it. Disagreement and debate is fine. :)

This post has been edited by macosxnerd101: 15 May 2020 - 05:26 PM

Was This Post Helpful? 0
  • +
  • -

#44 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 15 May 2020 - 05:29 PM

If i understand correctly, a static method in a class isn't really a "method", it's a function which can only return something



Usually, but it could also have side effects like jQuery's $.ajax, the object can also be a kind of module with no instances like Math.

I often use it this way:
class CustomType {
    static of (value) {
        return new CustomType(value)
    }
    ...
}



It makes class instance creation composable, because the `new` keyword is evaluated immediately otherwise

This post has been edited by ge∅: 15 May 2020 - 05:49 PM

Was This Post Helpful? 0
  • +
  • -

#45 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 15 May 2020 - 05:32 PM

View Postge∅, on 15 May 2020 - 04:07 PM, said:

If you compute `home.City` and the definition of the getter is `.toLowerCase` and not `.toLowerCase()` then the output should be a function, not a string in lowercase.


Thanks for that, i'll have to think about it.

[quote]maybe you have yet another rule that is different for getters (the getter must return a function that is implicitly executed?)

Yes, that's the idea. The parens are there in .toLowerCase, but unstated. The transpiler looks at it, and says "this line is the getter so we're returning something. Also, .toLowerCase is a known function." Feel free to identify ambiguities in my proposed syntax.


Quote

How do you even look up the documentation of such a language?

You'd go to the website and click "documentation".


Quote

What should the user type in a search field to get the definition of stuff that that changes behaviour depending on the context?

Good question! You got me thinking about documentation. My off-the-cuff answer is: search for the context of interest. But my answer may change.


Quote

OMG you're designing vi, but as a programming language O_O


thanks for that, i'll have to check out vi :)
Was This Post Helpful? 0
  • +
  • -

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