Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

[Propose] Coffee Style Smart Computer Language should be the future #49

Closed
snowyu opened this issue Oct 6, 2016 · 6 comments
Closed

Comments

@snowyu
Copy link

snowyu commented Oct 6, 2016

I treat the coffee-script and Literate CoffeeScript as the first coffee style smart computer language concept.
This should be the basics of the next generation Smart Computer Language.

Features:

  • Space indents for block, the curly braces are optional.
  • The brackets are optional for function revocation.
  • The array, object(dict) assignment could be no comma, instead of using the block.
  • The functional expression definition could be '->' or '=>'.
  • Smart variable definition
    • It should be a compiler switcher.
    • The first variable assignment will be declared if no the same name variable before.
  • RTL(run-time library) replace-able.
    • you can write your own extends, for in etc rtl functions.

Pros:

  • More Natural Readable for humans
  • More humane intelligence
  • Functional

Cons:

  • Ambiguity: The Human statement as possible ambiguity. eg,

    I saw a man on a hill with a telescope.

    • It seems like a simple statement, until you begin to unpack the many alternate meanings:
      • There’s a man on a hill, and I’m watching him with my telescope.
      • There’s a man on a hill, who I’m seeing, and he has a telescope.
      • There’s a man, and he’s on a hill that also has a telescope on it.
      • I’m on a hill, and I saw a man using a telescope.
      • There’s a man on a hill, and I’m sawing him with a telescope.
  • Smart man used only(the stupid is difficult to use)

    • the man should have a mindset always. So you have got a big trouble if you can not recognize the ambiguity of some statement.
    • the smart variable definition should be care too.

Most languages could be transformed into a similar coffee style.

The previous generation computer language is very mechanical and rigid.
It's strictly limited, even missing a semicolon would raise an error.

Language Reference

Functions

square = (x) -> x * x
cube   :integer = (x: integer) -> square(x) * x
fill   :string  = (container: string, liquid: string = "coffee") ->
  "Filling the #{container} with #{liquid}..."

The return and argument type should be optional for the types could be inferred.

The following is the C language transform:

int square(int x) {return x*x;}
int cube(int x)   {return square(x)*x;}
char* fill(const char* container, const char* liquid) {
  if (!liquid) liquid = "coffee";
  const char* fmt = "Filling the %s with %s...";
  int sz = snprintf(NULL, 0, fmt, container, liquid);
  char* result = malloc(sz+1);
  snprintf(result, sz+1, fmt, container, liquid);
  return result;
}
@trylks
Copy link

trylks commented Oct 6, 2016

Have you checked Haskell? I've not seen a clearer syntax ever. It also has a very nice type system.

Scala is also good, if restricted to methods with a single parameter.

@snowyu
Copy link
Author

snowyu commented Oct 6, 2016

Enh, we can absorb good aspects from other languages to enhance humane readability experience.

Maybe someday we can write the computer language like an article.

@GeoffreyBooth
Copy link
Collaborator

This is more than a little off topic from the goals outlined in the README. Nothing against your ideas, but this isn't the place.

@snowyu
Copy link
Author

snowyu commented Oct 6, 2016

More scalability, more usable. The coffee-script is dead If no more people learned the real meaning of coffee-style.

@DomVinyard
Copy link

DomVinyard commented Oct 6, 2016

Like @GeoffreyBooth suggests, you are not incorrect. When you say "the coffee-script is dead", I do perhaps agree, but it is also clear that this must be changed before we can start applying your ideas across the broader programming world. Help us get coffeescript back into the hearts of devs and you will have a very large receptive audience for your ideas (including many people here).

First things first.

@snowyu
Copy link
Author

snowyu commented Oct 6, 2016

I would write type-script like coffee. But it hardly implement via following the coffee-script framework.

The simplest way should be make the indent block instead of {}( the {} block could be optional).
Then make the brackets as optional for function revocation.

What's the first.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants