Hacker News new | ask | show | jobs
by tom_mellior 3499 days ago
> I get that this language is very 'human readable'

I wonder why people say/think that. The language uses sigils like @ and #. Sigils automatically make a language non-"human readable" since they have no "human meaning". And no, "you just have to learn the meaning of the language constructs and then you can read it" is not "human readable" in a useful sense. From what I gather, in Eve the @ sign refers to databases. That's fine, but "database foo" is human readable in a sense that "@foo" certainly isn't.

Or look at this example from http://play.witheve.com/#/examples/todomvc.eve

    search
      [#app filter]
    
      all-checked = if not([#todo completed: false]) then true
                    else false
    
      none-checked = if [#todo completed: true] then false
                      else true
    
      todo-count = if c = count[given: [#todo completed: false]] then c
                    else 0
Why aren't these just

    all-checked = [#todo completed: true]
    none-checked = [#todo completed: false]
? Is the triple negation relevant? What is #todo? Is there some sort of implicit iteration over the database where #todo is bound to successive entries? If so, how are the individual flags combined to really arrive at an "all checked" or "none checked" value?

I know plenty of languages that are more "human readable" than this.

It might still be a nice language once you learned it. But this, too, won't be the holy grail of "programming for non-programmers".

5 comments

Eve is based on pattern-matching and is set-oriented. So

  all-checked = [#todo completed: true]
would match each of the records with both topic: 'todo' and completed: true. And the following commit block would once per matching record. But what is desired here is one value for all the matching records (an "aggregate" in Eve lingo).

Personally I think we would be much better off with a dedicated aggregate function instead of using if/else here. And count (which is an aggregate function), should have a default value for when no records match. Then could get rid of the if/else there also, and have something like:

  all-checked = all[#todo completed: true]
  none-checked = none[#todo completed: true]
  todo-count = count[given: [#todo completed: false], default: 0]
Disclaimer: I'm just an Eve user/contributor
Thinking about it, it is possible that this proposal would not work, because in the nothing-matches cases then the function would not be executed at all... But maybe this could work, by widening the matching pattern.

  all-checked = all[in: [#todo], where: [completed: true] ]
  none-checked = none[in: [#todo], where: [completed: true] ]
  todo-count = count[in: [#todo], where: [completed: false], default: 0]
Yeah that's awful. In Ruby it'd be like:

  all_checked = todo.select(&:completed?)
  none_checked = todo.reject(&:completed?)
  todo_count = todo.count(&:completed?)
In C#

  var allChecked = todos.All(todo -> todo.IsCompleted);
  var noneChecked = todos.None(todo -> todo.IsCompleted);
  var todoCount = todos.Count(todo -> todo.IsCompleted);
Did you guys notice that both of your examples use sigils?

Try Avail[1]:

  allChecked    = select element from todos list where [element is completed]
  allNotChecked = select element from todos list where [element is not completed]
  todoCount     = count of element in todos list where [element is completed]
I'm cheating a tiny little bit: `todos list` would probably need to be defined above as a method (I don't remember if one can have variable names with a space inside the name in Avail) and `_is completed`/`_is not completed` would also need to be defined.

Rebol or Red could be also interesting in this regard, also Forth and Factor. Still, Avail goes the farthest in terms of allowing you to write a truly human-readable code (EDIT: however, they support all of Unicode for names and such, so you can go nuts with sigils too, if you want).

(Possibly also Inform 7[2], but I don't know it, so can't really say much.)

[1] http://www.availlang.org/ [2] http://inform7.com/

> Did you guys notice that both of your examples use sigils?

As the person that initially mentioned sigils, I did not say that they are always evil. I just said that you cannot use them and at the same time claim that you have a human-centered fully intuitive programming language.

I'm very fine with using -> symbols for anonymous functions... In fact, I'm fine with other sigils as well, if they are explained properly.

> allChecked = select element from todos list where [element is completed]

To me, knowing nothing about this language, this reads like collecting the subset of the completed elements out of all the elements. But the original task was to compute whether all elements are completed, i.e., whether this subset is equal to the whole. So you're doing something else, or your language is misleading me.

> I did not say that they are always evil.

Of course not; but they are not human-readable. I thought that the posters above me used Ruby and C# examples to say that they (Ruby and C#) may be human-readable. I'm not sure if that was the intention, so I just noted that -> and &: are also sigils.

> So you're doing something else, or your language is misleading me.

It's the former! However, it's what the two posters before me did in Ruby and C#. The fact that all three of us misinterpreted the Eve code is interesting in the context of this discussion...

Correct Avail code would look like this:

    areAllEntriesChecked ::= (count of element in todos where [element is checked])→boolean
Anyway, that's not "my language" at all, I just happen to know quite a bit of strange languages and wanted to share info on one with an interesting take on readability. They call it "articulate programming", which seems to be an evolution of Knuth's literate programming.
> However, it's what the two posters before me did in Ruby and C#.

Ha! You seem to be right about the Ruby, I missed that too. The C# looks correct to me, though: https://msdn.microsoft.com/en-us/library/bb548541(v=vs.110)....

Yeah, this is my big complaint. It almost seems like it's less understandable to make the whole literate programming bit relevant.

Imo, literate programming should be solved by more expressive languages, not prose commentary layered on top.

maybe I should have said supposed to be human readable. I share your sentiment. I saw a comment on here once justifying that claim by saying something along the lines of "but if you look at the text and ignore the symbols you get the gist", which is not the original promise of Eve in my opinion [0]

Edit: found the source: [0] https://news.ycombinator.com/item?id=12819973

#todo is shorthand for [ tag: 'todo' ]. A record can have multiple tags. Agreed that there should be a full-form for database, not just @.