HNHacker News
TopNewBestAskShowJobs

stiff

4,244 karma · joined May 10, 2008

submissionscomments
stiff··on Programs to Read
Most of the kernel code is in the drivers, the general purpose subsystems (VFS, I/O scheduler, task schedulers, memory management etc.) are a small fraction of those 25 million LOC and largely independent of each other so it is not that hard to build some understanding of them.

Some ways you can start:

- Here is start_kernel(), the kernel entry point after booting up and handling the lowest level stuff in asm: https://github.com/torvalds/linux/blob/v4.19/init/main.c#L53...

- grep for SYSCALL_DEFINE to find definitions of syscalls, e.g. this is open(): https://github.com/torvalds/linux/blob/v4.19/fs/open.c#L1076

(understanding how the I/O and networking system calls work is quite helpful for application developers, even if you work in node.js, python or another high level language)

- this is the struct that represents each process in the system, you can pick some interesting field and search for where it is used and where updated: https://github.com/torvalds/linux/blob/v4.19/include/linux/s...

Finally, the linux-insides book is pretty helpful: https://0xax.gitbooks.io/linux-insides/

stiff··on Evolution of Emacs Lisp [pdf]
To read a file into a string you actually do this:

  (with-temp-buffer
    (insert-file-contents filePath)
    (buffer-string))
but if you work with file contents as strings in Emacs Lisp, you are going to have a bad time, because performance of this is terrible enough for it to easily turn into a problem. So instead you insert-file-contents into the temporary buffer and then do a ton of low-level, error-prone imperative processing on the buffer contents itself using things like goto-char, search-forward, using markers etc. Most of the major emacs packages are littered with code like this, here is one random example:

https://github.com/magit/magit/blob/master/lisp/magit-git.el...

It reads like fortran77 to me.

stiff··on Evolution of Emacs Lisp [pdf]
To write code that performs decently in Emacs-Lisp, you have to work with buffer contents rather than substrings, and it is just another frustration, the primitives for working with buffer contents are low level and heavily stateful, you end up writing imperative code that looks a lot like pascal or whatever, while loops conditioned on regexp searches, tons of setq's, moving point and mark around etc. It isn't a convenient way of programmatically modifying text. The basic examples of doing search and replace described here:

http://ergoemacs.org/emacs/elisp_find_replace_text.html

give a flavour of this (and of not having keyword arguments, of libary functions relying on global variables, ...).

stiff··on Evolution of Emacs Lisp [pdf]
If you are used to any reasonably modern programming language, writing any serious Elisp is an exercise in frustration, it is hard to even find out at all how to accomplish basic things, and once you do, there are tons of pitfalls, it is a legacy platform and it feels like its evolution over time was largely accidental. I am talking about doing basic things, working with lists, maps and strings, opening files, running processes, making HTTP requests, etc.

For example, if you want to use a map, you have three choices: you can use alists, plists or hash maps. There are no namespaces in Emacs Lisp, so for each of the three data types you get a bunch of functions with weird names. For alists get is assoc and set is add-to-list, for hash maps get is gethash and set is puthash, for plists get is plist-get and set is plist-put. For each of those types it is easy to find basic use cases that are not covered by the standard library, plus it is easy to run into performance pitfalls, so you end up rewriting everything several times to get something working. The experience is the same across the board, when working with files, working with strings, running external processes etc. There are 3rd party libraries for all those things now because using the builtins is so painful. In many ways it feels like programming some old web browser where you either need to patch the standard libary with 15 dependencies or learn complicated incantations for really basic tasks.

The ideas behind emacs and emacs lisp are great, so I really wish someone succeeded in creating a modern implementation from scratch and it gaining some traction, basically what Clojure did for Common Lisp. By the way even Common Lisp is way more modern than Emacs Lisp...

stiff··on Ask HN: Blogs Similiar to the Old New Thing but for Linux?
I am not a reader of The Old New Thing, but it seems LWN fits what you are looking for:

https://lwn.net/

The page is a bit difficult to navigate, and some articles are subscription only, but see e.g. the articles here:

https://lwn.net/Kernel/

stiff··on Ask HN: What's a starting point for learning how to write programming languages?
Implementing an evaluator for infix parenthesized arithmetic expressions, like "5*(1+2)+60", is a good starting point.

You can begin with writing a tiny lexer and a recursive descent parser that simply writes out the value of an expression that the user typed in. Then you can make it generate assembly for computing the expression instead (hardcoding some further assembly to print the result out at the end of the execution of the program), turning it into either a traditional compiler or a JIT compiler. Once you do that, it should not be too hard to see how to add variables and simple loops. This will already demystify things quite a bit and make further learning easier.

I specifically recommend implementing your own parser and generating assembly on your own, at least if your primary goal is learning. You could instead use an existing parser generator and e.g. a library for generating JVM bytecode, but those ready-made components are high level enough to turn it all into the usual exercise in plumbing libraries together, rather than a learning experience across many layers of the computing stack.

stiff··on A military technique for falling asleep in two minutes
This kind of practice is at least as early as yoga: https://en.wikipedia.org/wiki/Shavasana https://en.wikipedia.org/wiki/Yoga_nidra
stiff··on Ask HN: Resources to learn real analysis?
Springer has problem books with full solutions:

https://www.amazon.com/Problem-Book-Analysis-Books-Mathemati... https://www.amazon.com/Problems-Solutions-Undergraduate-Anal...

The second one is for Lang's "Undergraduate Analysis" book.

stiff··on The duties of John von Neumann's assistant (1993)
It is worth noting that Paul Halmos was an assistant of von Neumann's:

http://www-history.mcs.st-andrews.ac.uk/Biographies/Halmos.h...

stiff··on Brushing up on operating systems and C programming
I like this little book, in very small amount of space it teaches you how to build a bare bones OS, from there you can start doing your own experiments which I think is the best way to really learn something:

https://littleosbook.github.io/

It's good to not only know operating systems in general, but also to understand some of the internals of the operating system you are actually using. For Linux, this is good:

https://0xax.gitbooks.io/linux-insides/content/index.html

stiff··on Norvig's Python programs to practice or demonstrate skills
Peter Norvig has this unique style where he explains his design process in detail, including exploring the problem on example cases, writing multiple solutions, the thinking involved in moving from one solution to the next one, including profiling and finding bottlenecks etc., you see how he goes about problem solving and he is a master problem solver. In fact his writing provides a good opportunity to reflect on what designing programs even means: investigating and choosing trade-offs, choosing an adequate representation (data structure) for a problem etc. This illustrates on a small scale how a lot of the most serious software engineering happens, the engineering where you actually have a definite, hard problem to solve, rather than just making the program pretty by criteria on which there is no agreement etc.

He does this not only in those notebooks but for example also in his "Paradigms Of Artificial Intelligence Programming" book. I have not seen this done to any serious extent in any algorithm textbook or tutorials.

stiff··on Assume positive intent
This is also known as the principle of charity:

https://en.wikipedia.org/wiki/Principle_of_charity

stiff··on Paradoxes of Probability and Other Statistical Strangeness
In probability theory, when dealing with continuous sample spaces / random variables, events with probability 0 still have a chance of occurring, and events with probability 1 stil l have a chance of NOT occurring, see:

https://en.wikipedia.org/wiki/Almost_surely

This strange property comes from strange properties of the real numbers (and uncountably infinite sets) that give rise to things like:

https://en.wikipedia.org/wiki/Banach%E2%80%93Tarski_paradox

Measure theory deals with resolving this:

https://en.wikipedia.org/wiki/Measure_(mathematics)

stiff··on J one-page interpreter fragment (1992)
I did run it back in the day, it works, I think it just happens to assume a 32 bit OS. You can fix the gist by changing this:

  I *ma(n){ R (I*) malloc(n*4); }
to:

  I *ma(n){ R (I*) malloc(n*8); }
Note that it's a very tiny interpreter for a very tiny simple language - it does not have any error handling (it still WILL segfault if you enter "incorrect" programs, where "correct" is whatever doesn't crash the interpreter :)), the letters a-z are the only available variable names etc., this is why it is so short. Once you get over the APLish way of writing the C code, and once you deduce what the operators are intended to do, it's a pretty straightforward C program.

Here is a sample session:

  a=1,2,3
  3 
  1 2 3 
  b=4,5,6
  3 
  4 5 6 
  a+b
  3 
  5 7 9 
This piece of the gist is the "symbol table" for respectively binary and unary operators, you can use it to get started understanding the language:

  C vt[] = "+{~<#,";
  A(*vd[])() = { 0, plus, from, find, 0, rsh, cat},
   (*vm[])() = { 0, id, size, iota, box, sha, 0};
