"really fast webserver for kdb and dashboard-making bits (more than 10x nodejs)"
753 karma · joined May 28, 2014
"really fast webserver for kdb and dashboard-making bits (more than 10x nodejs)"
I recently experimented with writing a web application in q while limiting myself to a single screenful of code - the efficiency is amazing! I am still trying to figure out what factors contribute, but it reminds of solving math problems. Write down what you know and stare at it - no distractions.
This version is technically unrestricted, but cannot be used for commercial purposes.
"Kerf is a programming language built on pragmatism, borrowing ideas from many popular tools. The syntax of Kerf will be familiar enough to anyone who has programmed in C, Python or VBA. Data is described using syntax from JSON (JavaScript Object Notation), a text-based data interchange format. Queries to search, sort and aggregate data can be performed using SQL syntax. Kerf’s built-in commands have aliases which allow programmers to use names and terms they are already used to."
"The Commodore 64 version had extra features to support the hardware on that PC. In particular, I added stuff to let you handle sprites, the colour screen, and the sound chip. This extra stuff took about another 4 Kb, so I think the whole G-Pascal took up 16 Kb."
kOS is my hope for a smaller and more efficient future: http://kparc.com/o.htm
I later got into Handyboard+IC, which is even more powerful/hackable.
Excerpt:
20 primitives/verbs, 6 operators/adverbs and 3 system functions.
1 control structure($) - rarely used - and no reserved words.The editor happens to fit in an HTML file <9k (excluding the behemoth browser...:).
Featured live in geocar's presentation: https://www.youtube.com/watch?v=kTrOg19gzP4&list=PLmRrx948XM...
Also: - "Arthur wrote an SQL in 20 lines of K, and a dynamic window manager in around 60 of C...kOS's kernel is under 60 lines of C as well (including annotations; paging, filesystem, syscalls, etc)." (https://news.ycombinator.com/item?id=9002302)
- "k includes language, files, procs, ipc, webserver, dbms, ..z includes graphics...edit.k is 1KB code + k/ztk(9KB)." (http://kparc.com/o.htm)
- "kOS doesn't use the Linux kernel code. It supports a few of the same syscalls: clone, execve(!), epoll_create, epoll_ctl, epoll_wait, dup2, stat, rename, unlink, getcwd, chdir, fstat, getdents, open, close, read, write, ftruncate, mmap2, munmap, ioctl, gettimeofday, socket, bind, connect, listen, acccept, socketpair, setsockopt...execve just runs another k interpreter (regardless of what you tell it to do) though, so it can just be used to run more k programs." (https://news.ycombinator.com/item?id=8744769)
Also interesting to note is that k's grammar is defined in terms of nouns, verbs, and adverbs.
http://www.reddit.com/r/apljk/comments/2y2bic/kxl_experiment...
http://johnearnest.github.io/ok/index.html
Welcome to oK v0.1
(inspired by K5)
\x 1+/1+1 2 3
1 + 1 2 3 --> 2 3 4
1 + 2 --> 3
3 + 3 --> 6
6 + 4 --> 10
1 +/ 2 3 4 --> 10
10As for your comment in #5, I noticed that I can hot load new versions of the server and client without impacting the existing clients' web socket connections. A production change to chat.htm only requires me to \l chat.k; any existing connections still have the older client running without interruption until they refresh, but all new connections get the new client. However, I am not all that concerned about hot loading new versions, as this is only deployed for a small team on the intranet.
And of course the impending kOS operating system: http://kparc.com/ with HN discussion: https://news.ycombinator.com/item?id=8475809
There are also some good links here, though you may have to dig: http://www.reddit.com/r/apljk/
Once you understand the underlying data structure, a lot of k's design decisions make sense. I am using the k.h file from k4 as almost the sole guide to recreating a toy k5 (http://kparc.com/k.txt) interpreter in C.
file:hopen`:index.txt / Open message log append-only
history:("\n"sv read0`:index.txt),"\n" / Load message history from log
.z.po:{neg[.z.w]history} / On join, send full message history
.z.ws:{s:(" "sv(string"du"$.z.Z))," ",x; / On message, add server timestamp
{neg[x]y}\:[key .z.W;s]; / Fan out to other connections
history::(history,s,"\n"); / Update message history in memory
(neg file)s} / Append to message log file
.z.ph:{"\n"sv read0`:chat.htm} / Serve static client appSince you are playing in JS, you might also have a look at c.js (http://kx.com/q/c/c.js), which is the tool KX uses to translate between JS objects and k objects through web socket IPC with a k process (http://code.kx.com/wiki/Cookbook/Websocket). Might be useful to see how Arthur envisioned the k data structure in JS. Also, it would be kind of interesting to have a k5 process running in the browser talking with a k4 process running locally in the 32bit trial...