TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

K – A simple, fast vector programming language

122 点作者 snicker7大约 3 年前

14 条评论

mlochbaum大约 3 年前
Since other array languages are being brought up already, here are two things K does that you won&#x27;t find anywhere else in the APL family as far as I know:<p>- Dicts (same as hashmaps, associative arrays, etc.) are a native datatype, with `ab`cd!0 1 indicating a dict mapping symbols `ab and `cd to 0 and 1, for example. In K4 and later (ngn&#x2F;k implements K6), array primitives work on them to do all sorts of fancy things. For example prefix &amp;, &quot;where&quot;, returns the indices of any 1s in an array. If given a dict, it gives you the keys corresponding to 1s.<p>- Partial application. If you have a function f of two arguments, f[;x] binds the second argument x to f, but leaves the first one unbound. So f[;x][y] is f[x;y]. But that&#x27;s not nearly all: arrays, dicts, and functions are unified, so if fs is a list of one-argument functions, then fs[;x] applies each function to x. This is because fs[;x][i] is fs[i;x] or fs[i][x]!<p>ngn&#x2F;k is the best implementation to use now in my opinion. It&#x27;s short on documentation, but the K Wiki is a new and very nice resource for K. Maybe start with the list of all primitives at <a href="https:&#x2F;&#x2F;k.miraheze.org&#x2F;wiki&#x2F;Primitives" rel="nofollow">https:&#x2F;&#x2F;k.miraheze.org&#x2F;wiki&#x2F;Primitives</a> .
评论 #31367212 未加载
评论 #31365253 未加载
评论 #31363857 未加载
jiggawatts大约 3 年前
<a href="https:&#x2F;&#x2F;codeberg.org&#x2F;ngn&#x2F;k&#x2F;src&#x2F;branch&#x2F;master&#x2F;v.c" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;ngn&#x2F;k&#x2F;src&#x2F;branch&#x2F;master&#x2F;v.c</a><p>Where does this madness come from, and why does it infect proponents of array-based languages to the point where they start writing C code in this style!?
评论 #31362894 未加载
评论 #31362581 未加载
评论 #31363400 未加载
评论 #31367061 未加载
评论 #31365443 未加载
评论 #31364073 未加载
评论 #31362975 未加载
评论 #31362540 未加载
andreypopp大约 3 年前
It&#x27;s very cool to see ngn&#x2F;k on the HN front page.<p>After the recent AoC which I&#x27;ve attempted to solve with BQN[1] (another array language) I&#x27;ve got interested in array languages and now exploring K too.<p>K seems like a nice blend between an array language and a lisp: list is a primary data structure in K, no multidimensional data. K is good at symbolic workloads as well — visit <a href="http:&#x2F;&#x2F;nsl.com" rel="nofollow">http:&#x2F;&#x2F;nsl.com</a> for some examples.<p>Also, make sure to check out the C code style ngn&#x2F;k is written with :-) another K implementation Kona (uses similar C code style) has a wiki page with explanation[2].<p>[1]: <a href="https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;mlochbaum.github.io&#x2F;BQN&#x2F;index.html</a> [2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;kevinlawler&#x2F;kona&#x2F;wiki&#x2F;Coding-Guidelines" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kevinlawler&#x2F;kona&#x2F;wiki&#x2F;Coding-Guidelines</a>
评论 #31361959 未加载
chrispsn大约 3 年前
In case you&#x27;ve jumped straight to the comments, here are some intro links. Many of these also appear in ngn&#x2F;k&#x27;s readme.<p>First, direct links to ngn&#x2F;k in the browser:<p>- REPL: <a href="https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#r" rel="nofollow">https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#r</a><p>- Editor: <a href="https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;</a><p>Second, the best one-stop shop for an overview of k6&#x27;s primitives (both ngn&#x2F;k and oK are based on k6). <a href="https:&#x2F;&#x2F;github.com&#x2F;JohnEarnest&#x2F;ok&#x2F;blob&#x2F;gh-pages&#x2F;docs&#x2F;Manual.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;JohnEarnest&#x2F;ok&#x2F;blob&#x2F;gh-pages&#x2F;docs&#x2F;Manual....</a><p>The best intro examples are in John Earnest&#x27;s k editor iKe - there&#x27;s a dropdown at the bottom right. <a href="http:&#x2F;&#x2F;johnearnest.github.io&#x2F;ok&#x2F;ike&#x2F;ike.html" rel="nofollow">http:&#x2F;&#x2F;johnearnest.github.io&#x2F;ok&#x2F;ike&#x2F;ike.html</a><p>ngn&#x2F;k&#x27;s editor also has an &#x27;examples&#x27; dropdown in its menu.<p>For an illustration of k&#x27;s strengths, Razetime&#x27;s matmul refactoring is brilliant: <a href="https:&#x2F;&#x2F;github.com&#x2F;razetime&#x2F;ngn-k-tutorial&#x2F;blob&#x2F;main&#x2F;c-thinking-in-k.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;razetime&#x2F;ngn-k-tutorial&#x2F;blob&#x2F;main&#x2F;c-think...</a><p>Finally, some nice examples of concise k:<p><pre><code> {$[2&gt;#?x;x;,&#x2F;o&#x27;x@&amp;&#x27;~:\x&lt;*1?x]} &#x2F; Quicksort (+&#x27;:,)\~!10 &#x2F; Pascal&#x27;s triangle {x x}{x{x[x]y}y} &#x2F; Y-combinator </code></pre> Executable versions of above:<p>- Quicksort (via Kelas&#x27;s KCC guide): <a href="https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJwrLLaqVok2slO2r7CusNbRz1evcFBTr7OKqbDRMrSviK3l4iosVspIzcnJVyjPL8pJUQIAgGcPkw==" rel="nofollow">https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJwrLLaqVok2slO2r7CusNbRz1evcFBT...</a><p>- Pascal (via Richie&#x2F;Attila): <a href="https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJzT0Fa30tGMqVM0NAAADYMCZg==" rel="nofollow">https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJzT0Fa30tGMqVM0NAAADYMCZg==</a><p>- Y-combinator (via ngn): <a href="https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJyLtKquUKiora6oroiuiK2srax14IqMro5Os66IVVCJrrCu0EpTqNA1tDaMrY015eLS0jfUVjQFABmvES8=" rel="nofollow">https:&#x2F;&#x2F;ngn.bitbucket.io&#x2F;k&#x2F;#eJyLtKquUKiora6oroiuiK2srax14IqM...</a>
skruger大约 3 年前
If anyone is looking for some additional docs for ngn&#x2F;k, I’ve written<p><a href="https:&#x2F;&#x2F;xpqz.github.io&#x2F;kbook" rel="nofollow">https:&#x2F;&#x2F;xpqz.github.io&#x2F;kbook</a>
technion大约 3 年前
These style of languages often come up here. Could a proponent give some examples of practical applications written in these array languages? I feel like that&#x27;s missing in these discussions. People say &quot;finance&quot;, but let&#x27;s say I have a finance team that have never heard of it - why might they be interested?
评论 #31364262 未加载
评论 #31365166 未加载
评论 #31363213 未加载
评论 #31363133 未加载
评论 #31368299 未加载
评论 #31368328 未加载
jhbadger大约 3 年前
What makes this implementation different from kona? <a href="https:&#x2F;&#x2F;github.com&#x2F;kevinlawler&#x2F;kona" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kevinlawler&#x2F;kona</a>
评论 #31364463 未加载
ur-whale大约 3 年前
This particular way of coding to me exemplifies one very important problem with people who work in technical professions: their utter inability to &quot;read the room&quot;.<p>In this specific instance, I suspect the folks who enjoy writing (and assuming they actually can - reading) code like this, completely assume that everyone has a brain with the same kind of weird quirks theirs has, namely the ability to recall almost instantly infernally long minutiae of details and thereby decipher what most people perceive as pure noise.<p>Or, more generally speaking, they assume that their potential audience essentially are as smart as they are.<p>News at 11: this is almost <i>never</i> the case.<p>And in the case of: this type of language, APL, LISP, functional programming, quantum physics, etc ... your favorite topic&#x2F;programming language&#x2F;hobby ends up bound to be confined to a tiny bubble of folks that are like you instead of gaining popularity.
评论 #31367170 未加载
评论 #31365417 未加载
评论 #31371222 未加载
ithkuil大约 3 年前
I also found <a href="https:&#x2F;&#x2F;t3x.org&#x2F;klong" rel="nofollow">https:&#x2F;&#x2F;t3x.org&#x2F;klong</a> very interesting
pxeger1大约 3 年前
ngn has a comparison page for various implementations of K:<p><a href="https:&#x2F;&#x2F;ngn.codeberg.page&#x2F;k.html" rel="nofollow">https:&#x2F;&#x2F;ngn.codeberg.page&#x2F;k.html</a><p>Note that ktye&#x2F;i is actually public domain, not proprietary as that page says.
ur-whale大约 3 年前
What does debugging code written in this style look like?<p>Has anyone run code like this under gdb?
评论 #31363466 未加载
7thaccount大约 3 年前
Array languages are very cool. I&#x27;m more of an APL guy myself though.
评论 #31362388 未加载
ur-whale大约 3 年前
I wonder what a diff looks like on code like this? Is it even a good idea to use a diff on something that dense rather than just re-sending the entire code?
评论 #31364298 未加载
评论 #31363437 未加载
评论 #31363720 未加载
wklm大约 3 年前
Cool to see another open source flavor of q, but is there an open source alternative to kdb+?
评论 #31364484 未加载