Friday, 11 September 2020

Flock Day 7

Its been 3 days since I have done any development. This is to be expected I am no longer on holiday, and my priority list goes in the following top to bottom order, family, work, house, sanity, personal projects.

In reality I have been procrastinating, I have loads of great ideas, but instead of writing it down, I have been making mayonnaise, badly. I roasted some garlic in olive oil last weekend, and a friend has invited me over for some tomahawk steak, so I thought the least I could do is steal some of my partners tomato relish, and make some garlic mayonnaise. I rushed it in the vain wish that I could do some programming, ended up with some vile curdled liquid. My dad who had taught me how to make the stuff aged 6, would be disappointed. If at first you don't succeed, play minecraft instead. Then make a second batch and hope the food processor doesn't wake the family, (see priority one).

However It got me thinking about the relationship of writing code and making mayonnaise; in that there isn't one, unless you like PHP, and even then it doesn't matter how patient you are you, will always end up with a runny curdled mess.

Ok, so maybe I should talk about Flock. To be fair one of the key concepts for flock is around polymorphism, I want separation of structs and traits, you can define a class that has both, but under the hood it is going to get split. That's because I want structs to be about as anemic as is possible. In fact if I had a name struct, that extended String, that would use the same struct as any other tiny type that extended string. The same with traits. 

So why bother? Well from an engineers point of view types are important, they allow me to subdivide what things do and how they look, but the computer/compiler it isn't important. Engineers also tend to have logic that is expressed against the types they use. That might be calling a method existing in a base trait/class and expecting any class that extends that method to have its version called instead. It might even be logic based on what type it is. Don't hold your nose, we have all done it, it is often used in most underlying libraries. I want to support 3 types of class extension, 

  • Inheritance: ClassA : ClassB
  • Prototyping: objectA : objectB
  • Duck-Typing: MethodA<ClassA> : MethodA<>

Notice how I am using the : to express extends. That might actually make it into the language. Thanks c++. Ok the last one probably doesn't make sense, even if you know what duck typing is, but I couldn't just leave it without some form of example.

Every OO object will have 3 distinct components, it will have its data (struct), its functions (traits), and its type. I am hoping to leverage some serious capabilities. So imagine I have a generic/template ClassA<ComponentB T> I could also say that ClassA<ComponentB&ComponentC T> to express a union of types alternatively I could also say ClassA<ComponentB|ComponentC T> to express the acceptance of one or the other, the methods that use this type, would only have access to the common method names or variable names. Hopefully that might give you a clue into why I want my compiler to only have one copy of a particular function or data point to worry about. Why waste time checking types if I don't have too.

I suspect a large part of generating the Abstract Syntax tree, will be around type inference, I have a fear I may have to navigate the whole tree several times just to nail down the exact types available. I have a greater fear that I will use some form of machine intelligence to predict the most optimal tree navigation. That is way too much navel gazing even for me.

No comments:

Post a Comment

Flock Day 8

 It's been a very long time since I last posted, although I have been spending on average 2-3 hours a day cutting code since the last po...