82% of People Say They Connect to Any Free WiFi That's Available in Public - <AUTHOR> https://decisiondata.org/news/report-82-of-people-say-they-connect-to-any-free-wifi-thats-available-in-a-public-place/ <comment><USER2> I'm one of those 82%. The risk is vastly overblown. If you use apps (for e.g. banking), they're already communicating over encrypted connections, and they're not going to accept unknown certificates. They're completely secure. The Google Play Store and the Apple App Store are completely secure. Your browser is going to warn you about certificates that don't match expectations. You have to go out of your way to fall victim to any MITM attack. The risk from a hostile WiFi is pretty close to zero unless you're the kind of person who blindly clicks on links in email you get, and people like that are unsafe in any environment.

<comment><USER3> You typo an address in your URL bar and an attacker can serve you a fake login page of your intended destination complete with valid SSL cert.

<comment><USER4> Regular users should not be using the URL bar, they should type whatever they want in the search bar.

<comment><USER5> I disagree strongly here. We should be encouraging users to take responsibility and agency for their actions. As admins and tech-aware people in our circles, we should be constantly encouraging better habits like typing URIs manually, decreasing the use of search engines for non-search purposes, and trying to spread literacy.

Besides, it's not like we should ever trust a search engine as an authority on anything but the results that bring the host company more money.

<comment><USER6> Why is typing a URI manually better?

It's undoubtedly less secure and it's upside is...what exactly?

<comment><USER5> Personal responsibility is the main benefit; teaching people to look twice at what they do on the Internet. And frankly speaking, if manual user entry is less secure than software that the user does not own from metal to UI, then we need to upgrade the users, not the Web. Demanding a manual entry means that the user is taking deliberate action, not following whatever some piece of software is telling them to be correct.

<comment><USER6> Personal responsibility, in and of itself, is not usually considered to be a benefit. It is considered a thing one has to undertake to achieve a benefit.

You seem to be suggesting that if I intend to visit mywebsite.com, that typing "myw", seeing "mywebsite.com", and hitting enter is somehow less deliberate than typing "mywebsit.com" and going to a site that was not my intent.

Given that only the first one of these things reflects my intent, describing the second as deliberate and the first as not-deliberate requires some odd twisting of definitions.

Your fear, it seems to be, is that tools we use might influence how we act. This is nothing new. Stories started to rhyme less when we figured out how to write things instead of memorizing them. That was still probably undoubtedly an improvement. So can you perhaps clarify what specific influences that our tools have might be bad? For example, my browser suggesting "mywatertower.com" instead of "mywebsite.com" because the first paid for a higher position.

That seems a reasonable end state to fear, but I have no reason to believe we're heading that direction. Do you? Is inconveniencing (literally) billions of people and forcing them to take less secure paths to do what they want worth avoiding a possibility that certainly doesn't seem imminent?

<comment><USER5> To me, it's definitely worth it to "inconvenience" people and demand conscious behavior. With the largest browser vendor being the largest advertising agency and the largest search engine, encouraging anyone to have anything beyond the barest minimum to do with them goes against everything I believe in. Search engines should not be able to intercede in direct Web activity; they should be used for content discovery and nothing else. You should not be able to type three letters and get a full URL unless you personally wrote a macro to do that.

Then again, when users stopped having to specify protocol for every server, that was probably the beginning of the end of deliberate browsing. My fear is really that people take the Web and the Internet as a whole for granted; and I want to see procedures put in place to demand that all users be aware of their actions, what data they share with servers, and all of what's being downloaded to their computer.

I don't like having to remind people that there is no "Cloud", only someone else's computer. And you're saying you trust that other person's machine and security more than your own by storing critical data there. Or pointing out what having one CDN for so much of the Web did last month.

<comment><USER6> > You should not be able to type three letters and get a full URL unless you > personally wrote a macro to do that.

Should you be unable to drive unless you can, IDK, build an automatic transmission? This point of view reduces, as far as I can tell, to the idea that good user interfaces should only be extended to those privileged with enough expertise to build them themselves.

This requires a level of literacy that most users will never be able to meet, by virtue of most people not having time to learn a programming language since they have other responsibilities.

It's also not clear why you aren't extending this backwards: why is it okay to use a browser I didn't write myself (or at least compile from source)? What about my OS? Do you really expect every user to have full knowledge of their entire system? That puts severe limits on the potential tooling we can use, and goes counter to one of the core ideas of software engineering: abstraction.

> And you're saying you trust that other person's machine and security more > than your own by storing critical data there.

Yes, I trust security teams and engineers whose job is security and reliability more so than I trust myself, in much the same way that I'd trust a surgeon to do surgery better than myself. I realize that there's certification/training differences that may be relevant, but in general, the same ideas apply.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER7> Any security professional who says there's a large _security_ risk when using free wifi has completely lost their marbles.

App stores require apps use https nowadays, and nobody is MITMing https, full stop.

If you want to talk about risks of using public wifi, then privacy should be the topic. DNS queries are not encrypted. Imagine how valuable it would be for a chain like Starbucks to know what websites their customers are looking at while in the store? I don't know if they do that, but it's multiple orders of magnitude more likely than a free wifi access point posing a security risk to end users.

<comment><USER8> > and nobody is MITMing https

Any security professional asserting this doesn't know whereof they speak. There are entire product categories of MITM devices ("TLS inspection") for sale. Another poster mentions nation states doing this openly.

Buy aside from many corporations and some nations states, nobody is doing this, full stop.

<comment><USER9> Corporate TLS Inspection products rely on each user (or the system administrators) installing the MITM certificate on all corporate systems. Unless users are also installing 'public' root certificates, this is a non- issue. And if users _are_ installing bad root certificates, then a fully closed wifi network will not be very good protection either way.

Now, nation states, which may be able to obtain valid PKI certificates for MITM purposes, are a whole other level of adversary. Still, again, anyone who can do that will probably not be deterred by you using a WPA-PSK2 protected Wi-Fi AP.

So, overall, I don't see what kind of increased security risk you would be exposing yourself to by using public wifi networks.

<comment><USER8> OP said "full stop". You don't make a categorical claim like that with a large asterisk when talking about things like this.

"Nobody can open this lock, full stop." "...well, except for nation states, and people who can touch it."

<comment><USER10> The point is, that the user has to do explicit action to allow TLS MITM. You cannot MITM until the user allows that, or uses a device that was already configured to allow that.

</comment></comment></comment></comment></comment><comment><USER11> Why does not having a WiFi password mean that the information must travel unencrypted?

And why is a password enough to encrypt that information, even if said password is written in large letters on a wall for everybody to see?

I'm sure that there are a good technical reasons, but at the same time it seems like there should be a better way to have convenient and safe WiFi networks in public spaces.

<comment><USER12> I think the answer is that public WiFi hotspots don't have any way of verifying that they are who they say they are, whereas TLS works because you have a trusted third party (the CA) that verifies the keypair.

So, if a WiFi hotspot used something like TLS, the data would be encrypted, but you have to way to verify that you're not going through a malicious third party's hotspot on the way to the public WiFi.

<comment><USER13> Ok, but to quote my GP:

> And why is a password enough to encrypt that information, even if said > password is written in large letters on a wall for everybody to see?

</comment></comment></comment><comment><USER14> The best security is the one you don't have to educate people about. Today's HTTPS implementations such as HSTS/Preload, DoT/DoH, etc can thwart most of the dumb attacks easily. In mobile apps, you can even pin a particular certificate and it's pretty much safe from.someone with the network access.

I work on security, and I connect to open wifi networks all the time when I travel. I trust myself to not install random root certs and not ignorant to go past https warnings.

For my own apps, I have HSTS preloaded, proper CSP headers, and don't TLS < 1.2.

</comment><comment><USER15> Networking newbie question: why are "locked-by-password" and "secure" conflated with WiFi?

Is there a technical reason for not having access points that are secure/encrypted _and_ open?

HTTPS is able to do protocol negotiation in the open, then provide a secure channel. Why is there no such thing at the WiFi link layer?!

