Hacker Newsnew | past | comments | ask | show | jobs | submit | more lambda's commentslogin

That seems like a really bad example of pattern matching, as no pattern matching is going on; it's just using the guard statements, and so could be replaced with an if statement:

    let computed_key = if key.len() > self.block_size {
        self.zero_pad(self.hash(key).digest)
    } else if key.len() < self.block_size {
        self.zero_pad(key)
    } else {
        key
    }


So the last statement in a block for a matched if condition gets assigned to the variable? That's pretty cool.


Any language that emphasizes expressions over statements will have this feature. Off the top of my head, that should include Haskell, Scala, CoffeeScript, Ruby, Elixir, Clojure (hell, anything Lisp really)...

The idea is that while you may be able to traverse code-paths with side effects in some of these languages, they encourage treating a line of code (term used loosely, as an expression can span multiple lines) as a computable value. It may take a bit of getting used to at first, but from my own experience, it now feels weird and awkward when a language doesn't.

Reminds me of looking at a nasty language like MUMPS or something, where persistence is built into the core language; statement-oriented languages tend not to be composable.


By leaving off the semicolon, you can make a block (which is anything in braces) evaluate to the value of its final expression. It's one of those rules that seems perfectly terrible at first blush, but actually seems to work really well in practice thanks to Rust's strong static typing.


Remember, there is a difference between not auditing access to their internal fileservers that they keep their PowerPoints on, and not auditing access to their wiretap data.

Now, a big concern is that even if they do audit access to the wiretap data, there are still too many people who have "legitimate" access to it, and it is still hard to prevent a rogue sysadmin or programmer from bypassing those controls. Merely having all of that data makes it a high value target for attack.


> Remember, there is a difference between not auditing access to their internal fileservers that they keep their PowerPoints on, and not auditing access to their wiretap data.

This will clearly be NSA's response -- whether it's true or not -- but Snowden didn't just take random PowerPoints and internal training docs. If I'm not mistaken, he also took copies of FISA court documents and other highly classified materials that were never intended to be shared among NSA staff.

I truly believe the lack of audits for these materials has destroyed NSA's credibility across the board:

1. We know that NSA hires/contracts incredibly smart and technically talented individuals who are experts at breaking into systems and avoiding detection.

2. The only way for NSA to provide reasonable controls in this environment is to create a culture of monitoring and accountability, and design all their systems from the ground up with auditing and security in mind.

3. But apparently they didn't do #2 (or never figured out how to enforce this for sysadmins), because Snowden repeatedly accessed restricted and highly classified material without an audit trail.

I don't see how they can credibly admit a Snowden sized failure but still ask us to trust them with our personal data.


Those PowerPoints are classified! Why would you think it's ok not to audit access?


They are changing the encoder in such a way that the resulting PNG does not decode exactly, but instead approximates the original image. This turns it into a lossy process. It doesn't really matter if this process happens before or after the PNG encoding step (in fact, from how they describe it, it sounds like it it is integrated into the PNG encoding process, not simply a pre-processor); the combined process of any filtering and PNG encoding is lossy, as in it does not preserve all information necessary to produce a bit-identical output.


The socat version I posted https://news.ycombinator.com/item?id=6224060 fixes this problem, but is a bit more cumbersome.


socat version; no loop, as it forks a separate process for each connection:

    socat TCP-LISTEN:8080,fork,crnl SYSTEM:'printf \"HTTP/1.1 200 OK\\n\\n\"\; cat test.html'
The extra quoting you need to do the the SYSTEM argument makes this rather cumbersome. socat is a powerful tool, but can sometimes be a pain to use.

Here's one use I found for it recently, when I wanted to do some experimentation with multicast:

    socat - UDP-DATAGRAM:239.255.1.1:4242,ip-add-membership=239.255.1.1:10.0.0.10,ip-multicast-loop=0,bind=:4242
This causes socat to bind to the multicast group 239.255.1.1 on the interface that has the unicast IP 10.0.0.10, sending and receiving on port 4242 over UDP, reading from stdin and writing to stdout. It basically gives you a simple chat service over the local network.


You get a similar interface in Python's Twisted using the @inlineCallbacks decorator:

    @inlineCallbacks
    def example():
        try:
            obtain_some_lock()
            ui_status("Fetching file...")
            result = yield fetch_file_from_server(args)
            ui_status("Uploading file...")
            yield post_file_to_other_server(result)
            ui_status("Done.")
        except SomeError as e:
            ui_status("Error: %s" % e.msg)
        finally:
            release_some_lock()
I must say that this style of writing async code is much friendlier than descending into callback hell.

There is work to make a similar async interface native in Python 3, in PEP 3156 http://www.python.org/dev/peps/pep-3156/, so this should become more widely available even to those who don't use Twisted.


Tornado has a similar interface:

    class GenAsyncHandler(RequestHandler):
        @gen.coroutine
        def get(self):
            http_client = AsyncHTTPClient()
            response = yield http_client.fetch("http://example.com")
            do_something_with_response(response)
            self.render("template.html")
