Modern Web Applications are Here - <AUTHOR> http://lucumr.pocoo.org/2011/11/15/modern-web-applications-are-here/ <comment><USER2> With the last three projects I have started (none live, yet) the backend is nothing more than a REST API and the frontend a single HTML page with javascript, javascript, javascript.

This is what web applications are now and will be. The user experience can not be compared to the old style of application. If you are still building applications today that are GET, fetch, pause, render, etc. then you are years behind. It is awesome being able to click on a link to a 10-page forum thread or blog comment page and have it render in ~100ms.

I think all of the web server frameworks will have to adapt - from RoR to Django etc. since a lot of what they do is being moved to the client (and it becomes even cheaper to run large-scale web services because of this). There are also tons of gaps on the client side - from more capable and cachable templating engine through to a full-stack framework (something like RoR for Javascript but less confusing and hard to use than the current)

The server now is just db+REST, auth and pubsub - soon enough somebody will release a generic PaaS that does all this based on a schema. Almost no more, or very little, server-side code (unless you insist on supporting old HTML clients).

<comment><USER3> > With the last three projects I have started (none live, yet) the backend is > nothing more than a REST API and the frontend a single HTML page with > javascript, javascript, javascript.

You might be doing that already, but the article mentions (if I got that right) that if you GET an arbitrary URL, the server will still serve the whole rendered page - asynchronous loading only happen on any subsequent requests.

This way, you don't "break" URLs, pleasing search engine crawlers and allowing copy/paste of the links, and still delivering a great experience for the user.

I truly believe there is a big demand for a Node.js framework to facilitate this. There are already a few that allows this kind of architecture (to some degree), but none are quite "there" yet.

<comment><USER4> What are some of the frameworks you've seen? I've been looking for frameworks that allow client-side javascript routing to be reused on the server. So far I've found two, both using a combination of backbone.js and jsdom to render pages on the server:

<https://github.com/Morriz/backbone-everywhere> <https://github.com/developmentseed/bones>

<comment><USER5> Rendering arbitrarily on either the client or server is hard. Other solutions that I saw forced the developer to have to think about it, so I developed FaxJs which allows the system to handle that complexity for you.

<https://github.com/jordow/FaxJs>

The gist is that you just write standard declarative ui structures in pure javascript and the system disassembles the markup on the server, and reassembles it on the client with all the events still in tact. You wouldn't know all that is happening just by looking, though.

        ...
        var twoDivs = {
          className: 'outerDiv',
          onClick: this.outerDivClicked,
          innerDiv: {
            className: 'innerDiv',
            content: 'inner-most-div!'
          }.Div()
        }.Div();

Or you can just do it all on the client too, if that's your thing. You'll need to work to get this integrated into your routing technology as with any rendering system.

</comment></comment></comment></comment><comment><USER6> I agree that Modern Web Applications are here. The key point is that they don't _have_ to be architected the same as Battlelog to be considered modern.

Most of us are too concerned (or straight up scared) of the JavaScript/HTML5 revolution that we can't see what is possible right now. Sharing templates server and client side is a magic bullet that everyone should be using.

Web applications are only going to get faster, and if you want to keep up, you're going to have to do implement modern solutions like Battlelog and Google+ do.

I can envision a time when full page refreshes are the exception and that isn't a bad thing.

<comment><USER7> You don't need to involve the server in generating the UI at all. You can have a static index.html, that bootstraps a javascript environment from static js files, whose first order of business is to contact a web service to fetch the initial content and configuration as JSON data. This makes all content static except that which is truly dynamic, which offers amazing CDN and caching possibilities. The JSON data can be cached in local storage, for easy offline support without constantly revving manifest files.

Once you get at that point, the dev experience starts to look a lot like traditional desktop client-server app development. Except desktop apps are built using components instead of templates, components that combine rendering and behavior into one encapsulated entity that you can treat like a black box. There's nothing preventing a web app from using that same architecture. In fact, ExtJS does just this.

But I don't think it stops there. I think we're going to get meta- configuration languages like mxml to send the layout of these components to the javascript environment, which will, essentially, mean that we're building another browser inside the browser. And so all software evolves until it can render a web page, including web apps.

<comment><USER8> If you do this, crawlers can't index your pages. Also your users see the page loaded blank and being gradually populated with content, which is not a good UX.

<comment><USER9> Your first point is not correct. Crawlers can crawl JavaScript only websites using the Ajax crawling API: [http://code.google.com/web/ajaxcrawling/docs/specification.h...](http://code.google.com/web/ajaxcrawling/docs/specification.html)

Your second point has merit. However I'd counter it thus: * You can load a HTML page first, containing a representation of the end content, so you can avoid the flash * You can show some sort of loading indicator on page load. Users are usually fine with waiting for the initial page load - it's only subsequent interactions that need be fast.

In other words, there's no reason why the page need be blank.

<comment><USER10> However by using hashbang URLs, you have to keep that little snippet of JavaScript forever to maintain permalink even after the web has moved on to another solution.

It's not a future-proof solution.

<comment><USER11> Hashbangs are only a stop-gap at this point - modern browsers ship with the HTML5 History API.

<comment><USER12> Does IE8 ship with the History API?

<comment><USER13> No, IE8 is not a modern browser by most definitions.

<comment><USER12> Which definitions? I've seen definitions of "modern browser" that only exclude IE 6 and 7.

<comment><USER14> They are wrong. They use modern to mean "quite new and available to most clients" instead of "actually implementing the majority of the latest standards".

IE 9 comes close, and can be considered modern.

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER15> I'm not sure I agree with the "work of beauty" statement. A browser plugin? Rendering all pages on the client via some massive JS framework? Intercepting all page loads and hooking into browser navigation? Compiling templates into Python & Javascript? Is all this complexity really justified?

I know that web apps is all the rage those days, but given the native plugin, pickiness about browser version, the fact that they apparently not care about being indexed by search engines, and all the trouble they went through to make it all work together - wouldn't they be better off to just implement the whole thing as a native app?

<comment><USER16> This is a throwback to thick client-server computing. Welcome to 1992 everybody!

I'm not a web dev, but I like the client side rendering. (Even if I hate JS with a passion). This is a fantastic move as it lets you very clearly seperate presentation from business logic and the database. Also, the rendering HTML/JS can be easily cached. So you get a normal page load the first time you try the app, every time after that you get _instant_ results. Nice.

<comment><USER17> Why do you hate JS?

<comment><USER18> It's an immature language with lots of design mistakes. When the bible to JS developers is called, 'JavaScript the good parts' it's a worry...

</comment></comment></comment></comment><comment><USER19> While I'm excited about "modern web applications," my understanding is that they're harder to develop for and test (I haven't done one yet). If that's true, it's worth considering if the ROI is there to make your app a single- page javascript app vs how fast you can iterate via the more standard method. You may not have the traffic to where offloading rending to the client makes sense. It's likely many actions your app does are "fast enough" as well, so a rich UI experience isn't going to be a huge improvement. Reserving the highly interactive bits for where it really counts may be a better idea.

That said, it's only a matter of time before the "harder to develop and test for" goes away and rich apps will become more of the norm.

<comment><USER20> I think they're only really harder to develop in so much as it's more like developing two applications. One backend that throws out JSON/XML or whatever and a frontend in HTML/Javascript.

I actually find that bit easier, because I can separate out the the parts and worry about things a piece at a time. The other benefit of this is if you chose to develop for iOS, Android or any other platforms you already have an API. Equally if you wanted a developer program, again it's already there.

The complexity comes when you make the decision as to whether or not to support clients that can't or won't execute Javascript, if you want to make it work for them too you're stuck with more work and things do get more difficult.

As far as testing goes, there are plenty of mature javascript unit testing frameworks and if your inclined to unit test your javascript already this doesn't add a great deal of overhead. Your really just testing something in JS you would have otherwise done and tested server-side.

<comment><USER21> I have to agree with you that "developing two applications" is actually simpler, especially if your application matures and when you want start developing different kinds of clients (e.g. mobile).

However, my experience is that it still has some mayor drawbacks. Javascripts frameworks (testing and otherwise) are still less mature, then their server- side counterparts are. It is not always as obvious how things should be done. There are still lots of incompatibilities between browsers. And when an error happens you can not log it (or at least you have to do more effort).

</comment></comment></comment><comment><USER22> Interesting, as Battlelog has been criticized by the gaming press including the Penny Arcade guys, who call it buggy and hard to use.

I have to say, too, that in my experience the more client-side state a web page keeps, the buggier it tends to be. Building applications this way is harder, and I hope we don't end up losing the characteristics that have made the Web so successful in the transition.

<comment><USER23> Battlelog by itself would be fine if it was just for statistics and socializing. On the PC it's also how you launch the game as there's no in game server browser. When you launch BF3 it launches origin which in turn opens your browser to battlelog. The context/app switching is annoying and slow as you go from your browser to the game and then back to the browser when it's time for a server change. When the game first was released and things were slow and buggy (in game and on battlelog) it was very painful.

<comment><USER24> I never had any problems, and I have to say it is easily the best server browser I've ever used. Valve's pre-TF2 updates one (still toggleable back on) is probably the only other one I've actually _liked_ before. It's a huge improvement over DICE's browsers in the past, which have always been merely bad at best (the BF2 menu had to _load_ when you pressed escape).

A lot of users complained that there was no feature to allow you to wait in a queue for a full server. So... they added it. Pushed a server update. No patch, no new binaries to download. A new checkbox simply appeared.

Now, there's no reason that this has to be in browser. EA and Valve both clearly have WebKit or IE implementations (I think I heard the "clicking" noise in the Origin browser) that play nice in fullscreen games. They could certainly be integrated as part of the game interface, but Battlelog makes it clear to me that HTML and CSS are the way to go with video game server browsers in the future.

<comment><USER23> During the first few days the game was out I routinely received errors trying to get the server list at all but as I've said, they have been incrementally improving battlelog since release. My biggest complaint is that the server browser isn't available in game. The game completely closes when leaving a server from in game or closing a game from battlelog. Then it has to be relaunched when starting the next game. This is really slow for many of us and there doesn't seem to be a very good reason for it. The use of origin also doesn't add anything for the player. I also would prefer being able to launch the game directly without having to open three applications (origin, browser, bf3).

</comment></comment></comment></comment><comment><USER25> FYI, Armin doesn't mention it in his article but the guys that built Battlelog, ESN, is releasing the web framework behind it: <http://www.esn.me/product/planet/>. They also have a great service, BeaconPush similar to Pusher, only better IMO. Both because it supports the notion of users and also it has both a Flash websocket and XHR long polling fallback where as Pusher only has Flash websocket fallback (believe me, this matters, I've tried both).

</comment><comment><USER26> We are a startup called Glancee. We build a mobile app (iphone version + android version) that finds people in your area with friends or interests in common with you. The apps are native objective-c and java apps, and the backend is a mix of python, mondodb, and a bit of erlang.

A month ago we decided to build a facebook app to reach users that don't have a smartphone. We chose not to change one bit of code in the backend, and we were able to build the web app in 3 weeks with backbone, jquery, and websocket-js.

You can try it here: <http://apps.facebook.com/glancee>

The app is just one 40-line html page, the rest is javascript (and templates embedded in js). You never refresh the page when clicking a link, which gives you the feeling of using something as fast and robust as gmail.

CSS files and JS files are compressed with requirejs before being deployed, so to load the page you need three requests (plus images). Right now our biggest bottleneck is the facebook api, which is tremendously slow.

</comment><comment><USER27> My problem with Battlelog isn't necessarily that it's browser based. My problem is that I'm forced to run 2 other system based applications on top of it. Namely Origin, the sole focus of which seems to be forcing me to buy EA games through EA exclusively.

Battlelog as a stat tracker is great. As a system of convenience run in conjunction with Origin and the actual Game EXE it sux.

</comment><comment><USER28> And herewith another example of history repeating itself.

If we make the assumption that: \- The vision of Web 1.0 (mid- to late 90's) was Web 3.0 (the modern web app). \- Web 2.0 really just evolved the technologies and tools.

During the 90's we deplored thick client apps. We had 2/3/n tier on the desktop, and we wanted web apps.

Now, 15 years later, we're building 2/3/n tier apps in the browser - but we make the same architectural mistakes we made with thick clients, we ignore user control and consent, we expose devices to all sorts of attacks that don't exist in thick client apps...

That's hard-core irony, right there.

<comment><USER29> For those of us who weren't around, could you please tell me why we deplored thick client apps in the 90's? Was it just that they had to be MS Windows Win32 or MFC apps? Or is there some other reason?

</comment></comment><comment><USER30> "All the pages can be rendered on both the client side via JavaScript as well as the server. How this work I cannot tell you"

There are plenty of templating engines that have been ported to Javascript. Mustache is the first example that comes to mind: <http://mustache.github.com/>

Once you have the templating engine the rest of the logic is pretty easy to build.

Rendering web apps entirely on the client in general is pretty awesome although there are two problems: 1) the push state API is not supported in all browsers yet, which forces you to resort the fragment identifier + onhashchange to approximate the same functionality. And of course the fragment identifier only affords you a fraction of the same luxuries as the push state API. And of course onhashchange is not supported in older browsers. 2) When you fall back to the fragment identifier rendering on the client is actually a little bit slower. The fragment identifier is not sent to the server meaning the javascript has to be loaded in the browser before anything at all is rendered. Does this lead to several seconds of delay? No. But it is noticeable. At least with push state you have the option of rendering the initial content on the server and all subsequent requests on the client without increasing complexity too much, assuming you have a good templating solution in place.

But yes I agree. Modern Web Apps are Here :)

</comment><comment><USER31> > The real interesting thing about Battlelog however is a Windows PC specific > component. If you are heading to Battlelog from a Windows PC and you own the > PC version of Battlefield 3 you can launch into a game right from within the > browser. How does this work? It works with the help of a browser plugin that > exposes additional functionality to the in browser client. Namely it has a > function to start the game and pass it information as well as a general > purpose function to ping an IP address which is used for the server browser.

Unreal did that back in 1998. They register the unreal:// protocol in windows so any hyperlinks that contain an address such as unreal://127.0.0.1 will launch the game and connect to that ip. The good thing about this is that it can also be used by third party websites such as promoting your clans server and it is completely browser independent. I don't know if it could be abused to "rickroll-launch" the game but i haven't heard of any such incidents.

<comment><USER32> I was thinking this as well. Why not just register a protocol handler calling out to the battlefield client. Seems much more x-browser. Why wouldn't that work, and why is the browser plug-in real interesting? What am I missing?

<comment><USER33> You are missing the two way communication that is impossible with URL handlers. A URL handler can only transmit information in one way and cannot do that implicitly. The user has to click on that link.

</comment></comment></comment><comment><USER34> I don't see how this is different than using any of the myriad javascript mvc style frameworks that are out there in tandem with websockets.

<comment><USER35> I'm glad to see someone on here doesn't think this is quite so sensational. The only relatively new thing they've done is launching the native game from the browser plugin - and I also wondered if a custom URL scheme would not work instead (and be simpler).

In terms of game manufacturers it is light years ahead of what they've done before. I just don't see why the author is quite so blown away by it..

<comment><USER36> I tend to agree with you. XSLT web apps can render on the client and just transmit XML. Same idea. GWT does this too. And I'm sure there are older examples.

</comment></comment></comment><comment><USER37> Now that the client is the MVC execution environment with the client-server interaction used mostly for data replication, plus some extra invokable server-side behaviours, we can congratulate ourselves on having more-or-less reinvented Lotus Notes.

</comment><comment><USER38> I was surprised to only see one brief mention of GWT in this comment thread. I use GWT on one of my personal projects and SmartGWT on two client projects, and even though the development process has some difficulties like long Java to Javascript compile times, it is great to be able to write/debug both client and server side code in the same IDE.

Something I read a few months ago: Thoughtworks paper on technology that described GWT as a bad idea, very well implemented. :-)

<comment><USER38> I should have added for people who are not familiar with GWT: you write your client app in Java, almost like writing a Swing app, and it gets compiled to 6 different combinations of Javascript. Google's setup code determines browser capabilities and downloads the compiled Javascript best for your environment. After that, the only data passed between client and server is model data for the UI.

</comment></comment><comment><USER39> Companies that properly implement service oriented architectures will be very well positioned to create these advanced web applications that push the computational cost of rendering the UI to the client machines. An added benefit that many overlook is the ability to execute on mobile strategies. I do not buy the idea that mobile applications will one day all be html based. Client-based applications will always produce a richer, more integrated experience. But, if you have already designed your html application to function more like a rich client. You already have the api calls that any other mobile, or desktop application would need. You have forced yourself to design the back-end based on services that encapsulate a good amount of business logic that will not have to be repeated when implementing the different "views" of your application.

<comment><USER20> That's the big win I think this architecture has, it's already an API and already ready to create platform specific implementations.

It also makes a developer program something that's quick and easy to support, again the API is ready and waiting.

</comment></comment><comment><USER40> This reminds me of Quora's LiveNode stack: [http://www.quora.com/Quora- Infrastructure/How-does-LiveNode-...](http://www.quora.com/Quora- Infrastructure/How-does-LiveNode-work)

</comment><comment><USER41> Is this phrased accurately?

 _The framework then hooks into your browser's navigation code an intercepts all page loads. Instead of letting the browser replace the page with something new on load it instead does the HTTP request via Ajax and adds an additional header to the HTTP request: X-Ajax-Navigation._

Wouldn't it be better to intercept the page leave event, rather than load?

<comment><USER42> I figure it probably just intercepts all click events, which usually trigger loads, hence "intercepting page loads".

</comment></comment><comment><USER43> Does anyone have any good examples of a substantial web app using this architecture that doesn't require purchasing a video game or creating an account? I'd like to take a look at Firebug (actually, Chrome developer tools) and experience the snappy performance the author talks about.

<comment><USER44> I like poking around the javascript "applications" of Twitter and Stack Overflow. The latter uses jQuery, and both provide for a nice code "book" to read (granted, the variables are minimised, and the code compressed, but you can fix the latter by running it through jsbeautify).

</comment></comment><comment><USER45> Worked on something similar with javascript, nginx, gevent, 0MQ, and a C backend. The only issues we had was with file uploads for transfers of large amounts of data.

How do other people do file uploads with an asynchronous web server?

<comment><USER46> I would suggest to use the nginx file upload module, which would only pass the file path to the uploaded file to your gevent/tornado app server.

<comment><USER45> Thanks, I'll check that out.

</comment></comment></comment><comment><USER47> to get battlefield 3 working on ma friends windows vista pc i had to install 215 updates. it took 6 hours. why? because the machine had to have IE9 installed even though that wasn't his default browser and wasn't the browser started when origin kicked off battlefield. so for sure this is cool in theory. the idea is certainly plausible and fun to talk about, but melding the complexity of web apps with the complexity of system apps makes me shudder.</comment>


What could you code in four hours? - <AUTHOR>

If you were allotted four hours to program anything you wanted in any language and environment, how much could you accomplish? What tips would you give to be productive?
Let's say these four hours include planning time, and any test cases/docs that need to be created. I'm talking production work.
I've heard about people coding thousands of lines of code in a few hours, how would _you_ accomplish this feat?  Creative ideas and mind hacks welcomed :) <comment><USER2> I would probably go the highest-level route I could, using tools that I am familiar with (and won't get caught in nasty workarounds due to my unfamiliarity with the platform).

In my case right now, I'd probably put together a web mashup using a container of useful platforms--Like Apache ServiceMix using Camel, ActiveMQ, CXF, etc. to grab services, munge them, and output something useful.

Then again, going super low-level might be fun too. Go to the depths of the OS or a compiler and fix an annoying persistent issue.

</comment><comment><USER3> I would think the most important thing to do first is to stop and think about the logic of the code. Plan a small and simple roadmap in your mind, or on paper if your mental memory is low.

This will save you a lot of the try-and-fail attempts, and even better, before you write a single line of code, you have a general idea of what it is that you're doing and how it is that you're going to be doing it.

</comment><comment><USER4> I'd write a programming language that targets OCaml.</comment>


Trump Names Elon Musk, Uber CEO to Advisory Team – TheHill - <AUTHOR> http://thehill.com/policy/technology/310321-trump-names-elon-musk-uber-ceo-to-advisory-team <comment><USER2> Jeff Bezos is also on this "advisory team" and he's close to a mortal enemy of Trump.

I predict this is no more than a sunshine squad for PR reasons. Trump met with Al Gore for many hours as well, then nominated the most ardent climate change denier as head of the EPA the next day. As long as that kind of thing doesn't change (e.g. Trump literally comes out and says, "OK, I was wrong, I finally believe in climate change"), there's nothing here.

