HNHacker News
TopNewBestAskShowJobs

davidhollander

996 karma · joined December 11, 2010

.
submissionscomments
davidhollander··on Functional languages will rule (but not this year)
>If I find time to neaten up that code, are you interested in swapping notes?

Yes, I wrote a coroutine-less one here and tried to include design decisions in readme: https://github.com/davidhollander/ox

It works for HTTP but has few features so far. I have a bunch of exploratory code lying around though, so I could be adding message passing or better fileserving to it in the future. I will send you an email at some point.

davidhollander··on Functional languages will rule (but not this year)
Coroutines aren't as flexible as continuation passing style and add significant overhead for the non-vital syntactic sugar they give you.

I'd much rather explicitly set an OnWrite event that has a one-to-one correspondence to a socket write event from a poll() system call, than create a ton of coroutines and juggle "resumes". This is especially true if you have a usecase where you want to start sending while you are still reading, this would require the creation of 2 coroutines per each context.

While Lua coroutines are significantly better than Python generators by having a more functional than syntactical "yield", I still feel it does more harm than good for structuring asynchronous applications.

davidhollander··on Functional languages will rule (but not this year)
> Unfortunately, Lua has statement- rather than expression-oriented semantics (i.e., no "implicit returns").

This is largely irrelevant for anything related to developing asynchronous services such as web or servers. Asynchronous web development using callbacks is a form of continuation passing style, where control is often explicitly passed using a callback. Since you are explicitly passing control, you usually never have to return values anyway. The 'return' keyword just becomes a bonus feature for convenient error handling.

Having a language with good closure support just works phenomenally well for asynchronous web development. For instance, sending an entire message asynchronously can be a pain because it can fail at any point in the message and require restarting at that point and keeping track of when it has finished.

It's a piece of cake in Lua though, due to its excellent support for closures:

    -- SendAll
    -- Start sending a message on connection [c]
    -- Close when done.
    function SendAll(c, msg)
      local n=0
      OnWrite(c, function(c)
        n=n + c.fd:send(msg, n)
        if n>=#msg then
          c.fd:close()
          return 'close' -- just for kicks
        end
      end)
    end
The variable "n" is a counter for the number of bytes sent to the file descriptor "fd". The write callback lambda assigned with OnWrite can always access the appropriate counter "n" based on its creation location. No extra work was needed to create the closure, unlike in languages such as JavaScript.
davidhollander··on Functional languages will rule (but not this year)
> Also important is that CoffeeScript's main selling point is that it's practical and more sane then JavaScript, not that it's functional or lisp-like. At the same time CoffeeScript is probably the closest thing I've seen to a (potentially) successful lisp-without-parens

Have you tried Lua? It has full lexical scoping like Scheme (so you don't have to (function(){})() all over your code to create closures) and has saner built in types than vanilla JS, while also being much faster (around SBCL\Java speed with LuaJIT).

I'm writing a basic functional library for it here if you need some stuff like map, foldl, foldr, partial, filter to get started: https://github.com/davidhollander/fn

davidhollander··on Author of LuaJIT explains why compilers can't beat hand-coded assembly
For anyone recently trying LuaJIT2:

If you are wondering why readline (history) support is missing from the interpreter and how to add it: http://dhllndr.posterous.com/adding-readline-support-to-luaj...

Also, I just put a small functional programming library for Lua on GitHub about an hour before reading this: https://github.com/davidhollander/fn Here's an example of how to create a sum function with Fold Left and an addition function:

    require'fn'
    sum = fn.partial( fn.foldl, function(a, b) return a+b end)
    x = sum(1, 2, 3, 4, 5, 6, 7, 8, 9)
    print(x)
    -- 45
...and for anyone who hasn't tried LuaJIT2: http://luajit.org/download.html
davidhollander··on Linux: The Source of All Desktop Innovation
Gnome-Do http://do.davebsd.com/ is what originally sold me on switching to Linux as my main desktop.

Much quicker to open what I need than either Windows 7 autocomplete or OSX spotlight.

davidhollander··on Node.js Interview: 4 Questions with Creator Ryan Dahl
>No matter what I did, someone was going to load an existing blocking Lua library in and ruin it.

I don't think this is the case, the most popular library for networking in Lua has been COPAS, which does nonblocking by using coroutines. And even the canonical guide to Lua, PiL http://www.lua.org/pil/, also has a chapter on using coroutines with LuaSocket to download multiple files asynchronously at the same time. Most complaints of Lua are about having too few libraries, so it's interesting to see an argument claiming it has too many.

If anyone is interested in a nonblocking networking library that uses callbacks (similar to node.JS) instead of coroutines for Lua and LuaJIT, I've started such a project here: https://github.com/davidhollander/ox

davidhollander··on ASK HN: Can any of you solve this?
[edit, Made a mistake, added sanity checks]

sin theta = r_earth / (r_earth + altitude)

theta = arcsin( r_earth/(r_earth + altitude))

p_visible = (2pi - 2*theta)/(2pi)

p_visible = 1 - arcsin ( r_earth / (r_earth + altitude))/pi

.

.

Sanity checks:

r_earth = 6378.1 X 1000 m

altitude = 1m

p_visible = .50006

.

altitude = 10^7 m

p_visible = .66766

This fits intuitively: the further away you are from the Earth's surface, the more of the sky you can see without the horizon interfering.

davidhollander··on All modern web-browsers except IE9 are vulnerable to a huge memory leak
Nice, just installed and I'm loving the JS terminal so far. Thanks for the link.
davidhollander··on All modern web-browsers except IE9 are vulnerable to a huge memory leak
Just booted up firebug due to your comment because I hadn't used it in a while. Here is my reaction after using Chromium dev tools:

- JavaScript auto complete text doesn't display right, it is a different font size shadow that obscures the typed text.

- Pressing tab multiple times will not cycle autocomplete, but instead jump the focus out of the console and into the search prompt.

- Really minor, but I prefer a terminal where the output and input are simply in the same line rather than in seperate locations that require looking back and forth.

- If I declare a function "hello" in the terminal, and then type "hello", it merely prints "hello()" instead of printing the source of the function. Printing the source of the function with no extra work is especially valuable if I grab the non minimized version of a new javascript library and want to poke around and see what everything does.

+ I do think the "Net" tab displays requests a bit more concisely than Chromium. This could be beneficial if you are dealing with pages with lots of pictures.

= CSS and DOM inspection seems about equal.

My main concern is JavaScript though, as my current app is doing all of its rendering client side with only the Model layer on server.

davidhollander··on All modern web-browsers except IE9 are vulnerable to a huge memory leak
I was a long time Opera user and love its configurability and full keyboard support for general browsing, but the Chromium dev tools won me over from a developer perspective and I disliked switching between the two.
davidhollander··on Satellite Images of North Korea Prison Camps Find 200,000 Living as Slaves
> But this is why NK gets to go merrily about its way starving and torturing its citizens.

No it's not. There are 3 foreign policy "sticks" that could be used to end this situation:

1. Invasion

2. Sanctions

3. Shaming

Aggregation of frustration is not one of them.

They have differing requirements in order to be effective:

1. Requires a weak enemy military and existent domestic political opposition to the regime. Internal dissonance exists and your forces are not over-leveraged on other fronts.

2. Requires the entity to already be integrated in the global economy. There is something real you can withhold that will not cause additional mass starvation.

3. Requires high social proof. Those doing the shaming can easily deflect accusations of hypocrisy to rapidly build a global and regional (Chinese) consensus.

Notice that no conditions necessary for 1 or 2 are present. This leaves 3 as one of the most obvious routes to discuss. As the US currently has the world's largest population of prisoners, it makes it hard for the USA to end the prisoner problem in North Korea as effectively as it could. Discourse will necessarily gravitate towards how the US can improve its social proof by striving for exemplary domestic policies. It's not a matter of "moral equivalence", but of being open to moral improvement when others remind us of our faults. Unless we can think of a new kind of stick, this may remain the best way to help those in North Korea.

davidhollander··on Satellite Images of North Korea Prison Camps Find 200,000 Living as Slaves
>The biggest problem in American prisons is the advocacy by law enforcement of inmate-on-inmate rape as a sanctioned form of punishment

Do you know if this is correlated with overcrowding of prisons (actual capacity vs. intended capacity)? You mentioned California prisons are some of the worst, to my knowledge they are also the most overcrowded?

What strikes me in a comparative analysis of the US penal system is not quality of treatment, but the perverse economic incentives promoting hoarding such a large percentage of the population in them. I would argue the biggest problem in the American penal system is public policy structuring unrehabilitated prisoners as assets:

1a. The standard contract for private prisons seems to be money per prisoner housed rather than money per prisoner rehabilitated.

1b. Each prisoner generates further revenue for the private prison as a labor source.

1c. Thus on a balance sheet, each additional unrehabilitated prisoner becomes an asset to be kept rather than a liability to be reduced.

2. Allowing drugs inside prisons becomes an efficiency gain, as prisoners failing drug tests results in assets being held longer.

3a. When prisoners are housed in prisons in rural districts, they count towards that districts population for purposes of calculating representation in state legislature. Even though prisoners cannot vote and are primarily from urban districts.

3b. Prisoners then also become an asset rather than liabilities for politicians in rural districts by giving them undue representative power. Politicians then are incentivized to increase this asset by supporting minimum sentencing laws.

Now there may be no direct agency or conscious intent to the above, but historically changing the underlying structure of economic incentives can have profound positive effects on individual behavior: http://www.npr.org/blogs/money/2010/09/09/129757852/pop-quiz... . I'd be interested to know if this perspective fits with your knowledge of the subject.

davidhollander··on What percentage of people are alive today?
>Am I the only one absolutely terrified by that number?

No, unfortunately there are plenty of other irrational sensationalists.

>Malthus wasn't wrong in principle, just in timescale.

He has been horribly wrong in principle, as has every other pessimist who cried wolf for the past 3000 years. Saying 'the timescale was just wrong' is not an adequate defense by any means. Timescale is what matters and is the essence of all predictions.

Ask a trader: a prediction that oil will go up in the long run is completely useless if you don't define when that event will occur, and subsequently loose everything on a big short term dip that you were blind to.

Additionally, if your prediction is allowed to take "infinity" duration to come true, then it can never be disproven. And what can't be disproven is usually categorically not worth the thought.

To discuss particulars, the current evidence is technology allows us to produce TOO much food TOO cheaply, which is compounded further by domestic farm subsidies. Efficiency gains are so successful in keeping up with demand, that in Mexico City they buy corn from Iowa, even though they have cheaper farmland and local labor that could be utilized.

Additionally, many economists are currently considering the possibility of efficiency gains being so strong a factor that they lead to structural unemployment. This picture of runaway efficiency gains is the exact opposite of what Malthus had envisioned (constant\linear resource utilization massively outstripped by population growth rate)

>It's sounds science fiction-ey, but I don't understand how you can see data like this and then defund NASA.

All the nations economically developed enough to have a space program are rapidly decreasing in population. China, Russia, Japan are all on the decline, the US is only increasing due to immigration. It's economics 101: wealthy people have more economic freedom to invest in birth control and their time in things other than family. Additional children switch from being an asset into a liability when you have to pay substantial amounts for them to be educated and the opportunity cost of taking time to raise a child becomes higher. The S shaped curve has been in full swing in developed countries like the US and Russia where the vast majority of the land is deserted, without anything resembling a Malthusian scenario.

davidhollander··on Unthinking Machines: Artificial intelligence needs a reboot, say experts
>Winston said he believes researchers should instead focus on those things that make humans distinct from other primates, or even what made them distinct from Neanderthals.

According to cognitive science, this is capacity for analogical reasoning. Compared to the other self-aware, social, tool using animals exhibiting emotion such as dolphins, elephants, and the great apes, what sets humans apart is our massive capacity for analogical reasoning that leaves dolphins in a distant second.

In other words, humans can not only think in terms of relations, but how relations relate to one another much easier than any other animal.

davidhollander··on LevelDB: a fast and lightweight key/value database library
> difference in data structures

Always good to have more tools in one's arsenal in that case. I'll drop one of you a message if I write a Lua binding for it (using LuaJIT+embedded k/v for data services atm).

davidhollander··on LevelDB: a fast and lightweight key/value database library
Based on their numbers it looks slower than TokyoCabinet but still much faster than BerkleyDB. Would need to design a head to head benchmark.

I don't think Redis is a good comparison as that's an in-memory database so better suited for the 10% of hot data you'd need to cache. Whereas disk stores like TokyoCabinet and LevelDB would be great for storing the other 90-100%. If your use case involves a large dataset and you don't have terabytes of RAM lying around, that is.

davidhollander··on Peter Thiel Is Wrong About Higher Education (It’s Worse Than A Bubble)
Flip the system and make the classwork homework and the homework classwork.

Instead of a lecturer being the 5000th person trying to teach the subject with a varying degrees of preparedness, you just get the single best and most enthusiastic lecture of all time, everytime, as a video. Then in class teachers, TAs, and students can have normal humans conversations with each other to work through problems and peer interaction to motivate learning. Instead of this being relegated to additional office hours\recitations\labs.

davidhollander··on You Got NoSQL in MySQL: Memcached Plugin in MySQL Technology Preview
If anyone is interested in direct access to InnoDB (without relying on Oracle who has stopped distributing it for download on their website) you can embed it directly into your applications using HailDB, which is an open source project continuing its development:

http://www.haildb.com/

davidhollander··on Wozniak: Tablet is the PC for 'normal people'
Does _anyone_ bother to fact check on Hacker News?

The first cars were not trucks, they were carriages. And your 35 horsepower Mercedes in the 1900s was not being bought by farmers but was being purchased by wealthy urban dwellers. The word "truck" by itself did not even refer to a motorized vehicle until the 1930s. Cars started out as a post-agrarian weakly powered luxury good for passengers before they ever became heavy duty farm implements, SJ's narrative is backwards.

http://en.wikipedia.org/wiki/Automobile http://en.wikipedia.org/wiki/Truck

Step outside of the reality distortion zone, please.

davidhollander··on Firefox 4 is here
For anyone upgrading firefox on ubuntu:

sudo add-apt-repository ppa:mozillateam/firefox-stable

sudo apt-get update && sudo apt-get upgrade

davidhollander··on The site Microsoft forgot: IE9 countdown
np, it's visible on my display just trying to be helpful based on past experience with others and seeing the initial comment. Part of what might actually be happening is that after seeing the header for each of the 3 columns, the eye sight jumps to the links at the bottom of the columns because it is higher contrast than the body text, and then the visual focus can't help but leaking further down into the "Oh ma" footer which also has higher contrast than the column body text, and then for each column the reader has to make a more concentrated effort to go back and focus on what that important content said. Whereas on the IE6 site, the body text of each column is actually higher contrast than its header and link footer rather than lower. So I think they got that annoying feeling you get when you have to reread a page of a book.
davidhollander··on AT&T has a fiberoptic splitter copying our data to NSA
>As was said by Deng Xiapong "it doesn't matter if the cat is white or black.."

..because "Parkinson's Law works everywhere." - Mikhail Gorbachev

davidhollander··on The site Microsoft forgot: IE9 countdown
The 3 columns are #ababab on #ffffff in Chrome, in other words a 33% difference in brightness. For primary body text of regular or thin width, a lot of readers are uncomfortable below 50%.
davidhollander··on OATV posted an opening for an associate. Only one woman applied.
I'll play devil's advocate to claims of illegality.

He said the "requirement" could be broken and convertible to any demonstration of creativity. Which is not a restriction on a protected class.

This doesn't seem insanely different than asking programmers to complete problem sets or coding scavenger hunts to apply. Here the assignment is social engineering rather than technical. For VCs, meeting people they are assumed not to know ahead of time to get in on deals is the core competency.

davidhollander··on How to construct a web developer in twelve months
Way too "culture" heavy. The only thing important on the list is BUILD, which is 2nd to last and does not include example projects to start building their momentum. If you only have 12 months to become a web developer, I hope all that time is spent building as many different projects as possible and not reading Hacker News.

Also I don't think it's smart to immediately steer them toward MVC framework such as Django or Rails. If you give them web.py or Sinatra off the bat you'll expose them to the fundamentals much quicker and significantly accelerate their learning process. Especially in regards to databases.

Then I would throw asynchronous web development at them. Have them write a simple app on top of an event loop with something like Node.JS or one of the python options (gevent,fapws3,tornado,etc.)

Having said the above, there are more books for Django and Rails if thats their preferred learning format. If there is a time crunch, I would recommend "Django 1.0 Website Development" by Ayman Hourieh. It walks through building a complete social bookmarking app and includes chapters on jQuery and AJAX, instead of focusing exclusively on Django. Which will give them a bit of breadth.

davidhollander··on Former nuclear reactor operator on Fukushima risks
>the US military has flown coolant to the site, but the coolant they use is regular water; I can’t imagine why the US would need to fly in coolant.

The US did not fly any coolant to Japan.

http://www.reuters.com/article/2011/03/11/japan-quake-nuclea... "US did not deliver coolant to Japan nuclear reactor"

"Ultimately, however, Japan did not need assistance from the United States but Clinton did not appear to have been updated before she made her public remarks."

davidhollander··on Cringley: Japan may have just permanently lost 20% of its electricity supply
>Hillary isn’t the kind of person to choose the wrong words

How has no one pointed out there was never any coolant delivered and Hilary Clinton did in fact misspeak? It renders this article a bit moot.

http://www.reuters.com/article/2011/03/11/japan-quake-nuclea... "US did NOT deliver coolant to Japan nuclear reactor"

"Ultimately, however, Japan did not need assistance from the United States but Clinton did not appear to have been updated before she made her public remarks."

davidhollander··on DuckDuckGo chat bot: imddg.gg
>"DuckDuckGo" itself is still an odd naming choice

I think what makes the name weird is that it interjects not zero, not one, but TWO hard sounds ("ck") in the middle of the name. It requires 5 movements to speak it out loud (Du-ck-Du-ck-Go), as oppossed to 2 (Goo- Gel). One has to be careful with adding hard sounds into the middle of product names.

davidhollander··on DuckDuckGo chat bot: imddg.gg
>DuckDuckGo chat bot: im@ddg.gg

>DuckDuckGo now has a chat bot at im@ddd.gg

Apparently the domain name even confuses the author

← PreviousPage 6 of 8Next →