
Egison – Pattern-matching-oriented Programming Language - hamidr
http://www.egison.org/
======
egi
The creator of the language here, ask me anything. Please check my paper
recently I put on arXiv.org.
[http://arxiv.org/abs/1407.0729](http://arxiv.org/abs/1407.0729)

~~~
kylebrown
This looks super interesting, thanks for including so many demos and docs. I'm
pretty new to PL theory, but was recently reading about OMeta - another
"language for pattern matching". For example, here's a png parser in OMeta.[1]

Maybe you could help me understand how Egison compares to OMeta? thanks.

1\.
[http://www.joshondesign.com/2013/03/18/ConciseComputing](http://www.joshondesign.com/2013/03/18/ConciseComputing)

~~~
egi
I read a slide on OMeta.
[http://tinlizzie.org/ometa/dls07-slides.pdf](http://tinlizzie.org/ometa/dls07-slides.pdf)
Its pattern matching is specialized in expressing pattern matching against
lists and trees. Egison aims intuitive expression for a wider range of data
types and provide non-linear pattern matching with multiple results on a
functional language. Please check a cheat sheet and demo pages on our website.
We can get its concepts easily from them.
[http://www.egison.org/cheatsheet.html](http://www.egison.org/cheatsheet.html)
[http://www.egison.org/demonstrations/poker-
hands.html](http://www.egison.org/demonstrations/poker-hands.html)

~~~
kylebrown
Thanks. It looks to me like Egison is focused on pattern matching of data.
While OMeta is focused on pattern matching of syntax (so is used to create and
extend new languages/DSLs). Is that a fair comparison?

How does the Egison online evaluator work? Server-side haskell or the ruby
extension?

Any plans for a javascript extension?

~~~
egi
What you wrote is what I wanted to write. We call the Egison command on the
server limiting code with side-effects via an API server implemeted in Ruby.
All source code on Egison including its website is on GitHub. Please check
them, too. [https://github.com/egison](https://github.com/egison) I’m not
planning a javascript extension for now, though I’d like it.

------
anigbrowl
Love the 'cheat sheet' accessible from the landing page. Great way to give a
feeling of what it's like in under a minute.

------
mamcx
Because lispy syntax is alien to me, how is this different to the pattern
matching of other languages (I barely know the ones about Haskell, and now
swift)?

This interest me because I'm dreaming about build a language and think pattern
matching is very cool and look like can replace if & case.

~~~
egi
The biggest difference is Egison realizes non-linear pattern matching against
unfree data types such as multisets and sets. I've wrote brief comparison
here. [https://github.com/egison/egison#comparison-with-related-
wor...](https://github.com/egison/egison#comparison-with-related-work) Please
check my paper, too.
[http://arxiv.org/abs/1407.0729](http://arxiv.org/abs/1407.0729)

~~~
mamcx
Ok, which are the baby steps to implement pattern matching in a language?, and
if is more similar to python/swift than lisp?

~~~
egi
I'm sorry but I think if you would like to implement a language not only use
it, it would be better to learn lisp at first. It is very easy to implement
lisp on lisp and modify it as you like. This is an scheme interpreter I wrote
in scheme. It's extremely short compared with other language. There are many
good textbooks, too.
[http://www.scheme.com/tspl4/](http://www.scheme.com/tspl4/)

~~~
mamcx
I understand that a lispy language make some stuff about building a language
easier, but still is very common to use a imperative one to build them, and in
imperatives I'm skilled...

So the question are really 2, to make them more clear:

1- What are the baby steps to make pattern matching?

I could follow a functional language if the explanation is clear, but if the
code requiere skills in them I could get lost. So, I ask if exist this kind of
resource, if possible. If not, then anything else is ok and them I know I need
to devote some time in learn other kind of skills.

2- Is pattern matching more problematic if the language is not functional,
inmutable? If is a mix (like with swift), what is the sweet spot (if exist?)
or what is needed to make it work easily/better?. So for example, lets imagine
that if the language is not statically typed it become harder to implement..

~~~
egi
I wrote my answer.

1- I'm sorry but I don't know materials for the baby steps to implement
pattern matching. However, I think it is not so difficult to compile ordinary
pattern matching expression into many nested if expressions, if you have a
small language you can manage completely.

2- I think difficulty to implement a pattern matching mechanism is not
different for each language. I think writing a parser may be the hardest work.

By the way, I forgot to paste URL for my interpreter I wrote in the past.
[https://github.com/egisatoshi/scheme-meta-
interpreter/blob/m...](https://github.com/egisatoshi/scheme-meta-
interpreter/blob/master/scheme-interpreter.scm) Lisp is easy to write a
parser, and it's because I recommended lisp.

------
stox
Could this finally be a real replacement for Snobol?

~~~
e12e
Egison looks interesting, but I think maybe Ometa is closer to being a Snobol-
replacement than Egison -- at least for now.

On a side note, I came across this:
[https://github.com/daveshields/gospitbol](https://github.com/daveshields/gospitbol)

~~~
egi
Why do you think so? I've created Egison not for text processing, but I think
text processing is important application of pattern matching and I'd like to
do work for that in future.

~~~
e12e
Perhaps Egison might be a useful tool for building a snobol replacement, or
perhaps I personally just don't find the syntax to be quite so amendable to
ad-hoc text processing. I could very well be wrong, though. As I said up-
thread -- it's a very interesting project :-)

------
innguest
Does Egison implement the Pattern Calculus?

[http://en.wikipedia.org/wiki/Pattern_calculus](http://en.wikipedia.org/wiki/Pattern_calculus)

~~~
egi
No. I don't refer to the Pattern Calculus when I've implemented Egison. I've
implemented Egison to realize non-linear pattern matching against unfree data
types such as sets and multisets. The Pattern Calculus seems not for that.

~~~
innguest
Amazing work nonetheless, I'm looking at slide 50 now. Very interesting
concept.

I had to google "unfree data types". This seems to refer to data types that
are unstructured and therefore no one thought of a way to represent in syntax.
For instance we can ask if the first item of a list (a structured data type)
is equal to the last, but we do not have good syntax (nor semantics) to ask
what are the pairs that occur in a collection. That's why we keep having to
translate between those structures in order to do some operations or ask
certain questions.

Very cool stuff.

~~~
egi
I believe Egison has provided good syntax and semantics for that. We have
demonstration pages of various Egison programs that you can edit and run
online. Please check them too. [http://www.egison.org/demonstrations/poker-
hands.html](http://www.egison.org/demonstrations/poker-hands.html)

------
mc_hammer
is it compilable? is there a windowing library? roughly what is the speed
comparable to? the examples look very nice, gj

~~~
egi
Thank you. We are providing only an interpreter now. Egison is not fast and we
don't provide benchmark yet. The development of Egison is currently sponsored
by Rakuten and Rakuten Institute of Technology, but a current active developer
is only me.

~~~
e12e
Is there some way to break computation? I had a look at the tutorial, and went
from: (take 10 nats) via (take 1 (reverse (take 1000 nats))) to doing the same
with 10000000 (or so). ctrl-z and pkill let me go on to to other things, but
it would've been nice if ctrl-c worked as well...?

~~~
egi
If you install egison on your machine, ctrl-c should work on your machine.
However, ctrl-c does not work online egison currently.

~~~
e12e
Hm, you're right -- could be that cpu/swappiness was the issue. If instantiate
less from the lazy sequence, I can indeed break with ctrl-c, so eg: 30000 is
about enough not to eat all resources, and still take enough time that I can
ctrl-c--out (and also does complete without crashing if I let it run a little
while, about a second I think):

    
    
        (take 1 (reverse (take 30000 nats)))
    

Anyone know if this is a known issue with Haskell (I assuming this is a pretty
straight wrap for Haskell lazy lists?) -- that you can get the
compiler/runtime into a tight loop eating so many resources that it isn't
possible to abort cleanly?

~~~
egi
Thank you for letting me to know about this issue. I noticed this problem for
the first time. Our implementation of lazy evaluation is not straight wrap of
Haskell. I'll look into about this.

