How Judy arrays work and why they are so fast (2002) - <AUTHOR> http://judy.sourceforge.net/doc/10minutes.htm <comment><USER2> Independent performance comparisons: [https://nothings.org/computer/judy/](https://nothings.org/computer/judy/)

<comment><USER3> This illustrates perfectly the premature optimization paradox, unless having huge datasets and the need to scale towards huge numbers it won't be much worth and still hashing maps are going to outperform Judy in certain use cases. Having clarity of code and being able to patch a critical bug is also a priceless competitive advantage, and to be honest, diving into a 20k line codebase related to algorithmic intensive code just is nothing to be underestimated... I wonder if someone uses Judy in production and if they made also some measurements.

<comment><USER4> I used Judy for spkg (spkg.megous.com), to efficiently store refcounted list of all files on the system in ram. It performed excellently even on 486DX2 CPU with 16MB of RAM for this purpose. Any space saving is great in that situation.

I also use it as part of a custom indexing/inverted index search engine daemon for PostgreSQL, in one of the bookstore e-shops I made more than a decade ago.

<comment><USER3> Glad to read a real world experience from someone. Memory saving is a great point. Did you have the chance to compare it against other structures before you settled with Judy?

<comment><USER4> I compared it with plain newline separated list of absolute paths, and savings were such that I could not imagine beating it with anything else I knew at the time, which would have similar characteristics.

The dataset has a lot of shared prefixes, and Judy excels at storing such data.

It was 15 years ago so don't ask me for details.

<comment><USER3> There is no point to compare it with something from 15 years ago, but in that case, the natural competing data structure would have been a Trie, which would have made searches at logarithmic speed (based on path) and saved as much memory as it is possible.

</comment></comment></comment></comment></comment></comment><comment><USER5> Some previous threads:

