8 ms·
The Egison Programming Language
- wizzwizz4 3y agoIt looks interesting, but I don't understand the syntax. The only documentation is a doctoral thesis, which contains the usual padding: > Interestingly, this basic definition of map has been almost unchanged for 60 years since McCarthy first presented the definition of maplist in [62]. but it jumps from what looks like standard Haskell, to the new syntax, without explanation.
- 082349872349872 3y agotry https://www.egison.org/download/pmo-paper.pdf https://www.egison.org/download/pmo-paper.pdf ?
- wizzwizz4 3y agoThis comment originally said that the link was useless. Actually, this is a nearly-complete explanation of Egison's syntax. The only difference I've noticed so far is : for Egison's ::.
- 082349872349872 3y agoEdit: glad it helped! (This comment originally suggested attempting to reverse-engineer the syntax after learning the semantics)
- hyperhello 3y ago“Egison makes programming dramatically simple!”
- 2h 3y agodef twinPrimes := matchAll primes as list integer with | _ ++ $p :: #(p + 2) :: _ -> (p, p + 2) why do people do this? this is unreadable to me. what is the second line, a comment? then they somehow found a way to cram 11 symbols in a single line after that. bravo?
- wizzwizz4 3y ago| begins a pattern match. ++ is list concatenation. :: means "thing-on-the-left is of type thing-on-the-right". That's all standard Haskell syntax. Egison seems to introduce some kind of advanced pattern-matching syntax with $ and #. I can't figure out what it is, or how it works; but I imagine it's quite simple once you actually know what it means.
- tromp 3y agoInterpreting :: as a typing judgement makes no sense here. What does make sense is interpreting :: as a list "cons", i.e. as : in Haskell.
- kristopolous 3y ago> I imagine it's quite simple once you actually know what it means. The first part isn't notable. Olympian athletes, for example, do the most baffling of intricate movements in grace and simplicity. Instead it's the amount of effort and context to get to the understanding that's at play. Maybe this syntax is intuitive for a mathematician, formal logician or some other specialist, but as just a mere every day programmer, it looks like nothing I'm familiar with. This is fine. Just let's not pretend that it's low effort to get onboard
- kragen 3y agoit's probably low effort for a 'mere every day' haskell programmer; it's just a question of what you're familiar with, not actually deep math (minor correction, as tromp points out, :: is evidently list construction, as in ocaml or haskell, not a type annotation) you asked what `matchAll primes as list integer with` meant ('what is the second line, a comment?') but apparently the person who answered you didn't understand that you didn't understand. it means 'evaluate the expression `primes`, which should have the type `list integer`, and then attempt to match the value resulting from that evaluation against each of the following expressions in order' deep math isn't simple to do even when you know what it means; it isn't just a matter of learning what all the symbols mean. this is just a matter of learning what all the symbols mean, like reading english instead of chinese. so to me your complaint reads like someone saying (in chinese) 'just a mere every day reader of novels, it looks like nothing I'm familiar with' because some text is written in english however, the situation is not quite so symmetric as with chinese and english. with a good notation, cramming lots of symbols onto a line is a really good lever to empower your reasoning ability. consider trying to explain how to play the seventeenth measure of pachelbel's canon in words. or writing assembly instead of c, even though they're both at pretty much the same level of abstraction pattern-matching really significantly improves the clarity of certain kinds of code, and you're missing out if you don't know what that's like i'm guessing that #() (the only weird part) is analogous to ${} in `-strings in javascript or #{} in ""-strings in ruby: it embeds an expression to be evaluated in a context where you wouldn't normally expect expression evaluation, in this case a pattern for pattern-matching (disclaimer, i don't actually know haskell, though i've implemented my own programming language featuring pattern-matching)
- sidkshatriya 3y agoI really like this language. Very intuitive and simple syntax (once you understand the fundamentals). And very powerful too! The pattern matching examples get addictive after you've read a few. Egison can be used to build a symbolic math backend and do all kinds of pattern matching. But its really niche requirement and it's never really occurred to me in all this time "hey, this might be a good time to use Egison" I wonder when it might be a good idea to use Egison and if there are some current users in production.
- ink_13 3y agoMaybe I'm just a dummy who should stick to scripting, but I had exactly the opposite reaction: based on everything I've seen, this is wholly uninteresting. I can't imagine a single practical application that isn't more comprehensibly written in an existing language. But I feel the same way about Haskell, too. The older I get the more I value code that is easy to understand and debug by either myself or someone else months or years down the line when the original context might be forgotten. Ultra-dense syntax like this only makes that almost superhumanly difficult.
- kragen 3y agotry implementing symbolic differentiation in a language like haskell or egison, and then again in a language like python or js, and your perspective on what is 'easy to understand and debug' is very likely to change
- znafelrif 3y agoDo you have an example of such an implementation in haskell?
- kragen 3y agogoogling i found https://gist.github.com/amalex5/541dc739201bbd8e26037b6738cdf75b https://gist.github.com/amalex5/541dc739201bbd8e26037b6738cd... although it's missing the type declaration http://5outh.blogspot.com/2013/05/symbolic-calculus-in-haskell.html http://5outh.blogspot.com/2013/05/symbolic-calculus-in-haske... is more complete and also includes an explanation and a bunch of algebraic simplifications you'd usually want along with the symbolic differentiation itself
- dang 3y agoRelated: The Egison Programming Language - https://news.ycombinator.com/item?id=17524239 https://news.ycombinator.com/item?id=17524239 - July 2018 (67 comments) Egison – Pattern-matching-oriented Programming Language - https://news.ycombinator.com/item?id=7992661 https://news.ycombinator.com/item?id=7992661 - July 2014 (33 comments) Egison: A Lisp Written in Haskell with Advanced Pattern Matching - https://news.ycombinator.com/item?id=7924168 https://news.ycombinator.com/item?id=7924168 - June 2014 (27 comments)
- pasquinelli 3y ago> Egison makes programming dramatically simple! that doesn't mean anything, it should be "Egison makes programming dramatically simpler!"
- canadianfella 3y ago[dead]
- sambeau 3y agoThis comment makes you patronisingly incorrecter.
- BaculumMeumEst 3y agoif i wanted abstractions for the problems this language aims to solve i would personally prefer to either find a suitable libraries in lisp or write some myself than learn an esoteric language where i don’t know how it works under the hood
- Jtsummers 3y ago> if i wanted abstractions for the problems this language aims to solve i would personally prefer to either find a suitable libraries in lisp Here you go: - As a Common Lisp library: https://github.com/zeptometer/egison-common-lisp https://github.com/zeptometer/egison-common-lisp - As a Scheme library: https://github.com/egison/egison-scheme https://github.com/egison/egison-scheme
- barrister 3y agoHere is my brief explanation of the example given on the website in order to clear up some confusion, that I gleaned from the thesis paper. Admittedly, this language does require knowledge of Haskell to really comprehend: -- Extract all twin primes from the infinite list of prime numbers with pattern matching! def twinPrimes := matchAll primes as list integer with | _ ++ $p :: #(p + 2) :: _ -> (p, p + 2) "matchAll is composed of an expression called target, matcher, and match clause, which consists of a pattern and body expression." In the example `primes` is a list of primes as in Haskell: `[2,3,5,7...]` considered the "target", and the "matcher" `list integer` may be thought of as a Haskell type like `[Int]`. So I suppose you could simply write it as `primes :: [Int]` and mean the same thing. This notion of a "Haskell list" is important because in the "match clause" the "pattern" is a combination of concatenation using the operator `++` and cons from Lisp using the operator `::`---note that this deviates from Haskell syntax in a somewhat confusing way where Haskell uses `:` and `::` for typing. Nonetheless, the integer list is deconstructed according to concatenation first, in every way, i.e. `[] ++ [2,3,..]`, `[2]++[3,5..]`, etc.., then according to cons'ing with the head stored in the variable `$p`. Yet, the "rest" of the list in this case is actually matched according to the pattern `x::y::_`, therefore, the second element must be 2 from the first, which is why the first pattern `[]++(2::3::_)` is discarded. The `#p` notation simply means to reuse the previous value of p to create a literal match, therefore for the first pattern `p is 2` and `#(p + 2) is 4` thus the pattern becomes 2 followed by 4 followed by the rest, which again doesn't exist. Finally if a match does exist, the values are constructed according to the "body expression", in this case a pair, and all of the results kept in a list. Therefore the type of this value is twinPrimes :: [(Int, Int)]
- wizzwizz4 3y agoI really hope that | _ ++ ($p :: #(p + 2) :: _) -> (p, p + 2) is valid syntax. That would've cleared the whole thing up for me.
- 1letterunixname 3y agoFor systems use, binary manipulation is essential. Elixir/Erlang's binaries are nearly optimal in this regard. I maybe wrong, but it doesn't seem far removed to include such features.
- omneity 3y agoI’ve had the chance to chat with the author of Egison a while back. A brilliant character.
- crabbone 3y agoAnother Haskell-style cuneiform where a ten-lines-long function will give you a massive headache for days before you can decipher it.
- sevensevennine 3y agoThis is not hard to read. The main novelty is pattern matching itself, which is making its way into languages that are used (java, javascript, etc) from languages that are interesting (Haskell, lisp, etc) Take a look at this example from the text, which contains an obvious domain modeling error while demonstrating cool things: def suit := algebraicDataMatcher | spade | heart | club | diamond def card := algebraicDataMatcher | card suit (mod 13) def poker cs := match cs as multiset card with | [card $s $n, card #s #(n-1), card #s #(n-2), card #s #(n-3), card #s #(n-4)] -> "Straight flush" This matches a new kind of poker hand called the "wrap around straight flush," where a straight can wrap around Q, K, A, 2, 3. assertEqual "poker hand 1" (poker [Card Spade 3, Card Spade 2, Card Spade 1, Card Spade 0, Card Spade 12]) "Straight flush" TRUE IOW, in their eagerness to demonstrate a really cool match on a mod 13 expression (something I haven't seen before), the author models the domain incorrectly. It's also somewhat confusing that the cards are modeled as n-1 - ace=0, 2=1, 3=2, etc, which is also confusing. I tried for about 10 minutes to fix it, but the only notation documentation I found is math that is way over my head.