HNHacker News
TopNewBestAskShowJobs

azov

2,891 karma · joined July 30, 2011

submissionscomments
azov··on How can C Programs be so Reliable? (2008)
Popular C software is so reliable because of enormous amount of effort spent developing, testing, and polishing it over many years - not because error handling in C is superior to that in higher-level languages.

If your python script sticks around for 30 years constantly being used by millions of people - I bet it will be rock solid as well. All other things [1] being equal [2], a program written in a higher-level language will likely be more reliable - simply because it will likely be shorter. C has many properties conductive to great longevity of software written in it, but error handling is not one of them.

Now, to the rant about not knowing the exact number of exceptions a function can throw. Most sane languages [3] give you exception hierarchy. You know that every function can throw an Exception (or Throwable, or whatever the root of all things evil is called in your language), and you either handle it or let in propagate. The important bit is you catch exceptions based on what you can handle in a current context, not on what the functions you call can throw [4]. As long as you realize that every call can potentially throw, it is not important what exactly is thrown - letting you abstract away the exact nature of an error is a feature, not a bug, that's what exceptions are there for! Let's say some function deep below changed and now throws a new exception type. So what? It didn't change what you can handle, so there's no reason to modify calling function - just let the exception propagate. What if nothing in your program can handle that exception? You let it crash (hopefully to the debugger, and no, it's not ironic that I suggest it in a topic about reliable programs - crashing is a reliability feature invented to expose problems that would be hidden and hard to debug otherwise). Of course you may also put a few catch-all clauses in a very limited number of strategic places.

If you approach exceptions this way they are vastly superior to error codes.

[1] Scope of the problem, amount of effort spent on development, programmer skills

[2] Or at least on the same order of magnitude

[3] With a notable exception of C++ - I'm not sure what they were smoking when they decided that throwing arbitrary values is a good idea

[4] And this, by the way, is what's wrong with checked exceptions in Java

PS. Didn't mean that having no exceptions is insane - but that if a language has exceptions, the sane thing to do is to organize them in a hierarchy with a single root.

azov··on Let’s Stop the Unix Time Insanity
> Unix timestamps are thoroughly and unnecessarily broken. They should be a continuum.

If you assume that system time is a continuum I have some bad news for you: system time is actually a user preference. Users can change it any moment to whatever they feel like, no time machine required. Given that, leap seconds are small potatoes. If you propose we change this and take away user's ability to set system time... well, there might be some merit in this from purely theoretical point of view, but in real world where batteries die, clocks get out of sync, and tons of software already rely on existing behavior - I don't think your proposal is likely to get very far :-)

Now, if you want a continuum, it's already there: look up CLOCK_MONOTONIC.

azov··on What is the enlightenment I'm supposed to attain after studying finite automata?
The answer on SE is still very theoretical. Yes, technically we can model any computation [1] as an FSM, but when does it actually make sense to do so?

FSMs are often used when modelling physical devices - think microwaves, elevators, CD-players, something with buttons or sensors, something event-driven, embedded controllers, also network protocols, text parsers, etc. Basically, whenever we must ensure correct behavior having few constraints on sequence or timing of inputs.

How can you actually apply it in your everyday programming? Look at your class. Every method call is an event that can cause a transition. Member variables are the state. Theoretically changing any bit of any member variable gives you a different state. In practice you only care about the bits that affect your control flow. Figuring out how variables map to states is the tricky part. Sometimes one variable corresponds to several states (say, when airspeed goes over V1 a plane transitions from can abort to must takeoff state), sometimes several variables define one state (say, when ignition=on and door=closed car is ready to drive), sometimes you'll need to add an extra variable to distinguish between states. Then you draw a table with events on one side and states on another and look at each cell. This is when you have all those precious "oh, crap, what if the user hits play when the song is already playing" moments. And voila - now you know that your class behaves correctly because you've systematically considered every possible scenario. It takes enough effort that you probably don't want to do it for each and every class, but when you do it - it's magic :-)

[1] Any computation with finite memory, to be pedantic

azov··on How to design a class
It's not philosophically wrong to model the problem upfront, it's just very hard to get it right in practice.

You don't literally have to start with one function. If you've solved a similar problem before you may have a good idea of what the code structure is going to be (this is what design patterns are all about). Frameworks may force a structure on you. There are shortcuts. But even then, I've been bitten more then once by the problems that looked awfully similar to what I've done before only to turn out to be very different at the end.

azov··on How to design a class
Let's try this advice. Say, we're solving Hanoi Towers [1]. So, we're going to have rods, and disks, and rods are going to have the number of disks on them, and disks are going to have size, and probably a reference to the disk underneath, and a reference to the disk on top, and maybe also weight and color... and by the end of the day instead of a 10-line snippet [2] we're going to have Enterprise Java Beans.

No, it doesn't mean that OOP is awful - it just means that this particular way of modeling a problem is a recipe for over-engineering.

Start with the simplest thing that works. That thing will probably be just a function. Grow it from there. If it gets too big, split it. If you find that you pass the same 12 parameters to a bunch of functions - factor out a class. If you do the same thing in a bunch of classes - abstract it out. Keep it DRY [3]. Keep it SOLID [4]. Rinse and repeat. This way you end up with a useful class hierarchy - and OOP won't be awful.

[1] http://en.wikipedia.org/wiki/Tower_of_Hanoi

[2] http://rosettacode.org/wiki/Towers_of_Hanoi

[3] http://en.wikipedia.org/wiki/Don't_repeat_yourself

[4] http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

azov··on Portable Native Client
http://en.wikipedia.org/wiki/ActiveX - 1996 is knocking… yes, I know - it's very, very different this time, but still can't help remembering the horrors of ActiveX :)

PS. From Wikipedia article: In principle it [ActiveX] is not dependent on Microsoft Windows, but in practice, most ActiveX controls require either Microsoft Windows or a Windows emulator

PPS. I'm not really trying to compare them, just pointing out that obsessive idea to run Photoshop in browser is almost as old as browser and photoshop themselves. And so is the idea for a grand platform that will let us "write once, run everywhere". Uncountable attempts were made, yet somehow they all fall short of expectations. Is the idea itself flawed? Perhaps we have different operating systems for a reason?..

azov··on Bjarne Stroustrup Discusses C++
For the sake of balance, here is Yossi Kreinin's list of things that are wrong with C++: http://yosefk.com/c++fqa/defective.html

PS. One of my biggest gripes with C++ is the lack of uniformity. Not only the language itself has insane learning curve, every project does so many trivial and not-so-trivial things differently that it's like learning another language each time you dive into a new codebase. From code formatting, documentation, and source tree layout to error handling, libraries and build system - for something so huge and complicated as C++ there's an amazing number of batteries not included. Even the things that are supposed to be standard in theory are often not so in practice. Damn, there's still custom string classes in the APIs of many popular libraries - almost two decades after std::string and STL!

PPS. And yes, there's a difference between having consistent conventions and trying to be perfect for everybody and everything.

azov··on 25 years ago this week, the Morris Worm brought the Internet to its knees
I like how they spin it in Robert Morris profile on the YC page: "In 1988 his discovery of buffer overflow first brought the Internet to the attention of the general public." (http://ycombinator.com/people.html)
azov··on How is a system of axioms different from a system of beliefs?
There's an infinite variety of axiomatic systems, most of them not much different from, say, a set of beliefs in Santa Claus and magical elves living at the North Pole.

However the axiomatic systems we happen to use most have one important property: they are useful for acquiring new knowledge via scientific method. I.e. they serve as a foundation for theories that make correct predictions as verified by experiment.

That's the main difference.

azov··on 37signals Works Remotely [video]
>one possibility is to make contact with a SV consulting company for subcontracting to larger enterprises

Any particular companies you can recommend?

azov··on MacBook Air Flash Storage Drive Replacement Program
I have one of those 128G MacBook Airs, and the SSD failed on me literally a few days after the warranty expired. I took it to the Apple store to see if they would repair it under warranty (Apple used to be lax about warranty dates), but they told me no. I ended up ordering 256G SSD from OWC and repairing it myself (which was cheaper and faster then what Apple store clerk quoted me for a new 128G SSD).

Called them today about a refund - they told me I might not be eligible because I did the repair myself and not through an authorized repair center, but they will try to get it approved. We'll see how it works :)

azov··on The Code Documentation Fallacy
> When some coder changes the function, it is very easy to forget to update the comments

It isn't.

All public APIs should have documentation, even if you believe it's obvious what they do. This documentation never goes out of date because once you release your API it tells you what you cannot change. If you changed the code so that your documentation is now wrong - this code change is a bug and you should fix it. Because there's other code in the wild that relies on the behavior that you promised.

Of course in practice you do have to change that behavior every once in a while. But this should be a big deal (that usually includes bumping up version numbers, mentioning it in release notes, etc). If you're changing it so often that updating the damn comment is an issue you either document implementation details that don't belong in API documentation or your API is unstable crap and nobody should be using it.

PS. Complaining that API documentation gets out of sync with the code is like complaining that unit tests break when you change the code. Duh - that's what they are there for!

azov··on How Open Should a Startup CEO be with Staff?
>Of course as a founder & CEO you know that your 18% of the company at an $80 million is worth more than 26% of a $30 million valuation but I promise you that this is a nuance that even really smart & educated employees struggle with.

Oh, really?.. Your smart employees suddenly stop comprehending basic math when it comes to their future compensation?

Or maybe - just a guess - when the CEO was recruiting engineers (who, perhaps, don't have much experience with the business side of startups) he told them they would have 0.75% of the company but forgot to mention dilution?.. Could that be the "nuance" employees struggle with?

azov··on 1Password and the Crypto Wars
They can, for example, have a policy that every code change is reviewed by a non-US employee.
azov··on Buildbox: A Hosted CI service that uses your own infrastructure to run builds
Would be nice if the page explained how Buildbox compares with other popular hosted CI tools, e.g. Jenkins (http://jenkins-ci.org)?
azov··on Just got an Amber Alert on my Phone
It's a really bad UI for a disruptive message that gets pushed to millions of people.

How many people know what amber alert is? Of those people, how many know what to do about it? Of those people, how many know what Nissan Versa looks like?

How much harder would it be to change the text to something like "Child abduction alert: if you see <car color/model/license plate> call 911" (and, perhaps, include a silhouette of the car model they are looking for)

azov··on Storage for Photographers
Backup is about having several copies. If you delete files after you uploaded them to the cloud, you don't have a backup - with all the problems that come with it (say, if you delete a file by accident there will probably be no way to restore it).

If your files are important to you - you need a back up. If not - just get rid of them in the name of simplicity :)

PS. Also, uploading many gigabytes over a typical ADSL connection is just painfully slow... even local NAS is too slow over WiFi for my taste, and if I have to have a wire - I can just as well connect an external drive.

azov··on Why I’m quitting the C++ Grandmaster Certification course
Dealing with the lack of regex engine^ is such a tiny part of the monumental task of implementing C++ compiler from scratch - it's like quitting Mt. Everest summit expedition because a three-story hotel on the way there doesn't have elevator.

^ - which he probably didn't need to begin with

azov··on Putin defends the U.S. on spying programs, drones and Occupy Wall Street
Russia has it's own internet surveillance system, likely even more invasive then PRISM. Would be really odd if he spoke against it. http://en.wikipedia.org/wiki/SORM
azov··on Sen. Mark Udall: I knew about the NSA spying, did everything but leak to stop it
>Civil liberties should be as big of an issue (if not bigger) during elections as the economy.

This. Fixing broken economy takes years. Fixing broken civil liberties takes decades, if not centuries.

azov··on Wikipedia’s Emergency
Wikipedia was never intended to be a formalization of semantic web (wikidata.org is more along those lines, if that's what you're looking for). So what's the emergency?

The decline in number/quality of editors is alarming, but what does it have to do with taxonomy? And how do the links fit into the picture?

TL;DR A random set of barely coherent assertions followed by OMG, Wikipedia is over

azov··on Show HN: Free hi-resolution photos for your website. 10 new photos every 10 days
Nice shots, but why not just submit them to Wikimedia Commons/Flickr/etc under Creative Commons license? Much better chance of people actually finding and using them, IMO.
azov··on Using checklists for code review
I have yet to see a code review checklist that I find useful. There are just too many things that can go wrong with software, so the list ends up either too long to be practical, or too generic to be helpful.

What I do find useful is to have a good variety of skills on the review team. Different people tend to check for different things. Some are just naturally good at spotting, say, concurrency problems, others have a pet peeve with names that aren't clear, etc. But someone who doesn't have an eye for concurrency problems won't magically start noticing them in a pile of code because there's a box saying "check for race conditions" somewhere on the list.

azov··on Tests Are Overhyped
tl;dr: Tests are overhyped because we once wrote tests that became irrelevant when the thing we were testing changed

Really? I mean, tests might be overhyped, but so far it looks like the author draws incredibly general conclusions from some isolated incident. Why did the tests become irrelevant? Is their scoring algorithm now doing something completely different? Do they now have different use cases? Were they hard-coding scores when the actual thing that matters was, say, the ordering of the things they score?

> Only test what needs to be tested

well, thanks for the helpful advice :) Care to share what, in your opinion, needs to be tested?

azov··on Coinbase Response: Data On Merchant Pages
This is so blown out of proportion... yes, letting Google crawl email addresses is not kosher, but come on, public data already includes their company name, website, and phone number, it's not like those merchants are anonymous.

Given the attention span of the folks who circulated the news in the first place, I would mention that no transaction data was leaked somewhere in the first paragraph.

azov··on JetBrains is working on a cross-platform C++ IDE
Why does it have to be lumped into IDE? Both could be written as standalone utilities that your favorite editor can call.

I think IDEs hurt innovation in development tools more than almost anything else. They are like crack for your workflow - easy to get started with, but once you're on them you're stuck. Plugging in better tools into existing IDE is a big PIA if possible at all, and rewriting the whole IDE is a huge undertaking for any company who wants to make your life better.

azov··on Why you should never ever ever have Managers in your class name
> the purpose of ThingManager is perfectly clear--to manage miscellaneous or common functionality

Ironic, isn't it? :)

PS. Don't get me wrong - a Manager, or Util, or Helper is not the greatest crime against software design. The intention here is clear, functionality - no, not really. However engineering is about tradeoffs, and it is sometimes practical to have a dumping place for miscellaneous stuff. Just keep in mind that it is a "be careful" territory, those places do tend to turn into ugly and hairy mess over time.

azov··on Why you should never ever ever have Managers in your class name
ThingManager is indeed a bad name, but I think the article is blurring the explanation with poorly chosen example. The example is more about wrong design than wrong name, there are certainly legitimate cases when you want a class that deals with multiple things.

ThingManager is a bad metaphor for a class that follows single responsibility principle (http://en.wikipedia.org/wiki/Single_responsibility_principle). It encourages you to stuff too much into a class because managers do many things, and it's not always clear what exactly they do - almost anything can be thought of as some sort of "management". The real reason is mentioned two paragraphs from the end - the name is simply too ambiguous.

azov··on Time management hacks
It's missing one slide: "it's more important to be happy than productive". Crossing stuff off your TODO list with maximum possible speed is not the end goal in itself.
azov··on The largest computer ever built
If you're in Bay Area, it (well, some pieces of it) is on display in Computer History Museum - http://www.computerhistory.org/VirtualVisibleStorage/artifac...
← PreviousPage 4 of 8Next →