stiff··on J one-page interpreter fragment (1992)
Once you get past the formatting and cryptic variable names it's actually a pretty straightforward program, have a look at one of the older threads if you are interested in understanding it:

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

stiff··on Qualities that I believe make the most difference in programmers’ productivity
Kent Beck has an article that is a nice complement to this one:

https://www.facebook.com/notes/kent-beck/mastering-programmi...

stiff··on Grumpy: Go running Python
It's actually a transpiler written in Python that generates Go code.
stiff··on What Is Abstract Algebra? [video]
estimated that the PS codebase could be reduced from 3,000,000 LOC to 30,000 LOC (=100x!!)

I challenge anyone making such claims to construct an even _moderately_ realistic example of where such reduction would be possible.

Here is a very simple and already very optimistic model that is still way below a 100x reduction: say my program consists nearly exclusively of sorting of various arrays and I write out bubble sort in full each time using for loops etc. rather than call a sort() procedure. Bubble sort takes roughly 20 lines of code to implement, so I would at best get a reduction of close to a 20x, rather than a 100x one.

stiff··on Ask HN: Anything Like Carl Sagan's Cosmos for Computer Science?
The New Turing Omnibus: https://www.amazon.com/New-Turing-Omnibus-Sixty-Six-Excursio...

Algorithmics: The Spirit of Computing: https://www.amazon.com/Algorithmics-Spirit-Computing-David-H...

stiff··on Ask HN: What are some rite-of-passage style projects for programmers?
Those kinds of projects are valuable not because of any significant chance of having to do something similar professionally, but because doing them gives you a fuller and more mature mental model for programming. Doing the larger projects listed will give you deep understanding of the stack (compiler/programming language, operating system, network protocols etc) you are interacting with every day. Especially non-trivial bugs and performance issues tend to test this understanding, and if you go through those kinds of experiences, you will be up for the challenge.

(I have personally done a toy HTTP server, small compiler, neural network, etc. and will be forever grateful I did so)

stiff··on My Top 100 Programming, Computer and Science Books: Part Four
SICP explores real, interesting programs: a digital circuit simulator, an automatic differentiator, etc., in a sense it explores mathematics and electrical engineering in parallel to computer science and shows a certain unity between all three disciplines, at the cost of requiring more background to understand everything.

CTM explores a lot more programming language concepts than SICP, but the examples and exercises seem to be focused on illustrating those individual concepts in the simplest way possible. I think CTM is ultimately a more down-to-the earth book - you are likely to have more immediate direct use for the things you learn compared to SICP, but it doesn't give you this very high level perspective that SICP does.

stiff··on Physical Intuition, Not Mathematics (2011)
Feynman also said the following (in the "The Character of Physical Law" lectures):

Every one of our laws is a purely mathematical statement in rather complex and abstruse mathematics. Newton's statement of the law of gravitation is relatively simple mathematics. It gets more and more abstruse and more and more difficult as we go on. Why? I have not the slightest idea. It is only my purpose here to tell you about this fact. The burden of the lecture is just to emphasize the fact that it is impossible to explain honestly the beauties of the laws of nature in a way that people can feel, without their having some deep understanding of mathematics.

stiff··on What every computer science major should know (2011)
From the article:

I've tried to answer this question as the conjunction of four concerns:

    What should every student know to get a good job?
    What should every student know to maintain lifelong employment?
    What should every student know to enter graduate school?
    What should every student know to benefit society?

For all the four points listed the attitude of focusing on some checklist covering everything is not really the optimal strategy. For graduate school you may need to pass some broad exam, but afterwards in turning towards research you also want to be much more picky about what you choose to learn and stick to learning mainly (but not necessarily exclusively) things that are likely to help your particular goals.

You should think of learning as of investing and learn things that you are likely to have some use for in the future or ones that you simply like learning. Things that you learn but that you have no long term use for or passion for you will promptly almost completely forget and the time and effort you spent learning them will simply be lost.

stiff··on What every computer science major should know (2011)
There is more harm in the notion that there is anything at all that absolutely everyone needs to know to succeed than there is benefit from the contents of such lists themselves (which boil down to "everyone needs to know what I know").

To succeed, all you really need to know is enough to be able to do meaningful contributions to society in any way whatsoever. This is all there is to it and there are thousands of individual paths that lead to this. In fact, many of the most successful people specialize early, devote themselves to a single project or group of projects and spent the rest of their professional lives on it. Do you think John Carmack knows much about visualization, databases or cryptography? Does Linus Torvalds care about Scala, Haskell or Prolog? People love what those guys have created, so they have succeeded, it is as simple as that - nobody examined them for knowledge of 25 unrelated areas, instead they have built for themselves a useful toolkit of skills for their particular goals. It is not worth it to spend your life chasing some abstract platonic ideal of an uberprogrammer who knows everything about anything - in fact such attitude is detrimental to success.

stiff··on Slack was hacked
Please do not do it:

http://stackoverflow.com/questions/16891729/best-practices-s...

stiff··on Machine Learning Done Wrong
If you use performance on the test set for model selection, this is not true. It follows from simple probabilistic reasoning, the more models you try the higher the chance one will score well on both the training set and the test set by "luck", and this is especially true with small datasets. In fact it is a best practice to use a separate validation set for model selection and use the test set only for final performance evaluation, see e.g. the answer to this question:

http://stats.stackexchange.com/questions/9357/why-only-three...

stiff··on Mathematicians who died under unfortunate or unfitting circumstances
Two whole schools of mathematics died in "unfortunate and unfitting circumstances", namely the Lwów school and the Warsaw school:

http://en.wikipedia.org/wiki/Massacre_of_Lviv_professors

http://en.wikipedia.org/wiki/German_AB-Aktion_in_Poland

http://en.wikipedia.org/wiki/Stanis%C5%82aw_Ruziewicz

http://en.wikipedia.org/wiki/W%C5%82odzimierz_Sto%C5%BCek

http://en.wikipedia.org/wiki/Herman_Auerbach

http://en.wikipedia.org/wiki/Stefan_Kaczmarz

http://en.wikipedia.org/wiki/Antoni_%C5%81omnicki

http://en.wikipedia.org/wiki/Juliusz_Schauder

http://en.wikipedia.org/wiki/Stanis%C5%82aw_Saks

http://en.wikipedia.org/wiki/Stefan_Mazurkiewicz

http://en.wikipedia.org/wiki/Adolf_Lindenbaum

http://en.wikipedia.org/wiki/Samuel_Dickstein_%28mathematici...

http://en.wikipedia.org/wiki/Leon_Chwistek

http://en.wikipedia.org/wiki/J%C3%B3zef_Marcinkiewicz

Some members emigrated before or during the war and spread all over the world, mostly in the US. After 1945 almost none of the original members were still alive and in Poland/Ukraine.

stiff··on Tips for Intermediate Git Users
The master tip: have a detailed written policy on git usage, on what goes into which branch, on git commit message format, and make really, really sure everyone understands it before they start anything.

No tips will help if the history is crap.

stiff··on List of Computer Science Courses
ArsDigita Discrete Mathematics course (this one gives a really gentle start):

http://www.aduni.org/courses/discrete/index.php?view=cw

MIT Mathematics for Computer Science (harder but still not that hard):

http://ocw.mit.edu/courses/electrical-engineering-and-comput...

Steve Skienna discrete mathematics course (graduate course based on Knuth's "Concrete Mathematics", quite hard):

http://www3.cs.stonybrook.edu/~algorith/math-video/

I also recommend checking out some books:

http://infolab.stanford.edu/~ullman/focs.html - free "Foundations of Computer Science" book that combines discrete mathematics with C programming and some theory of computation stuff, a pretty good way to make things more practical

http://www.amazon.com/Discrete-Mathematics-Elementary-Beyond... - very pleasant introductory discrete mathematics book, a welcome break from the usual "brick" format and covers some important topics that often do not make it into the normal discrete mathematics curriculum e.g. induction on trees.

http://www.amazon.com/Introductory-Combinatorics-Modern-Birk... - classic introduction to combinatorics

stiff··on What Doesn’t Kill Me Makes Me Stronger
Even if this was true it's ridiculous when taken as evidence for radiation lowering cancer risk:

Survivorship bias (or survivor bias) is a statistical artifact in applications outside finance, where studies on the remaining population are fallaciously compared with the historic average despite the survivors having unusual properties.

http://en.wikipedia.org/wiki/Survivorship_bias#As_a_general_...

← PreviousPage 2 of 23Next →