HNHacker News
TopNewBestAskShowJobs

davidhollander

996 karma · joined December 11, 2010

.
submissionscomments
davidhollander··on Node.js: details and best practices (a server side guy's analysis)
> I've been doing stuff like this

Why use callbacks over 'return' for anything other than IO and waiting? If there's not two out of sync parties, there's no need to tell another person to call you back, and no advantage to performing an extra function call.

re: yummyfajitas: that does not use a callback, it returns a list. And if retrieveURL is nonblocking, then iteration is nonblocking.

davidhollander··on Node.js: details and best practices (a server side guy's analysis)
>I understand that IO is expensive, but so is performing string interpolation on a string in memory 50 times (for whatever reason).

I think you are conflating waiting and working. Both cost time, but they are not the same. Waiting can be avoided (nonblocking), working cannot.

Iterating over an array in most languages probably takes .000001 seconds. Reading from a bad connection could take 30+ seconds, or whatever your servers timeout is.

Since the 30 seconds is spent _waiting_, it can be avoided within a single thread of execution. On the other hand, if you are spending 30 seconds _working_ to compute prime numbers, this cannot be avoided in a single thread of execution.

Blocking vs nonblocking refers to dealing with waits. Does each IO operation do the waiting, or does each IO operation return immediately and we pool waits into a single poll() (etc.) call?

Parallelization refers to dealing with work. In the rare instance one needs to generate huge fibonacci sequences, one can do so in a seperate fork\process\thread\cpu core\machine, and report results back to the event loop via pipe\socket\shared memory. [1] Multiplexing waits in a single thread makes sense, multiplexing work in a single thread such as array iteration does not: on the contrary it sounds like a good way to increase the overhead of iteration and generate more work rather than reduce it.

It's confusing because some tools such as threads can be used to address both the problem of parallel work and the problem of parallel waits.

[1] edit: quick example in lua:

    -- In fork, write to the blocking end of a pipe
    local r = formfork(function(w)
        local work = fibonacci(10^10)
        w:write(work)
        w:close()
    end)

    -- In event loop, read from the nonblocking end of a pipe
    readline(r , 1024, function(r, line)
       print('got work', line)
       close(r)
     end)
davidhollander··on Node.js: details and best practices (a server side guy's analysis)
> Underscore.js for Iterations: each implicitly blocks

???? Blocking refers to IO system calls. underscore is not an IO library. Does a 15 year programmer with C++ experience not know what an O_NONBLOCK system call is? Blocking or non blocking is about how you are performing IO with the external world. It has nothing to do with the world internal to your program: callbacks are merely correlated with nonblocking io, continuation passing style does not constitute nonblocking in an of itself. You do not have to use continuation passing style and lambdas for code that does not perform IO for it to be "nonblocking".

davidhollander··on Rich Hickey: "Simple Made Easy" from Strange Loop 2011 [video]
> Is it worth my time to learn Clojure or Haskell, when I don't even know what I'll use it for?

I don't know if it's a binary decision between investing a lot of of time, or investing none. You could skim the reference manual, and if anything jumps out at you, you have a topic for future investigation, or a non-zero quantity of information to base your decision to "is it worth more time?" on.

If you mean on a very abstract level, the balance between learning what others are doing and producing your own stuff, you might enjoy Richard's Hamming essay "You and your Research", pg hosts a copy on his site: http://www.paulgraham.com/hamming.html

davidhollander··on Jwz: Google's pseudonym support "obvious bullshit"
> Google is the real evil corporation but these geeks are too blind to see it.

Okay, since there is a singular, "real" evil corporation, are the other non-real evil corporations in the imaginary-evil or fake-evil domain?

edit:

A bit cryptic, my point is that "evil" has been overloaded to meaninglessness. It decreases one's intelligence to use it in an assertion. In war and throughout history, party A asserts party B is evil, and party B asserts party A is evil. If party A is truly evil, then they would have no scruples over claiming party B is truly evil, and vice versa, analagous to the Liar's Paradox. Entering this frame, and debating who is "truly" the evil one, is a lens more likely to obscure than clarify.

An alternative heuristic for assessing the merits of actions: Coercion is considered polar to freedom by many social philosophers. Does party A use coercion to force party B into making a decision that leaves party B worse off?

Does google use coercion to drive user registration?

Does google use coercion to prevent deregistration?

Does google use coercion to damage competitors?

Does google use coercion to forcefully identify the anonymous?

No. No they don't.

davidhollander··on Ubuntu and GNOME jump the shark
Search this ArchLinux thread, lots of great tips: https://bbs.archlinux.org/viewtopic.php?id=97375

"o" or ":open" plus a url, "t" or ":tabopen" plus a url. "d" closes a tab. Press tab to autocomplete. "B" to add a bookmark. "H"\"L", back\forward in history. To perform a search, simply start your open or tabopen command with "google " or "duckduckgo " etc. If you are on a site that uses javascript keyboard controls, press CTRL-Z to enter pass through mode. ":wq" saves your session (pages that are open will be reloaded next time) and quits.

If Javascript doesn't work in gmail or google plus, change

> "AppleWebKit/%s.%s+"

to

> "AppleWebKit/%s.%s+ (KHTML, like Gecko)"

in globals.lua and it will.

davidhollander··on Ubuntu and GNOME jump the shark
I'm very happy with Awesome running on top of arch linux. If you like the configurability of awesome, also check out luakit:

http://luakit.org/projects/luakit/

It's a lua binding to webkit that allows you to fully customize your web browser as well, with a configuration scheme similar to Awesome. By default it's configured with VIM bindings, imo better than the vimium or vimperator plugins.

davidhollander··on Time to fork the FSF
>hatred and bigotry outside of religion, it pales compared to what religion has given the world.

The 20th century is evidence enough that man is capable of resorting to the worst possible barbarism without invoking deities as justification, plenty of other excuses are readily available. Going by death count, political purges in officially atheist communist nations took the cake... by far. Ethnicity was a distant second behind politics, and religion a distant third.

> Of course I consider most "-ism"s to be religions too.

Communism, solipsism, humanism, socialism, nihilism? If the majority of philosophical and political beliefs, even those with a stated opposition to religion, are now redefined to be religion, then "religious belief" is no longer a subset of "belief", and you've expanded the categorical definition of that word to be useless at anything other than proving yourself correct.

davidhollander··on Alibaba's Ma: "very interested" in buying Yahoo
>US Treasury bills burning a hole in its pocket

The Chinese central government needs to maintain its high level of reserves, because under their system they are also the guarantor for all local and provincal government debt (which is enormous).

davidhollander··on How Quake (the videogame) changed my life forever.
>I think it was either Qed, or Qoole...

Ah, Qoole was the first level editor I ever tried. What I vividly remember about Quake 1 though was all the mods! I spent hours tying up the phone on a 14.4K modem hunting for new stuff to try.

Grappling hooks, bots, friendly attack dogs, Quake Rally which converted it into a racing game, Air Quake which added pilotable helicopters and tanks... I didn't get into coding until UnrealScript, but Quake 1 definitely got me into the internet.

davidhollander··on I was once a Facebook fool
> the top 20 most upvoted articles of all time

I don't think that's an accurate list, as it excludes [dead]ed articles. Zed Shaw's "Programming, Motherfucker" received 870 upvotes: http://news.ycombinator.com/item?id=2355427

davidhollander··on Arch Linux – "It is what you make it"
The "shallow mental model" most likely refers to fewer initialization files and locations. When starting out, most everything you need is in /etc/rc.conf . Also, Arch and its package manager don't use /usr/local/, instead simply using /usr.

"It really does take time" most likely refers to the fact that you are responsible for building up the OS yourself. So unlike in an OS like Ubuntu, where you do not have to know what a window manager is, or what an xorg xserver and client means, you'll have to learn it all along the way.

Fortunately the wiki makes figuring everything out managable, and I found it an enjoyable to spend a couple days with different software[1] and a programmable tiling window manager[2]. The end result is a fast-booting custom tailored system.

[1] https://wiki.archlinux.org/index.php/Lightweight_Application... [2] http://awesome.naquadah.org/

davidhollander··on Comparing Go with Lua
I'm a big fan of Lua and Go's use of multiple return values, nil, and simplified error handling, (No exception 'types'). I think the problem with 'typing' Exceptions is that it means you are using it to record and pass describable\known state similar to return, instead of being reserved for unknown state. For indicating predictable failure states without using exceptions, I think multiple return values as used in Go and Lua is a much better paradigm. To recap Steve's post, opening a non-existent file in Lua:

    =io.open 'sdfasdf'
    nil	sdfasdf: No such file or directory	2
The first value returned is nil, the 2nd value is a string containing an error message, and the 3rd is an integer error code. This allows you to write most code using 2 state boolean logic:

    f=io.open 'sasdasdfsf'
    if f then -- nil is a boolean 0
whereas in Python, one often has to reason about 3 states due to the use of try\except blocks. Even though you are not using typed Exceptions, multiple return values does not discard any state about the error if it is desired:

    f, err = io.open 'sasdasd'
    print(err)
In Lua (not Go), when you combine multiple return values with an assert() function of the form assert(boolean, error_message), you effectively get a mechanism for making exceptions optional:

    > =assert(io.open 'sdfasdf')
    stdin:1: sdfasdf: No such file or directory
    stack traceback:
    	[C]: in function 'assert'
    	stdin:1: in main chunk
    	[C]: ?
Although Go does not appear to include assertions at all, arguing against them in its FAQ: http://golang.org/doc/go_faq.html#assertions
davidhollander··on Will Deflation Destroy Bitcoin?
Krugman wrote a column on BitCoin: http://krugman.blogs.nytimes.com/2011/09/07/golden-cyberfett...

He predicts failure by asserting its algorithmic scarcity results in an ultimately deflationary currency which will result in hoarding and not spending money on goods, and uses it as a proxy for arguing against returning the USD to a gold standard.

I thought the first answer was an interesting repudiation regarding currency divisibility and effects of deflation. I think it's interesting that although prices for computing power are massively deflationary, consumers continue to keep buying faster computers every few years.

davidhollander··on Why Haskell is Kinda Cool
>More compile time errors = fewer run-time errors.

But any possibility of 1 run time error means you'll still need to manually write a test asserting the correct runtime behavior anyway. So the typical argument is that typed languages don't actually save you any work, and might actually increase the likelihood of errors by discouraging unit testing.

I'm not claiming this holds for Haskell, as my experience with the language is not great enough to pass any judgement yet.

davidhollander··on Why Haskell is Kinda Cool
> Since most of my bugs in other languages stem from unwanted interactions between pieces of code via side effects, this is kind of a big deal.

Is this really the case for most people? Most of my errors are syntax, pattern matching, not considering certain cases, unrefined logic, etc.

Creating external side effects such as writing to files or sockets is not that big of deal or as error prone, because after you learn that trick once, it behaves in the same way. The POSIX standard does not change as frequently as my own code :)

davidhollander··on I am nothing
No apologies necessary, I did indeed use a newtonian object as the particular for ego in the first analogy. In regards to abstract forms and mental constructs as not existing in the same manner as objects, I'd disagree with you and the OP and hold that they do exist, at least in the same manner that everything else can be said to, if anything else is said to. In other words, I would assert there is no difference in types of existence nor duality between existence and nonexistence, object and nonobject, that is derivable and non-arbitrary. What I would concede is that an ego (and everything else) is "empty" of perfect causal independence. In other words, it must be emergent and generated.
davidhollander··on I am nothing
>As for your analogy, that our thoughts and selves are an object in motion, which we must curb to reach a desirable point in space: the reality is, there is no object.

Ah, how convenient, a single objective reality where nonexistence is possible :)

To more precisely define my analogy and convey my understanding: current thought is a recurrence relation with previous thoughts. Inertia is the strength of the recurrence relation, the degree by which previous thoughts determine present thought. This is measurable as neural adaptation and learning. Ego or self is an observed distribution of thoughts occurring during a certain duration. As with statistical distributions, we tend to construct parameter estimators to make sense of the data[1].

Now, as with statistics, whether these generated parameters contain information and are useful in describing the distribution is up for debate and dependent on the question the investigator seeks to answer. But simply stating 'there is no object' is as sensical and productive as claiming 'there is no mean, there is no standard deviation'.

[1] http://en.wikipedia.org/wiki/Method_of_moments_(statistics)

davidhollander··on I am nothing
Premise: we are what we think about. Being nothing requires one to think about nothing. It's actually quite a lot of work to think about nothing! The brain is constantly solving problems while awake and while asleep, building up momentum.

Proposal: Instead of expending massive amounts of energy bringing an object of such high inertia to rest, why not just change the inputs you are feeding it to gradually alter its direction? Don't focus on the cessation and extinction of the turning of mind. Focus on feeding the turning of mind solvable or aesthetically pleasurable problems, to decrease the bandwidth occupied by unsolvable\fear based problems.

tldr: I'm not convinced the epicness of ego destruction is necessary for ego transmutation, if that is one's goal.

edit: Well, I just realized my analogy does not hold for all cases. In Physics, if you want to change the direction vector of an object in motion, to the opposite of its present heading, it will require at least as much energy as bringing the object to rest. So focusing on ego destruction could be worth it depending on where you want to go and where you are now.

Additionally, we also know from Physics that all motion is relative, velocity cannot be measured without a frame of reference. I think the Buddhists would argue that cessation of the turning of thought provides this otherwise missing frame of reference, enabling the thought\ego vector to accurately be measured when the turning of thought restarts.

davidhollander··on Awesome Window Manager
Tiling window manager, scriptable with Lua. If installing on top of Ubuntu:

sudo apt-get install awesome, logout, select 'awesome' at login. Meta+w to get to the manual. Meta+r 'nm-applet' to connect to the internet if it does not automatically.

davidhollander··on Hacker puts a video cam on an RC truck and saves the lives of 6 soldiers
A response to statements such as:

> it shouldn't be that damn hard to send some RC cars to Iraq to save lives

Actually, efficient resource allocation is usually a NP hard problem! It's very computationally complex, and the US Department of Defense is one the largest bureaucracies in the world. From that perspective, and depending on one's expected value for bureaucratic efficiency in relation to size, one could also argue that the efficiency of the DoD is surprisingly good.

What could possibly help the Department of Defense's resource allocation problems for such infantry equipment, and to open up the possibility for more off-the-shelf solutions, is to push acquisition demand down to the squad level as much as possible. You would more or less be giving squad commanders equipment purchasing credits to allocate independently of one another. This would simulate one the best tools currently available for resource allocation, markets.

davidhollander··on SICP is Under Attack
>Beautiful.

I guess beauty is in the eye of the beholder. A simpler way to analyze this problem is noticing the f(n-3) term implies your function has to memorize up to 3 previous results. Then just use the coefficients from the formula to cycle the next result into memory. Using algebra and generating new coefficients as per the OP's solution is unnecessary.

    function f(n)
      if n<3 then return n end
      local a, b, c = 0, 1, 2
      for i=3,n do
        a, b, c = b, c, c+2*b+3*a
      end
      return c
    end
davidhollander··on SETI Needs Your Help to Resume Search for Extraterrestrial Life
My point was simply that SETI isn't related to the NASA funding debate, and the OP wanted to connect the two via an emotional space shuttle reference.

>Why don't we devote more to exploration?

Maybe because people are failing to communicate its benefits clearly? For instance, the OP:

war==bad + assertion of disgust --> X==good

X could be anything. ANYTHING. Why aren't we investing more in wooden shoes? Didn't you know war is bad? Even if X==good, I hope people are inoculated against these type of arguments.

davidhollander··on SETI Needs Your Help to Resume Search for Extraterrestrial Life
>It's disgusting that we can spend as many billions of dollars a year as we do on blowing each other up, but things like "Let's see what's on the other side of that proverbial mountain" get defunded because they're "pointless".

?? The SETI institute is a California non-profit organization. The government cannot defund it, because it receives no government funding. It is financed entirely by private contributors.

davidhollander··on If you gaze into nil, nil gazes also into you
I'm a big fan of Lua's use of nil and the simplified error handling (No exception 'types') in that language. I think the problem with 'typing' Exceptions is that it means you are using it to record and pass describable\known state similar to return, instead of being reserved for unknown state. For indicating predictable failure states without using exceptions, I think multiple return values is a much better paradigm. Here's what happens when you open a non-existent file in Lua:

    =io.open 'sdfasdf'
    nil	sdfasdf: No such file or directory	2
The first value returned is nil, the 2nd value is a string containing an error message, and the 3rd is an integer error code. This allows you to write most code using 2 state boolean logic:

    f=io.open 'sasdasdfsf'
    if f then -- nil is a boolean 0
whereas in Python, one often has to reason about 3 states by using the try\except blocks. Even though you are not using typed Exceptions, multiple return values does not discard any state about the error if it is desired:

    f, err = io.open 'sasdasd'
    print(err)
I believe this also the design decision Google's Go language has made: http://golang.org/doc/effective_go.html#multiple-returns
davidhollander··on Poll: What online music service do you use most frequently?
For streaming music, YouTube playlists and http://www.di.fm/ are my favorites for convenience. It's nice to have the tracks sequenced by actual DJs in mixes if I want to hear a lot of new stuff. Di.fm is the only streaming service I have actually payed for before, they have a good iPhone app as well.

I also use Last.fm, but only for passive scrobbling and not listening.

Youtube should definitely be on this list, it has an insane amount of material compared to every other catalog, there are even plenty of out of print Vinyl rips being uploaded.

davidhollander··on LevelDB: A Fast Persistent Key-Value Store
> and its permissive license

Other variables such as licensing are context dependent. In my context, I generally use embedded databases in shared library form to store arbitrary serialized Lua (much faster to reload than JSON, no need to compile protocol buffers) on my own servers, so in my development context LGPL vs BSD is irrelevant. But perhaps not for an iPhone developer. TokyoCabinet already has excellent bindings for nearly every language I've used, but thats irrelevant to a developer whose application is also C.

> Compare today's benchmarks with these http://fallabs.com/tokyocabinet/benchmark.pdf, it looks like random reads in LevelDB are quite faster than BDB.

I'd bet BDB is a snail, BUT the benchmark you just linked tests 0 databases in common with the one released by Google. What can be observed is that using a hashmap (TC) was over 7X faster than randomly accessing the fastest ordered data structure by the same author (TC-BT-RND) :)

davidhollander··on LevelDB: A Fast Persistent Key-Value Store
>LevelDB is slower with random reads, but that doesn't mean you shouldn't use it for unordered data - it's still quite fast.

In a positive analysis (should rather than shouldn't), assuming no default choice, it seems rational to use Tokyo Cabinet or CDB _hashmaps_ for unordered data, and LevelDB for ordered data, from a datastructure and performance standpoint. To assert more would probably need a specific use case for context.

davidhollander··on LevelDB: A Fast Persistent Key-Value Store
BDB is a key\value store for unordered data more similar to Tokyo Cabinet hash databases. Tokyo Cabinet hash databases are a much faster option than BDB if you only need unordered data.

LevelDB is for if you need ordered data, and a more appropriate comparison would be against a B+\tree database.

davidhollander··on Researcher Develops Cocaine Vaccine
> I then would like to see a law mandating its use for all people who who have a DUI.

The problem is that such vaccine wouldn't only work when you are in a vehicle or prevent you from making other stupid decisions. This really wouldn't address the root cause and would be a pretty egregious violation of an individual's freedom of thought.

The idea of the state having authority to permanately biologically alter an individual to control his or her behavior is a throwback to the time of lobotomies, which even the Soviet Union banned in the 1950s.

← PreviousPage 4 of 8Next →