Thursday, February 23, 2012

CargoCult, part one

This is a post about my dream language, which I've named CargoCult.  It's a mashup of Perl, Objective-C, JavaScript, Shell, and other things.


It does NOT eschew the use of shifted characters -- it just requires that they be important, with a value greater than the extra effort of typing shift + something.


Object Notation

CargoCult is a dynamic object language.  This means you have type-able structures, potentially dynamic, which have attributes and methods.

Core language features -- arrays, hashes, variables -- are objects.  For example, the implicit array type is an object, so you can do things like this:

    return [d1, d2, d3].sort.reverse.pop; 


Hashes and arrays use the grouping notation of braces. An array is a comma-separated list of scalars.  A hash is a comma-separated list of assignments.

     my array = 1, 2, 3, 'four';  # also [ 1, 2, 3, 'four' ]
     my hash  = [year = 2012, month = two, day = 23];


Hash and array accesses are object calls.

    my value = hash.year;
    my other_value = array.0;


Method Calling with Parameters

When we write methods in any language, we typically name formal parameters.  For example:

string myFunction( foo, bar )
{
   foo + ': ' + bar;
}

foo and bar are formal parameters, i.e. the names used in the method.

When calling a method, parameters are passed in by name.  In other words, the parameters are more or less a hash.

my str = myObj myFunction .foo 'hello' .bar 'world';


When you have to nest the call, use the backslash to indicate a method call (rather than a new array), and then braces for grouping.

           my str = myObj myFunction .foo \[myObj myFunction .foo 'hello' .bar 'world'] .bar '!';






Thursday, October 13, 2011

YSON is a Structured Object Notation

Here's my proposed structure.  I want to keep the quotes to a minimum.

records:
[
    !record record:
    {
      !game &001 game:
      {
        date: 'March 2, 1962',
        versus: New York
      },
      notes: Awesome!,
      number: 100,
      !player &002 player:
      {
        name: Wilt Chamberlain,
        team: Philadelphia
      },
      record: Most points single game
    },
    
    !record record:
    {
        game: *001,
        number: 59,
        player: *002,
        record: 'Most points, one half'
    }
]


object
    hash

hash
    {}
    { pairs }

pairs
    key: value
    key: value, ...

key:
    string
    &id string
    !type string
    !type &id string
    
list
    []
    [ elements ]

elements
    value
    value, elements

value
    key
    string
    number
    object
    hash
    list
    true
    false
    null

Toward a common script grammar

It seems like scripting languages are slowly converging on a small number of common grammars and one structural data representation.


Common Grammars

The two common grammars are (1) simplified C and (2) Smalltalk.

More to the point, the simplification of C includes removing those pesky parentheses in control flow expressions.  I see them dropping everywhere, which I think is probably a good thing.

Anyway, it seems reasonable that most scripting languages' identities are bound by their feature sets and runtime details, rather than their basic grammar, and therefore it's only beneficial that they should converge.  Naturally it won't happen, but it would be nice.  

Alternately, it seems like an ideal scripting language would be able to understand many variants of C grammar, if only because the grammars are so closely related and are, essentially, representing solved problems Solved problems should not have variant grammars.


Common Structure

The structural data rep has little variations, but is essentially curly brackets to hold key-value pairs, a pair operator, and square braces to handle lists.  The data model is more powerful than JSON, and less powerful than YAML, but otherwise looks like them.  Call it JSON with references, or a strict, sane subset of YAML of scalars, lists, hashes, and references.  YSON, perhaps.

Seems that an ideal scripting language would therefore allow the user to specify the pair operator, key decoration, and value decoration.  Should take care of the major players.
 

Monday, October 3, 2011

Deneb sourcebook

...is crawling along, sometimes painfully slowly. But I'm still on schedule, thanks to giving myself lots and lots of time.  I'm currently working on "Fleets" - how duchies and smaller states in the sector squabble with each other by tradewar and skirmishings, and how they do it without provoking an Imperial response.

Wednesday, September 7, 2011

I've got no time to code Perl (or anything else)

I need a less demanding job.

One that pays what I'm getting paid, but lets me work less.

Yeah, right.

Funny, but twenty years ago, before I had a house and a family, I still didn't feel like coding once I got home from work. I suspect the reason for this is that the job sucks all the code out of me during the day, leaving my brain tired and ready for downtime.

I wish it weren't so.

The only solution is to work smarter, both at work and at home. To develop programming tools which will build a foundation upon which I can do what I want. Tools that can be written modularly, a little bit at a time. Bottom-up programming.

Perl, Javascript, and Traveller

For a couple years I've had a suite of Javascript pages for building stuff for Traveller, 5th edition. They use Traveller's new rules for stacking attributes onto a base item, resulting in myriads of armor, weapons, vehicles and smallcraft.

Very recently, I added a backend Perl component which will email the results to you.  So say you define a fast civilian grav truck which can reach orbit on your iPad.  Just enter your email address and it will email the results to you.

I wrote that bit because I wanted to use my scripts from my iPad, and didn't want to rely on cut-and-paste.

A link to the scripts is here: http://eaglestone.pocketempires.com/scripts/armormaker.html

Bioinformatics and Perl

In order to do bioinformatics programming, you have to know a LOT about genetics.  You have to know the terminology and cell, uh, let's call it 'mechanics' for now, until I know what the official Latin-based fourteen-syllable word really is.

You also have to know Perl.

I know Perl.  Maybe I can learn the language of medical science.  Maybe I can help.

Maybe it will help improve the standard of living for people with special needs.

If you had told me back in 1994 that learning Perl might aid research that could help my daughter, I would have laughed. Perl was a fun hobby. It helped me get write scripts that got work done faster so that I could spend more time writing scripts for Traveller. It was not really practical in a larger sense.