Show HN: Tack, a fast lightweight scripting language for games and embedding https://ift.tt/AhKHu8B Hi HN! Tack is a scripting language I've been working on sporadically for the past year or so, and intensely for the past few weeks. It originated out of a desire for something that was like Lua, but with a more familiar syntax, and without some of the other surprises in Lua such as the 1-indexed tables. It's also been a great learning project, and a very satisfying challenge! While the current version is early beta at best, I hope to continue working on it and maybe see some adoption. Despite the relative lack of optimization, I'm very pleased with the performance so far - although I haven't done a huge amount of benchmarking, it seems to be significantly faster than the stock Lua 5.4 interpreter for the quicksort test, and the btrees test (copied from the Computer Language Benchmarks Game). The language is designed for embedding in C++ programs, and is written in C++ more or less from scratch including the handwritten recursive descent parser, and a register-based compiler/interpreter. The only dependency other than the standard library is my C++ adaptation of the khash library used for the object type - a from-scratch hashmap seemed not worth the trouble. Quick code example - more examples in the repo! fn quicksort(arr) { const n = #arr if n <= 1 { return arr } " find the midpoint " let l = min(arr) let r = max(arr) if r == l { return arr } const mid = (l + r) / 2 " split array into upper and lower " const upper = filter(arr, fn(x) { return x < mid }) const lower = filter(arr, fn(x) { return x >= mid }) " recursively sort the upper and lower sub-arrays and join the result" return quicksort(lower) + quicksort(upper) } let A = [] for i in 0, 1000000 { A << random() } let before = clock() let B = quicksort(A) let after = clock() print("Time taken: ", after - before, "seconds") Building requires just cmake and a C++20 compiler - tested with MSVC 2022, g++11 on WSL and Clang 15 on M1 https://craftinginterpreters.com was a great help with implementing closures, as I had gone down a blind alley with my first approach for locating the closed-over variables. However I have taken a slightly different approach towards boxing. As I do intend to use this for some small games myself going forward, there is a standard library already, and plans to expand it. I also intend to release a GLFW-based mini game framework along with precompiled binaries, so hobbyists (and younger relatives!) may use it without needing a full compiler toolchain. I would love if anyone is interested enough to try it out! James https://github.com/PlumeCat/tack May 14, 2023 at 11:09PM
Show HN: Tack, a fast lightweight scripting language for games and embedding https://ift.tt/SJv5Ict
Related Articles
Show HN: Dotenv, if it is a Unix utility https://ift.tt/FA1DUcwShow HN: Dotenv, if it is a Unix utility I like the idea of using dote… Read More
Show HN: Attorch – PyTorch's nn module written in Python using OpenAI's Triton https://ift.tt/jxJBVfOShow HN: Attorch – PyTorch's nn module written in Python using OpenAI'… Read More
Show HN: Bard PDF – Chat with Pdf in Google Bard or Gemini https://ift.tt/XFsYH6SShow HN: Bard PDF – Chat with Pdf in Google Bard or Gemini Chat with p… Read More
Show HN: Define and implement any function on the fly with LLMs https://ift.tt/WrAiRVYShow HN: Define and implement any function on the fly with LLMs It's n… Read More
Show HN: Kaytu – Optimizing cloud costs using actual usage data https://ift.tt/Xsj7TCWShow HN: Kaytu – Optimizing cloud costs using actual usage data Reduce… Read More
Show HN: Htpy – generate HTML from Python without templates https://ift.tt/ZwzKEO3Show HN: Htpy – generate HTML from Python without templates I built a … Read More
Show HN: Scenestamps – A website for sharing movie scenes with timestamps https://ift.tt/AyM8j73Show HN: Scenestamps – A website for sharing movie scenes with timesta… Read More
Show HN: OpenLIT – Open-Source LLM Observability with OpenTelemetry https://ift.tt/akjv4NgShow HN: OpenLIT – Open-Source LLM Observability with OpenTelemetry He… Read More
0 Comments: