Live data from Hacker News

Stages of denial in encountering K

nsl.com

381–390 of 432 posts

Re: Stages of denial in encountering K

#381

Earlier quoted context omitted.

Truly grokking Python as a first language also took me a few months of studying it and writing it, so the author is probably trying to say it's the same as any technology. The only caveat is once you learn something like Algol, you can kind of pick up similar ones fairly quick, while something like APL or K requires you to start over again.

Grokking a language in a few months is different from being able to just read a language in a few months. It's not just the paradigm change: Haskell, Julia, Mathematica or MATLAB for example are far, far more readable than K.

I think Julia, Mathematica, and Matlab aren't too bad, but have never had too much luck with Haskell despite spending time reading many blog posts and an entire book. APL was MUCH easier for me personally to start doing real things with quickly. Maybe because my experience is almost entirely with dynamic languages, I don't know. Point is, readability isn't an absolute. Haskell is easier for you, but APL is easier for others too.

Re: Stages of denial in encountering K

#382
post #351

Earlier quoted context omitted.

> It's a little funny comparing a language with another language+plus-its-entire-ecosystem This is pretty much my point: any ‘reimplement this weird built-in thing in $OTHER_LANG’ is going to involve overheads unless $OTHER_LANG also has that thing. I don't think keeping most types out of prelude should be a downside; you can always ‘from myprelude import * ’ if you disagree. > How would you do this in Python? I don'…

> I don't think keeping most types out of prelude should be a downside I don't understand what that means. > I don't really know what "persists the unique index of f" means, but this seems similar to shelve. I can misuse that to give the same effect as what you showed. I think you got it, but it seems like a lot of typing! How many characters do you have to change if you want it purely in memory? In k I just write: `…

‘Prelude’ is the set of standard functions and types that you don't have to import to use. Python comes with a rich standard library, but most require imports to use.

> How many characters do you have to change if you want it purely in memory?

When the question is if ‘K can reduce line count by a factor 1000’, shorter keywords hardly cut it. ‘setdefault’ is wordier than ‘?’, but as something you're only going to use on occasion, so what? And d.setdefault(_, len(d)) is something you'll use maybe once a year.

shelve acts like a dict, so you can do the setdefault dance the same way on in-memory dicts.

Re: Stages of denial in encountering K

#383
post #155

“ and you can add 5 to an entire matrix at once as easily as a single number. Why you would want this property remains elusive-...”. Why would that be elusive I wonder ? MATLAB has been doing it since the 80s as an example and that exact elusive feature would have been used countless times.

Those words were spoken "in character". The idea was that some readers would chuckle at the naivety.

And many time’s I shake my head at how people miss humor/sarcasm on HN. Got me.

Re: Stages of denial in encountering K

#384

From Arthur: design goal: speed write fast, run fast, modify fast. minimize product of vocabulary and program size. https://a.kx.com/a/k/readme.txt comprehensive programming environments (programming, files, comms, procs, ...) are depressingly complex. commonlisp, c/lib/syscalls, java, winapi are all in the 1000's of entry points. many with multiple complex parameters. with k we try to do more with less in order to w…

Don't use indentation for blockquotes. HN rendered indented lines as code, which is unreadable on mobile.

Re: Stages of denial in encountering K

#385

From Arthur: design goal: speed write fast, run fast, modify fast. minimize product of vocabulary and program size. https://a.kx.com/a/k/readme.txt comprehensive programming environments (programming, files, comms, procs, ...) are depressingly complex. commonlisp, c/lib/syscalls, java, winapi are all in the 1000's of entry points. many with multiple complex parameters. with k we try to do more with less in order to w…

The readme examples remind me of Perl code. Example: print !~($/=$")+2*map 1..$s{$_%$'}++,

What does this do?

Re: Stages of denial in encountering K

#386

Earlier quoted context omitted.

Doesn't that regex detect correct spellings instead of wrong ones? I.e. it matches tier, tie, etc.

Yes. Good eye :) The other comment is also quite accurate: it doesn’t properly grasp phonetics.

FWIW, I agree with your argument (I guess).

Regular expressions are complex and oftentimes a tool might be necessary to get a better idea of what an expression will match. However, if we were to make the language to describe them more verbose that'd still not solve this issue. Having a concise way to describe them is a good thing. Those who grok them can do so quickly without having to read several lines of a more descriptive language and those who need assistance can still plug them into a tool.

Re: Stages of denial in encountering K

#387
post #161
post #140

