4 ms·
> However, afaict languages following APL's suit specialize in math, so I wonder if the approach could be adapted to more general kind of coding. I use k/q reg
by geocar 8y ago
> However, afaict languages following APL's suit specialize in math, so I wonder if the approach could be adapted to more general kind of coding.
I use k/q regularly, and I'm not using it for "math".
The compact notation creates value in helping you make correct programs. See [1] and [2] specifically.
[1]: https://news.ycombinator.com/item?id=8476294 https://news.ycombinator.com/item?id=8476294
[2]: https://news.ycombinator.com/item?id=8476702 https://news.ycombinator.com/item?id=8476702
You can write C in a dense style as well. And I do. When I do this, I can see opportunities for reuse that I cannot see if I spread my C program across multiple pages and multiple files. Here is the bulk of my webserver[3] that will beat the pants off of any other webserver -- substantially faster than nodejs or kdb's own webserver[4], and probably nginx or anything else you've got. (PS: If you think you know of a faster one, I'd like to know about it).
I am telling you I can only do this because the code is small.
[3]: https://github.com/geocar/dash/blob/master/d.c#L63 https://github.com/geocar/dash/blob/master/d.c#L63
[4]: https://github.com/geocar/dash#performance https://github.com/geocar/dash#performance
- aasasd 8y agoNode.js is not the thing to compare C web servers performance to. Like, it's so much not the thing, it goes beyond funny and wraps around to sad. Let me refer you to the TechEmpower framework benchmarks: https://www.techempower.com/benchmarks/#section=data-r17&hw=ph&test=plaintext https://www.techempower.com/benchmarks/#section=data-r17&hw=... Look at the language column there, you'll be surprised.
- geocar 8y agoHere's fasthttp running on my machine (best of three): $ wrk -t2 -c90 -d9s http://localhost:8080/plaintext Running 9s test @ http://localhost:8080/plaintext 2 threads and 90 connections Thread Stats Avg Stdev Max +/- Stdev Latency 831.78us 364.48us 7.56ms 70.19% Req/Sec 40.55k 3.31k 48.04k 74.44% 726417 requests in 9.01s, 87.98MB read Requests/sec: 80603.64 Transfer/sec: 9.76MB which I got by checking out https://github.com/TechEmpower/FrameworkBenchmarks.git https://github.com/TechEmpower/FrameworkBenchmarks.git, disabling the mysql connection, and running frameworks/Go/fasthttp's ./server-mysql (which is what the benchmark script seems to do). I thought this would be easier than getting dash running the TechEmpower results. and here's dash running with the kdb networking disabled (best of three): $ wrk -t2 -c90 -d3s 'http://127.0.0.1:8080/?f=204&k=hi&v=1' Running 3s test @ http://127.0.0.1:8080/?f=204&k=hi&v=1 2 threads and 90 connections Thread Stats Avg Stdev Max +/- Stdev Latency 787.72us 213.62us 3.49ms 71.85% Req/Sec 44.82k 3.04k 60.44k 83.61% 271946 requests in 3.10s, 16.08MB read Requests/sec: 87671.23 Transfer/sec: 5.18MB My laptop isn't a beefy "Dell R440 Xeon Gold + 10 GbE" -- this is just a loopback test, but it's already disinclined me to spend any more time on it; Fasthttp definitely is impressive how close it gets, but dash is still faster. And comparing a 100 line C program to hundreds or thousands of lines of go or C or Java is a bit pointless. If the 100 lines of C doesn't do what you want, I'll throw it away and write a different 100 lines. That's what brief programs get you. NB: I would have tried ulib but it wouldn't even build on my laptop.
- mycall 8y agoIf you rewrote [3] to use cleaner variable naming, perhaps the readability would improve?