Business Practices

When trying to think of what would be the safest business practices one could follow, I tried to consider which companies had the highest requirements for safety as those would likely have some good imitable business practices. Suddenly, it hit me — NASA. I figure if you’re sending things (and people!) into outer space, you probably try to have pretty safe code.

As it turns out, one of the things NASA does is follow a set of ten rules for “safety critical code”. I won’t enumerate them in this post, but you can find a PDF with them here. Most of the rules have to do with code readability and simplicity (for example: they forbid recursion or functions which are longer than a page printed). I think codifying the need to write simple, easy to read code is an essential business practice. It can assist greatly with debugging, code reviews (by others or even yourself), and adding features in the future. If people aren’t struggling just to read your code, they’re much more likely to catch any insidious bugs you might have.

A rule worth picking out specifically is rule 7, which is essentially, “Thou shalt always check thy return values”. I have literally never had something like malloc fail in any code on any system I’ve worked on unless something else had already gone hideously (and obviously) wrong. I imagine I’m not alone in this experience. It becomes easy to not check the return values of these functions that “always work”, but if your code is really safety critical, you don’t want some horrible tragedy to occur because of some cosmic rays.

Finally, the last rule also deserves some special mention. It states that all code should be compiled with as many warnings as possible enabled, and all code must not produce any warning when compiled. It also states that all code must be checked with at least one static analysis program (which will have its own set of things to complain about), and that must also produce zero warnings. I think it’s easy to not concern yourself with the warnings (after all, your program compiled and ran, right?), but they are a good first line of defense from rare or well-hidden bugs — you’re being warned for a reason, after all.

References

Click to access P10.pdf

https://en.wikipedia.org/wiki/Soft_error#Cosmic_rays_creating_energetic_neutrons_and_protons

Waymo v. Uber

Waymo v. Uber is a lawsuit scheduled to go to court today (if this is read Monday, otherwise pretend I said February 5th, 2018). Waymo, a division of Alphabet inc (the parent company of Google) is suing the “ride sharing” company Uber for allegedly stealing trade secrets.

Waymo is Alphabet’s self-driving car division, and Uber hired one of their engineers, Anthony Levandowski, “who had taken 14,000 internal files without authorization before leaving Google.” Uber, on the other hand, maintains it didn’t do anything wrong when it hired Anthony and also paid “$680 million for his startup.”  In addition, Uber has fired Levandowski since the case began, as he refused to comply with subpoenas (though this could be part of Uber attempting to distance itself from Levandowski).

The burden of proof on Waymo is rather high, as trade secrets aren’t as protected as patents and copyrights and, “Waymo will need to prove that Levandowski stole its information, that Uber knew it, and that Uber incorporated [the information] into its self-driving car technology.” If it is proven that Uber acted inappropriately, the payout could be “billions.”

There aren’t enough facts about the case to make a firm judgement one way or the other, though if I had to go with an admittedly biased gut feeling I would say that Uber is guilty. Uber is one of those companies that seems to constantly skirt the law and venture in to gray (and not so gray) areas of ethically (see: hell and greyball for two quick examples), but sticks around because people like the service it provides. Levandowski has also been known to double dip —  he worked at 510 systems and sold products to Google while simultaneously working at Google itself. He later sold 510 systems to Google for “just shy of $20 million” which was just below the line where 510 employees would have received equity payouts.

I also think it will be difficult to prove — maybe too difficult — and Uber and Levandowski stand a good chance at walking away from this scot-free. If that happens, I wouldn’t be surprised if Levandowski released a book titled: “If I Did It: Confessions of an Intellectual Property Thief”.

References:

https://arstechnica.com/tech-policy/2018/02/quest-to-dominate-self-driving-cars-is-at-the-heart-of-waymo-v-uber-trial/

The Guest

“The Guest” by Albert Camus is a condemnation of indecisiveness and inaction. Daru, a schoolmaster and our protagonist, was faced with a decision: he could either set an Arabic prisoner accused of murdering his own cousin free, or he could take him to a prison in Tinguit. Instead of one of these choices, Daru opted to take a third route and allowed the prisoner to decide his own fate. This ultimately led to the most negative outcome for the schoolmaster — an old acquaintance of his was insulted, the prisoner headed toward Tinguit, and a threat to Daru’s life was written on his chalkboard by members of the prisoner’s village.

At several points in the story, Daru reveals that his true inner desire is for the prisoner to have his freedom. Initially we see this with Daru’s insistence that he won’t turn the Arab in, stating “every bit of this disgusts me” (Camus, 69). Later, when the prisoner gets up in the middle of the night to relieve himself, we see our protagonist think, “He is running away … Good riddance!” (Camus, 72). With these previous examples, it is still possible that Daru merely wishes to avoid the onerous task of delivering the prisoner to Tinguit, rather than wanting the man to go free. It is toward the end of the story that we find Daru’s true feelings, as the sight of the prisoner marching dutifully toward Tinguit leaves Daru with a “heavy heart” (Camus, 74). Then, driving home Camus’s disdain for our protagonist’s inaction is the fact that the prisoner’s village still believes Daru has turned in their compatriot and has sworn to get revenge — even though the schoolmaster did no such thing (Camus, 74).

The authorial intent in “The Guest” is strongly influenced by Albert Camus’s life and beliefs. “The Guest” takes place in Algeria, where Camus was born, during the end of the French’s control of the area in a time where “even the most fundamentally decent of civil servants [was] forced the share the blame for … a callous example of colonial injustice” (Camus, 64-65). Camus spent a large portion of his short life combating injustice and tyranny with his writing. He was an editor for Combat, a Resistance newspaper during World War II, his novel The Plague was symbolic of the French resistance against the Nazis (Camus, 64), and The Rebel was an essay about the nature of revolution and rebels themselves (Popova). Camus was also a “moralist who believed in the values of human courage and individual responsibility” (Camus, 64). It is for these reasons that I believe the authorial intent was to condemn the actions (or inaction) of Daru.

References:

Camus, Albert. The Guest, 1957, 
    

Click to access camus_theguest.pdf

Popova, Maria. “Albert Camus on What It Means to Be a Rebel and the Heart of Human Solidarity.” Brain Pickings, 16 June 2016, www.brainpickings.org/2016/06/17/albert-camus-the-rebel/.

Consequentialism

Consequentialism is the belief that the ends justify the means — the morality of an action should be judged by the outcome of the action, rather than the action itself.

A brief history

The world’s earliest known form of consequentialism is Mohism, which was from the teachings of Mo Di in fifth century BCE China and advocated “a unified ethical and political order grounded in a utilitarian ethic emphasizing impartial concern for all” (Fraser).

A somewhat more modern consequentialist ethical theories is Utilitarianism, which was initially formalized by Jeremy Bentham in the late 1700s (Driver). Bentham’s moral philosophy is hedonistic — “[a]ctions are approved when they are such as to promote happiness, or pleasure, and disapproved of when they have a tendency to cause unhappiness, or pain” (Driver).

Contemporary consequentialism is heavily inspired by Classical Utilitarianism, but it shies away from its hedonistic nature (Driver). Modern ‘Consequentialists’ like G.E. Moore argue good includes “far more than what could be reduced to pleasure,” and also that pleasure itself is not an intrinsic good (Driver).

Applications/Where it works

Consequentialism is the ethical philosophy that most non-religious people believe they follow (BBC, General introduction).

In theory, consequentialism can be applied anywhere an action has good or bad outcomes — the action with the highest good would be the one to take.

As we discussed in class, consequentialism is often used in the creation of policy and legislation — we can consider the population as an ‘individual’ and in theory make decisions for the greater good.

 

Consequentialism can also be used to justify ‘bad’ actions taken for the good of society or an organization.

Problems with Consequentialism

The future is hard to predict. Often an action may have vastly different consequences than originally believed, making the ethical calculations inaccurate.

Highly immoral actions can be justified as long as the good outcome from the action is strong enough. Consider the following example from the BBC: “A billionaire needs an organ transplant. He says that if he is given the next suitable organ he will fund 1000 hip-replacements a year for 10 years. Giving him the next available organ means Mr X, who was top of the list, will die – but it also means that thousands of people will be very happy with their new hips.” Following consequentialist logic, this is a good and moral action, regardless of what  happens to Mr. X (BBC, Consequentialism).

References

Driver, Julia, "The History of Utilitarianism", The Stanford Encyclopedia of Philosophy 
    (Winter 2014 Edition), Edward N. Zalta (ed.), 
    URL = <https://plato.stanford.edu/archives/win2014/entries/utilitarianism-history/>.

“Ethics - Introduction to ethics: Consequentialism.” BBC, BBC,
 URL = www.bbc.co.uk/ethics/introduction/consequentialism_1.shtml.

“Ethics - Introduction to ethics: Ethics: a general introduction.” BBC, BBC, 
 URL = www.bbc.co.uk/ethics/introduction/intro_1.shtml.
Fraser, Chris, "Mohism", The Stanford Encyclopedia of Philosophy 
    (Winter 2015 Edition), Edward N. Zalta (ed.), 
    URL = <https://plato.stanford.edu/archives/win2015/entries/mohism/>.

Sinnott-Armstrong, Walter, "Consequentialism", The Stanford Encyclopedia of Philosophy
    (Winter 2015 Edition), Edward N. Zalta (ed.), 
    URL = <https://plato.stanford.edu/archives/win2015/entries/consequentialism/>.

 

Final week

This is it. The last blog post I’ll ever make for one of Professor Downing’s courses, as I have taken both SWE and OOP, and don’t intend to take his summer class. This post will focus on my experience in CS 371p: Object Oriented Programming.

Lectures/Day to day

Professor Downing presents the material well. His lectures are well organized, he provides many examples of what he is talking about, and generally explains things in a clear way.

He calls on people in class, so it’s not always just one person answering every question, and more people get involved with their learning (in theory at least). He also has a quiz every time the class meets, which I have a bit of a love/hate relationship with. I like that it provides a reinforcement for what we previously discussed in class, but they’re also where I’ve lost the most grade points (so far).

Programming Assignments

 

For the most part I thought the programming assignments were fine. The workload was reasonable, and the assignments were fairly instructive and gave an opportunity to try out some things we talked about in class.

I’m not sure I like them all being turned in on hackerrank. The requirement that everything go in to one file is pretty annoying/unrealistic. The hidden tests also led to some annoying bugs with things that were missing from the specification (both Life and Darwin had hackerrank tests which placed multiple things in to one cell on the grid).

I also actively disliked the required length of the acceptance tests for the later assignments for one major reason: the frequency parameter. When you need to make a few thousand lines of tests, you’re going to write a script to generate them, and this will likely just use random values within the acceptable parameters. This is fine, except when your display frequency is once every 250 generations, you’ve officially made a test which doesn’t give very many hints on why it was failed, and this isn’t particularly useful for debugging.

I’m also not sure if Darwin was overly hard, or Life was overly easy, but Darwin was by far the most difficult and time consuming assignment of the course. It might have been nice to talk about the shared pointer before the Life assignment, and require that the cell class be one.

Exams

As of the time of writing, we’ve only had one exam. It was pretty standard — the multiple choice section was similar to the difficulty of the quiz questions, and the programming part was reasonable.

If I could make any change, I would have the hackerrank test cases actually enforce the constraints of the problem, and maybe check some more edge cases. It’s pretty easy to make a solution which appears to work, but actually doesn’t work all that well.

Argument to change the course name

I liked this course, but it seriously needs to have it’s name changed to something like CS 371p: Introduction to C++ Programming. We didn’t really mention objects until we talked about some containers three weeks in, and it was October before we were writing our own classes in lecture. To me, that’s some day one stuff in an OOP class, which I guess should be taught in Java at UT.

That being said, CS 371p: Introduction to C++ Programming is a great course to take. I think learning C++ really helps solidify what many core concepts of other languages mean. Since you have the power to choose if you want something on the stack or on the heap, passed by reference or passed by value, to be immutable or not, have virtual binding or not, etc, you really get a better feeling for what the implications of all of those things are. (Full disclosure: I took some intro to computer science courses in C++, and I think that C++ is an excellent language for intro courses because it presents you with all of these choices).

Actually, changing the class to intro to C++ programming could make the course even better. Maybe we could use new more often and actually experience what it means to have a memory leak (give Valgrind some purpose). We could talk about splitting up your header and implementation (and how you can’t really do that for templated classes). Be mad together that C++ really DOES know the size of your array, but still makes you keep track of it. The list goes on.

 

 

 

 

 

Twelfth week

What did you do this past week?

I did a big data assignment in its entirety, which took a lot less time than I originally expected. I also made some good progress on both my AI assignment and the Life assignment.

What will you do next week?

I want to have all of the hackerrank tests for Life passed tomorrow. Then, on Tuesday, I’ll need to put some serious work in to my AI assignment. After that I’m going to go in to work on Wednesday, then enjoy having some time off.

What’s in your way?

Not much, surprisingly enough. I thought my partner and I’s schedules would cause some serious issues for the Life assignment, but so far it has proven to be much easier than I initially anticipated.

What’s my experience of the class?

I really like timing aspect of hackerrank. It shows that you can’t rely on asymptotic complexity alone, especially with the relatively small size of our inputs. Sometimes ‘optimizations’ will make things slower in the long-run. (Note: this may also be because the compiler is magic and knows better than you).

Tip-of-the-week

Been stuck wondering how to test asserts using gtest? I looked in to it today, and found that testing assertions and the like is called ‘death testing’, and can be done with ASSERT_DEATH(thingToCall, regexString) or EXPECT_DEATH(same params).

Note that death testing and valgrind don’t always play nice together as valgrind notices the forked child of the death test’s execution ending. You can silence the output from the child by modifying your makefile to have the flag “–child-silent-after-fork=yes” wherever you call valgrind.

For example:
$(VALGRIND) –child-silent-after-fork=yes ./TestLifeConway

Eleventh week

What did you do this past week?

I finished up Darwin, which took more time than expected. I also continue to be frustrated beyond belief with how registering for classes goes here. It’s really draining to repeatedly take (and pay for!) electives I don’t want just so I can graduate ‘on time’.

What will you do next week?

Hopefully the next assignment is released tonight so I can get a head-start on thinking about it. I’ll be working with a partner and this makes me pretty concerned about the timing of everything — I’ve got a busy couple of weeks coming up.

Speaking of which, on Monday/Tuesday I will be writing a cheat sheet and cramming for my second exam on my math class on Wednesday, wish me luck.

What’s in your way?

This semester has been pretty mentally taxing. My frustrations with some of my current set of courses, my job, my upcoming semester, and the need to actually get employment for after next semester have been getting to me.

What’s my experience of the class?

It’s still going well, though sometimes I feel like I’m the only one who likes C++. To be fair, I learned it in the intro courses at ACC, so I do have some previous intro-level experience with it making things a bit less daunting. In general I just like the control it affords you and the decisions that were made to allow the compiler to do a lot of optimizing by default.

That being said, I guess that idea of ‘fast code’ in general is a bit less important these days when compared to ‘fast coders’. I will also admit that C++ does give you plenty of rope to hang yourself with, and also can definitely have some janky looking syntax. I can see why some people don’t like it.

I also definitely write most of my one-time-use code in Python.

Tip-of-the-week

Speaking of C++ giving you plenty of rope to hang yourself with, be wary of having pointers to data inside of a container. As has been mentioned in class, resizing will ruin all of your pointers, but they’ll also be point at unintended objects if you ever sort the data (with array-based containers, at least).

With this said, I finally found a use case for list. List is too slO(1) to use even in applications it seems like it’s made for (std::stack comes to mind), but it turns out that if you want to maintain pointers to the elements of a container, list is where it’s at.

You don’t have to worry about resizing, and sorting a list doesn’t actually move values, just changes their linking.

Tenth week

What did you do this past week?

I did two assignments for Big Data, and one for AI, all of which were pretty easy (AI surprisingly so). This weekend I made some significant progress on the Darwin assignment, and I think I’ve got a good idea on how to finish — now I just have to put all of the pieces together.

What will you do next week?

I’ve been thinking a lot about what I need to get done and when for the upcoming weeks. I need to finish the Darwin assignment, do my math homework, and then start preparing for my exam in my math class next week.

I also need to find some time to put in some actual hours at my job again.

What’s in your way?

The semester continues to be increasingly busy. Between Darwin and my upcoming exam I didn’t really get much of a break from having a couple of easy assignments last week.

What’s my experience of the class?

I felt like we lingered a little long on the allocator and which constructor is called when, and also didn’t get into the details of how the allocator does what it does (with the placement new).

I also wish I could split my classes in Darwin up in to multiple files.

Other than that, it’s still going well. I’m looking forward to inheritance.

Tip-of-the-week

I mentioned it in class, so I might as well talk about it more here.

Since C++11, the STL containers have “emplace” member functions (here’s one for vector: http://www.cplusplus.com/reference/vector/vector/emplace_back/) which construct elements as they add them to the container.

vector v;

v.push_back(MyObj(1, 5, 7)); // Makes an instance of MyObj, then copies (with move semantics if possible) it to the back of the vector
v.emplace_back(1, 5, 7); // Makes an instance of MyObj at the back of the vector

Ninth week

What did you do this past week?

Finished up the allocator assignment, and worked overtime on my AI project. At the end of the day we think we finished up the AI assignment, but it was difficult to tell as it turns out that the algorithm we were implementing was pretty mediocre in the environment we’re working in anyway.

What will you do next week?

I have an exam in Big Data Programming which I don’t feel particularly prepared for (discussion of the content of the exam has been fairly vague), and also a large big data programming assignment to finish.

I also will need to work a significant amount on our newest AI assignment, hopefully it’s more clear than the previous one.

What’s in your way?

Apathy. I have a lot that needs to get done, and less motivation than I would normally have to actually do it. I’m still doing relatively well in my courses, but I feel like I’ve been coasting a lot this semester.

The inevitable last minute crunch-time right before things are due has also cut into my ability to put in as many hours at work as I would like.

What’s my experience of the class?

It’s going well, we’re covering more and more things which I haven’t been taught before, basically anything and everything which isn’t part of the C++98 standard is new to me.

Man is that move() syntax ugly though.

Tip-of-the-week

There is actually one other way to avoid the ‘double copy’ issue, and that is:

object bar() {

return object;
}

const object& foo = bar();

Const references to temporary objects have a lifetime which is guaranteed by the C++ standard to have an extended lifetime. Note that the const is necessary (see: https://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/ ).

It’s worth noting that you should really just use the C++11 move semantics. I don’t know the exact mechanics of how the lifetime of the temporary is extended, but I imagine it’s not as clean as a move constructor.

Eighth week

What did you do this past week?

I made significant progress on my projects for OOP and AI, took an AI exam, and have hopefully finished my big data programming assignment (I’m writing this as the AWS cluster spins up).

On the home front, we took in a stray dog a couple of weeks back. Turns out it has heart worm, but as my girlfriend has already imprinted upon it, it looks like it’ll just join our growing menagerie of sick/expensive animals.

What will you do next week?

I need to finish up the AI assignment by Tuesday night, the OOP assignment by Thursday night, and also have to teach myself the math to do my next math assignment by Friday morning, so that’ll be my main focus.

What’s in your way?

My AI class is pretty rough, and not for any of the right reasons. I hope we’re doing the assignment the right way, and that we can manage to finish by Tuesday night.

What’s my experience of the class?

It’s still going well, but I’m surprised there aren’t more requirements in the assignments to build and use objects. I really thought the course would start out teaching the basics of classes in C++, then go from there. I guess there is just a lot of C++ stuff to cover.

Tip-of-the-week

I found out that apparently a fair number of people don’t know this, so I guess it works as my tip.

Did you know that you can have free wired internet for your laptop in the UTCS computer labs? That row of monitors on the third floor with no computers at it has some network cables you can use, but you’ll need to log in at horatio.cs.utexas.edu before you have internet access.