The Earl Grey programming language
breuleux.github.io
breuleux.github.io
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.
Because I like subtraction.
[1] And IMO people shouldn't, basic arithmetic isn't that frequent or complex enough to need such a dedicated treatment. But that's another lisp thing, you care more about having DSL opportunities for anything rather than a fixed set.
This code example doesn’t actually have any examples of unspaced subtraction in it, but there are a bunch of other binary operators with space removed. In my opinion adding spaces around all the operators in this file would make the code less readable, especially if trying to follow along from the formal published spec describing the algorithm: https://github.com/jrus/chromatist/blob/master/src/ciecam.co...
Still, you make a good point with the space savings. I guess I just find hyphens nice enough that I don't mind the tradeoff :)
Something like:
result = balance-sheet - ledger-total + discount-total
Is harder to read than result = balanceSheet - ledgerTotal + discountTotalAnyhow, I feel that this is the kind of feature you just stop noticing after a while. I think we often tend to assume that what we are used to is more readable than what we aren't used to, but the brain will adapt to nearly anything. Doesn't mean we ought to go crazy with changes, but hey, I like hyphens.
Me too, and I've wondered if it's because it's activating the same part of my brain that gets aggravated when people decide to use capitals on seemingly random words within the sentence.
Also, it feels morally wrong that the first word typically doesn't get the capitalization (and often languages ask/require programmers to follow some arbitrary first letter capitalization rules...). Yes, that's right, it's about ethics in programming language design.
A search on github etc might give some idea of how common it really is - though their search wasn't precise enough last time I tried. Google code was (regex) but I think they closed down? Or you could just clone a few of your favorite projects and grep it.
let some-var = a-number-another-number
instead of
let some-var = a-number - another-number
This language may require whitespace around all operators, though. It's not clear to me.
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).
https://downloads.haskell.org/~ghc/latest/docs/html/users_gu... http://stackoverflow.com/questions/1604270/what-is-the-diffe...
Personally I much prefer the way I do it, because it is more powerful, works in more places, and requires no new syntactic forms.
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.
(Like a company I know which picked VB 6 and still hasn't fully migrated away from it. The same company picked Microsoft's AJAX demo as a basis for a JS framework and is still developing that even though MS long since abandoned it. Would it be better to use jQuery, Angular, Ember, React, Riot, etc? Well, those are too new and untested. Very conservative leadership.)
Anyway CoffeeScript and JavaScript work well together and you might want your code to be in CoffeeScript but you have to use a library, say Ember (also a real project at a different company) which means certain improvements, bug fixes, etc. to Ember are done in JS. There's two. I'm sure you could easily end up with multiple libraries written in multiple compile-to-JS languages.
Long-term code maintainability is a bit of a hard problem. You probably need to be constantly refactoring, rewriting, and re-inventing so you don't have too much old code in play anyway. Maybe. What do I know?
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.