Hacker Timesnew | past | comments | ask | show | jobs | submit | kelas's commentslogin

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.


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.


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.


(well, at least the mf is big in japan now lol)


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 %


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.


That is wildly disingenuous. Assuming you've imported numpy as np, you get an nxn identity matrix by doing

   np.identity(n)

http://numpy.org/doc/stable/reference/generated/numpy.identi...


> 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)


i'm a fan of

    t=\:t:!x


> 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!


nice :) also see here:

https://hackertimes.com/item?id=45603661

HN is such a sweetheart. i should check in more often.


> 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.


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


> 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.


> 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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: