News for hackers. Stuff that matters.
Re:For Donald Knuth, good coding is synonymous with beautifu... by bbbobbb on Thursday April 16, 2020 @01:18PM (#22891504)
What does it mean though? What programs? I can't write new programs at work where I maintain existing applications for the most part.

What kind of programs, not for the sake of programs, can you actually write almost daily?

Re:For Donald Knuth, good coding is synonymous with beautifu... by nickdrozd on Thursday April 16, 2020 @02:12PM (#22891978)
I think what he has in mind are small programs that do some kind of nontrivial computation without much in the way of IO or UI. For example, [1] is a program from December 2019 that "finds n-bit binary squares that are palindromic".

A great way to get into this kind of thing if you're stuck for ideas is to go through the Online Encyclopedia of Integer Sequences [2] and just write little programs to print out the first n entries or whatever for a particular sequence. As other comments have suggested, don't worry about making them perfect, just get the numbers right and then move on to the next one.

[1] https://www-cs-faculty.stanford.edu/~knuth/programs/squarepa...

[2] https://oeis.org/

Re:For Donald Knuth, good coding is synonymous with beautifu... by paganel on Thursday April 16, 2020 @02:50PM (#22892268)
> is a program from December 2019 that "finds n-bit binary squares that are palindromic".

No dis-respect for Donald Knuth (who of course I found orders and orders of magnitude above programmers such as myself) and no dis-respect to people that found those types of programs interesting, but there are also programmers (like me) for whom those programs are just simple riddles, with almost no interest whatsoever.

They're like sudoku or crossroads, interesting and somehow intellectually stimulating but they don't help shape/change/modify the world around us. And I got hooked on programming when I realised how it could help me change the world around me and most of all how it could help me (and others) in trying to make sense on said world that surrounds us.

Re:For Donald Knuth, good coding is synonymous with beautifu... by samatman on Thursday April 16, 2020 @03:07PM (#22892425)
Well, yes, of course.

The question was about the sort of little programs someone could write daily, and the answer resembles crosswords or sudoku, which many people are in the habit of completing once a day.

Would completing one integer sequence algorithm (brilliant suggestion btw!) change the world around you? No, of course not.

Would it make you a better programmer, though? Certainly it would. Which would mean, when you settle down, crack your knuckles, and start changing the world, you'd do a better job of it.

Your objection strikes me as that of a hunter who won't go to the range, because when he fires his rifle, he wants to put meat on the table!

Re:For Donald Knuth, good coding is synonymous with beautifu... by saagarjha on Friday April 17, 2020 @03:21AM (#22896923)
> Would completing one integer sequence algorithm (brilliant suggestion btw!) change the world around you? No, of course not.

Depends on the sequence, of course. I hear a lot of people would be interested in a fast algorithm for computing membership in OEIS A000040.

Re:For Donald Knuth, good coding is synonymous with beautifu... by remcob on Thursday April 16, 2020 @03:20PM (#22892532)
> They're like sudoku or crossroads, interesting and somehow intellectually stimulating but they don't help shape/change/modify the world around us.

I don't think this is accurate: sudoku and crossroads have deterministic known solutions. Solving them is a mostly mechanical feat and indeed somewhat useless beyond the joy of solving.

In contrast, the challenge of creating these sorts of programs is creative and open ended. It is very well possible that someone will come up with an even more efficient algorithm. Or a much simpler one. Or just a completely new strategy.

As to the usefulness, these little toy programs are a constant source of inspiration for solving actual real world problems. A perfect example of this is Algorithm X. One of Knuth's toys that solves Sudoku puzzles. The same algorithm is easily adapted to solve scheduling problems and actually is a major innovation.

Re:For Donald Knuth, good coding is synonymous with beautifu... by boomlinde on Thursday April 16, 2020 @07:25PM (#22894615)
No one was holding their breath for a program that finds n-bit binary squares that are palindromatic, but this kind of mucking about can be useful as exercise and as a source of new insights, both of which will aid the programmer in achieving more ambitious goals.

The musician doesn't noodle around randomly or repeat uninteresting exercises with the ambition that that in itself is going to constitute a meaningful and memorable work.

Re:For Donald Knuth, good coding is synonymous with beautifu... by cdrini on Friday April 17, 2020 @08:03AM (#22898262)
I think others have already done a good job of describing how programs like that help make you a better programmer, and can be inspiring.

I'd like to add that something that I find interesting and inspiring about programming is managing complexity. That's something that's not as easily explored with programs like the above. But for example, you could try to create as much of a spreadsheet program as possible in a few hours. Do that 4 times starting from scratch. How can you organise the code in such a way to make it easy to read, performant, maintainable, and fast to write? What language features will you take advantage of? Maybe try making a part of a word processor, an IDE, a raytracer, an HTML viewer, an FTS engine, a relational database, etc. Try implementing mvc, or reactive, or two way binding UIs. I would consider these sort of a different genre of poem, that let you explore a different problem space. Maybe this might be the genre that you're more interested in?

Re:For Donald Knuth, good coding is synonymous with beautifu... by superpermutat0r on Friday April 17, 2020 @07:25AM (#22898050)
Checkout his latest fascicles on applications of zero-supressed binary decision diagrams to all sorts of problems. From beautiful tiling problems to travelling salesman.

His latest fascicles are bleeding edge when it comes to a general algorithm that solves a wide variety of problem instances very efficiently. (much similar to his Algorithm X, but superior in almost every way)

Re:For Donald Knuth, good coding is synonymous with beautifu... by svat on Friday April 17, 2020 @12:40AM (#22896249)
When the very adjacent sentence is “Poets have to write poems”, I think this question is like asking “what kinds of poems, not for the sake of poems, can you actually write…”, then ask about how they change the world, etc.

Even poets don't write poems just for the sake of poems — they write because it gives them pleasure, because they are moved by some strong feeling or because they have some irresistible urge to say something, etc. (And sometimes because they're being paid for it, or hope to be.) Anyway, here are some reasons (in no particular order, and not mutually exclusive—there's some overlap) for Knuth to write programs:

1. Because it gives him pleasure.

2. Because he wants to find out the answer to some question — for instance, how many knight's tours are unchanged under a 180° rotation?

3. Because he wants to experiment or gain more experience with some algorithm(s) or method(s) that he's learning or writing about.

4. Because he wants to collect data on their performance, so that as a scientist when he makes a statement like “a program using this algorithm finds the answer for N=13 using only 0.3 billion memory accesses”, it is a correct statement.

5. Because he wants to understand something better (e.g. his program for linear programming where he says he understood the simplex method clearly only after implementing it).

6. Because he wants to "debug" or interactively see what sub-components of some algorithm do.

7. Because he has encountered (or been posed) a hard problem and wants the challenge of solving it.

8. Because he has seen a beautiful program and wants to translate it to his preferred style, as he'd like more people to appreciate its clever ideas. (E.g. his reimplementation of the original "Colossal Cave Adventure" game of Crowther and Woods.)

9. Because he wants to provide this program as an illustration of some idea or algorithm mentioned in his books.

10. Because someone has asked him for the program.

One can easily imagine more reasons. Though at the rate of five a week it would be more than 7500 programs over the last 30 years, he has given a few examples on his webpage: https://cs.stanford.edu/~knuth/programs.html (Many of them are in CWEB so to help people who don't have `cweave` installed, I typeset them in 2017: https://github.com/shreevatsa/knuth-literate-programs/tree/m... — I ought to update the repository sometime.)

Re:For Donald Knuth, good coding is synonymous with beautifu... by fooker on Thursday April 16, 2020 @05:16PM (#22893663)
Well you can write an interpreter or a compiler for a simple language you design.

You can try to make text-based games.

You can make a bare-bones browser.

You can write a simulator for ..say.. classical mechanics.

Are none of these interesting for you?

Re:For Donald Knuth, good coding is synonymous with beautifu... by freddie_mercury on Thursday April 16, 2020 @11:33PM (#22895963)
You can't really write five of those in a week.
Re:For Donald Knuth, good coding is synonymous with beautifu... by RMPR on Friday April 17, 2020 @03:59AM (#22897093)
500 lines or less, hold my beer.
Re:For Donald Knuth, good coding is synonymous with beautifu... by danielscrubs on Friday April 17, 2020 @05:24AM (#22897485)
Is this your way of saying you're a programmer not a computer scientist? Because his job is as a scientist.

Calling his exercises simple riddles is disrespectful. It's like calling doing a 5km run every morning, simple walking. The proof is in the pudding, he has impacted the world in a profound way.

But on a more positive note. Which non-cs programmer heroes exists today? I'm thinking John Carmack.

Re:For Donald Knuth, good coding is synonymous with beautifu... by paganel on Friday April 17, 2020 @05:52PM (#22903314)
Yeah, of course I have never thought as myself as a computer scientist, I like my job/title as a programmer, I don't see any downside in that, manipulating data is fun.

I don't personally have "programmer heroes", maybe it's because I'm 39 years old and as such I haven't believed in cowboy-like programmers for almost a decade now. I did strongly believe though in what Aaron Swartz used to do and in what he used to believe, i.e. an open internet and open data for almost everyone, but that dream died in the late 2000s - early 2010s and I don't think we'll ever going to get close to anything like that ever again.

Re:For Donald Knuth, good coding is synonymous with beautifu... by danielscrubs on Saturday April 18, 2020 @02:32AM (#22905773)
No one said anything about cowboys? Just shining examples of programmers.

Maybe you are your own hero?

Re:For Donald Knuth, good coding is synonymous with beautifu... by vbezhenar on Friday April 17, 2020 @05:46AM (#22897582)
Many people praise Fabrice Bellard. Not sure if he's counted as a non-scientist, but his achievements are astounding.

Although I think that many heroes are hidden behind corporations. Those people who contributed most to Google Search or architectured Chrome. Those people who built systems everyone relies on. For example almost every Java project uses Spring Framework, but I'm sure that it was founded by one or few very talented people. And those examples are many, but not very public or exposed.

Re:For Donald Knuth, good coding is synonymous with beautifu... by danielscrubs on Friday April 17, 2020 @06:22AM (#22897731)
Fabrice Bellard seems like an awesome guy!

Do you guys think programmers don't recognise each others work as much as in other fields?

Re:For Donald Knuth, good coding is synonymous with beautifu... by vbezhenar on Friday April 17, 2020 @09:18AM (#22898702)
I don't really know much about other fields. Do architects recognize those who architected outstanding projects, like huge bridges and tallest skyscrapers?
Re:For Donald Knuth, good coding is synonymous with beautifu... by tonyedgecombe on Friday April 17, 2020 @10:54AM (#22899468)
There were quite a few people on the burnout[1] thread that wanted to change the world.

[1] https://news.ycombinator.com/item?id=22876241

Re:For Donald Knuth, good coding is synonymous with beautifu... by Ragib_Zaman on Thursday April 16, 2020 @02:28PM (#22892100)
Along these lines, Project Euler is great.
Re:For Donald Knuth, good coding is synonymous with beautifu... by tgvaughan on Thursday April 16, 2020 @04:36PM (#22893274)
So is the blog "Programming Praxis". Its author has been posting short and interesting programming exercises at least once a week, but often more, for years.
Re:For Donald Knuth, good coding is synonymous with beautifu... by hackermailman on Thursday April 16, 2020 @08:02PM (#22894871)
Of course the answer for OP is reading and working through taocp, that practice makes you better which is why Knuth spent his life writing these books even if technically, they are as the Knuth states just a study of 'alg a compared to alg b' the byproduct is more practice that OP is looking for.
Re:For Donald Knuth, good coding is synonymous with beautifu... by winter_blue on Friday April 17, 2020 @09:12AM (#22898654)
I feel like solving leetcoe problems would fall somewhere in the category of programs you're describing. (They seem like small problem solving programs.)
Re:For Donald Knuth, good coding is synonymous with beautifu... by gen220 on Thursday April 16, 2020 @04:11PM (#22893000)
You can write "meta" programs that help you maintain existing applications.

Whenever I start at a new company, before I get thrown into the heart of things and become "too busy" to write these kinds of programs, I like to write things that automate the boring stuff.

Some recent examples:

- a cli for inspecting, adding comments to, and updating the status of JIRA tickets. because our hosted JIRA instance was god-awful slow and their web interface is a mess. - a tool for monitoring things and pinging me with macos native notifications when things crash or complete.

Was my net productivity positive for writing these tools? hard to tell.

There are some companies full of engineers whose actual job is to write tools like this; I'm not sure what they would do for fun :P

Re:For Donald Knuth, good coding is synonymous with beautifu... by 0x445442 on Friday April 17, 2020 @10:26AM (#22899226)
> There are some companies full of engineers whose actual job is to write tools like this; I'm not sure what they would do for fun :P

I think there are a lot of organizations that would be better served devoting more resources to the meta work given the labor and infrastructure costs. I would go out on a limb and say the capital expended on the majority of projects I've worked on in my career had a smaller ROI (because it was negative in most cases) than would have been the case had the organization just invested in improving internal tools and processes of their existing systems.

Re:For Donald Knuth, good coding is synonymous with beautifu... by gen220 on Friday April 17, 2020 @12:26PM (#22900377)
I totally agree with you. I think that most corporations are in a state of suspended myopia.

We’d rather direct engineers to improve the effectiveness of a single system by 200% (even though it impacts 1% of revenue), than to impact all (or many) systems by 5%.

Yet, most of the impressive software we admire today was built in the environment you prescribe. C and UNIX, famously, but also git, Go, Rust. I imagine many others.

How much has C improved productivity, over Assembly and COBOL? How much has Borg or BigTable?

The issue, IMO, is that no ambitious manager wants to invest the social capital in defending and advocating for these teams, because they don’t look good until they look exceptionally good.

Re:For Donald Knuth, good coding is synonymous with beautifu... by mmcdermott on Thursday April 16, 2020 @02:48PM (#22892254)
I find lots of little utilities fit the bill. They are oftentimes sufficiently narrow in scope to be of little use to anyone but the author, but that shouldn't necessarily eliminate their use.

For example, here is a Gist with a shell script I wrote that, given a set of Maven coordinates, works with a few other tools to build out a docset for use in Zeal / Dash.

https://gist.github.com/michaeljmcd/5564758537946963e946806e...

I had to dig into some corners of Maven I didn't know well to pull it together and it formalized some random bits of minutae.

Nothing elegant or crazy, perhaps, but it is a bit of coding apart from the normal day job that taught me a couple of tricks.

Re:For Donald Knuth, good coding is synonymous with beautifu... by thewebcount on Friday April 17, 2020 @01:43AM (#22896544)
I find myself writing debugging tools all the time. For example, our logs are overwhelming because our developers use them for debugging and then never remove their logging statements. So finding anything in them is next to impossible, and it's often interleaved with a bunch of other junk that's meaningless to you. And fixing the logging system we use would to make this work better would also be a huge task.

So a little while ago we needed to log some info to figure out where 2 parallel sets of calculations were going wrong. So I wrote some logging that output the info to a file instead of the main log, and then wrote a simple parser to read them in and display them side-by-side in a nice hierarchical tree structure. It made something that normally takes us a week to work out only take a few hours. It's something we'll never ship to customers, but helps us enormously.

I'm finding myself writing more and more stuff like that these days.

Re:For Donald Knuth, good coding is synonymous with beautifu... by stjohnswarts on Friday April 17, 2020 @05:59PM (#22903369)
You might also try to get your QA process to require removal of debug print messages or at the very least an "off" flag as an environmental variable or config file element
Re:For Donald Knuth, good coding is synonymous with beautifu... by gowld on Thursday April 16, 2020 @02:05PM (#22891928)
We're business application/infastructure maintainers, not programmers. It's a different world from Knuth's expressions of mathematical ideas.

Outside of work, it's easy to write whole programs. Project Euler, LeetCode, etc. These are the kinds of programs Knuth is talking about -- example programs to illustrate algorithms from TAOCP.

Re:For Donald Knuth, good coding is synonymous with beautifu... by bbbobbb on Thursday April 16, 2020 @02:39PM (#22892183)
I understand that but those don't fall into the "not for sake of programs" category.

Under that category, I imagine something where the resulting program itself is of any, however minuscule, use to me.

Re:For Donald Knuth, good coding is synonymous with beautifu... by mark-r on Thursday April 16, 2020 @04:34PM (#22893259)
Stack Overflow is a great place to practice writing short programs or even just code snippets. Just look for interesting problems and solve them.
Re:For Donald Knuth, good coding is synonymous with beautifu... by tcgv on Friday April 17, 2020 @12:46AM (#22896281)
I'm a frequent user of SO, but I find leetcode [1] much better when I just want to practice coding / problem solving. Their free account is more than enough to have some fun ;)

[1] https://leetcode.com/

Re:For Donald Knuth, good coding is synonymous with beautifu... by thewebcount on Friday April 17, 2020 @01:38AM (#22896526)
I disagree. Leetcode and related sites have problem descriptions that are often vague or nonsensical. Just figuring out what the author is trying to say is more of a challenge than the actual program sometimes.
Re:For Donald Knuth, good coding is synonymous with beautifu... by RMPR on Friday April 17, 2020 @04:03AM (#22897109)
I feel exactly the same, I thought that it's because I'm not a native speaker, at least now I know that I'm not alone.
Re:For Donald Knuth, good coding is synonymous with beautifu... by pletnes on Thursday April 16, 2020 @06:08PM (#22894064)
There’s a few utility functions that come to mind. Git hooks, for example.