Show HN: Zen Text - Beautifully simple text authoring - <AUTHOR> http://zentext.heroku.com/

<comment><AUTHOR> I spent Friday afternoon and a bit of Saturday hacking this together and am wondering if anyone else finds it useful / has any ideas where to take it from here.

For those interested, it is using Heroku for hosting (obviously), Sinatra, MongoHQ, Google OpenID (via ruby omniauth gem), the ruby dropbox gem and Google Web Fonts.

Edit: Sorry, forgot to add it is only really styled for webkit

</comment><comment><USER2> Nice demo.</comment>


Teaching AI to Play a Platform-Fighting Game Using Genetic Neural Networks - <AUTHOR> https://medium.com/@mikecazzinaro/teaching-ai-to-play-a-platform-fighting-game-using-neural-networks-ef9316c34f52 <comment><AUTHOR> Hello Hackernews, This is my first time posting here and this is a write-up of an AI i'm writing for the game I'm developing. I'm not here to try and market or anything and the article isn't really about the game it's more about the struggles of applying machine learning practices to AI in games. I'm no expert in the field and i'm sure people will have a lot of suggestions on what to try. I read a lot of the machine learning articles here so I thought I'd help contribute, let me know what needs work and what should be improved upon.</comment>


Le Wagon Is an Impressive French Coding Bootcamp for Entrepreneurs - <AUTHOR> http://techcrunch.com/2014/11/27/le-wagon-is-an-impressive-french-coding-bootcamp-for-entrepreneurs/

<comment><USER2> Very cool to see coding ability turning into a new commodity - and a game changing one.</comment>


How Universities Work, or: What I Wish I'd Known As a Freshman - <AUTHOR> http://jseliger.com/2010/09/26/how-universities-work-or-what-i-wish-i%e2%80%99d-known-freshman-year-a-guide-to-american-university-life-for-the-uninitiated/ <comment><AUTHOR> A bit of background: I wrote this because a lot of my students say things like, "You teach AND take classes?" and call me "Dr." or "Professor" when I'm technically not, although many of their other instructors are PhDs and professors. As noted in the essay, such experiences made me realize that I didn't know a lot about universities when I started in one either.

So now I direct people who ask me what this grad student business is to the essay, which has been on my private course sites for a long time but which I've finally decided to make public.

Note: if you have feedback, I'd love to hear it, especially if you're an undergrad (two of my former students read "How Universities Work" and said it made sense; the changes that resulted were relatively minor). If you want to send msgs privately, try seligerj [[at]] gmail --dot-- com.

<comment><USER2> Since you asked for feedback...

Your statement that all T.A.s do care _a little_ about teaching is false. I was a T.A. that Did Not Care. There were no consequences to doing poorly, and student grades were controlled across T.A.s so my performance could have no affect on student performance.

Also? Be nice to your T.A. Sometimes I was allowed to wildly inflate grades for students who were enthusiastic/tried hard. Sometimes not. But it can't hurt.

Another random piece of advice I would give is for students to take sections later in the week rather than earlier. My first section was always a disaster, I had no idea what I was doing.

If there is a rubric, follow it to the letter, and don't try to be creative. Rubrics are for larger classes to make the grading even, and they are followed exactly. I knew an A paper from a B paper, but sometimes A papers got Bs and B papers got As because of the stupid rubric (or worse...)

<comment><AUTHOR> _Your statement that all T.A.s do care a little about teaching is false._

From the essay:

 _To be sure, there are exceptions: some professors will be hostile or uninterested regardless of how much effort a student shows, and some will be martyrs who try to reach even the most distant, disgruntled student. But most professors are in the middle, looking for students who are engaged and focusing on those students._

</comment></comment></comment><comment><USER3> Spot on. The 'how do I get an A' question always seemed to be on the lips of everyone who never seemed to want to do the thing consensus reality suggested you might have to do to get one (turn up, pay attention, work hard, ...)

Computer Science, particularly, has a problem with bright students who managed to blaze through their first-year courses with a 4.0, expending absolutely no effort at all. This is because they already know how to program and are often inculcated with enormously broad knowledge of CS as compared with their peers.

Many of them also know dangerous portions of typical second-year subjects - e.g. just enough to regard their second-year algorithms or operating systems courses as 'oh, this is just like first year, I know this'. Unfortunately, this often refers to the first 20-25% of the course, not all of it, and maybe not even that.

Some of them never quite seem to recover and start regarding the marks they get as arbitrary personal judgements of their character ('you gave me a bad mark because I'm smarter than you and you hate me') or as failings in the system ('you gave me a bad mark because this course is in ML and ML is stupid').

Naturally none of this is helped by the fact that there are copious actual failings in the system. The hours of my software engineering course spent on the waterfall model (back in the early 90s), or mind-numbing lectures on the Seven Deadly Layers of OSI, are hours I'll never get back...

<comment><USER4> Don't first year CS courses usually share the same maths classes as first year engineering? Pretty difficult to "blaze through" that purely on prior programming knowledge (believe me, I tried and almost got kicked out of the course I did for failing maths).

<comment><USER3> True enough. I mainly meant 4.0 in their CS courses, although some have overlap between advanced HS math and first-year university math.

<comment><USER4> My fault I think, being British I have no idea of the significance of the 4.0 thing :-)

</comment></comment></comment></comment><comment><USER5> One thing I would add is that if you have any interest in graduate school, it's important to become involved in research ASAP. Research experience is an important differentiator on grad school applications and scholarships, but it's a rare school that will warn you about that before senior year, when it's already too late.

<comment><USER6> Any tips on landing a decent internship position in researches headed by different universities? I am currently attending an institution where the highest level of education offered is a masters... so there's no research going on here. But I do live nearby a univ. where there is. Do I just e-mail one of the professors there, speak a little about myself, and just sort of say "I'm interested in becoming involved in the research you head"?

And actually, furthermore _deciding_ what sort of research I should get myself involved in. Does it even matter? -- in line of what jseliger and pg said about choosing majors -- that it doesn't matter, because the more important skills are easily translatable into different fields.

<comment><AUTHOR> "Do I just e-mail one of the professors there, speak a little about myself, and just sort of say "I'm interested in becoming involved in the research you head"?"

Funny -- I actually wrote another essay called "How to Get Your Professors' Attention" on this subject. Some friends are reading it right now, and I wrote it in response to some of the things I've read on HN.

In any event, if you're trying to get in another lab, I'd try something like this:

1) Find the list of the profs and/or their websites.

2) Look at their research. You might not understand a lot of it, but try to get a sense of what they're doing.

3) Try to read some of their recent papers. You might not understand a lot of them, either, so look at the bibliographies: figure out if there are any seminal papers in the field that are cited that you might have a better shot at understanding. Alternately, try to look for a more accessible source of information on the topic. Profs at your own university might be good for that.

4) _Then_ send them an e-mail saying, "I'm interested in subject X and read Y and Z. I've done A and B to learn more about this subject. Can I drop by your office hours to talk it over with you?"

Almost all profs will have office hours.

5) Part of your goal should be to signal that you're not going to waste the prof's time. One way you can do this is by showing that you've invested some amount of your own time. Profs quickly discover that most people who claim they want to learn don't and that most people who implicitly claim they won't waste their time will.

If you want to see a draft of the essay I mentioned, send me an e-mail.

 _Does it even matter? -- in line of what jseliger and pg said about choosing majors -- that it doesn't matter, because the more important skills are easily translatable into different fields._

