-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax #4
Comments
In the chat app, you use freeze all. What does it mean? Thanks |
https://github.com/witheve/rfcs/blob/master/proposed/syntax.md#freeze-all Good catch, I forgot to include a section on that. Right now, Honestly, we're not too thrilled with the keyword |
Considering the call for a new name for Eve's Objects:
The name Object is problematic for a variety of reasons. You mention the obvious one of Objects in Software is usually referring to a unit in a OOP model. This is problematic not only for the person who is familiar with OOP but also for the person who has heard of OOP, and also for the learner of Eve who after Eve might want to dip their toes into other forms of programming. Furthermore the term Object is a vague and crude term in that anything can be an object. So I suggest the name Records. You describe objects as:
This falls in line with the concept of Records in Elm and Databases, and somewhat close to other functional programming languages concept of Records. But more importantly Records is a term already known well to mean a collection of data about a specific thing to the general public. |
Given that "Eve" is a homophone of "EAV" (Entity-Attribute-Value) and that EAVs are Eve's core abstraction under the hood, it seems more appropriate to refer to Eve's objects as entities. Record is also a sensible alternative. |
And later:
It seems to be an inconsistency here. If I'm not mistaken, "if they are a spouse of a friend and not busy" should be written as |
Pascal pointed out some deficiencies in the example on the mailing list. We wrote it a couple weeks ago when the runtime still couldn't run the code. I'm currently rewriting the program to make it correct. |
How long does a session last? After the session is closed, is the data stored in the Eve DB deleted? |
@Eucalyptus2013: The Eve DB is a distributed database, so it's a little nuanced, since there are actually multiple DBs (we call them "bags", a better word is appreciated here too). When you start an Eve server, it starts with an empty global bag. When I start a session on the server (which lasts as long as I am connected to it i.e. the websocket is open), then I'm given my own instance bag, which is empty. But the facts available to me are the union of my instance bag and the global bag. So every time I say When I say In the context of a chat app, it uses Does that make sense? |
If I want to store a fact in the global bag (by using freeze all), because I want to access this fact after the session is closed, but I don't want the other users to access this fact, how can I do this? |
Right now, our permissions story is incomplete. Eventually, we will have a notion of a user, and be able to stick facts into bags with restricted access. Until then, you can create your own users, and parameterize the facts with a user attribute. The you can join the restricted facts against the current user. The chat example does this in a way. |
Okay, I've updated the RFC with a better example program. Right now, there are still some execution issues with it, so the result if you run it isn't correct. But we'll work on those more today. I also removed a section on reusable code. We had a discussion about user defined functions yesterday, and that whole area will be going through a redesign. I'll add that new design to the proposal here as a pull request when I've gotten it together. |
After further consideration, being as objects are employed not only as literal representations of Eve DB facts but also as patterns for matching against such facts, I don't believe records is a suitable replacement term for objects; and while entities still seems applicable, I now prefer the term forms. |
First off, how stable are you trying to get your syntax? You mention under "Risks" that you don't want to turn people off, which is reasonable, but Eve is not at risk of becoming hoon. I'd worry less about turning people on or off and more about gently introducing them to the semantics. Let's allow ourselves to learn how to write Eve programs before we get confident about syntax. That said, the biggest thing I'd expect to cause people to "not get it" and be turned off is the fact that although a block looks like a procedure, you're actually building a single query. The second-biggest thing are the set semantics. This still throws me off sometimes after writing SQL for 10-15 years. I really don't know what to recommend, but I feel like the syntax has to communicate a programmer's expectations around cardinality. Perl's On objects: I agree, records or entities would be fine. "Record" is maybe more friendly. On phases: I think of "prepare" and "commit" phases, if we are talking about them. Consider "do" and "commit", but I'm not confident I understand my intention when using freeze and freeze all. I think there's a sense of making a commitment to others, of making a statement that is hard to retract, so: "publish"? Manipulating the state of bags is surely not what I'm thinking about.
What is
Regarding How do you fit predicates other than equality into that record query syntax? Sorry, I'm at a disadvantage here: you've spent a couple years programming in this paradigm, and I haven't. I can tell you what's confusing to me, but without that experience of solving actual problems in Eve, it's hard for me to suggest concrete improvements. |
Peter,
Actually, you're exactly the kind of person we want commenting on this; we need the perspective of an outsider because ultimately we want more people using Eve than just us :)
I think we're happy with the overall direction of the syntax, so we wouldn't want to switch to s-expressions or a c-style curly brace syntax. That said, we still see this syntax evolving as we discover more about how to write good programs this way. Since we posted the RFC, we already have new ideas for how to do user defined functions.
One of our decisions we hope will mitigate this perception is that the blocks are not really named, and there's no real concept of "calling" a block, so without those a procedure really can't exist. Once upon a time, we thought about wrapping the blocks in a Another way we hope that our code doesn't "look" procedural is that we're trying push the idea that eve files are actually prose with code interspersed, rather than code with comments interspersed. Thus, visually, eve code will look more like a document than code. Finally, I think that while the statements could look procedural, the overall feel of the syntax stresses that there’s something different going on. If we had a c-style curly brace syntax, I think that it would be a much bigger concern.
Yes, we see this as a source of confusion too, but we hope to mitigate it in several ways. For the most part, you can actually code without thinking about cardinality, because our evaluation is row by row. Just consider everything as a scalar, and most of the time things just work when they’re not. You really only have to pay attention to cardinality when you’re using an aggregate, or mutating. With a little tooling though, we can actually provide the cardinalities of your variables as you code, so this is one way we can help here. Another might be to try and enforce a convention, that plural variables should be used for sets and singular ones should be used for scalars. But that would be purely convention. Regardless, we'll see if this is an issue or not.
Any time the programmer uses a tag selector, then there's the potential for cardinality greater than one. Regarding the plurality of the variable, maybe this is something we try to encourage through convention. If the variable can be plural, write it as a plural.
Commas for us are whitespace. They have no syntactic meaning. The use of the comma here was in the english sense to delineate a list. It should be read "sum the burgers given burgers, guest". However, we’re thinking about new ways to express this to avoid any confusion.
It has a tag because it’s a normal object, like any other. When I connect to the server, Eve puts a #session-connect in the DB that exists for one tick of the executor. For that one tick, the object [#session-connect] exists, and I have the opportunity to do something to the DB. So this is a good place to initialize any data with a freeze. Using a This is something we might sugar over in the future though.
You can bind any variable to create an alias. For example:
The same way you do equality. For instance: Thanks again for your comments; you've raised some important points that I need to think about some more. Let me know if you have more ideas/opinions |
When an Eve program is run, are the blocks evaluated in top-down sequence as they appear in the source file? When a block is evaluated, is the collect phase evaluated eagerly, or is it evaluated when its objects are first referenced in the mutate phase? Blocks with a maintain clause appear to keep the queries in the collect phase alive. Is there syntax for terminating these open queries programmatically? Can a single block contain a maintain clause and a freeze clause? |
Bertrand,
No, block order should not matter. Typically, line order should not matter at all for Eve programs. However, there are two instances when order matters:
We eagerly evaluate it. For instance, consider this block:
If there are no objects with
The way you could achieve this is by putting a
Yes, blocks can also contain multiple |
I just found this comments thread. I think a tutorial would be great for Eve. I can write one myself, but would like to know, how long before the first version of the syntax will set set in stone as it were? |
Thanks for nailing down those loose edges for me Corey. I've learned conceptually esoteric languages like Haskell without much difficulty, but in learning Eve I'm having to bury pretty much all of my assumptions and a good number of my intuitions. There's one important aspect of Eve that remains opaque: I haven't seen public discussion of Eve's temporal logic underpinnings yet. Can you address this and how it might be exposed to programmers through the developer syntax? |
Zubair, The syntax probably won't be set for a while, so a tutorial might be out of date as soon as you write it. I'm working on one myself (well a couple), which will help in learning the language. However, maybe writing about your experience in learning Eve would be a worthwhile exercise. |
@ZubairQ the main thing is we don't want to set anything too into stone until we see more usage from folks outside of us. That being said, there's only one biggish change that I can think of at the moment in terms of the syntax, which is a slightly different syntax for function calls. Beyond that, unless we get some drastic feedback, it's likely just wording changes and such. @bertrandrustle That's interesting, our language is easily an order of magnitude simpler than something like Haskell. What intuitions and assumptions are being challenged? Do you think there's something we could do to help facilitate that understanding? At the moment, we don't expose general time traveling in queries, but that's probably the simplest and least semantically important part of the temporal logic. Our semantics are based on dedalus, which has the notion of talking about "now" and "next". This shows up for us as part of the difference between
If |
@RubenSandwich suggested changing "freeze" to "commit". The thought here was that "freeze" implies that the object is frozen in time, forever unchanging, which seems wrong since a frozen object can be mutated. Thoughts? |
The choices Haskell makes on what to expose and what to abstract away closely complement my natural cognition, whereas Eve brings one of my greatest challenges to the fore, temporal reasoning. I'm more fluent in structure than process. My brain models systems as a complex of visual-spatial impressions where each part can be shifted within a concrete-abstract spectrum to facilitate relations with other parts or systems. This is pretty effective for structural pattern recognition, but a major weakness is the lack of a temporal sense, and so I often resort to modeling temporal things as spatial/structural things, somewhat like the Bret Victor demos in which he models time using geometry. With Eve a visual interface may prove more natural for me than a textual syntax. In the Haskell world almost everything is lazy and immutable by default and time rarely makes an explicit appearance. Programs are fundamentally structured around timeless, unchanging functions which are devoid of side effects. These properties make it easy for me to reason about things. Haskell is a largely frozen world. Superficially the Eve world is declarative as with Haskell. But Eve programs are structured around movement of state in temporal dimensions. A block essentially describes a discrete interaction of state in time, the duration of which is determined by a two-phase process over state: observations of state (queries) matching certain criteria in the first phase determine whether or not state will be changed in the second phase, and the nature of change in the second phase can be snapshotting (freezing in time) of state or manipulation and continued observation of state (maintenance of state in an open-ended "now"). Also in contrast to Haskell, side effects appear to be Eve's primary method of computation. I'm not sure any of that makes my perspective relatable or even understandable. As for improving the textual syntax, I don't have anything useful to propose yet; I need more experience with it. But in light of how my brain works I concede I might be an outlier the textual syntax probably shouldn't try too hard to accommodate. ;) |
@cmontella "freeze" is a good choice from a time-oriented viewpoint, and "commit" is a good choice from a database-oriented viewpoint. If Eve is a temporal query language on top of a relational database, which viewpoint should prevail? The time viewpoint is consistent with the abstraction presented by Eve's temporal semantics. (Although the way I conceive of it, the term "snapshot" captures the meaning even better than "freeze.") The database viewpoint is closer to the underlying implementation, where it's just a standard database transaction, something already very familiar to developers. The term "commit" itself is also common to source control tools and has much the same meaning there. |
Some thoughts:
This clears up the confusion of the earlier minimal pair even more clearly:
|
It seems likely the keywords
In addition to renaming
I'm aware that Eve's relational database doesn't use SQL, but SQL is widely familiar to people with database experience, and I couldn't identify terminology for a comparable two-phase dichotomy in the domain of Prolog/Datalog/Dedalus. |
I thought of another perspective on replacement candidates for
Objects fenced with With those considerations, I propose renaming:
|
First off, thanks for the awesome and thoughtful feedback @benjyhirsch and @bertrandrustle ! I spent a bunch of time last week and this weekend thinking about the comments here and have a few proposals that I think help address a lot of the feedback. Most fundamentally, we should probably adjust the way we talk about Eve's paradigm in general. Instead of evoking logic or relational languages, it seems like the most straightforward way of describing Eve is as a pattern matching language. "When you see this pattern, do this." Amusingly enough, that's where we very first started with the madlib version of Eve. To that end, I propose the addition of the
I tested a few variants of
I also suggest we change @benjyhirsch you brought up some really good points about the confusing semantics of the mutation operators and I spent the most time trying to figure out something consistent for them. It took a bit, but I think we've got something that's a good deal more sensical than what's there now. The biggest change is that any object in the action part of a rule is a new object. Also, instead of set (
One thing I'm not certain about is what Finally, unrelated to this part, we want to change the way "functions" are called to reinforce that they are themselves really just objects that are created on demand. We also want to make the code a lot more readable by using keyword arguments:
One big advantage besides being self documenting is that optional/alternative parameters are much more straight forward in this scheme:
Putting the name outside is really just sugar for:
Which means that defining your own functions would be something like so, where
In reality you need functions in our language very rarely, but this is a very powerful system. For example if I wanted to support an entirely different coordinate system for sin, I could do this:
|
All of the above proposals have been implemented in the match-syntax branch. |
@ibdknox Your changes seem reasonable, but I'm fuzzy on a few things regarding the changes to function syntax. Now that the match (formerly collect) phase is explicitly fenced, is anything actually being matched in the
That looks like a simple equality statement involving primitives and attribute variables but no objects. Conceptually, I believe simple equalities and other statements which don't query the database, filter a query, or affect any statements which do those things, should go before any From a practical standpoint, because a non-querying, non-filtering equality rule such as this is, I assume, always true, its presence in the Finally, would the availability or application of the |
Instead of "object" I suggest "selection". We could say that each query defines selection variables in the "collect" phase. This makes it clear that a selection is not immutable - the value of each selection variable (its "current selection") actually changes over time. Then it would be natural to rename the "collect" phase to the "select" phase. |
@cmontella Actually I would say the opposite, in that saying "database" as singular is unusual. In Pharma we use products that talk to multiple databases all the time, products like Qlik Sense and SAS so it is actually unusual to talk about database in the singular most of the time at my work. I think developers making webapps usually talk to ONE database, so I agree that for them it may be a little weird for them. But I like database and datebases ! |
I'm glad people are finding my naming questions helpful. 😄 @cmontella Your answer for naming question #3 for Context makes sense. I'm ok with the word Database/Databases and am not bothered by the plurality of it as it is very common for apps to have both a client side and server side persistence store which to me fits the concept of "Database" even if some implementations of these two stores do not fit the actual technical meaning. However one thing that does bother me is how technical sounding the word is which I fear could scare people completely new to programming off. (Devils Advocate: If a beginner gets to the part about worrying about multiple Databases in Eve they might have already gotten over the 'hump' so to speak, but maybe not depending on how central of a concept it ends up becoming.) |
Switching gears here from the naming of Bags. One wart I currently see in the Eve syntax is the use of the not operators parenthesis. For example here is the not operators usage in the documentation:
These parenthesis seem ugly to me because this is the only operator that uses them. The only other place parenthesis are used in Eve, to my knowledges, is for the tuples. I can see why they are required for nested queries, but I think for consistency this operator should use the function syntax. This removes what I believe to be a gotcha and makes the parenthesis always mean tuple. Function syntax not operator:
Alternative Haskel like syntax:
|
@cmontella @ibdknox I think databases could be a reasonable name, but I'm confused about what role databases will have. It seems like they might have two purposes:
But I feel like you really want a separate scope for every single "relation"/"table"/"collection of objects" that conceptually appears in your program, otherwise what can I expect to get when I try to match on some simple patterns?
I'll get a whole lot of values of semantically-different attributes (that happen to be named the same) from a whole lot of unrelated entities. This seems like a substantial flaw in the language as it stands. From what I can see this would never be desirable. Maybe this is what #tags (or names) are supposed to be used for. But if you're meant to use a tag to make sure you only access the subset of an attribute that has the right semantics, then it seems like tags should be mandatory for every record, because tags are really defining a context too: the context of the attribute names. Of course a record can have more than one tag, so this implies the contexts can be overlapping. One thing is clear though: a record should certainly belong to at least one context (have one tag). A tag/context assigns meaning to a collection of records.** So is it safe to say that tags are really used to give context to a record and its attributes? If so we might want to mandate that all records have at least one tag. And with this understanding of tags, it definitely makes more sense to call bags databases, because they'd be much less about scope/context and much more about modularity. ** Aside: I really want to say "object" or "entity" here. To me, records are homogenous rows in a table. |
@ecl3ctic Really good points.
And does a module as such add things to just one database or potentially many?
Might adding a #tag (or a @name for that matter) be just the same as using a context? So that:
is basically the same as:
or even incendiarily as:
Word. |
@ecl3ctic As you identified that is more or less what tags are for, but I don't think we should make them mandatory. One simple counter example is wanting to select Chris @RubenSandwich so far,
Right now we have a few uses of parens:
They seem decently consistent to me, but I definitely agree there may be better ways to spin it. We could keyword arg is/not:
Or something like that (really dislike those attribute names lol). |
@ecl3ctic As @ibdknox said, maybe sometimes you are looking for all the records with an id attribute. Do we have a way to match an attribute with a particular value? For instance, suppose our #person is populated with all sorts of relations: mother, father, cousins. Given two people, what are all their relations? |
@wtaysom That's where I started myself it just seemed like you could accomplish pretty much everything you want by specifying more tags, but it's not quite the same. One example is that having separate "databases" allows you to fork the data. There's also a semantic difference in the examples given if you take multiple databases into account:
You also end up with the CSS selector problem where you're trying to make more and more specific patterns to ignore things you don't care about. Instead, this way you can put them in a different box.
We don't talk about it much right now, because we don't like it and it's slow. In the current implementation there's a magic thing that does:
We eventually arrived at this as a better thing, but it's not implemented (yet!):
|
Hey everyone. I just wanted to point out that we've made a couple changes to the language and so I'd like to get some feedback here. First, as we mentioned earlier, bags/contexts are now called "databases". This doesn't have any other effect that word choice. Second, we've removed the In place of Finally, we're renaming |
I agree with the decision to remove @. I also think The way I would describe |
Thanks for the thoughts Nick! I'm glad you think We've actually had a lot of success describing
So that's the meaning of "bind" we're going for. In a sense, the meaning of "bind" you put forth is still applicable here; what's being tied together are the records themselves. That's something that's unchanging. When you search for a record and then bind a record in response, those records are forever intertwined. It's the values of attributes that change. But a bound record cannot exist without its supporting records. But I can definitely see how this might be confusing to people unfamiliar with this usage. I think when we launch to a wider audience this month, we'll see what the general perception is and adjust accordingly. |
@nmsmith In any domain, some words should stand out and others should be as plain as possible. In Eve, I say "bind" should definitely stand out, and should lead any curious person to the notion of data-binding. In contrast, "match" is needlessly more obscure than "search". Likewise, an essential attribute used in basically every Eve file merits a sigil. Use sigils for less prominent purposes, and you end up with Perl, or worse: APL. @cmontella One downside of "search" is the old "search" vs "find" debate. (One incarnation http://stackoverflow.com/questions/480811/semantic-difference-between-find-and-search.) My main qualm is the usage, "you search a place for the thing you want". So it is natural to say "find this, bind that to it" but not so much "search for this, bind that to it". Others will, no doubt, have very different feelings. |
@wtaysom I personally prefer search, because I think it might be a common thing to search a particular database. e.g. |
Instead of "search" how about "when"? |
@ZubairQ "when" does evoke the "if-this-then-that" kind of workflow that is similar to what's happening in Eve. But it kind of loses out in the context of databases:
versus:
In my mind, search fits nicer with what is actually going on here. Thoughts? |
The word "search" does work well when you have a database context. Don't see the point of having the extra punctuation though. I mean why "search (@db1, @db2)" instead of just "search @db1 @db2". -- Of course how to use punctuation is the most superficial programming language issue second to tabs vs spaces. |
That's fair, originally I was thinking it might have the same parsing ambiguity issues that |
@cmontella Actually I thought about it more after reading your comment and you are right. Also, non programmers also know better what "search" means. Also "When" would not have been the right term. I guess I should have suggested "whenever" to indicate something that occurs on a continuous basis, as one of the issues with "search" as a word is that it tells me in my head that this only happens once... but "search" the best for now, I agree |
I feel like "search" doesn't capture the semantics as well as "match". One thing I don't like about search I feel like a search can come back with no results where as something matches or it doesn't. Match captures the Boolean aspect of whether the second clause fires at all. With "search" the reason the second clause doesn't fire is "there were no results" which intuitively feel like "okay fair enough -- now you tell me that's what you meant" where is with "match" the reason the second clause doesn't fire is "um, because it didn't match" which feels more like "well yeah that's what we agreed". I can see how search might be more approachable though and work well with the "database" name too. One thing I wanted to bring up at this point was about the optional commas. I feel like things like pep8, gofmt and clang_format are trying to get things to a place where equivalent programs that only have superficial differences have a preferred form. Personally I think it makes it a lot nicer for multiple people to work together. In the aforementioned projects the language communities have converged on one coding standard. I wonder if it might be better to avoid allowing the choice of commas or not entirely since it's basically one less thing to have to normalise for a possible future gofmt like tool. |
I strongly agree that tools like gofmt go a long way toward normalizing style. |
@wtaysom For what it's worth, short of a tool like gofmt, we realize that many new users will copy the style that they see us using, so we're trying to make our code consistent. We've started a style guide (still a draft) that aims to make our style explicit: https://github.com/witheve/docs/blob/draft/src/guides/style.md Until we have a tool like gofmt, we'll try to encourage a certain style in these ways. |
How about "require" as an alternative to "search"? require Requires the person record/pattern be in the database. OTOH, x = 10 = 20 is a requirement that cannot be met. |
Hm, haven't thought of that one before! It's nice because it gives the impression that if the requirements aren't met, the block cannot run. But at the same time, we really haven't had any complaints so far about "search", so I don't know if changing it adds any more clarity. Just curious, what was your impression about what "search" did? |
I mentioned this just in case "search" does cause some confusion with initiates. My understanding is the search clause is setting up prerequisites prior to commit/bind. Search/finding/matching against a database makes sense. Two more possibilities: "assert" and "facts". Yet another: "when". Here's an example where "search" does not seem such a good fit. From the CRM app: search |
For me, "search" always feels a little awkward. When I talk or write, I'm liable to use "match". @frankier pointed out when "match" feels funny. "require" has nice connotations. I've encountered "given ... assert ..." before, which, though precise, feels mathy. There's also Inform's curious use of "instead ... try ...". |
I agree with @RubenSandwich that I also feel that sometimes allowing a single unnamed argument to a function, in addition to additional named arguments, leads more elegant API. For example, having to always pass Swift has a nice API Design Guidelines doc which may be worth taking a look at. |
The use of |
In the docs, it says that In
the use of |
Can't resist one more alternative to search. How about when/commit and while/bind pairs? |
I like the way your suggestion reads, and it actually fits with the change we made in v0.3 -- to forbid the use of bind and commit in the same block. However, I think having two different names for "search" belies the fact that in each case, the search/when/while portion of the block works the same way. I'm sorry for the extended delay in getting back to you! Somehow your posts slipped under our radar. To answer your thoughts:
Square brackets signify a record, and contain a list of attribute/value pairs. This is true for bare records, and functions (which is why we used square brackets for functions instead of parens like other languages -- we want to draw attention to this duality). I do agree having square brackets would be more consistent, and we had considered this at one point with the goal of minimizing the number of grouping characters we used, but in the end I think reserving square brackets for records exclusively is important enough to add another character to the syntax.
I agree, this is something that's tempting, especially for functions with one self-descriptive argument. If we choose to allow anonymous arguments there are two immediate effects:
Number 2 might be okay, since as you demonstrate I thank you for the link to the Swift API guidelines, as I think they actually explain our general philosophy pretty well:
This is more or less one of the principals we outlined in this RFC.
In our syntax, the
This was a style choice. In other languages Again, sorry for the long delay in responding, I'll try to monitor RFCs a little more closely from now on :) Corey |
RFC Link - https://github.com/witheve/rfcs/blob/master/proposed/syntax.md
The text was updated successfully, but these errors were encountered: