HackerTrans
TopNewTrendsCommentsPastAskShowJobs

kelas

no profile record

comments

kelas
·9 tháng trước·discuss
oh no, not really.

this is not writing in assembly, and definitely not in bytecode.

but if you are indeed an elite intel(R) assembly coder, and old enough for eax and rax to have taken too much toll on you, or your time away from your family, and of your career as a computer programmer in general - you should probably consider a more modern, more simple and elegant isa, which is now omnipresent, royalty-free, has a huge encoding margin for custom extenstions, and spares you from the childhood trauma of 16 GPRs. it is called riscv.

k family languages isn't asm. it doesn't expect you to hardly ever need anything other than x,y,z in terms of function arguments. this is why they are so conveniently implicitly auto-declared for you in your function - just reference them, done.

it is useful, man. it works.
kelas
·9 tháng trước·discuss
author of the annotated version here.

> representative example

this is grossly taken out of context (which is explicitly stated at the very top of the corresponding readme, https://github.com/kparc/ksimple).

ioccc is often brought up in such HN rants, but the comparison is off mark completely. if you can't read this, you're better off writing some python or some such. this works exactly because it is not obfuscated. this code can't be more regular. tripwires (lack of malloc errno check, possible overflow of refcount) are given as exercises.

> Is there some kind of brain surgery you have to undergo when you accept the q license that damages the part of the brain that perceives beauty?

this code has absolutely zero to do with commercial system k4/kdb+, where did you get that idea? this is published under MIT license. would you like to be reminded of the terms, or fancy an explanation of what they mean? all of them implicitly state that if you're unhappy with the terms you're very welcome to walk away.

hopefully, no brain surgery required for you, god forbid. just an open mind, in methaphorical sense, healthy sense of humour and common sense that the less you type the more you think.

you are also welcome to share examples of code which tickle your sense of beauty, authored by you or someone else.

now, stand straight and defend your argument. we're all ears.
kelas
·9 tháng trước·discuss
> If you're arguing that "Read-Eval-Print cycle" doesn't count as REPL, then it pretty strongly undercuts your argument that "dialog approach".

no, thankfully, it doesn't, and here's why. as i elucidated above, PDP-1 was indeed a revolutionary "el cheapo" computer, which DEC managed to ship over 50 units of. it gave birth to hacker culture, just because it had to be hacked with all kinds of peg legs in order to be useful. now, to the point:

1. PDP-1 is mostly remembered for Spacewar!, a groundbreaking space combat game invented by a dude who also coincidentally invented large parts of LISP while on IBM payroll.

2. APL, after its debut in 1965-1966, had its first official application to teach formal methods in systems design at NASA Goddard Center.

My point should be obvious, but just in case:

in our line of work (between sessions on Hacker News) we are sometimes faced with the concept of "production" (usually on Friday afternoons). this idea really matters. it makes all the difference between fooling around and the real deal.

therefore, as it must follow, and as i mentioned much earlier, APL was and remains the very first real REPL system, although they didn't really use that terminology. all i meant is that in 21st century people take Chrome's devconsole, ipython, node, zsh for granted. with completions, hints, all that.

(in APL'esque family, by the way, there's hardly anything to hint or auto-complete. mathematics doesn't work that way. by the way, not coincidentally, one of the most successful modern descendants of APL is called Wolfram Mathematica)

are we on the same page?
kelas
·9 tháng trước·discuss
this is a gross undeappreciation of a truly remarkable effort by my dear friend and associate. also, at least one of the languages presented is due to him. you can call him @ktye. he's too modest.

it is not a Kunstkamera or some computer cryptozoology extravaganza. many things are shown here, from different eras, but some are not - they are evolving. and progress takes sacrifice.

cheers k.

ps. we usually spell atw as atw :) he also goes by a. don't chicken out, send him an email. he's a very friendly guy. just like me.
kelas
·9 tháng trước·discuss
(well, at least the mf is big in japan now lol)
kelas
·9 tháng trước·discuss
julia is cool, hands down.

only typical k binary will be less than 200kb and doesn't need stdlib. it still needs a few syscalls, but we're working on that.

and julia has this small and insignificant dependency called llvm. i bullshit you not:

  kelas@prng ~ % cd /opt/llvm-project
  kelas@prng llvm-project % du -hd0
   14G .
  kelas@prng llvm-project %
kelas
·9 tháng trước·discuss
> Or, do you just not do that sort of stuff in these languages?

i tell you more. it is very much recommended to avoid doing this sort of stuff in all languages.

  v_sepallength: 11 14 12
  v_sepallthickness: 1.3 1.5 1.2
  mul[v_sepallength;v_sepalthickness]
no:

   /sepal:lengths and stroke widths
   spl:[l:11 14 12;w:1.3 1.5 1.2]    /this is your "struct", if you will
  
   spl.w
  1.3 1.5 1.2    /proof

   */spl
  14.3 21. 14.4  /for mul, we don't even have to bother with field names

   */spl`l`w     /but if you insist, lets make it explicit
  14.3 21. 14.4

to produce a "factory" for well-formed spl objects is a no-brainer as well.

why we don't use v_ prefix:

  1. everything what can be a vector should be a vector.
  2. we can't use underscore anyway - it is an operator.
kelas
·9 tháng trước·discuss
exactly.

the complexity is built differently in k.

  * namespaces do exist, and are just as useful as they are in c++ and especially my beloved *sun.misc.unsafe*. i recommend.

  * instead of passing 20 arguments to a function (which is impossible - the limit is lower), we pass a dictionary if we have to. k **pretends** that everything is passed by value, but in reality it is much smarter than that.

  * notion of *scopes* is a bit of a non-sequitur here, but it is fundamentally important that there is no *lexical scoping* in k. the only two scopes which are available from the scope of a lambda are exactly *local* and *global*. and for as long as your function doesn't mess around with global scope or i/o (which is essentially the same thing), it remains pure, which is super cool. this design is not just for simplicity - it is for a good reason, and more than one.

  * the above doesn't mean that it is impossible to create a *closure* in k and pass it around as a value.

  * functions take up to three implicit arguments - named x,y and z (they can be renamed explicitly, but why not just document their semantics instead, in-situ?). all you need to do to declare xyz is reference them in the function definition. in competent k code, you'll rarely see a function with more than xyz.

 * in k community, we don't use upper case unless the apartment is on fire. god forbid.

 * shorter names and more documentation, and there will be joy.
kelas
·9 tháng trước·discuss
> t=\:t:!x

this is of course obvious first idea, but the recipe from above is actually from the official k4 cookbook. t=t is less innocent than it seems, i'm afraid.

in k7/k9, we can:

  10^@[100#0.;11*!10;1.]    /just for more lulz
there's also a way to mutate it in place!
kelas
·9 tháng trước·discuss
nice :) also see here:

https://news.ycombinator.com/item?id=45603661

HN is such a sweetheart. i should check in more often.
kelas
·9 tháng trước·discuss
> That is wildly disingenuous.

assuming you're referring to numpy as to have anything to do with python spec, i totally agree with you. only it doesn't. so don't pytorch and pandas (and good so, poor python doesn't need any extra help to be completely f).

> you get an nxn identity matrix by...

no, man, that's how you get it. really advanced technique, kudos!

i get it by:

   id:{...}     /there are many ways to implement identity in k, and it's fun!
   id 3
  +1.00 +0.00 +0.00
  +0.00 +1.00 +0.00
  +0.00 +0.00 +1.00
but if you can keep a secret, more recently we've gotten so lazy and disingenuous in k land, and because we need them bloody matrices so often now, we just do it like so:

   &3
  +1.00 +1.00 +1.00
  +1.00 +1.00 +1.00
  +1.00 +1.00 +1.00

   =3
  +1.00 +0.00 +0.00
  +0.00 +1.00 +0.00
  +0.00 +0.00 +1.00
(but of course before we do that we first install python4, numpy, pytorch, pandas and polars - not because we need them, just to feel like seasoned professionals who know what they're doing)
kelas
·9 tháng trước·discuss
ok, you have a point there. all 53 PDP-1s were "cheap" computers compared to IBM stuff (only $1M, adjusted) and used paper drum instead of punch cards. that was a nightmare to deal with, so people were buying IBM M typewriters to punch stuff in. Although Deutsch and Berkeley's LISP was in large part a copycat of IBM's LISP, people were indeed typing in LISP expressions in a REPL'ish manner. But if you ever saw a line of LISP, you can imagine what kind of "REPL" that was. "Miss one paren" comes to mind :)

APL\360 used a much more advanced selectric with a dedicated typeball, was designed for a machine of a totally different class, and could not be compared to literally kilometers of paper containing mostly mistyped parentheses. it was TRULY terse, expressive and interactive.

but yeah, PDP-1 hackers technically got there first - they had no choice :) check this out:

https://s3data.computerhistory.org/pdp-1/DEC.pdp_1.1964.1026...

6-7 Input and Output, System Operation is where the READ-EVAL-PRINT is indeed mentioned. but if you read the entire paragraph, and the next one ("if the system drops dead" lol) you'll agree that PDP-1 "REPL" was hell on earth, at the very end of the manual there are some really juicy REPL expressions :)

LISP was a torture compared to short and powerful APL notation.

less code less bug.
kelas
·9 tháng trước·discuss
for that matter, i always wonder how people mistake python for numpy :) they have surprisingly little in common.

but enough talking about languages that suck. let's talk about python!

i'm not some braniac on a nerd patrol, i'm a simple guy and i write simple programs, so i need simple things. let's say i want an identity matrix of order x*x.

nothing simpler. i just chose one of 6 versions of python found on my system, create a venv, activate it, pip install numpy (and a terabyte of its dependencies), and that's it - i got my matrix straight away. i absolutely love it:

  np.tile(np.concatenate([[1],x*[0]]),x)[:x*x].reshape(*2*[x])
and now lets see just how obscure and unreadable exactly the same thing looks in k:

  (2#x)#1,x#0
no wonder innocent people end up with brain aneurisms and nervous breakdowns.
kelas
·9 tháng trước·discuss
> without it being tacit, it would probably be more readable

definitely. tacit can be taken a bit too far sometimes, but when a certain discipline is observed (just like in any language, really) it is no less readable than... let me see. oh, lets take some typical pandas/polars heroics - no, those things don't give me brain aneurisms and not too shocking either. they just make wanna vomit no less than the poor people who were forced to write it and contemplate what they've done.

> tacit is "bad"

not at all. it takes one time to see how avg looks in explicit notation to understand that the idea of trains is totally justified.

> the question of how to thread data around without naming it is an interesting one to me.

good question. see above - yes indeed, things can be taken to extremes. when an apl/k program is a oneliner 80 chars long, that's just not cool. there is no reason not to break it down a bit into moving parts with names (and ample space on the right margin for annotations). in no way APL and friends are somehow exempt from commenting their code. but that's not really endemic to array languages, you'd agree.
kelas
·9 tháng trước·discuss
> seems to disagree

no, actually i think Wikipedia got it right:

  "The 1974 Maclisp reference manual by David A. Moon attests "Read-eval-print loop" on page 89, but does not use the acronym REPL.[7]
  Since at least the 1980s, the abbreviations REP Loop and REPL are attested in the context of Scheme.[8][9]"

The first APL interpreter was implemented on System/360 in 1965. Iverson got a Turing in 1979.
kelas
·9 tháng trước·discuss
of course it runs in a browser - pretty much everything you can build using clang will run on the web. including linux kernel and llvm itself.

to hell with peanuts: i'm pretty sure someone must even built cpython interpreter to wasm target, why not. there is no limit of what can be achieved by a group of motivated people with zero sense of direction.

k, however, makes quite a bit of sense on the web - also on your phone. and time to prompt is going to be MUCH faster than python and octave. and i mean their native builds :)

https://kparc.io/k/

backslash is reference card, cmd+[] some examples
kelas
·9 tháng trước·discuss
> your first working program feels like a happy accident.

if you don't mind sharing: how did your own first working program felt like, and what was it written in?

by the way, did it work, or did it work correctly? it's a small but important distinction.
kelas
·9 tháng trước·discuss
> I'd call that code obfuscation.

we call them "trains". since this one has a descriptive name, `avg a`, is not cryptic at all. just a bit fewer of absolutely meaningless parens and duplication.

but it doesn't end there:

1. imagine you wanted a moving average instead. i need to change one character in this train to get `mavg`. what would you need to do?

2. imagine you want to compute moving averages for each of 1000 arrays using both instruction-level parallelism and all available cores? while you'd be writing your unobfuscated code for that, i'd be done way before you're back from your lunch break. in two keystrokes.

once you'd be done with your solution, there would be no need to discuss productivity, or so i hope, but to discuss performance would be interesting.
kelas
·9 tháng trước·discuss
guys,

symbolic algebra package and a computer language are not the same thing :) not even remotely.
kelas
·9 tháng trước·discuss
i'm sure niall is missing it too :)

what does he do these days?