150 points · by breuleux · 11y ago · 126 comments
But I agree, excellent set of features.
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)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.
(some random link http://stackoverflow.com/questions/1050913/erlang-style-case...)
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. 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.And not even because of CSS, just because I think "do-thing" looks better than both "doThing" and "do_thing". Of course, I would think differently if I tended to write "a-b" instead of "a - b", but at the moment I quite enjoy this feature.
style['border-width']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
> 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.
Also, love the name :)
That said, I really like the inclusion of async and a DSL for documents. These two are things that benefit a lot from having language support.
f(x, y) =
match x:
{m, n} ->
match m:
<= 0 -> n + y
else -> m + n + y
n -> n + y
Can be rewritten: f(match x, y) =
{match m, n} ->
<= 0 -> n + y
else -> m + n + y
n -> n + y
So you can match hierarchically like that (sorry if the example is strange, it's not supposed to mean anything).Ruby, dart, coffescript allow setting of instance variables from the parameter list:
class Example
constructor: (@name) ->
# do stuff
class Example
constructor: (name) ->
@name = name
# do stuff
Jonathan Blow's language allows the `using` keyword in parameter list, which desugars in much the same way.I'm personally not a big fan of using this technique for pattern matching, but its better than requiring explicit match blocks everywhere (like Scala and rust).
There's also a few language features I couldn't find anywhere else that I wanted to try out (my % operator, ad hoc exception classes, some pattern matching features like coercion and "match" inside a pattern to define sub-patterns, the each operator, some features of the macro system that I have yet to document, etc.)
It's kind of fun, really.
> Earl Grey's % operator can be used to easily build HTML, DOM, virtual DOM, and other things:
tag.xyz %
property = value
child1
child2
Will produce the data structure: {tags = {"tag", ".xyz"}
props = {property = value}
children = {child1, child2}}
as an instance of the ENode class. Then, transformer functions can process the data structure to generate HTML or other things, e.g. require: /html
html(thing)
==> <tag class="xyz" property="value">child1child2</tag>The same as typing '24 tv series' will mostly return relevant results.
I'm aware there are many people who don't see the value in creating "yet another compiles to JS language," or those who view them as simply "syntax sugar," but I for one very much appreciate the work done by yourself and others on similar projects.
On the other hand I have to admit I like the idea of calling utilities Picard or Engage, they have a nice ring to them. Hmm.
Gives me a good sip of the entirety: the syntax, macros, patmatching, integrating with React, and even how to gulp it and write tests with it. Yet succinct enough to scroll in one swipe.
—Everyone, probably
I think this looks like a great project, we can never have too many programming languages to play around with.
Wait until we start having legacy code in all those languages.
>we use 30 different compile-to-js languages used in our projects(that are no longer being developed) and you have to maintain it.
Competition is good, competition is creativity.
More like "write once, run in the browser". I don't think most compile-to-js languages care too much about "anywhere", they are just trying to get nicer alternatives in what is basically a platform (the browser) closed to anything except JS.
Haskell does it:
\x -> x + 1
OCaml does it: fun (x : int) -> x + 1
It is very common in functional languages to use -> both for function bodies and return types.