2013 [https://news.ycombinator.com/item?id=5639013](https://news.ycombinator.com/item?id=5639013)

2013 [https://news.ycombinator.com/item?id=5043667](https://news.ycombinator.com/item?id=5043667)

2012 [https://news.ycombinator.com/item?id=3675759](https://news.ycombinator.com/item?id=3675759)

2010 [https://news.ycombinator.com/item?id=1419526](https://news.ycombinator.com/item?id=1419526)

2009 [https://news.ycombinator.com/item?id=859336](https://news.ycombinator.com/item?id=859336)

</comment><comment><USER6> See also [https://db.in.tum.de/~leis/papers/ART.pdf](https://db.in.tum.de/~leis/papers/ART.pdf)

</comment><comment><USER7> I read up on these many years ago (around the time of the original essay).. seemed like impressive work.

But are the assumptions made still applicable to newer hardware?

</comment><comment><USER8> In a way Judy arrays illustrate the difference between C's memory model (flat memory) and real hardware (with cache lines).

<comment><USER9> C doesn't have a flat memory model, other than within objects. ISO C doesn't even define the behavior of comparing two pointers to distinct objects for inequality, as in p0 < p1. Only exact equality: p0 == p1.</comment></comment>


College Students Prefer Reading Print Books to E-Readers - <AUTHOR> http://www.newrepublic.com/article/120765/naomi-barons-words-onscreen-fate-reading-digital-world <comment><USER3> I just had a conversation about this last friday with a coworker. We both basically came to the conclusion that the only e-books that work are prose- oriented, not learning-oriented.

With your average novel, you only read from beginning to end, and you only read words. With a textbook, you not only read words, but you read diagrams and figures. You also skip around...you follow footnotes, references, and you also might follow a curricula that was not defined by the author. You will often refer to two or three different hotspots while studying a single chapter...for example, while working on practice problems, you will flip back and forth between the practice problems, the chapter intro, the context for that problem, and possibly a chapter recap.

This user-adoption gap is not one of the underlying medium, but rather of the user interface. Flipping pages one at a time is not sufficient.

<comment><USER4> There are tons of text features that suck or are absent in ebooks. Even footnotes aren't great, let alone things like facing-page translation—or anything else that relies on two pages being visible side by side at once, which is quite a bit if you're reading much outside of mass-market fiction. Plus, yeah, diagrams, figures, _et c._

Poetry often blows in ebook form. A good paper book of poetry has a lot of care put in to precise placement of the text, and it can add a lot to the experience. Ebooks can't do that. Really, any book that benefits from fixed page boundaries has similar problems.

Even one of ebooks' big advantages, full-text search, is worse than using an index unless either 1) you need to search for something that's not in the index, or 2) you're on a device with a full, real keyboard, so not a tablet or eink device.

Ebooks are also very expensive and there's no used market—I'd effectively have to pay ~3x what I did to assemble my physical book collection to replace it with ebooks, provided there were an ebook version for all my dead-trees (not the case). It'd be even worse if most of my books were common paperbacks (the thing ebooks are best at replacing) since you can pick those up for next to nothing if you keep an eye out. 10x the cost to take such a collection digital, I'd imagine.

<comment><USER5> Sure ebooks can have precise text placement, just use a PDF. As for indexed vs full text search, an eBook can have both, and many do.

No argument on the price, though it didn't hold for works out of copyright.

<comment><USER4> > Sure ebooks can have precise text placement, just use a PDF.

Not so hot on most e-ink devices, but yeah, you can use a print format to achieve print-like documents that throw the middle finger at your screen's dimensions/resolution with sometimes-nice results.

> As for indexed vs full text search, an eBook can have both, and many do.

Ah, but their indices are usually more of a pain to use than an index in a real book. Like footnotes, but even worse. As with full text search, though, it might beat the dead-tree if you're on a laptop/desktop (bigger screen that can show the index to the side of the text) but at that point there's not much distinction between an "ebook" and anything else one might read on a computer.

> No argument on the price, though it didn't hold for works out of copyright.

Unless they're not originally written in a language you can read, in which case odds are good that the best translation is still under copyright. In fact, it's not uncommon for there to be _several_ copyright-protected translations all of which are better than any of the public domain ones. So technically, yes, you can go to PG and grab a ton of classics for free. Practically speaking, for non-[language(s) you can read] works, if it's worth putting in the time to read it you'll be well served by buying (or borrowing) a newer translation. All those 19th century ones have a way of being both less accurate _and_ less pleasant for a modern reader.

</comment></comment></comment></comment><comment><USER6> I feel the complete opposite for all of the college textbooks I've used (although all of my textbooks are filled with problems rather than readings).

Using a laptop or e-reader to read textbooks is awesome for a couple of reasons. First off, having multiple textbooks doesn't weigh anything, and I can carry them around at all times. Secondly, when doing assignments and the like, I can bookmark the answer section in the back, and flip back and forth between questions and answers arguably faster than I could with a paper book. Finally, the best part of electronic books is the ability to search through it. Every definition in the book is a Ctrl+F away.

So maybe reading books electronically isn't as great when you're doing a lot of actual reading, but in my experience using more math/science textbooks, electronic wins out every time.

<comment><USER7> You need to have multiple copies open at the same time if you want to refer to different parts at the same time.

Ctrl+f is great, but you end up losing the part of the book you were at before you started searching. So basically I needed to have 4 copies open at a time. 3 for different parts of the book I needed to refer to and one for searching. This made the actual size of the text way too small on a laptop screen.

Some of the problems could probably be solved with bookmarking software, but then you have to remember where each bookmark is instead of glancing at it.

<comment><USER8> Not necessarily. I use the PDF-reader on OSX called Skim and it lets me bookmark the current page I'm on. Then I can just keep clicking the bookmark menu item and switching to the page I need. Only one copy. Each bookmark can have a label. Not too bad.

<comment><USER6> I also use Skim, it works really well. A pretty cool feature is the back and forward buttons, that hold your page if you skip through large chunks. For example, if I use the table of contents (Cmd + Shift + T) to go to the answers section, I can press back to get back to the question I was on. Then forward brings me to the answers once again.

That's basically my textbook workflow 90% of the time.

<comment><USER8> That works too! I really like using Skim. Without it, I would definitely not like reading/doing problems from my textbooks.

</comment></comment></comment></comment></comment><comment><USER9> I think the biggest problem is we are getting e-books that are just digital representations of physical books. I'm learning music theory right now and it would be great if the book I'm following was an app with animated examples to re-enforce the concepts.

I'm also imagining the time I first saw the animated unit circle gif (years after trig class):

[http://i.stack.imgur.com/1oSJw.gif](http://i.stack.imgur.com/1oSJw.gif)

If that was in my "e-textbook", I think some concepts would be easier to explain. I think we are sitting at just the cusp of what "e-books" in school should be. They shouldn't just be for words, but for conceptual learning in a school setting.

<comment><USER4> You seem to be describing web pages. In ~20 years they've had little success in replacing textbooks.

Since they're so obviously superior for that purpose, I can only assume it's because there's not enough money in it for one reason or another.

Seems like some sort of free multimedia web textbooks resource would be a great way to spend public money helping some of those unemployed/underemployed professional scholars and scientists that are often covered on HN. Shouldn't even cost much, as government education expenditures go.

<comment><USER10> My biggest irritation with using web pages for school is that with schoolwork, I am often looking down at my desk with paper and pencil in front of me. Using a website requires me to look up and deal with a keyboard taking all my desk space. It is hard to focus on the work when you are fighting with a computer at the same time.

<comment><USER11> I agree. When the tools get in the way it is very difficult to learn.

</comment></comment></comment></comment><comment><USER12> "In the United States, e-books are less expensive. Students will say, "I'd like to have the print version, but the electronic version is so much less expensive." But if you buy a book used, the publisher and the author are not getting any money but they are getting another reader and they're not cutting another tree. And the cost is less. And if it goes to a third generation the cost is really less."

That's a nice sentiment but there were a bunch of books in college that purposely changed portions from year to year to kill to resale market. Some profs were cool and researched what sections/questions would be so that you could use one of the 3 editions available but others didn't care.

I was happy to get all some of my books in digital form in grad school. Preparing for finals was so much easier.

</comment><comment><USER13> 'they say they get distracted, pulled away to other things.'

This is probably the biggest draw away from e-readers for me and the reason I gave up on them.

For prose, Amazon's Kindle achieved the right form factor, battery life, display combo many iterations ago for me; but I seemingly can't handle having so much information available with a button press. It's just too little effort.

It's one of those oddities of being human, I feel. It seems perfectly possible in theory to learn about a complex field fairly rapidly by simply using Wikipedia and Google, but in practice the discipline required to not wander off-topic I find impossible to manage.

The sort of semi-procrastination that occurs when you're still being productive (because you're still learning), but you realise that you've gone from studying waveforms to ventricular fibrillation.

The thing that's so strange about it to me is that books themselves are alien concepts, there's nothing inherent about them - humans chugged along for millenia without them. Yet somehow, clicking off of an e-book for 'just a few seconds' to look something up seems to function differently to, say, closing one book and opening another.

Reminds me of the Doorway Effect.

<comment><USER13> I've also seemingly paradoxically found that scarcity seems to have a dramatic effect on this.

Immersion, the sense of losing hours to a good book (or a good movie, or video game, etcetera) I seem to find more difficult as availability increases. There's a constant nagging feeling that I could be making better use of that time, that perhaps the next book on Gutenberg would be 'better' (whatever that means).

It's very difficult to really pin down why that is. If I were fantastically wealthy and could buy books by the truckload without even thinking about it, would I feel detached from them all in the same way?

<comment><USER14> What you're describing seems to me like blasé, and it's a fairly well- documented phenomenon.

</comment></comment></comment><comment><USER15> We need a comparison of print, pdf and epub. PDF can retain print layout and typography, which makes a big difference in aesthetics. EPUB still needs work from device makers, to honor embedded fonts.

When the flexible eink screen from the 13" Sony Digital Paper goes mainstream with a bluetooth keyboard and Android clones, students can have access to a large yet lightweight device for reading PDF+epub, handwritten annotations and typed notes.

[http://goodereader.com/blog/electronic-readers/sony- digital-...](http://goodereader.com/blog/electronic-readers/sony-digital- paper-review)

<comment><USER16> That looks Pretty Cool(tm) for dorks, but what's the real advantage over an actual piece of paper? Other than infinite content-to-weight ratio I don't really see the justification for the price tag. It's inconvenient, much heavier than single piece of paper or small magazines, journals, and printed out papers, needs a special pencil, requires charging.

I used to think that something like a Kindle DX would be amazing for reading datasheets while I design circuits, but in reality I need to draw the circuit and read multiple datasheets at the same time. One of these gizmos can't do that. Printing can do that, and at a tiny fraction of the price.

<comment><USER15> No device can compete with the usability of paper. Devices can compete with libraries.

Letter size e-ink pdf readers have long battery life (weeks), no eye strain due to page refresh, security/privacy of cloud-free offline SD card storage, fonts & diagrams in their original layouts, with handwriting annotation that exercises motor memory. The Sony device weighs 20% less than an iPad Air 2 while providing 60% more screen space.

For anyone who travels and needs access to a changing subset of a large document corpus, there are few alternatives. The excessively high price on the Sony device is reportedly due to an exclusivity period (less than a year), because Sony funded research for the new screen. Hopefully cheaper competitors will appear soon. Even at the $1K price, the Sony device is selling far beyond their expectations, into business markets, so they are now selling it direct online.

</comment></comment></comment><comment><USER17> I travel a lot around the world, so I digitalized my entire library, University notes, everything...

I used a Fujitsu ScanSnap(amazing scanner with automatic feeder) to digitalized them using a Wood saw to cut the back of the books. I stored them in boxes in a locker room.

I love it because I control it. I could analyze my documents, I could index them, I could organize them as I want. I could mark them too on my tablet.

Much better than paper.

But most people can't do it(each of my kids going with a USD400 device to school sounds ridiculous to me). A tablet is expensive just for reading, and more expensive if you are going to add an active pen, like I use.

What is quite shocking is that the device I use the most for reading is a new 55 inches LG OLED screen, rotated 90 degrees. I use software that converts black over white "paper" to green on black.

Einks are slow, very bad resolution, monocrome(exchanging resolutions for tones using halftoning), and very small screen.

If only Qualcomm Mirasol or other technologies were cheaper it will be totally different. Not ready yet for the mass market.

<comment><USER15> _> What is quite shocking is that the device I use the most for reading is a new 55 inches LG OLED screen, rotated 90 degrees. _

Is that because you prefer to focus at a longer distance?

 _> I love it because I control it. I could analyze my documents, I could index them, I could organize them as I want. I could mark them too on my tablet._

Do you store them as PDFs? What software do you use for indexing/ocr?

</comment></comment><comment><USER18> >found a near-universal preference for print, especially for serious reading

Is this really any surprise for "serious reading"? Reading a textbook, especially one with lots of graphs, charts, figures, etc., is miserable on an e-reader. I suppose I always assumed that pleasure reading was the most popular use case for an e-reader. Maybe I'm way off.

EDIT: while muddling through this in my brain, I realized that I've been mentally defining e-readers as E-Ink readers.

</comment><comment><USER19> This finding is not surprising and is a result of shortsightedness by technology companies, IMHO. They placed more importance in video games, multimedia than the simple readability of texts. First, they moved away from antiglare, matte screens. They favor flashy, shiny highly reflect displays, which show shiny videos and images very well, can are subpar compared to matte screens when reading in different lighting conditions. Second, they put less money in developing technologies similar to the Kindle readers, which prioritize reading.

I am sick and tired of reading reviews of devices based on their ability to watch videos and play games. I want to get things done. I want screens that do not reflect. I want screens on which I can read comfortably in different lighting situations. Give me those.

</comment><comment><USER20> Well, yes, if you force people to use today's college ebooks. I made the mistake of buying ebooks a year ago. The ones I got forced me to use proprietary crap-ware that hardly worked, let alone worked the way I wanted. Eventually, I downloaded illegal PDF copies of the print versions of the books (that I legitimately paid for!) Using simple PDFs and an iPad was a dream come true. I can't imagine anything better for large, technical textbooks. Unfortunately, the legit offerings from text book companies don't even come close.

Honestly, I'm inclined to look sideways at this article. The college text book industry is just too entrenched and future-phobic for me not to believe that special interests funded these findings.

</comment><comment><USER21> "They run out of battery, they hurt your eyes, they don't work in the bath."

None of that is practically true.

The Kindle can run out of battery but lets face it it lasts weeks so you just need to remember to charge it occasionally. It is unlikely to die on you like a mobile phone.

I am not sure what they mean by hurt your eyes, but the ability to change the font size and still have convenient paging is brilliant. With a paper book you have to don your 2x non-prescription glasses I guess.

And they do work with the operator in the bath, and the eReader just above the surface. Just keep the window open so it isn't too steamy, and have a table ready for when you want to put the reader down (stop reading once your toes start to wrinkle!).

<comment><USER22> Oddly enough, my mother started having problems with eye strain with her Kindle a couple months back. She switched to a high DPI tablet and says it is easier for her. Rather odd since it goes against everything I think I know about eInk versus LCD, but the end user is always right!

</comment></comment><comment><USER23> I'm suprised that no one's mentioned this yet, but I've found that even for linear prose-text, my recall of what I've read is much better with paper books than with ebooks.

My working hypothesis for why this is true is that it's easily the mentally differentiate the paper books I've read: when I try to remember a book, often the first thing that comes up in my mind is the cover art. My mental records of paper books are indexed by a multitude of factors---what the cover looked like, what the paper felt like, approximate size, typeface, etc.---that just aren't there for ebooks

</comment><comment><USER24> At first I was going to agree with this statement; however, I hate carrying all of my textbooks around, and if I have the e-book of the text that means I saved a lot of money. I do love reading paper books, you cannot replace the feeling of holding a paper book in your hands. It is something that I love about paper books. But I really do love the fact that I can have all 5 of my text books in one device that weighs less than any text book I am currently carrying around.

Last semester I had all E-Books and I was able to bring them all with me at work, and I was also able to read them while sitting in my work truck in the dark. This semester I do not have any E-Books and two of my text books are fairly large. Which really sucks, because I hate having a heavy back pack.

All around I do love having E-Books, on the Kindle I can slide back and forth to different sections, high light the pages and everything I do with paper books. I also take notes on paper as I go along with the E-Book, it really helps me to remember certain parts.

I am saying this at the beginning of the semester though, I might change where I stand but I currently love E-books, except when the battery runs out I hate the thing haha. Who wouldn't love to have 6 major textbooks on one device?

</comment><comment><USER25> What this doesn't go into is how the students evaluated such a task

> When students were given a choice of various media—including hard copy, cell > phone, tablet, e-reader, and laptop

How many have actually compared those devices? And what digital format were they using epub, pdf, HTML, txt ?

I have all those devices to try out the same books on. And I'm a student. I would rate them

1) E-reader - least eye strain, good bookmarking, one more device to carry - <USER2> only have one without a backlight

2) Tablet - better pdf support, good bookmarking, backlight is handy, multi function can be a boon and a distraction

3) Hard copy - I still read a lot of paper books - too bulky, I bought a sheet feed scanner just to scan my library and dump it

4) Laptop - at least it's not a phone

5) Phone - too small but I have read whole books using it when I had no option

<comment><USER22> How do you deal with flipping back and forth pages?

For math classes specifically (realistically the only classes that I used a book for), I would frequently flip all around the book, where I was flipping too and from varied per chapter of course. Often times it would be 2 or so locations in the book that had all formula's listed (for the well organized math books!), the n and n-1 chapters text, the page with the current problem set that I was working on, and an answer key in the back of the book.

I guess I could set all of those up as bookmarks, but it'd be a real pain to have to keep adjusting bookmarks every day.

The slow page turn speed is just a killer for e-readers IMHO.

Heck even for large PDFs on tablets I have issues. Right now laptop is about competitive with a paper book (and searching can help a lot, but PDF searching is abysmal in seeming 80% of PDFs), and last time I tried a tablet (about a year ago) they tended to just choke and die on RPG ebooks. (But hey, they are 2x as fast now so maybe things work...)

<comment><USER25> I should have said that my course is Supply Chain Management, so there's not so much page flipping.

But if there was I would probably write formulas down in my hand written notes as I was reading.

</comment></comment></comment><comment><USER26> A few thoughts:

1) Hardware interface: People here are conflating hardware interfaces (e.g., on Kindles) with the data medium (e.g., paper or ebook). For serious knowledge work, such as studying, of course a large screen area (such as dual 22" monitors) and good input (such as a full-sized keyboard) are essential. I think the question is, in that environment, which data medium is better

2) Software interface: How much is an issue of basic interface design. Paper book interfaces have been perfected over centuries; ebook interfaces are still immature. With the right interface, could ebooks exceed paper?