(via http://www.tornadoweb.org/en/stable/gen.html ..)


Obligatory mention of gevent[1].

It handles all the plumbing for you with monkey-patching I/O calls. No annotations necessary, you just write linear code.

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


Yes! I really hope this use of yield will bubble up to the language spec and become pervasive in Python. It really strikes me as the Pythonic approach to solving callback hell.


> Yes! I really hope this use of yield will bubble up to the language spec and become pervasive in Python.

And the time machine spaketh: http://www.python.org/dev/peps/pep-3156/#coroutines-and-the-...

(it has no reason to "bubble up to the language spec", the language provides all the right primitives — especially with Python 3's `yield from`, it's up to the libraries to use them. That is a Good Thing.)


Good point. Bubble up to the standard library, then.


That's very cool, thanks for sharing.


There have been many variations of these basic ideas for a while.

Hyperloop is different in that it does not require a full vacuum, but just a low-pressure atmosphere, which make the tubes much cheaper to build an maintain. It also does not require magnetic levitation along the full length of the tube (like the Chinese proposal uses), as it uses an air cushion provided by that a compressor that sucks in that low-pressure atmosphere, further reducing the cost of building the tube. It merely uses occasional magnetic linear motors spaced out along the route to accelerate and decelerate the pod, spending most of its time coasting on its air cushion.

So, while it does share design features with many previously proposed systems, it is not exactly the same as what has been proposed before. There's a good reason why people have been talking about evacuated tube transport for centuries but no one has actually achieved it on a practical scale; the hope is that the low-pressure design will be much cheaper than the evacuated tube design.

Now, I am somewhat skeptical of the incredibly low numbers that Elon Musk quotes, especially relative to the much more well understood high-speed rail he's comparing it to. But you shouldn't dismiss it just because there are some superficial similarities to previously proposed systems; as far as I know (and I haven't done much research, so I could be wrong), this is the first such system that proposes using low pressure, a compressor on the front of the pod to deal with the problem of the air mass not being able to flow around it, and an air cushion to support the pod taking advantage of the air taken in by the compressor.


Why do you think this would need to be viable to use on a daily basis to be viable? There are probably enough people who need to have a meeting once a week or once a month in another city, or who want to visit for a weekend, or who want to get to a medical specialist in the other location, to make it work out.


It's one thing to not be able to write code as fast as you can type. It's another to use a speech to text input method that's designed for long-form prose and try to use it to code. Can you imagine the frustration of trying to enter longCamelCaseVariableNames without a special macro to do so? I don't know the usual commands in Dragon, but I imagine it would be something like: "long delete space uppercase camel delete space uppercase case delete space upper case variable delete space uppercase names", possibly with a few false starts and undos in there as it interprets some of your words as commands rather than code.

To experience something like it, try using your phone keyboard, with word prediction on, to write code. It will be slow, and frustrating, and have a lot of false starts.

There's a big difference between "not the fastest way to enter text" and "so slow it's unusable", and the impression I get is that without extensive macros like this, most speech to text systems are so slow as to be unusable for writing code.


That's kinda the point of this article. He's got a bunch of macros and idiosyncratic commands.

At 11:30 in the video:

"Camel this is a test" -> thisIsATest "Studly this is a test" -> ThisIsATest "Jive this is a test" -> "this-is-a-test" "Dot word this is a test" -> "this.is.a.test" "Score this is a test" -> "this_is_a_test" "Mara" -> selects all text on screen "Chik" -> delete

He says he'll release his code in a few months.


Yes, that was my point. I watched the video, and picked the camel case example from it.

I was replying to someone who said that input speed is not the main bottleneck in coding, hence implying that it's not all that useful to do things to improve input speed. While I concede that input speed is not the primary bottleneck, my point is that without macros like this to speed it up, voice input would be way too slow to do anything useful.


... the video is itself a few months old.


I frequently have times when I'm doing things like "writing articles on what's stopping me from coding" and the like. But for me, when I'm on, I'm ON, and in those periods, being able to put code together reliably and quickly is of utmost importance.

Even with the macros and shortcuts he shows, I still would be slower using a system like that. When I'm typing in a good editor, I can blast out code VERY quickly, and when I've typed it, I KNOW it's what I meant. When he says it, he has to stop and look to ensure the code matches what he said.

Yes, he can say a phrase like "camel someVariableName" quickly, and sometimes it Just Works, but when it doesn't, he has to back up and say it again. That kind of distraction can throw me off my train of thought, and the damage to my productivity would be profound.

That said, it still IS great for anyone with an RSI as an alternate way to enter code. I just don't buy the "it could be better even for people who don't need it" argument. Especially with his claim that I would need to abandon my modern editor with awesome language support for one of those relics that relies on CTAGS.


...Did you watch the video?


I do think that there is a substantial difference in how interesting it is to use a fast motorized vehicle as an aerodynamic shield, vs. using your competitors (and teammates) in a peleton. The first feels like "cheating" in a sense, as bicycling is supposed to take advantage only of human power, while the second adds a fascinating strategic dimension to racing.

That said, I do think the original video has merit. Yes, cycling in the aerodynamic wake of a car is substantially different than cycling entirely under your own power, but it is still a neat thing to try and see how far you can push it.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: