News for hackers. Stuff that matters.
Re:Arthur Whitney's one liner sudoku solver by nebulous1 on Saturday October 05, 2024 @09:48PM (#41754136)
Here is the line, it is written in K. K is a language created by the same person (Arthur Whitney) based on APL and Scheme.

  x(,/{@[x;y;]'(!10)^x*|/p[;y]=p,:,3/:-3!p:!9 9}')/&~*x
Re:Arthur Whitney's one liner sudoku solver by pjot on Saturday October 05, 2024 @10:27PM (#41754286)

  > Advocates of the language emphasize its speed, facility in handling arrays, and expressive syntax.
Indeed.

https://en.m.wikipedia.org/wiki/K_(programming_language)

Re:Arthur Whitney's one liner sudoku solver by brookst on Saturday October 05, 2024 @10:50PM (#41754383)
“Expressive” = like two cats fought while standing on the keyboard
Re:Arthur Whitney's one liner sudoku solver by xwolfi on Saturday October 05, 2024 @11:03PM (#41754435)
I work with it daily in a bank, and I couldnt find a better way to express it. Many colleagues throwing their keyboard in despair at this stupid impossible to remember syntax.
Re:Arthur Whitney's one liner sudoku solver by rak1507 on Saturday October 05, 2024 @11:18PM (#41754483)
There are a lot of things in various programming languages which are hard to remember, but k and array languages have such a small surface area, not being able to remember it while working with it daily amounts to learned helplessness.

(source: mostly amateur k programmer, also worked with it in a bank, find it vastly easier to read/write/remember than most mainstream languages)

Re:Arthur Whitney's one liner sudoku solver by aguaviva on Sunday October 06, 2024 @12:22AM (#41754719)
Which is why banks love it. Because one has to be pretty smart to be able to wade through all that nutty, impossible to remember syntax.

Therefore, k is a smart choice, and people who use k in business applications must be really smart.

Re:Arthur Whitney's one liner sudoku solver by inopinatus on Sunday October 06, 2024 @12:30AM (#41754760)
"Debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"

— Kernighan, Brian. The Elements of Programming Style (2e). McGraw-Hill, 1978.

Re:Arthur Whitney's one liner sudoku solver by userbinator on Sunday October 06, 2024 @01:00AM (#41754875)
Re:Arthur Whitney's one liner sudoku solver by nine_k on Sunday October 06, 2024 @03:10AM (#41755368)
It's a nice interpretation.

I prefer a different approach: "smart is good; clever isn't smart". If you have to express something in a clever, that is, highly contrived but actually working way, it means that you lack the right way to express it, and maybe your mental model of the problem is not that good. The theory of epicycles is clever; Kepler's laws are smart.

Re:Arthur Whitney's one liner sudoku solver by IshKebab on Sunday October 06, 2024 @02:36AM (#41755239)
Very unconvincing. If you become cleverer you can just write even more clever code and still not be able to debug it.
Re:Arthur Whitney's one liner sudoku solver by chmod775 on Sunday October 06, 2024 @03:17AM (#41755391)
Great!
Re:Arthur Whitney's one liner sudoku solver by darkwater on Sunday October 06, 2024 @06:17AM (#41756121)
This can probably true for some people, but still will not work for many other. One probable outcome of a frustrated debugging session is "let's rewrite/refactor it to make it easier to debug next time", and not self-enlightenment.
Re:Arthur Whitney's one liner sudoku solver by chii on Sunday October 06, 2024 @02:04AM (#41755098)
> how will you ever debug it?

By being so smart that your program has obviously zero bugs in it!

Re:Arthur Whitney's one liner sudoku solver by nosianu on Sunday October 06, 2024 @03:10AM (#41755370)
This view is too static.

That is not possible, because the environment can (and at some point always will) change which wasn't planned for due to a lack of working crystal balls. Data, user behavior, the network, the system(s) the software runs on can all change over time.

Also, it is way too expensive to try to cover every single conceivable possibility, so we deliberately leave holes.

For non-trivial things we often prefer to wait to see what problems actually come up during use, and then fix exactly those, but not the many more problems that could come up but are too unlikely and/or too costly to guard against.

In a living environment the software lives too, and keeps changing and adapting.

Re:Arthur Whitney's one liner sudoku solver by chii on Sunday October 06, 2024 @03:28AM (#41755435)
you might've missed the quip, since this whole thread is about a quote, which i'm countering with an alternative quote from Hoare

> There are two methods in software design. One is to make the program so simple, there are obviously no errors. The other is to make it so complicated, there are no obvious errors.

Re:Arthur Whitney's one liner sudoku solver by boomlinde on Sunday October 06, 2024 @04:47AM (#41755766)
> That is not possible, because the environment can (and at some point always will) change which wasn't planned for due to a lack of working crystal balls. Data, user behavior, the network, the system(s) the software runs on can all change over time.

It sounds to me like you are describing a change of problem, not bugs in the solution. If in the future someone redefines the concept of a Sudoku puzzle such that this solution is no longer applicable, or tries to use the solution verbatim in a language which is different from K and therefore yields different results, it's not a bug in the original code that it's not a solution to that new problem. It's still a solution to the same problem it was always a solution to.

I can see what you mean in a practical sense, but also consider (practically) that a lot of problems can be broken down into smaller, well-defined problems which are themselves practically immutable. You can throw the solutions to such problems out when you no longer need them, and come up with solutions to whatever new problems replaced the original problems.

Re:Arthur Whitney's one liner sudoku solver by RHSeeger on Sunday October 06, 2024 @03:50PM (#41759732)
In my experience, the vast majority of problems are insufficiently specified. No matter how well you solve the current problem, there are bound to be certain assumptions you've made about the requirements. And when those assumptions don't hold true, your solution may no longer work.

> What do you mean the input file can't be ISO-2WTF encoded?

Re:Arthur Whitney's one liner sudoku solver by dotancohen on Sunday October 06, 2024 @07:15AM (#41756338)
I believe that you are addressing maintainability, not debugging.
Re:Arthur Whitney's one liner sudoku solver by nosianu on Monday October 07, 2024 @07:04AM (#41764800)
In your book, debugging problems is not part of maintenance?

What even is the difference, apart from trying to start a discussion about definitions (I'll let somebody else comment on that terribel habit: https://www.lesswrong.com/posts/7X2j8HAkWdmMoS8PE/disputing-...).

Re:Arthur Whitney's one liner sudoku solver by dotancohen on Monday October 07, 2024 @08:11AM (#41765204)
Debugging problems is part of maintenance, but a small part. Extensibility is probably a much larger part, and what I think of first when someone says "maintenance".
Re:Arthur Whitney's one liner sudoku solver by ryanjshaw on Sunday October 06, 2024 @02:04AM (#41755101)
The average bank/company would rather have an average solution maintained by 10 easily replaceable average developers than a nutty, smart solution only understood by 1 highly talented developer.
Re:Arthur Whitney's one liner sudoku solver by Moru on Sunday October 06, 2024 @04:14AM (#41755628)
You could also say that the average bank/company should have learned from previous mistakes doing exactly that for many decades. Select a language that is well tested, understood and supported. Set a limit on cleverness and instead focus on maintainability and simplicity.
Re:Arthur Whitney's one liner sudoku solver by speed_spread on Sunday October 06, 2024 @07:14AM (#41756332)
If only. In my experience, banks end up building a solution that is maintained by 100 mediocre developers that a reasonably smart developer can't make sense of when it behaves erratically or has extremely poor performance.
Re:Arthur Whitney's one liner sudoku solver by ryanjshaw on Sunday October 06, 2024 @08:42AM (#41756745)
I described the theory. You have described the practice :)
Re:Arthur Whitney's one liner sudoku solver by aguaviva on Sunday October 06, 2024 @11:19AM (#41757719)
Which was precisely my point (and I agree with all the responses in this thread), though my wording and light sarcasm seems to have been a bit too dry, and didn't quite take up as intended.
Re:Arthur Whitney's one liner sudoku solver by queuebert on Sunday October 06, 2024 @11:27AM (#41757785)
Keeping skill barriers low keeps wages low as well.
Re:Arthur Whitney's one liner sudoku solver by nine_k on Sunday October 06, 2024 @03:02AM (#41755344)
Not that it's impossible to remember, bit it's definitely contrary to most traditional use of the symbols employed in it, though not without logic. My favorite is the functions from io package, called 0, 1, and 2 (yes, numbers) which handle interaction with stdin, stdout, and stderr respectively. In dyadic form they at least have a colon, but in monadic form they look like plain numbers: 1 "Hello world".

I suspect that to study k (and use kdb) efficiently, you need to actively forget what you knew about the syntax of other languages, and study k as a language from Mars that happens to map to ASCII characters somehow.

Re:Arthur Whitney's one liner sudoku solver by anonzzzies on Sunday October 06, 2024 @03:14AM (#41755384)
It is really easy to remember; it is so small that remembering is the least of the issue. The rest is just using it a lot; I find it readable and nice to work with. Unlike other some other languages we get shoved down your throats.
Re:Arthur Whitney's one liner sudoku solver by rtpg on Sunday October 06, 2024 @03:33AM (#41755452)
I've been messing with Uiua (https://www.uiua.org/) a good amount recently, and find its sort of dance between having a stack and being an array language somehow gets you to a nice level of legibility despite being a combo of two styles that tend to generate line noise.
Re:Arthur Whitney's one liner sudoku solver by g8oz on Sunday October 06, 2024 @10:30AM (#41757399)
Thanks for the link, it looks like a fascinating language
Re:Arthur Whitney's one liner sudoku solver by dahart on Sunday October 06, 2024 @11:14AM (#41757688)
The front page there has examples like “÷3/+∿⊞×⊟×1.5.220×τ÷⟜⇡&asr” - is that closer to noise, or does it actually look more readable than K once you get used to both? I’m kind-of intrigued by the built-in multimedia output, but still this language looks scary and impractical at first glance. How does it compare to using numpy & jupyter? Do a lot of people prefer the extreme tenseness over using typeable keywords? I’m curious why it lets you type the readable operators but wants to turn them into glyphs; wouldn’t it be more approachable, more readable, and make more maintainable code, if it just used the keywords instead of glyphs?
Re:Arthur Whitney's one liner sudoku solver by rtpg on Sunday October 06, 2024 @06:37PM (#41760945)
Well firstly you can just type keywords and they get swapped by glyphs

Secondly, the power with Uiua is you can easily split up that expression literally by just hitting enter in some spots (and line swapping but…). You can give names

And finally if you are constantly doing operations across arrays it can be more legible to go a symbol like approach, like how most people prefer x+y to add x y. The conciseness helps you build up larger expressions before you need to break things up.

Re:Arthur Whitney's one liner sudoku solver by PhilipRoman on Sunday October 06, 2024 @11:58AM (#41757990)
Cool language. I happened to notice the ⍜ operator, which operates on a transformed array, then reverts the transformation. Not sure if other array languages include this, but it's a really cool idea. I always found the traditional map/filter operators to be limiting in this regard, kind of like trying to write expressions without using parentheses.
Re:Arthur Whitney's one liner sudoku solver by mlochbaum on Sunday October 06, 2024 @12:47PM (#41758378)
It's in several, particularly newer APL dialects; see https://aplwiki.com/wiki/Under#History . Proud to say I originated the "structural" form used by Uiua, which is able to deal with transformations like filtering that lose parts of the input. Every language now seems to have its own take on what exactly Under means, with different implementations leading to different supported functions and various ways to relax the theory to be more convenient or handle intuitively expected things better.
Re:Arthur Whitney's one liner sudoku solver by rtpg on Sunday October 06, 2024 @06:38PM (#41760953)
Under is a concept in array languages, though it’s supported in a very adhoc way
Re:Arthur Whitney's one liner sudoku solver by hilux on Sunday October 06, 2024 @02:24AM (#41755190)
But possibly not its maintainability.
Re:Arthur Whitney's one liner sudoku solver by Isamu on Saturday October 05, 2024 @09:55PM (#41754163)
Not knowing K, am I correct in assuming this is a backtracking brute force solver?
Re:Arthur Whitney's one liner sudoku solver by o11c on Saturday October 05, 2024 @10:22PM (#41754265)
From the linked page (and the one linked beyond that), it's a breadth-first search actually. Keep a list of possible puzzle states at all times, pick a blank cell (theoretically arbitrary, but in practice intelligently for performance), add copies of the state with each possibility for that state added.
Re:Arthur Whitney's one liner sudoku solver by BobbyTables2 on Saturday October 05, 2024 @11:26PM (#41754506)
That sounds like 100+ lines in python or similar languages…
Re:Arthur Whitney's one liner sudoku solver by otteromkram on Saturday October 05, 2024 @11:51PM (#41754616)
It probably isn't. At least, not for Python.
Re:Arthur Whitney's one liner sudoku solver by throwup238 on Sunday October 06, 2024 @01:04AM (#41754884)
You should be able to do it in under 20 lines using the same matrix operations as the K code via numpy.
Re:Arthur Whitney's one liner sudoku solver by anonzzzies on Sunday October 06, 2024 @03:16AM (#41755386)
Numpy is indeed very apl. Just more horrible to me; not python-y and annoyingly verbose for the apl-er.
Re:Arthur Whitney's one liner sudoku solver by hrzn on Sunday October 06, 2024 @05:04AM (#41755834)
A few years back I made a modest attempt at writing a concise yet readable sudoku solver in Python - in about 29 lines: https://github.com/hrzn/sudoku/blob/master/sudoku.py

Could have been made shorter at the price of readability.

Re:Arthur Whitney's one liner sudoku solver by forgotpwd16 on Sunday October 06, 2024 @08:24AM (#41756655)
Looks nice. Since imports numpy can utilize (more of) numpy's operations to squeeze validation functions and nested fors to one. Should result in shorter code but readability will probably depend on reader's experience in array programming.
Re:Arthur Whitney's one liner sudoku solver by dzaima on Sunday October 06, 2024 @02:09PM (#41758880)
The k code at least isn't doing any heuristics for the iteration order, and is just doing a fold over the indices of zeroes in index-ascending order.
Re:Arthur Whitney's one liner sudoku solver by make3 on Saturday October 05, 2024 @11:49PM (#41754612)
"one line in your custom language" is not one line at all lol
Re:Arthur Whitney's one liner sudoku solver by Spivak on Sunday October 06, 2024 @12:00AM (#41754642)
To be fair K is a real language that's used by more than just him.

Why array languages seem to gravitate to symbol soup that makes regex blush I'll never know.

Re:Arthur Whitney's one liner sudoku solver by fodkodrasz on Sunday October 06, 2024 @01:58AM (#41755076)
> Why array languages seem to gravitate to symbol soup that makes regex blush I'll never know.

Because the HN crowd is amazed by the cool hacker vibes of the symbol-soup subset of array languages. The comments also reflect an (unfounded) elitist attitude.

Matlab, for example, is very commonly used array language in the wild and is definitely not a symbol soup. Bit more verbose but makes the array programming paradigm very approachable (and other paradigms are also supported).

Re:Arthur Whitney's one liner sudoku solver by exitheone on Sunday October 06, 2024 @03:01AM (#41755340)
Array language have been around far longer than any "HN crowd".
Re:Arthur Whitney's one liner sudoku solver by fodkodrasz on Sunday October 06, 2024 @11:15AM (#41757690)
Which is totally orthogonal to the original statement, and my reflection to it, which was on one hand statig that seemingly array languages tend to be letter soupy, for which I replied that a selection bias is at play, as array languges are used widely, most notably Matlab is used widely which is not a letter soup. It is simply not regurgulated on the site as it does not seem so hardcore.

Nevertheless you are right, array langueges have been around earlier, for example Matlab itself dates back to the 1970s.

I do not understand the awe some are giving them in the comments, they are an easy to understand paradigm, which is very well suited for certain types of problems. Some having overly terse syntax is a thing, but I do not feel that only geniuses can comprehend array programming, anyone who did learn some university level physics or signal processing has the tools in their belt.

Re:Arthur Whitney's one liner sudoku solver by IshKebab on Sunday October 06, 2024 @02:39AM (#41755254)
Yeah I think MATLAB and Mathematica are waaay more used than K et al. They just don't look insane so people aren't posting them on HN as much.
Re:Arthur Whitney's one liner sudoku solver by asah on Saturday October 05, 2024 @11:57PM (#41754637)
What baud is that? /s
Re:Arthur Whitney's one liner sudoku solver by genewitch on Sunday October 06, 2024 @12:14AM (#41754690)
mismatched, whatever it is, that's for sure. It's not quite line noise, so maybe it's just the wrong stop bit?
Re:Arthur Whitney's one liner sudoku solver by speed_spread on Sunday October 06, 2024 @07:17AM (#41756345)
My cat puked in the modem receiver cup, sorry.
Re:Arthur Whitney's one liner sudoku solver by lofaszvanitt on Sunday October 06, 2024 @12:59AM (#41754870)
It has strong perl vibes and it brings back ptsd :D. Maybe this overshortification of things is a personnel or intelligence indicator of some sorts.
Re:Arthur Whitney's one liner sudoku solver by nine_k on Sunday October 06, 2024 @03:18AM (#41755395)
Lines of code is a poor metric, because languages use lines differently.

A much better measure would be the number of nodes in a parse tree, of semantically meaningful non-terminals like "a constant" or "a function call".

An even better measure would also involve the depth and the branching factor of that tree.

Re:Arthur Whitney's one liner sudoku solver by tromp on Sunday October 06, 2024 @03:44AM (#41755493)
The preferred measure of information content is simply number of bits as used for instance in Algorithmic Information Theory [1].

[1] https://en.wikipedia.org/wiki/Algorithmic_information_theory

Re:Arthur Whitney's one liner sudoku solver by jodrellblank on Sunday October 06, 2024 @01:07PM (#41758511)
By that measure naming a variable “objUser” instead of “user” is better because it has more information, and naming the same variable “cgjkkytdvjkftujmhffetb” is even better because it contains more information.

The parse tree approach is trying to get at a fuzzy notion of useful information and useful density of information.

Re:Arthur Whitney's one liner sudoku solver by smokel on Sunday October 06, 2024 @04:47AM (#41755768)
The built-in functions and API to a system library spoil these metrics. As an example, consider HQ9+, which is pretty good at printing "Hello, world!" for instance.

https://cliffle.com/esoterica/hq9plus/

Re:Arthur Whitney's one liner sudoku solver by xelxebar on Sunday October 06, 2024 @05:38AM (#41755965)
Just... no. What are you even trying to compare? UX of a language matters. Clarity, thinking paradigm, expressability etc. all matter and are affected by the visual size of code.

A one line solution takes up very little visual real estate. That matters a lot when you are working on some more complex problem. Flitting your eyeballs around a screen takes orders of magnitude less effort than scrolling around and navigating files. Cognitive load is important.

We really need to burn this vague "only semantics matter" scourge that's creeped into our programmer values these days. I'm sorry, but I care about things like incentives against over-engineering, ease of directly thinking in the problem domain, and simplicity of the encompassing ecosystem.

A terse one-line solution tells me there is virtually no room for over-engineering. Even without knowing K, I can see obvious constants side-by-side, telling me it's likely using a direct data representation of the problem in its code. Does K culture encourage code like that? Does programming in K bias you towards directness and simplicity? Then please, I want some of that special sauce on my team.

</rant>

Re:Arthur Whitney's one liner sudoku solver by lukan on Sunday October 06, 2024 @06:10AM (#41756093)
"A one line solution takes up very little visual real estate. That matters a lot when you are working on some more complex problem."

When I work on some more complex problem, I like to think about the problem, not spend energy decoding condensed text. Scrolling a bit more verbose, but clear code, is faster for me.

Re:Arthur Whitney's one liner sudoku solver by cenamus on Sunday October 06, 2024 @06:57AM (#41756266)
I think the difference is not a bit of scrolling, but rather the whole program on half a page vs 10 files à 200 lines of mostly noise
Re:Arthur Whitney's one liner sudoku solver by lukan on Sunday October 06, 2024 @07:07AM (#41756301)
There is noise and there is self explaining code. One liners for complex problems are a nice challenge, but are seldom clear to read.
Re:Arthur Whitney's one liner sudoku solver by Etherlord87 on Sunday October 06, 2024 @06:15AM (#41756114)
Why not create a programming language, that uses all possible unicode codepoints to further decrease the number of characters used? That would be so much more readable!
Re:Arthur Whitney's one liner sudoku solver by vrighter on Monday October 07, 2024 @06:13AM (#41764493)
How about having a "binary operator" codepoint, that is then specialized by a following combining character codepoint. That way it's also intrinsically obvious that the thing is a binary operator at first glance. Even more expressiveness!
Re:Arthur Whitney's one liner sudoku solver by agumonkey on Sunday October 06, 2024 @11:05AM (#41757631)
I mentally work like what parent described. I plug ast node in my mind when I read. I like operating with combinators, graphs/trees of them that I almost naturally understand the results of.

Any language that add complexity at that layer loses me, and APL, even with crude visuals is not far from that.

Re:Arthur Whitney's one liner sudoku solver by dahart on Sunday October 06, 2024 @11:59AM (#41757998)
Don’t get confused between using smaller keywords and actually understanding the problem at hand. Terse languages do absolutely nothing to prevent over-engineering. They might even contribute by giving a false sense of simplicity and a tendency to prevent certain kinds of code reuse. To prevent over-engineering on large projects, you don’t need a terse language at all, you need the right mentality, the right management & product team, good team culture & cohesion, strong code review process, and job performance metrics that align with not over-producing code.

It seems like parent’s metric (size of parse tree) would easily optimize for terseness and penalize bloat, regardless of language, so maybe your reaction was too reflexive. UX of a language does matter a bit, and one that’s too terse incurs development friction and technical debt when used in larger projects. Just study the history of Perl and why it’s not widely used.

What a one liner looks like is more or less the worst possible metric to use for large software projects. In any language, the style of code changes the larger the codebase, and cleverness and terseness become a liability. https://www.teamten.com/lawrence/writings/norris-numbers.htm...

Re:Arthur Whitney's one liner sudoku solver by xelxebar on Sunday October 06, 2024 @10:43PM (#41762318)
> Don’t get confused between using smaller keywords and actually understanding the problem at hand.

Absolutely. I'm not arguing for maximal terseness and spent a lot of words attempting to say otherwise. (IMHO, we're both reflexively reacting to our parent comments a bit).

What I am wanting to point out is that form affects function and how we think about and use our languages. This in turn shapes our ecosystems and cultures, which influence our heuristics for keeping a pulse on project health and the surrounding support structures. Which all in turn reflect back to affect the forms we like and produce!

The mechanics of middle-sized and large businesses naturally incentivize bloat and churn to some degree, not because we necessarily want those things, but because coordination and communication are large information bottlenecks, a la Mel Conway's observations [0]. When our heads are filled with syntax, tooling, best practices, and absolute ideas about what correct code looks like, we make it that much harder to fill our heads with direct problem-domain concerns.

While senior engineers can and often do successfully wade through all that, it's a long grind, and anything that empowers team members to get there faster seems like an obvious win.

I wish that we as a community could better recognize that our values like "semantics over syntax" or "code review is necessary" or "readability is good" implicitly invoke a large set of contingencies in order to become heuristics that serve well.

Tools that violate our common sense and aesthetic values present an opportunity to sanity check those sentiments and potentially sharpen our understanding of them. In my experience, APL and probably K are really excellent at that, offering a new way of thinking that highlights clear disfunctionalities within our current "mainstream" languages and cultures.

If true, isn't that something we obviously want to eagerly investigate?

So, to bring it back, I think the statement that "AST node count is a better" embodies exactly the kind of values and mindset that make it harder for us to grow. What do we think about readable, maintainable, highly terse code? Does this K sample exemplify that? Why are K and APL successfully (if quietly) running significant portions of our economy? What structural, organizational, and cultural lessons do they embody that we can learn from?

[0]:http://www.melconway.com/Home/Committees_Paper.html

Re:Arthur Whitney's one liner sudoku solver by dahart on Monday October 07, 2024 @04:44PM (#41770833)
I don’t know what you mean, and currently do not agree with the idea of parse tree size being a bad mentality or making it harder to grow, and I don’t feel like you’ve provided any objective evidence to back up that claim. Parse tree size seems like a better metric than terseness, for the reasons I and others have already mentioned, despite the fact that sometimes tight small code has some advantages that might be invisible if your only metric is AST size. (Neither parent nor I made such a claim, but your argument depends on that assumption.) K specifically is unreadable by most people, and somehow examples never seem to come with comments or error handling. Is it the best poster child for programming progress as a whole? I have my doubts, even though it might be very useful for some people in some situations.

I would be willing to bet that Excel spreadsheets are running more of our economy than K code, likely by orders of magnitude. I’d also be willing to bet that COBOL exceeds K use by similar multiples. Business/economic use doesn’t seem like a very good metric for what you’re talking about.

Re:Arthur Whitney's one liner sudoku solver by xelxebar on Monday October 07, 2024 @08:59PM (#41772783)
The original post I replied to made an explicit claim with zero evidentiary support, so your demands for rigor are a bit lopsided. But more to the point, I'm really not saying anything about which metric is better or whatnot. What does it even mean to be a "better metric" when we have no consensus on what criteria we're using for comparison?

In effect, replies here effect to provide some criteria, but each is slightly different and somewhat begs the question, since said criteria can be easily chosen to support whatever conclusion you want.

When the object level discussion (i.e. in this case, the comparison of code size metrics) is ill-defined, the only natural thing we can reach for are cached ideas, heuristics, memetic trends, etc. That is, the discussion essentially becomes an implicit sharing of which cultural ideas we consider salient and important.

That is why I keep going on about culture and values in my previous replies. I'm not saying anything about ASTs vs. token count or whatever. I'm trying to say, "Hey, fellow devs. You know all the obvious ways that K and APL violate our sense of what good and proper code should look like? You know how they feel wrong? Well, actual experience by APL and K devs provides us evidence that we're potentially wrong and should give these languages more open-minded attention."

Re:Arthur Whitney's one liner sudoku solver by dahart on Tuesday October 08, 2024 @12:10AM (#41773743)
All programmers think they have culture and values. Getting them to agree on what those are and to prioritize them the same is the hard part. Having an open mind is great, and if you’d said that from the start I totally would have agreed, but you didn’t, you dismissed the GP’s comment with relatively strong language as being very wrong headed on behalf of the entire community, and doubled down on that stance in your followup comment, without acknowledging (or maybe without even realizing) that the suggestion might ultimately align with your message, that you might be picking a fight with someone who agrees with you. I don’t feel like the top comment required any evidence, partly because the claim is nearly tautological and quite easy to agree with, and partly because it wasn’t shitting on someone specific or being mean. You made a much bolder and more antagonistic claim and called their message a “scourge” and framed your point of view about over-engineering in opposition to their comment (which seems like straw man and very presumptuous), so yes I think your argument does require some evidence if you’re going to do that.

