Ultimate Tic Tac Toe - <AUTHOR> http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/ <comment><USER2> I think the Orwin gambit can be extended to win the game every time.

\- Force opponent to fill center miniboard, as he describes.

\- Force opponent to fill (e.g.) northeast corner in the same way. Opponent now has taken two miniboards, and you have none, but you are one turn away from taking each of the remaining seven.

\- Pick SW corner of SW corner. You have taken SW corner miniboard. Opponent is forced to play in same SW miniboard, already won by you.

\- Pick SW corner of S. You have taken S miniboard. Opponent is forced to play in SW corner again, already won by you.

\- Pick SW corner of SE corner. You have taken SE corner miniboard.

\- Done. You win.

Like regular tictactoe, there is an advantage to going first. Unlike regular tictactoe, the advantage can't be compensated for. Otoh, the second player can use the same strategy with a little more carefulness, as long as they start early.

So either player can force the other into a protracted certain loss, unless there's an agreement or a rule against it. That's no fun.

EDIT: actually, you can win every time, in far fewer moves, and not using the Orwin gambit at all. It's not necessary to force your opponent to _fill_ any of the miniboards, not even the center.

I think this will win in ten moves and never lose driver control (excuse the notation): C/C, C/SW, C/S, [opponent takes C], C/SE, NE/SW, NE/S, NE/SE, [opponent takes NE], SW/SW [you take SW], SW/S [you take S], SW/SE [you take SE, and win]. A variation can be used by either player early in the game, but whoever starts with control would be foolish to lose it.

If this is a game played by mathematicians, either I'm wrong, or there are additional rules. :)

EDIT2: C/C (first move above) is unnecessary. Nine moves. Perfect inning.

<comment><USER3> Here's an implementation that pretty much does exactly that. If someone can beat this bot, lemme know: [https://www.khanacademy.org/cs/in-tic-tac-toe- ception-perfec...](https://www.khanacademy.org/cs/in-tic-tac-toe-ception- perfect/1681243068)

And here's James Irwin's original implementation, auto-set to a Monte-Carlo AI and with a rules variation that (to my knowledge) prevents Perfect Bot from winning. Play with the config variables at the top for some other AIs and 2-player games and whatnot. [https://www.khanacademy.org/cs/in-tic-tac-toe- ception/167633...](https://www.khanacademy.org/cs/in-tic-tac-toe- ception/1676336506)

<comment><USER4> Does the AI always have to make the first move?

<comment><USER3> For Perfect Bot's strategy to work, yeah, but the environment is very open to configuration. Set xIsComputer to false and yIsComputer to "monte" for a fun challenge in which you go first.

</comment></comment></comment></comment><comment><USER5> My favorite "mathematician game" is Sprouts: [http://nrich.maths.org/2413](http://nrich.maths.org/2413)

First heard about it in a column in Scientific American by A. K. Dewdney. The rules are simple and it is rather fun. In one of his columns he talked about playing a toroidal version where a line going off one edge of a rectangular page comes back in on the opposite side.

<comment><USER6> My Dad, a physicist, taught me that game as a kid. I have great memories of him producing a pen at any restaurant we might have been at, and he and I passing any waiting time playing sprouts on napkins or paper scraps. I since play it with my kids.

<comment><USER5> Did you ever learn about the variant called 'Brussels Sprouts' and the trick to winning?

<comment><USER7> Please explain :)

<comment><USER5> If I remember correctly, instead of only allowing three edges to emanate from a vertex, you can have four. All other rules are the same. Apparently, in that set up, the the first player either always wins or loses depending upon whether the number of initial vertices is odd.

</comment></comment></comment></comment></comment><comment><USER8> My daughters play a variant of tic-tac-toe with a physical board and just three stones each.

I brute-forced this with a little lunchbreak program and the visualisation output from graphviz was ... 340 MEGAPIXELS!

I blogged about it: [http://williamedwardscoder.tumblr.com/post/35858593837/tic-t...](http://williamedwardscoder.tumblr.com/post/35858593837/tic- tac-toe)

<comment><USER9> That's how we used to play as kids, there's an algorithm so that the first mover always wins.

</comment></comment><comment><USER10> A weird version of tic-tac-toe my friends and I came up with years ago: you play without a board. Any move is valid so long as you could superimpose a standard tic-tac-toe grid over the results. (You assume the marks are at the center of their respective squares; you allow the board to be at any scale or angle, but you can't skew it.)

The first two moves have no constraint, so you can just start with an X and O already on the board. And after a few moves there might be only one implied board possible, after which it reduces to the normal game. But I always thought it was an interesting twist.

<comment><USER11> Somebody posted another tic tac toe variant on HN some time ago, where the squares were numbered 1-9 and the goal was to get any three squares that summed to 15. It turns out this is equivalent to playing tic tac toe with sides that wrap around (like a torus).

<comment><USER12> No, that's 100% equivalent to tic tac toe ([http://en.wikipedia.org/wiki/Tic- tac-toe#Variations](http://en.wikipedia.org/wiki/Tic-tac-toe#Variations))

(To see why no torus version exists: on a '3x3' torus, all squares are identical, so you have must four ways to get three in a row from each starting number. Also, the row/column/diagonal sum must be 15. However, starting with 9, there are only two ways to get 15 with: 1 and 5 and 2 and 4)

The variant with nine words, where selecting three words that share a letter wins the game, IMO is even better.

<comment><USER11> I may have misremembered the details of the game, or conflated it with another game.

What I remember clearly is that the game was equivalent of tic tac toe on a torus -- one could win with a "diagonal" of the form

.|x|.

x|.|.

.|.|x

as well as any of the traditional tic tac toe win conditions.

<comment><USER12> Tic tac toe on toruses is fairly popular as an educational toy, and there also is serious research on it, for example [http://www.ux1.eiu.edu/~kwolcott/TTT.pdf](http://www.ux1.eiu.edu/~kwolcott/TTT.pdf). You might have mixed the 'on a torus' part with the 'using a magic square' part. No problem, but the two do not mix that way (maybe, on larger boards? That 4x4 Dürer square ([http://mathworld.wolfram.com/DuerersMagicSquare.html](http://mathworld.wolfram.com/DuerersMagicSquare.html)) has zillions of 'add up to 34' sets of cells. There may be even better ones of larger size)

</comment></comment></comment></comment></comment><comment><USER13> There is another great variant of Tic Tac Toe you can play on a Torus (a donut shape): [http://upload.wikimedia.org/wikipedia/commons/1/17/Torus.png](http://upload.wikimedia.org/wikipedia/commons/1/17/Torus.png)

The way to play is to "warp" each side of the board to the side opposite of it. For instance, playing on a 6x6 board with a win condition of length 5:

        .|X|.|.|.|.
        X|.|.|.|.|.
        .|O|.|.|.|.
        .|O|.|.|X|.
        .|.|O|X|.|.
        .|.|X|O|.|.

is a win for X, because the upper and lower ends of the board are synonymous.

I can't find any material about this on the net, I just played it in school on boring lessons (but more commonly we played for 5 in a row on an infinite board, I personally prefer the Torus)

</comment><comment><USER14> > Whichever square he picks, that's the board you must play in next.

And what about the dual of this game, where whichever board you pick determines the square he plays next?

</comment><comment><USER15> Does anyone else play the 'infinite board' tic-tac-toe which requires you to get five in a row? It's what I used to play as a student, and it's pretty well-known at least where I live. Nobody bothers with the 3x3 version, but the five in a row version is pretty exciting and requires plenty of strategy and thinking ahead.

<comment><USER16> I think this is called "Gomoku" (just on a quasi-infinite board): [http://en.wikipedia.org/wiki/Gomoku](http://en.wikipedia.org/wiki/Gomoku) I used to play this a lot when I was still at the university

<comment><USER17> Yup, Gomoku is a much more difficult game than it looks. Indeed, the game is challenging enough that there is a world championship every odd year. You can find the games from the last world championship here: [http://renju.net/media/games.php?gameid=45016](http://renju.net/media/games.php?gameid=45016)

I am amazed by the fact that Gomoku can be so hard to master with rules so simple you can explain to a five year old. And unlike Chess where there are a hundred year of theories to learn from before you can get going, Gomoku is still new. After a few weeks studying the standard surewin openings, you can expect to see things in a very different light and the game will get much more interesting.

Perhaps Gomoku is best known for programmers as a problem to solve. But it is nowhere near being solved. In fact, the best software are weaker than many top players.

I find Gomoku hits the sweet spot when it comes to my desire to play board games. It doesn't consume much of my time. I am always excited to find those long and obscure wins. I think the game needs more love from programmers like me.

Facebook page: [https://www.facebook.com/GomokuWorld](https://www.facebook.com/GomokuWorld) Play here: [http://www.playok.com/en/gomoku/](http://www.playok.com/en/gomoku/) Or here: [http://fumind.com](http://fumind.com)

<comment><USER18> Gomoku has already been solved actually, maybe you were thinking of Go? There's a revised version called Connect6 though, in case you are interested.

[https://en.wikipedia.org/wiki/Connect6](https://en.wikipedia.org/wiki/Connect6)

<comment><USER17> Under free opening rules, Gomoku has been proved to be sure-win for black, aka the first player. This work done by Victor Allis could be part of the reason why Gomoku is undeservedly treated as a toy board game.

We have to remember, however, that this proof is computer search based. There was never an algorithm to find the best move given a random position. In other words, it only proves that these certain openings will guarantee black a win.

Those who loved the game came up with new opening rules. The world championships in 1989 and 1991 used the pro rule. After some evolutions, swap2 now became the standard. Under Gomoku swap2, the first player puts two black stones and one white stone on the board, and the second player can either pick one color, or puts two more stones and gives back the power to choose color to the first player.

I know about Connect6, and also a branch called Renju. But I find Gomoku more attractive. You should totally try it sometimes.

</comment></comment></comment></comment></comment><comment><USER19> Neat variant. I made something similar for the last ludum dare: [http://madelfino.github.io/LD26/postcompo.html](http://madelfino.github.io/LD26/postcompo.html)

<comment><USER20> Nice! Managed to beat it, but it wasn't easy: [http://dl.dropbox.com/u/1127246/Screenshots/5ths.png](http://dl.dropbox.com/u/1127246/Screenshots/5ths.png)

</comment></comment><comment><USER21> When my dad was at university he made just out of curiosity a AI to play Tic Tac Toe that started knowing nothing about the game, and tried to learn from playing against the player, until it became impossible to beat it.

Later someone complained with university administrators that my dad was "playing games" in the computer lab, and he got banned from it :/

But I guess this version might be even more interesting to make a AI test or something!

<comment><USER22> The only winning move is not to play

</comment></comment><comment><USER23> I don't understand the clarifying rule #2: "What if my opponent sends me to a board that's full?" Isn't that impossible, as there is a maximum of 9 ways to be sent to each local area?

<comment><USER24> I think you can get sent to a full board only if the game started on that board.

<comment><USER25> Of course, there's a cascading effect where it's now possible to also overflow the board you chose with your free move.

</comment></comment></comment><comment><USER26> Another quick implementation of this game: [http://joeyrobert.org/projects/ultimatetictactoe/](http://joeyrobert.org/projects/ultimatetictactoe/)

</comment><comment><USER27> Perhaps the game is less deterministic if you can choose any board as soon as the board is won - not when it is filled. Then, you can only force 3 moves before you have to give up control. Then approaches like the Orwin gambit would not work (it is too costly to lose a board if it only lets you choose three spots.)

</comment><comment><USER28> [http://xkcd.com/832/](http://xkcd.com/832/)

Randall Munroe could do a "small" update to this based on these rules... although it would take some time.

<comment><USER29> A "small" update? I think this is more like the difference between checkers and chess. But yes, relevant xkcd

<comment><USER30> > I think this is more like the difference between checkers and chess

I'm not sure what you mean by this?

BTW are you aware that despite it has only one type of stone and simpler rules, checkers is in fact the more complex game, to write an AI for?

<comment><USER31> I guess you refer to International checkers (being from the Netherlands). Still a challenge for computers, given that the brute-force solution for American checkers doesn't work well for this larger board.

Much harder to program an AI for than chess, certainly. The computer never managed to beat the world champion in a match last year.

<comment><USER30> Cool, I didn't know there were multiple versions of checkers. I'll have to check (hah) out that solution for the American version though, always interesting (as well as what the differences in rules are). Off to Wikipedia, I guess ;-)

</comment></comment></comment></comment></comment><comment><USER32> This is brilliant! Has anybody created an online version of this?

<comment><USER33> I can bet you there will be now

<comment><USER34> It doesn't observe a win and for now you have to play against yourself, but:

[http://xoxo.gl/ultimate](http://xoxo.gl/ultimate)

</comment></comment></comment><comment><USER35> Important question, can this game be solved, like ordinary tic-tac-toe. Is there a solution that always leads to draw of defeat.

<comment><USER36> Zermelo's theorem[1] says "yes," although I don't know which it is (between draw, p1 win, p1 lose).

[1] [https://en.wikipedia.org/wiki/Zermelo%27s_theorem_%28game_th...](https://en.wikipedia.org/wiki/Zermelo%27s_theorem_%28game_theory%29)

<comment><USER37> In fact, it can't be a p1 lose, because the extra piece p1 gets can never be a disadvantage (you can prove this more carefully). The question is then is it a p1 win, or draw?

A similar situation arises in the game 'hex', except in that game there is no draw, so it has to be a p1 win!

<comment><USER12> _" because the extra piece p1 gets can never be a disadvantage (you can prove this more carefully)"_

Please do so, as I do not see that this is trivially true. I see two tricky cases:

\- your opponent must play on the board where p1 is placed, and that board would have room iff p1 weren't present => Addition of p1 gives him a 'move anywhere' move.

\- you must play on the board where p1 is placed, and that board would have room iff p1 weren't present. The normal argument 'move anywhere and assume that that 'anywhere' is where your first move went, and you just played p1' does not help here, as changing the first move may change where your opponent's first move could have gone.

Except from an exhaustive search, I do not see how to prove that you can prevent either case.

<comment><USER37> Yes, you are right.

Actually, the fact you force your opponent isn't the problem (I don't think) but the fact that the presence of that piece might later give p2 a free move, where previously they wouldn't means it doesn't work.

Sorry, that's what I get for thinking I didn't need to figure out all the details carefully!

</comment></comment></comment></comment></comment><comment><USER38> The one I play with my friends is usually a 4-in-a-row, 4 level board. You can win on any individual level, or by creating a straight line of 4 that intersects plays on each level (so playing in the top right of each level would net you a win, for instance). It forces the players to keep a three dimensional model in their head and opens up the board for more counters/strategy.

Anyone care for a game?

        level 1    level 2    level 3    level 4
        .|.|.|.    .|.|.|.    .|.|.|.    .|.|.|.
        .|.|.|.    .|.|.|.    .|.|.|.    .|.|.|.
        .|.|.|.    .|.|.|.    .|.|.|.    .|.|.|.
        .|.|.|.    .|.|.|.    .|.|.|.    .|.|.|.

</comment><comment><USER34> I made a quick HTML demo for playing through the game at [http://xoxo.gl/ultimate](http://xoxo.gl/ultimate)

<comment><USER39> Now add an AI :)

<comment><USER34> You think so? I'm not very keen to work on an AI if there's proof of a quick win.

</comment></comment></comment><comment><USER40> We made this into an Android application about a year ago: [http://superttt.com](http://superttt.com)

</comment><comment><USER41> I recall seeing this before, called "crazy" tic tac toe:

[http://tictactoe-cssi.appspot.com/](http://tictactoe-cssi.appspot.com/) via: [http://neil.fraser.name/news/2011/07/16/](http://neil.fraser.name/news/2011/07/16/)

<comment><USER42> The first of these doesn't follow the same rules as OP. It seems that you can retake a board if you get a new row in a box that has already been won.

</comment></comment><comment><USER43> I haven't tested all the cases but this method seems to win every time I've tested it against myself:

Start on an edge-center container [N,E,S,W], marking it with it's corresponding sub-board space. Employ the Orwin gambit to fill the initial edge container. When your opponent selects the last space in the first container, wherever you are sent: pick it's corresponding sub-board space and then employ the Orwin gambit again and then repeat the routine until the game is finished. Your opponent gets to pick your next moves but because they eventually must send you to a filled square on the second and third rounds, you have the ability to control the game's end.

Starting in the center gives you a tactical disadvantage because it only leaves you 4 paths to victory compared to your opponents 8 with him/her in a position affecting 4 lines, whereas by starting on a side piece, you have 7 paths to victory and your opponents position only benefits him on 2 lines.

</comment><comment><USER44> My team and I have implemented what you call Ultimate Tic Tac Toe as what we call Tic Tac Toe Ten. We put it out for iOS, Android, Windows Phone and have made board game sets to go into school districts with starting in 2008. If any of you in this community are interested in helping us to build out the backend analytics infrastructure to help us make the academic breakdown of this game useful for teachers and students please visit our community at [https://www.facebook.com/tictactoeten](https://www.facebook.com/tictactoeten) and drop me a message or DM us on Twitter (@tictactoeten) ... we are also always looking for volunteers at our school tournaments where we pit kids against each other March Madness style with brackets and give out prizes to the winners ... we are here in the Bay Area, hope to meet some of you guys soon :)

cheers, @bware218

</comment><comment><USER45> I created a version of this game back in 2008, for the 3 major mobile platforms and PC:

PC: [http://www.tictactoeten.com/play](http://www.tictactoeten.com/play)

iOS: [https://itunes.apple.com/us/app/tic-tac-toe- ten/id317168510?...](https://itunes.apple.com/us/app/tic-tac-toe- ten/id317168510?mt=8)

Android: [https://play.google.com/store/apps/details?id=com.livelovele...](https://play.google.com/store/apps/details?id=com.livelovelearn.tictactoeten&hl=en)

Windows Phone: [http://www.windowsphone.com/en- us/store/app/tictactoe10/d84e...](http://www.windowsphone.com/en- us/store/app/tictactoe10/d84eac98-7a6f-e011-81d2-78e7d1fa76f8)

</comment><comment><USER46> What if you played it where the square selected is the direction you move to go to the next board. If the player selects the center square on a board, that board must be played again. If the player selects the left square, the board to the left must be played next. If a corner square is picked, you play the board to that diagonal direction.

If the corner is not attached to a board, you roll the board around as though the ends are connected (or as though it's an infinitely repeating tiling of the same game). For example, the bottom right square on the bottom right board makes the next board the top left.

The center-right square on the center-right board would result in the next board being the center-left board, and so on.

Would there be a gambit in this ruleset?

edit: So, it looks like the same gambit applies, instead of selecting the center piece you just pick the one pointing toward the center every time.

</comment><comment><USER47> [http://graffitiwall.co.uk/ultimatetictactoe](http://graffitiwall.co.uk/ultimatetictactoe)

My quick implementation of this game

Edit: For anyone who arrived 10 seconds after i posted that link, The board resembled the ultimate tic tac toe, and then quickly degraded into a paint fight

<comment><USER21> Interesting that hackers instead of working or reading HN are very interested in fighting over the board (ie: gray color people try to erase it, pink color try to draw a board, and blue color trying to play the game...)

<comment><USER48> "Someone keeps stealing my letters" [http://www.lunchtimers.com/](http://www.lunchtimers.com/)

</comment></comment></comment><comment><USER49> There's a way to prevent the Orlin gambit. Allow the player with the last three in row to take another turn.

This creates a means of alternating who goes first.

I'm not sure whether this gives too much advantage to the other player or not.

<comment><USER50> It does. He can now force _you_ to now place pointless moves in the center square.

</comment></comment><comment><USER51> My friends used to play something similar with connect 4. You don't expect to meet people who are good at connect 4, but these two guys beat me 100% of the time...

</comment><comment><USER52> Reminds me a bit of [http://en.wikipedia.org/wiki/Fire_and_Ice_%28board_game%29](http://en.wikipedia.org/wiki/Fire_and_Ice_%28board_game%29) / [http://www.boardgamegeek.com/boardgame/4643/fire-and- ice](http://www.boardgamegeek.com/boardgame/4643/fire-and-ice) \- look at the board.

</comment><comment><USER53> Can anyone else hear the quiet roar of a thousand not-so-silent fans as they struggle to dissipate heat caused by furious Xcode and RubyMotion compilations?

</comment><comment><USER54> Another interesting way to play tic-tac-toe that makes it a lot harder:

There is a bag of numbers 1-9. Players take turns moving numbers from the central bag to their own private bags, removing that number from play. Whenever a player has a subset of exactly 3 numbers that sums to 15, they win.

This is isomorphic to tic-tac-toe since the magic square for a 3x3 board has rows/columns/diagonals that sum to 15.

</comment><comment><USER55> It happened a while back, when Bobby Kehres told my colleague and I about the game. [https://github.com/1337/Tic-Tac-Toe- Extreme](https://github.com/1337/Tic-Tac-Toe-Extreme)

</comment><comment><USER56> I made this a while back. It a HTML5 game made with construct2. [http://jenpop.com/game.php?gurl=games/uttt](http://jenpop.com/game.php?gurl=games/uttt)

<comment><USER57> Your game is just Tic-Tac-Toe on a 6x6 board. It is not the same game as the Ultimate Tic-Tac-Toe described in the article.

</comment></comment><comment><USER58> My favorite Mathematics game is: [http://en.wikipedia.org/wiki/Connect_Six](http://en.wikipedia.org/wiki/Connect_Six)

Mathematically fair

</comment><comment><USER59> Kid-tested. The 7-year-old loves it. Thank you for saving me from plain-old Tic Tac Toe games with my kid.

</comment><comment><USER60> What happens to the game if you switch order when you take a board?

</comment><comment><USER61> Someone needs to write a JavaScript implementation of this!</comment>


If you could unilaterally establish any rule at your startup/company...? - <AUTHOR>

What would you choose? <comment><USER2> I would establish the rule that any unilaterally established rules should be ignored.

<comment><USER3> Ah, but would that rule be unilaterally established? Because then it would break itself.

</comment></comment><comment><USER4> Require _brevity_ in documentation, E-mails, policies, etc. Then employees think for themselves, ask questions, and avoid a lot of BS. :)

</comment><comment><AUTHOR> I'd make each instance of copypasta in code require board-level approval in writing. :)

</comment><comment><USER5> No tabs, 2 space indent.</comment>


Diesel cars can be banned from German cities, court rules - <AUTHOR> https://www.reuters.com/article/us-germany-emissions/german-court-backs-city-bans-on-diesel-cars-idUSKCN1GA2XD <comment><USER2> As a German who never owned a car (have driver license 30+ years) and never will, hurray!

Next: Petrol cars please.

Costs for cities would decrease a lot [1], room for bicycles would increase, noise would drop to a level which can't believed, ambulances would be adjusted to walking persons instead of loud cars with their stereos on and air would be wonderful.

[1] [https://www.amazon.de/High-Cost-Free- Parking/dp/193236496X](https://www.amazon.de/High-Cost-Free- Parking/dp/193236496X)

<comment><USER3> And the German economy would crash, but never mind that. Before you ban all petrol cars you will first need something that can replace them because not everybody is in a position to use public transport both due to capacity, speed and door-to-door elements.

<comment><USER2> Economy will crash in the next 5 years either way with mass replacement of people by AI (call centers, taxi drivers, truck drivers, ...).

Edit: Plus German car industry will crash either way because most people work not in building cars, but motors, electronics, transmission etc. which are mostly redundant with electric cars.

<comment><USER4> Just like it did during the industrial revolution with mass replacement of people by machines.

<comment><USER5> Quite a few Luddites starved during those times.

</comment></comment></comment></comment></comment><comment><USER6> It's important to note that popularity of diesel is the doing of the German government. The fuel is subsidized for the sake of the environment because it's more efficient. [https://www.google.com/amp/s/amp.ft.com/content/eb8be120-de5...](https://www.google.com/amp/s/amp.ft.com/content/eb8be120-de5f-11e7-a8a4-0a1e63a52f9c)

The situation is similar to Germany's work on its electric power sources. Nuclear was turned off because it's dangerous. Now Germany spews out about same carbon as before giant investments in solar, electricity is four times the price as in US, plus they now have to buy from France cause they don't produce enough.

[https://www.google.com/amp/s/www.forbes.com/sites/jamesconca...](https://www.google.com/amp/s/www.forbes.com/sites/jamesconca/2017/10/10/why- arent-renewables-decreasing-germanys-carbon-emissions/amp/)

<comment><USER7> Sorry, but some of your statements are only partially correct. In fact germany exports more energy than it imports. ([https://www.ise.fraunhofer.de/en/press- media/news/2016/germa...](https://www.ise.fraunhofer.de/en/press- media/news/2016/germanys-electricity-exports-surplus-brings-record-revenue-of- over-two-billion-euros.html)) Also the popularity of diesel might have other factors as well.

<comment><USER6> Perhaps my view of German energy industry is not detailed, but what are the advantages of diesel engines in cars if not efficiency?

Cold starts can be hard, they smell, make a funny sound, slow to accelerate. Maybe maintenance is easier when there are no spark plugs.

<comment><USER8> > slow to accelerate

Have you driven a modern diesel? At lower speeds, they easily beat similar- displacement petrol cars off the line with superior torque. They are weaker at high speeds, but in normal (especially city) driving, a diesel is usually faster than a petrol.

But yeah, their main factor for popularity is the cost per km. They use less fuel than petrol engines, and the fuel is less expensive (in Germany). This is offset by higher road tax and insurance somewhat, but for commuters and others who drive a lot (>~20000km per year) diesels are a much more cost effective option in Germany than anything else.

<comment><USER9> Diesel isn't that cost efficient actually, even if you drive a lot. Diesel are more expensive to maintain due to regulations, plus diesel cars tend to be more expensive their petrol counterparts. Moreover, there is depreciation, which tend to be worse for diesel cars, because they are valued less on the second hand market (fairly or unfairly).

On average, you should expect to drive at least 150.000+ km before you've broken even on a diesel car with its petrol counterpart.

People only look at fuel consumption and fuel prices, but maintenance and depreciation are actually one's biggest loss on a car purchase. And in general petrol comes out on top.

<comment><USER10> The premium of diesel engines over petrol is one of the key reasons that we don't get many in the USA (the other issue being emissions). Bob Lutz, former GM CEO, was a big proponent of diesel but repeatedly acknowledged that it doesn't make sense in the USA. The market for people willing to pay the $5,000 premium (in 2007 dollars, mind you) was very small. Americans don't appreciate just how cheap cars in their region are.

GM did manage to get a diesel Cruze into the USDM market, and keep it here, but it's low-margin and not a huge seller. A manual diesel Cruze starts at about $25,000 (compared to $17,000 for the base). So it is basically slotted as an "enthusiast" model, just not a high-performance one like Ford and Honda would offer.

</comment></comment></comment></comment></comment></comment><comment><USER11> European law has been very tilted towards Diesel engines for a long time. As the recent VW debacle proved - oversight was quite lax compared to the US diesel regs. This laxness was the result of the influence of BMW, Mercedes and VW and the outcome of years of corporate lobbying. It's a good first step, but they have further to go.

Despite the rhetoric, Germany has also been very restrictive with Tesla, viewing it as a challenge to its crown jewel automotive companies (no credits, no additional supercharger stations, much harsher reading of laws to protect their own industries).

You know that Germany will be serious when that changes.... (or the German car companies will have finally caught up to Tesla's battery power and power train)...

<comment><USER3> A big part of the problem here is the the EU was focusing on CO2 rather than NOx and that diesels are actually really good in the CO2 department.

<comment><USER12> Fun fact: NOx emmisions actually help to counter global warming, as they break down methane particles, which is one of the worst greenhouse gases.

</comment></comment></comment><comment><USER13> Partially related: "Fiat Chrysler is reportedly ditching diesel cars by 2022" ([https://www.theverge.com/2018/2/26/17053362/fiat-chrysler- di...](https://www.theverge.com/2018/2/26/17053362/fiat-chrysler-diesel-car- end-production-2022)). Diesel sales are collapsing all over Europe, I think one of the latest reports puts the number of new Diesel cars sold in France at just under 50%, while they used to be at 75% four or five years ago. The writing is on the wall.

</comment><comment><USER14> I am so confused by government policy here in the UK. Right now I'm looking at a 5 year old used Diesel car with £0 road tax and 70+ MPG for about 10k GBP.

My current Petrol engine costs £130/annum road tax, and only gets 30-40 MPG, I can also buy petrol cars with road tax of £240-500/annum (based on emissions)

But if I buy the Diesel, it could be banned or worthless in a few years, because of these types of policies. So what is the government telling me to purchase?

I can't buy an electric car because I only have on street parking so there's nowhere to charge it, and decent electric cars aren't really available at the 10k mark yet.

<comment><USER15> I could be wrong, but I would guess that your quandary isn't to do with the policy as such, but the way it's been gamed by car manufacturers. That diesel would likely have a much higher road tax if its actual emissions were taken in to account, and not just the lab-based ones.

Get a petrol car pay the tax would be my recommendation. Depends on what you need too. My 5-year-old petrol Fiesta was <£10k and is £0 road tax.

<comment><USER10> > That diesel would likely have a much higher road tax if its actual emissions > were taken in to account, and not just the lab-based ones.

Is NOx a consideration for road taxes? If not, that's the issue. Diesels do emit less CO2 than gasoline and AFAIK, no auto companies were "cheating" CO2 emissions, just NOx.

<comment><USER15> Good point, I was wrong. The road tax policy should be updated to take NOx levels in to account. The recommendation remains :)

</comment></comment></comment></comment><comment><USER16> Eastern Europe will be flooded with those cars now. [http://www.dw.com/en/germanys-dirty-diesel-cars-en-route- for...](http://www.dw.com/en/germanys-dirty-diesel-cars-en-route-for-eastern- europe/a-40224565)

<comment><USER17> The EU comission threatened to fine Germany for the air pollution caused by these cars. I expect they'd treat other EU countries the same.

<comment><USER18> Already happening:

> The EU's top court ruled that Poland has persistently breached European > standards on air pollution, which causes nearly 50,000 deaths in the country > each year.

[https://www.ft.com/content/b1d8794a-17d8-11e8-9e9c-25c814761...](https://www.ft.com/content/b1d8794a-17d8-11e8-9e9c-25c814761640)

<comment><USER19> It's not caused by old cars (for the most part), but rather by people burning cheap coal in inefficient furnaces to keep warm during winter (see "energy poverty").

</comment></comment></comment></comment><comment><USER20> Note that this ruling is only to clarify that cities are allowed to implement car bans on their own without a federal directive in place.

Now we will have to wait and see if the cities will actually be sued into having to implement such bans.

<comment><USER21> >Now we will have to wait and see if the cities will actually be sued into having to implement such bans.

They already have been forced to implement such bans by the lower court. The cities appealed, but as decided today were unsuccessful in doing so.

<comment><USER20> Well, some have.

</comment></comment></comment><comment><USER22> The backstory here: EU law mandates doing something to reduce pollution if it's too high. German law prohibits various kinds of discrimination. For example, a simple ban on half the cars on Monday and the other on Tuesday would bother large plumber companies much less than independent plumbers who need a carful of tools and have only one car. What actions are the cities permitted to take, and/or required.

<comment><USER21> >EU law mandates doing something to reduce pollution if it's too high

And it mandates that for around 15 years now.

One of the cities (Stuttgart) has been exceeding the pollution limits for at least 8 years now.

It's quite strange that it took so long to finally force the city to do something effective.

<comment><USER23> > (Stuttgart) has been exceeding the pollution limits

Funnily enough multiple car factories are based here.

<comment><USER24> True, Stuttgart as the biggest cluster of German car manufacturing has been the epicentre of the German pollution-debate (that was based around particulate matter, not NOX).

The Diesel has become somehow the victim of this (sadly, since as mentioned by other commenters here, Diesel cars have their advantages).

The reason Stuttgart is Germany's pollution capital has almost nothing to do with the Diesel but:

\- its topography, being a city almost completely surrounded by hills, thus unusually hot and windless for a German city

\- the upper class areas on the hillside/slopes are the main polluters with houses dating from ca 1900 and/or re-equipped with pellet heating systems that were subsidized because of energy footprint while being even worse pollution- wise than even older heaters

Both of these points are validated by the fact, that it's not the weekends when the pollution calms but its the winters when there is almost a daily pollution warning - its when the rich people heat.

Even the plaintiffs in the other recent (particulate matter focused) important German pollution case complained that a Diesel ban does nothing for the pollution situation: The main source for car based emissions aren't the engines - but the wheels.

</comment></comment></comment></comment><comment><USER25> Excellent news for the air quality in German cities. We've been blatantly breaking German and EU law for years now.

</comment><comment><USER26> Is this backed by real science? I was under the impression that modern diesels were highly efficient and quite within the acceptable emission standards.

<comment><USER27> There's a big difference between general "emissions" which a lot of people take colloquially to just mean greenhouse gases (and CO2 in particular with combustion engines), and then the small particulates and other things (like NOx) that create worse local air conditions[1]. Most "modern" diesels in use do still have the latter problem. I think at the very cutting edge, if you maintain a very good filter and operate in favorable conditions you can cut those emissions dramatically, but as far as I know it isn't widespread among the personal diesel fleet.

[1] [http://theconversation.com/fact-check-are-diesel-cars- really...](http://theconversation.com/fact-check-are-diesel-cars-really-more- polluting-than-petrol-cars-76241)

<comment><USER28> Most local air pollution, counterintuitively, doesn't even come from exhaust.

Wear on tires, brakes, and the road each contribute more individually.

There's another process called resuspension that dwarfs even these. Cars grind down large particles sitting on the road, making heavy particles light enough to float in the air. Then the cars' wake kicks those newly light particles into the air, suspending them in the air.

That process is driven by vehicle weight, size, and aerodynamics, and contributes about two-thirds of the particulates from all vehicle sources.

One of the interesting takeaways from all that is that average vehicle weight can be massively important to local air conditions (no pun intended).

I think there's still some debate about the exact relationship between weight to PM output, but lighter frames and smaller vehicles are probably a good idea:

[http://www.greencarcongress.com/2016/04/20160418-pm10.html](http://www.greencarcongress.com/2016/04/20160418-pm10.html)

<comment><USER18> Related to PM output, here is a crowdsourced effort to collect air quality data around the world:

[https://maps.luftdaten.info/#2/0.0/0.0](https://maps.luftdaten.info/#2/0.0/0.0)

Building and deploying your own sensor is pretty easy: [https://bergie.iki.fi/blog/microflo-particulate- sensors/](https://bergie.iki.fi/blog/microflo-particulate-sensors/)

</comment></comment></comment></comment><comment><USER29> A correction to the headline; its only older diesels, not all diesels.

From way down the article:

> Cars that meet Euro-4 emissions standards could be banned from Stuttgart > from next January, while Euro-5 vehicles should not be banned until Sept. 1, > 2019, four years after the introduction of the latest Euro-6 standard.

If you have a diesel with Ad Blu designed to catalytically remove NOx, you should be OK for now.

</comment><comment><USER30> Can anyone more familiar with this case comment on what exactly happened here?

It sounds like two private organizations, DUH (Deutsche Umwelthilfe) and ClientEarth, sued a couple of cities (Munich, Stuttgart, and Dusseldorf, possibly among others), saying they had to improve air quality. This was, apparently, on the basis that the cities had illegally high levels of NOx -- I'm not certain on what basis this was illegal, whether German or EU regulations.

Munich offered a ban, which everyone was happy with. Stuttgart and Dusseldorf attempted to offer a mitigation strategy, and DUH and ClientEarth sued again saying that the mitigation was insufficient, and the judge ruled that they only a ban would suffice.

The cities appealed, apparently on the basis that they were not legally allowed to impose such a ban(?) and now, a higher court has ruled that they are legally allowed to impose such a ban.

<comment><USER31> Great summary. This is so good to see, one of the advantages of living in Europe.

</comment></comment><comment> blubb-fish awesome news - first of all public transportation in any town with more than a hundred thousand inhabitants is good enough that nobody needs to use a car except for very specific cases. of course if everybody would switch to ÖPNV then the capacity would be maxed out - so the conclusion is increasing availability of public transportation.

also the way parts of government (mostly those rooted in Bavaria) attempted together with VW, Audio etc. to weasel their way out of taking responsibility. the testing applied was stupid and lacking realism - but nonetheless they programmed software that detects a test and adjusts the motor's inner workings. that's beyond benefiting of stupidity - that is criminal.

It feels great, great, great - I hope this will strengthen research and development for and of electric vehicles.

</comment><comment><USER32> Wouldn't it be great if Tesla kicks these cheaters in the bin and wins the car race (like the iPhone did vs. the other phones)? Pity producing cars isn't as fast as manufacturing an iPhone. Germany's industry is in real trouble, looks like they were cheating.

<comment><USER31> What would be really great if we could get rid of cars all together, spend all that money on an awesome PT system, and convert 80% of roads into parks and other uses. Make suburbs actually nice places to live.

</comment></comment><comment><USER33> I assume they are removing cars and buses making use of this tech first as they are far more likely to be dirty that cars. Even the cheating VW cars were still magnitudes cleaner than the immediate previous generation.

I think they are going to find their pollution problem is nearly as bad and will need to make more difficult choices rather than relying on fear of a partial truth. It isn't just diesel cars making their cities dirty. As stated, the change made to even the cheating cars would have demonstrated such if it were just cars

<comment><USER34> Buses, HGV's and all other large vehicles actually tend to run okay on diesel, because they are large and expensive enough to carry and pay for the necessary equipment to reduce NOx and PM. It's small cars in particular where diesel just doesn't work.</comment></comment>


Ask HN: Building a virtual SOC for non-profits, activists who wants to help? - <AUTHOR> Hey everyone,
I just wanted to see if anyone knew of any UTM, EDR, Next Gen Antivirus companies that have non-profit programs or discounts? I know that Crowdstrike has a foundation (https://www.crowdstrike.org) that I am reaching out to (haven't got a response in the past 12 months unfortunately) and some vendors have very basic endpoint offerings (https://www.techsoup.org/security).
So a little about us. We are a small human rights organisation that specialises in working with high risk non-profit, NGO, activists, media etc all over the world. Ranging from small community groups in the US to large well-known international organisations and to lone individuals protecting rainforests. We work to protect a few dozen groups and hundreds of individuals every year all over the world.
As you are well aware, such organisations are often targets for very sophisticated spear-phishing, malware attacks, APTs from countries like China etc. Unfortunately most are woefully under resourced and lack the ability to have basic monitoring systems (and most importantly, someone looking at them) in place. So often we can find the same basic attacks repeating themselves even when IOCs etc are available to block them.
We are currently experimenting with building a small virtual SOC across a number of at-risk activist, media, human rights and environmental organisations (from activists in Zimbabwe to rainforest defenders in Brazil) to help them pool their resources and manage security in a more effective way. So tools like CB, Falcon etc. Obviously it's highly expensive stuff so we want to do our best to make sure it is available to people doing good work on the ground in a lot of high risk places.
Also, if anyone is interested in maybe helping out with some advice (experiences/positive/negative) about using/setting these tools up, running or being part of SOC, the people we are working with a pretty inspiring and your knowledge would go a long way to help protect them in troubled times!
Feel free to reach out to vsoc AT secfirst.org
Thanks! <comment><USER2> Pardon my ignorance, what does SOC stand for? I can only think of "system on a chip" but based on context I don't think that's what you're referring to.

<comment><USER3> Security Operations Center

</comment></comment><comment><USER4> Isn't a virtual SOC just a VM with extra steps?

<comment><AUTHOR> Well I guess you can nail it down to that but in reality it's ways more, especially for who we work with.

It would be a whole series of steps including selecting and picking the technology, testing and deploying it, working with low capacity groups to help them train on areas from basic user security to advanced monitoring, working with it within those orgs, more testing, then having the right people doing daily response on alerts, action on things etc etc...

So yes at a basic level it is just VM chips but in reality it's much more than that.</comment></comment>


Design Patterns in Clojure - <AUTHOR> http://mishadoff.com/blog/clojure-design-patterns/ <comment><USER2> I like Clojure quite a bit more than Java, but some of these are unfair if you are comparing against modern Java.

For instance, the sorting example can be simplified:

        Comparator<User> userOrdering = Comparator.comparing(User::isSubscription).thenComparing(User::getName);
        // forward sort
        Collections.sort(users, userOrdering);
        // reverse sort
        Collections.sort(users, userOrdering.reversed());

A lot less verbose than it's made out to be.

<comment><USER3> While it's definitely the case that there are more concise domain-specific examples, as you've pointed out, the article's point stands: in Clojure, a Strategy is simply passing a function as an argument to another function.

<comment><USER4> The caveat is perhaps that in Java 8, a Strategy is simply passing a function as an argument to another function too.

I'd love to see patterns struck down as obsolete with Java language updates.

<comment><USER5> \+ Finding or creating suitable functional interface for passing the function

</comment></comment></comment></comment><comment><USER6> Brilliant-- this is among the best design pattern writeups I've ever seen, and will greatly help developers who are coming to Clojure.

This would be excellent for expanding to book-length guide to help people learn functional programming along with the patterns. Thank you Misha for writing this!

</comment><comment><USER7> Peter Norvig covered this two decades ago: [http://norvig.com/design- patterns/design-patterns.pdf](http://norvig.com/design-patterns/design- patterns.pdf)

Paul Graham mentioned Norvig's work in 2002: [http://www.paulgraham.com/icad.html](http://www.paulgraham.com/icad.html)

</comment><comment><USER8> I love the idea! A few examples are a bit strawmanish but really when you're comparing languages like that who can resist the strawman.

The Clojure solutions do sacrifice a lot of safety though, due to dynamic typing (e.g. the visitor pattern, which relies on basically strings to do its dispatching).

<comment><USER9> keywords are not strings. And what do you mean by safety ?

<comment><USER10> I'm assuming commenter meant it'll crash at runtime if there's typos in a keyword used for dispatching a multi method.

</comment></comment></comment><comment><USER11> [http://wordsmith.org/anagram/anagram.cgi?anagram=SerpentHill...](http://wordsmith.org/anagram/anagram.cgi?anagram=SerpentHillREE&t=1)

Subtle.

</comment><comment><USER12> I'll just plug my own (not as comprehensive) contribution to this meme: [http://www.colourcoding.net/blog/archive/2014/10/27/design-p...](http://www.colourcoding.net/blog/archive/2014/10/27/design- patterns-happy-birthday-and-goodbye.aspx)

</comment><comment><USER9> I would love to have some Java programmer opinion on this piece.

<comment><USER13> I'll bite, downvotes notwithstanding :)

One advantage of the Java is that the interfaces are named, type-checked documentation. Yes it's more verbose, but a maintainer of that code can understand exactly the intention just from the interface names, without having to decipher it line-by-line.

For the Clojure code, after you've added enough comments to explain what you're doing, so that the code can be reasonably maintained, then it's the same size as the Java code, but without the type safety.

Granted for some of the simpler patterns like strategy, Java's verbosity just gets in the way, though much of that has been simplified in Java 8. FWIW I prefer Scala over both in all cases. But if Scala didn't exist, I'd prefer Java for the enterprise use case, and Clojure for the small applet use case.

<comment><USER14> > it just doesn't work at an enterprise level Elaborate?

<comment><USER13> Big, not-very-interesting CRUD app. Every time the data model changes, you've got to go through manually and find all the places the code needs changed, and hope you didn't miss anything. It probably didn't help that it was running on MongoDB, so two levels of dynamic typing and impossible to remember what went where, and a DB that takes whatever you give without complaining. So no compile errors and often no runtime errors either, just incorrect behavior.

Switched to Scala and SQL, and code is almost as compact but typed relations are far easier to reason about; if a relation changes then you change the core type and follow the compile errors. Once it compiles, it usually works. We've not missed Clojure in the least.

Scala (and even Java) simply feels more structured, with relations between types, the resulting app more "designed", which seems necessary at the enterprise level. In my 2 years, Clojure constantly felt like just hacking.

Would love to see some examples of Clojure being used well at an enterprise level so I could understand better how to do so, but CircleCI's recent flopping between core.typed and prismatic just makes me think it's a square peg in a round hole.

<comment> michel-slm Using Mongo certainly didn't help, we're in the same situation ourselves and having various regrets over different aspects of it...

What do you use to interface with SQL on the Scala side? Squeryl?

<comment><USER13> JDBC. I tried a few libraries and found they all provide either too much or too little. It's not so hard to write your own wrapper around it to make JDBC more friendly. Plus then you get to use features specific to your DB rather than just the lowest common denominator.

Another thing that helped was to use underscore_naming for any case-class in Scala that maps directly to a query, so it's easier to identify them.

</comment></comment></comment></comment></comment></comment><comment><USER15> Really nice writeup of patterns. What turned me off Clojure is that the dynamic typing makes it very hard to refactor. e.g. even renaming a function is really quite difficult, let alone adding function parameters. Forget extracting a function. The dynamic typing also means a typo can yield a nil that travels far from the mistake site making debugging difficult. There are hints towards better debugging in clojure, but last time I checked it was still very much a work in progress. Also lazy lists are easy to screw up, e.g. if you put a concat inside a reduce then stack go boom.

Still this is a great post because it teaches you both good Clojure and the design patterns. Since java has closures now you can take a lot of what you learn from Clojure and put it in your well typed and refactorable Java programs.

<comment><USER9> Refactoring is a breeze when your editor is connected to the repl, you should try clj-refactor for instance.

I'm not sure what you mean with the typo story since most of the functions in your program should be free of side effects you should be able to test them as you write them.

<comment><USER13> I'm always curious about the latter sentiment. Maybe I just haven't been on enough interesting projects, but I've never had a program that didn't have/need side-effecting code nearly every other line. Upload something to S3, if X then call some web service, otherwise log and call something else, etc etc etc. Pure data manipulation has always been a fairly minor component limited to dashboard statistics for me. Is purity that really your experience? What industry / types of projects?

<comment><USER16> Thinking in data & functions just takes some practice. Traditionally imperative code can often be reimagined in terms of reducing over a command sequence, or interpreting some more sophisticated representation. The benefits for implementation, testing, debugging, refactoring, etc can be massive.

Consider your chain of examples for "Upload something to S3, if X then call some web service, otherwise log and call something else, etc etc etc." You could represent this as a sequence of steps which could be interpreted by a central side-effecting loop. Let's call it an "action plan", in this case for your "upload" operation:

        (defn upload-plan [req]
          [{:action :upload
            :file (get-in req [:params :doc])
            :max-size 2000
            :name :doc}
           {:action :notify
            :message (fn [state] (get-in state [:data :doc]))
            :target [:somebody]}])

Now you can process this plan centrally:

        (defmulti take-action (fn [state {:keys [action]}] action))

        (defmethod take-action :upload ...)
        (defmethod take-action :notify ...)

        (defn execute [plan]
          (let [{:keys [status]} (reduce take-action {:status :ok, :data {}} plan)]
            (when (not= status :ok)
              (log "omg!"))))

While this is initially a tad more verbose, there's great reasons to do this sort of thing.

For example, now have a central place to mock all side effects! You could substitute a different execute method during testing, or automatically log the "action" object that failed.

More importantly, you can develop each of your "plan" functions independently. You can reuse them, re-order them, etc.

You can also do hypotheticals, for example: "Which plan would cause less network round trips?" can be answered before committing to a plan.

You can _record_ plans. Instrument your execute method to record and save plans to a file, then you can just check them right in as test cases.

You can optimize plans. If five different functions all notify the same target of the same thing, your central execution method can filter subsequent calls. Or you could separate your "optimization" from your "interpretation" and you can ask "After accounting for idempotence, which operations will be performed?"

The list goes on and on...

<comment><USER4> As an aside, you just (sort of) implented the IO monad.

The simplest explanation of the IO monad is that your Haskell application outputs a recipe or "execution plan". This output is side effect free and pure. The runtime then executes your plan, producing those side effects.

<comment><USER16> One key difference between this and the IO monad or a free monad: There's no continuation.

That is, you can't communicate between the code that produces the command sequence and the code that interprets it. This is either a shortcoming, or a dramatic simplification, depending on your needs. I find that it's often the latter, since it enforces a one-way information flow.

<comment><USER13> I looked at this, and isn't it inside-out though? Given that code/data equivalence being the fundamental thing that makes a lisp a lisp, wouldn't the lisp way to go about it be, to write a whole-program-transformation macro that can replace certain function calls with specified equivalents? That way you can write code just like normal, but have it do completely different things based on the context. The idea of being able to do this is what made me consider a lisp in the first place. Yet I don't see much evidence of people working in that direction.

<comment><USER16> There's a lot of stuff packed in to your comment here.

The code/data equivalence isn't necessary to make this data-first approach work. Consider JavaScript, where it's quite popular to power complex processes with simple JSON (maybe + extensions, like functions). The approach also works well in typed functional languages, albeit with greater declaration burden. Moreover, it would even work well in languages like Java, if you're willing to buck the XML trend.

That said, data being a subset of code (which is also implied by equivalence) is what makes this technique much more popular in Lisps (and JavaScript). Being able to easily move forms between evaluation, quoting, interpretation, etc is critical to evolving the right approach.

Regarding whole program transforms: They don't compose, at least not without a substantially more sophisticated macro system (like Racket's) or evaluator (see work on "extensible interpreters"). Check out Racket's rich literature on macros if you want to see the state of the art here.

Lastly, changing behavior based on context can be accomplished by many techniques including interpretation, dynamically scoped binding, etc. Read about Common Lisp's condition system, or Eff's "Algebraic Effects and Handlers" to see the state of the art of the dynamic substitution of effects. However, each new context needs to carefully reason about the interleaving of effects, since time is linear.

If you want more flexibility with time, you have to turn it in to space. That's what happens when you take a step-by-step procedure and turn it in to data you can interpret. Consider code that prints a lot of stuff. Instead, you can return a lazy sequence of strings and then at the very end do something like `(apply str parts)` to concatenate it all together. Now that each sub- printer doesn't have side effects, you can re-order and refactor the calls without worrying about messing up the printed output. You've decoupled the evaluation timeline from the linear order of the output.

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER12> Whilst I agree in general with the sentiment, it really doesn't help if you start with a misunderstanding of the command pattern. The essential property of command is that it's data that can be executed. Implicitly, it's possible to do other things with them: log them, undo them and so on. A better model would be a record that implements IFn.

</comment><comment><USER17> I think the Visitor example is a mistake. Couldn't you replicate the Clojure version in Java by having a "Formatter" singleton that has a function for each of the different item type/format type combinations?

<comment><USER18> I don't think so, the whole point is that Clojure will select the correct function dynamically (that's what multiple dispatch is about). In all cases you need 4 different functions (for each type/format combinations).

</comment></comment><comment><USER18> Excellent, definitely going to read this. I would like to see this for Haskell, though. And some Lisp idioms (from On Lisp, for example) could be thrown in for a good measure, too.

</comment><comment><USER19> > Eve: Stop talking, show me the code!

I like Eve.</comment>


Show HN: AnswersEngine – A flexible web scraping platform for Ruby devs - <AUTHOR> https://answersengine.com <comment><AUTHOR> Hello, I'm a co-founder here. I've recently built a web scraping platform for Ruby developers. It is intended to solve the pain points of what I've experienced over the years of doing web scraping for my clients.

Things that are just a hassle to do, are already taken care of:

Proxy and user agent randomization, so that you don't get banned easily.

Parallel scraping, that allows you to scrape at scale.

Page Caching. Imagine your scraper already runs for several days, and it fails.... would you rather re-download the pages all over again? or would you rather just parse from the cache?

HTML parsing using Nokogiri, and/or any other gem.

A pretty granular RESTful API, so that you can integrate it with your app.

Currently, it's in Beta. Feel free to join. I'm giving away $100 free credits, so that you guys can test it out. Any feedback, is greatly appreciated.</comment>


Llvmpipe: The Jitted OpenGL software renderer inside Mesa - <AUTHOR> http://www.mesa3d.org/llvmpipe.html <comment><USER2> This looks interesting. I wonder if browsers could implement this as a fallback for WebGL when the drivers are missing or blacklisted? Chrome on Windows uses SwiftShader to fallback to software-rendered WebGL, and I think IE11/Edge use WARP, a DX11 software renderer. Firefox and other browsers on non-Windows platforms could benefit. But by the sound of it running this against the WebGL conformance tests could be spotty!

<comment><USER3> Does Chrome still use SwiftShader? I've tried on a reasonably large number of machines to verify this, with no luck. Including machines that have blacklisted GPUs.

It's clear that there seems to be some cases where it kicks in (or at least theres some legacy cruft that references it if not) but hell if I've ever seen it happen.

</comment></comment><comment><USER4> FWIW, OS X at least used to, and I think still does, use a JITed software renderer using LLVM.

See <[http://lists.llvm.org/pipermail/llvm- dev/2006-August/006497....](http://lists.llvm.org/pipermail/llvm- dev/2006-August/006497.html>) for a short overview and <[http://www.llvm.org/devmtg/2007-05/10-Lattner- OpenGL.pdf>](http://www.llvm.org/devmtg/2007-05/10-Lattner-OpenGL.pdf>) (slides, PDF) for a longer one.

<comment><USER5> fixed links: HN is keeping the > at the end of them.

[1] [http://lists.llvm.org/pipermail/llvm- dev/2006-August/006497....](http://lists.llvm.org/pipermail/llvm- dev/2006-August/006497.html) [2] [http://www.llvm.org/devmtg/2007-05/10-Lattner- OpenGL.pdf](http://www.llvm.org/devmtg/2007-05/10-Lattner-OpenGL.pdf)

</comment></comment><comment><USER6> Potentially relevant sidenote:

Using VirtualGL ([http://www.virtualgl.org/About/Introduction](http://www.virtualgl.org/About/Introduction)) and TurboVNC ([http://www.turbovnc.org/About/Introduction](http://www.turbovnc.org/About/Introduction)), you can drop a GPU in a server and serve up OpenGL applications _rendered using the GPU in the server_ via VNC over the network.

VGL pools the GPU(s) between multiple VNC displays, allowing for excellent performance.

<comment><USER7> Virgil ([https://virgil3d.github.io/](https://virgil3d.github.io/)) is a similar effort for virtualizing GPU(s) in QEMU. The virtio-gpu guest DRM driver just shipped yesterday with Linux 4.4, making it possible to accelerate multiple VMs using host hardware.

A Direct3D guest driver, if it performs well enough, could finally end the hacky VFIO passthrough setups that are currently in vogue.

<comment><USER6> Wow, this looks really cool.

One curious idea that might be worth exploring: writing a Vulkan guest driver on top of this stack. It would be a novel approach, as the guest would see a Vulkan-centric view of the world (making development really simple), but that "world" would be easily transportable between machines, regardless of said machines' host graphics stacks.

</comment></comment></comment><comment><USER8> I followed planet.freedesktop.org around the time that Gallium3D was being developed, so I knew that LLVM was being used inside Mesa. However, the only time I actually noticed it was when I hit [https://github.com/NixOS/nixpkgs/issues/11467](https://github.com/NixOS/nixpkgs/issues/11467) last week

</comment><comment><USER9> Looking at this: [https://codereview.chromium.org/1548893004/](https://codereview.chromium.org/1548893004/) and this, is there chance that there will be decent option for headless webgl testing or making screenshots? Phantomjs doesnt want to do that, slimmerjs also (on xvfb), anybody have a working solution?

<comment><USER10> For [http://Clara.io](http://Clara.io), we explored a bunch of headless gl solutions and none worked. It may have changed by now. But even if you got a headless gl solution working, it likely would have poor extension support, which means the results will suffer anyhow. :(

<comment><USER9> So did you take any other solution? I was thinking about renting or collocating server with gpu and just automate whole process with ansible/fabric or just vnc. About exentions - thats true. I was able to run software rending for shaders (llvm, xvfb, ec2), framerate was acceptable (1-5 fps, which is more than fine for screenshots), but issues like having max anisotropy = 1 make it unusable for this use case.

</comment></comment></comment><comment><USER11> Multiple times I've read about the better software renderer. If I read it correctly it's because of LLVM. What has LLVM to do with that? Why wasn't there a faster software renderer before there was LLVM? Is it easier to create a performant software renderer with LLVM? Could someone explain this to me or maybe provide a link for more information?

<comment><USER12> In OpenGL, you take vertex attributes in some user-specified format, run them through a user-supplied program, and rasterize it with a user-supplied program to generate pixel data. These programs are specified in GLSL. You want to run them, you have to interpret or compile. No surprise the compiled version is faster.

Even unpacking attributes is going to be faster with JIT.</comment></comment>


Ask HN: Would you buy datasets of Web authoring methods & the Web's structure? - <AUTHOR>

I want to sell datasets that I create from doing regular Web crawls. An example dataset would be the link graph. I would sell the link graph in chunks of 1 billion edges for a price. The dataset would include the source and destination URLs, the anchor and title text of the link, any rel or rev values, and so on. Other datasets would include the top 1,000 [HTML editors, CMSs, forum and blog software, etc.], big lists of sites using X technology (AdSense, Feedburner chiclet, etc.), how many sites are using which advertising platform, and so on.
Are you personally interested in such datasets? Are there certain niches that would benefit from the data that I should be targeting?
Edit: I should note that I've already done a tremendous amount of work on this project. For example, I've completed each of the datasets I listed above from a [rather small] 10 million page crawl. I'm also running a Hadoop cluster with HBase and I'm using MapReduce for data processing. <comment><USER2> What would be interesting would be to let users hook their own custom functions to your web crawler. In other words, whenever you crawl a link, you feed the link to the developer's script which does whatever it wants with it. I've had plenty of ideas that would involve a web crawler, but I just don't have the time to customize an open source crawler. There are too many complications like not falling into infinite loops (such as a calendar type pages).

<comment><AUTHOR> I have something in mind along those lines, and I'm going to provide at least two or three ways to create custom datasets from my 'snapshot of the Web.' I thought about your suggestion of allowing customers to execute their own scripts over the snapshot but the security issues involved are my big concern. I would need a way to sandbox it. My plan right now is to offer the ability to run simple data tasks on the snapshot. For example, regex (filtered for things like SSN matchers, and so on), a language with a limited vocabulary for grabbing features with certain textual of visual characteristics, or even something as simple as xpath. I would run these tasks on the cluster and the result would be returned to the customer.

</comment></comment><comment><USER3> Send me an email to ilya [at] unviral.com about this, I would be very interested in talking about applying this for tracking ad campaigns and correlating with some of the data I have been collecting.

There's definitely a lucrative market for this if your crawling and data can be targeted enough.

</comment><comment><AUTHOR> Update: I created a landing page for the time being: <http://webscaled.com/></comment>


The World's Richest Families 2020 - <AUTHOR> https://www.bloomberg.com/features/richest-families-in-the-world/ <comment><USER2> Imagine being Jerome Powell and saying with a straight face to the cameras that the Fed monetary policy has absolutely nothing to do with inequality. Pitchforks get ever closer.

Robin Williams on the topic: [https://www.youtube.com/watch?v=etQeFJ2lbbo](https://www.youtube.com/watch?v=etQeFJ2lbbo)

<comment><USER3> I'm not sure billionaires are the problem with respect to income/wealth inequality. We've always had mega-rich families, but what's driving the anger against wealth inequality now?

The new phenomenon we're seeing now is the pulling away of the upper middle class from everyone else. I think that's the real source of anger against inequality. I don't think most people really care that there is some billionaire out there. All billionaires combined earn just 1% of all income, so it's not like they're sucking up a huge part of all income. People get mad when they feel like they're competing for real world resources, and there just aren't enough billionaires to do that. But the Facebook engineer making $500,000/year? They're the ones buying up the houses and driving middle class people out of neighborhoods.

I've been listening to the new New York Times podcast "Nice White Parents": [https://www.nytimes.com/2020/07/30/podcasts/nice-white- paren...](https://www.nytimes.com/2020/07/30/podcasts/nice-white-parents- serial.html). The first couple of episodes talks about the conflict between lower income Black and Hispanic parents and high income white parents in a Brooklyn neighborhood school. I think when people get mad about income inequality, for the most part they're reacting to that sort competition for limited resources in American neighborhoods. And the "rich people" that are competing for those resources aren't billionaires, but the upper middle class.

<comment><USER4> """ But the Facebook engineer making $500,000/year? They're the ones buying up the houses and driving middle class people out of neighborhoods. """

Wait this sounds like demonizing the FB engineer for making the 500k even though he would now have to pay millions for a medium size/class/type home that was previously owned by (and sold for) a crazy amount by said "middle class".

I get very worried when I see this sentiment where somehow the employees of these companies are responsible for killing the previous fabric but what is driving them to these decisions is somehow sacred?

<comment><USER3> I'm not demonizing anyone. But the inequality that affects every day people directly—rising housing prices in formerly middle class suburbs, competition for good school districts, rising prices in restaurants, etc., is driven by the large growth in upper middle class salaries. (My parents wouldn't have been able to afford the 1,100 square foot 3BR 1950s house I grew up in at today's prices. The neighborhood isn't full of parked Saudi money. It's the explosion in upper middle class incomes.)

Housing prices in full Silicon Valley suburbs aren't exploding because of a handful of billionaires, it's because of a vastly larger number of engineers making $500k.

<comment><USER4> I do apologize for the over reaction :). Engineers like anybody else are going to flock to where the money is (the intent of capitalism). To me it sounds like Engineers aren't wilfully driving away middle class as much as congregating closer to their employers for convenience. No? The same 500k eng would drive up a price no matter where they are located. So instead FB should limit salaries so that these engs cannot inflict this (unwilling) damage?

</comment></comment></comment></comment></comment><comment><USER3> > But even a pandemic hasn't stopped the relentless growth of their fortune. > The Waltons are richer than ever, adding $25 billion in the past year to > take their combined fortune to an estimated $215 billion

To put things into perspective, the entire Wolton fortune, accumulated over decades, would bankroll the ongoing COVID lockdowns for about a week.

<comment><USER5> If we could have a hard lockdown for 4-8 weeks and still come out the other end in good financial shape, that would be amazing, and really get the virus under control. If a small number of families could make that happen, let's do it.

<comment><USER6> That reads like "If a small number of families could forfeit several lifetimes' of fortunes accumulated via serving the needs/wants of vast swaths of population, let's take their money and do it!"

This seems like something that is much more properly paid via broad-based taxation, not by seizing wealth from a small number of families.

<comment><USER5> > That reads like "If a small number of families could forfeit several > lifetimes' of fortunes accumulated via serving the needs/wants of vast > swaths of population, let's take their money and do it!"

"via serving the needs/wants of vast swaths of population" is completely false. The article was about inherited wealth. When you inherit wealth, you didn't serve the needs of vast swaths of the population. You were simply born to the right parents.

</comment></comment></comment></comment><comment><USER7> Things I like to think I'd do if I made 10^9 every 2 weeks:

-pay everyone making minimum wage or below 100$ for registering to vote. Cost about 170m.

-devote some portion of it to animal safety and care taking. Even stuff like sanctuaries for feral cats, dogs, and other non-adopted creatures as opposed to euthanasia.

-public libraries that provide services people otherwise wouldn't have. Like a public square almost. Have a clearing house match up community interests with speakers and the like. Ie inviting religious people or leaders from religions foreign to the community to come in and discuss their beliefs and culture. I also want people to be able to request and invite things like lectures from theoretical physicists. Also do stuff like letting people request time on musical equipment in the building to learn how to play - or even just see if it's for them.

Granted, all of this would probably negatively affect that biweekly 1 billion!

<comment><USER8> First you'd have to convert your 1BN gain of non-cash assets to cash every 2 weeks.

<comment><USER9> That wouldn't be very difficult.

<comment><USER10> You think the demand is so high that increasing the supply of shares for sale won't have an effect on price?

<comment><USER7> Yes, look at the average daily volume for stocks. There's plenty of opportunities for cashing out when you have that sort of asset.

<comment><USER8> You'd also run out of that asset pretty fast.

<comment><USER7> Doubtful. Bill Gates has been spending a lot of his time looking for ways to spend his wealth to help humanity. He's not close to running out of wealth either.

I sense that you're looking for a denialist argument against this concept and potentially in bad faith. "If it's not possible to actually cash out on 1B every two weeks then discussing the things we'd do with it is pointless."

</comment></comment></comment></comment></comment></comment></comment><comment><USER11> Koch

>Family's political network is planning to engage in nearly 200 federal and state races in 2020.

Why not take all of that and put it toward green or fusion research?

<comment><USER12> Because their power rests on fossil fuel revenue?

<comment><USER11> Unsustainable. I'm not a billionaire but I think it would be wise to own the next big energy source.

<comment><USER13> I wonder at which point you can be considered a bad person, if you have money and actively work against mankind - which ignoring climate change is IMHO.

</comment></comment></comment></comment><comment><USER14> the intersting bait and switch that always seems to happen is people point at billionaires and then use their wealth to justify raising taxes on dentists that make 200k. Whereas the billionaires can just offshore their wealth.

they are used as scapegoats but the damage is done to working professionals like family physicians

<comment><USER15> I was listening to the BBC the other day and someone was something they estimate there's 32 Trillion dollars in tax havens the world over. I've never understood why some small country just doesn't invade a tax haven and seize the money. I know it wouldn't happen but it'd be a great way to disrupt crime in the world.

<comment><USER10> Because there isn't 32 trillion in cash laying around with in various island vaults.

This thread is rife with lack of knowledge about what wealth even is and how to re distribute it to society.

</comment></comment></comment><comment><USER16> > With that much money, you could pile $1 million onto each of the 19,368 > seats in the Walton arena and still have enough left to give Walmart's 2.2 > million associates about $90,000 each.

Does this measurement mean anything to anybody? It doesn't help me visualize anything.

<comment><USER15> They really need a serious billionaire tax. Something fun like: If your a billionaire and at your death your collective wealth was greater than 2 Billion. You get a public statue with a plaque that overlooks all slimy stuff you did to make that money. Also you can give your kids 1 Billion and the rest is returned to the government.

Maybe even throw in a street name or something.

<comment><USER17> They would just put the money and company shares in trusts. It wouldn't change anything.

What we really need is for capitalism as we know it to die. It's unethical that people are having to worry about starvation, not having a roof, and not having access to medical care in the US while Mark Zuckerburg is colonizing an island of Hawaii and suing native residents out of their family land.

<comment><USER18> I'm all for killing capitalism, but that doesn't magically solve the inheritance problem. If they would put it all in trusts, then make laws to prohibit that. You need to close all the loopholes of inherited wealth, which goes far beyond trusts as well.

</comment></comment></comment></comment><comment><USER19> One might have expected Georgina _Bloomberg_ to make this "top 25" list... does the founder have to be dead?

<comment><USER20> FTA

> The ranking excludes first-generation fortunes and those fortunes controlled > by a single heir.

</comment></comment><comment><USER21> Sam Walton made a fortune by offering people goods priced lower than anyone else offered. He also pioneered no-questions-asked return policies.

Wal-Mart has done a lot of good for people with lower incomes. Prices are low, employment is usually easy to come by.

It's not home to the finest of goods, but when the chips are down Wal-Mart is your friend.

</comment><comment><USER22> What would happen over time if a specific class of people had an unfair advantage?

I did the math and Bloomberg has ALREADY earned back all the money he spent in the election by literally doing _nothing_.

\- They pay _dramatically_ less taxes. Often zero percent on many transactions and with money hidden overseas or in specifically designed financial instruments for the rich.

\- They have connections you don't because they send their children to ivy league schools, the ENTIRE purpose of which is to act as a filter for the rich.

\- They own the means of production.

\- The working class won't stand up for their rights, won't unionize, and consistently ...

\- They can bypass state taxes entirely by lying about where they live.

I've started FOUR companies now. Sold three. I'm NOT a communist. Capitalism is amazing - but it's fundamentally broken.

All the criticisms that US conservatives have previously applied to the Soviet Union now apply to the US.

\- The government picks the winners. \- Government and corporations are in bed with one another to the point where we have a centralized control of power.

The BEST reform we could have, and fight for, is adequate taxation. Make the rich pay the SAME % as everyone else. NO tax benefits for corporations for moving to a specific state/city. Uniform state taxation.

The extra money we make from making the rich pay their fair share, without having YOU subsidize them, should go to help ALL Americans pay for health care, education, etc.

If you're a Christian it's what Christ commanded you to do. If you're a good person it's the RIGHT thing to do because it helps your fellow man. If you're a capitalist it's the right thing because it will SAVE capitalism.

<comment><USER17> The rich shouldn't pay the same percent. 20% of my income in taxes has pretty profound changes to my life. Bezo's getting taxed at 90% means he has fewer megayachts and fewer private jets and fewer private islands. That 20% means a lot more to me than that 90% means to Bezos. That is how we should measure value.

</comment></comment><comment><USER23> They must be 260,000× engineers.

</comment><comment><USER24> > _That's partly testament to long-standing advantages vast wealth affords. > Bolstered by years of strategic diversification and family offices that can > rival investment banks in their scope and sophistication, the 0.001% can > weather economic and social turmoil._

Interesting how this article points to their tactic being some kind of sophisticated investing strategy, and not the federal reserve bailing out stocks and lowering interest rates to prop up property prices.

The whole article reads like a desperate attempt to keep people from realizing our own government props up these rich families at taxpayer expense.</comment>