3) Does anyone know if ebook formats combine these capabilities:

* I own the data; it's not licensed to me.

* Open formats, so the book is readable 20 years from now, including the annotations (see below)

* Annotation: I can add notes and associate them with specific locations in the text.

4) An interesting article on ebooks disrupting the college textbook business: [http://www.fastcolabs.com/3028855/why-cant-e-books- disrupt-t...](http://www.fastcolabs.com/3028855/why-cant-e-books-disrupt-the- lucrative-college-textbook-business)

</comment><comment><USER27> Love digital text. The find command saves me so much time than flipping and skimming.

Books with a lot of charts and graphs, it's a hassle even in print. Figuring out the placement so relavent text and visuals can be displayed on a single page would be better, and it would be easier to experiment with the format digitally.

</comment><comment><USER28> It took me several years before I made the cognitive switch to preferring eBooks for large, complex, dynamically accessed textbooks over the paper variant. For the first few years I actually couldn't stand trying to read stuff on my laptop versus a nice healthy paper text book (of which I have about 4 boxes that I've incredibly carefully curated down from around 10 boxes). And even attempting to read them on the crappy kindle technology and laggy ipads just sucked beyond belief circa late 2010. It was probably around 2012/2013 that they became my preferred platform on Laptops. Two things probably changed things - SSDs became commonplace, so load times were instant, and, EPUB/CHM readers got a lot betters - allowing quick hotkey movement back/forth. Now, laptops work great - but tablets (in particular, everything I've tried on the iPad), still lags horribly for textbook reading (though they are great for longform prose - I devour books on my iPad - but it's not clear that the iPad is any better for reading fiction books for me than my iPhone - and I suspect the iPhone 6+ is going to replace reading on both in short form for everything except magazines/comics).

Recently, I purchased the Oreilly 5th Edition "Learning Python" and almost laughed. (A) The book is entirely infeasible to bring with you on a trip, (B) I actually had a hard time navigating it, compared to the electronic version which gives me the quickly navigated TOC on the side.

And, the deal breaker - I carry about 30 commonly used textbooks with me on 9 month+ international engagements, all the time in which I'm constantly moving from country to country. It's hard (but I guess possible) to imagine how I might do that with physical textbooks (Just keep shipping them to the hotels I'm next moving to, and hope I'm there long enough to meet up with them).

But I can think of no conceivable scenario in which I could be using these textbooks on the 22 Hour+ flights that I frequently take.

I'm willing to wager I'll never use a physical textbook again.

</comment><comment><USER29> > There are two big issues. The first was they say they get distracted, pulled > away to other things. The second had to do with eye strain and headaches and > physical discomfort.

These problems may be common with laptops and tablets, but e-readers fix that. You can't get distracted if the device is only capable of reading books, and e-ink screens offer far less eyestrain than typical LCDs.

Personally, I would say that I prefer reading print books over ebooks, but I vastly prefer reading ebooks on an e-reader over reading them on a different device. I also have almost no shelf space, so being able to store hundreds of books on my device is a great benefit. I get print copies of my favorite books, but in general I use the e-reader for everything else.

I have no experience with e-textbooks, however.

<comment><USER30> This is what I don't like about this headline and study. It seems to conflate pretty easily iPads/tablets and "ereaders", because it doesn't look like they only tested e-ink ereaders, but "ebook readers", and many use iPads for reading ebooks. That's how they got the eye strain.

</comment></comment><comment><USER31> We'll know the solution is near at hand when there's a satisfying way to represent a book like "House of Leaves" (colored words, intentionally blank/sideways/mirrored pages, backwards text, and other typographic mischief) or "Gödel Escher Bach" (diagrams, puzzles embedded in formatting, messages riffing self-referentially on the medium in which they're represented). This is apparently a long way off, given that after all these years, the Kindle hasn't even evolved to the point where it can render a page without what is often sparse and uncomely full justification (to the best of my knowledge).

</comment><comment><USER32> Found it weird that the only explanation they could come up with for why students still buy ebooks was "saving the environment". How about the sheer weight of all the books you need to carry to last through a 16 hour flight?

</comment><comment><USER33> The problem with ebooks is the false ownership. I much prefer ebooks, but as opposed to a physical copy, unless I get my hands on the pdf or epub file when I "buy" a book in iBooks I don't actually own that book.

<comment><USER34> This is most apparent with digital textbooks, which are often only sold as rentals for the duration of a single semester. You are paying for the book, except it disappears after a few months.

</comment></comment><comment><USER35> They need an e-ink screen that is big enough to show an A4 PDF. The e-reader (which actually an Android tablet with an e-ink screen) below at [1] is the only one I am aware of, apart from the very expensive Sony legal A4 e-reader.

(I own the smaller version of this e-reader and it is excellent)

[1] [https://onyx-boox.com/shop/onyx- boox-m96-universe-97-inch-e-...](https://onyx-boox.com/shop/onyx- boox-m96-universe-97-inch-e-ink-pearl-display-e-book-reader-google-play-ivona- text-speech-bluetooth-4-0-low-energy-powered-android-4-0-4/)

</comment><comment><USER36> I am not a college student anymore, but I can only imagine the time savings of searching for answers and/or keywords in an ebook when writing a paper or finishing a take home test.

As for the ebook vs print argument as a 29 year old, I always order my books on amazon in paperback or hard copy. I stare at a screen all day, and don't want to sit down for an enjoyable read using the same medium. I also always order used copies of books and the prices are often times $.99-$2.00. Far cheaper than a digital copy.

</comment><comment><USER37> I also prefer print books for in-depth work that requires flipping around between different pages while also working on the computer. There is also something comforting about reading a paper book for fun. My iPad is just not warm and fuzzy.

However, I can't carry my paper books everywhere I go, so I have largely moved to reading by iPad for necessity's sake (I travel quite a bit). Search functionality is awesome for non-fiction how-to books, but my thought process hasn't quite adjusted.

</comment><comment><USER38> I was surprised I didn't see mention of the reason I buy so many books electronically: Impatience. Getting the book now versus waiting a couple days is a big benefit for me.

</comment><comment><USER39> I think part of the problem is that there is no full letter/A4 device that isn't heart stoppingly expensive and hard to actually buy.

I might have most of the texts I need to read in digital form but I'm not going to read it on a tiny eReader meant for pulp fiction and my iPad has too many distractions for me to honestly get through dense centent like text books.

</comment><comment><USER40> "NB: If you're annotating on a Kindle, on a Kobo, you see—you know how many people thought that word was really important, or maybe everybody else liked this passage. If we sat and thought about it, what we think the author has to say. … Rather, we're just trying to present ourselves or fit in."

... who thought this feature was a good idea to build??!!

</comment><comment><USER41> ereaders are a really nice platform but the current problem with ereaders is the lack of tactile feedback, and the difficulty of random seeking.

The first issue is mostly just preference. being able to see how far finished a book you are and the satisfaction of flipping a page is nice, but has little utility.

The second issue is a bigger problem. anything but a linear read from start to finish is difficult on an ereader. the only reasonable use case of ereaders in the current form is reading a novel. anything with a more complicated interaction, such as textbooks where you need to jump back and forth for reference to equations; choose your own adventure books; or books with footnotes or endnotes are severely limited.

I'm not sure if either of these issues can be fully solved, but they will definitely need to be mitigated in the UI for ereaders to have a more sustainable demand.

</comment><comment><USER42> College books on e-readers aren't amazing yet. This isn't very surprising at all.

Novel style ebooks are a great fit for the Kindle reader. Technical books are not so great. I don't think there is a big push to get technical book reading experiences to be super amazing, even with the iPad being so popular.

<comment><USER43> A 10" iPad is still too small to legibly render a typical textbook. It requires a lot of scrolling and/or zooming. If the rumors of a 12-13" iPad turn out to be true, this will certainly be one of its primary uses.

I'd buy one just for reading my large collection of PDFs for tabletop RPGs.

</comment></comment><comment><USER44> It would be interesting to see the comparison done again with a subset of e-textbooks actually designed to take advantage of the platform (and not just be an exported PDF dumped into an azw or epub), like some of the better iBooks examples.

</comment><comment><USER45> College e-texts are typically "rented", the use terms are terrible. Also, exams in courses I teach are almost always open-book, but I don't allow electronic communication devices, which most tablets qualify as.

</comment><comment><USER46> The two (huge) advantages of e-books, for me: 1) physical space 2) abundance of available material.

In a perfect world, I'd own physical copies of all books. But as an avid reader, ebooks have been a godsend.

</comment><comment><USER47> I much prefer printed books, but what I prefer even more than that is the savings of physical space I achieve by having e-books on my iPad instead of print books sitting on a shelf.

</comment><comment><USER48> This does not surprise me - I print all peer-reviewed journal articles I'm giving anything beyond a cursory glance, and generally prefer print editions of journals.

</comment><comment><USER49> Not what I expected at all. I would guess that college students would prefer taking notes electronically rather than writing with traditional pen and paper.

</comment><comment><USER25> Sample size: 300 across four countries.

There are 20 million college students in the US alone.

I don't think that is a large enough sample size.

<comment><USER10> With those numbers, that's about a 5.5% error margin at a 95% confidence level.

<comment><USER25> Assuming the same rate of higher education in Europe, that's another 20m.

</comment></comment></comment><comment><USER50> I've seen a calculation claiming an ebook-reader is better for the environment after 10 books.

</comment><comment><USER51> smart people, good for them!</comment>


Ask HN: Freelancing for equity - <AUTHOR>

Recently one of my freelance clients mentioned they want to offer me some equity in their company. They asked me to make a proposal for this equity deal.<p>Currently we are negotiating a support contract for a web & app platform I have built for them. I was thinking of reserving x support hours every month for the next year or so that are paid for by the equity deal. Is this something that has been done before? How do I define the value of the equity so I can put the correct amount of services against it? <comment><USER2> Have they already paid you the previous work in cash?

Do they have any investors? What was their equity price? How long ago did this round happen?

They will give you the equity in a written contract or only an informal oral promise?

Do you have to pay them ... because they need to ... in order to ...?

Just assume that equity is worthless. The company may flop, the new CEO may be a douchebag and use a loophole to dilute your equity, the fine print legal conditions may have unexpected surprises, ...

Get 95% of the contract value in cash and take a 5% in equity (just in case they are the next Google), but don't expect get too much value from it.

</comment><comment><USER3> It sounds like they're going a roundabout way of getting you to be an employee.

</comment><comment><USER4> Why not try to freelance for lottery tickets instead?</comment>


China factory activity shrinks to six and a half year low as orders tumble - <AUTHOR> http://www.reuters.com/article/2015/08/21/us-china-economy-pmi-idUSKCN0QQ05H20150821 <comment> rm_-rf_slash First off, China has been getting more and more expensive over the years as their labor costs rose and other developing countries started playing the same game. Even Chinese companies outsource to Vietnam, Bangladesh, etc.

Second, China's bigger problem is that they lack sex, and that's not just a dig at the one child policy. Sure, they have some lovely trains and airports, but nobody says "I buy Vietnamese so someday I can buy Chinese." They say "I buy Chinese so someday I can buy German."

China is simply not an aspirational brand. They have plenty of businesses that mirror the West (Weibo for Twitter, Renren for Facebook, etc) which are highly popular among Chinese (because the government often gives them no other choice), but are little more than an eye-roll outside the Middle Kingdom.

Classic middle income trap scenario: too rich to compete by making things cheap, too lame to compete on the high end. I would be interested in hearing a rebuttal, but so far I have been unable to find one, on HN or otherwise.

Edit: Downvoting without giving an explanation doesn't count as a rebuttal. In fact I'm not entirely sure what effect it is supposed to have, aside from making you feel less insecure about your own opinions ;)

<comment><USER3> You could make many of the same arguments about Japan post-WWII. As I understand it, Japan stopped exporting as many low quality, low-margin products during the 80s (largely due to the Ministry of International Trade and Industry), and was able to very quickly gain a good reputation and brand. I've heard they had a similar reputation to China before this.

China has been well-aware of this impending trend, I'm sure they can make similar shifts. I think it's happening to some degree - I'm already impressed with some Chinese companies, like Xiaomi.

<comment> rm_-rf_slash Xiaomi is a good example and I intentionally left it out so someone smart could mention it ;). The engineering is quality, and I can see it becoming popular outside of China.

Regarding manufacturing quality and the similar trajectory, you are correct. But in the 80s and onward it wasn't just electronics we were getting from Japan. Anime, jpop, ramen, sushi, all of these cultural products - <USER2> couldn't quite be emblematic of anywhere else - made Japan a soft power juggernaut.

Can China do the same? I'm not sure. Part of being cool is the ability to say "fuck the man," whoever that is and in whatever way, but dissent is too tightly managed for such an entity to be both globally enjoyed and accepted by the state, lest others start asking questions about the way things are run.

<comment><USER4> Japan has always been fascinating to the West, from the moment Perry told them to open the hell up. Japan has such an interesting wacky culture, architecture, art, lifestyle. They've always had craftsmen the like of whom can compete with the Germanic countries; something which few countries can say. When it came time to industrialize, Japan was able to build very advanced stuff on their own- the Zero, for example. And they make fantastic movies!

The Japanese language is also not super hard for the West to pronounce, and it is even possible to learn it. The writing system(s) are a bit confusing, but we can pronounce it. Contrast that with Chinese, and especially Chinese music. Yeah, no. The operative question: Is there any reason to learn Chinese apart from making money?

Taiwan, on the other hand, is an interesting place. Really good food, and it's going to experience a major boom as a travel food destination in the near future.

<comment> rm_-rf_slash Spot on. Especially about Taiwan. It's not that "China" is culturally lacking, it's _Mao 's_ China, where the exact people capable of stimulating culture from the ground up - intellectuals - were killed off if not dead from starvation.

But Japanese being easier to learn than Chinese? I'm in shock: I've always found Chinese to be simple and Japanese to be mind-bogglingly impenetrable, even if I like it more.

<comment><USER5> It is mind boggling that the Mao-created famine that killed 40 million was only ~50 years ago.

<comment><USER6> I suppose if you're young enough. I was born in the middle of the Great Leap Forward, but very fortunately in the US, came of political age during the middle of the Cultural Revolution (which we're now learning, which should be to no one's surprise, slaughtered and maimed millions) ... and all this was brought into sharp relief when Nixon sundered the PRC from its alliance with the USSR and went to China in 1972. Only someone with his impeccable anti- Communist credentials could have pulled off that essential victory in the Cold War (with, of course, the aid of the USSR, which offered us co-dominion, to take out the PRC's nukes and rule the world together, at least for a while; we declined and took that offer to Mao and company, who by then were not surprised). So the politically aware of my generation and older know this sort of thing, and know the leadership of the PRC is today only somewhat less murderous.

</comment></comment></comment></comment></comment></comment></comment><comment><USER7> This is big news, as it might signal that the Chinese economy is coming in for a hard landing.

<comment><USER8> This is bad new for everyone. China's economy is a the only thing that is driving global demand - at least for the last few years after the financial crisis.

<comment><USER9> From what I've read on Reddit (so take it with a grain of salt), a lot of companies have recently been switching from having their goods manufactured in China to in the U.S. Due to falling oil prices it doesn't work out much more expensive, and the benefits from not having to wait 6+ weeks for a shipment that may or may not be correct out weight the price difference.

<comment><USER10> Apart from naive tribalism, is there any reason people so interested in "driving manufacturing back to the US"? Isn't it better to let it happen in whatever country buyers prefer to buy from? Maybe America doesn't need to make so many low-tech products anymore. Maybe it can cope with ongoing unemployment better than China can.

<comment><USER11> > Apart from naive tribalism, is there any reason people so interested in > "driving manufacturing back to the US"?

Stimulating local economy?

<comment> saiya-jin that is interesting only if you are US resident, which many of us are not :)

<comment><USER12> Well, the people interested in "driving manufacturing back to the US" are mostly US residents.

</comment></comment></comment></comment></comment></comment></comment><comment><USER13> Maybe this downturn isn't actually a huge deal? Wait until the quarterly service sector numbers next come out and see if they follow suit.</comment>


How Big Tech Built the Iron Cage - <AUTHOR> https://www.newyorker.com/culture/cultural-comment/building-the-digital-iron-cage <comment><USER2> Zuboff theory that Google and alike live from the metadata exhaust, not from the data itself, explains the lack of respect for the valuable data contributed by the users. [https://link.springer.com/article/10.1057/jit.2015.5](https://link.springer.com/article/10.1057/jit.2015.5)

<comment><USER3> I've always found that the key realization is that on the whole things _aren 't_ "valuable data". Very few data points are actually valuable.

We call it valuable data to feel good about it and indignant about howe we're treated. Coming face-to-face with the possibility that our individual data is worth essentially nothing is uncomfortable.

<comment><USER4> Individually, mostly valueless. But in aggregate, the emergent patterns are hugely valuable. Just as a litterer is fractionally culpable for worsening the earth, our data is fractionally responsible for the wealth of these companies, and for the same reason shouldn't be dismissed as worthless.

<comment><USER3> The flaw in the analogy being that litter builds up additively. User data is more like a square law effect.

You're completely right, of course. One user's data isn't worthless and should never be dismissed. Yet in financial and practical terms its value far closer to zero than to any useful unit of account.

</comment></comment></comment></comment><comment><USER5> The most shocking of this all is that these big tech companies are communicating in a way you see in dictorial countries. There is hardly any dialog possible. Disputes are ignored. the right to a fair dialog and the principle of an adversarial process is completely ignored by these giants. And that is quite a bad thing. We see it now happening quite often with smaller but also bigger companies. Sooner or later even individuals will get to face the strong negative influence these companies can give. For many centuries we killed each other to fight for proper humane rights. Individuals but also companies. And now some kind of new virtual world is created where local laws are completely ignored. Not good!!!

<comment> spaced-out All corporations in the US act like mini-dictatorships/oligarchies.

<comment><USER6> Comcast was always terrible, but at least I could call up their support desk and make someone answer for their bad service. Sometimes they even fix the problem!

You can't call anyone at these new companies.

<comment> spaced-out Not true, I've dealt with Amazon support and I thought it was better than dealing with my bank or cable company.

<comment><USER7> As a product buyer? AWS customer? Or vendor?

As an S3 customer for web hosting, I couldn't understand why I was paying 10 cents a month for EC2 charges since I don't use it. They just refunded me an entire month, but I really wanted to know what was happening!

<comment><USER8> I suspect that on Amazon's scale, it's probably cheaper for them to toss refunds at customers than to actually fix problems.

Having a first-tier CSR click a dashboard button costs them the 10 cents per month plus 25 cents of labour to pay the guy to read the complaint, find the button, and press it.

Opening a ticket for a well-paid engineer to actually dissect the billing system and figure out where the 10 cent charge comes from, develop a fix, push it through validation and deploy it, probably costs $300.

<comment><USER7> Oh, I'm sure. It worked out great for me, but it probably affected all S3 public web hosting users.

Though i'd Estimate a fix costs at least 10x $300, if not 100-1000x.

</comment></comment></comment></comment></comment></comment></comment><comment><USER9> The core issue with governance that arises regardless of paradigm, in my opinion, is over-centralization.

Now it seems that we have technology behemoths superceding government and centralizing control of our economies.

I like to call them "technopolies". They are successful largely because they are so all-encompassing over particular areas. The problem is that they are private profit driven entities and so the playing field, though large, is not fair, and core functions lack competition.

Eventually all-encompassing decentralized public technology platforms should be able to supercede the technopolies. This way we can have systems that operate holistically in a way with majority networks but without the private centralization of control.

That is not to say that it is going to be easy. But it's the only viable paradigm that could replace the Iron Cage.