what is ` the closest i got to finding some pattern is this: >>> xs '34210' >>> grade(xs) [4, 3, 2, 0, 1] >>> grade(grade(xs)) [3, 4, 2, 1, 0] # :O where grade = lambda xs: ( [i for (i,_) in sorted(enumerate(xs), key=swap)] ) swap = lambda p: (p[1], p[0]) no clue what it means though. (i guess "ordinal" really is too ambiguous...) EDIT alright, i see it now - `<<xs` is "for each item x of xs, where does x land when y…

x: 10?A:"abcdefghijklmnopqrstuvwxyz" x "ysyselacwl" +`x`y`z!(x; So <x gives a sort index, <<x tells you how far each element is from the minimum in that sort index

I still don’t understand what the numbers in column y mean. I understand column z and that’s also what grade up is returning in John Earnest’s oK:

    x:“baced“
    
That is, for example, when sorting, the item at position 1 in the original string (“a”) moves to position 0 (the beginning of the sorted string). So in the end you get “abcde”.

What does column y mean? If I sort the original with it, I get “wllaysysce”.

Has this changed between versions of K?

Re: Stages of denial in encountering K

#388
post #373

Earlier quoted context omitted.

According to Guy Steele, if you're a C++ programmer using Java, you've been dragged halfway to Lisp. https://people.csail.mit.edu/gregs/ll1-discuss-archive-html/... So by that estimate, if you switch to Python you're another halfway to Lisp (three quarters of the way from C++).

I could never figure out how Java is in any sense halfway to Lisp. Python, maybe.

The reference point is C++.

What makes Java nearer to Lisp than C++?

Mostly the Java runtime, the JVM. C++ basically comes with some kind of manual memory management and raw data layout.

Lisp comes with Garbage Collection and managed memory. In Lisp one passes references to arrays and other objects around. The runtime tracks which objects are of what dynamic type and of what size. The garbage collection may be a simple mark&sweep or a more complex, say, generational GC. The first garbage collection was developed for Lisp around 1960 and has then slowly spread to other languages. C++ was object-oriented, but with a more traditional non-GC approach. Java changed that.

Re: Stages of denial in encountering K

#389
post #352

I have the same question for K aficionados as I have for Forth ones: what real-world, human-usable, important software has been written in it? A GUI framework, a web browser, a window manager, a text editor, etc. Anything? I'm asking because the article is poking at C-like languages, i.e. implying that K is good for general-purpose use. Yet all I hear about is that K is good at multiplying numbers and matrices, which…

Forth: OpenFirmware (previously seen in Power Macs, pretty much every Sun device until Sun died, so on. Canon Cat (greatest text editor of all time, by Jef Raskin, the guy who made the Macintosh) Forth Has Been to Space (multiple times, but who's keeping score?): https://www.forth.com/resources/space-applications/ OKAD, which was used to create the processor with the lowest power usage per instruction in the entire w…

Sorry, but I'm not the one trolling. Reading up on "Canon Cat", I find

> It had a text-based interface without a mouse, icons, or menus

sigh

The Forth in space thing is just some drivers/firmware for spaceships. I.e. once again nothing that an ordinary user would care about. The APL part is devoid of links to real contemporary software. Not even something of Notepad++ quality...

Please don't waste your time as you don't seem to want to understand my question. Thank you.

Re: Stages of denial in encountering K

#390
post #351

Earlier quoted context omitted.

> I don't think keeping most types out of prelude should be a downside I don't understand what that means. > I don't really know what "persists the unique index of f" means, but this seems similar to shelve. I can misuse that to give the same effect as what you showed. I think you got it, but it seems like a lot of typing! How many characters do you have to change if you want it purely in memory? In k I just write: `…

‘Prelude’ is the set of standard functions and types that you don't have to import to use. Python comes with a rich standard library, but most require imports to use. > How many characters do you have to change if you want it purely in memory? When the question is if ‘K can reduce line count by a factor 1000’, shorter keywords hardly cut it. ‘setdefault’ is wordier than ‘?’, but as something you're only going to use…

> ‘Prelude’ is the set of standard functions and types that you don't have to import to use. Python comes with a rich standard library, but most require imports to use.

I might not understand this about python.

    $ python3
    Python 3.7.6 (default, Dec 30 2019, 19:38:26) 
    [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> Counter
    Traceback (most recent call last):
      File "", line 1, in 
    NameError: name 'Counter' is not defined
Should that have worked? Is there something wrong with my Python installation?

> but as something you're only going to use on occasion, so what? And d.setdefault(_, len(d)) is something you'll use maybe once a year.

If it takes that many keystrokes, you're definitely only going to use it once per year! This is the normal way you make enumerations in q/k.

The low number of source-code bytes is the major feature in k. I've written some on why this is valuable, but at the end of the day, I don't really have anything more compelling than try it you might like it, and it works for me. This is something I'm working on though.

- https://news.ycombinator.com/item?id=8476113

- https://news.ycombinator.com/item?id=10876975

Post reply on HN