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

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

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

#16 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

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

Posted 15 May 2020 - 12:35 AM

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. 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.


We can make this a bit more precise. Programming language syntax adheres is structured according to a context-free grammar (CFG). It is quite easy for a computer to verify whether a given input string is generated by a CFG. Precisely, given a string w and a CFG G, deciding if w is generated by G can be done in polynomial time in |w|. [More strongly, the CFG membership problem is not only in P, but is complete for P under logspace reductions.]

As it applies to programming languages, the CFG membership problem deals with verifying that the program adheres to correct syntax and structure. A compiler or interpreter needs to be able to easily check that this.

Adding more expressive syntax to a programming language can actually make it harder for the computer to verify that the code in question adheres to proper syntax. For instance, the context-sensitive grammar (CSG) membership problem is PSPACE-complete (under polynomial time reductions). [To compare, SAT, which is NP-Complete, is actually easy for PSPACE.]


Quote

No, we don't have to make code "easy" for computers.


Actually, we do, unless we want compilers/interpreters to take forever. Fortunately, "easy" just means that we use a CFG to define the syntax and structure of our programs. As is evidenced by languages such as Python, programming language syntax doesn't have to be miserable for the developer.
Was This Post Helpful? 4
  • +
  • -

#17 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 - 01:28 AM

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

Programming language syntax adheres is structured according to a context-free grammar (CFG).


Was hoping not to get into a philosophical debate. Just seeking language recommendations.

But ok. SOME languages are CFG, some are not. Or rather, different languages are CF to varying degrees. So imo the whole concept is somewhat misleading. You're describing a theoretical ideal, which might or might not be desirable, depending on who's reading the code (computer vs human A vs human B etc).

Quote

"What most people don’t know is that the vast majority of programming languages have grammars that are not context free."
[url]https://eli.thegreenplace.net/2007/11/24/the-context-sensitivity-of-cs-grammar[/url]


Quote

most programming languages are not context-free languages. Let’s take Python as a first example.
[url]https://www.cs.unc.edu/~plaisted/comp455/Python%20is%20not%20context%20free.htm[/url]


Quote

Is all programming language grammar context-free or "nearly context-free"? No.
[url]https://www.quora.com/Is-all-programming-language-grammar-context-free-or-nearly-context-free[/url]


Quote

There are almost no context-free languages in practice. Most of the programming languages popular today, including C, C++, Javascript, Python, and Ruby, are not context-free languages.
[url]http://trevorjim.com/parsing-not-solved/[/url]


View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

CFG membership problem is not only in P, but is complete for P under logspace reductions.

You didn't define P, but i don't know what you're talking about anyway. I'm interested practical, real-world solutions, not theory.

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

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

verifying that the program adheres to correct syntax and structure. A compiler or interpreter needs to be able to easily check that.


i don't know what "easily" means. We're talking about computers. Maybe you mean, writing the compiler should be easy?

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

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

Adding more expressive syntax to a programming language can actually make it harder for the computer to verify that the code in question adheres to proper syntax.


- Not if the code adheres to unambiguous rules.

- Define "harder". Oh yeah, it means "forever". Two very unambiguous terms :D/>

- Clojure, CoffeeScript, and Haskell are considered very expressive languages. So, have you decided Clojure, CoffeeScript, and Haskell are too hard to compile?

- Which fantasy syntax that i shared is "more expressive"? Or are you actually not talking about my actual sample code?

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

context-sensitive grammar (CSG) membership problem is PSPACE-complete (under polynomial time reductions). [To compare, SAT, which is NP-Complete, is actually easy for PSPACE.]

I cannot discuss that, it's very personal :D/>

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

Quote

No, we don't have to make code "easy" for computers.


Actually, we do, unless we want compilers/interpreters to take forever.

You're making a big assumption, a broad generalization, and an exaggeration.

- There are degrees. Are you asserting that the specific fantasy code and accompanying rules that i posted in a previous comment are so laborious and complicated that a compiler will "take forever"? I asked, in that comment "What here is unambiguous?" Feel free to respond to that specific code. I like specifics.

- Or do you just mean "in general". Because that's non-specific. It's just a blanket statement, and therefor meaningless.

- Since we're speaking in very academic and scientific terms, saying things like "forever" isn't appropriate or meaningful. 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. You're just speaking in vague terms.

View Postmacosxnerd101, on 15 May 2020 - 12:35 AM, said:

"easy" just means that we use a CFG to define the syntax and structure of our programs. As is evidenced by languages such as Python, programming language syntax doesn't have to be miserable for the developer.


Python uses whitespace syntax. My fantasy code uses whitespace syntax. So, exactly what code are you talking about?

Are you asserting that Python is the best we can do? That Python represents the most concise, or nearly the most concise human-understandable code possible in 2020? That's a might big assertion. One that i find pretty absurd.

I enjoy theoretical, philosophical discussions, but don't take offense if i cannot keep up with this one too long. I'm not a computer-science major, so i'm not going to last long in a debate involving computer science theory and terminology.

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

Was This Post Helpful? 1
  • +
  • -

#18 Ornstein   User is offline

  • D.I.C Head

Reputation: 105
  • View blog
  • Posts: 216
  • Joined: 13-May 15

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

Posted 15 May 2020 - 02:18 AM

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


If we take your code on the 4th line to suggest that the period can be used to concatenate those two values, how does a reader know at first glance whether the code on line 3 is calling the toLowerCase method on the variable or attempting to concat the variable with a toLowerCase variable? :P

Quote

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


If we're replacing compilers with advanced AI, maybe - or with the extra overhead that comes from a parser/etc having to figure things out that otherwise could have been immediately communicated by the programmer, for want of some additional symbols and keywords.

Quote

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.


Some code bases already take hours/days to compile. The impact would be even more significant for the performance of interpreted languages.

On the topic of balancing writing code for compilers and humans, I'll throw another grenade into the mix: compiler optimisation often depends on how well a programmer has expressed their intent - or the way in which the language forces a programmer to express their intent, etc. Perhaps a good example of this is Haskell, which is (if the legends are true) able to do aggressive high-level optimisations e.g. the compiler is sometimes able to essentially "rewrite" your algorithm if it's able to identify a better approach.

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.
Was This Post Helpful? 1
  • +
  • -

#19 Radius Nightly   User is offline

  • D.I.C Regular

Reputation: 64
  • View blog
  • Posts: 389
  • Joined: 07-May 15

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

Posted 15 May 2020 - 06:11 AM

I always write so i can understand it later, and i dont care.
There are some limitations around syntax, math or some special commands (like commands for PC to create on his own variable names and information in that variables), thats why we got colors.
Sure var1 and xyz2 are easier and simpler for computer, rather then CurrentHomeTownLocation, but in the end, its just a text, so small in size, and it will be compiled into another language, so i dont think we should care much about that. I rather like to have my own syntax style across whole code, so at least compiler can notice similarities and make better optimizations.
Here is my example.

This post has been edited by Radius Nightly: 15 May 2020 - 06:14 AM

Was This Post Helpful? 1
  • +
  • -

#20 ge∅   User is offline

  • D.I.C Lover

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

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

Posted 15 May 2020 - 07:54 AM

Quote

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


Is there any ambiguity here?


I don't know, but what I can see is that you have no way to tell when something is a function. Surely, in the rest of the program you will want to make a distinction between a class, an object literal, a function, etc., you will need to have a keyword for that. You don't include it in this example because you are only thinking locally of a narrow subset of what your language is supposed to implement. If you think of it globally you will probably realise your syntax is missing essential structures and the fact I can't think of them myself is no proof that they don't exist (which makes the high level academic conversation very relevant because this problem requires generalised thinking to be solved with confidence).

Now imagine that you decide to make everything dependant of the context: inside an object the function keyword is not needed, but it is needed elsewhere, etc. you are making your language more complicated and maybe less flexible (as it is often the case when something is very optimised).

Take the class syntax in Javascript. There are many things you can do casually with the prototype notation, like private static fields (that you implement with a closure). You couldn't do them with the class syntax until very recently (with babel). People using this syntax were stuck. And the syntax we have now is totally alien to the language: it obeys rules you see nowhere else. How inelegant...

Quote

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?


Say I have developed something personal with functional programming and I write stuff like that because I too want a less noisy syntax
const xform = filter(state1  state2)  map(change1  change2)  filter(state3);
const process = xform into Array;
const result = process(data);


Then for some reason I want to share it with someone else and, obviously, my syntax is not standard... Not everyone is going to like having to type the character , and maybe they won't like having to add a compile step either, so I might want to distribute the generated code
const xform = compose(
    filter(compose(state1, state2)), 
    map(compose(change1, change2)), 
    filter(state3)
);
const process = reduce(xform(concat), []);
const result = process(data);


It is not ideal but at least I can be confident writing code the way I like and know it wont be a dead end if I need to collaborate with someone else later.

But if the variable names change...
Was This Post Helpful? 3
  • +
  • -

#21 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

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

Posted 15 May 2020 - 08:16 AM

Quote

But ok. SOME languages are CFG, some are not. Or rather, different languages are CF to varying degrees.


I learned something today! Thanks for pointing this out! In doing some reading, the non-CFG parts are handled by special cases (e.g., whitespace and nested layers in Python) which are not manually generated by tools like YACC. Even so, we are not using the full expressive power of a CSG, so we avoid the difficulties of the CSG membership problem.


Quote

You didn't define P, but i don't know what you're talking about anyway. I'm interested practical, real-world solutions, not theory.


Programming language design is very mathematical. There are some key hard problems which provide limitations as to what we can/cannot design (e.g., the CSG membership problem). P is the set of decision problems which are solvable in polynomial time. PSPACE is the set of decision problems which are solvable in polynomial space. It is well known that P \subset PSPACE and conjectured(/widely believed) that P is not equal to PSPACE.

By "easy," I mean polynomial time solvable (the usual notion of easy in computing). 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.


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.


Quote

- Not if the code adheres to unambiguous rules.


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


Quote

I asked, in that comment "What here is unambiguous?" Feel free to respond to that specific code. I like specifics.


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.


Quote

Since we're speaking in very academic and scientific terms, saying things like "forever" isn't appropriate or meaningful. 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. You're just speaking in vague terms.


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. I believe there is a $1 Million prize in it for you. :)


Quote

Are you asserting that Python is the best we can do? That Python represents the most concise, or nearly the most concise human-understandable code possible in 2020?


I made no such claim. The point I was making was that syntax does not have to be miserable for the developer and cited Python as an example of this.



Quote

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.


The systems side and compiler optimizations are very nice, practical things. There is no argument here. 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. :)




Quote

I enjoy theoretical, philosophical discussions, but don't take offense if i cannot keep up with this one too long. I'm not a computer-science major, so i'm not going to last long in a debate involving computer science theory and terminology.


Honestly, I think you would benefit from some CS Theory and Design of Programming Language background (whether those are in the form of a course, independent readings, etc.). Having the terminology (e.g., basic automata theory, enough computational complexity to understand notions of hardness) and some rigorous background on how programming languages are developed would add a lot to your discussions.

In particular, 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? I think everyone will agree that a good ecosystem (support, documentation, libraries, etc.) is one very important aspect.

With everyone agreeing on that point, the conversation has really become one of syntax. In particular, it sounds like your goal is to optimize for human readability of syntax, without sacrificing the expressive power of the language. Programming language design is a bit out of my wheelhouse, and I am really only qualified to address expressive power in a meaningful way. Our resident linguist, jon.kiparsky, might have more to add here. He has also spent more time on PL design than I have, if memory serves. :)
Was This Post Helpful? 3
  • +
  • -

#22 ndc85430   User is offline

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

Reputation: 1031
  • View blog
  • Posts: 3,960
  • Joined: 13-June 14

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

Posted 15 May 2020 - 08:27 AM

The discussion here reminded me of this thread.

This post has been edited by ndc85430: 15 May 2020 - 08:27 AM

Was This Post Helpful? 1
  • +
  • -

#23 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11986
  • View blog
  • Posts: 20,312
  • Joined: 19-March 11

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

Posted 15 May 2020 - 11:24 AM

View Postjohnywhy, on 15 May 2020 - 03:28 AM, said:

I'm interested practical, real-world solutions, not theory.


At some point, if you want to talk seriously about languages, you're going to want to abstract and generalize. At that point, you're going to be talking about "theory" whether you like it or not.
Reminds me a bit of a guy I saw last night trying to explain "How to get really good at Data Structures + Algorithms" to a bunch of bootcamp grads. He started out by saying "you don't need to understand CS for this" which is ironic because by definition, understanding anything about DS&A means understanding something about CS.

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. And when you do have the concrete understanding, you've got something like a theory.

It's like someone saying "I can build this bridge without having any sort of theory of structural engineering". Well, sure, maybe you can. But you can't really give anyone any confidence that the bridge will stand up, or what sort of load it'll stand up to, or for how long. And if it does stand up, then that only shows that you have something like a theory of structural engineering - it's just not a very good one.



Quote

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


Does this apply to human languages as well? I look forward to your compiler/interpreter/transpiler for English...


Quote

- Not if the code adheres to unambiguous rules.


Define unambiguous. (without resorting to theory, if you prefer)
Hint: theory has a definition for you already, and either you'll be repeating that definition or you'll be wrong.

Quote

- Define "harder". Oh yeah, it means "forever". Two very unambiguous terms :D/>


Quote

- 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...


So, let's try to dial back the snark just a little bit. Partly because you're verging on rude, and partly because I think if you make an effort to engage a little more constructively you might find that you're talking to someone who has spent a lot of time studying these problems and can help you learn a lot more about them, which might be fun for you.
Was This Post Helpful? 3
  • +
  • -

#24 ndc85430   User is offline

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

Reputation: 1031
  • View blog
  • Posts: 3,960
  • Joined: 13-June 14

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

Posted 15 May 2020 - 11:47 AM

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 briefly here, or watch Rich Hickey's more detailed talk here, which gives a fuller intro to the language.

This post has been edited by ndc85430: 15 May 2020 - 11:49 AM

Was This Post Helpful? 1
  • +
  • -

#25 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12769
  • View blog
  • Posts: 45,954
  • Joined: 27-December 08

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

Posted 15 May 2020 - 11:52 AM

