Better HN
topnewbestaskshowjobs
Log inSign up

chimeracoder

21,186 karma · joined Oct 12, 2010 (16y ago) · 6,050 submissions

Inveterate builder.

Personal site: http://www.adityamukerjee.net/

My email is pretty easy to guess from my username.

Submissions

comment 13y ago · link · parent

> There is not a 1:1 correspondence between Unix time and UTC

Or between any two time formats, but Unix time still makes for the cleanest intermediary by far.

comment 13y ago · link · parent

Off the top of my head, it's easier to think of APIs that don't provide UNIX timestamps than ones that do. You wouldn't believe some of the half-baked implementations I've seen used in production code (unless you've also had to deal with it yourself, that is!)

Yes, you still have to deal with timezones, but I'd much rather be given a UNIX timestamp for a UTC time and then adjust accordingly, rather than deal with all the other problems that come from communicating and converting between various other calendar formats and locales.

And this exchange should occur at the very last step, only when being displayed to the user. For almost any other purposes, there's no reason that two different applications should need to talk to each other using anything but UNIX timestamps. The potentially error-prone conversion should happen in the latest stage possible, because that's the part with the most knowledge of how any error should be corrected.

> At the same time, the human brain doesn't seem particularly well-suited to breaking down Unix time into meaningful scales,

But we're talking about for programming purposes - to a computer, one 64-bit int is as good as any other.

comment 13y ago · link · parent

> If a company has a huge sale for 1 month and everything is temporarily 50% off, we don't call it a 100% "price hike" the next month.

No, but if they had that "sale" for over 10 years, rather than one month, then you might call it a price increase.

comment 13y ago · link · parent

I'm amazed by how many applications don't do this (and, similarly, how many languages make it difficult just to get a simple UNIX timestamp). It's far and away the easiest medium to work with, even if you only use it as a pivot format[1].

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

comment 13y ago · link · parent

Well, multiple goroutines can run in parallel, which isn't possible in CPython. That's a huge difference right off the bat, even if gc has some work left in optimizing the implementation.

(As far as non-concurrent code goes, gccgo is very well-optimized, because it's basically piggy-backing on the extensive optimizations of gcc over the decades.)

comment 13y ago · link · parent

Here's a really basic Go web server I wrote that doesn't do much except log someone in via OAuth: https://github.com/ChimeraCoder/go-server-bootstrap

The only messy part is the OAuth callback, which I did manually instead of using one of the OAuth2 libraries, because at the time I was trying to identify a possible bug in an OAuth implementation.

Keep in mind that it's not the cleanest or most idiomatic Go code, but even that aside, it's relatively concise - and more importantly, straightforward to understand, even if you've never written Go before.

comment 13y ago · link · parent

> If you're looking at scizophrenics then by definition you're looking at the ones who haven't recovered.

Well, yes, it's really easy to say that a disease doesn't exist if you ignore all the people who are suffering from it.

> they don't just do better because they're given less drugs, it's also because of social differences in terms of how families interact with each other.

What "social differences"?

Schizophrenics in India are far more likely to go undiagnosed and untreated, which only exacerbates the problems for them and their families. That's a big difference from saying that there's a high recovery rate, let alone that it's not a disease.

comment 13y ago · link · parent

> There are very high recovery rates for schizophrenia in 3rd world countries, which he believes is due to the lack of medication.

Looking at the state of schizophrenics in India, I find this hard to believe.

comment 13y ago · link · parent

If you're interested, there's still some low-hanging fruit left, namely in two edge cases:

1. It assumes all slices to be of type []interface{} by default, though oftentimes a more precise type is possible. (This is just a matter of looping through and determining the most specific type)

2. It only accepts valid JSON. Not a bug, but for example, the sample responses on the foursquare API documentation omit the (required) quotation marks around identifiers: https://developer.foursquare.com/docs/venues/venues (click "Try it Out"). That's a common problem which I'd like to fix eventually.

comment 13y ago · link · parent

> If you know the shape of [JSON] data, you can serialize (marshal, in Go’s parlance) data structures to JSON or XML and de-serialize (unmarshal) from JSON or XML into a struct.

I wrote a short script to automate generating the struct definitions, since I didn't want to generate the structs by hand. Go's reflection made this really easy.

https://github.com/chimeracoder/gojson

comment 13y ago · link · parent

> Tools that watch the file system are no substitute for servers that can guarantee you get the latest version when you hit f5.

How are these mutually exclusive? If you want a server that automatically runs the most recent (working) build of a piece of code, it's rather straightforward to implement.

comment 13y ago · link · parent

> No independence, no civil war, nada.

To be honest, most schools that do cover those do an even worse job than not teaching anything at all.

If you're interested in filling in the gaps on your own:

http://www.amazon.com/Dont-Know-About-History-Anniversary/dp... http://www.amazon.com/Lies-My-Teacher-Told-Everything/dp/074...

comment 13y ago · link · parent

> Wasn't the 2% tax cut on the side the employer pays? That means if you paycheck goes down because of it, your employer is pretty much a jerk.

In the short run, this would make a difference, but not in the long run - the incidence of payroll taxes has been shown to fall almost entirely (~98%) on the employees.

(For those unaware: the incidence of a tax[1] is a way of describing who really bears the burden, which is completely unrelated to who nominally pays a tax out-of-pocket).

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

comment 13y ago · link · parent

> I successfully communicated and pissed off people I don’t like. Yay!

You'll make a lot of friends with that attitude.

comment 13y ago · link · parent

My mistake. Still, it doesn't use GNU utilities - Android is Linux but not GNU.

comment 13y ago · link · parent

Yeah, I'd be interested in doing an associative version of this (sort of like what we did for this[1]), though my mapping skills are not quite up to the author's/

[1] http://blog.okcupid.com/index.php/the-real-stuff-white-peopl...

comment 13y ago · link · parent

Isn't this what your credit card company is for?

I had an issue where Paypal never refunded the $2 fee for verifying my account and instead pocketed the cash instead. I got my bank to issue a chargeback over the phone - it took all of five minutes.

comment 13y ago · link · parent

> It's also using most of the standard GNU tools - bash, etc.

Actually, I'm pretty sure it uses Busybox tools with ash, not GNU with bash.

http://www.gnu.org/philosophy/android-and-users-freedom.html

comment 13y ago · link · parent

Because EVERY piece of hardware that I have bought is mine, and that means I should be able to do what I want with it.

comment 13y ago · link · parent

You're right; I realized that afterwards but it's too late to change it. I was trying to think of a straightforward example of why this difference isn't just because of a difference in type systems, but that's hard, since types are so helpful in understanding the way languages work.

Or maybe I've just been thinking about types too much recently!

comment 13y ago · link · parent

The L has its own horror stories too (mostly because it lacks a third track).

comment 13y ago · link · parent

According to wc -w, I wrote 571 words in support of that initial sentence. If you'd like citations for each of the individual points I use to illustrate my point, including the basic terminology, some cursory research should point you in the right direction of whatever you're looking for.

If you're looking for a tl;dr, you've come to the wrong place - not everything is so simple, and while I'm happy to explain my comments to people who ask politely (like isbadawi), I'm not really in the habit of writing MLA-style research papers on demand (and certainly not when the same information is already so widely and easily accessible).

comment 13y ago · link · parent

> As far as I know any program that translates code from one language to another is a compiler.

No, there's a distinction between a code translation and a code compilation. At an abstract level, it's the difference between an actual Turing machine encoded with a specific set of instructions, and a Universal Turing machine along with an encoded representation of a program. Logically equivalent, yes, but that's not the same thing as saying that they're actually the same thing. (If they were, this would mean that any Turing-complete languages would be the same, so you might as well just write COBOL!)

Compilation is not just a matter of "produce another piece of source code that appears to have the same logic when executed". With compilation, the only information required at runtime is the input to the program itself (which is never known at compiletime, unless your program is one massive thunk - which would be kind of a useless program!). When translating code to another language like, eg., Javascript, this isn't the case, because the input to the program isn't fed directly to the output of the translation; rather, both are fed to the interpreter which executes one on the other.

This applies whether the target language for the translation is itself an interpreted language or a compiled language, but in practice, the translated form of a compiled language (ie, C) can itself be compiled immediately as part of the translation, so this isn't really a relevant distinction there.

(By this logic, it would seem that javac is a translator, not a compiler, which is almost half-true, but only because Java itself blurs the distinction[1]. javac compiles Java code to run "natively" on the Java virtual machine, and that machine is virtualized on actual hardware. So no input is required at runtime from the perspective of someone inside the virtual machine; however, since we're outside that hypothetical bubble, we can't actually execute that code natively and need to run a second translation at runtime - ie, the "just-in-time" portion of the process).

The reason this distinction is important has to do with the portability, reliability, and predictability of the generated code. Compiled code is inherently less portable (or at least, no more portable) than the pre-compilation source (whatever that language is). This is why languages like C are compiled for a particular system. On the other hand, the compiled form "solves" a lot of the decision problems that don't require executing (or even knowing) the input before-the-fact.

An interesting example of this problem is hiphop-php. As one of the other commenters pointed out, when translating code from one language to another, you have to encompass all of the quirks of the language (like 'wat') properly. The hiphop-php output is incredibly large because it has to statically determine the actions required when, ie, two variables are added, but one is a number and one is a string. This is just a feature of a dynamically typed language, yes, but it's not an issue if you simply wanted to translate Ruby to PHP, because you don't have to factor in any of that logic at compilation time - rather, it gets factored out and passed on to the interpreter. To create a truly self-executing, compiled form, that requires solving a lot of this logic insofar as your target system will allow, which is a much trickier process - you can't just rely on the runtime or the interpreter to pick up the slack for you.

[1] Incidentally, this was one of Java's selling points back in the day - hard to believe now!

comment 13y ago · link · parent

Man, I've heard horror stories of the L, but 25.5 hours is ridiculous.

comment 13y ago · link · parent

You're correct; however, unfortunately most discussions on here ignore the difference, I've noticed.

comment 13y ago · link · parent

I don't know enough Javascript to give the analogous exploit myself, but that approach looks dangerously similar to some attempts I have seen at making Python's "eval" safe - attempts which, I might add, all fail to capture corner cases that any sufficiently determined or motivated attacker would eventually discover.

comment 13y ago · link · parent

You'd be surprised how little most non-geeks use the keyboard for much of what they do. Heck, even geeks use tablets for a lot of daily work.

In any case, I think this was just for display purposes. The touchscreen is intended more to replace the mouse than to replace the keyboard - at least for now.

comment 13y ago · link · parent

> (Yeah, there are some availability issues, but I bet after Christmas things will get better on that front.)

The availability issues for the Nexus 4 have absolutely nothing to do with the Christmas rush.

> So don't buy locked down devices. There are unlocked device for sale,

You're missing the two points, which are:

1. Unlocking the device should be an option for all phones - it's a basic right of ownership.

2. It's getting harder and harder to find truly open devices (the Galaxy Nexus had issues on this front). If things keep heading in this direction, soon there won't be any unlocked devices for sale.

comment 13y ago · link · parent

I haven't used the assistant, but yes, git-annex works well.

For example, my music collection is split across multiple hard drives in two different states - not by intention, of course; it's just what happens over the years. However, I can create a single folder on my laptop that organizes all of this music, even though it's far too large to fit on the laptop's hard drive. Even though the files exist on multiple hard drives, my laptop knows which ones have which files, so I know which hard drive I'd need to plug in to access a particular file.

Better yet, since this is a fully distributed setup, there's nothing magical about my laptop - I have a desktop that has another copy of the repository, and it too knows where all of the files are (even though it has a different subset of my music collection).

I can also back portions of the collection up without ever having my entire collection on a single drive. I can enforce redundancy - "make sure that three verifiable copies of this file exist on other drives before deleting it here". I can back up to Amazon S3 or Glacier. I can - well, do pretty much whatever you'd want to do on a non-distributed filesystem - except this is distributed.

Dropbox is a great idea - I'm happy that it exists, and I see its value for a lot of use cases, but at the end of the day, it's not really solving the problem of distributed data; it's just creating a centralized, canonical data store in the cloud that is capable of interacting with other data stores.

Dropbox is great, but at some point, it's nice to move on from SVN! :)

Keep in mind, I'm not trying to do any sort of version control on my files - it's strictly a way of managing a completely distributed filesystem. If you want versioning, git-annex apparently can do some of this too, but I can't speak to it.

comment 13y ago · link · parent

As someone who's in his 20s and first got interested in programming as a kid by trying[1] to install Linux on his 386... I don't know how to react to this.

On the other hand, it's ridiculous to think of how far things have come since then... people who complain about Linux usability and driver issues in 2012 really don't know what they missed!

[1] and failing!

1
173174175
202