<comment><USER10> So do you think it's more about breaking down the (centralized) big dogs or supporting the (decentralized) smaller startups. This Iron Cage is full-on dystopia. I really can't believe we're letting it happen!

<comment><USER9> I think we need to promote startups and companies in general that are built on public decentralized protocols. Breaking up monopolies without having the public platforms available could just lead to other technopolies popping up to replace the old ones.

</comment></comment></comment><comment><USER11> I wish that these critiques grappled with the ways that so many of the services that we now resent were truly embraced by many because they seemed magical when they appeared.

</comment><comment><USER12> I wonder if Shoshana Zuboff will be able to resist the 7-to-8-figure offers she's already received and will continue to receive from Facebook et al.

</comment><comment><USER13> We need better software alternatives, not regulation. That's how we beat IE, and that's how we beat AOL, Britannica and so on and so forth.

The problem is a lot deeper: [https://qbix.com/blog](https://qbix.com/blog)

<comment><USER14> Part of what undid IE was literally antitrust regulation...

<comment><USER13> What about AOL?

</comment></comment></comment><comment><USER15> Completely absent from this narrative is a discussion about the immense value people get out of these technologies and what people like the author propose as a replacement.

The internet and "tech giants" have given us the ability to put our thoughts out to a global audience, stay in touch with friends and family around the globe (for free). Take and store a near infinite number of photographs. Order a car to your front door and have the destination chosen before hand without having to negotiate with your driver...

Tech is awesome, life is good. Yes the East Coast old media companies hate that they've lost their gatekeeping power but plenty of us would see that as yet another benefit of tech empowerment.

The cost? You give up some privacy. Only no one cares about that. Most people don't have anything to hide from advertisers. Most of this personalization tech doesn't even work. I've literally never seen an ad so enticing that I've clicked on it.

Normal people love their technology and the "issues" outlined in this piece and the book it's discussing are those of the old money elite and their loss of power, not those of the masses who are more empowered by tech than ever before.

<comment><USER16> > Only no one cares about that.

I really wish people would stop saying this. It is a completely idiotic statement. There are hundreds of people throughout history that quite literally gave their lives for privacy, as recent as one generation ago. Complacency and the silent majority does not equate to "no one cares about that" otherwise, you wouldn't have so many privacy centers and advocacy groups throughout the country.

> Most people don't have anything to hide from advertisers.

"'I've Got Nothing to Hide' and Other Misunderstandings Of Privacy" [https://scholarship.law.gwu.edu/cgi/viewcontent.cgi?article=...](https://scholarship.law.gwu.edu/cgi/viewcontent.cgi?article=1159&context=faculty_publications) It's a good read, and I hope it convinces you otherwise that privacy is as important as ever, even in lieu of fallacious "nothing to hide" arguments.

From the paper, the easiest way to debunk the "nothing to hide" argument is to ask easy questions.

"I've got nothing to hide." "OK, so why do you have curtains or blinds in your home?" "OK you have nothing to hide, so can I see your past credit card statements?"

If we all have nothing to hide, why don't those interested in our private lives show us theirs? It's the ole "Show me yours and I'll show you mine" adage.

<comment><USER17> I think it's very fair to say that your average user absolutely does not care about privacy past catastrophic and specific leaks or revelations based on their own private data.

Wether that's wise or not is definitely up for debate. I think we'd be much better off instilling a higher value for privacy than we'd be trying to legislate and regulate the problem away. Companies will find ways to skirt legal measures, but an evaporating user base cannot be ignored.

<comment><USER18> The reason they care about "catastrophic and specific leaks or revelations based on their own private data" is because that is the only time the average user notices how much information they cede to these platforms.

If the general public truly understood how much information they give up and how valuable that information is, people would begin to take these things more seriously.

Users are conditioned to allow access to GPS and Camera without thinking for the sake of using specific features of an app. Combine that with maliciously impenetrable ToS and its hardly surprising that people give away their information so freely.

<comment><USER19> >The reason they care about "catastrophic and specific leaks or revelations based on their own private data" is because that is the only time the average user notices how much information they cede to these platforms.

Because the instances of tangible harm coming to someone from data leaked by Facebook et. al. are few and far between.

>If the general public truly understood how much information they give up and how valuable that information is, people would begin to take these things more seriously.

I think it's intellectually lazy to think that people disagree with you because they don't have all the facts. Most people are aware with the amount of data collected on them. They are somewhat bothered by it, but not bothered enough to make a lot of changes.

<comment><USER18> >Because the instances of tangible harm coming to someone from data leaked by Facebook et. al. are few and far between.

Not sure what makes you think this considering the fact that lately there has been at least one data leak outrage story every week from Facebook alone.

>I think it's intellectually lazy to think that people disagree with you because they don't have all the facts. Most people are aware with the amount of data collected on them. They are somewhat bothered by it, but not bothered enough to make a lot of changes.

I appreciate you calling out my platitude but it is funny that you decided to answer with one equally lazy. How do you know? In my experience most younger people are aware, but for people of my parents generation this stuff is a complete mystery.</comment></comment></comment></comment></comment></comment>


Great international electronic music to enjoy while coding on a Sunday night - <AUTHOR> http://alienairmusic.com/

<comment><AUTHOR> I figure there's some folks out there that will enjoy these tunes. It's made working late Sunday one of my favorite parts of the week...

The site's not much to look at, but I don't think you can find such diverse music in one spot. I've been listening to him for years (he used to be followed by a show with 3 hours of underground hip-hop, but no longer; didn't know how good I had it back then).

On from 9-11pm PST on Sundays, streams from a couple of places - kxlu.com is a good place to start.</comment>


Fibers: An Elegant Windows API - <AUTHOR> https://nullprogram.com/blog/2019/03/28/ <comment><USER2> Ouch. POSIX did an awful job when it wrote the API for "makecontext". You can't even pass a pointer to the context's function in the natural way, because only 'int's can be passed, and on any real computer, sizeof(int) < sizeof(void*)!

And anyway, POSIX removed makecontext in POSIX.1-2008 so new code shouldn't be using it. This is too bad, as there are legitimate reasons to use these kinds of cooperative threading abstractions. I guess we still have gnu pth, which hasn't seen a release in 13 years, but it also has a much bigger (pthreads- like) interface compared to the mere 3 functions in POSIX for cooperative threading.

<comment><USER3> That's too bad indeed. How would one implement coroutines in Linux/Unix today then?

<comment><USER4> Usually using C's `setjmp()` and `longjmp()` functions (but I consider that an ugly hack). I did an implementation for both x86-32 and x86-64 [1] that works for Linux and Mac OS-X that's for C (written in assembly). I doubt it will work for C++, and I'd be a bit hesitant to use it for production, but it's surprisingly simple.

[1] [https://github.com/spc476/C-Coroutines](https://github.com/spc476/C-Coroutines)

Edit: clarification of what language my coroutines are implemented in.

</comment></comment></comment><comment><USER5> Fibers have some annoying edge cases related to thread local storage, which can bite fiber unaware code. Which is why Microsoft recently added User-Mode Scheduling, which behave much closer to actual threads, except that they still have the manual yielding behaviour of fibers.

[https://docs.microsoft.com/en- us/windows/desktop/procthread/...](https://docs.microsoft.com/en- us/windows/desktop/procthread/user-mode-scheduling)

<comment><USER6> That's because what you need is Fiber-local storage no?

<comment><USER7> What happens when you call an API that isn't fiber-aware and uses thread-local storage in its implementation?

Basically your entire stack needs to be fiber-aware, or you can't use them.

</comment></comment></comment><comment><USER8> > POSIX certainly has its own ugly corners, but those are the exceptions. In > the Windows API, elegance is the exception.

Makes me wonder how seriously OP used POSIX APIs, and across how many platforms... because large parts of POSIX are pretty bad. And as an OS interface, the Windows API is clearly superior in almost every regard (if there wasn't this tiny portability issue).

<comment><USER6> I don't know what parts of Win32 you mean, but one task I did recently that should be dead simple was listing the contents of a directory. Why did I end up appending "* . *" (spaces inserted to avoid triggering HN's italic formatting) patterns to the directory name, and why do I need to find the first file with FindFirstFile() and all the remaining files with FindNextFile()? Maybe I was particularly dumb that day, but it's the best I could figure out and I don't think that's elegant.

<comment><USER9> > Why did I end up appending "* . *" (spaces inserted to avoid triggering HN's > italic formatting) patterns to the directory name

Because sometimes you just want get all the XML files in a directory, and it's nice to not have to filter yourself.

> why do I need to find the first file with FindFirstFile() and all the > remaining files with FindNextFile()?

Why do you consider this a poor API and what would you consider a better API?

<comment><USER10> What is the important of distinguishing between the first file and files that follow it?

Why not FindFile()?

<comment><USER9> How would FindFile() work then?

As far as I can see, either you have some separate call to initialize the find handle (just like FindFirstFile does), or you pass the directory/filename mask redundantly over and over again, introducing the potential for suddenly calling it with an already initialized find handle but with a different directory.

<comment><USER8> The classic UNIX approach would of course be making FindFile non-reentrant and not thread-safe either, then later adding a FindFile_r which takes an void* * where FindFile_r will store some intermediate state that you need to free yourself except when an error occured, because when you free it then you get a double free. (However, not all UNIX systems have FindFile_r, and some of those instead have FindFile2 with slightly different semantics).

<comment><USER6> You are snarky, but I don't think it's warranted. Any examples of non- reentrant or thread-unsafe system calls in POSIX?

There are a few _library_ calls that have a cousin with an _r suffix in POSIX, but these are not system interfacing calls. Just don't use them if they don't match your requirements. Most of them aren't even non-reentrant or thread- unsafe, but simply lack an additional parameter for some use cases (the use cases mostly come when you program in object-oriented style).

The one offender (not a system call, either) that I know from the top of my head is strtok() which is of course terrible, but why would you use it?

<comment><USER11> _"There are a few library calls that have a cousin with an _r suffix in POSIX, but these are not system interfacing calls."_

Neither are most Windows functions. _FindFirstFile_ , for example, is defined in _kernel32.dll_ , and calls through to _ntdll.dll_ , and eventually makes system calls such as _NtOpenDirectoryObject_ and _NtQueryDirectoryObject_.

What IMO matters is the usability of the stable API. It doesn't matter whether that is the kernel interface or not.

<comment><USER6> Yes. The distinction I made was meant to be between calls that end up calling into the system and ones that do not (like strtok()). I agree with what you say and my statement was exactly that the stable APIs into the system offered by POSX are mostly unproblematic.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER12> It's not that elegant.

Win32 fibers can't return like UNIX/ucontext.h supports with the uc_link member. So you end up having to wrap your win32 fiber functions with your own trampoline to let them return without exiting the program and Do The Right Thing.

Furthermore there's this thread-global fibers-enabled state win32 toggles with ConvertThreadToFiber() requiring any transparent coroutines library supporting win32 fibers to carefully initialize once per thread while also supporting reentrant use. It's mildly annoying when you want to generically support things like nested bundles or heirarchies of coroutines.

This last bit seems completely strange considering a fiber's state should be a subset of what forms a thread, and you're always running on a thread. There should be nothing to do when "converting" to a fiber. Just make the fiber state always accessible to userspace via GetCurrentFiber() and always allow calling CreateFiber() and SwitchToFiber().

Another strange wart in win32 fibers is the C srand()/rand() state is per- fiber for some reason. It's undefined by C since C says nothing of coroutines, but it's very strange and generally unexpected behavior to see your coroutines producing identical sequences of values coming out of rand().

On *NIX the rand() state is per-process, pthreads share user memory so they all share the rand() state, and ucontext shares the thread so of course its contexts share the single state as well.

I much prefer the UNIX/ucontext API, they just fucked up the operands for makecontext(). Instead of deprecating ucontext POSIX should have just fixed makecontext() to explicitly take a pointer. C programs have no supported system-supplied coroutine API on UNIX now, which is bullshit.

</comment><comment><USER13> Hmm, let's read this one.

> "March 28, 2019"

> "Fibers: the Most Elegant Windows API"

> "The Windows API — a.k.a. Win32 — is notorious for being clunky, ugly, and > lacking good taste. Microsoft has done a pretty commendable job with > backwards compatibility, but the trade-off is that the API is filled to the > brim with historical cruft. Every hasty, poor design over the decades is > carried forward forever, and, in many cases, even built upon, which > essentially doubles down on past mistakes. POSIX certainly has its own ugly > corners, but those are the exceptions. In the Windows API, elegance is the > exception."

I'm glad OP just discovered in mid-2019 an API that has been there since Windows XP (ca. 2001). Why then, does OP start by crapping all over the Windows codebase?

You think the Fibers API is elegant? Have a look at IOCP. IO in Windows in general actually, since the days of Windows 95. Event management. Threading and parallelism. The kernel subsystem. The APIs in Windows have remained stable, consistent, forward and backwards compatible - from pretty much day one.

<comment><USER14> IOCP is particularly strong when you compare it to select, poll, epoll, kpoll, and all of the other attempts to make asyncio work in Linux.

<comment><USER15> Eh. I used to think that, until I actually wrote event systems based on all of the above. epoll turns out to be my favorite.

Buffer allocation with IOCP feels incredibly ugly. You must allocate a buffer before you initiate a read(), and then you must leave that buffer alone until the read() completes. You would _think_ that this has the advantage that the kernel doesn't need to allocate its own buffer, and you get some sort of zero- copy magic where bytes land directly in userspace. But that's not really the case. The socket still needs a buffer on the kernel side in case bytes arrive while no read() is pending. So now you have to allocate a buffer for each socket _and_ the kernel also has to allocate a buffer for each socket, which seems like a waste.

This rabbit hole gets deeper. What happens if the socket receives two packets in rapid succession? In a naive implementation, the first packet completes the read(), and signals the completion on the IOCP. The app now has to process that event and start a new read() when it's ready. But in the meantime, the second packet arrives. Whoops, no read() is pending, so now the packet has to go into a kernel-side buffer only to be copied later.

But that's a naive implementation. Apparently, in reality, the kernel implements some sort of nagle-like algorithm where it tries to wait a bit for additional packets before it actually signals completion of a read(). But this introduces delay, and many projects (e.g. Chrome) have discovered this delay is rather harmful to certain kinds of performance. I read somewhere that Chrome and others have given up on IOCP and use WSAPoll instead -- but I can't remember where I read this because all the lore about Windows event handling is hidden in random forum threads and Github gists rather than proper documentation.

It seems to me that the _right_ way to do what Windows was trying to do here would be for userspace to allocate a ring buffer for the kernel to use, and then the app and the kernel would coordinate the start and end pointers of the ring buffer. Then the kernel needs no buffer of its own; it can always deliver to userspace. If the buffer fills up, the kernel can do exactly what it would do in the case of a regular kernel-side buffer filling up -- apply backpressure and force the peer to retransmit later.

<comment><USER15> I should add: Even what I wrote above is not the whole story. The deeper you get into kernel internals, the more you realize that the story is nuanced.

On Linux, apparently, the kernel does not actually allocate static socket buffers. Instead, the "socket buffer" is actually something like an array of pointers to packets. When the read buffer is empty, it's not taking any space.

So on Linux, an idling socket is very cheap (by my understanding, at least).

The Windows kernel might do something similar internally (I don't know), but there's no way to avoid the redundant buffer on the userspace side when using IOCP.

So basically, it seems that IOCP turns out to be a rather-poor interface for networking in practice, despite at first appearing theoretically superior.

<comment><USER16> I've never used IOCP, but my understanding is that they can sort of emulate readiness notification (as opposed to completion notification) by passing a 0 sized buffer. On the callback then you would perform the (non-blocking) read yourself.

In general I think that readiness notification is superior to completion notification for network reads. Completion notification works fine for network writes and it is superior for disk IO (where readiness is ill defined).

The biggest advantage of IOCP though is that it basically acts as a dynamically sized threadpool, as it keeps the amount of running threads to a minimum. MacOS does something similar with GCD. I still haven't found a non- hacky way to do the same in Linux (you can sort-of emulate it with either with sched_fifo realtime threads or by using sched_idle to detect idelness).

</comment></comment></comment></comment></comment><comment><USER17> I recently had an idea about an app and a clever way to hook it into fairly modern, user-facing parts of Windows and macOS (Search/Cortana and Spotlight, respectively.)

I did some feasibility research on Windows first, and very soon hit some ancient win32 interfaces I had to implement, used by parts of the shell that have existed since the earliest days, something I have no intention of wasting my time on.

I was under the impression that macOS would be much better, but was surprised to find that there's no public or documented API, just a 3rd party open source framework implemented as a hack that combines javascript and python somehow, but seems to get the job done.

This got me thinking that you need a serious amount of expertise to implement new experiences on modern operating systems, never mind crossing platforms. Puts the appeal of technologies like Electron that do platform integration for you in perspective.

<comment><USER18> On Windows, you do need some effort if you have no idea what is going on, but it isn't like those systems were sloppily put together, there are some design ideas and you get used to them... eventually. But once you do, things more or less fall into place.

A biggest issue with working on older Windows APIs is that modern web-based MSDN documentation is simply awful and the best you can do is to find old MSDN CDs/DVDs that often contained more information than the site (especially articles), better organization and -especially- _much_ faster interface (being local and all, but also the cdroms around late 90s / early 2000s were in CHM format are lightweight). And 99.999% of the documentation you'll find on these CDs will have the same text as the documentation (if it still there) on MSDN (and very often the same text that is on the much older WinHelp WIN32SDK.HLP files too).

Like most things Microsoft on desktop, everything went downhill since .NET people took over and decided to redo things their way (yes, .NET brought some nice things too, but it created an internal schism - before .NET became a thing, desktop tech in Windows was mostly coherent) and now history is repeated with UWP.

<comment><USER19> Totally agree. I worked for a while with pure Win32. Once you get the hang of it it's quite consistent and pretty well thought out. Also agree about the documentation. Seems MS is determined to make it worse every year, break more links and provide less useful information. The old MSDN CDs were a piece of beauty.

<comment><USER20> Consistency?

Let's start with strings...

\- the standard null terminated single byte char C string

\- the double wide null terminated C string required for dome frameworks - especially Windows CE

\- the COM BSTR where the first two bytes are the length

\- the ATL bstr_t

\- CString that isn't a null terminated C string

\- of course the C++ string class. I'm not sure if this is ever used by the Win32 APIs

I'm sure I'm missing one.

<comment><USER21> If you count various flavors of UWP (C++/CX, C++/WinRT, WRL) you can add std::wstring and Platform::String^

<comment><USER22> Don't forget HSTRING, which Platform::String^ is built on. They added those two in Windows 8 because there was no one standard string type. (Not joking.)

</comment></comment></comment></comment></comment></comment><comment><USER16> I wouldn't call it elegant at all, the convertthreadtofiber is a pain for a library. I like swapcontext much more in theory.

In practice the issue with swapcontext is that it does not integrate well with the rest of posix (what happens if you move a fiber to another thread?) and the requirements to restore the signal mask pretty much require a very slow implementation.

On the other hand, Windows Fibers are somewhat efficient (one can still do significantly better), but most importantly, the interaction with the rest of the system is well understood.

I wrote my thoughts on the API here about (/checks calendar) 13 years ago: [http://www.crystalclearsoftware.com/soc/coroutine/coroutine/...](http://www.crystalclearsoftware.com/soc/coroutine/coroutine/fibers.html)

</comment><comment><USER7> Fibers still have a lot of problems. They're incompatible with any APIs that have thread affinity. Windowing, single-threaded apartment COM, CRITICAL_SECTIONs, etc...

</comment><comment><USER23> I just fell in love with that API. That's seriously the first thing windows has which I really REALLY wish linux would just copy as is. It's simple and to the point, but there's nothing missing either. Perfect.

<comment><USER6> I once built something on it and remember it as quite a nice experience.

</comment></comment><comment><USER24> How do you manage stack memory (allocation, increasing capacity, freeing, moving, etc.)? Is it possible to suspend a fiber to disk?

<comment><USER5> A Fiber has its own OS stack and cannot outlive the process (just like a thread). So the memory cost is the same as a normal thread. The main difference is that it uses cooperative scheduling.

</comment></comment><comment><USER25> The big news seems to be that makecontext et al are deprecated. Does anyone know why that happened? Lots of "green threads" / coroutines implementations are based on it.

<comment><USER16> Basically their signature can no longer be expressed in ISO C, so instead of fixing it POSIX decided to just deprecate them.

</comment></comment><comment><USER26> FWIW Russ Cox wrote a similar API on top of the -context() calls named libtask.</comment>


The Dark Side of Nobel Prizewinning Research - <AUTHOR> http://www.france24.com/en/20151004-dark-side-nobel-prizewinning-research <comment><USER2> The problem is the idea that the worth of a scientist or their work can somehow be established by a title, prize, medal. Much less that the Nobel Committee members don't conform to the circa-2010s leftist/progressivist political bias.

People are very quick to delegate the responsibility to decide whether things are worth our while to somebody, anybody, lest we actually have to do the evaluating ourselves. Has it won an Oscar? What is the most popular SQL database? Which University has the highest ranking? Has his work been published in a respectable journal? All of these questions are a sub-optimal proxy for "is it the best?" or even a more modest "is it any good?"

But with the reverence to the Nobel Prize, it's maybe even something else. It's the human longing for an ultimate authority, for some priest who would tell us what is good, and what is evil. In that case, I'm glad the author feels frustrated.

</comment><comment><USER3> I can't figure out what they're implying about Norman Borlaug's award at the end... that it was a mistake too? Either way, the NYT had a much better critique of why big scientific prizes are bad:

[http://www.nytimes.com/2015/10/03/opinion/the-folly-of- big-s...](http://www.nytimes.com/2015/10/03/opinion/the-folly-of-big-science- awards.html?smid=tw-nytopinion&smtyp=cur)

<comment><USER4> Seeing that the French are one of the biggest opponents of GM technology and this a French article, I assume that "genetic crossbreeding" (what does "genetic" mean here? It's just "old" cross-breeding) is implied to be a bad thing. It rather reflects badly on the author.

If you haven't heard of Borlaug, he's one of my scientific heroes - it's due to his work that Mexico's food production turned completely around, from wheat importing to wheat exporting. He did this by essentially reversing natural selection: each wheat plant in a field competes with the other for light, so while humans plant them close to each other each generation will grow higher and higher. This removes resources normally used for the generation of seeds, so you get less grain. He crossed dwarf-varieties with high-yielding varieties, so you got smaller plants which had more resources left over to make grains, thereby greatly raising the amount of grains you get out of each plant. No modern GM needed for this one.

He's estimated to have saved roughly a billion people form starvation and IMO fully deserved his Nobel Prize.

(As an addendum, DDT isn't as bad as initially thought - if you use it indiscriminately in the outside like they did initially, then it's a huge health concern as it accumulates in the food chain. But if you use it targeted inside homes it's highly effective, and it's still used for that today)

Edit:

>Yet in November 1945, just three months after atomic bombs were dropped on Hiroshima and Nagasaki, the Nobel chemistry prize honoured the discovery of nuclear fission.

This is an error that makes the article's point here moot - Hahn's Nobel Prize is the Nobel Prize of _1944_ (so before the a-bombs were dropped), it was just awarded in 1945.

</comment></comment><comment><USER5> Why should we care how the science was applied?

'"Once the rockets are up, who cares where they come down That's not my department," \- says Wernher von Braun' \- Tom Lehrer

<comment><USER6> If it can't be applied for anything useful, was it really a scientific breakthrough?

</comment></comment><comment><USER7> We changed the URL from [http://phys.org/news/2015-10-dark-side-nobel- prizewinning.ht...](http://phys.org/news/2015-10-dark-side-nobel- prizewinning.html) to something more readable that appears more legit. If there's a canonical URL for the article, please let us know.

<comment><USER8> I think

[http://www.france24.com/en/20151004-dark-side-nobel- prizewin...](http://www.france24.com/en/20151004-dark-side-nobel-prizewinning- research)

may be the original.

<comment><USER7> Ok, we changed to that from [http://www.ndtv.com/world-news/the-dark-side-of- nobel-prizew...](http://www.ndtv.com/world-news/the-dark-side-of-nobel- prizewinning-research-1225911).</comment></comment></comment>