You are not logged in.

#1 2009-06-12 01:26:05

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

punt: An s-expression-based programming/scripting language

I've been mooching around with language design as of late. So far I've written several in Python and a mediocre one in C++ — but there was no challenge in doing so. The only way I could prove my skills to myself was to write a language purely in C.

Which I did.

The language is called punt (all-lowercase), simply because it's a cool name. It consists of an interpreter and a set of modules. Note that while the syntax may vaguely resemble that of Lisp/Scheme, there are few other similarities.

The interpreter

This is a tokenizer/parser and an engine glued together. All non-essential functionality is contained in punt "modules", which are .so's conforming to a specific API — basically your standard C library.

The modules

These are the language's libraries; each one is designed for a specific category of functions. They can be loaded with the interpreter's built-in function use. I'm still in the process of writing them, so punt isn't particularly functional at the moment.

Hello World
(note that these examples are likely to get out of date as I/we rework the language)

# simple way
(use 'io')
(fput (stdout) 'Hello, world!\n')

# slightly more complex way
(use 'io' 'flow')
(.hello_world (func .(last
  (.hwstr 'Hello, world!\n')
  (fput (stdout) hwstr) )))
(hello_world)

punt is a work in progress, but I have high hopes for it. smile

Developers

* Myself
* Ghost1227

Links

Project website
AUR package: being maintained by the awesome Ghost1227
github: where teh source codez be @

Logos

arch-punt_logo_2.png arch-punt_logo.png

Everyone go worship Xyne for being totally awesome.

Last edited by Peasantoid (2009-06-21 16:26:15)

Offline

#2 2009-06-12 01:30:20

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,418
Website

Re: punt: An s-expression-based programming/scripting language

Interesting project... will have to follow your progress.

Offline

#3 2009-06-12 02:27:44

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: punt: An s-expression-based programming/scripting language

Sounds totally awesome! Whatever you do stick to your design of keeping it minimal, that makes it even better smile
You said it doesn't have similarities to lisp other than using s-expressions,  would it be possible to implement lisp like constructs via modules?

Why am I asking you! I can just go look at the code! big_smile

Offline

#4 2009-06-12 02:32:37

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

HashBox wrote:

would it be possible to implement lisp like constructs via modules?

What do you mean by this? (My apologies, my Lisp experience == nil.)

Great to see you're enthusiastic! smile

# Update: starting work on the math module.

Last edited by Peasantoid (2009-06-12 02:44:20)

Offline

#5 2009-06-12 03:18:09

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: punt: An s-expression-based programming/scripting language

Peasantoid wrote:
HashBox wrote:

would it be possible to implement lisp like constructs via modules?

What do you mean by this? (My apologies, my Lisp experience == nil.).

I'm not actually all that sure, my lisp experience is pretty close to nil also, but I just wonder to what extent the modules can modify things really. I suppose if a module can read in an s-expression and spit one back out that would be enough to implement a lisp

Offline

#6 2009-06-12 03:24:02

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

I see... Yes, that is within the capabilities of the module system. Because of C's dynamic typing (praise the gods of computing for void pointers), they can do pretty much anything they want with data.

Offline

#7 2009-06-12 03:26:18

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: punt: An s-expression-based programming/scripting language

Peasantoid wrote:

I see... Yes, that is within the capabilities of the module system. Because of C's dynamic typing (praise the gods of computing for void pointers), they can do pretty much anything they want with data.

Well that's really nice work man, I look forward to playing around with it smile

Offline

#8 2009-06-12 03:30:26

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

HashBox wrote:

Well that's really nice work man

Thanks! big_smile

/me likes praise

N.B. The API might be a little confusing... you should take a look at one of the existing modules for ideas.

Last edited by Peasantoid (2009-06-12 03:31:18)

Offline

#9 2009-06-12 04:12:36

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,418
Website

Re: punt: An s-expression-based programming/scripting language

Offline

#10 2009-06-12 04:18:35

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

Ghost1227 wrote:

Dude, thanks! smile I didn't even think of AUR'ing it.

Offline

#11 2009-06-12 04:22:27

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,418
Website

Re: punt: An s-expression-based programming/scripting language

It's a sweet project, what can I say?

Offline

#12 2009-06-13 00:04:09

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

I've completed the 'math' module. It defines all but the most esoteric functions in the C standard library's math.h.

Interesting thing I discovered: you have to pass '-lm' to GCC in order to get it to link with the math functions. Does anyone know why this isn't in libc?

Offline

#13 2009-06-13 01:42:41

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: punt: An s-expression-based programming/scripting language

Peasantoid wrote:

Interesting thing I discovered: you have to pass '-lm' to GCC in order to get it to link with the math functions. Does anyone know why this isn't in libc?

I've encountered this before, it's one of those things that make you go "huh?". Nice work on getting the math module done smile

As a suggestion, it would be useful to have a module which allows loading and running arbitrary functions from shared libraries, although I'm not too sure where to start with implementing this, I think there is a library around that allows you to do this fairly easily, but I can't seem to find it right now. But as a relatively new scripting language something like this would make it easier to interact to common libraries while other modules are still being written.

Edit: Obviously I was searching for the wrong thing, what I'm talking about is a foreign function interface smile

Last edited by HashBox (2009-06-13 01:43:44)

Offline

#14 2009-06-13 03:49:49

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

HashBox wrote:

As a suggestion, it would be useful to have a module which allows loading and running arbitrary functions from shared libraries, although I'm not too sure where to start with implementing this, I think there is a library around that allows you to do this fairly easily, but I can't seem to find it right now. But as a relatively new scripting language something like this would make it easier to interact to common libraries while other modules are still being written.

Edit: Obviously I was searching for the wrong thing, what I'm talking about is a foreign function interface smile

A foreign function interface would be an interesting thing to implement, but is not currently on the list of priorities — maybe you could try your hand at it? smile My focus is on the bare essentials, such as flow control (which is still incomplete).

Offline

#15 2009-06-13 04:58:42

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: punt: An s-expression-based programming/scripting language

Peasantoid wrote:

A foreign function interface would be an interesting thing to implement, but is not currently on the list of priorities — maybe you could try your hand at it? smile My focus is on the bare essentials, such as flow control (which is still incomplete).

That's fair enough, I would try it but I'm not too sure where to start with the FFI thing. I'll give it another look in about a weeks time (ultra busy with schoolwork at the moment).

Offline

#16 2009-06-13 05:01:08

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

As long as the foreign function to be called doesn't accept any arguments, you could just dlopen() + dlsym() and return the function pointer as a custom type ('ffi_func' would do) that can be executed by a function called, for example, 'ffi_exec'.

But I doubt any particularly useful function is going to have 0 args...

Last edited by Peasantoid (2009-06-13 05:06:05)

Offline

#17 2009-06-13 16:31:48

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

New module: 'cmp'. Functions for comparing values.
Next on the list is 'str'.

Offline

#18 2009-06-14 16:17:32

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

Thanks to Ghost, we now have a website! Currently, it's a subdomain of archuser.com.

Offline

#19 2009-06-14 19:59:53

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: punt: An s-expression-based programming/scripting language

I've added punt to the Arch Linux Programming Language Logos thread.
I modelled the svg on the logo on the site but it was difficult due to its size. I also used a little artistic license so it isn't an exact match. If you have an official svg I'll redo the logos using that. If you don't have an svg image yet, you can use the one that I created as a base: http://xyne.archlinux.ca/img/xyne_misc/punt_logo.svg


with semi-transparency:
arch-punt_logo.png
svg: http://xyne.archlinux.ca/img/logos/arch-punt_logo.svg

without semi-transparency:
arch-punt_logo_2.png
svg: http://xyne.archlinux.ca/img/logos/arch-punt_logo_2.svg

Offline

#20 2009-06-14 20:24:36

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

Whoa Xyne, nice! Did you use Inkscape for that?

Offline

#21 2009-06-14 20:31:07

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: punt: An s-expression-based programming/scripting language

Peasantoid wrote:

Whoa Xyne, nice! Did you use Inkscape for that?

Thanks. Yeah, I've used Inkscape for all the logos in that thread.

Offline

#22 2009-06-14 20:35:37

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,418
Website

Re: punt: An s-expression-based programming/scripting language

Excellent work Xyne, and there's hardly any difference between my original svg and yours, so feel free to leave those as they are.

Offline

#23 2009-06-14 21:57:34

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: punt: An s-expression-based programming/scripting language

Wow, brilliant! Keep up the good work.

Is it a known issue that if the last line of the source file contains code, but does not end with a newline, that line won't be parsed?

Offline

#24 2009-06-14 22:09:17

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

Barrucadu wrote:

Is it a known issue that if the last line of the source file contains code, but does not end with a newline, that line won't be parsed?

Just tested this and it is confirmed. Will get right on it.

Yay, 1st bug report! big_smile

Offline

#25 2009-06-14 22:11:32

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: punt: An s-expression-based programming/scripting language

... and it is fixed. The problem was due to a misplaced piece of code in tokenizer.c:

if(feof(fp)) { break; }

Thanks, Barrucadu!

Offline

Board footer

Powered by FluxBB