Particularly when it says, "meet with the President frequently to share their specific experience and knowledge as the President implements his economic agenda." - this is a man too lazy and detached to even be interested in his own intelligence briefings ([http://www.npr.org/2016/12/13/505348507/what- exactly-is-the-...](http://www.npr.org/2016/12/13/505348507/what-exactly-is- the-presidents-daily-brief-and-why-is-it-important)). All evidence so far points to him not caring at all what new ideas this panel brings, if even paying attention at all.

<comment><USER3> While I'm not a Trump fan and don't disagree with a ton of what you say here, people need to stop with this intelligence briefings stuff.

He said he doesn't need to dedicate time to have people tell him the exact same thing everyday, but to let him know when things change. If anything, that's an efficiency gain that a site full of programmers and avid "meetings are the devil" folks should appreciate. Every time that gets cited right now it roughly translates to "person who only reads headlines."

<comment><USER4> If Trump was too busy for briefings, it wouldn't be a big deal. But the "I don't want to hear the same thing every day" is likely very telling of how little he cares about _details_. Details are important and U.S. national security is at risk if the President doesn't want to know the nuances of current events.

<comment><USER5> Especially since he has time to meet with Kanye West

</comment></comment></comment></comment><comment><USER6> I remember seeing a bunch of "Elon Musk for president!" among certain social groups. And I was thinking that's like "He's my favorite musician! I want _him_ removing my appendix!"

But that said, this is just noise anyway. It's not like these guys, however much we like them, will have any say in policy.

<comment><USER7> That reminds me of a Dylan Moran joke: "Arnold Schwarzenegger is the governor of California. There's a perfectly ordinary English sentence. How did that happen!? ... He went over to the heavy thing, and lifted it, and put it back down and didn't move it anywhere. And then he did it again, hundreds of times, and he said to people who stopped to observe this aberrant behaviour, "Look how good I am at lifting the heavy thing in my underpants." Now, that may seem a little dim. But it was they who said "You're the man. You're the one we want to deal with immigration, and water rates, and taxes, and all that."

<comment><USER8> This is nonsense.

Are you or anyone you know a completely one-dimensional person? Do you have the capacity to learn just one (and no more) topic?

Stop acting like people can't learn or have multiple passions/knowledge domains.

Please, there's absolutely nothing special or unattainable about politicians. If anything, they are the people who are most trained, set in their ways and corrupted in the most corrupted system humanity has known.

I welcome any and all outsiders.

<comment><USER9> I don't know capitalism seems pretty corrupting. I doubt people grow-up thinking gee I wish I could work for a company that hides research for years that my company produces a product that kills people and spends billions researching how to make it more addictive. or commit the largest ponzi scheme or pollute the environment or push drugs that have marginal benefit to people, etc.

Also, for every bribee in politics there's a briber as well.

<comment><USER9> not sure why I'm being down voted.

corruption - dishonest or fraudulent conduct by those in power.

CEOs and other decision makers of companies certainly have power. Several of them have hid the side effects of their products to continue making money.

I would call that being corrupt.

<comment><USER7> You're being downvoted because capitalism has nothing to do with the topic at hand. But, because I feel like tilting at windmills, I'll say this: there's nothing inherently corrupting about capitalism. Corruption is inherent to human nature and exists in socialism, communism and every other form of government ever invented.

The reason for this is humans naturally sort themselves into hierarchies and people will always strive to better their position in those hierarchies. With better position comes better chance at survival for you and future generations of you.

Money helps in the climb up the hierarchy, but it's not sufficient in most cases. Most climbs require power. Money can sometimes buy power, but it's not nearly as effective as trading favors, forging political alliances and manipulating people through blackmail.

Money influences power outside of capitalist systems as well. CGP Grey's video 'Rules for Rulers'[0] does a great job of illustrating why.

[0]: [https://www.youtube.com/watch?v=rStL7niR7gs](https://www.youtube.com/watch?v=rStL7niR7gs)

<comment><USER9> fair enough I should have just down-voted the guy above me for saying government is innately corrupt and moved on.

The more people dismiss corruption as normal in the government the more corrupt it will be.

</comment></comment></comment></comment></comment></comment></comment><comment><USER10> Did _not_ see that coming...

The cynic in me says this is entirely about PR, but if it's not, this is a suprisingly positive step in the right direction.

I'm not sure what to make of it and wonder what will come of it.

<comment><USER11> I take this as a sign that politics are out, and simple business administration is in.

Of course real cynics will yell too much power is being given to business people.

<comment><USER12> I am in awe of how quickly our distaste for lobbyists and money in politics has faded now that a woman is not running for president.

People keep saying Trump's cabinet and team is "business leaders and political outsiders" when it's hard to imagine people more "inside" than lobbyists.

</comment></comment></comment><comment><USER13> Honest question, what does this mean for all the talk of Silicon Valley doom and gloom under Trump's presidency? Was all that just fear mongering? How do we understand this move?

<comment><USER14> The doom and gloom was of course a lot of fear mongering (the Hitler comparisons grow old very quickly). Trump talked so little of policy during the campaign we really have no idea what he is going to do. That in of itself is also scary because it is an unknown. While he was not my pick for POTUS, I'm holding a wait and see attitude. Historically Trump's public views were liberal, and he leaned democrat so we'll see how his actions break from the rhetoric. So far, he certainly does not seem to be following a playbook that anyone could have guessed.

<comment><USER15> > the Hitler comparisons grow old very quickly

I agree in general. But when Auschwitz survivors make the Hitler comparison up we should listen. [https://www.washingtonpost.com/opinions/in-the-age-of- trump-...](https://www.washingtonpost.com/opinions/in-the-age-of-trump-grim- warnings-from-holocaust- survivors/2016/01/27/c65ea38c-c549-11e5-8965-0607e0e265ce_story.html)

<comment><USER16> Hitler seemed like a more capable leader though, and less of a bigot. I believe he also had better taste in furniture.

(Yeah sure downvote me all you want, gneeeh!)

</comment></comment></comment></comment><comment><USER17> How fast things change. November 4th:

"I think a bit strongly that Trump is probably not the right guy" for the presidency, and wouldn't be the best candidate to represent the U.S. abroad, he told CNBC.

Democratic presidential nominee Hillary Clinton's economic and environmental policies "are the right ones," Musk said.

From: [http://www.marketwatch.com/story/elon-musk-on-donald- trump-j...](http://www.marketwatch.com/story/elon-musk-on-donald-trump-just- no-2016-11-04)

<comment><USER18> I'm curious how things changed? Advising someone doesn't mean you have to agree with them. In fact wouldn't you want to advise someone you don't agree with? Try and direct them more towards your opinions?

<comment><USER19> "I'm curious how things changed?"

It would be one thing to prefer one candidate over the other.

But Musk's remarks are very strong.

Basically: "This man is not qualified for the job" is a very string rebuke.

And then to go on his panel? It's a little hypocritical.

Trump knows that these guys value their careers more than their credibility, and he's making Elon Musk, Mitt Romney etc. 'kiss the ring' and 'eat their own words'.

They will likely have to say positive things about Trump in the future, coming out of meetings etc..

I'm by not means a Trump fan but there are shades of brilliant Machiavellian bits about this.

<comment><USER20> _Trump knows that these guys value their careers more than their credibility, and he 's making Elon Musk, Mitt Romney etc. 'kiss the ring' and 'eat their own words'._

You really think the likes of Musk and Bezos can't sleep at night because of risk to their _careers_? These guys don't worry about credibility because they make their own credibility. This is more of a position of "I'm a captain of industry, if the President wants to call me to ask a question, I'll take the call". Doing so is both good business (good for _their_ businesses at least), and is compatible with a position of "this man is not qualified for the job", because "that's why he's got _me_ on his advisory board". If anything, it's a subtle, shrewd move on the part of Musk.

</comment></comment></comment></comment><comment><USER21> This isn't surprising.

Elon Musk and Travis Kalanick are both admirers of Ayn Rand and likely supporters of Donald Trump (although they probably couldn't express their support prior to November 8th).

<comment><USER22> I have no idea if the source is credible but a simple Google search got me this: [http://www.marketwatch.com/story/elon-musk-on-donald- trump-j...](http://www.marketwatch.com/story/elon-musk-on-donald-trump-just- no-2016-11-04)

<comment><USER23> It's credible. Here's the interview the quote came from:

[https://www.youtube.com/watch?v=Ecfn9ULApXo](https://www.youtube.com/watch?v=Ecfn9ULApXo)

</comment></comment></comment><comment><USER24> Kalanick is an obvious choice for Trump, being a self-proclaimed Ayn Rand fanboy.

Musk is a much more surprising choice, not just because of his obvious environmentalism. Both Kalanick and Musk are well-known for not being very worker friendly. At least Musk leads by example. He destroyed his own marriage through overwork and expects his employees to do the same.

<comment><USER25> To be fair to Musk he was managing two pretty revolutionary businesses at once, both of which where going through very very tough times. This puts strain on any marriage and his broke. During this tough times. He still managed to hold it together. That's superhuman.

It's not like he was a mid level white collar exec staying too long at the office.

</comment></comment><comment><USER12> Unless these people have any real and appointed power in the administration, I'm skeptical. This reeks to me of showmanship and a "carrot" to counterbalance the "stick" of political reprisal for Rs joining the Hamilton electors.

</comment><comment><USER26> Keep your friends close, your enemies closer.

</comment><comment><USER27> Which role is Peter Thiel going to play now?

<comment><USER28> maybe this IS the role he is playing? It's likely he has the ear of the president elect.

</comment></comment><comment><USER29> Literally the only good thing I have seen related to Trump's plans so far.

Hopefully won't be an illusion and this would change my perception of Musk. I really hope it won't... really....

<comment><USER30> Did you read his 100 day plan? There are some terrible and scary things in there but there are also things to like. So I'd suggest reading it.

<comment><USER29> I have read pieces of it and didn't find anything compelling really, but I guess it depends on the perspective.

<comment><USER30> I like the idea of term limits on congress. I think it makes sense. There are a few things to like in there but I tend towards the middle of the political spectrum.

<comment><USER31> We have term limits in California. What they have done is removed any institutional experience. For example, instead of having people who have specialized in an area run a committee on that topic, everybody is shuffled.

It has simply given the governor more power.

</comment></comment></comment></comment></comment><comment><USER32> Please no more politics!

I thought we were on a one week long hiatus from this crap.

Please, down vote this article if you have the ability.

<comment><USER33> The experiment was called off by dang a while back [https://news.ycombinator.com/item?id=13131251](https://news.ycombinator.com/item?id=13131251)

IMHO This is pretty relevant stuff for anyone interested in the future of the companies these men run.

<comment><USER32> it was such a refreshing experiment while it lasted.</comment></comment></comment>


The Ferengi Programmer - <AUTHOR> http://www.codinghorror.com/blog/archives/001225.html

<comment><USER2> I'd be more inclined to believe Jeff when he says he doesn't need the rules, if I had some evidence he actually knew them.

From what I can see, the problem of "overly-rule-bound developers" is nowhere near the magnitude of the problem of "developer's who don't really have a clue."

<comment><USER3> Yeah. As codinghorror's userbase goes up, its relevance declines. I'm still waiting for a "Wiley Coyote and The Don't Repeat Yourself Rule" post or something equally nonsensical.

Zed Shaw actually wrote a blog post about how these two guys were at a conference and he called him out on his shit. You can't talk tell everyone something like "real software is written by people who's income is directly proportional to their user base" when you've spent your whole life as a consultant to in house IT departments.

<comment><USER4> you know Zed worked at Bear Stearns, right.. on in house IT stuff? I was one of the people at CUSEC urging him to get the hell out of there. Ultimately BS went out of business while Zed was there, so I guess it's moot.

<comment><USER3> Yeah, he was quick to point out he was razzing Atwood. And Its been been written that the Zed Shaw personality that writes online and the Zed Shaw personality that you'd meet in meatspace are complete opposites.

But still..."Ferengi Programmer" metaphors are unclear at best, terrible at its worst. There's a way to highlight the danger you're talking about ("religious adherence to coding standards / design patterns without comprehension") without being so gimmicky and still be entertaining.

</comment></comment></comment></comment><comment><USER5> Following rules slavishly is a pretty easy target; of course you want to do X because you think it's the right idea, not just because someone else told you to do it.

But at the same time, often the only way to develop the intuition and experience to know when to follow those rules (even if it's hard) and when to break the rules is to blindly follow the rules for at least a little while so that you get a feel for them. How do they fit with your personality or problem space? Which parts seem to add value or prevent mistakes? Which parts are getting in your way? Which parts add value some of the time but not if you have to try too hard to follow them?

Any idiot can come up with a set of "rules" that other people should follow, but there are also plenty of incredibly intelligent, experienced people who have attempted to distill their knowledge for other people in that form. Dismissing them out of hand and then patting yourself on the back for it ("I'm an awesome programming precisely because I don't follow other people's rules") is not the way forward.

To me, part of being a good programmer is being able to temporarily put aside your existing notions of what's good or bad, what will work and what won't, in order to try out someone else's way of working so that you can truly internalize it and hopefully learn something new. That applies not just to following simple "rules" about how to structure your code, but to trying out new styles of development, new programming paradigms or languages, new toolsets, etc. All of those require the ability to temporarily suspend your judgment about what works and what doesn't and to just try to do something "by the book" for a bit in order to hopefully come out the other side an even better programmer.

</comment><comment><USER6> There are many ways to write a small piece of software so that it conforms to certain specs. Rules, even if arbitrary, tell a developer what is a "better way" and reduces the doubts he has about how to write that code. So developers, especially novices, like rules.

Software engineering is fundamentally about trade-offs and it seems plain rules like IF context THEN follow_recipe are not expressive enough. Like a database engine, rules based optimizer will only take you so far, for better results you need to use cost based optimizer, and learning the costs associated with each option only comes with experience.

</comment><comment><USER7> It's like human machine learning.

Rules are what you use to program programmers. If your aims are limited and it's a good set of rules, why not.

If you want to use your programmers to do something you don't know how to do, instead create an environment that evolves the right kinds of programmers and set them loose.</comment>


Moving Forward Boldly with Kin [Kik Shutting Down] - ga-vu https://medium.com/@tedlivingston/moving-forward-boldly-with-kin-ec6290a6453 <comment><AUTHOR> Posts like this one make me hate HN's strict title requirements, which you've even broken with your clarification in brackets.

The important story here is the shutdown and mass firing, but on HN it has to be told through the lens of their PR-friendly title, which is unlikely to get much attention (and that's exactly why they wrote it that way).

<comment><USER2> HN's title rule is " _Please use the original title, unless it is misleading or linkbait; don 't editorialize._" When a corporate press release uses an anodyne title to deflect attention, that's misleading—so it's well within the guidelines to change it to something more accurate. The main thing is not to overcorrect by sensationalizing it the other way.

[https://news.ycombinator.com/newsguidelines.html](https://news.ycombinator.com/newsguidelines.html)

</comment></comment><comment><USER3> Seems bizarre to me that there wouldn't be enough value in the Kik app to spin it off or at least sell it. It must be losing a lot of money to need to be dumped like this.

</comment><comment><USER4> Additional information here: [https://www.coindesk.com/in-drunken-text-kik- ceo-threatens-t...](https://www.coindesk.com/in-drunken-text-kik-ceo- threatens-to-quit-im-not-going-to-jail-for-this)

</comment><comment><USER5> I wonder if Azer Koçulu should get his NPM package 'kik' back. :)</comment>


Show HN: VSCode extension to copy/paste multiple code snippets in your workspace - <AUTHOR> https://github.com/adoi/multicopy <comment><AUTHOR> VS Code extension to copy and paste multiple snippets of code in your workspace</comment>


Ways to plot dendrograms in R - <AUTHOR> http://gastonsanchez.com/blog/how-to/2012/10/03/Dendrograms.html

<comment><USER2> I know the purpose of this is to just demonstrate/present the code necessary to plot dendrograms but a good complimentary blog post would discuss the useful of actually executing that code:

-When for instance is it appropriate to use dendrograms (hierarchal clustering) versus non-hierarchal approaches (ie. k-means clustering)?

-What does it actually mean for two observations to be clustered close together in a dendrogram (and would they also be clustered together if you uses a non-hierarchal approach)?</comment>


The "What Are Monads?" Fallacy - <AUTHOR> http://two-wrongs.com/the-what-are-monads-fallacy <comment><USER3> I think it is a cultural mismatch. The Haskell community seem to be very influenced by mathematicians and their way of describing everything as abstractly a possible. You can even see it in code examples where it is pretty common to see arbitrary one-letter variable names.

The software development community is by and large much more pragmatic and focused on solving real-world problems. They have an easier time understanding concepts and code examples when explained in the context of real-world problems.

So when the Haskell people try to explain monads, they start with the abstract definition, the monadic laws and so on, and they focus on explaining the _concept_ of a monad, rather than what they are practially useful for. Even the many infamous monad-metaphors (its like a spacesuit! No its like a burrito!) try to find a metaphor for the abstract concept of a monad, not for any practical use. For the typical developer this might seem like a lot of mathematical wanking for little benefit.

The language F# seem to have a more 'pragmatic' culture. 'Monads' are called 'computation builders' in F#, and the equivalent to do-notation is called 'computation expression'. Yeah it is just naming, but it shows a focus on the _use_ of monads rather than on the underlying mathematical concept.

A typical F# example of the use of monads - sorry, _computation builders_ is the Async monad:

      let AsyncHttp(url:string) =
        async {
                 let req = WebRequest.Create(url)
                 let! rsp = req.GetResponseAsync()
                 use stream = rsp.GetResponseStream()
                 use reader = new System.IO.StreamReader(stream)
                 return reader.ReadToEnd()
        }

This example fetches a resource over http without blocking. It is immediately obvious why this is useful. After all, similar functionality was recently added to C# through the keywords 'async' and 'await'. But in F# it didn't require the addition of new keywords but could be implemented as a library, due to support for monads in the language.

<comment><USER4> > You can even see it in code examples where it is pretty common to see > arbitrary one-letter variable names.

This is usually because Haskell functions are _really short_. For example:

        compose f g x = f (g x)

We _could_ write this with more descriptive variable names, but there are only 3 variables and they're only in scope for one very tiny line:

        compose outerFunction innerFunction argumentForInnerFunction = outerFunction (innerFunction argumentForInnerFunction)

There are certain conventions as well; if a variable must be present, but isn't used, it gets called `_`:

        first (x, _) = x

Lists tend to get a plural "s" on their name:

        elem x xs = any (map (x ==) xs)

> So when the Haskell people try to explain monads, they start with the > abstract definition, the monadic laws and so on, and they focus on > explaining the concept of a monad, rather than what they are practially > useful for. For the typical developer this might seem like a lot of > mathematical wanking for little benefit.

This is because functional programmers tends to spend the most time on writing generic, abstract, re-usable libraries. Particular applications are just thin veneers on top of these libraries. For example, I might spend most of my time writing generic, abstract code to deal with tuples. To make an application, I can just pick and choose the library code I want to use:

        type Name = String
        type Address = String
        type Quantity = Int
        type OrderID = Int
        type SKU = Int
        type Customer = Tuple Name Address
        type Order = [Tuple SKU Quantity]
        type Invoice = Tuple Customer Order

Given that I'm using Tuples for Orders, Invoices and Customers, the time I spent writing abstract code to deal with tuples wasn't "a lot of mathematical wanking for little benefit".

The time spent writing generic, abstract monad libraries isn't wasted either; by picking and choosing which monads to use, our application can automatically get error-handing, non-determinism, backtracking, exceptions, state, software transactional memory, etc.

<comment><USER5> Moreover, there are some conventions (which you followed but didn't call out) that make the single letter names clearer. Whether that makes them clear _enough_ is more debatable, but I think they're worth noting.

For values:

       f, g, h: functions
       x, y, z: numbers or generic values
       m, n, o: monadic values

For polymorphic types:

       a, b, c: arbitrary value type
       s, t, u: state or structure
       f, g, h: functor (possibly applicative)
       m, n, o: monad
       i: index

There are probably some others that I'm not thinking of, too.

</comment></comment></comment><comment><USER6> The fact that no one is able to show a canonical, succinct example of a monad makes me suspect it's multiple concepts under a single banner. But I haven't spent much time trying to understand what one is.

EDIT: Thanks for the responses. I'd love to study any resources that you found useful when learning Monads. Do you know of any?

<comment><USER7> I'd say Monads shouldn't require the use of Haskell to be understood.

I personally don't understand them.Some people told me it's a bit like "reversed" generics,some others pointed me at promises in Javascript which are "monadic".

I guess I don't understand them because I work with languages that make them either hard to implement or totally unnecessary.

<comment><USER3> F# also has monads. However both Haskell and F# has syntactic sugar which makes the use of monads convenient. Without some syntactic sugar, using mondas requires chains of nested lambdas which quickly becomes convoluted and unreadable.

E.g. you could use monads in JavaScript, but it would probably be simpler to solve the same problem without monads.

<comment><USER8> You can use the chain of nested lambdas for monads in Haskell easily. That's bearable mostly thanks to the way lambda syntax works.

</comment></comment></comment></comment><comment><USER9> It's kind of ironic that the author states "In his article, Byorgey hints at what I'm going to say, but I think it deserves to be said again, with slightly different words.", which is essentially what monad tutorials say about other monad tutorials :)

<comment><USER10> The 'The "What are Monads?" Fallacy' Fallacy?

<comment><USER11> Yeah, it's kind of like: There's a problem with too many people making blog posts with dubious metaphors for monads, so here's a blog post with another dubious metaphor for monads.

Quite liked the post, nevertheless..

</comment></comment></comment><comment><USER12> There's a bigger issue: using computational and mathematical complexity that is confusing to large swaths of mere mortal coders. This is sadly why languages, to pick on some easy target religions like PHP and so on have proliferated.

Sure it's possible to reduce LoC and look clever with ever more complex representations of computational structures, but it's another thing to write supportable code that's straightforward to debug, improve and maintain.

If someone wants to use a "research" language in production and/or want perpetual job security, there are plenty of languages for those requirements too.

(There's never a perfect Turing power language for anything, only better fits than others. Clarity for a new-hire reader should be most valued goal after functionality.)

<comment><USER13> A monad is just a code pattern. If you try to program in a style that minimises mutate state you'll probably end up inventing something like a monad. Heck, jQuery is almost a monad -- it's not a true monad but it is similar in concept.

Monads are not a big deal. Indeed they are so much of a not big deal that I expect this is a big part of the problem learning monads. People expect them to be something difficult and exotic, and go looking for hidden depths where there aren't any. I know I did when I first learned them. Eventually you break through and realise there is no hidden mystery. It's just a data type with a few functions, and they happen to be usable in a wide variety of contexts. That's what this blog post is trying to explain.

Finally, you can teach monads to new hires in a very short period of time. We do in our training courses.

<comment><USER14> I like this post because it describes specific monads and why they are useful.

If I were to recommend a basic path to understanding monads, I'd say do this:

1\. Understand `map` in the context of lists. This can be done in Ruby or Scala very easily if you don't want to get into Haskell directly.

2\. Learn about the Maybe monad (or Option in scala). Understand what mapping an Option or a Maybe means. A simplified explanation is to compare it to a list of either length 1 or 0.

3\. Learn about the IO monad in Haskell. Understand how IO monads can compose. At this point, it's ok to just say magic happens and the compiler then cause a single IO monad (the result of composing multiple IO monads) assigned to main to execute and the side effects will happen.

At that point, you've got a general understanding of how to use monads. It will actually take you pretty far.

One key point that might be a hangup is going from `map` meaning "apply this function to every element and return a new list of the results" to `>>=` meaning "apply this function as dictated by the monad and return the result". It's probably good enough to acknowledge that `map` is a simplified case of `>>=`.

In any case, as the linked article says here, you should be able to understand specific Monads fairly quickly. Perhaps truly understanding monads means knowing when to create new monadic structures but that's hardly a prerequisite to being productive with monads.

<comment> vertex-four Haskell's IO monad is decidedly not useful outside the context of Haskell and pure functional programming, both of which I do not find fun. Are monads in general useful outside that context - for example, in mostly-imperative languages like Rust?

<comment><USER3> The IO and State monads is specifically to solve the problem of side effects in a purely functional language, so they are not really relevant in other languages.

But other uses of monads, like say monadic parsers could be useful in other languages. And list comprehensions is also based on a monad in Haskell - <USER2> functionality is clearly useful in many other languages.

But without some kind of syntactic sugar (like do-notation in Haskell) the use of monads becomes far to cumbersome, and it ends up being easier to solve the same problem in an ad-hoc manner.

<comment><USER12> Check out [https://youtu.be/xKRndVoo2ms](https://youtu.be/xKRndVoo2ms), it explains how monads can refactor messy things like call chaining if you're building SQL-like result interfaces.

<comment><USER3> In what language?

<comment><USER15> C++ it seems.

<comment><USER12> Thanks. The speaker mentions Haskell, hopefully the religion isn't so important as the code patterns.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER16> I've never really done anything seriously in Haskell, but this is how I feel monads could be explained through example. Let me know what you guys think. If it's good I'll add it to the stackoverflow question on Monads.

\---

We know how operators (add, substract, multiply,...) work on integers. example: 5 + 6 = 11.

Now let's add some extra state/dimension to integers. Let's assume this extra state is ROCK, PAPER or SCISSORS.

Here are possible values:

5_ROCK

6_PAPER

999_SCISSOR

...etc...

\---

What is the result of 5_ROCK + 6_PAPER ?

There is no answer unless someone defines it. That's what a monad does. In this case I am deciding that 5_ROCK + 6_PAPER = 11_PAPER

The way MY monad works is to use the operator on the integer portion ( 5 + 6) and then use the winner of ROCK, PAPER, SCISSORS game as the non-integer portion.

3_ROCK * 4_SCISSOR = 12_ROCK

8_SCISSOR / 2_PAPER = 4_SCISSOR

...etc...

<comment><USER17> So what is `return` (also known as `pure` or `unit`) and does it satisfy the monad laws?

<comment><USER16> Hmm... I guess Rock, Paper, Scissors game is non-associative so it does not meet all 3 laws, but I feel like that's more of a detail. Perhaps a different game would be better for an example.

</comment></comment></comment><comment><USER18> I'm really sorry author, but this is how I read your post:

> _This is like someone new to a language with regular expressions asking what > a regular expression, is, or someone new to object oriented programming > asking what a class or object is, or someone new to functional programming > asking what functional programming is, or someone new to node.js asking what > node.js is, or someone new to programming asking what a program is.

>What's _wrong_ with you people? These are horrible questions. I refuse to answer them, and you should know better than to ask. Yes, I could illustrate, but why should I?

>I prefer to just explain that it's a question that won't help you in the slightest. I'm not going to illustrate something that will, or give you any examples.

>Just do it. The important thing is, not in front of me._

Author, you could vastly improve your blog post by actually doing the teaching instead of sending the student off.

<comment><USER17> The article is criticizing people who explain monads badly, not people who are trying to learn about monads.

<comment><USER18> You didn't really read it carefully then. It's criticizing the question. You can't "criticize people who explain monads badly" without explaining monads well. Think about it.

This is like me criticizing how classes are taught, without offering my version or showing how they should be taught. Come on.

I'm afraid this post is completely without any value. It's an outline for the post that the author should write, when the author figures out how to teach monads (which don't exist in all languages) properly. Building up from several usage cases, per the author's outline.

The only problem with the outline is that it's notes to self on how to teach monads well. Well, go ahead then. Put your money where your mouth is and teach people who have never used a monad how to use a monad. Which is why they're asking.

</comment></comment></comment><comment><USER19> For the same reason, we should not say, "use the IO monad to do output". We should just say, "use IO to do output".

You may not even need the monad instance for IO -- for example, you might just use its functor instance.

<comment><USER8> Or just use the IO combinators directly (if there were exposed outside the typeclass instances).

<comment><USER19> Of course! It turns out that GHC implements the Monad instance for IO by using `returnIO` and `bindIO` in `GHC.Base`.

I played around with these as a mini demonstration of using IO in Haskell without any mention of monads: [https://gist.github.com/jameshfisher/1d735b5267e8f848b280](https://gist.github.com/jameshfisher/1d735b5267e8f848b280)

<comment><USER5> It's cute, but I think it's misleading to call it "non-monadic" \- you're calling the same functions in the same way, just not through the Monad typeclass.

</comment></comment></comment></comment><comment><USER20> Each narcissistic blogger should at least once write about monads - [http://karma-engineering.com/lab/wiki/Monads2](http://karma- engineering.com/lab/wiki/Monads2)

</comment><comment><USER21> I don't agree with the blog post since the same argument could be made for any design pattern. There is nothing wrong at trying to understand things at a higher level of abstraction.

<comment><USER15> I'm probably one of those rare programmers who has never had any real experience with OOP. I can tell you that reading about design patterns makes my head spin. I've been able to understand a few design patterns, but that has been because I've had an actual, practical problem in my code and the design pattern could be applied to solve it.

Take as an example the following paragraph from Wikipedia:

> The essence of the Mediator Pattern is to "define an object that > encapsulates how a set of objects interact". It promotes loose coupling by > keeping objects from referring to each other explicitly, and it allows their > interaction to be varied independently. Client classes can use the mediator > to send messages to other clients, and can receive messages from other > clients via an event on the mediator class.

I have no idea what that means and how and when I apply it in practise. It's just a bunch of abstract mumbo-jumbo, like an explanation of "what a monad is" will be.

So I still hold that the abstract description comes after you learn how to use the thing, not before it.

<comment><USER22> FWIW, I have done a ton of OOP experience, and I have trouble understanding most descriptions of design patterns. One you see them implemented, you generally think, oh, well, duh, I've done that before.

I think the main problem is that most programmers are terrible at explaining things, and should just stick to code examples, because they're usually a lot easier for other programmers to understand.

</comment></comment></comment><comment><USER23> i think i got what functors are in category theory ( aka morphisms between categories , IIUC ), but i can't understand what it is in haskell. There's a link missing in my head between category theory and programming language.

I also couldn't find a post or a video that would explain what monads are in cateogy theory.

<comment><USER5> First, all functors in Haskell are endofunctors in Hask. They map Haskell types to other Haskell types, and Haskell functions to other Haskell functions.

A functor in Category Theory has two parts - a map of the objects and a map of the arrows. In Haskell, when you create a Functor instance, you are saying "this type constructor _is_ the map for objects; here's how you map the arrows".

It's typically not the best place to start, but since you asked - a monad, in category theory, is a functor plus two natural transformations. In Haskell, the functor is the type constructor plus fmap from the Functor instance. The natural transformations are return (eta, in the math) and join (mu). Haskell programmers have historically found it more useful to talk about bind than join, but in the presence of fmap you can implement either from the other, so there's not much theoretical difference:

       join m = bind m id
       bind m f = join (fmap f m)

<comment><USER23> Thanks for that answer. I first thought monads were a completely different beast than functors, but considering the small number of fundamental objects category theory deals with, i had a hard time finding out what.

</comment></comment></comment><comment><USER24> Who's on first ?

No results found for "abbott and costello explain monads".

</comment><comment><USER11> Is there an rss feed for this blog?

<comment><USER15> Unfortunately no, but that's in the works. Now that several people have requested it, I've bumped it up on my list of priorities.

</comment></comment><comment><USER25> Having also struggled with Monads before having an _aha!_ moment, I've tried on occasion to help boil it down for those on the search for understanding.

The hardest thing to get is that Monads aren't quite as "tangible" (not sure of a better word) as concepts like variable, object, property, instance, function, method. They are essentially relational and require something of a mental leap akin to coming to grips with how JavaScript's event loop is bound up in the control flow of your code, which otherwise proceeds from top to bottom of a .js file; or the rules governing closures and asynchronous function evaluation in this or that language.

The following is reprised from one of my HN comments in 2013.

\</comment><comment>-

Monads are _programming patterns_ which relate a set of values to a set of of functions – that's pretty much it! For any monad X, we can say that a function is monadic if it returns a value in the X Monad. The set of values are precisely those such that the following three Monad Laws[1] hold:

[ Using JavaScript syntax, they can be approximated as... ]

Left Identity

        mBind( mReturn(a), f ) == f(a);
        // => true

Right Identity

        mBind( mReturn(a), mReturn ) == mReturn(a);
        // => true

Associativity

        mBind( mBind( mReturn(a), f ), g ) == mBind( mReturn(a),
                                                     function(a) {
                                                         return mBind( f(a), g );
                                                     } );
        // => true

Above, `a` is (basically) any value, while `f` and `g` are any monadic functions for the same Monad. The definitions of `mBind` and `mReturn` will vary depending on the Monad, but the same laws (and sometimes additional properties) hold for each group of things taken as a whole – the monadic values, monadic functions, and the `mBind` and `mReturn` pair for those values and functions.

As you can see, there is nothing special that requires a statically typed language. That being said, if your language is statically typed, and even more so if its type system has advanced capabilities (e.g. Haskell's type system), then the relationships between the monadic values and functions can be leveraged to do a number of useful things, e.g. catching a host of bugs at compile time (though that's true regardless of Monads).

If your language is dynamically typed, then you won't get those extra benefits, but you can still take advantage of the fact that Monads can abstract away a great deal of plumbing between various pieces of your program.

Sometimes the _Monad patterns_ will appear in a language under another name, or will be used "under the hood" to implement a particular API. Clojure/Script's `let` for example is essentially the Identity Monad; and its `for` is very much akin to the List Monad (the same is true for list comprehensions in other languages). The core.async library involves an inspiring application of the State Monad pattern[2].

[1] [http://en.wikipedia.org/wiki/Monad_(functional_programming)#...](http://en.wikipedia.org/wiki/Monad_\(functional_programming\)#Monad_laws)

[2] [https://github.com/clojure/core.async/blob/master/src/main/c...](https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/ioc_macros.clj#L56)

[&] [https://github.com/clojure/core.async/blob/master/src/main/c...](https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/ioc_macros.clj#L46)

<comment><USER26> I read your explanation, but couldn't make any sense of it. To begin with, you completely lost me in the second sentence:

> For any monad X, we can say that a function is monadic if it returns a value > in the X Monad.

You're defining a monad by using itself in the definition! A definition is recursive if it recurses.

I sort of understand the three laws after that, but it's like someone asking "what are operations on numbers" and getting the answer "operation is any operation that's associative, commutative, etc". It does nothing to explain monads to me, it just tells me that a monad is any thing that obeys three things. That information is completely useless to me.

<comment><USER27> > You're defining a monad by using itself in the definition! A definition is > recursive if it recurses.

The parent is not defining a monad with that sentence, he is defining what a monadic function is given that you have something that behaves like a monad

> I sort of understand the three laws after that, but it's like someone asking > "what are operations on numbers" and getting the answer "operation is any > operation that's associative, commutative, etc". It does nothing to explain > monads to me, it just tells me that a monad is any thing that obeys three > things. That information is completely useless to me.

The thing is that there is not much more to a monad than those three laws and the two functions(return and bind/join).

Nonads are remarkable because lots of things happen to behave like monads(i.e have return and bind defined in a way that follows those operations). This includes interpreters, actions with side affects, non deterministic computations, computations with the possibility of failure and many other things.

Monads are useful because they let you write code that is reusable across all monads and not just the one you happen to be coding for. If you look at code that is written like this, after enough experience you will get a vague idea of what it does, but its actual function will almost completely differ based on what kind of monad you use it for. This gives you a great amount of flexibility and refactorability as you can tweak and extent monads or create entirely new monads while still having this great mass of reusable code already written for you to use.

Like the OP says, a monad is not some tangible concept like an object or a function. It is a concept that groups other concepts together.

To learn about monads, you have to look at specific examples like the List monad, or the State monad or the IO monad. But there is no general explanation of a monad any more tangible than what the parent said.

<comment><USER26> > The parent is not defining a monad with that sentence, he is defining what a > monadic function is given that you have something that behaves like a monad

But I have no idea what a monad is, so it's all equivalent to "a blorx function is a function that returns a value in the blarx blorx". He never explained that a monad is different from a function, or that a monad is something that has values, or that you can return them, or any of the parts that make up that sentence.

> To learn about monads, you have to look at specific examples like the List > monad, or the State monad or the IO monad. But there is no general > explanation of a monad any more tangible than what the parent said.

I have a feeling that that's exactly what someone who attempts to explain what monads are should talk about. If they're a general concept, like patterns (the concept of patterns in general, not specific patterns), it is probably clearer to show how specific examples work and then how they relate to each other, so someone who doesn't know anything about them can grasp their significance.

<comment><USER18> You're not seriously asking for a definition of a basic everyday English word like monad, are you? (hmmm, Chrome underlines this word in this edit box for some reason - probably some political thing since C++, Go, and Python - Google's go-to languages - don't support this extremely mundane and everyday feature.)

Anyway it's like the word 'if' or 'except'. You just need to know about the syntax or any rules. Type "define monad" into Google if you don't know this super-basic word. (Personally, I would have thought most of us learned it when we were 3 or 4 and learning the numbers or the alphabet song). Anyway watch:

[http://google.com/search?q=define%20monad](http://google.com/search?q=define%20monad)

it clearly tells you,

>Monad: a single unit; the number one.

What could be simpler?

So we can simply understand the OP's definition:

> For any monad X, we can say that a function is monadic if it returns a value > in the X Monad.

plainly:

> For any X that is equal to the number one, we can say that a function for it > is equivalent to the number one if it returns a value that is the number > one.

in other words, the definition of a monad is just a function that returns 1 in all cases. This definition is super-simple. I have no idea why you object.

here are some examples of monads written in C:

int raise_to_zero(int x){ return 1; }

this is a monad to raise a number to 0. Here is another one:

int multiply_by_zero_and_add_one(int x){ return 1; }

this is a monad for multiplying by zero and adding one.

yet another would be:

int divide_by_self(int x){ return 1; }

You get the idea. Likewise there are monads for all sorts of times that you need a function to return one in all cases.

It's really not hard. There's nothing circular or unusual about the OP's definition. He's just using plain everyday words we've all known since second grade, in their usual meanings. I'm at a loss why you would have trouble with this.

NOTE: I'm certainly not an expert, so if I've left anything out, anyone should feel free to correct me!

( _pssst - this might be the only way of getting anything out of these folks._ )

<comment><USER26> Oh, sorry, I'm not a native English speaker, which confused things. This is the clearest explanation on monads I've seen yet. I am going to try to implement these in Python right away, I think something like "return 1" should do the trick. Version 2 will support different values of 1.</comment></comment></comment></comment></comment></comment>


Ask HN: Review 'GitHub Feed Filter' - <AUTHOR>

I've made a Google Chrome Extension -
https://chrome.google.com/extensions/detail/jcpkhafkpnaljjbgdgbehajihicjalkc - to filter the GitHub News Feed by repositories.
There is also a GreaseMonkey user script if you are a Firefox fan: http://userscripts.org/scripts/show/101729
Waiting for some great feedback :) <comment><AUTHOR> Clickable Links:

[https://chrome.google.com/extensions/detail/jcpkhafkpnaljjbg...](https://chrome.google.com/extensions/detail/jcpkhafkpnaljjbgdgbehajihicjalkc)

<http://userscripts.org/scripts/show/101729></comment>


Learn C programming and the rest will come - <AUTHOR> https://www.zeroequalsfalse.press/posts/learn-c-programming#.XHH5I3kBQA0.hackernews <comment><USER2> id probably be pretty inclined to agree with this, c was my first language back when i was like 12 and i pretty much thank that for my general ability to process programming languages (even ones unknown to me) as long as I can tie it back to that algol style of syntax. granted I haven't used it in over a decade now because I just haven't had the use case for it, but as an archetypal starting choice i think there isn't a better one for a beginner that wants a good and enriching challenge

</comment><comment><USER3> While the premise of the article is very correct, i am afraid it doesn't make the necessary convincing arguments. C should be one of the very first languages one should learn because;

 _C is a small, minimal language and hence it is quite easy to learn and keep everything in your head unlike a lot of modern languages which are too baroque and confusing. There is not much of "magic" in the language and thus "what- you- see-is-what-you-get"._

 _C is considered as "high-level assembly" and thus is the closest to the machine underneath. You will be forced to learn how computers actually work rather than treating it as a blackbox. Language Abstractions have well-defined limits._

 _C is available everywhere, from very small embedded systems to large desktops /clusters/GPUs etc. This allows one to program literally anything. I personally have programmed Windows Desktop Apps, Network Protocols/Appliances and MCUs all in C. I had to only focus on learning the Problem Domain rather than the Language/Libraries/Tools which made the job much easier._

 _C is the de-facto language for Systems programming. Thus one can avail of opportunities throughout the software spectrum both Systems and Applications. You can study and understand how "everything" works from Hardware all the way to Application Software._

 _C is also the de-facto "glue" language i.e. every other language/system/tool gives you a way to link to a C module. This gives one the ability to extend the capabilities of one's chosen language/system/tool as needed. This is often quite useful in the real world._

PS: To really understand how all the above come together through C, see the book; "Computer Systems: A Programmer's Perspective" (3rd edition:64-bit, 2nd edition:32+64-bit and 1st edition:32-bit).</comment>


Search the web without getting tracked online - <AUTHOR> http://snapsearch.online <comment><USER3> Posted this on your other, duplicate post.

Some questions:

Why is it an app? Why do I need an app to search the web? Why can't you make it a website?

Second, you claim it's private - how? How do you search Google for example? Do you proxy it through your own servers, and if so, how do you get around the captchas?

You mention there's a built-in proxy or VPN for "even more" security - <USER2> provides that and why? If the whole point of your service is to provide private searches then why are there 2 modes ("less secure" and "more secure"?) and how should a user decide which mode to use?

How does this compare to StartPage which offers the same service?

Finally, how do you explain this: [https://snapsearch.online/advertise-with- us/](https://snapsearch.online/advertise-with-us/) \- why are there Google Analytics in a private search product where the whole point is to protect your privacy against Google?

Overall, good web design, terrible product and business model.

</comment><comment><USER4> No SSL. Requires JS. Thanks, but no.

<comment><AUTHOR> SSL was a miss during the recent re-design, but it's added now.

Also, give a chance to the Android app, I'm sure you won't have complains there :)</comment></comment>


Ask HN: resources/papers about the future of programming? - <AUTHOR>

After listening to Bret Victors latest talk about the future of programming I'm trying to find more new (or old) ideas. It doesn't seem to be easy as I don't know where to start. Any recommendations for papers, sites, books for starting points? <comment><USER2> The LISP 1.5 manual [1] is quite old, fairly straightforward, but still seems 'fresh' to me.

The Arxiv [2] seems to always have to newest ideas, and CiteSeerX [3] has many, many popular (old) ideas.

[1] [http://www.softwarepreservation.org/projects/LISP/book/LISP%...](http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf)

[2] [http://arxiv.org/list/cs/recent](http://arxiv.org/list/cs/recent)

[3] [http://citeseer.ist.psu.edu/stats/articles](http://citeseer.ist.psu.edu/stats/articles)

</comment><comment><USER3> The O'Reilly Radar team are thinking about this a lot lately but I'm not sure how far they've got with sharing their ideas. A start, though: [http://radar.oreilly.com/2013/01/the-future-of- programming.h...](http://radar.oreilly.com/2013/01/the-future-of- programming.html)</comment>


Making the Best of MacBook Air Touchpad on Ubuntu - <AUTHOR> https://int3ractive.com/2018/09/make-the-best-of-MacBook-touchpad-on-Ubuntu.html <comment><USER2> I'm happy enough with the libinput driver that I don't want to go building a whole custom driver from source, but I really liked the "pixel-perfect scrolling in Firefox" tip at the end.

<comment><USER3> Same. I moved from Chrome OS to Arch Linux and this was one of the few things I missed.

</comment></comment><comment><USER4> Thank you for posting this! I recently installed linux on my MacBook Air and the biggest thing I missed from macOS was how nice the trackpad was, especially scroll inertia and 3-finger drag. Now I'm completely happy with my decision to switch.

</comment><comment><USER5> Really happy to see I'm not the only one using Ubuntu on a MacBook air! If anyone is looking for the most customizable Ubuntu desktop (and my favorite window manager since 2010), I highly recommend compiz!

> sudo apt-get install gnome-session-flashback compiz compiz-core compiz- > plugins compiz-plugins-default compiz-plugins-extra compiz-plugins-main > compiz-plugins-main-default compiz-plugins-main-dev compizconfig-settings- > manager

You'll log out of GNOME, click the settings cog, and select Flashback-Compiz. Then you'll see a wonderfully clean desktop, and then you can go into Applications -> Administration -> Compiz Config Settings, and you'll have complete and total control over your desktop!

This video is kind of gaudy but it might help explain what's possible: [https://m.youtube.com/watch?feature=youtu.be&v=Jb7kFWTj28g](https://m.youtube.com/watch?feature=youtu.be&v=Jb7kFWTj28g) MINUS the horrible sidebar, that will be replaced with an upper toolbar similar to Mac.

I actually have a proper write-up for how to get the Ubuntu Desktop you deserve using compiz, but it's very much a WIP unfortunately.

</comment><comment><USER6> This is cool, but this doesn't really work when you are running a wayland session. Also the default libinput driver on wayland already catches multitouch events with macbook without issues. The window manager just has to handle them.

I have done some exploring to get better touchpad gestures with gnome on wayland: [https://github.com/mpiannucci/gnome-shell-extended- gestures](https://github.com/mpiannucci/gnome-shell-extended-gestures) . Its an incomplete project that I work on slowly when I get the time between my job and freelancing, but slowly coming along and meets my personal needs fine.

<comment><USER7> > Pinch gestures are not handled or configured

Why would the shell ever touch (hah) these? Pinch gestures are handled by apps like Evince and EoG for smooth zooming already!

<comment><USER6> Maybe pinch gestures are not the right way to put it. Maybe spread is better? Like with 3 or four fingers spreading from or converging to center. MacOS can handle it fine.

<comment><USER7> Oh. That. The one that revealed your desktop, right.</comment></comment></comment></comment>


Pegasus for Cocoa Touch - Framework to build UIKit view hierarchies in XML - <AUTHOR> http://jona.than.biz/projects/pegasus/

<comment><USER2> It seems like a neat project, but I don't really hate Interface Builder that much.

Getting rid of all the glue code is a _really_ nice part of interface builder and this makes it so every UI element I want to use requires at least a couple lines of code.

I also don't like the idea of randomly tweaking numbers and rebuilding to see my whole interface.

</comment><comment><USER3> Just to add: I'm seeing a lot of click-thrus from Ycombinator onto my site.

This is fantastic and I'm glad people are checking it out. I'm also looking to gather requests and feedback for how it can be improved further.

Right now it's little more than a proof-of-concept with a handful of adapters for the most basic UIKit classes (UILabel, UITextField, etc. but support for UITableView, UIPickerView, etc. is still in the works).

If anyone has any feedback, suggestions and/or criticisms please do leave a comment on the site or post here and I will look into it.

</comment><comment><USER3> Developer of Pegasus here:

I hear what you say. The idea is not to necessary replace IB, but to provide an alternative.

Next step is to include layout managers (similar to Android/Swing) which will automatically lay out views based on some pre-defined templates (e.g. i*j grid, horizontal, vertical, etc.) which will remove the need for randomly tweaking numbers as you say ;-)

(Said so, this is how a lot of developers tend to work already...)

<comment> buff-a Love it. I can't stand IB.

<comment><USER3> Thanks. Please do follow the repo and check back on the site in the coming days and weeks as I will be providing a LOT of updates which will (hopefully!) make writing an interface in XML just as functional (if not more so) as writing it in ObjC/designing it in IB.

</comment></comment></comment><comment><USER4> I'll bite.. why describe your UI in XML when interface builder does it for you? How does pegasus deal with localizing your UI in different languages? This seems a bit like reinventing the wheel for very little benefit.

Who is the target developer? A new developer to the platform or an experienced one?

<comment><USER3> Thanks for your feedback.

1\. Because the XML generated by IB is completely incomprehensible for the average (or even experienced) developer. The XML from IB was never intended to be modified by the end-user. If you're talking about why you'd want to use XML at all over IB, well there are several reasons: Firstly, many advanced developers have ended up ditching IB for anything more than the most trivial interfaces, because you can only do so much with point-and-click, sooner or later it is just easier to do everything in code. Secondly, IB can become confusing when working with lots of different views which have exotic properties; you inevitably waste time clicking through submenus to find the property you're looking for -- IB simply doesn't let you have a bird's-eye view of your project and hides options away. The XML approach on the other hand gives you a single file containing your entire view, all in one place -- a true embodiment of MVC.

2\. Localisation can be done with the existing APIs that are already in place. Alternatively, one could (or I could) extend Pegasus to deal with localisation in a wide range of other interesting ways. For example, you could specify additional attributes to deal with each region, or specify a system whereby each tag is flagged with a token that relates to a string localisation table. Pegasus is simply a bridge between the XML and native UIKit controls, nothing more. You can still access all of the traditional UIKit classes and properties at runtime.

3\. I wouldn't say that Pegasus reinvents the wheel, I'd say it just offers a different way of driving the wheel. For example, on Android users are able to create their views in XML, but this functionality has not (until now) been available to iOS developers. I'm simply providing a different approach to creating a view, and while I'm at it, looking at providing a _better_ way of creating views, by completely separating code from the views, implementing useful features like hex-to-UIColor and JavaScript-CSS-Selector-style searching for views based on tags and IDs. Thanks to recommendations I've received today I'm also looking at creating layout attributes/tags whereby views can be laid out automatically according so predefined templates, something that just isn't possible currently. But it's important to remember Pegasus in its current state is just an initial proof-of-concept. I'm in the process of gathering feedback and ideas and looking to build upon it. This is definitely not the finished product.

4\. I think that this is a product that transcendes the new/experienced developer divide. Instead, let's look at the complexity of the product. I think that what Pegasus provides right now is a very fast way to prototype a UI. For beginners, this means they can write a UI without needing to know the nuances of UIKit or the details of IB (which can be daunting at first). With Pegasus, what you write is what you get, and I've tried to remove excess "fluff" and boilerplate code wherever possible (e.g. I implemented "virtual properties"). For experienced developers, I think that -- in time (not yet!) -- Pegasus can provide a way to be able to strictly enforce an MVC workflow, and to refactor and design views in a fraction of the time it could otherwise take, without having the hassles of IB or the micro-management needed in Objective-C: I just don't see why developers should have to worry about creating object references, structs and enums when all they are doing is creating a view. This should all be a totally separate workflow.

And what's more, I think that Pegasus provides a way for non-developers to be able to design UIs. Even using IB requires some knowledge of Cocoa Touch/ObjC, but with Pegasus the ultimate goal is to create a powerful platform on which UIs can be designed and prototyped with only a basic knowledge of XML.

</comment></comment><comment><USER5> Interesting. Have you thought about using JSON to describe views (like in QML)?

<comment><USER3> It's already something I'm considering for a future release.

Having said that, I'm not sure that the readability of JSON (when producing an interface like in QML) is as straightforward as XML.

<comment><USER5> Well I personally find JSON easier to read and write than XML. Though it might be different for some people, I don't know. It would differentiate the whole thing a bit more from the usual XML approach by interface builder.

<comment><USER3> Will definitely take that onboard

</comment></comment></comment></comment><comment><USER6> How stable is Pegasus now? Is anyone using it for realworld applications yet?</comment>


Shaken 101: Mitigating Illegal Robocalling and Caller ID Scams [video] - <AUTHOR> https://www.youtube.com/watch?v=xfsjLc8LM1U <comment><AUTHOR> The video is an hour, but the explanation is the first 35 minutes. The latter half is Q&A.</comment>


The Average Tech Worker in San Mateo Makes WHAT? - <AUTHOR> http://news.dice.com/2014/08/26/average-tech-worker-san-mateo-makes/

<comment><USER2> What's the median? Surely Zuck isn't the only billionaire contributing significantly to distortion of the mean?</comment>


Killing C.I.A. Informants, China Crippled U.S. Spying Operations - <AUTHOR> https://www.nytimes.com/2017/05/20/world/asia/china-cia-spies-espionage.html?ribbon-ad-idx=3&rref=world/asia <comment><USER2> I wonder whether humanity will ever ascend to a level beyond realpolitik?

<comment><USER3> I wonder if it can be proved one way or the other, whether it's even possible to ascend beyond it.

<comment><USER4> I think, individuality is a cornerstone of realpolitik. Remove it and you will have unified human hive. Does it worth it?</comment></comment></comment>


Show HN: Bot house for Slack - <AUTHOR> https://github.com/abouthiroppy/bot-house <comment><USER2> What's the use case for this?</comment>