Live data from Hacker News

The Earl Grey programming language

breuleux.github.io

81–90 of 137 posts

Re: The Earl Grey programming language

#82
post #77

Earlier quoted context omitted.

"fact(match)" is just making use of a generic feature: the "match" keyword in a pattern dictates that the body defines a sequence of sub-patterns to match at that position. An argument uses pattern syntax, so it works there, but it works in other situations, for example this contrived example: f(x, y) = match x: {m, n} -> match m: n + y else -> m + n + y n -> n + y Can be rewritten: f(match x, y) = {match m, n} -> n…

Is there any other language that does this? For me the second example doesn't look better than the first one.

I haven't seen the feature elsewhere. The second example looks better to me (syntax highlighting helps) and reduces redundancy and indent, but I guess views may vary on this. Good to know!

Re: The Earl Grey programming language

#84
post #78
post #32

Earlier quoted context omitted.

> Write once, run anywhere is still the dream 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.

JavaScript will run anywhere

Javascript will run anywhere you have something to run it on, same as Java, or any other language.

Re: The Earl Grey programming language

#85
post #9
post #6

Earlier quoted context omitted.

God damn it how did I miss that. The condition was wrong, too. Fixed, thanks :)

Why not have a "Show HN" if you're the one who made it (assuming from the URL)?

https://news.ycombinator.com/item?id=8150346

Re: The Earl Grey programming language

#86
post #77

Earlier quoted context omitted.

"fact(match)" is just making use of a generic feature: the "match" keyword in a pattern dictates that the body defines a sequence of sub-patterns to match at that position. An argument uses pattern syntax, so it works there, but it works in other situations, for example this contrived example: f(x, y) = match x: {m, n} -> match m: n + y else -> m + n + y n -> n + y Can be rewritten: f(match x, y) = {match m, n} -> n…

Is there any other language that does this? For me the second example doesn't look better than the first one.

I haven't seen this specifically, but I have seen other languages move common top level behaviors within functions into parameter lists.

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

Re: The Earl Grey programming language

#87

Earlier quoted context omitted.

> I'd love to hear why people prefer underscores over hyphens. Because I like subtraction.

Just wondering though, how often do people write subtraction as "stuff-thing" instead of "stuff - thing"? I find myself typing the latter almost systemically, so hyphens never get in my way, but of course it's all too easy to be blind to the habits of others.

It's more a question of readability than writeability

Something like:

    result = balance-sheet - ledger-total + discount-total
Is harder to read than

    result = balanceSheet - ledgerTotal + discountTotal

Re: The Earl Grey programming language

#88

Earlier quoted context omitted.

> I'd love to hear why people prefer underscores over hyphens. Because I like subtraction.

Just wondering though, how often do people write subtraction as "stuff-thing" instead of "stuff - thing"? I find myself typing the latter almost systemically, so hyphens never get in my way, but of course it's all too easy to be blind to the habits of others.

If you have `stuff - thing` it’s no big deal, but once you start having `(a0-b0)/(a1-b1) + (x0-y0)/(x1-y1)` or whatever, then being able to save all the spaces starts to be kind of nice, especially if your math expressions get to be 60 characters long. There are a few times where I’ve definitely ended up with more readable code by using the presence or absence of a space as a way to group expressions. Also, I generally prefer to write things like `array[n+1]` or `array[n-1]` without the extra spaces.

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

Re: The Earl Grey programming language

#90

Earlier quoted context omitted.

> I'd love to hear why people prefer underscores over hyphens. Because I like subtraction.

Just wondering though, how often do people write subtraction as "stuff-thing" instead of "stuff - thing"? I find myself typing the latter almost systemically, so hyphens never get in my way, but of course it's all too easy to be blind to the habits of others.

in a complex expression, I tend to use white space, and absence of it, to make it clearer, as well as parentheses. So, sometimes x2-x1 happens.

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.

Post reply on HN