I found some discussion at [https://security.stackexchange.com/questions/35867/why- isnt-...](https://security.stackexchange.com/questions/35867/why-isnt-open- wifi-encrypted) and [https://security.stackexchange.com/questions/149422/why- isnt...](https://security.stackexchange.com/questions/149422/why-isnt-a- standard-for-encrypted-but-open-wifi-developed) , with wildly varying answers.

</comment><comment><USER16> Random HP printers, Wi-Fi with weird names ... no.

Places of business ... Yeah I guess I do that, and really, I've no idea if that is actually that business's wi-fi.

Granted I run a VPN at nearly all times anyway.

<comment><USER17> Anybody ever abused wireless printers direct wireless modes ?

</comment></comment><comment><USER18> Because the alternative is no wifi. Give me a more secure option, I'd take that. Otherwise, I'm gonna trust TLS does it's job. I know there could be a "heartbleed" zero-day out there, but beats no internet at all.

</comment><comment><USER19> I think the point that some of the naysayers here are missing is that while SSL and a VPN aren't _perfect_ security, they're more than enough for Joe NineToFive. They eliminate the vector of a random person running a honeypot network trying to scoop up low-hanging banking credentials. If you have a knowledgable, perhaps state-level adversary trying to get you in particular, then yes, connecting to random hotspots is probably not a great idea, but you either already knew that or were compromised long ago.

</comment><comment><USER20> Does it actually matter if you use SSL for connections?

<comment><USER21> Ideally, no. If you install their CA certificate, though, all bets are off.

<comment><USER22> I don't think 82% of people regularly install CA certificates from random WiFi.

<comment><USER23> I am inclined to believe alot would, since it's easy to, and many users don't understand the implication of doing so. It's simply the button in the way of getting wifi. It's not that users are dumb, it's that the industry has made this a painful footgun that is easy to trigger.

</comment></comment></comment></comment><comment><USER24> If you use a VPN, it's absolutely safe.

The solution is _to raise more public awareness_ of VPNs, and their benefits.

Also, automating the setup of self-hosted VPNs (like OpenVPN) on a home machine (like a Raspberry Pi plugged into the router) would go a long way. I personally prefer not to use third-party VPN providers, as I don't really know whether I can trust them.

<comment><USER25> A VPN just pushes link-layer security off to someone else. Now instead of trusting your coffee shop, you're trusting your VPN vendor. Why a VPN vendor deserves any more trust than your coffee shop is beyond me.

Trusting the link layer is an unnecessary band-aid. It doesn't need to be trusted, and you should always operate with the assumption that it's not trusted. Only trust end-to-end encryption and authentication.

<comment><USER23> I agree with the first line - with the proviso that there are (IMO) trustworthy third parties that have vetted some VPNs (for example, Mozilla's partnership). I also agree that E2E could resolve a number of issues, but I don't think it's practical or useful advice.

Your second line steps toward security absolutism, since it just pushes out the trust boundary one step further and requires even more technical expertise to be actionable, especially in contrast to using a VPN provider.

The advice to only trust E2E encryption is only useful if you trust both the E2E service provider and the implementation, especially where the service provider owns the only compatible implementations, and the implementation is closed source.

The recent observations that FB could, either willfully, or under coercion, completely undermine their E2E implementation illustrates that, in general, solutions that are user friendly, readily accessible, and operating at scale, are subject to manipulation for economic, law enforcement, or political reasons.

<comment><USER25> If you can't trust the other end of the E2E implementation, there is nothing a VPN can do to get you closer to trusting them. Of course Facebook has all the requests you sent to them. You sent them! Using a VPN doesn't prevent Facebook from misusing the data they collect on you.

Perhaps using a VPN prevents them from logging your IP address. But they still have your username that you logged in with, your phone's device ID, your session cookies (which were created when you were at home on WiFi), your browser's signature, etc. Again, using a VPN isn't going to stop any of that.

The likely outcome of using a VPN is that Facebook's analytics will know exactly who you are, but their global rate limiter will cut off your access because your IP address is now shared with a thousand other people, some of whom are using a VPN to spam them.

</comment></comment></comment></comment><comment><USER26> How much protection do you gain by using a vpn like PIA, nord, etc. with a "kill switch" option turned on ?

</comment><comment><USER27> I find public WiFi without password unhygienic just like the average pub toilet or an internet café Windows XP computer. I might get away fine using them but I always feel a bit dirty afterwards.

Paid for an unlimited 4G plan just to not have to use public WiFi anymore anywhere.

</comment><comment><USER28> i used to run a little gig where the free wifi was the gateway, and the access points were a threesome of 802.11 extenders jacked up with an amplifier and labled as per wifi provider. basically MITM ing the starbucks feed and evesdropping out of prurient curiosity. it was easy and got boring after a while so i stopped. never went beyond snooping, but i could have screwed a lot of people if i was an evil guy.

</comment><comment><USER29> I've a new one... let's ask how many people think the green/ssl bar means it's safe to enter your credit card details into the site?

SSL != trust

<comment><USER30> How many people even know about the bar/lock at all? Most people don't have any idea how it all works.

</comment></comment><comment><USER31> use cloudflare's free vpn, problem solved.

<comment><USER32> Isn't the wait list quite long now for it? I'm still at >200k on the wait list with little movement

<comment><USER33> They haven't opened it up yet because of some changes with the iOS networking side of things. Last update was they were finishing that up over the past/next few weeks.</comment></comment></comment>


Programming Interview Question: Eight Queens - <AUTHOR> http://jetheis.com/blog/2013/12/01/programming-interview-question-eight-queens/ <comment><USER4> One more reason why this is terrible question: many people solved it in the past as part of a programming course, many didn't. If you want to test which school they went to you can look at the resume. If you want to see how they handle writing solvers for simple games/puzzles under pressure of the interview come up with one that is guaranteed (or almost) to be new for the interviewee.

<comment><USER5> This is best comment to tell about the current state of some of the programming interview questions.

</comment></comment><comment><USER6> > I do have to say that as someone who sometimes conducts technical > interviews, I'm not sure I would actually give this question to an > interviewee, unless I was leaving him or her alone to work for a couple of > hours, because of how long it would probably take to reach an answer

It can actually be done fairly quickly if you really only ask for 8x8 instead of a general NxN solver, and the person realizes one key thing: computers have gotten ridiculously fast, so that if you just bang out the first dumb thing that comes to mind, you can probably be done and have the answers before the people with the clever, general, efficient solutions get their solutions coded or even designed.

For instance, this brute force, ridiculously ugly, un-clever, only-works- for-8x8 solution took about 5 minutes or so to write, with half that spent deciding how to number the diagonals and looking at a couple of squares on a chessboard to see how rank/file maps to my diagonal numbering:

       #include <stdio.h>

       int main(void)
       {
           unsigned long pos;

           for (pos = 0; pos <= 077777777; ++pos)
           {
               unsigned long tmppos = pos;
               unsigned long taken = 0;
               int rank;
               int file;

               for (file = 0; file < 8; ++file)
               {
                   unsigned long mask;

                   rank = tmppos & 07;

                   mask = (1L << file) |       /* file */
                           (1L << (rank + 8)) |    /* rank */
                           (1L << (23 + file - rank))  /* diagonal */
                           | (1L << (45 - file - rank)); /* other diagonal */
                   if (taken & mask)
                       goto fail;
                   taken |= mask;
                   tmppos >>= 3;
               }
               printf("%lo\n", pos);
       fail:   ;
           }
           return 0;
       }

It takes under 0.5 seconds on my 2009 Mac Pro when compiled without optimization, and about half that with optimization.

(To be completely honest, I rarely write C nowadays, so although it only took a few minutes to write, the damn thing took half an hour to debug. I wrote "1 <<" instead of "1L <<" because I thought for some reason that int was 64 bit nowadays).

<comment><USER7> Not sure if you're aware of this, but the technique of representing a chess board as a 64-bit bitmap is in fact the method used by pretty much all chess engines these days. These 64-bit unsigned long longs are known as "bitboards".

[https://chessprogramming.wikispaces.com/Bitboards](https://chessprogramming.wikispaces.com/Bitboards)

</comment></comment><comment><USER8> Never had a job where programming chess boards was a requirement. So unless you have one don't ask this. It's not a programming question it's a puzzle.

<comment><USER9> That's the unfortunate part of it. You could have an interesting conversation about strategy. Its an interesting puzzle because the ultimate crude brute force implementation, if my math estimates are correct, is a "couple day" project for a "several hundred" sized parallel cluster, but a slightly smarter algo would be much quicker. There's only 64!/56! possible board configs for 8 pieces ignoring symmetry speedups, and a couple 1E9/second class machines would only take a couple hundred machine*days.

The funniest thing about puzzle interviews as an observer is I can't stop thinking ... "and if he gets the job he's going to spend 12 hour days writing a boring frameworked CRUD app" ... "this poor noob probably thinks real on the job programming is like solving chessboard puzzles all day long LOL".

The unfortunate part about the abstract puzzle fad is almost no one is paid to solve abstract puzzles but no one is tested on real puzzles. "Yes I know quite well traveling salesman is infeasible for 48 states, I'm asking you to solve it for 5 sites because we only have 5 warehouses" etc.

<comment><USER10> Because there is such a straightforward though intractable brute force solution, but several straightforward improvements that can be made on it, I think this is actually a fairly reasonable interview question.

If they can't get the naive brute force solution in a few minutes, that indicates something pretty bad. If they treat it as a permutation question and get the n! brute force answer, that is much better (and is still something that can be done in about the same amount of time. If you treat the problem as numbered permutations then checking for diagonals even becomes non-tedious, making it _easier_ to write out on a whiteboard than the naive brute force solution).

If they get a proper solution in only a few minutes, you know that they either have their act together, or that they have seen the problem before _and remember the solution_. That in itself is a good indicator, though if they get a proper solution right away there should be some follow-up questions to get a handle on how exactly they were able to solve it that quickly.

<comment><USER11> Plus even if they know the solution, that proves practical knowledge of search strategies (having coded at least 1). Even if it only proves you know the naive one, that's good.

Real world problems just aren't practical in interviews, you'll never get to the point where their programming chops are really being tested.

</comment></comment></comment></comment><comment><USER12> I did this in about 20 minutes in Python in an interview.

The trick to solving things fast is to use the structure of the problem to make your problem solving procedure less general. That is, you do premature optimization, except instead of trading readability for runtime speed, your are trading readability for program length.

With real problems, there is a similar tradeoff, so I think this is a useful skill to demonstrate. But it does take practice to find the tradeoff that works best for interview questions, which is not the same as for real life coding.

In my solution, I use mutable state to reduce the amount of code. board is mutated to avoid the boilerplate of copying objects. valid is mutated as a kind of optimization, but the real reason is it makes the program simpler.

      def complete_board(board, l):
        """If possible, completes a board (whose first l rows
        have been filled with 1 queen per row).  Returns
        true if this is possible, false otherwise

        board is a list of ints representing the position
        (0-based) of each queen"""

        N = len(board)

        if l == N:
          return True

        # determine the valid positions for a queen in the r'th row
        valid = [True] * N
        for row, col in enumerate(board[:l]):
          valid[col] = False
          s = l - <USER2>
          if col + s < N:
            valid[col + s] = False
          if col - s >= 0:
            valid[col - s] = False

        for col, v in enumerate(valid):
          if v:
            board[l] = col
            if complete_board(board, l + 1):
              return True
        return False

</comment><comment><USER13> This question seems totally unreasonable for the length of any technical interview I have taken or conducted. Most interviews run under an hour and focus on multiple topics. Its rare you can focus on one question more than 10 minutes. The rule of thumb I use is that if I'm picking a question as an interviewer, I make sure I can answer that question in 1/3 the time I plan to give to the candidate. Given the pressure that they are under, I expect to owe that that much.

<comment><USER14> From the article:

 _I do have to say that as someone who sometimes conducts technical interviews, I 'm not sure I would actually give this question to an interviewee, unless I was leaving him or her alone to work for a couple of hours, because of how long it would probably take to reach an answer._

So it appears they are aware of that problem. I'm of the opinion that some "non-classical" problem is probably a better indication of skill and reasoning. Work through a known problem you had at work (which the candidate is hopefully not too familiar with, otherwise abort and try another), and see how they reason out the problem, then ask for some code that might fix it.

</comment></comment><comment><USER15> I don't think it would be too difficult to find a candidate who could at least talk through or whiteboard out an imperative solution to this. If a candidate couldn't come up with at least an outline of a solution, I probably wouldn't want to hire them.

This particular problem lends itself really well to functional or constraint logic solutions, though (e.g. [http://www.cs.nott.ac.uk/~rxq/files/8nQueenModel.pdf](http://www.cs.nott.ac.uk/~rxq/files/8nQueenModel.pdf)) -- I'd give bonus points to a candidate who could identify that this problem is well suited to one of those toolsets instead of immediately whipping out ruby, python, or js.

<comment><USER4> I'd give bonus points for pointing out some implementation decisions:

-when searching is it better to use copy-make or move/undo approach ? (copy make is faster on modern pc's, at least for things like 8Q's, it's also much easier to implement as you don't need any code for undoing moves)

-what is the best way to check if given move (placing the queen) is valid ? (you need three 0-1 arrays for rows and diagonals in both direction this a neat trick, very difficult to come up with but which speeds the whole thing immensely)

-how do you break out of the recursion if the task is changed to find one solution ?

I know all those things because I am a hobbyist who wrote a lot of solvers and dabbled into chess programming. I am probably in top 0.1% of people if I get question like this. I am incompetent when it comes to things needed in most commercial applications as I've never worked on big commercial projects. This question filters for people like me. I can't imagine how this a good thing for anything practical (unless the task is to produce the best chess program or something).

<comment><USER16> What is copy/make vs move/undo? I'm not familiar with that terminology...

<comment><USER4> When you search you have a choice of:

1)having only one board and make/undo moves on it. So every time you put a new queen on the board you add it to the representation of the board and every time you go back in recursion you need to do an undo before exiting the function (so you new branch won't have queens placed on the board from previous branch)

2)storing as many boards as many steps deep in the recursion you are (max 8 in 8 queens problem) so every time you go deeper into recursion you create new board then you copy current state there and then you make a move (place a queen) on this new board; this way when you go back in recursion you do nothing as this new board is taken care of by stack pointer going back.

The cost of copy make is memory (you need memory for new board representation for every step deeper into recursion) but it's usually not much of a problem. The benefit is that you don't need to code undo logic (which in case of some games is quite complicated) and undo is much faster which usually outweights costs of copying the memory. Some top chess programs are move/undo and some are copy/make, chess board representation usually takes about 200 bytes and variations may go as deep as 100 half moves which means you may need like 20kb additional memory for every thread doing searching. In case of 8 queens it's of course trivial though.

Some more information (for chess, so way more advanced):

[https://chessprogramming.wikispaces.com/Copy- Make](https://chessprogramming.wikispaces.com/Copy-Make)

[https://chessprogramming.wikispaces.com/Make+Move](https://chessprogramming.wikispaces.com/Make+Move)

[https://chessprogramming.wikispaces.com/Unmake+Move](https://chessprogramming.wikispaces.com/Unmake+Move)

<comment><USER16> Is this equivalent to a depth vs breadth first search? Sounds very similar...

</comment></comment></comment></comment></comment><comment><AUTHOR> > I do have to say that as someone who sometimes conducts technical > interviews, I'm not sure I would actually give this question to an > interviewee, unless I was leaving him or her alone to work for a couple of > hours, because of how long it would probably take to reach an answer.

This is a great point that I realized that when I sat down to write up a solution myself. The video-explanation-version of coding it up for the CFI course ended up being 60 minutes long.

Suspect when it does get asked in an interview context they might only want to see some of your problem solving process and algorithm devising, not a full code-up.

</comment><comment><USER17> This programming problem was what actually got me interested in compilers in the first place.

When I was 16 and learning how to program in Java, there was an online competition for high schoolers, and this was one of the introductory programming questions. Your program had to execute in under a time limit (5 seconds, N=13), and I had come up with the best solution I could and was still at 7 seconds. It took me the rest of the month spending hours a day reading on speed optimizations in order to cut down every unnecessary instruction, and remove every intermediate variable. Eventually, the program executed in 4.9 seconds.

While quite interesting, the problem only took an afternoon to implement the algorithm. What differentiated my chops from my competitors was that I could improve my program beyond the first implementation.

</comment><comment><USER18> it is sort of confusing... do you really consider it a hard problem? I am first year maths student at Uni Warsaw and we literally had this problem in the first month, and solution was found by most people in just a few minutes. It sometimes amazes me how people here at HN find some hard for me problems easy and vice versa

<comment><USER19> Frankly i've been programming for a few years i would not be able to solve the problem in 20 mins. Maybe in 3/4 hours but 20 mins no way. I could come with an idea to solve it though.

But that's a very good exercice.

> I am first year maths student at Uni Warsaw

then Math is your major discipline. Please write down how you would express the solution in a pure mathematical form.

<comment><USER18> Yeah that's a cool exercise and I try to do a lot of these!

I guess expressing it mathematically purely is already done in the code of the original solution, because in a way program == proof. If you have some time, here's a great read on this: [http://www.maa.org/sites/default/files/pdf/upload_library/22...](http://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/DonaldKnuth.pdf)

</comment></comment></comment><comment><USER20> > You can see how tricky this can be if you try to do it by hand (unless > you're Emilie, who found a solution in just a few minutes).

I got it on my second try, though maybe I just got lucky.

<comment><USER21> Not lucky - the answer is inferable. Exhaustive search is just the primitive way.

<comment><USER22> Just place them like knights!

</comment></comment></comment><comment><USER23> Back in grad school, I took a configurable computing course where we were to solve the N-Queens problem on an FPGA. My short write-ups are here: [http://people.cs.vt.edu/~scschnei/ece5530/](http://people.cs.vt.edu/~scschnei/ece5530/)

This was a computer engineering course, and I was a computer science student with no background in Verilog or VHDL. I think it took me about 30 hours to get a working solution. However, my solution is very limited, and shows how unfamiliar I was with thinking in hardware terms; other students in the course produced solutions which did not have my limitations, and they did it with much less effort. When I mentioned that to another student in the course, he looked surprised. When I mentioned I was a CS student with no prior experience with FPGAs, Verilog or VHDL, he said, oh, that's pretty good!

</comment><comment><USER24> Here is a solution I wrote when I was an undergrad TA that uses only bit arrays and can check for a valid solution using bitwise logic operations. That said what a horrible interview question. The hard part about the problem is figuring out how to convert a x/y position on the board to a diagonal dx/dy coordinate. Once you figure that out the coding is simple but I remember it taking me a day of mulling over in the back of my head before the solution came to me in my sleep.

[http://therandombit.blogspot.com/2008/09/n-queens- implmented...](http://therandombit.blogspot.com/2008/09/n-queens-implmented- with-bits.html)

</comment><comment><USER25> Everyone seems to forget that there are explicit solutions for the N queens problem.

[http://en.wikipedia.org/wiki/Eight_queens_puzzle#Explicit_so...](http://en.wikipedia.org/wiki/Eight_queens_puzzle#Explicit_solutions)

</comment><comment><USER26> If I got that question, I'd probably spend most of my time worrying about whether or not I should count solutions that are rotations/reflections of other solutions as unique.

</comment><comment><USER27> A quick solution involves starting at a corner, and placing each queen one horizontal and two vertical (a constrained knight's move, basically) away from the previous one. This works for an 8x8 board, but does not generalize to an NxN board (it is easy to see that this won't work when N is divisible by 3). Determining which N's it exactly works for is a math, not a programming puzzle, however. :)

</comment><comment><USER28> If I took this as a "Question to prepare yourself for an interview" and not a "Question you might be asked during an interview" I think it's great.

As prep it's a concise problem you can do on your own time to get your brain working over basic things that you may not have been thinking about lately.

As a question to actually give someone (or receive) during an interview? Seems way to long.

<comment><USER29> I work with someone whose go-to question is the 8 Queens problem. I think it's an interesting exercise, but like you said it's quite long - can easily consume most of the interview. It's also very poorly aligned with the kind of work we do and code we write (for example, I can't think of a single place in our code using recursion) and so I'm not a fan of it as part of an interview.

Edit: typo

<comment><USER30> So, how do the candidates that pass this colleague's interview do in the actual job?

</comment></comment></comment><comment><USER31> This just boils down to populating an 8 element array with all the numbers from 0 - 7, where abs(x[n] - x[m] != abs(n - m))

<comment><USER32> Right! I did that solution in response to a Byte magazine contest years ago. It ran in 20 minutes in Basic on an HP2000.

The tricky part is permuting the array. I used a recursive swap routine, swapping to the right and testing if the array were valid to the left of i then recursing i+1. If it fails you don't have to recurse, you can pop, trimming the search tree drastically. There were 8 or 9 solutions if I remember right, less if you eliminate rotations and mirrors. {edit: 12 solutions}

</comment></comment><comment><USER33> I really don't understand writing a program to solve this problem. Granted I play chess casually but I had a solution before I even finished reading the problem.

I think it's an interesting puzzle, but I don't think that makes it a good interview question.

<comment><USER34> Agreed. Knight's tour is much more of a "programming" sort of chess problem.

</comment></comment><comment><USER35> I love the Haskell version of this because non-deterministic computation via (depth-first) search is embodied by the list monad!

The preliminaries are that we represent a board position containing N queens on an NxN board by a list of row positions in each of N columns.

        newtype Board = Board [Int] deriving ( Eq, Show )
        emptySolution = Board []

Then, given any particular NxN board with M queens in first M columns that is a solution to M-queens, we can generate the list of possible new boards with (M+1) queens. We try all possible row positions for the new column excepting the rows where queens already exist.

        attempts :: Int -> Board -> [Board]
        attempts n (Board queens) =
          map (\r -> Board (r : queens)) ([0 .. n - 1] \\ queens)

And we prune out the ones where the new queen has a diagonal conflict.

        valid :: Board -> Bool
        valid (Board []) = True
        valid (Board (q:cols)) =
          and $ map (\(n, c) -> abs (q - c) /= n) (zip [1..] cols)

          -- this is a bit clever, as we walk back through
          -- the previous columns, if the absolute difference
          -- between the row position of the new queen and
          -- an old queen is ever the count of the column
          -- we're in, then it must be in a diagonal line
          -- from the new queen

All of the above is pretty standard, but the fun part is using the list monad to structure a search. Each bind (<-) in do-notation can be thought of as non- deterministically setting a particular choice from the right side to the name on the left

        queens :: Int -> [Board]
        queens n = search n [emptySolution] where
          search 0 boards = boards -- no more queens to add
          search k boards = do
            board <- search (k - 1) boards -- find a smaller solution
            filter valid (attempts board)  -- try all possible extensions,
                                           -- remove the bad ones

        >>> length (queens 8)
        92

Finally, the pattern of `search` is really common, it's just iterating the generation of attempted solutions. We can write it with the built-in function `Control.Monad.foldM` or another common utility combinator, `iterateM`

        iterateM :: Monad m => (a -> m a) -> a -> [m a]
        iterateM f x = iterate (f =<<) (return x)

        queens n = iterateM (filter valid . attempts n) emptySolution !! n

Finally, it's worth noting that there's nothing special about the list monad's implementation. It's easy to rewrite it without using the typeclass.

        -- this is the list monad definition
        instance Monad [] where
          return a = [a]
          xs >>= f = concat (map f xs)

        iterateList :: (a -> [a]) -> a -> [[a]]
        iterateList f x = iterate (concat . map f) [x]

</comment><comment><USER36> I am very interested in finding out Emily's approach on this.

<comment><USER37> How I'd approach it by hand, demonstrated on a 4x4 grid (other than 1x1, smallest grid with a solution).

I'll go column by column, noting symmetry that also means I only need to check half the rows for the first queen, and with symmetry and the squares she eliminates I'll have fewer options to consider on each subsequent column.

      +---+---+---+---+
      | Q | X | X | X |
      +---+---+---+---+
      |   | X |   |   |
      +---+---+---+---+
      |   |   | X |   |
      +---+---+---+---+
      |   |   |   | X |
      +---+---+---+---+

First queen placed, add the second we only have two options so I'll try the top one.

      +---+---+---+---+
      | Q | X | X | X |
      +---+---+---+---+
      |   | X | X |   |
      +---+---+---+---+
      |   | Q | X | X |
      +---+---+---+---+
      |   |   | X | X |
      +---+---+---+---+

Oops, gotta move the second queen:

      +---+---+---+---+
      | Q | X | X | X |
      +---+---+---+---+
      |   | X | Q | X |
      +---+---+---+---+
      |   |   | X | X |
      +---+---+---+---+
      |   | Q | X | X |
      +---+---+---+---+

Uh oh, can't place the 4th. Moving the first queen since we've exhausted all placements of the 3rd and 2nd queen with the 1st in the upper corner.

      +---+---+---+---+
      |   | X |   |   |
      +---+---+---+---+
      | Q | X | X | X |
      +---+---+---+---+
      |   | X |   |   |
      +---+---+---+---+
      |   |   | X |   |
      +---+---+---+---+

      +---+---+---+---+
      |   | X | Q | X |
      +---+---+---+---+
      | Q | X | X | X |
      +---+---+---+---+
      |   | X | X | Q |
      +---+---+---+---+
      |   | Q | X | X |
      +---+---+---+---+

I placed the remainder at once because there was only one legal placement in each column.

Extending this approach to 8x8 isn't difficult if the challenge is merely to find _a_ solution.

EDIT: I found it in 3 attempts on the 8x8. Going to the column with the most constraints (fewest options) to minimize my branching.

<comment><USER10> How I'd do it by hand:

Each row must have a queen, and each row must have the queen in a different position. Therefore there are 8 rows and we just need to find a correct permutation of them.

Number each row 0 through 7. Generate permutations of these numbers.

To check for diagonal collisions between permutation indices x and y: _abs(perm[x]-perm[y]) == abs(x-y)_

(In other words, if rows 2 and 4 cannot be two places apart, rows 6 and 7 cannot be one place apart.)

Check for diagonal collisions as you're writing out possible valid permutations by hand. Doesn't take long to generate solutions since you don't have to actually draw or mentally picture a board to work out diagonal collisions. You just need to keep 8 single digit numbers in your head.

</comment></comment></comment><comment><USER38> haskell solution:

import Control.Monad

queens n = foldM (\y _ -> [ x : y | x <\- [1..n], safe x y 1]) [] [1..n] safe x [] n = True safe x (c:y) n = and [ x /= c , x /= c + n , x /= c - n , safe x y (n+1)]

main = mapM_ print $ queens 8

\---- [http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscel...](http://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/N-Queens)

<comment><USER39> Your indentation broke:

        import Control.Monad

        queens n = foldM (\y _ -> [ x : y | x <- [1..n], safe x y 1]) [] [1..n]

        safe x [] n = True
        safe x (c:y) n = and [ x /= c, x /= c + n, x /= c - n, safe x y (n+1)]

        main = mapM_ print $ queens 8

<comment><USER32> Hm. And maybe that's why Haskell isn't catching on. That looks little better than terminal scripting languages. Its concise, sure. But maybe that's not as helpful as you might think, in communicating a problem solution.

<comment><USER39> Haskell _is_ catching on. It's extremely popular in academia, and it's growing on e.g. Github: [http://ec2-54-224-80-201.compute-1.amazonaws.com:8888/langua...](http://ec2-54-224-80-201.compute-1.amazonaws.com:8888/languages_visualization/71c6f3773a3cbe2aa440949bc906bd4d/index.html)

But you're right, examples like this are extremely poor marketing for Haskell. It's really not how you'd write most Haskell programs. A lot of the Haskell code on sites like Rosetta Code is deliberately terse to show off.

I changed the indentation a little bit, to make it more clear:

        queens n = foldM
                   (\y _ -> [x:y | x <- [1..n], safe x y 1])
                   []
                   [1..n]

        safe x []    n = True
        safe x (c:y) n = and [ x /= c
                             , x /= c + n
                             , x /= c - <USER3>
                             , safe x y (n+1)
                             ]

        main = mapM_ print $ queens 8

'queens' is essentially a for loop that concatenates the elements between 1..n that are safe, and 'safe' is a function that returns true if it's given an empty list, or if the input satisfies all of the predicates in the other list (notice the recursion that's possible because of laziness.) The function 'and' that it calls takes a list of bools and returns true if all of them are true. 'main' prints each list that results from running 'queens 8'

There is some syntax and convention you have to learn, e.g. what the _ in mapM_ means, what a list comprehension is, or what : means, etc. but once you have it's a fairly elegant solution (compare to the code snippets from imperative languages.)

</comment></comment></comment></comment><comment><USER40> I could solve it AND write it in a readable fashion. Your code is unreadable, you'd fail my test.

What the actual fuck ((if b[r]?[c] then c else -1) for c in [0..n-1]).filter (c) -> c >= 0

I am aware of what the line is doing, I just have no idea what b & c are. Best guess; Board & Column.

</comment><comment><USER41> My brother had created fastest solution ( both in time and space complexity ) for this problem.</comment>


Ask HN: Any other hackers looking to start a startup with me? (or others?) - <AUTHOR>

  I'm sure this thread already exists previously but could not find it. If there is another thread open already I would be open to posting on it as well if someone can reply with it.
     Also, does anyone know any other websites that allow good hackers to meet for startups? (Other than meetup and I am talking more on a national level not just locally).
    A little about myself, I was working at an iBank in NYC and left to start a startup. I am an experienced web developer, did my undergrad in Computer Engineering.
 <comment><USER2> I'm a young geek and passionate application developer. I live in Belarus (well, think it's Russia), but I think location is not so important as skills. I mostly do backends but I'm trying to learn front end development as well.

Unfortunately, I have no experience working at real-world projects, but I want to. I adore Ruby and Rails, love node.js, like Python and Django. Also I love NoSQL databases like MongoDB, I follow best practices when coding and I practice BDD as well.

I'm looking to start a startup with somebody, maybe another backend dev, maybe a frontend dev or designer, maybe both. Personally I have no idea for a startup but I'm comfortable working with somebody with an excellent idea.

firstname.lastname@example.com

<comment><AUTHOR> Cool will do

</comment></comment><comment><USER3> I'm looking for someone to help with the business-y side of things. Posted recently but it was badly timed/uninteresting/drivel and nothing came of it (<http://news.ycombinator.com/item?id=3188364>).

I've got the technical side covered but interested in anyone who can help me get started/further.

UK but amenable to travel.

<comment><USER4> Hey John,

I'm in the UK also and maybe able to help, even if it's just to throw ideas around to help you get to the next level.

I'm helen842000 on gmail.

</comment></comment><comment><USER5> Hey from NY! I'm also in NYC (well just outside)

I have no experience on the technical side of things (aside from basic HTML and CSS and using CMS like Drupal), but have other things to bring to the table. Let me know if you (or anyone else) want to get in touch. My email is in my profile (jfortes16 at gmail).

</comment><comment><USER6> Well done for embarking on the entrepreneurs journey!! Might be useful if you all put your location down too. I'm sure you find many opportunities, folks are always looking for good technical co-founders...

<comment><AUTHOR> I am currently living in Miami, FL

</comment></comment><comment><USER7> Im located in Atlanta, GA. Im a web dev myself. I have been looking for some interesting startups. I've worked in corporate America for 12 years and work part time projects as well. qas1981 at gmail.com

</comment><comment><USER8> Congrats on leaving GS! Happy to connect with a developer looking to build something, have some things I'm working on in my spare time. Shoot me an email if you're interested.

<comment><AUTHOR> Thanks will do

</comment></comment><comment><USER9> I'm a student at the University of Miami. I'd love to chat and see if there is anything I can do to help. My email is in my profile.

</comment><comment><USER10> Might try <http://techcofounder.com>

</comment><comment><USER11> How can I contact you?

</comment><comment><AUTHOR> contact me at rgadala at gmail</comment>


Ask HN what's the deal with linked in ipo? - <AUTHOR>

It looks like the price is 0 when I look up the ticker. Lnkd. It's supposed to debut today thought? <comment><USER2> 53.2 EBITA so at $100 its like 175x. Sweet action!

</comment><comment><USER3> its hovering in the 89 handle right now -- watch cnbc

<comment><AUTHOR> Wow I put in my buy order at 47 last night. I guess it shot past that before they could execute. FML.

<comment><USER3> I'm sure it'll come back. It's at 85 right now. You have access to RT market data?</comment></comment></comment>


Show HN: Visual representation of Hacker News comments - <AUTHOR>

Sometimes I want to make sure I read every comment in a Thread. Also comments that come in later.  For example, when I posted my laptop comparison map I got a ton of great feedback: https://news.ycombinator.com/item?id=8405065 and I wanted to make sure I don't miss any of these. For this purpose, I made this visual representation:
http://social.gnod.com/hn:8405065
I think you can grok what it shows. It simply templates all comments in a recursive way. Read items turn blue. You can mark interesting items and they turn green.
I find it interesting to look at different threads this way. Every one has it's own unique appearance. Here is a very short one for example:
http://social.gnod.com/hn:8710416
I use this bookmarklet to switch between HNs regular view and this visual representation:

    javascript:l=location.href; if (l.indexOf("y")>-1) a=l.replace(/[^0-9]*/,"social.gnod.com/hn:"); else a=l.replace(/[^0-9]*/,"news.ycombinator.com/item?id="); location.href="http://"+a;
 <comment><AUTHOR> Clickable links:

a long thread [http://social.gnod.com/hn:8405065](http://social.gnod.com/hn:8405065)

a short thread [http://social.gnod.com/hn:8710416](http://social.gnod.com/hn:8710416)</comment>


Are Qualcomm Layoffs a Disaster for San Diego---or an Opportunity? - <AUTHOR> http://www.xconomy.com/san-diego/2015/07/27/are-qualcomm-layoffs-a-disaster-for-san-diego-or-an-opportunity/ <comment><USER2> Short term, the engineering job market in San Diego will be terrible as the laid off engineers flood the market. Hopefully some of these engineers will start their own small companies and this is where it gets interesting...

There has been a dearth of small electronics technology company creation in San Diego since the start of the 2008 recession. Part of me says that this is about to change, but global competition, regulations, and barriers to entry may put a damper on it.

It's very hard to start a hardware company these days. There are lots of capital-intensive requirements such as adhering to safety, toxicity, and emissions regulations and performing the necessary testing to gain certification. These tests and reports can run in to the tens of thousands of dollars, and they have to be re-done several times as a product evolves.

I suppose this is why software-only companies have been popular recently. They are not subject to the same requirements as hardware companies. This may change in the future as more things are controlled by software, and the process becomes subject to regulation.

Please note that I am not against regulation to protect consumers and customers, I'm only concerned about the financial burden it presents to newly formed companies. The regulations are necessary and required, but the costs are a real barrier to entry.</comment>


Google open sources "Contracts for Java" - <AUTHOR> http://google-opensource.blogspot.com/2011/02/contracts-for-java.html

<comment><USER2> This is very similar to JML!

I co-wrote a paper on the subject a couple years ago during my undergraduate, which I humbly share with you :)

A Case Study in JML-Assisted Software Development [http://portal.acm.org/citation.cfm?id=1556581&preflayout...](http://portal.acm.org/citation.cfm?id=1556581&preflayout=flat)

Download: [http://cic.puj.edu.co/wiki/lib/exe/fetch.php?media=grupos:av...](http://cic.puj.edu.co/wiki/lib/exe/fetch.php?media=grupos:avispa:papers:cbg_09.pdf)

<comment><USER2> (thinking out loud: wouldn't be cool if someone at Google contacts me? I'd love to work for them :)

</comment></comment><comment><USER3> Very cool stuff. I wonder if there is any way to integrate something like KeYmeara (<http://symbolaris.com/info/KeYmaera.html>) for a way to prove correctness of Java systems (or components of Java systems).

<comment><AUTHOR> I did not know about KeYmeara. Looks great!

While I'm not sure if we may count those as "programmation by contract", some Java tools provide (some) static analysis:

\- Findbugs

\- IntelliJ IDEA does some nullness analysis : <http://www.jetbrains.com/idea/documentation/howto.html>

\- JSR 305 (Annotations for Software Defect Detection in Java) attempted to standardize on a set of annotations. We use it in our project, mainly the @Nonnull at the moment... I believe Findbugs considers these annotations.

\- CodePro Analytix, also recently open sourced by Google, might also do some static analysis: <http://code.google.com/javadevtools/codepro/doc/index.html>

\- Eclipse might too (any expert Eclipse user knows?)

I think there is still a lot to do in this space. "Contracts for Java" is a step in the right direction :)

<comment><USER4> Eclipse does not do static analysis by default I believe. There are some patches however...

<comment><USER5> The out-of-the-box Eclipse distro does include some static analysis stuff, but it's turned off by default. Preferences->Java->Compiler->Errors/Warnings. Under "Potential Programming Problems", you can alert on such things as guaranteed NPEs, etc.

</comment></comment></comment></comment><comment><USER6> Not having any experience with contracts like this, I wonder how this relates to testing. Is this thought to be an addition or an alternative to usual xUnit style and integration tests. Or are these concepts not even related and I am getting it all wrong?

<comment><USER7> This contracts refer to the concept of "Design by Contract."

<http://en.wikipedia.org/wiki/Design_by_contract>

The poster child of design by contract is the Eiffel Programming language.

<http://www.eiffel.com/developers/design_by_contract.html>

IMO Contracts help you te really reduce the number of unit test you need to write.

And the tests that you DO write are more intersting in the BDD kind of way.

I highly recommend to study design by contract. Is one of those things that will make you a better developer in any language you use.

A good book with examples in Java and Eiffel is this: Design by Contract, by Example [http://www.amazon.com/Design-Contract-Example-Richard- Mitche...](http://www.amazon.com/Design-Contract-Example-Richard- Mitchell/dp/0201634600)

</comment></comment><comment><USER5> I have read a bit about Crystal SAF, a static analysis framework for Eclipse from CMU:

<http://code.google.com/p/crystalsaf/>

What appealed to me was that it seemed to have a nice API against which one can write his own analyses. It exposes Java code at a granularity of control flow -- homogenization of for loops, while loops, etc. FindBugs works really well, and I use it on a reasonably large production codebase. However, extending it doesn't seem like much fun as one must express patterns in terms of Java bytecode! I tried using Crystal's built-in analyses on the same codebase upon which I use FindBugs, but it failed with an NPE.

Also, Soot from McGill (<http://www.sable.mcgill.ca/soot/>) seems worthy of consideration although the code is a bit creaky (it's dates back to at least 98, I think). It includes four different representations of Java code in various states between source code and byte code. Also, there are a lot of papers, theses, etc. which document various parts of the package.

</comment><comment><USER5> In general, why has static analysis not been more popular? When I first ran FindBugs on a 50 KLOC codebase I inherited, it identified several real, non- trivial bugs which likely hurt many users. Perhaps the average Java developer's skill level is too low to make sense of these tools' results? But, one would think that most teams have at least one "adult" who would love more visibility into a codebase.

</comment><comment><USER8> Microsoft has a similar project for .NET <http://research.microsoft.com/en- us/projects/contracts/> . Based on a quick look I think Microsoft's project is a bit more mature (already has VS-intergration for example).

<comment><USER9> There was also an older project known as Spec# at <http://research.microsoft.com/en-us/projects/specsharp/>

</comment></comment><comment><USER10> Looks interesting, but why isn't there a .jar to download or a maven reference to use this project? Moreover, there is no documentation explaining how to activate/disactivate contracts... Sorry, but it seems like half-ass delivery to me !!!

<comment><AUTHOR> It's still quite new, so for now I think you'll have to build it from source.

I know it's annoying when a jar is not available in the Maven repository. But it shouldn't be a dealbreaker either.

We have a Maven repository proxy for the company, so I deploy my jars there:

      mvn deploy:deploy-file ...

It's better than having each developer manually install the jar in their local repository:

      mvn install:install-file ...

More information:

[http://maven.apache.org/plugins/maven-deploy- plugin/usage.ht...](http://maven.apache.org/plugins/maven-deploy- plugin/usage.html)

[http://maven.apache.org/plugins/maven-install- plugin/example...](http://maven.apache.org/plugins/maven-install- plugin/examples/specific-local-repo.html)

<comment><USER11> Yeah, sorry but you have to build it from source, for now. There is no point in making a release now as there are a few bugs that need correcting before that.

But thanks for the feedback, I've added a README file now with proper dependency information and set up instructions. The build scripts are certainly quite shacky, I must admit; it was originally integrated into Google's internal build system but now that all of that has been stripped out (including the documentation), it looks kinda non-functioning.

I could certainly use some help in making that build and run smoothly in the outer Java world, since I'm not a Java programmer originally and my experience setting up Ant, Maven and the like is very very limited.

P.S.: It may be Google-branded but we're still just a small team. The other guys are taking care of the within-Google integration part so I should be working on the open source integration except I'm not very knowledgeable in the Java ecosystem, nor have I ever released any open source project with that level of visibility, so please be patient.

</comment></comment></comment><comment><USER12> A good thing to have - better than the "assert" keyword in Java.

</comment><comment><USER13> In the sorted parameters example contract, would it not be as good to pass an new object whose constructor ensures the sorting?

</comment><comment><USER14> Great to see, although it's really too bad that they didn't introduce this as part of the language when they developed it.

<comment><USER15> Live and learn, eh?

</comment></comment><comment><USER16> The next step for this would be to statically verify the annotations are being obeyed.

<comment><USER17> That sounds (close to) impossible. How would you tell if a given piece of code sorts a list properly? There are a million and one sorting algorithms and the static analyzer would have to be really smart to be able to check that reliably.

<comment><USER18> Yes, it is impossible. See: Halting problem.

<comment><USER19> The thing about program verification is that everyone knows that of course it is in general impossible. However, I am not writing a simulator. Most of the code I write does not actually take advantage of the power of a Turing machine.

The fact that the general problem is impossible does not mean that the entire area of study is useless.

<comment><USER20> see: dependent typing <http://en.wikipedia.org/wiki/Dependent_type>

and restricted languages such as Spark <http://en.wikipedia.org/wiki/SPARK_(programming_language)>

</comment></comment></comment></comment></comment><comment><USER21> Hmm, other java contract projects more mature for a few years even and fully in production..

Why Google even pushed this out in such an alpha state?

<comment><AUTHOR> You are not the only one arguing about the project's lack of maturity and the existence of better, more mature alternatives (which ones?).

I can understand this sentiment, and I'd love to be able to add a Maven dependency on this project and start using it on production code tomorrow (well, monday actually).

But I am also glad Google followed the "ship early, ship often" mantra . Better alternatives may or may not exist, but I'm pretty sure I had never heard of them before, and never really cared for "contract programming" until now. I knew about JSR 305 and used the @Nonnull annotation when it made sense, but that's about it (I guess doing this already puts me ahead of 80% of Java programmers in this regard...).

Some might say that it's sad people waited for a Google-branded project to be interested in this subject. I choose to view it as an opportunity for the field as a whole. The interesting discussions it sparked (here and on other websites) are worth it by themselves. Some developers might even compare options and start using one of the "better alternatives" you hint about.

The project may be young, but it seems to generate a lot of interest, and I'm sure many people will contribute and improve it.

<comment><USER11> Alternatives include: JML, C4J, Contract4J, JASS, and Modern Jass. The most popular and well-known solution is probably JML.

I'd like to mention though that Cofoja itself is not so "new", in a sense; it is a rewrite of Modern Jass, which itself was a rewrite of JASS. Though the code may be mostly new, we've borrowed many concepts, ideas, and implementation techniques from our predecessors, and hopefully learnt a bit from their experience.

One could then ask "why pick Modern Jass as a basis while there are other more <whatever> framework available?" but that's another question.

Links: C4J. <http://c4j.sourceforge.net/> Contrac4J. <http://www.contract4j.org/> Java with Assertions (JASS). <http://csd.informatik.uni-oldenburg.de/~jass/> Java Modeling Language (JML). <http://www.jmlspecs.org/> Modern Jass. <http://modernjass.sourceforge.net/>

And if you're interested in the fine details of the internal differences between Cofoja and other frameworks, you may want to read my technical report: <http://cofoja.googlecode.com/files/cofoja-20110112.pdf>

<comment><AUTHOR> Thanks for these links. Sounds like there are indeed alternatives, but they were considered before creating Cofoja.

I noticed in your report that you studied at Ensimag. That's funny: I almost went there! (I added it to my list of choices of Grandes Écoles, but finally opted for a generalist engineering school)</comment></comment></comment></comment>


Federal judge tosses Apple patent lawsuit against Motorola - <AUTHOR> http://news.cnet.com/8301-13579_3-57545283-37/federal-judge-tosses-apple-patent-lawsuit-against-motorola/ <comment><USER2> For reference: Apple is willing to pay a maximum of $1 for patents that make their device a functioning phone. Two years ago, they offered Samsung to license some of their less important patents for $30 per phone and $40 per tablet.

<comment><USER3> It's not obvious that "essential" patents are more important. 3G and Wi-Fi are commodity technologies while iOS is less so.

<comment><USER4> A phone without something like multi-touch is more useful than one without 3G/WiFi (or am I missing something in what you're saying)?

</comment></comment></comment><comment><USER5> I was wondering the same thing a couple of days ago. The iPhone5 hasn't got the buzz previous releases had, and the iPad mini seems to be less and later than comparable android 7" tablets. Apple is also putting increasing energy into patent lawsuits, which is another sign of a company resting on it's laurels. And of course they've lost Jobs.

Having said that, although I think it likely that Apple has peaked, I wouldn't short it just yet. I had the same opinion about Microsoft ten years ago during the years bewtween XP and Vista. Linux was surging ahead, Windows was going nowhere, lawsuits started flying and Bill Gates stepped down. Actually, now I commit this to text, the comparison is spookily similar!

But my point is that it took about 8 years before there was any effect on their share price. My experience is that what seems obvious to us now takes years to filter through to market sentiment. So if you're going to short Apple, do it 10 years out (if that's possible).

<comment><USER6> Tim Cook may be no Steve Jobs but he's no Steve Ballmer either...

(Though on the other hand as cash cows go the iPhone and iPad are no Windows and Office).

That said I think the whole Jobs thing is overstated at this point. It's not as if they didn't misstep with Jobs at the helm, and it's not as if they've been turning out bad products since he went (not to mention that everything "post-Jobs" they've done so far was in the pipeline while he was still in charge and would have had his blessing).

<comment><USER7> Agreed.

Cook is not the second largest shareholder of Apple stock and does not have a thirty year working relationship with the largest shareholder.

Thus, unlike Ballmer, Cook serves at the pleasure of Wall Street.

<comment><USER6> While being beholden to Wall Street is a double edged sword, you need to be a special sort of person to really work without being answerable to anyone in the way Jobs and Gates did.

I think Ballmer shows that for lesser mortals, some responsibility is a good thing.

<comment><USER7> The suggestion that Jobs was not answerable to Wall Street is false. Successful share price growth kept Wall Street from asking a lot of questions for a long time. Had there been less success, history might have repeated itself.

Even had he lived, Wall Street would have gotten the dividends they demanded. This in no way makes his success less impressive, but it is perhaps foolish to mythologize it.

</comment></comment></comment></comment></comment><comment><USER8> Is it time to short AAPL? They've lost some value recently, and the growth proposition doesn't seem to be where it has been. I could see them stay where they are, even with an earnings miss or two, however they are very much a stock traded on public perception.

<comment><USER9> Their P/E ratio is just 13.26, while Microsoft's is 16.05 and Google is 21.38. While P/E is just one simplistic measure, it does seem to indicate that their stock price already assumes lower future earnings relative to other mature tech companies.

<comment><USER10> Or it indicates that they are a hardware company, which is to say their ability to grow (or sustain) their business depends on any number of factors, not the least being political stability and conditions in China. Factors over which they can exert very little control.

</comment></comment></comment><comment><USER11> So where does this leave FTC who have been looking to accuse Google of the same thing? Do they need to start looking for other "crimes" to accuse Google of anti-trust now?

<comment><USER12> Relax. There are PLENTY of legal problems for Google.

You have the FRAND investigation in US, EU, SK. The countless lawsuits over Google News. The recent finding in Australia of defamation against Google because of their search results. How that plays out in the future will be interesting. The privacy violations over DNT and major concerns/lawsuits over the cross-product privacy policy in EU, Canada and elsewhere.

Then I expect there to be a wave of lawsuits over Google's intelligent search results e.g. flights, tickets, offers, shopping which are very similar to Microsoft's "embrace and extend" approach.

Seems like everyone misses the "do no evil" Google.

<comment><USER13> Google was never "do no evil", only "don't be evil" which is very different.

</comment></comment></comment><comment><USER14> So, this wasn't a trial about Apple using patents against Motorola. It was Apple filing suit against Motorola's use of patents against it.

Basically, when a standard is created the standard will likely use patented technology. Think about H.264. It isn't free. However, it is open (anyone is allowed to create hardware and software using the standard, so long as they pay the fee). Also, that fee is the same for everyone. These terms are FRAND (fair, reasonable, and non-discriminatory). It's essential for standards to ensure competition.

Then there are things that aren't standards. I'm not saying that you should agree with patents or anything like that, but they do exist and this distinction is made. If you hate patents (and I'm not saying you shouldn't), then they're all bad and we should get rid of them all. Disclaimer aside, let's say that you patented having 3 buttons on a phone (home, back, menu) ala some Android phones. There are many other ways to implement that functionality. Maybe that's the best combination of buttons and users love it. However, even in the Android world, we see phones with on-screen keys and no buttons, ones with 4 buttons, etc. You could even do something cool like a touch area with swipe left for back, touch for home, and swipe right for menu. Nothing there would kill your ability to create a device worthy of people spending money on. Taking a real-world example, let's look at Apple's bounce- back function for over-scrolling. Android 4 now does a highlight on over- scroll rather than the bounce-back. While a user might say, "the bounce-back looks better", it doesn't prevent a party from creating a device worthy of users' money.

Now, if you can't send signals using the technology that cell sites use, that does prevent one from making a device worthy of users' money. Those patents are standards essential. Now, when groups set standards, they will work around the patents of any company that doesn't want to license their patents under FRAND terms. However, companies want standards to use their technology because while they might not be able to extort money, they're guaranteed that everyone will use it. There's a big distinction between things you have to license and things you can implement differently with a little creativity and, as such, we treat them differently.

In the Apple/Motorola case here, Motorola (along with others like Nokia, Ericsson, Siemens, others) helped develop the wireless standards. They have to license their patents under FRAND terms. However, many of them want Apple to pay more per device than competitors. Part of this is that Apple has sucked up most of the profit in the industry and they want it back. Before Apple, Nokia was doing pretty well. Now? Motorola had been sliding for a bit, but Apple certainly helped that along by creating much better devices than pre-Android Motorolas.

Basically, there are patents that you're required to use and since you're required to use them (you can't build a phone without them), they have to be licensed under fair, reasonable, and non-discriminatory terms. The FTC looks like they will recommend that the government file suit against Google/Motorola over what the FTC sees as Motorola abusing these standards essential patents against Apple and Microsoft ([http://www.bloomberg.com/news/2012-11-01/ftc- staff-said-to-f...](http://www.bloomberg.com/news/2012-11-01/ftc-staff-said- to-formally-recommend-google-patent-suit.html)).

So, this isn't a suit about Apple pushing UI patents against Motorola that got tossed here. This was Apple trying to get Motorola to license their technology under FRAND terms.

It seems that the disagreement is over the percentage model that Motorola wants. Motorola wants 2.25% of the full retail price of the device. So, if you make a dumbphone for $35, you pay 79cents. If you make a 16GB iPhone 5, you pay $14.63. Somewhat ridiculously, if you make a 64GB iPhone 5, you'd pay $19.13. Apple seems to be arguing that FRAND means that you can't discriminate like that. Motorola, still losing money, wants a large portion of those profits while still being able to profit off of cheaper devices. One can make the argument that the percentage model is non-discriminatory, but it doesn't fly well by me. Non-discriminatory isn't with respect to the price of the device or the money you're making off of it.

<comment><USER15> First of all, I think it might be good if the FTC sue Motorola to explicitly nail down how FRAND patents can be used.

Secondly, I'm happy to see Motorola (Google) going after Apple and Microsoft with these patents. They are the two greatest perpetrators of unreasonable software patent abuse and they also both helped shape the system as it currently exists.

To be clear: If Motorola were going after other companies, I would have a problem with that type of behavior. Apple and Microsoft, however, deserve every kind of patent abuse they are getting (and then some).

<comment><USER16> > To be clear: If Motorola were going after other companies, I would have a > problem with that type of behavior. Apple and Microsoft, however, deserve > every kind of patent abuse they are getting (and then some).

This isn't patent abuse at all. The patents in question involve sophisticated, complex technologies (Wi-Fi and video compression). It's not the type of thing you accidentally stumble upon--these were technologies created by a consortium, including Motorola, at substantial cost. Licensing the underlying patents, and litigating if those patents are infringed, is how the members of the consortium recoup those costs. The situation presents the classical case of applicability for patents--you want the technology to be openly disseminated, so it can be used as a standard, but don't want people to be able to use it without paying.

As much as people kvetch about standards patents, they're an example of the patent system working well. You have an industry consortium (of specialists in a specific area) which develops complicated technology then standardizes it for everyone to use. Companies who want to be compatible with the standard then license the patents underlying the technology. The patents are just the legal glue that facilitate that transaction. Patent litigation is the mechanism by which the terms of that transaction are enforced--just like litigation is always the mechanism by which the terms of transactions are enforced.

<comment><USER17> I agree with this - A similar example of patents working in a reasonable manner is the pharmaceutical industry, where the time and money investment of developing a new drug is astronomical, and it can be reasonably argued that this justifies the 20-year monopoly that a patent entails.

The above cannot be said for design patents. Because there are essentially no barriers to entry in getting a design patent, yet they last the same 20 years as the development of a new drug, it's easy to see this getting stupid and destructive for the tech industry.

</comment></comment></comment></comment><comment><USER18> Can we just agree to always link to the FOSS Patents blog for all these stories in the future? Florian Mueller is always the very first one to report on these and does a much better job at analysis. Here on HN, we should actively replace upvoted articles with the primary source when it is clearly the better source of information.

<http://news.ycombinator.com/item?id=4745820>

<comment><USER19> I actually agree on the point about linking to primary sources, but having said that Florian Mueller is a proven shill and his analysis should never be trusted at face value by anyone, particularly when he's analyzing anything to do with Google.

<comment><USER18> I never claimed he was unbiased just like no one would claim that Gruber is unbiased. But having posts from source like CNET that just water down the original source make it to the front page adds absolutely nothing of value.

Imagine if every John Gruber article worthy of making it to the front-page only ever made it to the front page after being laundered by a site like CNET? I think everyone can agree that we would be worse off without the original voices.

One of the biggest losses of not having original voices, even from the most biased of biased bloggers, is that it also dilutes the counter-arguments of those on HN that provide the balance to biased articles. For example, a direct link to Florian Meuller's article may elicit a response from a contributor like yourself where you point out where Florian's analysis may be wrong and shouldn't be trusted. Without Florian's post to rebut, it's more likely that people like yourself would remain silent on the issue.

<comment><USER20> Perhaps we should just agree to link to Groklaw instead of a paid shill? [Who doesn't always admit his backers?]

<comment><USER18> I definitely like groklaw above the rest. Did he post on this issue as well?

<comment><USER20> She, Pamela Jones [aka PJ], has posted far more reasoned, and unbiased [by money] posts on Motorola Vs Apple.

<http://www.groklaw.net/article.php?story=20121105153442192> and <http://www.groklaw.net/article.php?story=2012110322254380>

are just the latest on throwing this FRAND case out.

</comment></comment></comment></comment></comment></comment><comment><USER21> for every one of these lawsuits i wish there were 10 more. we seriously need to get the patent courts so backed up that it should take 17 years to get your case in front of a judge and the same amount of time to secure a patent on an idea.</comment>