Readit News logoReadit News
mikejholly · 11 years ago
Await, pattern matching and macros are great language features Node and CoffeeScript both lack. Nice work!
pooriaazimi · 11 years ago
IcedCoffeeScript had await/defer three of four years ago: https://github.com/maxtaco/coffee-script/

But I agree, excellent set of features.

thomasfoster96 · 11 years ago
Async/await is coming in ECMAScript 7, so Node will have it soon.
Dralletje · 11 years ago
Define "soon" haha. With the speed of adopting ECMAScript 6 this "soon" could become really long.
fenollp · 11 years ago

    fact(match) =  
       0 or 1 -> 1  
       n -> n * fact(n - 1)  
why not simply

    fact(0 or 1) -> 1
    fact(n) -> n * fact(n - 1)

istvan__ · 11 years ago
I think the first one is a single function that has pattern matching for the parameter while the second one is defining the function twice and relying on the language to call the right one based on the parameter.

I think in Erlang the function identification is the name and the arity and this is as close I know of what you would like to have.

mikkom · 11 years ago
Erlang has both methods, pattern matching in function definition and case-clause pattern matching.

(some random link http://stackoverflow.com/questions/1050913/erlang-style-case...)

TheDong · 11 years ago
In haskell you can write exactly the following:

    fact 0 = 0
    fact 1 = 1
    fact n = n * fact (n-1)
It works as you would expect and really they aren't that dissimilar.

arh68 · 11 years ago
Erlang does it very much like GP's suggestion with the one downside of being 'noisy' with its punctuation (some might say 'clearer'):

  factorial(0) -> 1;
  factorial(N) -> N * factorial(N-1).

  factorial(Foo, 0) -> .. ;
  factorial(Foo, Bar) -> .. .
Semicolons separate partial definitions for a single function of a single arity, and periods end those definitions. Removing the punctuation might make parsing a bit more difficult (will there be more partial definitions?), so it's understandable to not offer it.

akst · 11 years ago
I'd imagine you could compile them both down to the same thing, as there has to be a conditional at some point to determine what code to run (unless there was some kind of dynamic dispatch), I think it's just a matter of preference

Deleted Comment

shakethemonkey · 11 years ago
Hyphens in variable names. It's a bold strategy for a scripting language, Cotton.
Shoop · 11 years ago
I think a lot of lisps use hyphens in variable names
shakethemonkey · 11 years ago
There's plenty of precedent. It's just rare for a reason. I'm not sure allowing slightly easier access to CSS syntax justifies it.
tmalsburg2 · 11 years ago
Yes, because Lisp uses prefix notation and hence there is no ambiguity: a-b cannot be interpreted as subtraction in lisp but in EG ...?
SeanLuke · 11 years ago
Lisps do not have operators. This language does.
TazeTSchnitzel · 11 years ago
Imagine being able to type style.border-width in JS instead of style.borderWidth
agumonkey · 11 years ago
saraid216 · 11 years ago

  style['border-width']

ghayes · 11 years ago
inner = border - width
xxyyxx · 11 years ago
I like it. It goes further than coffeescript and livescript can. Especially with macros and better react support
evincarofautumn · 11 years ago
One one hand, this is yet another syntactic reskin of ideas from modern imperative-land. On the other hand, it looks like a good one, by a thoughtful author who also cares about integration with existing platforms, and that’s not nothing.
sssilver · 11 years ago
Actually, the language looks and reads great. Keep up!
explorigin · 11 years ago
High-level comparison with Haxe:

EG and Haxe share: - compiles to Javascript - Macros - Pattern Matching - async/await (Haxe requires a 3rd party macro lib, but it integrates well)

EG has: - cleaner syntax - document-building DSL - "One of EG's primary goals is to be as compatible as possible with existing JavaScript libraries and frameworks and the node/iojs ecosystem." (Haxe makes compromises here to support other platforms)

Haxe has: - static type-checking - dead-code elimination - support for more platform targets (PHP, Python, C#, Java and more) - years of experience

makmanalp · 11 years ago
I really like how the tooling to create a full application is already there, it isn't like "here's my new language, but there are no libraries, good luck!".

> Global variables need to be declared to be accessible: > globals: > document, google, React

If I'm getting this correctly, what a brilliant idea! Contain the shittiness by having one single location where all globals are declared. So very helpful.