Learn Python 3 the Hard Way - <AUTHOR> https://blog.learncodethehardway.com/2017/07/07/learn-python-3-the-hard-way-officially-released/ <comment><USER2> People wanted LPTHW removed from beginner programming resource lists because Zed actively spreads misinformation about Python 3.

He writes condescending articles that confuse and mislead newcomers to the language. From his redaction:

> In the previous version I trolled people by pointing out that, if what the > Python project says is true and it would have been "impossible" to support > Python 2, then they broke it and Python 3 is not turing complete. Obviously > Python 3 is turing complete, but Python project members frequently claim > something this basic is "impossible" soooooooooooo alright. I even had a > note after the gag saying it was a gag, but everyone is too stupid to read > that note even when they do elaborate responses to my writing.

Check out the past HN discussion on his article, "The Case Against Python 3": [https://news.ycombinator.com/item?id=13019819](https://news.ycombinator.com/item?id=13019819)

<comment><USER3> Please everyone put down their fists and let the war finish.

It's all good. We all agree to program with Python 3 and educate beginners on Python 3.

Just forget the past and move on - Zed is on the Python 3 boat now and that's all that matters.

Indeed it makes a great deal of sense to not just end the conflict but go the other way - the Python community should simply ignore the past and do everything it can to welcome and include and bring Zed into the Python 3 community, to the extent that he wants that.

<comment><USER4> 100% agree with this in general and specifically. People tend to get too hung up on issues that are over. Zed has moved on and so should everyone else.

<comment><USER5> Writing an article that _very charitably_ wildly misrepresents events while leveling accusations at the PSF is not moving on.

I've recommended LPTHW to several new programmers, including one who I think bought the videos and really liked it.

Nonetheless, his strange dislike for python3 and continuing this flame war is not helping anyone, least of all Zed.

</comment></comment></comment></comment><comment><USER6> > Since I released the book in 2010 I have given it freely to about 12.5 > million people.

Amazing, what an achievement!

> Before my books there was this general belief in computing that only > "special" people could learn to code, and that it was pointless to teach > anyone who didn't start when they were 12. ... Before I wrote Learn Python > The Hard Way programming education books either patronizingly assumed you > were a child, or assumed you'd already been programming for years.

Hmm, I don't think this book was as revolutionary as described, but that doesn't take anything away from how good Learn Python the Hard Way is.

> Then I recently found out that members of the Python Software Foundation > (PSF) have been actively trying to have my book removed from other books and > websites. I received several chats logs from trusted associates that show > PSF members contacting authors and demanding that they stop referencing my > books. Believe it or not, it's because I said Python 3's strings suck or > that Python 3 sucks. I'm not kidding. They are so petty that they are > actively trying to destroy the one book that is potentially helping the most > people become Python programmers simply because…I don't like how they > implemented Python 3.

WWWWHHHHAAAATTTT???!! If this is true, the Python Software Foundation should be ashamed.

<comment><USER7> > _If this is true, the Python Software Foundation should be ashamed._

It's true and seriously misleading.

He's edited it a lot since (and even toned down its title), but the blog post he wrote against Python 3 was a FUD-filled incoherent piece.

You can absolutely expect members of the Python community to be disappointed. A lot of those members are people who learned from Shaw and to see him write a piece like that is heartbreaking.

The people on /r/Python who called for the removal of links to his resources (because yeah, it's not the PSF actively seeking out websites, it's the websites' members wanting him gone), those people were not "out for vengeance", they were not willing to link to material which actively campaigned against where the community was moving to.

He may be trying to position himself as one, but Zed Shaw was not a voice of reason who would point out the Python 3 flaws which nobody else dared criticize. _Plenty of others_ criticized Python 3. Zed was actually trying to harm the move to it.

Congrats on the book, and I'm glad he changed his mind, but I have no sympathy to his complaints there.

PS: This is what happened to processing durations when I upgraded our Hearthstone log parsing pipeline from Python 2.7 to Python 3.6 after Amazon finally made the latter available on AWS Lambda: [https://twitter.com/Adys/status/878985322436206592](https://twitter.com/Adys/status/878985322436206592)

<comment><USER8> Your last point is slightly misleading, you're comparing Python 3.6 (2016ish) with Python 2.7(2008), it better be faster

<comment><USER9> It's actually comparing 2.7.12 (2016) with 3.6 (2016).

Not that the release date has much to do with the benchmark, mind you...

<comment><USER8> Hardly matters since 2.7.xx are all maintenance releases and practically no features or performance improvements

<comment><USER9> Which is exactly why it's ok and not unfair to compare the performance improvements over time of Python 3.6 versus Python 2.7?

</comment></comment></comment></comment></comment></comment><comment><USER3> It's nice to see Zed on board with Python 3 - I know he has been a strong advocate against it for a long time but it would be really silly for people to hold that against Zed or his books into the future.

Zed Shaw educates ALOT of beginners about Python. _Everyone_ should be both glad and supportive that his education is now in the Python 3 world.

Time for everyone to leave the angst of Python 2 behind.

I can no longer think of any prominent industry figure who stands openly against Python 3. With no well known industry figures standing openly against Python 3, I think the long and painful transition can now be said to be complete. Finished. Certainly much Python 2 code still exists but conceptually Python 2 is now legacy.

Thanks to Zed for his work on the Python 3 book.

<comment><USER10> I started with LPTHW. Like literally did not know what a string was started. I remember the part of the book recommending to use 2 until 3 was as complete. I remember not caring either way.

Beginners do not care about Python versions. They're trying to figure out why their string won't print, running into bugs like: 'I'm printing a string' and being _stumped_. These people are not going to be contributing to Python3 migration, they're just not there yet.

And if people are running production grade applications are listening to Zed? Well, good luck to 'em.

</comment></comment><comment><USER11> > Before my books there was this general belief in computing that only > "special" people could learn to code, and that it was pointless to teach > anyone who didn't start when they were 12.

AFAICT, this is not only not all that true (teaching adults to code, and the belief that they could be successful, was not a novel when LPTHW was introduced, though some people certainly thought the way Shaw describes; I mean, schools have been taking people without programming backgrounds as CS majors forever, and there have been adult-targeted self-learning introductory resources, books and otherwise, for programming continuously since the 1980s, probably earlier), but LPTHW has not been associated with any substantial change in general attitudes on this point. While it wasn't then and isn't now then _general_ attitude, people still—and AFAICT in roughly similar proportions—buy into the idea of the "from childhood" coder being inherently superior.

<comment><USER12> Its downright delusional to believe that he in anyway is somehow responsible for a sea change in cs/programming education. I read that blog post eyes wide jaw slack. Moreover, I'm curious where he came up with the millions of users who "learned" via his books?

</comment></comment><comment><USER13> Learn Python the Hard Way was one of the first ways I tried to learn programming. It didn't end up working for me. It focuses on repetition rather than a conceptual understanding of what you're doing. But when I finally took a class and realized what I had been doing with all that practice I came to really appreciate how comprehensive it is. I won't use it myself, but I'm glad that something like Learn Python the Hard Way exists

<comment><USER14> I had the same experience, and thought it was the opposite of what the title implied. Rather than being more work up front for much easier progress, it seemed like a lot of easy typing things you don't understand and therefore making slow progress.

However, I generally prefer learning concepts first, with practical application later, so it could have just been a personal preference.

</comment></comment><comment><USER15> > Starting July 8th, 2017 both my Python 2 and Python 3 books will be no > longer free to read.

Now who's being petty? Sounds like you are retconning in a story about exclusively-commercial-book-titles-bring-maximum-community-benefit.

O'Reilly and other publishers have offered paper editions of freely- distributable books.

</comment><comment><USER16> God forbid anybody on the internet has his own opinions AND writes them in a non-corporate strong/humorous language.

And God forbid anybody calls the Python 2 to 3 transition (which took 7 years and is still underway -- not even 50% done) for the actual mess it has been.

<comment><USER17> > actual mess

Doesn't seem that bad to me. Py3k was released and folks waited for the hobbyists to iron out the quirks. A few years later the libraries started supporting it. A few years later the forward-thinking companies have started switching. That's a normal software upgrade timeline. Heck, the other day I found out a new client is still running Windows 97.

</comment></comment><comment><USER18> > I realized that I'm now sending beginners into a community that actively > ostracizes and punishes anyone who dissents against the decisions of the PSF > members. I simply can't support the PSF anymore given these actions, and I > can't send them new people if this is how they treat anyone disagreeing with > them.

> At that point the decision became much clearer. If I charge for my Python > books I can help even more people and also give people real jobs working for > me.

He doesn't want to "send" any more people into the community, so he now charges for his books.

What exactly is the connection there? How does charging for the books change anything? Does he assume charging for them sends less people to the community than before? If that's his goal, why doesn't he stop publishing his books completely?

</comment><comment><USER19> Awesome! LPTHW is my go to recommendation for introducing folks to programming and Python.

Also I really like his abrasive opinion writing style. It's very effective at getting people talking even if it is rather crude.

</comment><comment><USER20> This guy has such an ego problem. I'd hope that the PSF would actively ask people to stop linking to learn python the hard way, when it's teaching a version of the language that's over ten years old (and it's far from the only resource). The book has the benefit of having a catchy name that people can easily recommend, but that's about it. This guy really needs to get off his high horse, I'm even considering writing my own book just to compete with him.

</comment><comment><USER21> I've recommended LPTHW before. I actually _liked_ Zed's tone. It's nice to see a technical opinion when you're learning things so you pick up best practices or at least see justifications so you know how to form your own.

But seeing Zed's acerbity applied to a non-technical narrative makes it all just seems petty and toxic. I'm not going to wait for this to "play out" as some suggest. He's embedding this anti-establishment dribble into an introductory learning text, as he did for the first and I'm fed up of meeting developers who parrot his flawed feelings on the inadequacies of Python 3.

He says he's helped 12 million people with LPTHWv2... but in this day and age, taking a idealistic stand against Python 3 makes you a worse developer and would certainly count against you I were interviewing you. Professionally speaking, there's just too much to be had from Python 3.5+ to avoid it.

I won't recommend LPTHW again.

</comment><comment><USER22> You should start a patron page. I feel that a significant number of people would be willing to support the work you do, and this would allow you to both keep your education free while earning from it.

Just my two cents.

</comment><comment><USER23> I have multiple years of experience writing production Python code - is this book for me(new to 3)? Or is it more generally aimed at new programmers. Cheers!

<comment><USER24> You will not gain anything from it.

</comment></comment><comment><USER22> Love how everyone's getting themselves butthurt about Zed's opinion on a language. We all hated python3 at one point.

<comment><USER25> I did not. I started with Python 2 around 2009 (coming from a C and Perl background) and was surprised how backward string formatting is, and how unicode is messed up.

Then I started with Python 3 and was relieved to find named .format() parameters and bytes (vs. str). This is just an example - Python 3 is a very positive evolution.

(and yes, I read the arguments of the other (mistaken :)) group who advocates Python 2)

</comment></comment><comment><USER26> In that particular article, there were a lot of "alternative facts" (basically a lot of things that were simply not True), written in a subjective, aggressive manner. That's why it was bashed not because "somebody did not like him".

</comment><comment><USER27> Zed, you deserve to get paid for the work you are doing, and I appreciate that you've given it way for so long. Just be up front about it, don't bring the PSF into this.

Just own it. That said, I wish you had given more notice than a day.

<comment><USER28> Agreed. Wanting to get money is fine, wanting to get money out of something that was (mostly) free for the longest is sort of contemptible but he's in his right to do so. However, I've never liked much at all his attitude towards the PSF, and these so-called demands from them reek of bullshit.

</comment></comment><comment><USER29> Can anybody explain to me why, every time Zed Shaw writes something, flamewars emerge? Even here on HN which is one of the most courteous comment sites on the web I know off, has so many deriding comments within in minutes.

<comment><USER11> > Can anybody explain to me why, every time Zed Shaw writes something, > flamewars emerge?

Because Zed Shaw often writes things that are both (deliberately, AFAICT) inflammatory and about something which has a large interested community.

</comment></comment><comment><USER30> I couldn't imagine the cognitive dissonance he faced while working on this updated volume. He may have found some comfort in using Foo and Bar, though.</comment>


Steve Jobs on Gaming: It's the future of Learning [video] - <AUTHOR> http://www.cultofmac.com/136734/steve-jobs-on-gaming-its-the-future-of-learning-video/

<comment><USER2> As a student of physics, economics, and business I must say, sadly, that such "simulated learning environments" have by and large failed to materialize in higher ed. I suspect that savvy textbook publishers (Inkling?) will begin to offer these kinds of things in the next generation of electronic learning materials. There's really no excuse at this point.

<comment><USER3> Duolingo is a step in the right direction it seems (though language learning is not "higher ed", it can be used by adults).

</comment></comment><comment><USER4> "Bicycle for the mind" analogy is actually quite old. Steve mentioned it circa 1980 after he acquired the development of the first Macintosh.

He also mentioned it again in an interview for Entrepreneurs while starting NeXT and later in the introduction of NeXTStep.

</comment><comment><USER5> The actual content starts here: [http://www.youtube.com/watch?v=6kalMB8jDnY&t=1m10s](http://www.youtube.com/watch?v=6kalMB8jDnY&t=1m10s)</comment>


Cars hacked through wireless tire sensors - <AUTHOR> http://arstechnica.com/security/news/2010/08/cars-hacked-through-wireless-tyre-sensors.ars?utm_source=rss&utm_medium=rss&utm_campaign=rss

<comment><USER2> > _the tire sensors only send a message every 60-90 seconds, giving attackers > little opportunity to compromise systems or cause any real damage._

I fail to see how the _normal_ rate of the system at all implies what rate _can_ be achieved if attempting to hack the system. Unless it's peak receiving rate is 0.5 baud.

<comment><USER3> I was equally confused. I assume they must mean that the low frequency makes it impractical for _tracking_ vehicles.

</comment></comment><comment><AUTHOR> According to wikipedia (<http://en.wikipedia.org/wiki/Tire- pressure_monitoring_system>), most Tire-pressure monitoring systems nowadays use RF as their communication link.

I'm no EE major, but I do like to tinker with stuff like this... Anyone know what would be the best way to 'view' the RF signal? Hook something like this [http://www.mouser.com/ProductDetail/Linx- Technologies/RXM-43...](http://www.mouser.com/ProductDetail/Linx- Technologies/RXM-433-LR_/?qs=1hp3elAyKCmAgU90q27DmQ%3d%3d) up to an oscilloscope?

Edit: This looks pretty useful as well: [http://focus.ti.com/docs/toolsw/folders/print/ez430-rf2500.h...](http://focus.ti.com/docs/toolsw/folders/print/ez430-rf2500.html)

<comment><USER4> <http://gnuradio.org/redmine/wiki/gnuradio>

</comment></comment><comment><USER5> The worst thing about this security flaw is that cars don't really have a good update system for their OS. You have to take your car in to a dealership to get the ECU software updated.

If cars were designed so you could plug in an Ethernet cable to update the firmware, then patches for security flaws like this would be easier to distribute. With cars becoming more and more computerized we might reach that point some day.

<comment><USER6> I am not sure, if user service updates are a good idea. This would open a path to other risks. Anyway, I agree, there is currently no good solution for updates.

<comment><USER7> Other risks sure, but other benefits as well. Modern ECUs are pretty flexible and can be reflashed through the ODB-II port with extended functionality. cf. EMCS: <http://www.goapr.com/products/ecu_upgrade_s4.html>

<comment><USER8> Something I use, along a similar line: www.evoscan.com

Don't mind the wall of text website: I think it appeals to the revheads or something. The software is really quite clever (it can monitor and display variables from the ecu, along with allowing you to tinker with the software).

</comment></comment></comment></comment><comment><USER9> Ok, I guess I shouldn't feel so bad when I miss a test case or get an occasional exception in my web apps.

</comment><comment><USER10> I've once seen something on TV (iirc Discovery Channel or so) about certain government agencies using this together with certain antenna's to be able to track vehicles on the freeway.. so this is not completely new when it comes to the tracking bit..

</comment><comment><USER11> The paper is here, I think: <http://ftp.cse.sc.edu/reports/drafts/2010-002-tpms.pdf>

(I didn't see a link in the article)

</comment><comment><USER12> With the robustness of modern ECUs I'm surprised that these signals are not checked before being evaluated. Even my Arduino is capable of doing that.

</comment><comment><USER6> This is serious. Even bad sensor readings open the system for attacks.</comment>


Transcatheter aortic valve replacement effective in younger, healthier patients - <AUTHOR> https://www.nytimes.com/2019/03/16/health/aortic-valve-replacement-heart.html <comment><USER2> I had open heart surgery for repair of an aortic aneurysm. I also inherited the same wanky bicuspid aortic valve that has contributed to the death of at least one person (and usually more) in each of the last four generations of my family.

For some reason, the heart surgeon decided not to replace it when he had me opened up. Maybe I'll have the joy of undergoing another $160k operation to fix the valve using this technique.

By the way, in case you're wondering, open heart surgery kind of sucks. I wouldn't recommend it unless you absolutely need it.

<comment><USER3> Aortic valve disease is bi (Tri- for unileaflet but that usually presents at about 5-10 years) modal; trileaflets around 70-80, bileaflets at 40-50.

There are quite good reasons to not replace, not least of which is that replacement valves are nowhere as good as your native, particularly if it's still functioning.

Ie if metallic, you need to be on anticoagulants for life which can be a massive pain and cause other complications. Metallic last for around 30 years.

If porcine/bovine or possibly human, then they degrade much faster, 10-15 Years is the average.

So, depending on your age, and depending on the repair your aorta needed, the surgeon likely decided that since you will have to undergo the knife at some point again anyway (either for graft replacement for the Dacron that now makes up the proximal part of your aorta) or eventually due to the valve, you might as well minimise the complexity by only doing one thing at a time.

Plus, since we first started doing TAVIs (transcutaneous aortic valve repairs) they are getting better and better - see article - so possibly you wouldn't need the on-pump surgery.

Interesting that it costs you $160k; in the Australian public health system a valve is about $30k.

Source: I did my honours thesis on cardiothoracic surgery (actually on mitral valve repair, but spent a lot of time in cardiothoracic theatres dealing with aortic valve-disease)

<comment><USER4> Since you know a bit, can you clarify something not clear from the article? My aortic valve was replaced due to "ectasia", meaning the valve root stretched so the leaflets, which were otherwise fine, no longer met properly. Given the type of reconstruction to fit a porcine tissue replacement then, does this make TAVR more, or less, indicated for the replacement?

<comment><USER5> One problem with a TAVR in patients with aortic valve regurgitation is that they don't have enough calcification on their valve in contrast to aortic valve stenosis patients. Some valves need the calcifications to stay in place. As far as I know there are some studies with TAVR in regurgitation patients but it's not standard

</comment></comment></comment></comment><comment><USER4> I had an "aortic root reconstruction" by open heart surgery about 18 years ago, and my animal-tissue valve will no doubt need replacement sometime reasonably soon.

At that time, I made the optimistic prediction that by the time I needed a replacement, they will be able to grow me a new valve from my stem cells, and install it laparoscopically.

Well, 50% ain't bad, I guess.

<comment><USER6> Progress seems to always be extremely slow, and then it just happens remarkably fast. The scary part is you never know when the punctuated equilibrium will flip. Take CRISPR for example... sheesh.

You never know when they'll figure out scaffolding, could be sooner than you think. Could be later. Hopefully sooner.

</comment></comment><comment><USER7> TAVR is a remarkable advance. Interventional cardiologists are taking away lots of cardiotoxic surgery volume, and it's great for patients because it's much less invasive.

</comment><comment><USER8> Note that 'younger' in the title refers to people in their 70s as opposed to 80s, so perhaps confusing on Hacker News. From the article:

> _Aortic valve replacements have been performed for decades, and surgeons > know the valves placed during surgery last at least 10 to 15 years. It > remains to be seen if TAVR valves will fare as well. The question is > especially important for younger patients. The average age of subjects in > the current studies was the low to mid 70s, younger by a decade or more than > most patients getting TAVR now._

If anyone here needs a new aortic valve, you might also want to read about the latest results on the less-known Ross procedure and whether it might be suitable in your situation. It's been a thing since the 1960s especially for young patients (children) but I hadn't even heard of it until last year: [https://en.m.wikipedia.org/wiki/Ross_procedure](https://en.m.wikipedia.org/wiki/Ross_procedure)

Ouzounian, Maral et al. 2017. _The Ross procedure is the best operation to treat aortic stenosis in young and middle-aged adults_. The Journal of Thoracic and Cardiovascular Surgery [https://www.jtcvs.org/article/S0022-5223(17)31124-8/fulltext](https://www.jtcvs.org/article/S0022-5223\(17\)31124-8/fulltext)

</comment><comment><USER9> I'm 'young' and getting my second open heart surgery soon. Headlines like this are slightly misleading in that you have to have a pathology that will support tavr. In my case, I have a dilation of the annulus that apparently makes it less likley that a tavr valve can find a basis to stay in place. It has to be sown in.

</comment><comment><USER10> > "Open-heart surgery, particularly in low-risk patients, is very profitable," > Dr. Herrmann said.

Sheesh. For-profit hospitals are a foreign concept to me. Seems incredibly cynical to crack open someone's chest, leaving them with a very slow and painful recovery, to then think about profit instead of patient welfare.

<comment><USER11> Do you think the same about farmers who optimize profits on something that sustains life itself? Doctors just make you feel better and extend life a few years at best. Farmers, though, they make you tick every day.

</comment></comment><comment><USER12> I found out a few years back I've been living with ebstein's. I was surprised at the time to learn just how limited we are when it comes to heart surgery... It all seems to last 10-15 years and that about it. I'm glad to hear things are progressing for younger patients, but there's so much more work to be done.

</comment><comment><USER13> /offtopic

This article reminds me of Steve Yegge's dad and his experience with heart failure and having to go through a bypass surgery, post which, unfortunately, his femoral artery [0] burst, compounding more hardships on what had been an already tough ordeal. He wrote a letter to the hospital staff once he was back living his normal life: [https://sites.google.com/site/steveyegge2/really-no- big-deal](https://sites.google.com/site/steveyegge2/really-no-big-deal)

\--

[0] [https://en.wikipedia.org/wiki/Femoral_artery#Clinical_signif...](https://en.wikipedia.org/wiki/Femoral_artery#Clinical_significance)

<comment><USER14> That letter's wonderful. It was the first time I'd read it and I'm really glad I did. It's funny, slightly sad, and really well-written.</comment></comment>


Databases, The End User Experience - <AUTHOR> http://krow.livejournal.com/694408.html

<comment><USER2> I got excited thinking he was going to tell us how an end-user described a database (according to their non-technical understanding). No such luck :-(</comment>


Why should I use a pointer rather than the object itself? - <AUTHOR> http://stackoverflow.com/questions/22146094/why-should-i-use-a-pointer-rather-than-the-object-itself?newsletter=1&nlcode=47931%7c9e27 <comment><USER2> > note: in java, everything(except basic types) is a pointer. so you rather > should ask the opposite: why do I need simple objects?

I think this is by far the most important piece of advice in that thread. It gets right to the heart of one of the most basic areas of confusion that programmers coming from garbage collected environments to ones with manual memory management have.

They need to understand that they have NOT been working in an environment _without pointers_ , as they are often told to believe, but one in which _nearly everything is a pointer_. Understanding this is fundamental to understanding these differences and a 10,000 word essay about C++ allocation policies will not make it any clearer without dealing with that first.

<comment><USER3> I'm amazed at how many new programmers enter the workforce without a basic understanding of the stack and the heap.

<comment><USER4> Most of them are recent high school and college dropouts. What did you expect them to know?

They learned programming by reading blogs and pirated PDF files on BitTorrent. Of course they don't got a level of understanding most hackers here have.

You want a good programmer you need 15+ years of experience plus a good understanding of computer science, recent high school and college dropouts don't have that.

You hire a cheaper labor source, you won't get that level of quality a more expensive labor source will give you and you get what you pay for!

<comment><USER3> Well, to be fair, I don't have 15 years of experience (professional experience anyways). But I do believe the fundamentals are important and they seem to be glossed over.

</comment></comment></comment></comment><comment><USER5> Related Stack Overflow question: "C++: Why should `new` be used as little as possible?"

[https://stackoverflow.com/questions/6500313/c-why-should- new...](https://stackoverflow.com/questions/6500313/c-why-should-new-be-used- as-little-as-possible)

<comment><USER6> There are some very good answers to that question. Related to that question, I still fail to see any advantage to using shared_ptr, weak_ptr, unique_ptr, auto_ptr, etc. If you are doing C++ right, nearly everything should be allocated on the stack, and the things that aren't should be encapsulated in a class, RAII style. If you can't design your program so that the ownership and lifetime of your objects are clear, then you're using the wrong language, and shared_ptr won't save you.

<comment><USER7> The word RAII by itself is too non-specific. People typically mean: use (i) a scoped/auto pointer or (ii) a shared pointer (thats C++ speak for reference counted pointers). These are good thumb rules to rely on, but in itself they are very inadequate.

First, auto or scoped pointer gets you a stack discipline. If your objects weren't very big, you might as well create them on the stack itself. More efficient and suitable for multithreading. If the lifetime does not follow the lexical stack then you are out of luck with this style of RAII.

Next, reference counted pointers: Cycles are clearly a problem. The traditional mantra is: use weak pointers to break cycles, but then you are back to error prone manual management (of cycles). If I am to be trusted with using weak pointers correctly, I wouldn't be too bad with manual memory management either. Pure functional languages with eager semantics do not allow cycles, so are ref counts a good idea in such cases ?

Although, many do not think about it that way, reference counted system is a _garbage_collector_. Just a particularly simple one. Just because one understands how it works, does not disqualify it from being a garbage collection system. It is just not a very efficient garbage collector for cases where running time is sensitive to cache locality, which is true fairly often.

I am quite excited about Rust's regions. I dont think programming with regions is easy and you would want to have a garbage collector anyway. I hope this style of programming sees more mainstream visibility. Something should come out of all the MLton work on this. EDIT Indeed meant MLKit but it draws enough from MLton that I thought HNers would be able to relate.

There is also D's scoped guards, but I am not yet familiar with what they do.

<comment><USER8> [Regarding Rust:] > I dont think programming with regions is easy and you would want to have a garbage collector anyway.

I agree and I've been wanting to emphasize this too for a while.

I think it would help Rusts adoption a lot if it would get a good garbage collector while it's still young. Otherwise I think a lot of programmers will give up after stumbling around with borrow-checker errors when doing some things that are pretty trivial in other languages.

If we had a garbage collector, we could only worry about regions in the hot spots, that would ease many people's way into the language a lot, IMO.

<comment><USER2> I actually think the moves Rust has made away from an expectation of GC as part of the language will only help its adoption down the road. There are about 8 billion languages occupying some facet of the C++ With Garbage Collector niche and we don't really need another one. We need a better C++, and it's not a better C++ if you can't use it without a garbage collector, it's just another Java/D/Go/so on and on and on.

<comment><USER8> I agree it should be usable without a garbage collector, for sure.

But some types of algorithms which are allocation heavy (with dynamically sized parts) will just run much faster with a good collector, and are easier to write that way.

Also I've found that with regions, things get really complicated when structures contain borrows (and not every structure will logically own what it references), and then the structures become parameterized over the lifetimes, which multiply quickly.

For cases like that I'd rather start with a GC reference, and gradually remove GC references where time permits and profiling dictates.

I think Rust can really have the best of both worlds here.

BTW: I did manage to finish a fairly involved analysis program in Rust without using any GC, and I'm really very happy with the results. Being able to GC a few references would have made things easier though.

<comment><USER9>
      > For cases like that I'd rather start with a GC
      > reference, and gradually remove GC references where time
      > permits and profiling dictates.

Long ago this was one of the original theses of Rust, that you'd favor GC'd objects at first and then we'd provide easy ways to transition your code to use linear lifetimes where profiling deemed necessary.

It took us a long time and boatloads of iteration to finally realize that this just wasn't feasible. The semantics of GC'd pointers and linear types are just too drastically different, especially with how they interact with mutability and inter-task communicability. We "officially" abandoned GC in the language itself last October, and we're _still_ trying to wrest the last vestiges of its use out of the compiler itself. Ask pcwalton how much of his time has been spent doing exactly that in the past four months. Just yesterday one of our most tenacious community contributors proudly announced that an all-nighter had resulted in removing two more instances of GC'd pointers from the compiler, which required touching "only" a few thousand lines. It's a bad scene.

So yes, while Rust will still offer GC'd pointers in the standard library, we've long since learned not to encourage users to reach for them without great justification. You must understand that once you introduce garbage collection into your code, it will be very difficult to return from that path.

We've also, in practice, tended to point people toward RC'd pointers (with weak pointers to handle cycles) whenever anyone needs multiple references to the same piece of memory. Thanks to linear types, reference counting in Rust is actually surprisingly cheap (many instances where other languages would need to bump the refcount are simply achieved by moving the pointer in Rust, since we can statically guarantee that that's safe).

<comment><USER8> Thanks for the backstory, I may have been a bit naive then about how easy it would be to convert.

Good to hear about RC efficiencies, I assumed they were basically shared_pointer, I haven't tried using them and will give them a look.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER10> Can someone explain RAII to me? In the way that it's commonly used, it seems like it really means "stack variables that go out of scope are deallocated", which seems kind of, well, duh? I don't really understand why it's treated like a big deal.

(I mostly write C + Obj-C)

<comment><USER11> To better understand the importance of RAII, you might consider what some other languages offer to solve similar problems.

Consider a C example:

        int f()
        {
            int ret = -1;

            handle * a = acquire_handle(0);
            if (a == NULL) goto fail1;
            handle * b = acquire_handle(1);
            if (b == NULL) goto fail2;
            handle * c = acquire_handle(2);
            if (c == NULL) goto fail3;

            // use a, b, c
            ret = 0;

            release_handle(c);
            fail3:
            release_handle(b);
            fail2:
            release_handle(a);
            fail1:
            return ret;
        }

Consider a C# example:

        void f()
        {
            using (handle a = new handle(0))
            using (handle b = new handle(1))
            using (handle c = new handle(2))
            {
                // use a, b, c
            }
        }

Now a C++ example using RAII:

        void f()
        {
            handle a{0};
            handle b{1};
            handle c{2};
            // use a, b, c
        }

These examples are mostly equivalent (Although the C#/C++ assume exceptions instead of error codes).

The C#/C++ examples are far more structured and less error prone than the C example.

The advantage of C++'s RAII over C#'s using statement is that cleanup is tied to the object rather than a statement. This means that RAII is both composable and non-leaky as an abstraction. You cannot forget to destruct an object in C++, and you don't have to care that its destructor frees resources. When you have an IDisposable member in C# you must manually mark your class as IDisposable and then implement the Dispose method yourself. Clients must also be aware that your class is IDisposable in order to use it correctly.

<comment><USER12> Stylistic side note for C#: If you're nesting using blocks like that you can leave out the braces in all but the deepest instance which reads a little nicer, imho:

            using (handle a = new handle(0))
            using (handle b = new handle(1))
            using (handle c = new handle(2)) {
                // use a, b, c
            }

<comment><USER13> That actually looks terrible to me, but I don't program in C#. Mostly it's because there are three blocks, but it only looks like there's one.

<comment><USER12> It gets rid of excessive nesting when you need multiple resources allocated after another (e.g. SqlConnection, SqlCommand, etc.). You can do

            using (handle a = new handle(0), b = new handle(1), c = handle(3)) {
                // use a, b, c
            }

instead, too, but that obviously only works with equal types.

I'm usually not a friend of too deep nesting (worst thing I've seen in our codebase was 65 spaces deep) and in C# you already have one level for the class, one for the namespace (possibly) and another for the method. No need to add two more if you can help it.

<comment><USER13> Right, I understand that it removes excessive nesting, but the first example just looked ... wrong to me. Your example with above looks somewhat better.

</comment></comment></comment></comment></comment></comment><comment><USER14> I find it interesting that nobody mentions iterators anywhere in this discussion. One of the main uses of pointers is to iterate through data. Pointers are the most basic form of iterators in C++. STL iterators are based on, and often implemented in terms of, pointers.

</comment><comment><USER15> One interesting thing is that the QT framework prefers the use of pointers over reference variables. There's actually some reasonable logic here. Pointer syntax clearly shows you are acting on something in a different way than you act on an "ordinary" object. Reference object syntax is the same as ordinary object syntax but you are making changes that will go beyond the local scope and that is thus less obvious.

With this approach, you can still allocate objects on the stack - you then take their address and pass that to a subroutine.

<comment><USER16> Presumably, this pointer vs. reference debate is only relevant in C and no longer has a place in C++ with the use of unique_ptr, shared_ptr, std::move, etc?

<comment><USER17> C has no references -- 'type& param' \-- so there is no debate. This is a topic exclusive to C++, and isn't affected by smart pointers, which overload all the pointer operators in order to act like regular pointers, only with some sort of lifetime management.

</comment></comment></comment><comment><USER18> I audited a few MOOC classes.

They don't even bother to teach pointers, the stack, or heap. It just confuses the students they claim. Also teach students to store the value of PI into an Integer. Use DRJava and Java 6 and some bloated JAR library that makes Windows crash.

When I studied computer science in 1986, the very first things we learned where how memory and binary worked, plus what a pointer was and why it should be used and how to manage memory so it would not crash and lock up. We learned how to debug as well.

Most comp sci graduates that I talk to know almost nothing of how a pointer works, or the stack or heap, and binary might as well be Tagalog to them.

I think that over the years as the demand for IT workers increased, they relaxed the standards they used in teaching computer science and programming.

Any good MOOC should teach:

Pointers

The Stack

The Heap

Binary

Hexadecimal

How to debug code

Assembly Language instructions the code gets converted into and how to debug that

</comment><comment><USER19> One is allocating on the stack and one on the heap.

Allocating on the heap means you have to delete it yourself in C++.

It's pretty staightforward, no?

</comment><comment><USER20> It's not always obvious. Quite commonly one is used when the other would be better, even by otherwise good coders.

To beat the subject completely to death:

Pointers, References and Values

Passing Parameters, Returning Results, and Storing Member Variables with Musings on Good C++ Style

[http://www.warplife.com/tips/code/c++/memory- management/para...](http://www.warplife.com/tips/code/c++/memory- management/parameters/)</comment>


The Mirror Effect: The rise of mirrors in the fifteenth century - <AUTHOR> http://laphamsquarterly.org/roundtable/mirror-effect <comment><USER2> Fun fact: we are used to seeing our own faces in the mirror image of how others see us. Thus, if you have a picture of yourself which you really dislike, mirror it and see if it helps - on photos we see our faces mirrored from what we're used to, hence why they look off so often, and why it can feel so difficult to get the right picture from ourselves taken.

<comment><USER3> For several years, I parted my hair the way I liked the look. I'm embarrassed to say how long before I realized and reversed sides.

<comment><USER4> I didn't realize the connection until now (even though I understand the way mirrors work). Weird how one often doesn't take that one last obvious step of an inference.

I guess now I'll use a smartphone camera instead of a mirror for grooming.

<comment> d-sc Most front facing cameras reverse the image to make it look like you are looking into a mirror.

<comment><USER4> Yes. I just tried that now, and unfortunately, my S7 does reverse the image from the front camera :/.

<comment><USER5> There should be an option to flip the image somewhere though, to be the right way around.

<comment><USER6> Use a webcam with the always included AMcap application. Or skype, with the mirror option disabled.

</comment></comment></comment></comment></comment></comment></comment><comment><USER7> Nice article but I doubt the premise. Rich people had their portraits and sculptures made long before the invention. Think on Nefertiti or the multiple depictions in Egypt. Still in Egypt, there are Fayum Portraits. [https://en.wikipedia.org/wiki/Fayum_mummy_portraits](https://en.wikipedia.org/wiki/Fayum_mummy_portraits)

In Ancient Greece and especially Rome, there were hyper realistic sculptures of the rulers, generals and rich people. Pompeii art is realistic. Instead the article follows the path claiming that a technological invention brings with itself a change in human nature, a dubious argument always.

Even today with all the selfies, people still relate to themselves in relationship to how they are perceived by others. And there are a lot of beautiful people who think they are ugly...

<comment><USER8> The point of the article was that regular, ordinary people didn't see their own faces clearly until fairly recently, and when that happened it shifted the sense of self and identity with long-term ramifications.

<comment><USER9> You can always just look at your reflection in a dark, still, liquid, like soup, or dirty water, or clear liquid in a dark container, etc. Sure you're looking down and it's kind of inconvenient, but it's not like people couldn't see themselves ever.

<comment><USER10> Yeah, this was never a secret. The myth of Narcissus has him trapped by his own reflection in a pool of water.

Household mirrors go way back, although the quality of the reflection you could get was well below where it is now.

</comment></comment></comment></comment><comment><USER11> How would one characterize the difference between publications like Lapham's Quarterly or Nautil.us and publications like the New York Times or the Washington Post?

I've been trying to discover publications that are more like the former and less like the latter, but I'm not sure how to differentiate between the two well enough for, say, a Google search. Searches along the lines of "publications like Lapham's" haven't done the trick.

<comment><USER12> You'll probably like Cabinet Magazine as well. I'd refer to them as "art and culture publications", "literary publications", "alternative".

I think the best way of discovering interesting publications is to visit bookshops that carry ones that you've already discovered and grown to like. Generally independent bookstores around major universities will carry a lot of literary magazines, and other alternative low-circulation publications.

<comment><USER11> I never would have thought that brick-and-mortar would be the way to go. Thanks for the insight!

Also, I just gave Cabinet a peak, and it definitely looks interesting. Thanks again!

</comment></comment></comment><comment><USER13> Fun fact: mirrors don't reverse anything. Easily proven, raise your right hand while looking in the mirror. The hand in the right side goes up. No reversal.

What's gets reversed is when an observer looks at you. Since an observer is facing the opposite direction, his left side is aligned with your right side.

Alternate view: if a mirror really did reverse left from right, why don't they reverse top from bottom as well? Because they don't reverse anything. On the other hand, if an observer were turned upside down, you'd appear upside down to him.

<comment><USER14> This description is missing a key part which explains why it appears to reverse left and right. Mirrors reverse something: the direction perpendicular to the mirror. Mirrors can also reverse up-and-down just as easily as left- and-right. Imagine holding text printed on a clear sheet up before so that you can read it. Now look in a mirror that's behind the sheet. The text in the mirror is so readable, since it's reversed in the one dimension it has symmetry in (the thickness of the sheet). But now if the sheet were opaque, you'd only see the back of the page in the mirror and no text. So you flip the page around to read it. Now you've rotated AND mirrored the text and it looks swapped left to right instead of by the mirror's perpendicular direction: the rotation changes which axis was mirrored. Start again with the text facing you ready for reading, but now rotate the text to face the mirror again but this time do so in the 'unusual' manner of flipping it head over heel. Now the text in the mirror is mirrored upside down! Which rotation you apply changes which axis is apparently inverted. We're just so used to rotating things about their vertical axis that everything looks mirrored left and right.

Also there are mirrors which do reverse specifically left and right in the manner that you debunk above, but they are nonsymmetrically concave.

<comment><USER15> The way I try to explain it is in absolute (ish) coordinates:

If you face north, your image faces south. Your left hand is on your west side. The reflection of your left hand is also on the west side. If you grab the mirror and turn so you face west, your reflection faces east and both your left hand and the reflection are on the south side.

If you reset the mirror and then stand sideways (facing east, mirror to your north), your left hand is to the north and right hand is to the south. In the mirror, the image of your left hand is to the south and right hand, to the north. But your reflection is facing east, just like you are.

<comment><USER14> I think this is good too, but it leaves the reader with the original question "Okay, if the mirror _doesn 't_ reverse left-and-right, then why does it _appear to do so_?" A question which left me scratching my head for a while and frustrated that explanations given in otherwise excellent sources like Martin Gardner's The Ambidextrous Universe never actually addressed.

<comment><USER15> This is a good question and I think it's the perception that the person you see as a reflection is actually a clone turned around to face you. When you raise your left hand, your "clone" (if it is a clone) raises their right hand. If you imagine stepping through the mirror and turning around to stand next to your reflection you really will be reversed laterally compared to your reflection-twin.

</comment></comment></comment></comment></comment><comment><USER16> I wonder what effect the new convenient cheap mirror had on the profession of barber.

Did people shave themselves before mirrors became widely available?

</comment><comment><USER17> In many years it will be interesting to read what the effect of social medias have had on humanity. I'm suspecting not so good as initially thought.

</comment><comment><USER18> Cool article. I think I got my fill of general knowledge for today.

</comment><comment><USER19> I've often said to my friends and family, during more philosophical discussions, that the one object that has caused the most destruction to the human species is the mirror ..

<comment><USER20> Would you care to elaborate on that?

</comment></comment><comment><USER21> > _Previously the parameters of individual identity had been limited to an > individual's interaction with the people around him and the religious > insights he had over the course of his life. Thus individuality as we > understand it today did not exist: people only understood their identity in > relation to groups—their household, their manor, their town or parish—and in > relation to God._

This is a ridiculous argument. But par for the course for what passes as serious scholarship in the humanities these days.

See: [https://en.wikipedia.org/wiki/Sokal_affair](https://en.wikipedia.org/wiki/Sokal_affair)

And Richard Dawkin's great piece: [http://www.physics.nyu.edu/faculty/sokal/dawkins.html](http://www.physics.nyu.edu/faculty/sokal/dawkins.html)

<comment> shawn-butler And your post is equally ridiculous as critique.

If you disagree with the assertion post some disputed evidence. If you just want to dismiss it with a virtual eye roll then just ignore it instead.

The essay made me think about the rise of selfie culture and its impact. On a recent trip at every cultural vista I would say 80% of the cameras were pointed at their owners with the landmark posing as a simple adornment of their own face.

Snapchat has made billions on this recognition. That you huff and puff about scholarship "these days" like a grumpy old man is largely irrelevant to the value of the linked article.

<comment><USER21> > _That you huff and puff about scholarship "these days" like a grumpy old > man_

Are you really going to defend the state of the humanities disciplines? I'd love to read your attempt at a reasoned defense of postmodernist drivel.

<comment><USER22> The humanities are incredibly diverse fields filled with tens of thousands of very different scholars- dismissing all of their work because you've seen a couple of silly examples purposefully chosen to be inflammatory is anti- intellectual by very definition.</comment></comment></comment></comment>


Dummy houses in the heart of London (2007) - <AUTHOR> http://www.urban75.org/london/leinster.html <comment><USER2> Toronto has quite a few fake houses used as transformer stations with some looking pretty out of place with the boom in condo development.

[http://spacing.ca/toronto/2015/02/18/transformer-next- door/](http://spacing.ca/toronto/2015/02/18/transformer-next-door/)

[https://www.blogto.com/city/2010/10/toronto_hydros_not-so- hi...](https://www.blogto.com/city/2010/10/toronto_hydros_not-so- hidden_residential_substations/)

</comment><comment><USER3> LA has a few camouflaged oil derricks! [https://www.theatlantic.com/photo/2014/08/the-urban-oil- fiel...](https://www.theatlantic.com/photo/2014/08/the-urban-oil-fields-of- los-angeles/100799/)

<comment><USER4> More info about these: [https://www.stand.la/pico-blvd-drill- sites.html](https://www.stand.la/pico-blvd-drill-sites.html)

</comment></comment><comment><USER5> I've walked down there a few times, and never realised they were fakes. So they're quite effective.

</comment><comment><USER6> Dummy houses have been used to hide military bunkers [1].

[1] [https://en.wikipedia.org/wiki/ROTOR](https://en.wikipedia.org/wiki/ROTOR)

</comment><comment><USER7> A lot of real houses would benefit from having such a fake facade put in front of them.

</comment><comment><USER8> There is a railway tunnel in Burnaby, BC with a ventilation structure disguised as a house.

[https://www.google.ca/search?q=burnaby+tunnel+ventilation&oq...](https://www.google.ca/search?q=burnaby+tunnel+ventilation&oq=burnaby+tunnel+ven&aqs=chrome.1.69i57j33l3.5420j0j4&sourceid=chrome- mobile&ie=UTF-8)

</comment><comment><USER9> Also cell towers that look like trees: [https://www.vox.com/2015/4/19/8445213/cell-phone-towers- tree...](https://www.vox.com/2015/4/19/8445213/cell-phone-towers-trees)

<comment><USER10> Makes me wonder why the cell equipment can't be mounted atop an actual tree.

<comment><USER11> Trees aren't stable enough, and they tend to drop branches or occasionally fall down entirely.

</comment></comment></comment><comment><USER12> Here is a water pumping station. Could have done a better job with the telemetry antenna.

[https://goo.gl/maps/hNk7cUphLJy](https://goo.gl/maps/hNk7cUphLJy)

</comment><comment><USER13> Great photos, thanks! Reminds me of the "the world's only Greek Revival subway ventilator" in Brooklyn:

[https://en.m.wikipedia.org/wiki/58_Joralemon_Street](https://en.m.wikipedia.org/wiki/58_Joralemon_Street)</comment>


Ask HN: Need advice on Programming - <AUTHOR>

So right now in my life I work at a shitty job that pays $13hr and long hours in the freezer warehouse.
I'm 25 and I want something better for myself as far as money goes and the work is less stressful than standing for 10 hours a day and doesn't pay well.
Is programming the way out? I like web development and I've practice JS and Python but not a professional.
Can programming set me free?
Where do I go to get started and how long will it take to get a job working as I am right now.
What if I want to program from home is that possible? <comment><USER2> I don't know if programming will set you free, but I can try to offer a bit of advice (no guarantee that it's good advice :) )

Firstly, it's great that you've learned some Python and JS. Rather than trying to learn two languages, I recommend you focus on JS, because I think you're more likely to break into the industry as a front-end dev than a back-end one (and, once you're good at JS, you can always use Node for back-end stuff if you want to).

"Javascript: The Good Parts" is probably a good book to read.

Don't just learn JS. Try to learn HTML and CSS too. The better you can get at this trio the easier it'll be for you to pick up some small jobs where people need a jack-of-all-trades to help them with their site. If you don't have any contacts, or don't live in a big tech area, then you should take a look at one of the freelancing sites like odesk. You'll have to start off at the bottom, and you'll be competing for bids against people who live in places with a much lower cost of living, so you may not make much at first, but you'll get some real world experience. If you can learn and persist you should be able to build up your reputation and skills to increase your rate, or to switch into a full-time role.

Hope this helps - good luck!

<comment><USER3> I'd very strongly recommend against starting with freelancing jobs. You don't have experience dealing with clients nor building software. Find a stable job as a junior dev at some company and don't be afraid to ask questions. The first year or two will get you some perspective about the industry and you will gain some experience. After that, you can try freelancing or getting a better job.

</comment></comment><comment><USER4> It sure is possible.

When I got out of the army I had no degree, no professional experience, just what I had taught myself and learned in a few classes that I had taken along the way.

I went to work at a software sweatshop that had low pay and long hours but after about a year I was able to get another position just based on that experience... eventually I got a CS degree from an online school just to get the HR people to shut up, but you don't need it, and frankly if you can teach yourself effectively it is a waste of money.

I would recommend trying to get some small freelance gigs that you can easily handle and do those in your off hours. I know you are working a lot already but it is only for a short time. If those jobs work out and you can replace some of your income, consider cutting back on the warehouse hours if you can, and focus on landing a full time job or being a full time freelancer.

If you want a great learning experience, consider getting involved with an open source project ... find one you like, get on the dev mailing list, tell them what your skill level and goals are, and tell them that you want to be involved. Unless the project is run by a bunch of assholes they'll have something appropriate for you to contribute and will help you learn amazing things.

Stay cool, stay humble, and you'll do great. And BTW read this if you haven't already: [http://catb.org/~esr/writings/taoup/](http://catb.org/~esr/writings/taoup/)

Good luck!

</comment><comment><USER5> Watch this video to give you a good idea of what it takes to be a Front end developer now days.

[https://www.youtube.com/watch?v=zXqs6X0lzKI](https://www.youtube.com/watch?v=zXqs6X0lzKI)

Build tons of websites with just basic HTML/CSS then when you can drop code on demand and build a website without looking everything up learn javascript inside out like your life depends on it. Do not learn JQuery yet. Wait till you are a guru at Javascript before moving on to frameworks. Yes you have to learn the javascript frameworks. My suggestion would be to learn backbone.js , require.js, then when you get really good at the MVC give angular.js a shot.

This link will take you to a roadmap to learning javascript the proper way.

[http://javascriptissexy.com/how-to-learn-javascript- properly...](http://javascriptissexy.com/how-to-learn-javascript-properly/)

</comment><comment><USER6> Yeah it is man. I did the same thing and I used to work in restaurants. It was always a hobby and then it became a job. Yes, I even worked from home too.

I would actually recommend against working at home though. It's a catalyst for laziness, loneliness, and fatness.

The world never did, and still does not, take place in your own home. It's out there. Outside.

Key thing is you must be dedicated to what you're doing and not quit... You'll find tons of instructions on the specifics but the key thing is to always find time to code. I used to get home from work at 2-3AM. After that I would shower and pound some coffee or red bull then code until dawn. That is the kind of dedication you will need to break out of your routine.

Honestly it will be easy to find a job if you build some impressive projects for your portfolio... Worry less about what they are and more about the quality level and how they look.

<comment><AUTHOR> I guess I get lazy when it comes to programming I think to myself this will take way to long to learn and quit.

<comment><USER6> It does take a long time. If the only reason you want to do it, is money, then you're going to have a difficult time.

If you love it, then you're good.

</comment></comment></comment><comment><USER7> I've done this myself - I've been programming as a hobby since around 5th grade, but never did anything serious with it. I'm now 27, and am in my 3rd year at my first "professional" development job. My career before that was as a Paramedic ($14/hr).

Some quick advice, in no particular order:

1\. Get on GitHub. Look at the source code for libraries/programs that you like and use. This'll show you how other people do things. Look at the "issues" tab and help fix some projects or add new features. Also, most places use Git for version control. It can be a beast to wrap your head around at first, but it's not that difficult once you start using it.

2\. Look on employment sites and see what kind of requirements they have. Do you want to be a JavaScript developer? You'll probably want to know Angular, Knockout, etc. Want to work as a Python developer? You'll probably need to be familiar with Django framework. Then, there's all the other stuff for build automation and testing - grunt, composer, bower, phing, nose, etc.

3\. Stay away from frameworks and IDE's while learning. Use a text editor, not Dreamweaver, NetBeans or Eclipse. Notepad++, Sublime text, emacs and vim are all common favorites. Learn the frameworks, but don't rely on them. It's easy to gloss over the details and just use the framework "as-is", but you really need to understand what's going on under the hood.

4\. Learn Linux, if you don't know it already. Most developers I know are responsible for server administration stuff, too (to some degree anyway). Know how to tail an error log, configure the webserver of your choice, create a MySQL user, SSH to a machine, WGET a file, etc. DigitalOcean, Koding, and many others offer you a very affordable linux box to play with ($5-$10/month or less). (With virtual machines, you can screw up all you want, then just revert to a snapshot)

5\. Learn how the internet works. This should go without saying, but it'll keep you from banging your head off the wall when your AJAX application isn't working because you didn't know CORS was a thing.

6\. Look into "fizzbuzz" tests. They're short, simple programs that an employer may ask you to solve. These are good at weeding out people who know how to rearrange framework functions, but don't know how to program. [http://blog.codinghorror.com/why-cant-programmers- program/](http://blog.codinghorror.com/why-cant-programmers-program/)

You don't have to be a pro to get paid. Apply to jobs at small to medium-sized companies that don't have an HR department to throw away your degreeless resume. Check craigslist, freelance sites, etc. Build a portfolio.

As far as working from home, I'm still waiting on that opportunity myself. There are plenty of jobs out there that allow it (google is your friend), so just apply and see what happens.

Good luck!

See also: [http://programming- motherfucker.com/become.html](http://programming-motherfucker.com/become.html)</comment>


Why people love Stieg Larsson's Novels - <AUTHOR> http://www.newyorker.com/arts/critics/atlarge/2011/01/10/110110crat_atlarge_acocella

<comment><USER2> While I didn't care so much for the violence, I thoroughly enjoyed the novels. I thought they had a comparatively unusual plot and unusual characters. They are definitely much better written than, say, Dan Brown novels.

Funny to see the the NYT complain about 12 page long boring descriptions. Surely any regular reader of the NYT should have no problems to cope with those.

Also that article just quotes things out of context to make them sound silly.

<comment><USER3> Funny, I place Stieg Larsson and Dan Brown in the same section: writers who are good at constructing a compelling story, but not so good in actually writing it down.

With Stieg Larsson, I got really annoyed with the amount of boring expositions, pseudo-cliffhangers at the end of every other chapter, overuse of clichés ("and then they talked for X hours"), etc.. It reads like a very rough draft of a book, not as an edited text ready for publication.

That said, I've read both authors and enjoyed the books. I just feel that they could have been so much better with some serious rewrites (as apparently the English translation of Stieg Larsson had, I have to check that one out).

<comment><USER4> _It reads like a very rough draft of a book_

Given that Larsson died before the final edits where completed, that is probably a quite accurate description.

<comment><USER3> I suspect the same. I've considered reading the one of the books in English also just to see if they are improved. I found Dan Brown to be slightly less annoying in Swedish than in English, since some parts had been cleaned up.

</comment></comment></comment></comment><comment><USER5> Single page link: [http://www.newyorker.com/arts/critics/atlarge/2011/01/10/110...](http://www.newyorker.com/arts/critics/atlarge/2011/01/10/110110crat_atlarge_acocella?currentPage=all)

</comment><comment><USER6> > (And that welfare state may soon be disabled by the recently elected > conservative government.)

Uhuh. They've been in power since 2006 and the welfare state has not been "disabled".

<comment><USER7> The Swedish economy is basically the envy of most countries in Europe at the moment.

<comment><USER8> You're probably wasting your time. The US has its own Steve Jobs-esque distortion field when it comes to politics. I'm not sure the majority of them could ever be educated what "left" and "right" actually mean and you'll _certainly_ never convince them that both their main political parties are actually center right and far right.

<comment><USER9> This "distortion field" sounds suspiciously like relativity. Are you sure you aren't just declaring your political sphere the center of the universe and labeling anyone who uses a different reference point as a heretic?

<comment><USER8> Wait, what? I'm declaring _the rest of the world_ the "center of the universe" and labeling _the one_ (first world) _place_ that uses a drastically different reference point as wrong.

</comment></comment></comment></comment></comment><comment><USER10> The "funniest" part is that there really was a a scandal recently in Sweden about an upper class guy using his position for e.g. raping and abusing women.

He was a police chief which, despite police union criticism, got reinstated by the social democrat minister - because he was so politically correct...

Quite fun, considering the political leanings of Larsson.

<comment><USER11> Hmm source? I assume you mean Goran Lindberg, but there is nothing out there about him being reinstated to anything after being convicted. In fact wikipedia says he is in prison right now. How has he been reinstated?

I don't know what this has to do with Larsson at all.

<comment><USER10> Sorry for the late answer, I was busy today and didn't check hn until now, long after it went from the front page.

Lindberg was going to be fired because of complaints from the employees -- but he got reinstated, by Bodström himself! That was a few years before the big scandal.

That is well known and has been in the major media. Google gave me this link. IIRC, I originally read it in DN or SvD.

[http://www.expressen.se/nyheter/1.1862998/lindberg- raddades-...](http://www.expressen.se/nyheter/1.1862998/lindberg-raddades- kvar-av-bodstrom)

>>I december 2002 skickade polisfacket i Uppsala ett brev direkt till justitieminister Thomas Bodström där de krävde att Lindberg skulle avgå.

>>– Från justitieministern fick vi inget svar över huvud taget, säger Gunnar Elrud, som då var ordförande för polisfacket.

(And being at -3 in the original comment for posting well known facts, while that simple questioning got +11, is really funny...)

<comment><USER11> You may be right, I do not speak Swedish, so I cannot read your references. It really depends on how believable the complaints were.

But nevertheless your post was misleading because you made it sound like he was reinstated after the scandal. Also, again I do not really see the connection with the writer Larrson. Just because he is a leftie, he is not responsible for every remotely left wing politician out there.

<comment><USER10> Try translate.google.com

Ah, you mean it can be read as being reinstated after the crime last year? Sorry for being unclear, I was on the way into meetings.

The connection is that there _really_ was a conspiracy where someone was misusing power and influence -- but it was _political_ influence with a left wing government, because the psychopath claimed to be so politically correct...

Considering that Larsson was too left wing for the normal communist party, that was quite funny.

Edit: To back my claim about Larsson's politics, consider that Larsson was active with Eritrean guerrilla fighters. That regime he supported is much, much worse than even that rapist psychopath of a police chief...

[http://www.guardian.co.uk/books/2010/oct/15/stieg-girls- with...](http://www.guardian.co.uk/books/2010/oct/15/stieg-girls-with-grenade- launchers)</comment></comment></comment></comment></comment>


Questions to ask yourself when writing tests - <AUTHOR> https://charemza.name/blog/posts/methodologies/testing/questions-to-ask-yourself-when-writing-tests/ <comment><USER2> "consider instead writing higher level tests that each each test more of the code."

I really like the way they keep repeating this as the answer to so many questions. To me it reads as a softly softly approach to weaning people off what appears to be a mania for micro level unit testing, driven by people like Uncle Bob.

<comment><USER3> > ... micro level unit testing, driven by people like Uncle Bob.

"The structure of your tests should not be a mirror of the structure of your code. The fact that you have a class named X should not automatically imply that you have a test class named XTest."

"The structure of the tests must not reflect the structure of the production code, because that much coupling makes the system fragile and obstructs refactoring. Rather, the structure of the tests must be independently designed so as to minimize the coupling to the production code."

[http://blog.cleancoder.com/uncle- bob/2017/10/03/TestContrava...](http://blog.cleancoder.com/uncle- bob/2017/10/03/TestContravariance.html)

<comment><USER4> I really wish Uncle Bob would provide code examples with his blog posts and videos. I struggle to imagine what my tests would look like if I followed this. Possibly as my tests are so tightly coupled right now that refactoring is actually not possible in some cases.

Does anyone know of explations of this with a more hands-on approach, or is this simply a collection of ideas that can't really be shown?

<comment><USER5> I've been wondering about that for a while.

So far, I've not been able to find any examples of test architecture that follows those principles online or in my day job.

I've also been too lazy to do a side project and explore a more decoupled and scalable test suite. Maybe I should get off my arse and finally do it.

<comment><USER6> If you're writing a web application, i've had a reasonably happy time with tests at the controller level, or perhaps right below. You want an interface where values go in and out that correspond to fairly user-level ideas, but which are still tractable for testing.

</comment></comment></comment></comment></comment><comment><USER7> The most important thing here seems to be "For every part of my code change, if I break the code, will a test fail?". Or as I'd put it "if you break the code deliberately does the test actually fail?".

Seen quite a few tests in my time that don't capture the functionality they think they are. They pass but wouldn't be able to tell if the underlying functionality they capture is genuinely broken. This is why I guess the standard practice is to go test red before you go test green.

</comment><comment><USER8> The most important question to ask when writing tests: Can I do this faster if I don't write a test?

The answer is always no. Even if you are the only person building something, future you will lick your boots clean in gratitude if there are tests.

Because even the best developers have to work with their own code sometimes.

<comment><USER9> >Can I do this faster if I don't write a test? The answer is always no.

I think the answer is mostly no but it's dangerous to think that it's always no.

I've been given many stories in the past for which writing a realistic automated test would have taken days, manual verification took minutes and the code was fairly isolated and did not get changed very frequently.

Writing a test under those circumstances is actually a pretty poor investment.

<comment><USER8> I would be very surprised if an automated test literally took days to write when a manual test is just minutes.

Also the time savings still pay off later, as automated tests usually take seconds to run and there's no training required - once it's in the test suite and the test suite runs are automated, it will always run and quickly identify a failure - no "oops, we forgot to show Jim the Intern that he had to test that part manually..."

Setting up your test suite and automation is longer for sure, but not days. Even a complex manual process can be automated relatively quickly... the manual process should be fairly scriptable in any OS nowadays, and most platforms have great test frameworks.

<comment><USER10> Think about something that necessarily involves hardware interaction, or a GUI, or where all the interesting error cases are non-deterministic (concurrency, network error handling). Ok, on the last one you're pretty much hosed anyway. But we're not all writing nice data-in/data-out apps.

<comment><USER9> Actually, I probably wouldn't count network error handling, because you can probably use something like vaurien - [https://github.com/community- libs/vaurien](https://github.com/community-libs/vaurien) \- to deterministically mimic bad network conditions in an integration test in a fairly reasonable amount of time.

Also, integrating that tool would probably have applications beyond a single story so even if the change takes 5 minutes and making the test work with vaurien takes half a day, it's probably still worthwhile.

Assuming that no tool like vaurien exists, though (and there are plenty of scenarios out there where you'd have to build it from scratch), building the test scenario could become prohibitively expensive.

</comment></comment></comment></comment></comment><comment><USER11> Here are some more questions:

How much business value is this test adding? That is, if this test failed and we ignored it, how much would the business suffer?

Is the code easy to test? That is, does the design have lots of self-contained components with well-described input/outputs & conditions/assumptions? Do the docs clearly communicate that?

Will the test still work if we change the implementation? How much work to update/remove the tests if the behaviour has to change to follow new business requirements?

</comment><comment><USER12> > Have I just made something public in order to test it? > > If yes, consider > instead writing higher level tests that each each test more of the code.

This is one that I struggle with in JS with React.js components. If you have a little helper component in a file that isn't exported but used in the same file by a component that is exported, it is sometimes difficult to test that non-exported component. Because of how enzyme shallow rendering works you don't get the full tree so that component, if sufficiently nested, might not ever be touched. This forces me to export the component just to test it.

example: [https://imgur.com/a/gqgcS](https://imgur.com/a/gqgcS)

<comment><USER13> I run into the same problem with React and it bugs me from a testing standpoint.

Extracting code from a big component to helper functions and extracting those functions from the component can lead to cleaner code, and it makes it much easier to test the behaviour of the helpers directly than having to render the component with enzyme.

A good example of this is moving state changes to pure functions [1] which makes them much easier to test, but you'll need to export those functions to test them.

1: [https://twitter.com/dan_abramov/status/824310320399319040](https://twitter.com/dan_abramov/status/824310320399319040)

<comment><USER12> that is a really cool technique, thanks for the link!

</comment></comment></comment><comment><USER14> > Mocking introduces assumptions, which introduce risk.

This boils down something I've had on my mind a lot of late. Though, with a different spin. I write a lot of Go. I prefer testing interfaces while some others what to use mock generators. This quote captures part of my reasoning behind avoiding mocks. I plan to write a detailed post at some point full of examples. I think this quote will work its way in there.

<comment><AUTHOR> I would be interested in reading it... if / when, if you can send me a link, that would be great!

</comment></comment><comment><USER13> Couple more which haven't been mentioned yet:

\- Can I run the tests in random order?

\- Are the tests optimised for readability?

\- Are the tests unnecessarily testing third-party code?

\- Do individual tests contain the whole story? (Or do you have to look in many places to understand each test?)

<comment><USER15> Being able to run tests in a random order is indeed pretty important. It is not only an indicator that the features were written with high quality, but that the tests are high quality as well. Things such as the mocks mutating happen and the developer writing the tests should avoid those kinds of things happening.

</comment></comment><comment><USER16> I'm glad to see that increasingly people are recognizing that shallow mocks of an API interface are not very good at testing anything.

</comment><comment><USER17> I'll add a couple more

Can I run these tests more than once? Will they ever go stale? Can I run these tests and they'll clean themselves up?

Having to update tests because they didn't take into account the date changing (Happy birthday Joe Test!) or manually cleaning up data is a huge time suck.

</comment><comment><USER18> Here are 3 more questions:

      * Are these tests relying on API that is likely to change?
      * Can I make the API surface area used by all tests even smaller?
      * Can I make a library that wraps the existing API of the unit to
        get a smaller and/or more stable API for use in the tests only?

These 3 help get tests that withstand refactors.

An example:

An acceptance test for an editing form is relying on the save button having a certain CSS style to find it and click it. This is API that is likely to change. An unrelated change in the looks of a button may break the test.

If we switch to using the text of the button ("Save"), that's better because that is what the user is likely to rely on too when they try to find a sav button. But its still not perfect as the text of the button could change.

The final step is to make a little library function that finds a save button within a certain form. Then we can encode the logic of the test but vary the kinds of text that are considered "save" (or even the method of finding a save button - perhaps a standard CSS class of save buttons in the future!); the test logic itself remains "permanent" since it doesn't rely on any implementation detail anymore.

<comment><USER19> A small library function like document.getElementById?

<comment><USER18> The example wasn't perfect, but no, it wouldn't be that. What if in the future we have a screen that needs to show more than one save form? Then we'll need to stop using the "save" element id as a mechanism to denote save buttons; to do that, we need to update all the tests that rely on this mechanism.

The small library function would be `getSaveButton(form)` or even `save(form)` - now every form save test no longer encodes the knowledge of how a form's save buttons are made, whether that's by using a certain ID, class, text or anything else.

Now when we get that requirement for a screen with two forms, we'll no longer get mad and try to attack the idea (two save forms on one screen? that's inconsistent with our product, its confusing the users, etc etc) when the real reason is that it creates pain updating our tests. Instead we just update the save function.

The general idea is to encode the meaning of the test and separate the implementation details (clicking the save button might even be too concrete - "saving the form" is probably about the right level of abstraction). A good way to do this is to describe this test in prose and check if its encoding details that may vary - does this sound like something universally true / something that will be true forever, or accidentally true due to current circumstances?

</comment></comment></comment><comment><USER20> Here's one more. Is maintaining this test more time and work than testing manually?

</comment><comment><USER21> The author does not cover any question related to application security. Things like is this parameter/input value properly sanitized, does this piece is/is not vulnerable to injection attacks, does this piece of code performs authentication/authorization checks? Is RBAC properly implemented for this method?

<comment><USER22> I agree with some cases, but "is this parameter/input value properly sanitized" is a bit weird. It should only every apply to a) the db framework, b) those N really weird cases that have to break the abstraction and don't use the db framework. If you have to test every input, then the problem is on a completely different level than missing a test.

<comment><USER21> Kind of, if you have a centralized place to perform input data validation, as it should, then it is just a matter to test that piece of code same if you are using a framework. However, I don't understand why you refer to a db in the first place? Is it because I used the injection attack as an example? if that's the case bare in mind that Injection target other interprets as well not only a db.

But getting back to my original idea, what I want to highlight the need of adding cases to cover application security.

<comment><USER22> Yeah, my mind substituted parameter with query parameter. Too much database stuff at my $dayjob recently and I get tunnel vision ;-)

<comment><USER21> lol! thanks for your comments.

</comment></comment></comment></comment></comment><comment><USER23> >> "For every part of my code change, if I break the code, will a test fail?"

Since "breaking code" is super subjective, and generally speaking, trying to "cover everything" is a recipe for hell.

Anyone able to expand on what the author meant by this?

<comment><AUTHOR> Perhaps this part is not clear / well defined, but roughly, I meant that code coverage is (about) 100% for the lines added/changed, and some "reasonable" subset of possible breaking changes would be picked up by failing tests.

What I had in mind specifically in the answer, was the case of changing "interfaces" between parts of code. For example, the case of changing a function's arguments, or how it uses them, but omitting to change a call site. Checking that the call site just calls the function would not be enough to produce a failing test, especially without type safety. The test would actually need to assert on what the function does, e.g. its return value for a pure function.

Yes, I think trying to test against every single possible breaking change is not valuable.

</comment></comment><comment><USER24> Looks like Michal has been immersed in Haskell for at least the past year. I wonder if he will have something to say about balancing testing and coverage with static typing.

<comment><AUTHOR> Thinking about this, at the moment, I don't think static typing is a replacement for testing (or vice versa!). Although, apparently, with something like LiquidHaskell, you can get more logic "into" the types and checked by the compiler, but I'm unsure how much you can do when it comes to more complex business logic.

Regarding testing "glue": static typing often gives evidence (but not proof) that code is glued together appropriately [refactoring even small projects without tests in Haskell is a joy: the compiler essentially tells you what to change]. However, it doesn't give evidence that the high level behaviour is what it needs to be. So I think higher level tests are still needed.

I think maybe changing the first question from...

> Am I confident the feature I wrote today works because of the tests and not > because I loaded up the application?

to...

> Am I confident the feature I wrote today works because of the tests and type > checking, and not because I loaded up the application?

will probably help you to answer the question about how much static types allow you to forgo tests. My instinct is that in most cases, high level tests are still worthwhile.

<comment><USER24> I'm thinking much the same, though I do think of tests as looking after the dynamic behaviour and types after the static behaviour. Which seems obvious in retrospect, but once you wrap your head around it you can build neat abstractions like lightweight static capabilities: [https://github.com/yawaramin/lightweght-static- capabilities](https://github.com/yawaramin/lightweght-static-capabilities)

</comment></comment></comment><comment><USER25> 1\. Am I paid to write tests?

<comment><USER26> Yes. You are paid to write working software.</comment></comment>


Coronavirus Sparks a Global Gold Rush - <AUTHOR> https://www.wsj.com/articles/coronavirus-sparks-a-global-gold-rush-11585332624 <comment><USER2> No paywall: [http://archive.is/Iu89A](http://archive.is/Iu89A)

<comment><USER3> [https://en.m.wikipedia.org/wiki/HTTPS](https://en.m.wikipedia.org/wiki/HTTPS)</comment></comment>