Code Monkey home page Code Monkey logo

pounce_v0's Introduction

Pounce v0, a concatenative programming language (inactive since 2020-01, see instead, @pounce-lang)

@pounce-lang for new development of the Pounce programming language

pounce-lang repo has a core language npm package and a few other supporting, learning, documenting and exhibiting projects.

This repo is now an archive of the initial Version 0

Pounce is a programming language that targets the Browser, and limited resource processors such as edge server and IoT. The aim of Pounce is to help everyone explore stack-based, conatenative programming. Since Pounce works in the browser, you can try it out easily (with zero installation). This tutorial will get you coding in minutes. If you end up liking this style of programming, you may want to look at some other Pounce interpreters for Python and C that are in early planning / alpha development.

language origins Pounce has roots in FORTH and Postscript, but other concatenative languages like Joy, Cat and Kitten are much closer relatives that acknowledge a functional paradigm.

Concatenative Programming is...

It's a different approach to programming, that is for sure. Concatenative programming (CP) is all about the composition of functions, by concatenation.

CP uses a magic sauce in the form of post-fix notation to make the composition of functions feel natural, so natural in fact, that there is no syntax needed to compose two functions together. Simply by placing functions, one after another (concatenating them with a space inbetween) you have indicated that these functions are to be composed into a single (new) function. Post-fix notiation has other advantages, such as eliminating the need for "parentheses", more on that later.

CP is famous for the simplicity of its virtual machine archetecture. Pounce keeps this archetecture as simple as possible with only three virtual machine elements. A dictionary of functions (called words), a list of words (the program to be executed) and a stack (of values). These are all that are needed to run a Pounce program. The state of a running program is defined by the stack and the program list. The dictionary usually remains static while executing.

There's a lot more to say about this concatenative style. One thing worth mentioning is that there are no named variables in CP. This lack of variables is a shock to most programmers, but it is the philosophy of CP to "Name the code, not the data." Along with, the slightly derogatory quote, "Variables are 'GOTO' for data!", these mottos differentiate CP from other programming paradigms. Sure CP deals with data, but data is not referenced by named variables *, instead it's stored on a stack. For this reason CP is also known as stack-based programming. All functions take this stack as a single argument and return a modified copy. That consistency across function signatures gives CP programmers less to memorize and eases the mental overhead involved in coding.

(* Pounce also (optional) supports read-only named references to stack items)

Some CP languages (i.e. Joy, Cat, Kitten and Pounce) are 'pure' functional programming (FP) languages, but it comes as a shock to FP aficionados, just how different the CP style of problem solving is from FP. A FP vs. CP comparison goes something like this:

  • FP involves the application of functions to data. That is passing variables in, and gathering data returned by functions. FP makes this natural and effective, which is to say, if you pass in the right parameters to functions to solve a specific problem, then you have made a great FP application.
  • In CP the composition of functions is central. The programmer composes functions to form (essentailly) one function that takes a stack of data as input and returns a stack as output. CP can do this because every function (consistantly) takes and returns a stack, making composition across all functions possible.

This only scratches the surface what CP is, so for more definitions and discussions, you should jump to some of these links: ... {links TBD}

The particular brand of CP that Pounce aims to deliver, has these goals:

  • To be simple and consistent;
  • Support a functional programming approch to problem solving;
  • To provide IDEs and help in learning and debugging;
  • To be portable to the major computing platforms.

Simple and Consistent...

the aim is for Pounce to maintain a minimal core that only contains what is common to all applications (modules in the form of word maps will fill in application specific words). Consistency in post-fix notation is one thing that CP languages had failed to keep, switching over to prefix when defining functions, but Pounce supports a post-fix style consistency (other notations may be included, but post-fix is always the default).

Support FP style problem solving

Core words "map", "filter" and "reduce" process lists, records or the stack as a whole. Additionally any words that you define will be part of the FP eco-system. Once the post-fix notation becomes natural, problem solving starts to flow with out syntactic impediments. Keeping a functioanl simplicity will be a win for progrmers and their developed solutions.

IDEs and help in learning and debugging...

For all dynamic languages, the REPL has survived the test of time and will continue to be alive and well, but IDEs have given programmers more power and productivity. Pounce has a browser based IDE (under development) that will help you interact with and visualize your code. The aim is to keep the edit-run-debug cycle as short as possible. Tests may be built into any word (function) definition so that testes may be run while you code. Offering visualizations of your code and its affect on the stack, is the business of the IDE.

Portable to...

To be portable, Pounce (so far) has JavaScript, Python and Closjure interpreters capable of client and server side application. Also (in development) a "C" interpretor (or Python) for IoT platforms. Future development could include assemblers and compilers, to improve efficiency over interpretation.

Getting started...

First try Pounce in your browser to get a feel for the concatenative style of programming. The examples in the toutorial will help you start off small and then move into making larger applications. https://nmorse.github.io/pounce/js/try_pounce.html -- enjoy

Copyright & License

Copyright © 2018 Nate Morse. Distributed under the MIT License (see LICENSE).

pounce_v0's People

Contributors

nmorse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pounce_v0's Issues

import of dictionaries needs refactor of the runtime

Runtime will need to handle either a wordStack (current) with a object wrapper around word dictionaries --OR-- change to a dictionary of dictionaries format (e.g. {nameSpace:{word1:{}}}).

runtime.js needs to support an IDE that is debugging a running program and wants to know the current imported dictionaries (currently loaded) (i.e. runtime needs to expose wordStack or wordNameSpaces and the findWord function)

Word types and type checking

Word type declarations
parse or link time checking
implied types (duck typing? or fully resolved)

try Malpaux/fbp-types

ask for confirmation before def define or un-def

only run def or define or un-def with a submit button or the Enter key to confirm the request.

OR only run def and define from the ui (not the language input box) for example maybe there should be a whole word dictionary UI that helps you find, use and define your words.

Cursor position (in Input Tag) -- executes Pounce only up to cursor

input tag (type="text") should respond to the placement of the cursor
FYI If possible add this feature in a way that allows a transition to a future change from the input tag to a graphical component that displays and allows edits to Pounce words, painted on a canvas or svg tag.

'C' interpreter

A 'C' or 'C++' Interpreter is needed to support IoT and embedded applications. Possibly use nim to generate C.

UI for words! Visual Recursive Expansion, CRUD

Show the definition of words and facilitate recursive expansion..definition editing and deletion of words (remove from run time -- only for use in modules not part of the the run time execution)) and put in IDE.

Wrap Pounce in JS closure

(self deprecating humor: currently pounce pollutes the global space like a cat w/out a cat box -- seriously dude that smells bad)

enforce 'expects' stack validation

When a word declares that it expects the stack to have a number of items of a certain type and possibly additional validation of the value, it should check the stack (when feature-flagged ON).
If it does not find what it was told to 'expect' it should throw errors (or fall through to a synonym word).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.