Notes to self (Spindle)

Can’t help myself. Revisting grammer to keep it fresh in mind. Made some decisions:

  1. Definitely go with \foo->foo+2 as syntax for anonymous functions.
  2. \foo works as a standalone object for pattern matching
  3. Space sensitivity between identifier and (, {, and [. Avoids all the nasty problems I was having distinguishing between arguments to a function call and something else:
    • foo(bar) is a direct function call using standard c style syntax, foo (bar) is a function call with a tuple as an argument.
    • foo[1] is a special list method call. foo [1] call foo with a list as argument.
    • foo{bar=baz} is a special object method call. foo {bar=baz} calls foo with an object as argument.
  4. Effect of space sensitivity is that to call a no arg function requires foo(). A huge ramification is that I can interact with a function as an object such as with foo.bind, foo.curry, or foo.call.
  5. Indentation rules after = or ->: Either a single line, or it must start with a newline with indentation based on that.
  6. Field separator in {} is a , to match () and [].
  7. ; is now a statement separator
Advertisements

Greek Letters

I know this will make me sound really ignorant, but can I just say that as someone who isn’t really that into math, but knows it has knowledge I want, the whole greek letter thing really gets to me. I know this is really my problem, and it seems to work pretty well for all the math geeks, but as a programmer who hates one letter variable names, it always bothers me how this is the way math notation is. Same goes for the non-greek letters, really. The greek just makes it that little bit harder because I don’t always remember what the letter is called or which ones are the lower case versions of which other ones.

After a while working in one area you get used to it, and the letters basically always mean the same thing each time you see them. At that point the terseness is kind of nice, but its definitely a barrier to entry!

Set Theory

One of the interesting things I noticed looking over my books is that all of my theoritcal books start with an overview of Set Theory and Induction. I mostly remember sets from taking Discrete Math in college, but I don’t remember needing it too much outside of that class. What can I say, I’ve never really considered myself so much a computer scientist as a software engineer, but I know that’s one of the big things holding me back. In college I wasn’t as interested in that area, but programming languages are pretty firmly in the CS camp, so I need to be comfortable pitching a tent there. It is one of the things holding me back from wanting to take some graduate level courses, I’m not sure I’m ready for them yet.

The theme of my new course based philosophy is that I don’t want to just skim and go as fast as I can. (I also don’t want to do too many side quests, so I’ll have to be careful.) The set theory thing intrigues me. I actually kind of enjoy it, and I know my math skills are a little lacking, so I think it might actually be a good point to diverge a little from the initial plan and take a bit more of a deep dive into it. I found this interesting paper Set Theory for Computer Science, and I think I’ll go into it for bit before continuing on. I expect my next post will either be a sad story of dismal failure or some notes from what I think I learned.

New Idea – Courses For An Autodidact

Spindle Hiatus

So a common theme for me while trying to create a new programming language is that I just don’t know enough. I think it’s important to not just read, but also to do. However, I sometimes think that I try to do everything my own way without really absorbing the wisdom of others.

I have spent a lot of hours on Spindle. Too many of them have been spent struggling over syntax and features, and what I really want the language to be. I think that’s important for language design, because it’s so hard to go back, but in the time I have spent doing that, I could have learned a lot of computer science about how to actually implement my potential language. And speaking in practical terms, that knowledge is likely more important for me to know than to start by making the language.

When I was a teenager, I thought it would be really awesome to learn how to play an instrument. I really had no training. My end goal was to write music. I had no interest in learning how to play something someone else wrote. That really hurt my ability to actually learn how to play. I’m trying to avoid having that happen again.

Instructor and Student

So I had a moment a few days ago when I was thinking about all of my goals and aspirations and how I could do a better job of reaching them. One thing I noticed is that outside of work, I lack structure. I don’t do Spindle on a schedule, and I don’t really set deadlines. I stopped myself and thought how I could steer myself back on track.

What I concluded was that I needed to reverse my logic. Instead of learning as a side effect of doing, why not do as a side effect of learning. In other words, why not learn to play a few songs, and get some music theory under my belt before trying to write my first song (metaphorically speaking of course). I looked around at all of the books I have purchased to help me on my quest and realized that there was a lot of knowledge in there I have yet to extract, but I’d like to.

I don’t really have a place in my schedule for taking real classes, and the fact is that I don’t think I really need to take them, in the sense that I’m pretty good at learning without an instructor. Point me at the right resources, and I’ll figure it out. What I lack is structure. A class would help to provide this, but I’d like to just do it myself. So what I would like to do is effectively think of myself as taking a class where I am both the instructor and student. Create a syllabus, choose the books, do the exercises, etc. As I thought about it, I thought it might be interesting to really try to put myself in the instructor role. Reflect on what I’ve read, and all the things I’m learning and figure out how I would present it if I were and instructor. I really think a great way to learn is by trying to explain to somebody else. I’m not instructing anybody, but I think it would be interesting to put myself in theat mindest.

  • What would the arc of the course be?
  • What would my lecture notes be?
  • What analogies would be useful for instructing someone finding the material hard?
  • How can I use more than one resource in composition to create something greater?
  • What course assignments would be helpful? (And then I should actually do them)

I guess we’ll see how it goes. Oddly enough, I think I’ll be starting with set theory.

Another excuse post

I’ve been up to some important stuff that has had nothing to do with this project. Enough said. To follow: my formal study of programming language theory, design, and implementation.

Blackjack Update

So yeah, about that Antlr grammar… it’s still not here. What a surprise! However, the blackjack example has really been a nice way to find the holes left in my language.  Specifically, it made me face my type system head on. My problem came on something very simple – enumerations of suits and card values. Until now, Spindle has mostly been a structurally typed system. I knew all along that would not be enough, but this simple example really made that obvious. In Java, I think that most of the typing does not actually need to be nominal. That isn’t true across the board, but even if you look at the best practices, to use an interface instead of a class whenever possible really shows how rarely the structure needs to be tied to a nominal type. The new Go language actually goes this route. Interfaces are purely structural.

But then I found myself trying to describe a Spade, Heart, or Ace, and found that what I wanted was precisely a name. On exploring my options, I wanted to avoid doing anything too specific. Adding enums to the language may work for Java, but I’m trying to create a language with powerful reusable building blocks. Then I can use macros to make enums from that for example.

I explored algebraic types and abstract data types as done in ML-like languages. I had studied them before, but had not really considered them for Spindle.  Additionally I read an interesting paper on the difference between objects and abstract data types. It really struck a chord for me. I knew there was a place for nominal types in my language, but I wasn’t sure I wanted to get it in there. I had originally thought that I would do something where prototypes could be used as types and through prototypal inheritance I could do something nominal, but that’s not really what I wanted.  Pushed against a wall, I realized very clearly the harmony between an ADT – a thing with a public name and a hidden representation, and an object – a thing with no name, whose public interface is its defining characteristic.

Now I just have the task of incorporating the essence of algebraic / abstract data types into Spindle. I think that I will start by taking the core building block – the constructor, and getting it to stand on its own. I see a constructor as a locked box which holds its own key. It is the only thing which can unlock (or deconstruct) itself – through pattern matching. And this, I think will be the key to the flexibility of its use in Spindle. I will elaborate further when I have finished my blackjack example with algebraic types.

Blackjack

So considering I’m no longer going the gtk route, I’ve decided to scale down my first real world example to the game of blackjack. It should nicely scale to graphics and networked/distributed play. I’m referencing an example done in scheme. Hopefully it will temper my oop background.