Look for what interests you, and do that. What you major in does matter somewhat -- if you want to be an economist, I wouldn't recommend that you single major in art history, and if you want to be a psychologist, electrical engineering might be less useful than some other fields. But people say things like, "You'll be unemployable if you major in X," or "smart people only major in Y," and in those senses what you major in doesn't always matter.

When in doubt, build your reading/writing and math skills, since those are applicable to nearly everything.

<comment><USER6> >If you want to see a draft of the essay I mentioned, send me an e-mail.

Sure, I'd love to have a look at it. I've just sent you an e-mail (on your gmail address listed on your blog-site).

Thanks!

<comment><AUTHOR> I sent it.

Oh yeah -- also see pg's undergraduation: <http://paulgraham.com/college.html> , which is on point here. I think in some essay he points out that if you want to work in a lab, you need to convince the prof that you'll be a net decrease in work. This is harder than it might appear.

</comment></comment></comment></comment></comment><comment><USER7> Another thing: assume that the people designing the curriculum _might_ possibly know a little more than you do about what subjects are useful later on. I.e., don't say stuff like this:

"But why do I need to learn about matrices? I'm a meteorology major! We don't use matrices at all, it's all just partial derivatives!"

(This is an actual complaint I received when TAing ODE's, which was required by the meteorology major. I didn't even bother explaining how you discretize a linear PDE into a system of ODE's, or why that matters for weather prediction, I just referred her to her department head. )

<comment><USER5> By the time I reached the senior year of my EE degree, I was terribly impressed with how neatly the prerequisite courses slotted into requirements of later classes. It's a shame that the reasoning is opaque until you've already been through the program. If I was in charge of the program, I'd give every freshman a manual summarizing the content of each class up to the junior year, and why they should know it.

<comment><USER8> Something like this would certainly have helped me during high school and university, but I suspect schools may view it as competing against themselves by showing students all they need to know, thus allowing them to skip school and learn the exact same material on their own.

<comment><AUTHOR> _I suspect schools may view it as competing against themselves_

This kind of thought process is strange to my way of thinking but plausible; very few teachers I ever had said, "Hey, this is why we're doing what we're doing and why it's important," which is part of the reason I make a point of saying exactly that in the classes I teach. One favorite question: "Why are we reading this, as opposed to something else? What are you supposed to take from it?"

 _by showing students all they need to know, thus allowing them to skip school and learn the exact same material on their own._

This seems implausible: if students came in already well-prepared or overly advanced for the classes I teach (chiefly Engl composition), I'd be delighted. By now I've taught about ~250 students, and somewhere between 1 and 6 haven't really needed a comp class. Probably only 1. But I can guarantee that more than 6 have _thought_ they didn't need a comp class...

HN has a lot of talk about being self-motivated, and learning on your own, and so forth, which I think is great. But standing in front of a classroom makes me think that the number of people who will really do this is not very great, especially without deadlines and so forth to motivate them (for more on this, see Dan Ariely's book _Predictably Irrational_).

That's not to say the number of very self-motivated people who could acquire the knowledge that school imparts on their own is zero. It isn't. But it's really, really small, which is part of the reason school systems are shaped as they are.

</comment></comment></comment></comment><comment><USER9> Not nearly cynical enough. A lot of the things written here are sort of the 'ideal'. The fact of the matter is, if you want to be a chemist, you probably shouldn't be anything but a chemistry major (or something related enough, or effectively complete the chemistry reqs). I don't know that colleges are 'places where knowledge is created'. In retrospect, I feel like colleges are places where people get that A (i.e. a college diploma) to prove they've been there - and to gain qualifiaction in the eyes of the outside world.

Whether or not that should be the case, that seems to be the way that it is.

The Paul Krugman quote is shudder-worthy, but that is a personal bias.

<comment><USER10> Re creating knowledge, it depends on the specialism. In a lot of computer science, I feel that university is perhaps one third ad-hoc / industrial trends and practices getting formalized; one third blue skies work of a some relevance, though by the time it becomes relevant is quickly overtaken by industry; and one third useless formalizations generation, more exercises in rigour (or not) for their formulators than measurable knowledge.

<comment><USER9> ...It actually probably more depends on the school.

To a certain degree there are computer science programs where the net result is large-scale training in collaborative development. At the university where I worked, there was a graduate CS class where over the course of 10 weeks they rewrote the transportation department's website (enabling real-time tracking of campus busses and wi-fi base stations in all the busses).

However, I was a chemistry/math major as an undergrad, at a primarily research institution. I imagine chemistry departments at primarily undergrad institutions were probably not as involved in the process of "knowledge creation" - that's what REUs were for - and who can say about the humanities and political science?

</comment></comment></comment><comment><USER11> I think there is a growing apathy between undergraduates and there teachers: the students don't quite see the point of slavishly attending lectures when the same information is readily available online or in the library, while lectureres don't see why they should try harder to engage students when they constantly turn up late, don't pay attention, or skip classes entirely.

I don't know if it's always been like this. My undergrad uni seemed to have _recently_ added actual credit for mere attendance. One of the modules reportedly only had a tenth of the people show up (I didn't realise this cause I ditched it after the first two lecture which were exceptionally dull and unenthusiastic). My postgraduate class consisted of a room half full of foreign students who talked _all_ lecture. I don't know if there's cynicism amng academics about their students, or some sort of undying optimism. I suspect they say "unbelievable now lazy they're getting, how lax the standards are, how ignorant..." when we're not there.

And then there's the tutorials: 90% of the time they were a joke. Even the better ones where some active discussion transpired, I wasn't convinced of their actual value beyond entertainment.

</comment><comment><USER12> _The biggest difference between a university and a high school is that universities are designed to create new knowledge, while high schools are designed to disseminate existing knowledge. That means universities give you far greater autonomy and in turn expect far more from you in terms of intellectual curiosity, personal interest, and maturity._

I found that this to be vary a lot from department to department. First of all, undergraduate programs across the board are largely about disseminating knowledge, as a foundation to be able to create new knowledge later as a graduate student or researcher. As far as similarity to high school, I found that business school undergraduate classes in particular were very much like high school just on a larger scale: attendance taken, assigned seats, required homework, etc. Classes in the Math or science departments were more likely to leave it all up to the student: grades were based solely on performance on exams. Humanities courses were somewhere in between those extremes.

One thing not mentioned in this piece, as an undergraduate it is much easier to establish a high GPA your first two years than it is to bring up a low GPA as a junior or senior. You don't do this so you can "coast" later, but because your 3rd and 4th year classes in your major are going to be hard, or at least quite time-consuming. If you have a high GPA coming in to your junior year, you don't have to worry so much about the stray required electives you are still finishing off, at the expense of the subjects you are really interested in.

</comment><comment><USER13> _When you ask how you get an "A," they're likely to be annoyed because you're indicating you don't care about learning, which is the best way to earn an A._

I cannot stand it when a professor says that the best way to get an A is to learn. It shows a fundamental ignorance about their own system of instruction.

If there is anything I've learned about universities, it is that learning is at best orthogonal to getting an A. More often you have to actively sabotage your actual learning in order to get an A.

When you get excited about a subject enough to explore it on your own, you will almost inevitably end up either spending too much time on one part of the curriculum or neglecting the rote memorization and tedious busy work that is necessary to get an A. Classes are just small factories, treating and evaluating every student the same way. It is and ever was a game of points and percentages. If you want "learning" out of this, you need to balance it with playing the game.

Professors have either never known this or have completely forgotten it. They constantly whine about how students seemingly strive to get the least out of their education as possible by taking as many shortcuts as they can. What they fail to realize is that all of their classes are set up as silly little point games, and each student has about 5 or 6 of them. Then they give out so many busy work assignments and so much reading per class that it is impossible to accomplish it all. The students are essentially learning how to prioritize and cut out all of the unnecessary fat in order to maximize their _points_. They're kept so busy that they don't even know that they're not really maximizing for learning. Learning is not what the professors tell them to do. Learning is not what the professors hold over their heads. They live by points, and die by points. It takes a special student to pull his/her head out of this firehose of tasks and decide to pursue their own education.

So Bob the student comes into class and he hasn't done the reading. Why? Because he has spent 102% of his time on the various homeworks and deliverables for this and other classes -- the stuff that actually has an effect on the bottom line: his grade. He'd sure like to do the reading, but he knows that he can get the assignments done just as well without it, and so it goes to the bottom of the priority list. He will never get around to doing the reading, because the list of grade-impacting busy-work deliverables will never cease.

The professors then complain about the students like Bob, who don't seem to want to actively explore their subject. They complain about the work of their own hands, the inevitable result of their own system. The professor actively molds students to be this way, and then they complain about it.

That is what I wish I'd known as a freshman.

<comment><USER14> It sounds like Bob overloaded his schedule. Or, more likely, he's been partying all night and placed his priorities elsewhere. Most students tend to procrastinate to the last second then whine that they "didn't have time" to get the assignment done, muchless the reading. And that is the sad truth.

Anyhow, points are a game that even the best students get sucked into playing. We are not passionate about every subject, obviously. So, play the points game for subjects you don't care about, then really try and learn for the subjects you do care about. It will only help your grade, and you might find some friends and supporters along the way too.

<comment><USER15> Some, certainly, but not all by any means. Try doing well in an art / music field, both of which _require_ many many many hours outside of class - typically more than 2x the hour load - _and_ learning more abstract skills like math or coding. The stuff you can sacrifice a _little_ becomes the stuff you sacrifice.

For instance: across _two_ projects in _two_ classes, I've clocked over 1000 hours. Both classes had 3 (shorter) projects, and I had three other courses at the same time.

And that wasn't my busiest semester. _That_ one had 21 credits - one of which was an internship - and a part time job. (not recommended _under any circumstance_ , btw)

</comment></comment></comment><comment><USER16> _To get that A/B/C, demonstrate that you're interested in the material, do all the reading, and show up to class every day. Go to the professor's office hours to ask intelligent questions—like whether you're on the right track regarding a paper—or what you could've done better on a quiz._

I never find myself doing this with a CS class. I always show up right before class starts, answer a few questions to show the professor I haven't zoned out in front of my laptop and leave once class ends. Talking to others in the class, they pretty much did the same. What we were covering always seemed pretty set in stone. The complexity of mergesort won't change and its rather easy to see how it differs from quicksort, for a contrived example.

However, when I had International Studies as my second major, I found myself in professors offices a lot more. The politics behind everything at the level we were looking at things on was much easier to find questions to explore than CS was. And even more so with the art classes that I'm in right now. I'll stay after class to work on something, show up before class to talk to others and see how their project is coming along (and theirs is usually in a completely different direction than mine). I'd ask the professors if they knew of any artists who had made similar works that I could look at, etc.

</comment><comment><USER17> This all very useful information and well written but I have to ask, do undergraduates really not know this or at least figure it out very quickly? I would expect students who are investing large sums of money to be better prepared than just turning expecting High School plus with a generous helping of A's them a nice job? Perhaps it is different in the USA than elsewhere?

<comment><USER18> _I would expect students who are investing large sums of money to be better prepared_

So did I. I spent a lot of time during high school looking over options of where to study. When I enrolled, I knew almost as much about the CS department's course offerings and degree programs as the faculty did as well as what courses I would take to fulfill my general education requirements. I was very confused at the large proportion of students I encountered who knew very little about the teachings their departments (and the university) offered. While I now acknowledge that this is the way things are, I still do not understand why. I have not determined whether this correlates with the degree to which students put effort into their own education; this should make for some interesting conversations (I think I'll start with my brother).

<comment><AUTHOR> _While I now acknowledge that this is the way things are, I still do not understand why._

I'll posit some reasons:

I didn't know what I wanted to major in or what I wanted to study. This is very common, as is switching majors. It's also hard to evaluate schools because so many factors go into a decision: large or small school, big university or small college, scholarships, tuition costs, geographic proximity, faculty sizes, student culture... the list goes on. And the people choosing are 17- and 18-year-olds, most of whom aren't particularly well formed or knowledgeable about their interests. There's a reason why you're supposed to discover yourself at the university: because most people don't know themselves before they go. There's a reason why the bildungsroman is such a popular genre: most people go through phases when growing up and learning about the world. Maybe you did so earlier than most. I didn't.

I also think that most people are bad at anticipating what their future selves will want. That also applies to me, and my feeling has been reinforced by books like Philip Zimbardo and John Boyd's _The Time Paradox_, in which they talk about time preferences and how those change. One reason I like Paul Graham's "What You'll Wish You'd Known": <http://paulgraham.com/hs.html> is the hang glider metaphor: you don't know where you'll want land, so stay upwind.

If you _knew_ that you wanted to be a CS major _and_ you stayed in that major throughout your college experience, you're in the minority of students.

</comment></comment></comment><comment><USER19> Very well written, I like it. I wish more articles were proofed like this one probably was.

</comment><comment><USER20> There's nothing about getting laid in there. What's up with that?

<comment><AUTHOR> Upvoted for being funny -- I can only say that it's beyond the scope of this article, which isn't to denigrate its importance.

</comment></comment><comment><USER21> Interesting read, but he lost me when he said astronomy was useless, a few paragraphs after he talked about how professors would feel immensely insulted if anyone called their subject boring or useless.

<comment><AUTHOR> Notice the context:

 _I tried and found that there is virtually no negotiating with requirements, even if some are or seem silly. For example, Clark required that students take "science perspective." In studying my schedule and options, I figured that astronomy was the easiest way out. Considering how useless astronomy looked, I decided to petition the Dean of Students to be excused from it so I could take better classes, arguing that I'd taken real science classes in high school and that I could be more productively engaged elsewhere. The answer came quickly: "no."_

Considering how useless astronomy looked _in the context of taking it merely to fulfill a requirement of limited utility_ , I didn't especially want to take it, but I took it, fulfilled the requirement, and continued.

Astronomy is a lovely subject, like many subjects, but it's not one that I desperately wanted to learn about then, and the class was mostly a waste.

<comment><USER22> I noticed that too. I'm sure you could have found a more interesting (to you) way to get that credit - but then again, _errare humanum est_ and I've certainly made my own share of mistakes.

</comment></comment></comment><comment><USER23> "Tests asked things like the size of each planet—in other words, to regurgitate facts that one can find in two seconds on Google, which is how I found out what the Kuiper Belt is again."

Isn't this true for the entire undergraduate curriculum?

"The biggest difference between a university and a high school is that universities are designed to create new knowledge, while high schools are designed to disseminate existing knowledge"

This is wrong. There are no "new knowledge" in undergraduate level.

<comment><USER24> That isn't true. There most certainly can be new knowledge at the undergraduate level, and increasingly many schools are encouraging or requiring real research projects for both BAs and BS degrees. My wife was published for her biology thesis on petroleum consuming microbes and I was for my research & exhibit on the commercialization (via ephemera) of Thomas Jefferson since his death. That said, my actual thesis, on the impact of popular music on public opinion during WWI, was completely regurgitated hash. However, my university has an enormous collection of period sheet music so it was a lot of fun to research and I don't regret it at all. Hopefully my thesis advisor didn't, either. :)

<comment><USER23> Well, thanks for the examples; and interesting research as well.

I was thinking more about physics. I believe that it takes longer for a student to reach the original research stage in physics.</comment></comment></comment>


An Unbiased Overview of the Israel-Palestine - <AUTHOR> http://www.vox.com/2014/7/17/5902177/9-questions-about-the-israel-palestine-conflict-you-were-too <comment><USER2> Not exactly unbiased... reads very pro-Palestine.</comment>


Google's Secret Strategy with Kansas City Fiber Rollout - <AUTHOR> http://free-fiber-to-the-home.blogspot.ca/

<comment><USER2> If Google drives the consumer cost of high-speed internet down to nothing in response to the threat of google fiber, then Google wins.

Google wins when people use the web. Cheaper access to high speeds means more users at high speeds. Higher speeds means more pages per unit time, which means more ads server which means more revenue.

Google is declaring that the the US will have higher speed internet if they have to implement it themselves. Bold move. I hope it does drive down the costs.</comment>


Simple, safe, and fund anonymous chat - <AUTHOR> http://techcrunch.com/2014/09/18/reveal-chat-for-ios-helps-you-build-real-social-connections-via-anonymous-chat/?ncid=twittersocialshare

<comment><USER2> awesome app</comment>


C++ Stackless Coroutine - <AUTHOR> https://github.com/jbandela/stackless_coroutine <comment><USER2> Post-C++ 11 code is so very different from pre-C++ 11. Things are so different that I cannot even understand many of the constructs anymore. I realize C++11 is 5 years old now but still. I fear the same thing might happen to javascript as well with the changes in es7. I don't think this is a good thing for languages to change so much that the style becomes very different. This is probably the reason why developers like Go. The language designers are reluctant to change it from the get go.

<comment><USER3> C++11 is in a state right now where it is essentially unchallenged. It runs natively, has no garbage collection, zero cost abstractions, automatic memory management (memory leaks don't cross my mind any more) and most importantly, a hugely mature ecosystem.

C++11 on up is nothing short of revolution in systems programming. Hopefully D and Rust will be there eventually but right now no other language even comes close to the maturity of having 4 compilers you could bet your business on and just as many IDEs.

<comment><USER4> I think you're understating the case for Rust.

Rust has a better standard library (e.g., std::option) and better resource abstractions.

The "existing code" advantage seems a weak case at best for C++, given that it doesn't even have a package manager to use the code. Including 3rd party code is nightmarish.

A greenfield project would have to think long and hard about taking on the enormous bloat and not-for-mortals specifications of C++ over Rust.

<comment><USER5> I also think that Rust has a bright future ahead, but C++ will probably live forever. There is a huge amount legacy code in C++, a lot of it tied to embedded systems that have service contracts that measure decades.

C++ didn't manage to displace C completely, I doubt that Rust will manage to displace C++. This is especially true now that C++ is seeing active improvement that makes it a lot more attractive for new projects.

<comment><USER6> While true, I think the rise of Linux and FOSS, alongside embedded development helped C stay around.

On Mac OS, Windows, Symbian, BeOS, even commercial UNIX with CORBA and Motif OO libraries, developers were already transitioning from C to C++ when Linux and FOSS, which depend heavily on C, started to gain adoption.

Then you have the embedded space, specially with micro-controlers, where even packing C into the EPROM is already an exercise.

As for C++, the new standards rely reinvigorated it, with Apple, Google and Microsoft pushing it forward.

One of the reasons I updated to Windows 8 (now on W10) was to be able to use C++/CX with XAML. Visual C++ finally catched up with C++ Builder in terms of RAD experience.

This where I see Rust still needs to grow. There are lots of use cases where Rust still does not provide an out-of-the-box solution vs C++ tooling does.

</comment></comment></comment></comment></comment><comment><USER7> Shameless plug:

[http://lthread-cpp.readthedocs.io/en/latest/lthread.html](http://lthread- cpp.readthedocs.io/en/latest/lthread.html)

</comment><comment><USER8> could this be easily done without using boost?

<comment><USER9> Author here. The library itself (stackless_coroutine.hpp) has no dependencies other than C++14, and you can easily use it in any C++14 project with any async library.

For writing an interesting example, I wanted to do an example of how the library can simplify async network code. A widely used async C++ library is Boost.Asio, so that is what I used for the example.

TLDR: The library itself has no dependency on Boost. Boost.Asio was just used for the example.

<comment><USER10> It's a good example. I'm really liking asio so far. However, I've been using the standalone version[1]. Maybe you could do the same with your library?

[1]: [http://think-async.com/Asio/AsioStandalone](http://think- async.com/Asio/AsioStandalone)

<comment><USER9> I am planning on overhauling the example to use that latest version of Asio standalone that is tracking the C++ Networking TS. That way it will be a simple matter of people changing asio to std::experimental::net on a compiler that implements the Networking TS.

</comment></comment></comment></comment><comment><USER11> Does this really "help" in anyone's design? I know some people despise callbacks, but I would much rather read callback-based code than this (looking at example.cpp).</comment>


Destination Subconscious: Cary Grant and LSD (2010) - <AUTHOR> https://blog.wfmu.org/freeform/2010/03/his-girl-lsd-the-cary-grant-experience.html <comment><USER2> You can do worse than browsing WFMU's Beware Of The Blog from start to finish. It's like going down the Wiki hole, only weird.

</comment><comment><USER3> Hardest to read award of the month. Tiny white text on black, full width across, not gutters...ouch.

<comment><USER4> Just change the width of your browser window and use a minimalist browser that only cares about the important stuff like text and images while discarding the trash. Problem solved.</comment></comment>


Ask HN: Firefox on Mac causing systemwide graphical artifacts? - <AUTHOR> I posted about this issue a few weeks back: https://news.ycombinator.com/item?id=21790148
Basically I took home a brand-new 16 inch Macbook Pro, and a handful of times over the course of a few hours I saw graphical artifacts (random, tiny rectangles of pixels that would turn magenta, or green, or orange, etc. until that portion of the screen refreshed by scrolling or otherwise).
I returned that Macbook and ordered a new one. This time things seemed fine for the first 12 hours but then I started seeing the same kinds of artifacts, this time mostly on the menu bar (some were on the menu bar before).
I've noticed that while they aren't always on the Firefox window, they do at least sometimes correlate with things I'm doing in Firefox. Opening a new tab, visiting certain sites, etc. Turning off hardware acceleration in FF also seemed to have an effect (I'm trying Chromium now to see if they happen at all with Firefox closed).
I'd be shocked that two >$2k laptops in a row would have such an egregious hardware defect out of the box. Is it possible Firefox is the entire culprit? Or is it more likely that it just surfaces the underlying problem more often, by making greater use of the GPU?
Edit: This seems to be the same issue https://apple.stackexchange.com/questions/338319/red-pixels-on-mojave-dark-mode
Really I'm just trying to decide whether it's a software problem or whether I should exchange it again. <comment><USER2> I read the headline and I'm like _huh..._ because I'm also experiencing exactly this, on my 2019 16" MBP, with Firefox. It only occurs on or around the tabbar. Firefox has its own desktop space on my Mac, and the graphics artifacts haven't been occurring on other desktop spaces. I hadn't made the connection to the browser, figured it was a problem with the window manager or something. I'm also more or less permanently in dark mode.</comment>


Ask HN: Thoughts on Only allowing login by OAuth - <AUTHOR> I am in the process of releasing my webapp which requires users to login to my app first and create profile but instead of using the own login functionality i am only relying on OAuth and i am allowing users to login with Google/FB/Microsoft/GitHub/Linked-In. Only information i want is their email address (and optionally First & Last name). I am also displaying what information is received from respective provider.
My reason for not implementing my own login is it may not be as secure as the biggies in the business, i don't have to deal with the mess of activation/reset password thing, OAuth is fairly simple and less complicated to implement.
I signup to other sites using OAuth just to avoid remembering another user/pass, but do you think its a good idea to completely rely on Oauth?
I can add the help page link / button to assure user why i am using OAuth but still will it affect the user signups and BTW all services will be free on my site. <comment><USER2> Really depends on what your app does/what field it is in (what do other apps in the space do?), and there are nearly always going to be users for which one of the two is not an acceptable solution.

For social type stuff, Facebook/Twitter seems quite established, with professional or technical tools I'd be more careful.

<comment><AUTHOR> yes, you are right. I am thinking of adding my own implementation. Thanks for your input, it was useful.

</comment></comment><comment><USER3> Curious if the app really needs login.

If it does, I would definitely favor using something well tested rather than trying to invent a new login process.

If it does not, I favor reducing the friction for finding users (which is different from the number of email addresses a site can collect) by making giving an email address opt-in.

Good luck.

<comment><AUTHOR> it requires the login as i am collecting user data.

</comment></comment><comment><USER4> I never use the OAuth option personally. I wouldn't read a help page. I always offer both OAuth and email/password in implementations. I don't find managing my own logins difficult. Having said that, the percentage of users who opt for OAuth is much higher.

<comment><AUTHOR> to be honest, even i think i should add my own login process but that will require me to write the code/add reset password link and manage the information. this is not a tricky part (2-3 days of efforts) but i need to setup my mail on server to enable sending mails. i am looking for API to send mails.

Thanks for your input</comment></comment>


Ask HN: Lost my passion for development, anyone else been through this? - <AUTHOR>

After 7 years of working as a professional software developer I have realized this is not my passion anymore, and have started to doubt if it was a passion for me to begin with. I feel I'm not smart enough to keep up, I feel I will never be anything close to a "hacker", I am stuck being an average programmer. I have tried building things but it all seems like work to me, no matter how interesting the project might be or the technologies I choose. I have tried taking courses via coursera, learning new languages and technologies, even going back to the fundamentals learning algorithms, compilers and so on but again I lose interest, it all seems like work, makes me feel too dumb or stupid, not fun, and work has become something I dread and its making me miserable, I can only wait for the weekend to come and get drunk.
I live by myself, recently moved to a new country where I don't know anyone, but I have a mortgage and development is the only thing I "know" how to do and the reason I moved countries. I am still trying to find my passion, music has always been something I love, I am teaching myself electronic music production and guitar but at 30 I don't see myself making a career out of music or anything else for that matter.
Has anyone else been through a similar situation? is it possible to reignite my passion for software development? is it possible to switch careers at this stage in life? if not then how can I make the best of this situation?
Thanks HN. <comment><USER2> Yes as a fortysomething who has been hanging with techies since my youth i can tell you that yes people can grow out of love with writing code. If said person doesn't have another immediate road they often become managers of people who write code, or go into a related field like information architecture. Also frankly once you become a thirtysomething you often tend to get settled down with a spouse and perhaps even kids -- so the joy of spend an all-nighter no longer becomes a joy.

Although I suspect that your problem is that you didn't like to code in the first place (which you sort of said). I think the thing to do is to find something related and realistic that you have enough passion to keep you going. So can you be a rock star at age 30+? Maybe, but it's a long shot. But I bet that there is something that is viable that does get you excited. And I suspect that you're smart if you had the ability to go another country and earn a living (maybe your passion has something to do with that?). But whatever you do, don't try to fake a passion.

</comment><comment><USER3> You can make a career in music, though it may not be making music itself. Leverage your current skill (programming) to get yourself into a music-related job. Start making band web sites, or social media crap, online merchandise sites, or whatever it is that these people need. Meet people in the industry and figure out what might be fun for you to do. Maybe it will involve making music, or maybe something you find even more enjoyable.

Programming can open doors into just about anything these days.

<comment><USER4> staunch has the right idea. I'd add: use your well paid job to bankroll money to help you towards your goal of a new career.

</comment></comment><comment><USER5> I'm not a psychologist, but I notice some things that I look at differently.

You mention "being an average programmer" and learning new things feeling like work because they make you feel "too dumb or stupid."

So what is fun? Something you are good at? What are your expectations?

You also mention "trying to find my passion" Cal Newport wrote some articles of how "following your passion" is dangerous advice because it doesn't work like that.

Perhaps you are depressed and you just need to find some meaning behind what you are doing? Have you read Man's Search for Meaning?

Because being good or bad at programming doesn't have to affect the enjoyment you get out of it. I know some grumpy rock-star programmers who seem to unconsciously be chasing this concept of being accepted or loved when they finally reach whatever level of perfection they have invented for themselves. Imagine how frustrating it must be for them, every flaw is preventing them from receiving what they desire.

I worry that your line of thinking is: I'm not happy. -> OK maybe it is because "I'm not a good programmer." -> OK, let's try becoming better -> Progress with natural setbacks -> (Frustration because you aren't becoming happier) -> Maybe it is because I'm not a good programmer -> OK, maybe I need to do something else.

Also, moving to a new country is hard for everyone, it sneaks up on you.

</comment><comment><USER6> Keep a positive attitude.

It's tough feeling average when everyone wants to be a rock star but most people are closer to being average.

As far as your day job "that's why they call it work" it's not always going to be fun and exciting. You'll go through periods of time where you lose and regain your passion.

The guy working heavy construction in the construction zone on your way to work probably isn't 100% happy with his career either.

If you've been doing this for 7 years you are smart and you can keep up. Consider changing to a new company or new project. Sometimes managers have a way of making you feel not smart enough or able to keep up.

A career change is possible, typically you'll have to take a lower salary.

Music is an awesome hobby that you can do on the side. So keep learning musical skills and making music. I had a band in college so I had the dream of being a rock super star that has been replaced with being a tech super star (SaaS apps, big house, five cars).

So keep a positive attitude at work, maybe seek out a new project or maybe a new company for a change of scenery.

A nice distraction from your day job would be focusing on your music in the evenings and on weekends . . . if you have an interest in starting your own business look at starting a music related website or SaaS app or a SaaS app to replace your day job income. StartUpsForTheRestOfUs.com has a good podcast to learn more about that option.

The economy is tough out there so appreciate having a stable job as a developer.

Good luck.

</comment><comment><USER7> Following passion is a good thing. But it's simple to say, not as somple to do - you still have to make your living. Kinda "catch 22"... I felt same way when I graduated college and found myself thinking about it more and more. Once it got all over me - I knew I had to make my choice. It's hard - but if you're seriously thinking about turning your life to another path, which I guess you are, take a break for a few days and think deep. But if you make the approach to change your lifestyle, get ready to work twice as much to succeed for real.

</comment><comment><USER8> Consider going into project management, this seems to be what some people do when they don't want to be a developer anymore. I have worked with PM's who used to be developers and had basically completely stopped coding and went solely into management. One guy, at my last job, I don't think had even close to 10 years experience as a developer before he went into management. If you go this route, please don't become the type who attempts to trivialize the work of the people who do do the coding, the aformentioned PM had this attitude and it was rather obnoxious given that his skills had deteriorated (or were never there in the first place) as far as actually being a developer.

</comment><comment><USER9> A few years ago I went through a patch of about 2 years when I gave up my s/w development job and founded a small online business selling electronics. It paid the mortgage, but not much else. It was exciting, but at the same time it also increased my respect for having a stable job with guaranteed income every week.

Have you thought about combining some form of software development with your love of music? Not sure what exactly ... maybe an educational app to learn how to read music scales or something.</comment>


Amazing things with reporting - <AUTHOR>

Hello,
I have a pretty large web application that collects a lot of information that our clients use for both business reporting and machine to machine data moving.
Today we provide a handful of reports that cover the basics, and then develop custom reports in php.
It's painful, slow, etc…
What I am looking for is a reporting server solution that will let advanced customers create their own in a web browser and optionally a desktop client and have them run in our service. And for those who need assistance, give tools so there is no coding needed unless it's some scripting that's part of the reporting 'service' and is for some advanced functionality.
I have worked with Jasper and Brit in previous projects, but there must be some new and interesting products out there.
I'll be taking a look at Zoho and Pentaho.
Where else should I be looking? <comment><USER2> We're developing chartbliss, that is a tool for creating dashboards (but obviously you can create tabular reports as well). Check it out at [http://staging.chartbliss.com/](http://staging.chartbliss.com/), feel free to get in contact with me in private and I will get you access to our private beta instance.

<comment><USER3> Click the "Test-Drive The Live Demo" button at [http://staging.chartbliss.com/](http://staging.chartbliss.com/) \-- it gives you access to a demo account and pre-registers you for a private beta account.

</comment></comment><comment><USER4> I got so frustrated with the available choices (either really crappy = birt, or really expensive = tableau) so I finally made my own:

[https://github.com/gregpinero/django- mr_reports](https://github.com/gregpinero/django-mr_reports)

Feel free to use it or improve it. I think it's great :-)

<comment><AUTHOR> cool, thanks. I'll check out out.

</comment></comment><comment><USER5> Of the tools I haven't tried, QlikView sounds very nice and looks like it would do what you need:

[http://www.qlik.com/](http://www.qlik.com/)

I've tried several other reporting alternatives, and so far, I've been disappointed with most.

We're currently using Microsoft SQL Reporting Services and Crystal Reports, and are happy with neither (and they don't do what you need).

Edit: Tableau (what undertheradar2 mentions) sounds nice too:

[http://www.tableausoftware.com/](http://www.tableausoftware.com/)

The other one mentioned in the conversation is Spotfire

[http://spotfire.tibco.com/](http://spotfire.tibco.com/)

Edit2: they all sound pretty expensive though.

<comment><AUTHOR> Hey, thanks for the tips. Man, sorry your using microsoft SQL Reporting and Crystal. Been there and oh.. the pain.</comment></comment>


27 hilariously bad maps that explain nothing - <AUTHOR> http://www.vox.com/2015/2/18/8056325/bad-maps

<comment><USER2> [https://xkcd.com/1138/](https://xkcd.com/1138/) Alt-text: There are also a lot of global versions of this map showing traffic to English-language websites which are indistinguishable from maps of the location of internet users who are native English speakers.

</comment><comment><USER3> Welcome to Mexico</comment>


Ask HN: What are your favourite newer podcasts? - <AUTHOR> Getting a bit tired of the classics - Tim Ferris, This American Life, Andressen podcast.  Would love to hear what informative, inspiring, or entertaining stuff you guys are listening to lately. <comment><USER2> The startup chat is very good [http://thestartupchat.com](http://thestartupchat.com)

Megamaker by justin jackson is a new one that is interesting [http://megamaker.co](http://megamaker.co)

Zen founder is a third one i love listening to [http://zenfounder.com](http://zenfounder.com)

<comment><USER3> great list, thanks :)

</comment></comment><comment><USER4> Agree w/ andersthue's suggestions. Here are a few others I listen to frequently.

I like all of the Gimlet media podcasts. [https://gimletmedia.com/](https://gimletmedia.com/) Specifically Startup, Mystery Show, and ReplyAll

Hardcore History and Common Sense are favorites of mine: [http://dancarlin.com](http://dancarlin.com)

99% Invisible by Roman Mars [http://99percentinvisible.org/](http://99percentinvisible.org/)

Startup School Radio from ycombinator is pretty good [https://itunes.apple.com/us/podcast/startup-school- radio/id9...](https://itunes.apple.com/us/podcast/startup-school- radio/id992277217?mt=2)

What's the Point is a podcast from fivethirtyeight about data [http://fivethirtyeight.com/tag/whats-the- point/](http://fivethirtyeight.com/tag/whats-the-point/)

Traction by Jay Acunzo at Nextview Ventures is another great one [http://nextviewventures.com/blog/category/traction- podcast/](http://nextviewventures.com/blog/category/traction-podcast/)

<comment><AUTHOR> Thanks, these look great. Big fan of Carlin on a nice long drive.</comment></comment>


Ask HN: What are the top 3 accomplishments of Obama Administration? - <AUTHOR> I was asked by a foreigner (or I should say aggressively questioned) and I wasn't as concise I would want to be. I thought I would reach out and see what others think? Thanks <comment><USER2> \- Record number of commutations for nonviolent drug offenders and now Chelsea Manning, as well.

Granted, it's all symbolism, as his administration has prosecuted far more than he's released for those same 'crimes' and done nothing to improve the system, but at least it improves the dialogue going forward, potentially. I will be impressed if he also pardons Snowden, who exposed _him_ (as opposed to Manning who leaked Bush administration secrets).

\- Shifted a significant amount of land from the poorly managed BLM to the Forests Service.

Again, not actually solving any problems, as the BLM still owns roughly a third of the land in the country, but he did some symbolic improvements which benefit his image.

\- Providing a strong voice for the large strides made for the LGBT community during his administration.

Again, he opposed gay marriage during his 08 run but slowly came around and ended up warming up to it sooner than others. He certainly was not "the reason" progress was made, but I'm at a lack of other accomplishments.

Some additional ones: \- Balancing the budget. \- Getting us out of imperial interventions in the Middle East. \- Reigning in the surveillance state. \- Promoting healthy interest rates instead of kicking the can down the road and encouraging debt. \- Fixing the healthcare system.

Those ones were jokes, obviously. Obama has been a pretty awful President where it matters, competing with the Bushes, FDR, and Woodrow Wilson for the title of worst since 1900. The only things the President really has absolute control over are foreign policy, management of non-legislated decisions such as DEA drug scheduling/prioritizing and surveillance programs, and military execution (see: Pentagon audit 2016). On all of these fronts he is an absolute failure who has desecrated our Constitution and hands over the keys to the most powerful Presidency in US history to Donald Trump. But damn, did he look good doing it. Charisma > results, Obama 2020.

<comment><USER3>
      the poorly managed BLM to the Forests Service

which is still run by Obama appointees, just like Interior departments.

One change that Obama _could_ have made at the beginning (or anytime since) would have been to move Forestry into the same Cabinet post as the National Park Service and BLM. But, no.

</comment></comment><comment><USER4> \- Healthcare

\- Sorta-kinda ending Iraq/Afghanistan wars (cue can of worms)

\- LGBTQ issues such as repeal of DADT, marriage equality, etc.

<comment><USER5> Not sure how much the Iraq war ended, when last year they bombed it as much as they bombed Syria, and they were actually trying to wipe out ISIS in Syria (or was it Assad? I lost count on which side the U.S. was there) after the attacks in Paris and whatnot. So that tells you a lot about just how active the US military is in Iraq.

You can't say you "ended" a war where you're still dropping 1,000 bombs a month in a country, or more than 30 every day. Imagine 30 bombs being dropped every day in the U.S. by another nation. Would you feel "not at war" with that country? And the U.S. is a huge place with the population spread around. The Middle Eastern countries are much smaller so the impact (both physical destruction-wise, but also psychological to the population) is greater.

[http://blogs.cfr.org/zenko/2017/01/05/bombs-dropped- in-2016/](http://blogs.cfr.org/zenko/2017/01/05/bombs-dropped-in-2016/)

<comment><USER4> Hence "sorta-kinda" and "can of worms" ;)</comment></comment></comment>


How Apple has shaped the user interface - <AUTHOR> https://www.punchkick.com/blog/2015/08/07/how-apple-has-shaped-the-user-interface?utm_source=designernews

<comment><USER2> Ugh, what garbage.

Apple invented/popularised windows, grid of icons and flat design apparently.

<comment><USER3> They also invented circles, squares, watches, and rectangles.

Unfettered fanboyism at its finest.</comment></comment>


DHS had access to messages from Portland protesters, document shows - <AUTHOR> https://www.chron.com/news/article/DHS-had-access-to-messages-from-Portland-15450458.php <comment><USER2> _had neither collected nor exploited or analyzed information obtained from the devices or accounts of protesters or detainees_

I'm assuming this is just carefully chosen words - "from the devices or accounts".

If the DHS has someone undercover who asked and got permission to join the Telegram group, then the DHS could say "we didn't collect or analyze data from the devices or accounts".

</comment><comment><USER3> I am not going to comment on the propriety of conducting these activities. However, it appears they had access to electronic communications that were publicly available/accessible. This is akin to viewing someone's non-private Facebook profile and/or Twitter account. By the headline of this article, I had access to their communications too!

It has been well established that the 4th Amendment does not apply to when there is no reasonable expectation of privacy. Legalities aside, I would be concerned about how that information is used/what is done with it.</comment>


Apple plans to scale up presence in India, to triple exclusive stores to 200 - <AUTHOR> http://economictimes.indiatimes.com/tech/hardware/apple-plans-to-scale-up-presence-in-india-to-triple-exclusive-stores-to-200-by-2015/articleshow/19204356.cms <comment><USER2> Bit of Troll Sorry - Technically it's not possible, no whole number's triple is 200 :)

Now on the topic, I hope apple and other companies realize the potential of A location like India. India has various classes of people, and small subset of it which can afford apple products makes a huge market.</comment>


How do I get better at dinner conversations? - <AUTHOR> Recently, I invited my colleagues over for a farewell dinner and inadvertently put myself in the spot, by being asked a lot of inquisitive get-to-know-me better questions such as 1) Who among us did you feel turned out the most different from what you originally expected? 2) What are the top 5 things you'll miss about leaving this place? (Mountain View, if that helps) 3)What are the top 5 things you learnt over the course of the past year? etc.
I had either one-word responses or some very uninteresting answers and knew I was making the conversation stilted and boring. It was pretty awkward, and there came a point when I just wanted to be put out of the misery, and just be a fly in the wall, listening in on the fun conversation that the group would have, minus me.
So, to all the guys who make smalltalk seem effortless, how do you guys do it? Can this be learned? Should this be learned? <comment><USER2> You are a worthwhile and valuable person. That can be hard to remember when you want to shrink into the walls, but it is worth remembering.

Yes, good conversation skills should be learned. Yes, they can be learned.

Like most skills, it requires practice. You can hire a couch, if you want. I recommend improv comedy classes if you want a fast way to get over awkwardness and learn how to move dialogs along. But mostly getting better at talking to people involves talking and listening to a lot of people.</comment>


Ask HN: Why is russian election hacking so easy to identify? - <AUTHOR> You would think that a nation state would have the resources to make identification hard.
Some reporters were recently able to trace some evil emails sent from a server belonging to 'fancy bear'.
If you are fancy bear, wouldnt you have multiple servers around the world or maybe a botnet? <comment><USER2> The short answer is that they probably wanted to be identified. After all, it's an intelligence operation, so it serves several disinfo/doublecross- related purposes simultaneously.

The -bear APTs (fancy, fuzzy, etc.) had already been associated with russian military intelligence for _years_ , by the civillian cybersecurity community, posting evidence of that on the public internet, before the election.

(There's always the possibility that some other organization is posing as russian military intelligence & using a well-known APT to spoof their own work. But, supporting multiple sides of a conflict in a way that leaves clear evidence is standard MO for russian intelligence since the 90s -- though typically, russian intelligence will publically take credit for the ops later on.)

It's important to understand that the primary purpose was probably not to get a particular candidate elected, but instead to undermine public trust in the election apparatus. (The easiest way to do that is to take advantage of the fact -- generally known among security people but not among normies -- that the election apparatus actually is pretty insecure.) Actually influencing election results is secondary to making sure american citizens argue over whether or not they were influenced by a foreign power.

</comment><comment><USER3> [https://techcrunch.com/2017/07/20/microsoft-fancy-bear- lawsu...](https://techcrunch.com/2017/07/20/microsoft-fancy-bear-lawsuit- poulsen/)

</comment><comment><USER4> Usually you'd want to reuse existing hacking infrastructure that is people, exploits, operational practices etc. These are bound to leave fingerprints.

Doing everything from scratch to ensure secrecy would take significant resources. With no guarantee of success.</comment>


Libdill: Structured concurrency in C - <AUTHOR> http://libdill.org/structured-concurrency.html <comment><USER2> Many of the ideas inside the library are also explained in the Structured Concurrency blog post on the authors homepage: [http://250bpm.com/blog:71](http://250bpm.com/blog:71)

I really sympathize with a lot of them, e.g. scoping the lifetime of all child processes (goroutines, ...) to the lifetime of their parent and having good cancellation/timeout/close mechanisms for everything. I'm trying to apply these patterns in Go and it can solve a lot of scenarios in a more obvious and less spaghetti fashion.

Libdill seems to bringt a view more primitives to the table which for example make cancellation and waiting for child processes to finish easier. But the basic mechanism can be also applied in Go (e.g. via context.Context and a WaitGroup/Channel for waiting on the childprocess to finish) and therefore most likely also to libmill.

<comment><USER3> Go does not allow external cancelling of goroutines though, which I have wrestled with a few times.

The workaround is, of course, to have a "done" bool channel which is checked by the routine, but that's not always applicable or convenient.

<comment><USER4> First, since people generally assume replies are disagreement, yes, goroutines can not be externally cancelled and I don't expect that to ever change.

However, you can often mostly simulate what this library does in Go fairly effectively, since the goroutines end up stereotypically used. For instance, if your goroutine's purpose in life is to read from a socket, you can close the socket from another goroutine and that will result in all reads immediately failing. If you close the resources the goroutine expects, you get similar results.

You do have to structure your code for this, though; if the goroutine that you're trying to close both opens a socket and listens for it, then another goroutine trying to close that socket may fail if it tries before the first one even has the socket open. One solution I've sometimes used is to lock around a struct with a bool and a socket reference; the goroutine opens the socket, takes the lock, closes if the bool is true and updates the socket reference if it isn't to point to the socket, then drops the lock. (One lock is generally not a great penalty next to the costs of acquiring the socket.) If an external goroutine tries to close the resource, it takes the lock, closes the socket reference if available, and sets the "closed" bool if it isn't. It sounds complicated in English but isn't that much code.

It's a cute trick in C to turn all blocking calls into ECANCELLED results (no sarcasm, it is a cute trick), but generally goroutines should be small enough that they have an obvious and small set of "resources" that can be closed, where one such resource is definitely the dominant case. (And Go is all about considering the dominant case and not inserting tons of language features for the longer-tail cases.)

A "done" channel is a good solution if your goroutine already has a "select" statement in it. I've found that correct use of the select statement actually requires more such "structural" channels than is sometimes advertised; in particular, whenever you write code where you want the receiver to close a channel for some reason, the correct solution under current Go constraints is actually to add a channel that goes back to the sender, which the sender must be modified to check, and close that. I find rather more of my channels end up being "struct{}" than I expected at first.

<comment><AUTHOR> To me, the trick with closing the resource sounds like a hack.

Imagine you wanted to generalise it: We have a goroutine that may use some resources: sockets, files, keyboard, screen etc. To shut it down you cut it off from all those resources and hope that it will die.

It sounds wrong somehow.

<comment><USER4> I'd agree it was a hack if it were ill-defined, but I don't think it is. I don't think Go introduced that trick. In many cases you have to write your code to be able to deal with the resource being unavailable at any moment anyhow, especially networks, where Go is on its home turf. (As I've said more than once, the farther you are from writing something that looks like a network server, the less happy you will be with Go.)

</comment></comment></comment></comment></comment><comment><USER5> In the same vein, but with less idiomatic C, note also [https://github.com/hnsl/librcd](https://github.com/hnsl/librcd). I had the opportunity to work with it two years ago at Jumpstarter, and it was quite wonderful.

I've rehosted the long and opinionated introductory blog post about it at [https://github.com/hnsl/librcd/wiki/Announcing- Librcd:-Concu...](https://github.com/hnsl/librcd/wiki/Announcing- Librcd:-Concurrency-and-Segmented-Stacks-in-C). It's well worth a read, I'd say -- there's a lot of interesting ideas in librcd.

</comment><comment><USER3> How is this different from [https://github.com/sustrik/libmill](https://github.com/sustrik/libmill)?

It's from the same author.

<comment><USER3> Just noticed that there is an entry in the FAQ.

Pasting here for others:

[http://libdill.org/documentation.html](http://libdill.org/documentation.html)

It's C-idiomatic. Whereas libmill takes Go's concurrency API a implements them in almost 1:1 manner in C, libdill tries to provide the same functionality via more C-like and POSIX-y API. For example, choose is a function rather than a language construct, Go-style panic is replaced by returning an error code and so on.

Coroutines and processes can be canceled. This creates a foundation for "structured concurrency". chdone causes blocked recv on the channel to return EPIPE error rather than a value.

chdone will signal senders to the channel as well as receivers. This allows for scenarios like multiple senders and single receiver communicating via single channel. The receiver can let the senders know that it's terminating via chdone.

libmill's fdwait was replaced by fdin and fdout. The idea is that if we want data to flow via the connection in both directions in parallel we should use two coroutines rather than single one. There's no networking library in libdill. This is meant to be a separate project.

<comment><USER6> Is it meant to be a successor then? Or are they complementary? It's misleading that the FAQ only seems to mention advantages.

<comment><USER3> For reference:

libmill was a project to copy Go's concurrency model to C 1:1 without introducing any innovations or experiments. The project is finished now. It will be maintained but won't change in the future.

libdill is a follow-up project that diverges from the Go model and experiments with structured concurrency. It is not stable yet and it may change a bit in the future.

</comment></comment></comment></comment><comment><USER7> Looks like a very nice API. Now I'm waiting for an excuse to use it!

The only minor blemish I see is the need to call `fdclean()` before closing a file-descriptor. It introduces a slight non-orthogonality between libdill and straight posix.

Another approach might have been to wrap the fd up as a channel -- perhaps not one that transfers actual bytes, but which does signal availability.

The user would still need to to call chdone to clean up before calling fclose. But that would be a natural usage of the interface rather than a special- purpose wrinkle.

<comment><AUTHOR> fdclean() is not strictly needed and it haven't even existed in earlier versions of the library.

But it turns out that when handling 10,000 concurrent connections, the version with fdclean() is 1700x faster...

<comment><USER7> I am not really objecting to the need to clean up the fd-bookeeping data, just the interface.

And it's not much of an objection. I guess the intention behind libdill is that applications will do their I/O using some abstraction layer anyway -- and layer can be libdill aware enough to call fdclean().

If that is the design philosophy, then does that means there would be problems if someone used some big external libray that did lots of its own I/O inside a libdill coroutine?

<comment><AUTHOR> Here's the use case that drives the design of fdclean: Imagine a third party library makes a callback to your code and hands you a file descriptor. You can use it temporarily, but you have no idea what will happen to it after you return from the callback function. Will it live on? Will it be closed? The only way to deal with that is to purge any cached info about the fd before returning and pretend that you never had anything to do with that file descriptor.

        void callback(int fd) {
            fdin(fd);
            recv(fd, buf, len, 0);
            fdclean(fd);
        }

</comment></comment></comment></comment><comment><USER8> If you can use C++, give Intel TBB a try. It has a lot of structured primitives but still makes it easy to just parallelize a for loop.

<comment><USER9> This is about concurrency, not parallelism.

<comment><USER10> It is equally "about" both, if you look at what the API actually provides.

</comment></comment></comment><comment><USER11> > What that means is that one coroutine has to explicitly yield control of the > CPU to allow a different coroutine to run. In the typical case this is done > transparently to the user:

And this is exactly what's wrong with coroutines. It's not "transparent" to the user, but actually implicit to the user and unpredictable. With that user has no control over switch between coroutines and no idea when it's happening, which forces him to think about synchronization and generally have a very bad time if the essential complexity of the task he needs to implement is not something as trivial, as talking to a database.

In contrast, having a keyword, like await, to let the user keep control of the switching doesn't have that problem and user doesn't have to think about synchronization. But such things cannot be called coroutines.

So, be wary when someone is trying to push coroutines onto you. It's never a good idea to have them.

</comment><comment><USER12> I am more familiar with the "futures and promises" approach. [https://en.wikipedia.org/wiki/Futures_and_promises](https://en.wikipedia.org/wiki/Futures_and_promises)

<comment><USER7> It seems libdill supports channels -- blocking FIFOs.

In Golang (which seems to have indirectly inspired libdill), you would implement such logic by returning a channel (future) over which is sent just one value. That result itself might be a channel and so on.

No doubt the syntax in C would not be as convenient as in some other language -- but lightweight channels that work as first-class objects are a lot like futures.

</comment></comment><comment><USER13> Looks very interesting. The only problem I see with it right now is that functions aren't prefixed with dill (or some other unique prefix).

</comment><comment><USER6> One thing that I would love to see is the ability to schedule coroutines accross threads. Currently, you have to choose to spawn a new thread for your coroutine or keep it on the same thread. Although I believe adding a thread a pool and an assorted dispatch capability shouldn't be too hard.

</comment><comment><USER14> It looks like a very nice and well thought beginning.

Now we should wrap this into safer abstraction and maybe we should explore if it is worth to create a supervision mechanism and a communication model.

Would love to explore this further, but my time is lacking, feel free to drop me an email for any kind of discussion :)

</comment><comment><USER15> Is this portable among compilers/OS'/architectures?

<comment><AUTHOR> gcc/clang, linux/osx/bsds, x86_64, ARM...

<comment><USER16> I'm far out of my area of expertise here, but can anyone offer thoughts about the potential of wrapping these C routines and accessing them from python (Cython) to give python this level of concurrency?

<comment><AUTHOR> Don't know about Python but someone did a similar thing with Swift: [https://github.com/VeniceX/Venice](https://github.com/VeniceX/Venice)</comment></comment></comment></comment>