There’s a famous couple of comments by @arcfide defending the extremely terse K/APL style of coding, and it really makes a strong case. From what I can tell, this might be what you’re trying to say. I would just say to take note that he does not try to make the poster of the comment he replied to feel wrong headed, he focuses on the positives of his own approach, and he does not project his style on everyone else or make any claims that everyone should use it, he focuses on why it works for him. https://news.ycombinator.com/item?id=13571159

Re:Arthur Whitney's one liner sudoku solver by xelxebar on Tuesday October 08, 2024 @05:04AM (#41775221)
First off, thanks for continuing this exchange with me. Text communication between strangers is fraught with miscommunication perils left and right, so hanging in there is a really nice gesture. Cheers.

It's so weird, though. Everything disagreeable you point out with my comments, I kind of feel like is true of GP's comment. It casually dismisses the content of OP, injecting a strawman about a "metrics". Wore still, it just touts normative and relatively mainstream opinions about better vs. worse thing, without even offering up a hint as to what these supposed metrics are supposed to be measuring.

That's a dick move, IMHO, and a common one at that in these array language posts. I think we as a community do ourselves a disservice by allowing ourselves to propagate such echo chambers.

Which is all a pretty different message than @arcfide (eloquently) attempts.

Please note that nowhere do I attack GP or GP's comment specifically. If you're inclined to reread my comments, please note that I really do try hard to delineate ideas and cultural trends as the target. Heck, I even own up to being part of those trends and culture. Where you have thought I say "you", try rereading it as "we".

