On Sat, May 19, 2012 at 11:12 PM, Mike Austin
<
mike.aus...@gmail.com> wrote:
> Hey Bob, where do you get your ideas?
Hmm. Good question. I think I've probably scoured every language on
Wikipedia's list of programming languages by now. :)
> Parallel looping, multi-methods, quotations, records & patterns, constructor initializers, indexer setters...
Multi-methods are from CLOS and Dylan of course. Although I mostly
backed into them after wanting to figure out a nice way to do operator
overloading.
Quotations from Lisp, naturally.
Records and patterns from ML by way of F#.
The way constructors work in Magpie is a little strange, where you
pass in a record of all of the fields. At the time, the motivation for
that was:
1. Back when Magpie had a static type checker, I wanted to support
non-nullable types, so I had to ensure all fields were initialized
before you could access an instance. Passing in a record of all them
made that happen.
2. Back when Magpie was single-dispatch, it supported extending
classes with new fields outside of its initial declaration. (I.e. you
could monkey-patch new fields in.) Since you couldn't be sure what
order that would happen in, the constructor couldn't take the fields
positionally. Passing them in as a named record fixed that.
> def (this is Contact) phoneNumber(type is String) = (number is String)
> print("Set " + type + " number to " + number)
> end
>
> How did you come up with this syntax - the ability to pass arguments to a
> setter? I love this stuff.
Thanks!
Indexers are mostly from C#, I think. The syntax for defining them is
a little different but it seemed to make sense for Magpie. If you look
at parseSignature() in MagpieParser.java, you can see a (now that I
look at it, out of date) comment where I tried to work through the
syntax for all of the different kinds of methods you can define. It
took me a long time to figure out something that handled every corner
case (and it's still more verbose than I'd like).
One annoying corner of the def syntax right now is that you can't do
a single-line definition. The newline is needed to tell when the
signature ends and the body starts. I'd like to come up with something
better here but I haven't had any revelations yet.
> I know you've looked at Io, CLOS and Dylan, but what else?
Those are definitely the big ones. The overall block syntax is mostly
Ruby-inspired.
> Also, what do you plan on working on next for the language?
Right now, it's just getting a real implementation. I've been hacking
on the C++ VM and gradually getting it working. It's been a lot of fun
and so far the performance seems to be OK, which is good. I want to
get to a point the VM supports most of the language and I can ditch
the Java prototype completely.
What I'm really looking forward to are:
1. Optimizing and trying to get decent performance. I want Magpie to
be in the same league as Python and Ruby at least. I've got some rough
ideas on how it might be possible to do better than that too but
that's farther down the road and not something I have a lot of
experience in yet.
2. Building out a decent stdlib so you can actually do stuff. File IO,
networking, etc. I really like API design, so that should be fun.
3. Playing with asynchrony/concurrency. I've been doing a lot of
node-style async code at work and it's made it clear how deeply
painful that is, so I want to try something different for Magpie. I
want to see if I can do something fiber/coroutine-based and see how
that goes.
Hopefully, all of those will add together at some point to make Magpie
a language that you could actually write real programs in. :)
- bob