kgabis / ape Goto Github PK
View Code? Open in Web Editor NEWApe Programming Language
Ape Programming Language
I was trying to get this to run on both Windows and Linux, and in Visual Studio I was getting a compile error on the enum error_type
where there was a collision on ERROR_TIMEOUT
with something in Windows.h
. Just to test I changed all copies of that to be ERROR_TIME_OUT
and it ran compiled/ran perfectly after.
I've looked at a lot of C based scripting languages over the last few weeks and I really like how well put together this is and how easily it's called via an interop scenario with C.
Since you asked someone else I thought I'd share, for fun, I work on MUDs (multi user dimensions, text based D&D type games online, were very popular in the 90's, the one I play still has hundreds of players). One of the most popular code bases are "Diku Muds" which have spawned thousands of forks/games. Most DikuMuds or their decedents have a VERY bare bones scripting language called mud progs or mob progs to allow the NPCs to crudely interact with players (they have basic control flow and access to some in game features, but no variable storage, etc.). Some muds have swapped that out for Lua (which is a big task and one so big that most people who do it don't share it which is a shame.. Lua is great but it also requires an insane amount of glue code and a lot of diligent managing the interop / using the stack correctly).
I was considering trying to swap this in either side by side or in replacement of mob progs in one of the open source code bases (probably ROM 2.4 but it's the one I know the best and plays the most like I expect a mud to play out of the box: https://github.com/avinson/rom24-quickmud). If I can do it successfully, I'll let you know.
İmpressive! But I'm asking myself the question, why should I use this language.
Currently, I get a crash at
because I sometimes may passNULL
to the string parameter, and strlen
crashes on NULL
input on Ubuntu 16.04, should this part of code maybe do a check
object_t object_make_string(gcmem_t *mem, const char *string) {
if (string == NULL) {
return object_make_null();
}
int len = (int)strlen(string);
to handle non-expected NULL
gracefully without crashing? :)
Thanks! Ape is great, I'm having a blast with it!
Just a heads up, but there is another programming language named Ape.
Hi,
I'm considering prefixing builtins with std:
: prefix, so instead of len
and array
one would write std::len
and std::array
. Why? Because there's a lot of keywords used up by builtins so it's quite easy to get a name collision for popular names (len, array, values, etc.). At the same time I want to add using
(similar to c++ using namespace
) to make converting existing code easier. Alternatively I might prefix functions with context dependent prefix, for instance values
would become map::values
, sqrt
becoming math::sqrt
. Since it's quite intrusive I wanted to ask users for opinion.
Hello,
It would be great if the API for memory handling functions allowed for a user supplied argument -- which is useful for allocators that are not global.
typedef void* (*ape_malloc_fn)(size_t size, void* mallocArg);
typedef void (*ape_free_fn)(void *ptr, void* freeArg);
void ape_set_memory_functions(void* mallocArg, ape_malloc_fn malloc_fn, void* freeArg, ape_free_fn free_fn);
// user land code:
struct Allocator {
...
}
struct Program {
struct Allocator* alloc;
} * program;
void* myMalloc(size_t size, void* arg) {
struct Allocator* allocator = (struct Allocator*) arg; // allows to specify an allocator without being a global
...
}
...
ape_set_memory_functions(program.alloc, &myAlloc, program.alloc, &myFree);
This language is called Ape and the language extension is .bn
. What does .bn
means? Could you just make it .ape
so it will be make sense?
Hello,
I think there might be some bugs with concat_fn
:
// I think should be: res_buf[len + arg_str_len] = '\0'; otherwise you are hitting invalid memory
res_buf[len + arg_str_len + 1] = '\0';
Also in object_make_string_no_copy
, there is an attempt to use memory after free:
if ((len + 1) < OBJECT_STRING_BUF_SIZE) {
memcpy(obj->string.value_buf, string, len + 1);
ape_free(string); // <--- free'ng the memory here
obj->string.is_allocated = false;
} else {
obj->string.value_allocated = string;
obj->string.is_allocated = true;
}
obj->string.hash = object_hash_string(string); <-- Using it here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.