This talk of Clojure and FP makes me wish Raynes was still around. :(

He would have good insights here.
Was This Post Helpful? 0
  • +
  • -

#26 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11986
  • View blog
  • Posts: 20,312
  • Joined: 19-March 11

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

Posted 15 May 2020 - 12:42 PM

View Postndc85430, on 15 May 2020 - 01:47 PM, said:

Quote

Where's the evaluation?


You can read about how Clojure evaluates code briefly here, or watch Rich Hickey's more detailed talk here, which gives a fuller intro to the language.


If you want a more general introduction, Michaelson's Introduction to Functional Programming Through Lambda Calculus lays out a lot of groundwork, and of cource SICP gives you a very good model for evaluating scheme, in that it takes you through the process of evaluating scheme.

View Postmacosxnerd101, on 15 May 2020 - 01:52 PM, said:

This talk of Clojure and FP makes me wish Raynes was still around. :(/>/>/>



Aw, man.
Was This Post Helpful? 3
  • +
  • -

#27 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 - 12:59 PM

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

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


If we take your code on the 4th line to suggest that the period can be used to concatenate those two values, how does a reader know at first glance whether the code on line 3 is calling the toLowerCase method on the variable or attempting to concat the variable with a toLowerCase variable? :P/>


- .toLowerCase can't be confused for a variable name cuz it starts with dot.
- dot can't be confused for a concatenation operator (if that's what you mean), because dot isn't a concatenation operator in JS.

Quote

If we're replacing compilers with advanced AI, maybe - or with the extra overhead that comes from a parser/etc having to figure things out that otherwise could have been immediately communicated by the programmer, for want of some additional symbols and keywords.

In every language, there's some degree of trade-off between raw code-syntax and parser[1] "intelligence".

[1]: "Parser" = parser, interpreter, compiler, transpiler.

Your implication is that any syntax even just a little more intuitive/contextual than Python is going to require "advanced AI". I think my code sample and rules for the above sample, and wouldn't require advanced AI to transpile to JS.

Rules for code sample above:
- 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."

Quote

Some code bases already take hours/days to compile.

It depends on the code and the rules. Would the code and rules above take hours or days to compile? I don't think so.

Quote

compiler optimisation

For now, i'm just thinking of minimal transpiling.

View PostRadius Nightly, on 15 May 2020 - 06:11 AM, said:

I rather like to have my own syntax style across whole code, so at least compiler can notice similarities and make better optimizations.
Here is my [url="https://img.techpowerup.org/200515/code.png"]example[/url].

What should we be looking for in your code sample? It seem pretty straightforward.
Was This Post Helpful? 0
  • +
  • -

#28 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,565
  • Joined: 12-December 12

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

Posted 15 May 2020 - 01:20 PM

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.
Was This Post Helpful? 3
  • +
  • -

#29 ge∅   User is offline

  • D.I.C Lover

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

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

Posted 15 May 2020 - 02:15 PM

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 pointing to a string before deciding if it should be concatenated with the parameter "." or if ".toLowerCase" is a property, and it should also check if toLowerCase is a function in order to decide if it should be executed or not. How slow do you think your language is going to be to execute? By the way the lack of parents also means that functions are always executed when they are referenced, which means that they are not first-class citizens and functional programming is impossible, or maybe you need to add some syntax to be able to pass them around... I don't know man, it doesn't seem like a good idea.

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

Was This Post Helpful? 2
  • +
  • -

#30 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:16 PM

View Postge∅, on 15 May 2020 - 07:54 AM, said:

Quote

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


Is there any ambiguity here?


I don't know, but what I can see is that you have no way to tell when something is a function. Surely, in the rest of the program you will want to make a distinction between a class, an object literal, a function, etc. you will need to have a keyword for that.


Let's talk about big-arrow syntax. There's no "function" keyword.

Quote

imagine that you decide inside an object the function keyword is not needed, but it is needed elsewhere, etc. you are making your language more complicated

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

Quote

with the prototype notation, like private static fields (that you implement with a closure). You couldn't do them with the class syntax until very recently (with babel). People using this syntax were stuck.

Stuck?

Quote

And the syntax we have now is totally alien to the language: it obeys rules you see nowhere else. How inelegant...

i definitely agree that inconsistent syntax is problematic. If i was going to develop a JS lite syntax i'd want to avoid inconsistencies (However, i am partial to default behaviors for the most common cases, but a default isn't foreign, it's a shortcut).

Quote

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

if i understand that [url="https://youtu.be/dxaCWhDFAl4?t=1105"]youtube excerpt[/url] (which is doubtful), it sounds like sweetJS only renames variables when they conflict with variable-names in the macro definition. But yeah, f i was going to develop a JS lite syntax i'd want to avoid renaming peoples variables, and ensure the transpiled code is good enuf to share. It sounds like Sweet.js devs went to a lot of trouble to handle variable-name conflicts-- why not just avoid names in sweet macros that anyone would ever use? Like, prefix everything with "$SWEET_" or something.
Was This Post Helpful? 0
  • +
  • -

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