Anyway, cheers!

Re:Arthur Whitney's one liner sudoku solver by dahart on Tuesday October 08, 2024 @10:25AM (#41777731)
I appreciate that your tone is softening with me, and that you took the time to mention some positives. De-escalating from a potential misunderstanding is the right way to go.

I’ve reread your comments, and they still read like an attack to me, while the top comment does not. You may feel like you’ve drawn a line, but the implications you made were quite clear. Calling it a dick move is a more direct attack, and talking about how it offends you tends to demonstrate that you have been and still are in fact attacking. Using strong language in a direct reply and talking about how wrong the mentality is is always going to be taken as an attack on the comment you’re replying to.

Personally I feel like the “one line” part of the article title is intentionally provocative, and as such, it invites critique, which is what the top comment is. It’s both impressive to fit a sudoku solver on one (short) line, and also at the same time, making a claim that can’t be fairly compared to other languages. As such, it is fair to point out that there’s a more universal way to evaluate the size of Arthur Whitney’s solution that is more compatible with other languages, and combined with the fact that everyone (including you?) already agrees that lines of code aren’t a good metric for anything, it’s not clear why you’ve taken such issue with that casual comment.

The article, disappointingly, doesn’t explain Whitney’s solution in words that non K readers can understand. At a glance, I would assume it’s a more or less brute force search over all possible sudoku boards and then matching against the cells, rows, and columns rules. In a way then, Whitney’s solver might be seen as a succinct statement of the rules of sudoku, which are indeed relatively short in any language.

Re:Arthur Whitney's one liner sudoku solver by xelxebar on Wednesday October 09, 2024 @04:10AM (#41785609)
Oh well. It's clear you read my posts as personal or uncouth attacks. I genuinely disagree and tried to explicate intent clearly, but c'est la vie. IMHO, it's helpful to separate out ideas and actions from identity, freeing us to deal with the former without mercy as needed.

That said, this exchange will definitely bounce around in my subconscious, so whether or not I explicitly agree, you've definitely moved the needle!

Anyway, whatever happened here, it was a genuine meeting of minds, so much obliged fellow HNer. Be well.

Re:Arthur Whitney's one liner sudoku solver by skrebbel on Sunday October 06, 2024 @09:26AM (#41757022)
This oneliner was obviously done for the giggles, and nobody pretends it's reasonably readable code. Getting anal about definitions here is entirely missing the point. (which is "look, K lets you write extremely dense code!")
Re:Arthur Whitney's one liner sudoku solver by wk_end on Sunday October 06, 2024 @09:45AM (#41757146)
I don’t know if that’s the case, simply because all code that I see written by array language programmers looks like code golf. Even the language implementation itself!

https://code.jsoftware.com/wiki/Essays/Incunabulum

Re:Arthur Whitney's one liner sudoku solver by mlochbaum on Sunday October 06, 2024 @10:23AM (#41757371)
Is this because all the code you see is through HN or similar? No one's going to share something titled "an unremarkable script I use to help run my business" here. Not sure what your threshold for code golf is, but you can see APL written in a variety of styles by searching Github. It doesn't recognize K but does have Q, which is basically K plus keywords, obviously promoting more verbose code. Whitney originated the dense style of implementation shown at your link, and a few other implementers (including myself in the past) have picked it up, but it's not that common. For example April, GNU APL, Kap, Goal, and Uiua all use an idiomatic style for their implementation languages.

APL: https://github.com/search?type=code&q=language%3AAPL

Q: https://github.com/search?type=code&q=language%3Aq

Implementation: https://aplwiki.com/wiki/List_of_open-source_array_languages

Re:Arthur Whitney's one liner sudoku solver by jodrellblank on Sunday October 06, 2024 @01:12PM (#41758533)
Re:Arthur Whitney's one liner sudoku solver by sorokod on Sunday October 06, 2024 @03:46AM (#41755509)
The LoC count and similar metrics have the advantage of an easy calculation.

Ultimately though,they are a proxy to a more relevant but difficult to determine attributes such as

Given a reasonably proficient engineer, the amount of time it would take them to resolve a bug in code written by someone else or alternatively extend its functionality in some way.

Re:Arthur Whitney's one liner sudoku solver by TZubiri on Sunday October 06, 2024 @07:49AM (#41756461)
I thought it was written by Ursula K. Le guin.

Not sure where I got that from.

Re:Arthur Whitney's one liner sudoku solver by Intralexical on Sunday October 06, 2024 @09:41AM (#41757118)
It may be interesting to compare this one line to "Code Golfed" equivalents in different programming languages:

https://codegolf.stackexchange.com/questions/tagged/sudoku?t...

Re:Arthur Whitney's one liner sudoku solver by forgotpwd16 on Sunday October 06, 2024 @05:05PM (#41760307)
Funnily top[1] solution for specific problem (brute-force Sudoku solver) is the K snippet. Second comes a J solution that replicates K's.

[1]: https://codegolf.stackexchange.com/a/5030