Coder Social home page Coder Social logo

vio's Introduction

What is Vio?

"vio is " { "fun" "expressive" "concise" "a work-in-progress" } ++

inspiration: "J Perl6 Factor Processing" <s> split

Vio is an experimental new programming language designed to be fun to use. Its goal is to be quick to try out and to have easy ways to visualize your program, rather than minimal or flexible. In the long run, it's aimed at new programmers, particularly ones learning to program on mobile devices. But for now, it's for hard-core nerds.

At the moment, Vio is very new. This document is as much of a design document as it is actual documentation.

Features:

  • Many useful built-in functions
  • A nifty REPL web application
  • Ability to load/save VM images (snapshots of the virtual machine state)
  • Simple implementation (~2.3k semicolons)
  • Not terribly slow
  • Few dependencies

Issues:

  • Nobody uses it :-(
  • Tricky to compile on Windows
  • Probably buggy
  • Weird
  • Crashes when running the webREPL on Windows

Getting Vio

Dependencies:

  • A more-or-less POSIX-compliant OS, including Cygwin
  • The GNU Multiprecision Library (GMP)
  • OpenBLAS
  • GNU Make
  • A semi-recent GCC or Clang (Vio uses computed goto statements, so it's not strictly C11-compliant)

The rest of Vio's dependencies are bundled with the source (they're mostly portable single C files).

Once GMP and OpenBLAS are installed, clone and build:

git clone https://github.com/alpha123/vio.git
cd vio/src && make

Vio is known to build on FreeBSD and Cygwin64, but should build fine on anything vaguely *nix-y.

Note for building on Windows/Cygwin: you may have to install various x86_64-w64-mingw32 packages (or the 32-bit equivalent) and copy the DLLs from $CYGWIN/usr/x86_64-w64-mingw32/sys-root/mingw/bin to somewhere in your path. Building natively with MinGW may be possible in the future.

What does Vio code look like?

Only the core VM and bytecode compiler are implemented; these examples may or may not work.

-- Entirely tacit, no formal parameters ever
square: dup *
4 square		-- 16

-- Vectors are the central data type
factorial: iota 1 + 1 \*
5 factorial		-- 120

-- Higher-order functions
mean: [0 \+] &len bi /
{ 5 9 4 8 3 } mean		-- 5.8

-- Lots of weird sigils
qsort: [&small-vec? &all-eq? bi or] preserve [&median preserve ~/'[_  cmp] #qsort {} \vcat] unless
-- Or just the built-in sort function, but whatever.

Other stuff:

-- Parse infix calculator input
maybe-op: over dup &one-of dip2 , , |
parens: `(` swap ,`)` ,

expr: <factor> "+-" maybe-op
factor: <term> "*/" maybe-op
term: <int> <expr> parens |
int: d +

math: <expr> parse
"4 + 2 * 2" math		-- .success{ .expr{ .int{"4"} "+"  .factor{ .int{"2"} "*" .int{"2"} } } }

-- Find prime numbers inefficiently but concisely
primes-upto: 1 - iota 2 + $[dup *o] member? not mask
6 primes-upto		-- { 2 3 5 }

On the horizon:

-- Immediate-mode GUI
.xywh{10 10 30 12} "Click me!" button [.xy{50 10} "Clicked" label] when

-- Data visualization and whatever
11 iota 5 - &tanh graph

-- It's meant to be a visual language, sort of like Processing except entirely different.

Data Types

Strings
"spam"

Integers
42

Single-precision floats
Unlike most languages, you don't use floats for decimals most of the time. They are only for writing performant code, since Vio can exploit the processor's vector units.
5.8f

Arbitrary-precision floats
3.22

Tagwords
These are kind of like Ruby's symbols or Erlang's atoms, except they can have values attached (sort of named vectors).

.foo
.bar{20}

You could pattern match on them, if I'd implemented that.

Vectors of all of the above
Row-major by default (todo: reconsider that?)
Can contain any of the above types, and may be heterogeneous. Homogeneous float vectors are optimized to GO FAST.
{7 20 433}

Matrices
idk how these work yet, but eventually you'll be able to do useful vector-matrix and matrix-matrix things
{{ 1 2 3 ; 2 4 6 ; 3 6 9 }}

Quotations
Basically lambdas but without formal parameters.
[ 2 + ]

Parsers
Yeah parsers are their own type of value. It's about as weird as it sounds, but you can do cool stuff.

`foo`
digits: <d> +
float: <digits> ,`.` ,<digits>

vio's People

Contributors

alpha123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vio's Issues

Needs a useful tutorial

Preferably once I either replace the simple webrepl with the web notebook system or once I have the UI stuff. The tutorial should actually do something, not just walk through builtins and implement factorial/quicksort/whatever.

Memory corruption with /+

vio> {1 2 3} {1 2 3} /+
Error: Fatal: unable to allocate memory.
�
empty stack
vio> a
[1]    9085 segmentation fault (core dumped)  ./vio

or, alternatively:

vio> a
Error: Attempted to call undefined word.
Attempted to call 'a', but that word is not defined.

Perhaps it was a typo, and you meant one of the following:
- s
- d
- ,
empty stack
vio> /+
*** Error in `./vio': free(): invalid pointer: 0x00007fa1d9e43b61 ***
======= Backtrace: =========
/usr/lib/libc.so.6(+0x72055)[0x7fa1d9b17055]
/usr/lib/libc.so.6(+0x779a6)[0x7fa1d9b1c9a6]
/usr/lib/libc.so.6(+0x7818e)[0x7fa1d9b1d18e]
./vio[0x4119c3]
./vio[0x411a10]
./vio[0x408532]
./vio[0x40b5b8]
./vio[0x40bed8]
/usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fa1d9ac5610]
./vio[0x404209]
======= Memory map: ========
[snip]

Can't build vio

Attempting to run make outputs

make: *** No rule to make target 'vecapply.c', needed by 'all'. Stop.

That file doesn't seem to exist, however. Removing vecapply.c from the makefile has math.c complain about cblas.h, since under Arch Linux the path to the header file is /usr/include/cblas.h, not /usr/include/blas/cblas.h

Fixing the header include makes stdvio.c error, because it's including vecapply.h, which also doesn't exist. Removing that include gives errors about vio_fold and vio_partition in stdvio.c, but according to grep and GitHub search that's never defined anywhere.

I assume it's just a missing git add for vecapply, but not sure how to fix the blas include without makefile hackery.

Occasional alignment error when allocating VM stack frames

Truth be told I have no real idea what's causing this yet.

Steps to reproduce (in REPL):

vio> undefined_word
...
vio> undefined_word
...
vio> undefined_word
terminated by SIGBUS

Number of times you have to call an undefined word varies from 2-5 so far in my experience.

mtf not included (and unused)

mtf_default_alphabet() is still in there, but mtf.[ch] is missing.
mtf_encode() is not yet even used.
it should be disabled.

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.