• Stars
    star
    127
  • Rank 281,529 (Top 6 %)
  • Language
    JavaScript
  • License
    BSD 2-Clause "Sim...
  • Created about 13 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A readable, DSL friendly programming language with excellent concurrency primitives

Whaa?

Pogoscript is a programming language that emphasises readability, is friendly to domain specific languages and compiles to regular Javascript.

travis-ci

NPM version

NPM dependencies

Installation

Pogoscript requires node.js and npm.

npm install -g pogo

Or to install local to your project:

npm install pogo

Usage

Interactive Prompt

pogo

Executing a Script

pogo helloWorld.pogo

Debugging a Script

All the regular node debugging invocations work:

To invoke the node debugger:

pogo debug helloWorld.pogo

To allow remote debugging, e.g. with node-inspector:

pogo --debug helloWorld.pogo

If you want to break on the first line:

pogo --debug-brk helloWorld.pogo

You can also put breakpoints in your source code, just put debugger on its own line:

someFunction ()
debugger
someOtherFunction ()

Compiling a Script

pogo -c helloWorld.pogo

Will produce helloWorld.js.

Watching and Compiling

pogo -cw helloWorld.pogo

Examples!

The canonical Node.js hello world:

http = require 'http'

http.createServer @(req, res)
    res.writeHead 200 ('Content-Type': 'text/plain')
    res.end "Hello World\n"
.listen 1337 "127.0.0.1"

console.log 'Server running at http://127.0.0.1:1337/'

The canonical 99 beers on the wall:

sing (n) bottlesOfBeerOnTheWall =
    if (n > 0)
        console.log ((n) bottlesOfBeerOnTheWall)
        sing (n - 1) bottlesOfBeerOnTheWall

(n) bottlesOfBeerOnTheWall =
    "#((n) bottles) of beer on the wall, #((n) bottles) of beer.\n" +
    "Take one down, pass it around, #((n - 1) bottles) of beer on the wall."

(n) bottles =
    if (n == 0)
        "no bottles"
    else if (n == 1)
        "1 bottle"
    else
        "#(n) bottles"

sing 99 bottlesOfBeerOnTheWall

The Big Features

Arguments and Parameters

Arguments and parameters can be placed anywhere in the name of a function or method call. The careful placement of an argument or a parameter can give it a lot of meaning.

mountains = ['Everest', 'La Tournette', 'Valuga']

for each @(mountain) in (mountains)
    console.log (mountain)

Blocks

Blocks are just indented code:

after (duration, doSomething) =
    setTimeout (doSomething, duration)

(n) seconds =
    n * 1000

after (10 seconds)
    console.log "hi there!"

Self

The self variable, also known as this in JavaScript, is retained from a block's outer context:

jack = {
    name = "Jack"
    
    sayHello () =
        console.log "hi, my name is #(self.name)"
        
        after (10 seconds)
            console.log "hi! this is #(self.name) again."
}

jack.sayHello ()

But if you want and expect self to be redefined to something useful, put => before the block like so:

onEachHttpRequest (action, port: 3000) =
    server = http.createServer @(request, response)
        requestContext = {
            request = request
            response = response
        }
        
        action.call (requestContext)
        
    server.listen (port)

onEachHttpRequest =>
    self.response.end "Hello World\n"

Optional Arguments

Methods and functions can take optional arguments, in the form of a hash passed as the last argument.

webServer (port: 4567) =
    console.log "starting web server on port #(port)"

webServer ()

webServer (port: 3000)

No Built-in Keywords

There are no keywords in PogoScript. All control structures use the same syntax rules as regular functions and methods, so it's very easy to write your own control structures:

unless (condition, block) =
    if (!condition)
        block ()

unless (windSpeed > 25)
    console.log "going surfing"

What about a multi-line control structure?

renderEachIn (list, render) ifNone (none) =
    if (list.length > 0)
        content = ''

        for each @(item) in (items)
            content := content + render (item)

        content
    else
        none ()

mountains = ['Everest', 'La Tournette', 'Valuga']

renderEach @(mountain) in (mountains)
    "<li>#(mountain)</li>"
ifNone
    "<li>no mountains...</li>"

More

joshski has put together a page showing how PogoScript translates into JavaScript. You can examine the cheatsheet, or head to the home page page.

More Repositories

1

coypu

Intuitive, robust browser automation for .Net
C#
562
star
2

hyperdom

A fast, feature rich and simple framework for building dynamic browser applications.
TypeScript
162
star
3

sworm

a write-only ORM for Node.js
JavaScript
146
star
4

promise-limit

limits calls to functions that return promises
JavaScript
140
star
5

interfaceable

Strict interfaces in Ruby
Ruby
92
star
6

browser-monkey

Reliable DOM testing
JavaScript
53
star
7

css-to-xpath

Convert CSS selectors to XPaths, in JavaScript
PogoScript
41
star
8

vdom-query

Traverses and manipulates virtual-dom trees
JavaScript
26
star
9

httpism

Resource-oriented HTTP client for node.js and browsers
JavaScript
25
star
10

xpath-builder

JavaScript DSL for building complex XPath expressions
PogoScript
25
star
11

lowscore

a very small underscore, for browser apps that like to watch their weight
JavaScript
24
star
12

node-ebnf-diagram

Generate png diagrams from Extended Backus–Naur Form (EBNF) grammars
JavaScript
20
star
13

jquery-sendkeys

JavaScript
20
star
14

strictly_fake

Stub that automatically verifies that stubbed methods exist and the signatures match the original.
Ruby
19
star
15

full-stack-js-testing-demo

javascript web app full stack browser testing demo
JavaScript
18
star
16

SelfishHttp

self hosting HTTP server for testing in .net
C#
18
star
17

codesandbox-example-links

Generates "run this example" links for your readme.md
JavaScript
15
star
18

html2js-browserify

for turning crummy HTML into beautiful Javascript, with browserify
JavaScript
15
star
19

coypu-jvm

Intuitive, robust browser automation
Java
12
star
20

karma-server-side

Run server-side code from karma tests
JavaScript
12
star
21

dslify

JavaScript function rewriter, for little DSLs
PogoScript
10
star
22

snowdock

a docker deployment utility, with special support for hot-swapping updates to websites
PogoScript
10
star
23

spawn-cmd

node.js module to run windows and unix processes the same way
PogoScript
8
star
24

Everest

Resource-oriented HTTP client for .net
C#
8
star
25

browser-pdf-support

detect PDF support in the browser
JavaScript
7
star
26

hyperdom-router

model driven router for hyperdom
JavaScript
7
star
27

fixture_farm

Why writing fixtures when they can write themselves?
Ruby
6
star
28

fs-tree

Directory hierarchy builder utility for node.js
PogoScript
5
star
29

trytryagain

Keep retrying until it works. Actually a very reliable testing strategy.
PogoScript
5
star
30

vinehill

In process bridge between http requests and connect based servers
JavaScript
5
star
31

banana-shark

A strictly synchronous test runner for JavaScript
JavaScript
4
star
32

browserify-server

browserifying JS server, with support for multiple bundles
JavaScript
4
star
33

bo-selector

JavaScript CSS selector parser
JavaScript
4
star
34

shellsubstitute

JavaScript
4
star
35

cooperative

Cooperative threading versions of map, filter, forEach, etc, suitable for big processing in single-threaded Node.js.
JavaScript
4
star
36

oracle-client-buildpack

Shell
4
star
37

hyperdom-modal

Accessible modal built with Hyperdom that uses <dialog> element
JavaScript
3
star
38

rack-stubs

Rack middleware for stubbing responses from HTTP web services
Ruby
3
star
39

routism

Minimal, fast javascript URL router
PogoScript
3
star
40

create-hyperdom-app

Hyperdom starter kit
JavaScript
3
star
41

qo

finally, a task runner for insect people
PogoScript
3
star
42

pogo-examples

Side-by-side examples of pogoscript to javascript compilation
JavaScript
3
star
43

fireworks

PogoScript
3
star
44

htmlism

Pogoscript template engine
PogoScript
3
star
45

flynn-pr-apps

Review apps on flynn
JavaScript
3
star
46

crc-pad

A browser-based, iPad-friendly CRC card editor
JavaScript
3
star
47

vim-pogoscript

PogoScript support for Vim
Vim Script
3
star
48

cappie

Instant capybara/cucumber/selenium configuration for non-ruby web apps
Ruby
3
star
49

hyperdom-ace-editor

A hyperdom component that embeds the ace editor
JavaScript
3
star
50

stitchy

Command-line wrapper for stitch
PogoScript
3
star
51

rest-browser

An HTML client for REST APIs, designed to be embedded into the API itself
JavaScript
2
star
52

language

DSLs for the washed masses
JavaScript
2
star
53

build-status

A single BIG page showing users of Team City if they're an idiot or not.
PogoScript
2
star
54

mock-xhr-router

JavaScript
2
star
55

invertism

A dependency inversion utility for JavaScript
PogoScript
2
star
56

pogo-react

React.js components in PogoScript instead of JSX
PogoScript
2
star
57

hyperdom-semantic-ui

semantic-ui components for hyperdom
JavaScript
2
star
58

hyperdom-medium-editor

medium-editor for hyperdom
JavaScript
1
star
59

cloqwork

An experiment in programming experience
JavaScript
1
star
60

hyperdom-sortable

sortable lists for hyperdom
JavaScript
1
star
61

blocker

An HTTP proxy that blocks unwanted requests
Ruby
1
star
62

node-anticipate

retries asynchronous functions until they succeed
JavaScript
1
star
63

ringleader

Experimental distributed job queue using node.js and websockets
PogoScript
1
star
64

unset-timeout

resets any setTimeout or setInterval between mocha tests
JavaScript
1
star
65

hobostyle

Dynamic CSS for your web page!!!
JavaScript
1
star
66

node-featurist

CLI to create a new project with the Featurist stack
JavaScript
1
star
67

Bounce.MsDeploy

msdeploy tasks for bounce
C#
1
star
68

hyperdom-interactjs

multi-touch gestures for hyperdom using interact.js
JavaScript
1
star
69

generate-docker-certs

Generate client and server certificates just like `docker-machine regenerate-certs`
Go
1
star
70

waitforsocket

wait for a socket to open
PogoScript
1
star
71

GotFood

πŸ• Gets food to hungry people
Ruby
1
star
72

dateism

JavaScript
1
star
73

tweetsonos

Ruby
1
star
74

wiblr

Cloud HTTP Debugging Proxy
JavaScript
1
star
75

html-pdf-server

URL -> PDF
JavaScript
1
star
76

thursby

PogoScript
1
star
77

fs

for .net, some simple filesystem operations: copy, move, delete and create.
C#
1
star
78

hyperdom-draggabilly

A hyperdom component that makes elements draggable
HTML
1
star
79

sworm-schema

JavaScript
1
star
80

hyperdom-loader

A magic asynchronous loader thingy for hyperdom
JavaScript
1
star
81

PogoScript.tmbundle

PogoScript support for TextMate
1
star
82

somepx

converse in px
JavaScript
1
star
83

modelism

A schema language for validating JavaScript objects
JavaScript
1
star
84

plastiq-throttle

JavaScript
1
star
85

angry-unicorn

Fix up the Github UI when they do something silly
JavaScript
1
star
86

extract-dates

Finds dates in strings
PogoScript
1
star
87

featurist-hubot

A robot
CoffeeScript
1
star
88

mocha-test-name

sets the current mocha test name to a global variable (because global variables are awesome)
JavaScript
1
star
89

nodeapp

just a simple node app that can be Dockerized
Shell
1
star
90

squashy

Packs HTML, inlining javascripts and stylesheets
JavaScript
1
star
91

procession

Starts a long-running process and blocks until it's ready to roll
Ruby
1
star
92

hyperdom-ckeditor

JavaScript
1
star
93

promise-builder

Builds up promises step by step
JavaScript
1
star
94

hyperdom-zeroclipboard

zeroclipboard for hyperdom
JavaScript
1
star
95

meddler

A programmable http proxy for node
PogoScript
1
star
96

cucumber-parallel

Runs cucumber scenarios in parallel
Ruby
1
star
97

cocos-pogo-template

A template for building cocos2d-js games in PogoScript
PogoScript
1
star
98

babel-preset-hyperdom

JavaScript
1
star
99

WebApi.ControllerTemplates

Templates for WebApi controllers
C#
1
star
100

finished-promise

Synchronous implementation of Promise for use in tests
JavaScript
1
star