News for hackers. Stuff that matters.
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @06:56PM (#14915425)
I'm a Lisper (and Pythoner) and strongly agree, the first one is not readable. I would say it's gross. It boggles my mind that Lispers haven't taken that problem seriously. I have taken it very seriously and have been working on it for years.

I just started publishing my results.

http://breckyunits.com/the-flaw-in-lisp.html

What I've discovered is that the parentheses are completely unnecessary in Lisp, and in fact cause much harm by making Lisp harder to read and maintain in the long run. Drop the parentheses in Lisp by switching to whitespace/geometry for syntactic structure and you suddenly have the dream language.

Your example above would be something like:

  setv result
   -
    /
     + 1 3 88
     2
    8
You might think that looks a little strange too at first, but the neat thing about that code is you can write it on a piece of graph paper, draw lines around each word, connect the indented nodes, and you'd have a tree visualization of your syntax code without doing a single transformation of the source.
Re:Hy – A Lisp-flavored Python by kod on Wednesday August 02, 2017 @07:13PM (#14915521)
Yeah, whitespace sensitive languages are a great idea...

Until you permanently lose user data because of a pull request that contained whitespace changes.

Yes, I've seen this happen in production, yes it could have been prevented in other ways... but why invite disasters like that upon yourself?

Re:Hy – A Lisp-flavored Python by simonh on Wednesday August 02, 2017 @08:27PM (#14915951)
Have you really never seen a bug in curly brace code due to a misplaced curly bracket hidden by incorrect indenting? Or code that was just really difficult to understand and modify accurately because it was indented inconsistently with the braces? And yes there are tools that can help with that, but...

I worked on Quartz for a few tears, that's over 10 million lines of Python code and many thousands of commits per day. If concerns like that really were anything more than nitpicking, projects like that would know about it.

Re:Hy – A Lisp-flavored Python by kazinator on Wednesday August 02, 2017 @11:39PM (#14916794)
Discrepancy between actual code structure and indentation is susceptible to diagnosis by machine. That's the beauty of having a bit of redundancy in the representation.

Recent GCC now has a warning for indentation that doesn't match code structure. (Had to recently patch a breakage in GNU Binutils in an embedded distro due to this being a -Werror).

Re:Hy – A Lisp-flavored Python by kod on Wednesday August 02, 2017 @09:08PM (#14916157)
The point is with lisp you can automatically and unambiguously parse and format code regardless of whitespace. Giving that up in favor of whitespace sensitive languages has real world drawbacks, no matter how many "no true python programmer" arguments you make.
Re:Hy – A Lisp-flavored Python by JadeNB on Thursday August 03, 2017 @09:25AM (#14919306)
> I worked on Quartz for a few tears

This lovely typo deserves to be noticed.

Re:Hy – A Lisp-flavored Python by mulmen on Wednesday August 02, 2017 @07:38PM (#14915671)
Is that a problem with whitespace or your test/qa/release process? A curly brace language isn't any less likely to lose user data to a bug just because it has curly braces.
Re:Hy – A Lisp-flavored Python by kod on Wednesday August 02, 2017 @08:12PM (#14915888)
It is less likely to cause problems, because a removed curly brace won't parse correctly, and won't be hidden when someone excludes whitesoace from a diff.
Re:Hy – A Lisp-flavored Python by JadeNB on Thursday August 03, 2017 @09:29AM (#14919335)
> won't be hidden when someone excludes whitesoace from a diff.

Surely it is good advice not to exclude whitespace from a diff when using a whitespace-sensitive language?

Re:Hy – A Lisp-flavored Python by pharrington on Wednesday August 02, 2017 @10:04PM (#14916391)
Your -if- clause sans curly braces definitely still parses.
Re:Hy – A Lisp-flavored Python by jjnoakes on Wednesday August 02, 2017 @10:22PM (#14916463)
Depends on the language.
Re:Hy – A Lisp-flavored Python by lgas on Thursday August 03, 2017 @01:32AM (#14917165)
Technically true, but I mean c'mon... Java, JavaScript, C, C++, C#, PHP... You have to get down to into the Go/Swift neighborhood before you'll find mandatory braces.
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @07:45PM (#14915722)
This is a great concern, and glad you brought it up.

In ETNs (the new family of programming languages I'm talking about), there are no "whitespace changes", in the sense that all changes to the code affect actual nodes in the program.

This is a really important property that embeds diffs with a whole lot more meaning. You can not only see the number of lines changed, but also the number of nodes changed. If you expected a change to only change content and not change any nodes, and you saw in a negative number in the nodes changed field, you would know immediately that something had gone wrong.

This is one of the many new beneficial properties unique to these languages.

Re:Hy – A Lisp-flavored Python by kod on Wednesday August 02, 2017 @08:10PM (#14915878)
Unless your language is somehow changing the behavior of existing tools like diff -w or github ?w=1, you're just making semantic distinctions.
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @08:44PM (#14916041)
Correct. We have new diff tools specifically for ETNs.
Re:Hy – A Lisp-flavored Python by gnaritas on Thursday August 03, 2017 @12:18AM (#14916926)
No, that's not changing the behavior of the existing tools everyone uses and aren't going to stop using. You can't say correct when you're not actually agreeing with his point.
Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @01:57AM (#14917273)
Perhaps I misunderstood the parent comment.

It changes the behavior in the sense that there is no w=1 option. All whitespace is significant. The idea of ignoring whitespace would be like the idea of ignoring angle brackets in html. Whitespace is an essential part of TN and ETNs and is never ignored.

Diff tools then can benefit by showing not only aggregate line diffs but aggregate node and word level diffs without knowing anything about the meaning of a program.

Re:Hy – A Lisp-flavored Python by olavk on Thursday August 03, 2017 @03:17AM (#14917576)
Well, if you randomly delete parentheses in Lisp or curly braces in C you will also get problems. So...don't delete information at random.
Re:Hy – A Lisp-flavored Python by dragonwriter on Wednesday August 02, 2017 @08:19PM (#14915913)
> Drop the parentheses in Lisp by switching to whitespace/geometry for syntactic structure and you suddenly have the dream language.

This has been “discovered” many times, but somehow this dream language never approaches even Lisp in popularity. (Though a loosely similar transformation of it's basic ML-based syntax is used in Haskell to reduce parens, but that's not a Lisp base.)

Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @08:39PM (#14916012)
> This has been “discovered” many times,

So far I'm only aware of one previous discovery--https://srfi.schemers.org/srfi-49/srfi-49.html--, which nsajko pointed me to a couple weeks ago, (https://news.ycombinator.com/item?id=14606595). Are you aware of other identical or near identical implementations? The tiniest details matter here. I'd be very interested in more.

> but somehow this dream language never approaches even Lisp in popularity.

Agreed! That's what I'm hoping to help change. It's going to be a long slog, but I'm very confident the math works out and it's going to happen. The tooling needs to be built to take advantage of the properties of these languages before they will catch on. But once that happens, I think we're in for a whole new world in programming.

Re:Hy – A Lisp-flavored Python by kbp on Thursday August 03, 2017 @01:42PM (#14921822)
Logo lets you leave out parentheses most of the time, except to use rest arguments or force grouping. For example:

    ? print list sum 0 1 2
    1 2
That expression parses as (print (list (sum 0 1) 2)) because both list and sum normally take 2 arguments. However, using the parenthesised function call syntax, you can pass them however many you like:

    ? (print (list 1 2 3 (sum 1 1 1 1)))
    1 2 3 4
Or you can of course mix and match (probably to better effect than this example):

    ? print (list 1 2 sum 1 2 4)
    1 2 3 4
Logo also lets you use infix arithmetic operators with normal precedence:

    ? print 1 + 2 * 3 + 4
    11
Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @04:14PM (#14923386)
I love Logo! Advanced Logo by Michael Friendly is one of my programming books.

Logo came very close to TN and ETNs but adding the parens and other visible syntax I believe was a design mistake. It's not obvious, but when working with large programs in 2 and 3 dimensions (only possible with parens free lisp, or ETNs as we call them), you gain tremendous productivity benefits

Re:Hy – A Lisp-flavored Python by dTal on Friday August 04, 2017 @06:35AM (#14927654)
>Are you aware of other identical or near identical implementations?:

srfi-110, srfi-119.

Re:Hy – A Lisp-flavored Python by breck on Saturday August 05, 2017 @01:44PM (#14936864)
Thanks!

Some thoughts on 110 and 119 in my comment below.

Re:Hy – A Lisp-flavored Python by emmelaich on Wednesday August 02, 2017 @08:32PM (#14915978)
e.g. http://chrisdone.com/z/

Fascinating but I don't think it has many users!

A quote from that page...

    (Note: there are no parentheses in Z. Zero.)

    Which, if you think about it, is the natural
    grouping for the definition of the name
    argument syntax I gave above.

    To pass additional arguments to a function,
    the arguments are put on the next line and
    indented to the column of the first argument:
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @08:43PM (#14916035)
I love Z but think there are a few details that are off.

1. A single space for indenting nodes works much better. 2. strings don't need quotes.

Re:Hy – A Lisp-flavored Python by anaphor on Wednesday August 02, 2017 @06:58PM (#14915444)
The problem is that it requires all of your functions to have a fixed arity I think, or at least a lower bound on the arity, or you use newlines as part of the syntax. Check out this https://shriram.github.io/p4p/
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @07:42PM (#14915688)
Very interesting link, thanks for sharing. I'm always eager to see developments in the Racket world.

> The problem is that it requires all of your functions to have a fixed arity I think, or at least a lower bound on the arity, or you use newlines as part of the syntax.

This was my initial thought as well.

However, in my latest batch of ETNs (the name I give to these types of lisps), I've found that a simple convention of putting any variadic argument last seems to work well.

An example may help. Here would be a language blueprint that defines 2 node types:

  =+2
   description Adds two numbers
   pattern resultIdentifier number number
  =+
   description A variadic adder of unknown arity
   pattern resultIdentifier number+
Here's a sample program in the language we partially defined above:

  =+2 sum 2 5
  print sum
  # prints 7

  =+ sum 1 2 4
  print sum
  # prints 7
Re:Hy – A Lisp-flavored Python by flavio81 on Thursday August 03, 2017 @12:56PM (#14921303)
>I'm a Lisper (and Pythoner) (...) It boggles my mind that Lispers haven't taken that problem seriously. I have taken it very seriously and have been working on it for years. I just started publishing my results. http://breckyunits.com/the-flaw-in-lisp.html

Honestly, there is no flaw in the parentheses. You just need to write more Lisp.

The parentheses are one of the best things in Lisp.

Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @04:12PM (#14923352)
Disagree. The parens are a missed opportunity. If you use geometry instead, you gain extraordinary new powers of analyzing and editing large programs in 2 and 3 dimensions. Not possible with the parens. The benefits still are not obvious but we're working on publishing more data and tools
Re:Hy – A Lisp-flavored Python by flavio81 on Thursday August 03, 2017 @08:41PM (#14925415)
Well, then have fun programming in Befunge, exactly the programming language that will fullfill your bidimensional desires.
Re:Hy – A Lisp-flavored Python by breck on Saturday August 05, 2017 @01:42PM (#14936854)
Sadly, I've worked with some code bases before that may have been more fun to work on if they were in Befunge.
Re:Hy – A Lisp-flavored Python by blain_the_train on Wednesday August 02, 2017 @09:13PM (#14916179)
Take a look an Parinfer https://shaunlebron.github.io/parinfer/. Which essential makes clojure a whitespace language with indent mode.
Re:Hy – A Lisp-flavored Python by breck on Wednesday August 02, 2017 @09:47PM (#14916320)
Super interesting.

I wonder if the creator has considered just not having parens at all?

Re:Hy – A Lisp-flavored Python by undershirt on Thursday August 03, 2017 @01:48AM (#14917229)
Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @02:01AM (#14917292)
Interesting, I should have been clearer when I said not just no parens, but also just whitespace instead of any syntax characters. The none language uses both () and "". Sweet expressions use {}. And indent-clj uses () and [].
Re:Hy – A Lisp-flavored Python by blain_the_train on Wednesday August 02, 2017 @10:04PM (#14916387)
I have had the same thought. I'm guessing, given how long lisp has been around. That the ideas is well research.
Re:Hy – A Lisp-flavored Python by amelius on Thursday August 03, 2017 @03:20AM (#14917579)
I'm using this same approach in a side project. The idea is very old. See e.g. [1] and the references therein.

[1] https://srfi.schemers.org/srfi-119/srfi-119.html

Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @11:59AM (#14920699)
Very cool! Is wisp yours? I learned of SRFI 49 just over a month ago. I reached out to Egil and hope will be able to chat with him this summer.

As 110 and 119 also note, Egil was on to something. Although I came to it from a different angle, I think he had it about 90% correct.

My contribution is identifying the split between TN and ETNs, and then getting the details perfect with TN. Getting the details perfect meant showing how to craft it so that every single input was a valid TN program. My motivation was, if you can write it/build it in real physical life (3D world), or in other words, if nature allows it, then why shouldn't your compiler? I think 49 missed a few tiny details (like " It is an error if neither one of the leading space/tab seqquences are a prefix of the other, nor are they "...in my TN, there are no errors, and extra spaces are translated into separators for empty words).

Re:Hy – A Lisp-flavored Python by gnaritas on Thursday August 03, 2017 @12:15AM (#14916914)
> by switching to whitespace/geometry for syntactic structure and you suddenly have the dream language.

Nope, you've just made it awful, white-space with syntactic meaning is just god-awful. It's the worse thing about Python, there's a reason it's not a more popular language feature.

Re:Hy – A Lisp-flavored Python by breck on Thursday August 03, 2017 @11:37AM (#14920487)
I actually agree.

Unless done perfectly, whitespace with syntactic meaning languages are quite annoying.

If I had a nickel for every time I had a tab vs space bug in Python when I was first starting to code.

Re:Hy – A Lisp-flavored Python by kirbyfan64sos on Friday August 04, 2017 @07:13PM (#14933141)
Well, now Python 3 doesn't allow tabs anyway. ;)
Re:Hy – A Lisp-flavored Python by breck on Saturday August 05, 2017 @01:38PM (#14936833)
I got it excited when I read your comment, but turns out it still allows tabs, just not mixing. :(