HNHacker News
TopNewBestAskShowJobs

efaref

1,217 karma · joined July 16, 2014

submissionscomments
efaref··on Malloc envy
Manual deallocators are more interesting.

PJSIP[1] has an interesting approach to this. SIP messages have lots of strings associated with them, are usually relatively short-lived, and typically you'll want to modify these strings or attach new ones. PJSIP does this by hanging a string arena off of each SIP message object.

As you add strings to the SIP message, these get appended to the arena, which is grown automatically as and when it needs to be. If you delete a string, it just sticks around in the arena unused. Arena space can also be shared, e.g. if you copy a substring from one SIP header to another, it'll just be referred to twice using a pointer and length.

Finally, when you free the SIP message, it just frees the entire arena in one go.

[1] http://www.pjsip.org/

efaref··on Malloc envy
If anything, Rust shows that you can have reliable "manual" memory management without the need for a GC. The best of both worlds.

While I don't buy the GC performance argument, it's ok to use it, because most of the time it doesn't matter. Sure it can be "almost as good as" manually managing memory, but that's about as hard to achieve as manually managing your memory. The point of GC is that it relieves the programmer of caring about managing memory, and as such it's only really useful where the system has sufficient resources that the fact that a GC is running doesn't matter. For the vast majority of workloads on modern hardware this is true.

At the other end of the scale, in real high-performance embedded systems, even malloc+free is too slow, and memory fragmentation is too much of a problem for things with expected uptimes measured in years. GC is a complete non-starter here. Instead these systems use pools of fixed-size buffers than can be O(1) allocated and freed, and never fragment. You can use MRU allocation of buffers from these pools to keep the dcache warm, and you can make your memory-using operations queue until they can reserve the memory they're going to use up front so that your system can run flat out using all the memory it can without ever crashing from OOM. Both malloc+free and GC (especially GC) can only dream of those characteristics.

efaref··on Left-pad as a service
That's just a no-true-scotsman fallacy.

And pinning versions just means you lose automatic updates, which is surely the point of using a package manager in the first place. Otherwise you might as well just download the package and include it verbatim.

efaref··on Top Myths About Teaching Computer Science (2015)
#1 is definitely off, for certain in the opposite direction. There are some people who simply do not "get" software, and never will. And that's ok.

I'm have aphantasia, so I will never be an artist. That's ok. Some people are tone deaf and so will never be musicians. That's ok. Some people are just, let's say "logic blind", and so can never understand how a computer will work through software. They just can't follow it in their minds, in the same way that my mind just can't visualise pictures that are not currently in front of my eyes.

It's important that we don't claim the opposite so that people who discover they have aphantasia, or are tone deaf, or are logic blind don't think there's something wrong with themselves, because if "everyone can do it" but they can't then they must be either broken or lazy.

efaref··on English Syntax Highlighting
Of course the compiler has no problem understanding them, but humans aren't that good as parsing.

The purpose of a syntax highlighter is so that the human knows that the computer agrees on what the sentence/code structure is.

efaref··on AlphaGo Is Not the Solution to AI
Also, people are in general really bad at understanding how hard some problems are, particularly in relation to how easy we've made some seemingly magical things.

Reminds me of this XKCD: http://xkcd.com/1425/

efaref··on Venture Capital’s Answer to High-Priced Housing: Dorms for Grown Ups
Perhaps companies like Apple can get tips on worker dormitories from their business partners in asia:

http://www.theatlantic.com/international/archive/2012/10/ins...

efaref··on English Syntax Highlighting
Syntax highlighters for natural language would help against garden path sentences:

For example:

    The old man the boat.
... is not ambiguous if written as:

    {SUBJECT}[The old] {VERB}man {OBJECT}[the boat]
I think the reason syntax highlighting is important in programming is because garden-path style sentences are more common with the pedanticly strict grammars that programming languages require.
efaref··on Revealed: the 30-year economic betrayal dragging down Generation Y’s income
> We just have to stop them from voting themselves legislation to compensate.

Too late. In the UK at least, the state pension is being increased from ~£110pw to ~£150pw, despite the fact that pension payments are among the government's biggest liability and we're apparently in a time of austerity so severe that we're required to starve disabled people by removing their living allowance unless they submit to humiliating tests.

Meanwhile, the chancellor is planning some more pension "reforms" later this month, which is most likely going to involve removing the deferral of tax on pension contributions, i.e. moving all the tax payments that were due to happen in fifty years' time to today. That means the current pensioners will benefit from tax paid on current pension payments as well as tax paid on current pension contribuitions. By the time millennials retire, the deferred payments will have expired, and only the current contributions will remain.

Add on to that the massive blackhole that will be the forgiving of student loan debt (which even by the government's own optimisitic predictions, 40% of which will be unpaid over its lifetime - many experts predict this will be higher), and you begin to see exactly how fucked millennials will be come retirement.

efaref··on Some ad-blockers are tracking you, shaking down publishers, and showing you ads
The ad-blocker-blockers are annoying, and my usual response is to just go elsewhere. I'm not turning on advertising for anyone.

That being said, I'd happily pay a small ($5-10/mo) subscription if it enabled all (or a large number of) these sites again. Alledgedly my eyeballs are work millicents to advertisers: I'd like to buy all the advertising space I'm being shown at that price.

I don't think an adblock company could do it, as it would be too much like a protection racket, but surely someone could set up a subscription-based service for "ad-free content", where sites that took part got a slice of your flat subscription fee. A bit like microtransactions, except not microtransactions.

efaref··on Bill and Melinda Gates 2016 Annual Letter
http://www.forbes.com/sites/jamesconca/2012/06/10/energys-de...

It's the safest form of power we have.

efaref··on The Political War on Cash
Clearly we should replace Euro notes with Rai Stones[1] :)

[1] https://en.wikipedia.org/wiki/Rai_stones

efaref··on Debunking the myths about parsing JSON in Swift
True. Although the Android JsonReader class does force you to write your own parser (it is itself merely a lexer). This is really inelegant.

What I'd really like is a way to write my POD types as normal:

  class Foo {
    int bar;
    String baz;
    ArrayList<String> blah;
    ArrayList<Xyz> xyzs;
  }

  class Xyz
  {
    String name;
    int value;
  }
And then just write this to parse it all.

  ...
  Parser<Foo> p = new Parser<Foo>();
  Foo f;
  try {
    f = gp.parse(input);
  } catch (JsonParseException e) {
    ...
  }
I'd be willing to accept having to annotate some of the fields, (but other than that, this should be possible to do).
efaref··on A Message to Our Customers
From what I heard later revisions won't accept a firmware update without either providing the passcode, or erasing the private key.

Arguably, the fact that the 5C accepts a firmware update without the passcode is a security vulnerability and ought to be patched.

efaref··on An 'in' operator for Ruby
Well, shell has the '-ne' operator, which is 'not equals' in a terser style.

Really '!=' is just an attempt at rendering '≠' using only ASCII characters. They're a bit like digraphs and trigraphs in C/C++, except everyone is used to them.

I wonder if Unicode is ubiquitous enough now that you could write a language where the real maths operators were used instead. What would that look like?

efaref··on An 'in' operator for Ruby
.include? isn't really a predicate, as predicates are typically unary. Rather, it's the 'member of' relational operator written in the wrong direction. Since we don't have '∈' in ascii, the author is proposing using the word 'in' instead.

I do disagree with the author on one point: 'not in' should also be a valid operator, representing '∉'.

But I don't use Ruby; I mostly use Python, which has these operators.

efaref··on A bit of background for the unified C++ call proposal
Yes, except for calls to virtual functions, which actually become

  (&x)->vtbl[N](&x, y)
efaref··on Movebubble, an app that aims to make renting in London suck less, raises $1.6M
0 results found.
efaref··on Movebubble, an app that aims to make renting in London suck less, raises $1.6M
If renters can report a place as "gone" and once a few of those reports are in, the place gets delisted (or, at least, visibly marked as "reported gone" and removed from searches) will encourage agents to keep things up-to-date.
efaref··on I no longer understand my PhD dissertation
Leslie Lamport wrote a paper on this subject over 20 years ago.

http://research.microsoft.com/en-us/um/people/lamport/pubs/l...

As far as I can tell, nobody has really adopted any of his proposals yet, and most papers continue to be written in pseudo-prose. Remember, mathematics used to be written in full prose (e.g. "the square of the hypotenuse is equal to the sum of the squares of the other two sides") and it took hundreds of years for us to realise that "x^2 + y^2 = z^2" was a better notation.

While mathematics may be "genuinely very difficult to understand", so is any complex piece of software. Software engineering techniques might be useful to mathematicians, even if they are all new-fangled and modern.

efaref··on Making robust software: the “Mars Code” talk (2012)
> For example, coding standard says every "case" statement has to have a "default" switch. grep "case", grep "default", and you get wildly different numbers!

I hope that's an error in the document. I assume they meant "$(grep -r 'switch (' . | wc -l) != $(grep -r 'default:' . | wc -l)".

efaref··on A bit of background for the unified C++ call proposal
Under the covers, `x.f(y)` is actually something like `_ZN1X1fEi(&x, y)`, where the mangled name indicates the class of X and the type of y. The implicit 'this' pointer is actually explicit in the implementation. Similarly, a call to `f(&x, y)` would actually be a call to `_Z1fP1Xi(&x, y)`, with similar reasoning.

The author is proposing that writing

  f(x, y)
Which would normally only bind to the second mangled function, would bind to the first mangled function if the second is not available.

The additional proposal, that:

  x.f(y)
would work in the other direction was rejected. That's a bit of a shame, as this kind of duality is powerful in languages that support it (e.g. scala).
efaref··on For gifted children, being intelligent can have dark implications (2015)
It does seem eerily similar to Harrison Bergeron.
efaref··on Chart Shows Who Marries CEOs, Doctors, Chefs and Janitors
> Males generally dont marry up?

It's the politically correct way of saying women don't marry down.

Cf. the works of the great poet of our times, K. West.

efaref··on The Sad State of C Strings

  // This code is licensed under CC0.
  // A copy of the license can be obtained at https://creativecommons.org/publicdomain/zero/1.0/
  // May you forever catenate in peace.
  #define strncatm(dest, sz, ...) strncat_multi((dest), (sz), __VA_ARGS__, NULL);
  char* strncat_multi(char *dest, size_t dest_sz, ...) {
    va_list srcs;
    char *dest_end;
    const char *src;
    size_t src_sz;
    size_t dest_off;
    size_t copy_sz;
    va_start(srcs, dest_sz);
    for (dest_end = dest, dest_off = 0; *dest_end && dest_off < dest_sz; dest_end++, dest_sz++);
    for (src = va_arg(srcs, const char *); src && dest_off < dest_sz; src = va_arg(srcs, const char *)) {
      src_sz = strlen(src);
      copy_sz = src_sz < (dest_sz - dest_off) ? src_sz : (dest_sz - dest_off);
      memmove(dest_end, src, copy_sz);
      dest_end += copy_sz;
      dest_off += copy_sz;
      if (dest_off < dest_sz)
      {
        *dest_end = '\0';
      }
    }
    va_end(srcs);
    return dest_end;
  }
efaref··on How Long Can AWS Keep Climbing Its Steep Growth Curve?
Although Amazon, Google and Microsoft are the big players, everyone and their dog are implementing clouds.

There's even an open source cloud: https://www.openstack.org/ This is being used by some large companies (e.g. HP), and can also be used by companies who want to run a VM setup on their own hardware like they probably already do with VMware, but want a cloud-like API for it.

efaref··on “GOTO Considered Harmful” Considered Harmful (1987) [pdf]
"GOTO considered harmful" needs to be read in its historical context, where structured programming (for loops, while loops, functions) were new-fangled and under-used.

Dijsktra was not arguing against GOTO per se, but rather against unstructured programming.

Using GOTO to implement structured programming constructs that did not exist in the language (e.g. JMP in asm) is fine.

efaref··on A house that costs $20k
Indeed. My house is 20 minutes away from the centre of one of the financial capitals of the world. You couldn't buy enough land to build one of those houses on for half a million. You wouldn't get planning permission anyway, and I doubt it meets the local building regulations.
efaref··on Show HN: ION, a JSON alternative – Versatile, compact, fast, binary data format
One thing that I like about CBOR is that with very little knowledge it's surprisingly readable in a hex-dump. Low value positive integers are the value of the byte itself, strings all have the form "0x6L [string]" or "0x7X [len] [string]". Arrays and maps are similarly obvious.

Of course, anything more than a simple construct you're better off using a decoder (e.g. a Wireshark one).

Also, the fact that it's compatible with JSON means that you can use JSON in your development, and then switch to CBOR at the end for the reduction in packet size. In python it's as simple as changing:

    import json as encoder
to

    import cbor as encoder
efaref··on Show HN: ION, a JSON alternative – Versatile, compact, fast, binary data format
I don't really see how ION tables are an improvement over arrays of arrays, e.g.:

    {
      "headers": [ "a", "b", "c" ],
      "rows": [
        [ 1, 2, 3 ],
        [ 4, 5, 6 ],
      ]
    }
Furthermore, ION appears to require you to know the length of your data up front, whereas you could use CBOR unspecified length arrays to stream data from your database without precalculating the table length. It seems like quite a niche format, though. Most data is not truly tabular.

Also, in the table it claims "Yes" under support for "Cyclic references", and yet further down the page:

> ION has support for expressing cyclic references between objects. At this point this support is not 100% finalized.

So surely this should be "Yes(*)"?

← PreviousPage 8 of 12Next →