Android now builds with Ninja instead of Make - <AUTHOR> https://groups.google.com/d/topic/android-platform/Hhl_4hfOONg/discussion <comment><USER2> Text for those who can't/won't log in for it:

      AOSP master platform builds now build with ninja instead of GNU make.
      The build/core makefiles and Android.mk files are read by kati
      (https://github.com/google/kati/blob/master/README.md), which will
      interpret them and write out a $OUT_DIR/build_$(TARGET_PRODUCT).ninja
      file, and then the execution of the build rules will be handled by
      ninja (https://martine.github.io/ninja/).

      Building with kati and ninja provides some immediate benefits:
      1. Faster startup time for new builds. Running kati and then ninja
      results in builds starting about 25% faster than GNU make.
      2. Much faster incremental builds. kati caches the mtimes of files
      and directories it read, what environment variables it used, etc., and
      only re-reads all the makefiles if something has changed. This
      includes globs like $(call all-files-under). Incremental builds with
      a warm disk cache will start within 5 seconds.
      3. Better build command output. Ninja buffers the output of each
      command and prints it without mixing output from multiple commands,
      meaning error messages will be printed as a group after a build
      failure, and not mixed with other concurrent build output. Ninja also
      prints a configurable status line that defaults to printing the
      percentage of build commands that have been run, the number that have
      been run, and the number that need to run, giving a reasonable
      approximation of the progress through the build.
      4. Incremental builds should be more reliable. Ninja considers
      outputs whose command line has changed to be dirty, which will catch
      changes to global cflags, etc. and rebuild anything that has changed.

      The use of ninja should be transparent, it is wrapped by the top level
      Makefile, so all make-based commands should continue to work.

      These changes are a precursor to a much larger change that will
      replace all the Android.mk files with data files using a format that
      provides much better error checking, even faster builds, and 100%
      reliable incremental builds.

<comment><USER3> I appreciate the sentiment, but now I have to side-scroll to read ;-)

Maybe I'm just using an unusually large font for reading hn, but I find that <pre>/indented/code blocks on hn are best limited to around 50 character width - preferably a little less - to avoid scrollbars.

<comment><USER4> if you can't get 80 columns in your viewport you need to go back to 1974 and start using 80c wide punchcards.

<comment><USER5> This may blow your mind, but I code in 40 columns. By choice. It's amazing.

<comment><USER4> only if you write in APL is this acceptable

<comment><USER5> I write in JavaScript.

</comment></comment></comment></comment></comment></comment><comment><USER6> "ninja" seems to refer to this: [https://martine.github.io/ninja/](https://martine.github.io/ninja/)

Can anyone summarise the benefits of this build system vs make? According to the manual, just speed (why didn't they just work on making "make" faster?)

<comment><AUTHOR> The post (quoted above in a comment) describes some of the features the Android engineers liked.

This old post from when Ninja was first released discusses "why not just improve make": [http://neugierig.org/software/chromium/notes/2011/02/ninja.h...](http://neugierig.org/software/chromium/notes/2011/02/ninja.html)

With another four years of perspective, I think the things Ninja does could not have been added to make without forking Make (perhaps even the build file syntax), at which point there's little point in starting with the Make code. For example Ninja builds in parallel by default (like the -j flag to Make); you couldn't make that change in Make because existing users have builds that don't work in parallel.

(Disclaimer: Ninja author, no involvement in the Android work.)

<comment><USER6> You could just set MAKEFLAGS=-j<N> in the environment. I have this in my .bash_profile:

        export MAKEFLAGS=-j$((`nproc` + 1))

<comment><USER7> As evmar already mentioned, lots of projects don't support parallel make.

</comment></comment></comment></comment><comment><USER8> I thought Google was all about Bazel these days. Anyone know why Google is pushing two apparently competing build systems?

<comment><USER9> Only two? There are more than that. For example, Android Studio uses Gradle. Go and Dart have their own build systems as well.

It might be because Google is a big company doing many things in many languages, Bazel was only open sourced recently, and so on.

<comment><USER10> Don't forget Chromium which itself has two meta build systems (gyp and gn - similar to bazel/cmake/etc.) along with an underlying build system (ninja) which can target multiple compilers and runtimes on different platforms.

P.S. Chromium is in the middle of a transition from gyp to gn[1] which is why it has two build systems.

[1] [https://chromium.googlesource.com/chromium/src/+/master/tool...](https://chromium.googlesource.com/chromium/src/+/master/tools/gn/README.md)

<comment><USER11> Good to hear the move away from gyp. The hand tuned build scripts (VS/nmake/make) before gyp were better.

</comment></comment></comment></comment><comment><USER12> As if building android didn't need more bizarre dependencies setup.

</comment><comment><USER13> how long until they get it to build properly i wonder? XD

sorry... just can't help but poke fun at these tools i've never needed except in the linux environment.

every time i get something from google and need to build it its a nightmare of poor build experience. good to know they are making an effort to improve things.

one click build ffs.

<comment><USER12> And how exactly do you build your projects? Msbuild? That's a 2 (4?) GB download.

<comment><USER14> I agree that the GP wasn't .. coherent. But I don't understand your comment. msbuild resides in (for example) C:\Windows\Microsoft.NET\Framework64\v4.0.30319

What would you need to download? It doesn't seem to be part of VS if that's what you were suggesting.

<comment><USER15> That version of msbuild isn't fully compatible with the one that lives in VS's folder, even when VS is installed. I've had it fail when trying to use it to compile stock projects made by Visual Studio, without anything fancy in the scripts.</comment></comment></comment></comment>


Questionable Science Behind Academic Rankings - <AUTHOR> http://www.nytimes.com/2010/11/15/education/15iht-educLede15.html?_r=1&src=twr <comment><USER2> While these publications try to rank universities, I engage in the smaller task of trying to rank undergraduate colleges: <http://college.mychances.net/college-rankings.php>

The decision to rank them based on students' decisions of where to attend may be questionable, but at least the "science" is straightforward.

<comment><USER3> It seems like most of the things that make a university "good" are things that a prospective undergrad, with no college experience, would be least likely to know.

I'm not implying that the current system is a a good one.

<comment><USER2> I agree, and this is why I distinguish college, which is a place that undergrads go for 4 years, from university, which is the larger institution as a whole.

For certain characteristics of colleges, I believe it is fair to see students and parents as informed consumers; e.g., when considering cost and prestige, they probably do a good job. Without anything to substantiate this, I would also guess that students do a reasonably good job of selecting institutions that will make them employable (we're getting into fuzzy territory so I don't want to make too strong of a claim).

But I agree that this method of ranking colleges would not translate into a ranking of universities as greater entities. If Kenyon suddenly made tuition free for everyone, they might lure away enough students to become the "Best" in my rankings, but it would not therefore follow that Kenyon's academic output trumps that of Princeton.

<comment><USER4> I think GP was referring to the undergrad program. For what it's worth, I haven't met many students who knew much about their degree program's curricula or their general education requirements. Not knowing this makes them seem ineffective at evaluating the college. Given all the stories I hear of, for example, art students surprised that they cannot find jobs, I'm not sure I trust incoming students as estimators of employability either. The only things I really would trust them to evaluate are the school's reputation and the first year's tuition.

<comment><USER2> To a large degree, I agree with both you and RK.

</comment></comment></comment></comment></comment><comment><USER5> My last startup was in higher ed, and the stories about manipulating ranking are amazing. Everybody knows what goes into the rankings, and everybody manipulates the inputs.

As an example, one of the inputs is percentage of alumni who donate. So one large school has a gigantic push every year to get just one dollar from every alumni that they can. I actually sat in on a seminar where somebody from the university broke down all the bizarre things they were doing with admission, freshman retention, alumni relations, and so-on, just to game US News and World Reports.

<comment><USER6> Princeton is obsessed with getting $1 from me every year for this reason.

</comment></comment><comment><USER7> The rankings are not completely worthless, but they certainly are overrated. But you ask for them.

</comment><comment><USER8> University ranking is a strange beast. On one hand, it may merely indicate the amount of endowment a university receives from its alumni per capita. On the other, it may truly rank a school by the merits of its research.

But more often than not, I find that university ranking is mostly to measure how endowed a university is, no pun intended. If a university--particularly a well-established research university--were so good, why couldn't it turn a mediocre student into a star student?

(Went to Arizona State; not exactly high on the US rankings)

</comment><comment><USER9> How about another metrics that measure the number of billionaires where they originally dropped out from? That would be interesting.</comment>


Check that your Android app was not unpublished from the Market - <AUTHOR> http://phandroid.com/2011/01/13/developers-dismayed-as-apps-wrongfully-unpublished-from-market/

<comment><AUTHOR> I got a note from a user about an hour ago that they were unable to find our app in the Android Market. A quick check of the console showed it as "unpublished". I was able to easily go in and publish (all the assets were still there), but still a pretty serious "hiccup" on the part of Android.</comment>


Facebook working on tech to let you type with your brain and hear with your skin - <AUTHOR> http://www.businessinsider.com/facebook-confirms-working-on-mind-reading-technology-2017-4 <comment><USER2> Comments moved to [https://news.ycombinator.com/item?id=14150195](https://news.ycombinator.com/item?id=14150195).</comment>


Show HN: An animated history of Reddit - <AUTHOR> http://redditsnapshots.com/play/2012/7/12/0

<comment><USER2> I'm having a spot of trouble following items through the "shuffle".

Perhaps one could divide the horizontal space such that each story gets it own invisible vertical band. A translucent coloured dot exists where the band intersects the story's present position. The dot traces a light line behind it from left to right. When the story falls off the page its band is collapsed. You know how long a story stays on the page so running out of space isn't a problem.

More simply, one could leave a single-period trail, with one terminus where the story was and the other where it is, persisting for only a moment after each shuffle.

<comment><AUTHOR> Thank you very much for your thoughtful suggestion! I'm definitely looking for ideas on how to make the animation easier to follow.

</comment></comment><comment><AUTHOR> For anyone curious, I built it using TypeScript, d3.js, mongoDB, and node.js. I'm planning to open source it after I've made some facelifts on the codebase :)

<comment><USER3> Why do you need d3.js for this ?

<comment><AUTHOR> The complexity of the project does not make it absolutely vital (the animation could be done in plain jQuery with a little more hassle), but it was fun and I wanted to try it :)

</comment></comment></comment><comment><USER4> Yarg. I wish this better-represented the fact that reddit is a platform for communities (subreddits) but so it goes. Long before subreddits, here's what reddit looked like in the first months after Steve and I launched it: <http://reddit.blogspot.com/2006/12/time-machine.html>

</comment><comment><USER5> How do you work around their suggested API limits of one request every 2 seconds and one request per-page every 30 seconds?

Edit: I see this is a history. Though the question still stands for many reddit clients. I want to use the API, but find the terms too limiting for what I want to do.

<comment><AUTHOR> Can't you use your own server to get the data you want from the Reddit API only once, and then serve this as many times as you want (since the server is yours)?

<comment><USER5> But what if I want comments from 1200 threads? It will take me 40 minutes at one request every two seconds. I understand why reddit (and other API's) do the limit, I just want to find a way to experiment w/ new commenting UI's and still withstand the HN/reddit effect when showing it off.

</comment></comment></comment><comment><USER6> needs to be a pause, some things disappear before I can even read the heading.

<comment><AUTHOR> Yeah, now the only way to pause is pressing the < > buttons at the top. I'm planning to make the navigation controls always visible, so you will be able to pause even if you've scrolled down.

</comment></comment><comment><USER7> Impressive! Well done.

</comment><comment><USER8> This only goes back one year. I would hardly call that a "history" of Reddit.</comment>


Pyre: Facebook's static type checker for Python - <AUTHOR> https://github.com/facebook/pyre-check <comment><USER2> Type hints and tools like Pyre would definitely help with large code bases. PyCharm and VSCode (with Python plugins) also does a good job of warning of possible errors. This is no competition though to languages like Haskell or even more dynamic languages like Common Lisp where the SBCL compiler generates extremely good warnings of possible problems.

</comment><comment><USER3> Does anyone know how it compares to mypy? Mypy is very slow in my experience, would love a more performant option.</comment>


Ask HN: Best place to host a prototype? - <AUTHOR>

I'm working on a startup tht allows people to search for music by title, artist, lyrics, rhythm and more, and I think I'll have a working prototype in a few days, my main problem is where to host it so that investors, the RIAA, and others can see it? <comment><USER2> What's it written in? If it's in Ruby then Heroku would be my first choice because it's so easy to deploy an app to (with no system setup).

Another option would be to run it on EC2 using a pre-built distro image with the components you need (if you can find such an image). This will be more expensive than Heroku but you can define the stack.

I'm sure others can chime in with their suggestions depending on what you developed it in.

</comment><comment><USER3> Any vserver will do, I use Linode for my production stuff, they are excellent.

If you don't want to spend time on server configuration and deployments yet, you could also use <http://pagekite.net/> to just directly expose the HTTP server running on your work machine.

(disclaimer: I am the author of PageKite, actively seeking new users. :-)

<comment><USER2> PageKite is interesting - how do you mitigate the risk of security vulnerabilities that could exist by running on a potentially unpatched machine that you use for everything else (i.e. your typical PC)?

<comment><USER3> Your personal IP address is not exposed, so you "only" have to worry about the security of the HTTP server itself.

How good or bad that is depends on what you are doing. For someone demoing static files (e.g. a web designer), running a mature HTTP server like Apache in static-only mode is almost entirely without risk.

I am also planning to add some access controls to PageKite itself, so only authenticated users' traffic is passed through to the HTTP server, but that's just vapour at the moment. :-)

</comment></comment></comment><comment><USER4> Hosts that I've been very happy with: Rackspace Cloud, WebFaction, and Linode. If you don't expect too much load or traffic at this point, the easiest/cheapest solution would be to go for WebFaction (or Rackspace Cloud if you need a VPS. They have a slightly cheaper entry point pricewise than Linode).

</comment><comment><USER5> We use a combo of github/heroku. What has been especially nice is how easy it is to transition between people working on the project. As people come and go I can give/takeaway access and they can easily download the code, make some changes then push to staging or production.</comment>


How realistic is to find one lead engineer who knows many prgramming languages? - <AUTHOR> My cofounder and I have an app developed for iOS/Android plus backend via an outsourced team.
I am a non-tech cofounder (UX/UI/marketing guy) and my partner is the tech guy. Even though he is a software engineer by trade, he has been a project manager at Motorola for more than a decade so he does not know enough of the devlopment to touch the code. This is the reason we chose a third party initially and we rather paid for the development of the MVP (or MDP). We self-financed it (about $55K) and bootstrapped it up until now and it's time to bring in a lead developer who can finetune and iterate it to meet product/market fit and maybe clean up the code here and there if needed. Especially android. We got some good initial feedback from a few testers, and in general people like the concept of the app (it is a social app) but nothing more. And no traction at all.
This is the stage where we are heading next: 1.	Iterate to find product/market fit 2.	Try to get some traction that is meaningful enough to start fundraising<p>We want to offer equity rather than salary.
The programming languages that are used are: Android: Java (strong knowledge) iOS: Objective C Server: PHP Cake DB: MYSQL Deployment: Jenkins + AWS. How realistic is it according to your opinion to find such software engineer who knows it all? Thank You in advance for your honest replies. <comment><USER2> It's not unrealistic, I personally code on all these technologies (primarily on iOS and android native), but such engineer can be pretty costly and might not come on equity only easily.

Minimum experience of such engineer should be 6 to 10 (I'm 10) and they are either working on a pretty niche good paying job or running their own stuff, or selling their services as outsourcing firm (I do this, and have team of 30 other developers also).

Apart from this,even if you hire such engineer he would be able to do one piece only at a time and that's not good for today's time-to-market dynamics.

Also, you've paid already good for MVP (did you hire a local US firm?), I do most of the MVPs under 10 K, and price increase only when functionality is large, you don't need to develop things from scratch these days.

nevertheless, my best suggestion to you would be:-

1\. Hire a person as CTO or Tech lead, who know 1 or 2 of technologies you're looking for, but may not necessarily do all the coding. 2\. His KRAs should be architecture creation, leading everything tech at company, align business goals with tech. tasks, hire an execution engineering team, and get the stuff done by day to day management.

3\. Allow him to vet and hire development agencies or teams, negotiate on deliverable while you give him a realistic budget, and then give him realistic development goals.

One guy can't do it all (even if he knows it all), a whole team of mobile dev inhouse is more costly than hiring a developer agency (it should be a good one though) so decide accordingly.

Feel free to ask me for any further discussion on topic, my site is [http://www.agicent.com](http://www.agicent.com).

<comment><AUTHOR> Thanks for your input. We are actually trying to get away from this way of working because it does not work any more. As we have an MVP, we want to get towards some initial traction and if feedback leads us to some direction then take aim in that direction and then if everything goes well then fundraise. Your type of company has great value early on to get an MVP or MDP but we got to a point where we want in house people to do it who concentrate only on this app. I appreciate your feedback though and will keep you in mind.

<comment><USER2> I hear you, so apart from hiring an agency, my advise remains stick to following:-

1\. Hire at least 3 people and not 1. 2\. One Can be senior with an ability to work on multiple techs, while other 2 can be even fresh engineers (around or under 6 months of exp in their respective technology i.e android or iOS etc) and they shall scale themselves up in good company (It's tried and tested by many entrepreneurs, including myself). 3\. Utilize that senior tech guy more like CTO, architect, and backbone programmer (one who takes care of DB, APIs, troubleshooting, guiding, figuring out libraries to use, pros and cons of various tech. stakes etc) and remaining 2 fresh would do all sort of coding in less cost.

<comment><AUTHOR> Thanks for your advice!

<comment><USER2> np, take care.

</comment></comment></comment></comment></comment><comment><USER3> Depends on what level of knowledge you need.

If it's a run-of-the-mill social app then it shouldn't be too hard finding someone that knows "enough" to get the job done. I'll say this, though; in general, the types of people that know it "all" would prefer not to work in PHP.

<comment><AUTHOR> Thanks Davel for your input. Out of curiousity what would be the one that is more favorable to PHP. Thanks

<comment><USER3> Sarcastically: mostly anything.

Realistically: mostly anything, e.g., Rails, NodeJS, Elixir. Even Java, but I'd lean away from that from a resource perspective.

</comment></comment></comment><comment><USER4> I don't think it's unrealistic. I personally could handle all of that except the Android part (but it's nothing I couldn't learn)

Many experienced programmers could cover most of it, if not all.

<comment><AUTHOR> Thank you for your input! I really appreciate it. If you don't mind asking me, when a professional like yourself chooses a programming language to learn, what are the criteria based on what you make your decision?

<comment><USER4> iOS and Android are kinda a given. I personally prefer to use their native languages (Obj-C / Swift and Java) but that's just me not wanting to deal with interpreters and such from React Native, phonegap, etc... The native languages are perfectly capable IMO so no need to add another layer of complexity.

Web development is a different issue; If the site needed chat features, I might choose a Parse server or integrate with Firebase or other realtime NoSQL servers. Some form of MySQL IMO is always a requirement as eventually, you'll want to run reports and such and still IMO there isn't a NoSQL server that can handle it better then an SQL server. Hosting is it's own animal - Rackspace, AWS, Google Cloud, Microsoft Azure - pick your poison. If you need to keep server costs low and want to scale quickly - AWS. Don't need to scale quickly but need a load balancer / cdn / backups - Try Rackspace. Don't need a CDN? Try Digital Ocean. Tons of different price points; capabilities, etc... I've run sites on most and most can handle most projects; just depends on specific business needs and experience of the sys admin. Some don't like the complexity of AWS; some are ok with it. Some prefer DO; some want Windows servers (Azure)

<comment><USER3> The point of React Native and the like isn't that the native environment isn't "capable", it's that writing and maintaining two codebases is a different type of complexity that isn't always worth the tradeoff.</comment></comment></comment></comment>


Pubsub on IPFS - <AUTHOR> https://ipfs.io/blog/25-pubsub/ <comment><AUTHOR> I ended up on this page after reading this:

[https://news.ycombinator.com/item?id=14409187](https://news.ycombinator.com/item?id=14409187)

There are some parallels here in the work, it would be interesting to see an SSB styled application built on top of IPFS.</comment>


Ganeti: An alternative Hypervisor Manager - <AUTHOR> http://www.ganeti.org/ <comment><USER2> Some previous discussions

[https://news.ycombinator.com/item?id=926243](https://news.ycombinator.com/item?id=926243)

[https://news.ycombinator.com/item?id=2503824](https://news.ycombinator.com/item?id=2503824)

<comment><AUTHOR> Oh, shoot. I even searched but not far back enough, nevermind. I found tangential comments in threads, but I had not seen direct mention of Ganeti in a while.

I was very intrigued when I saw docs for parts Python, parts Haskell.</comment></comment>


Show HN: Twitter Lists Redux, Chrome extension that makes lists more convenient - <AUTHOR> https://chrome.google.com/webstore/detail/twitter-lists-redux/kcincllgjifchjihkklkcfdniofcjahb <comment><AUTHOR> The strangest thing about Twitter's lists on the web app is that they're this really useful feature for making sure your timeline isn't filled with noise, yet everything to do with lists is at least 2 clicks away.

At first, I just used another client, but I kind of actually liked the Twitter web app (conversations are much easier to discover). So I decided to make an extension to make lists easier to use, by promoting them to be a first class feature and always readily available.

Enjoy!</comment>


Docker in Practice – A Guide for Engineers - <AUTHOR> https://zwischenzugs.wordpress.com/2015/03/14/docker-in-practice-a-guide-for-engineers/

<comment><USER2> Do you plan to keep updating the electronic version of the book after the print version is published?

Since docker and its ecosystem are evolving so rapidly, I'd be hesitant to buy a book now due to the fear that much of the material would be outdated within a year.

<comment><AUTHOR> Yes, we do. Much of what we're writing now we know will be outdated soon, so the structure is designed to be flexible.

It's planned to be a living text, just as Docker's a living technology.

</comment></comment><comment><USER3> How to run Docker in production:

[http://blog.terminal.com/docker-without-containers- pulldocke...](http://blog.terminal.com/docker-without-containers-pulldocker/)

When you run a docker container on terminal, we handle all of the networking and storage problems for you. In addition, we're the only place in the world that's offering live-migration of docker containers right now (metal to metal without downtime. We carry everything from the RAM state to the IP address automatically).

</comment><comment><USER4> I'm really looking forward to this book. Question, how do you deal with users outside of Linux host regarding shared folders. I'm using boot2docker, but it's painfully slow if my code base is large(10kloc).

<comment><USER5> Take a look at [https://github.com/codekitchen/dinghy](https://github.com/codekitchen/dinghy)

<comment><USER4> This is exactly what I'm looking for. Thanks. :)

</comment></comment></comment><comment><USER6> I've been looking for an in depth guide to Docker. Thus looks perfect.

<comment><AUTHOR> Thanks! Let us know what you want covered.

<comment><USER7> The one thing I've spent most time getting right with Docker is networking. It's so different from FreeBSD Jails.

I believe a guide with how to setup a dns container with a dns slave container and get other Docker containers to use the dns containers could be a good introduction to how Docker networking actually work.

<comment><USER8> Networking with Docker is a pretty hefty topic. One of the interesting things talked about in the book in this area is skydock[1], which provides automatic dns registration inside docker when you start your containers. We've found it very handy for simulating a network of real machines!

[1] [https://github.com/crosbymichael/skydock](https://github.com/crosbymichael/skydock)

</comment></comment></comment></comment><comment><USER9> Tangent: Are there any good open source Docker books?

<comment><AUTHOR> Not that I'm aware of, but docker.com's documentation is good. For more advanced stuff, I can also recommend the Digital Ocean docs on their community site: [https://www.digitalocean.com/community/](https://www.digitalocean.com/community/)

</comment></comment><comment><USER10> Since when sysadmins are engineers?

<comment><USER2> All the developers started calling themselves "software engineers", and we wanted in on the fun too. ;-)

More seriously, I agree the term "engineer" is problematic.

[https://en.wikipedia.org/wiki/Software_engineer#Use_of_the_t...](https://en.wikipedia.org/wiki/Software_engineer#Use_of_the_title_.22Engineer.22)

<comment><AUTHOR> Useful link, thanks! I'd always used "engineer" as a more generic term for someone who "got things done" related to software. To do this you'd need to have done some form of programming, but perhaps not self-identify as such.</comment></comment></comment>


Re: New WIRED Offices - <AUTHOR> http://www.theawl.com/2015/01/re-new-wired-offices

<comment><USER2> _" I think you'll be delighted to see that we've engineered spaces that are designed to get messy, entire rooms for the implements of creative inspiration and expression."_

Awesome... I'd love to work in a place that has specially engineered rooms for creativity. The rest of the time I'd like to be on a spotless desk where I'm encouraged to "... you to proudly display a few small items at your desk"

Wired employees are soooo lucky.</comment>


Learn from Haskell - Functional, Reusable JavaScript - <AUTHOR> http://seanhess.github.com/2012/02/20/functional_javascript.html <comment><USER2> The article mentions it already, but if this style of programming piques your interest and you don't know about underscore.js, it's absolutely worth your time to check it out:

<http://documentcloud.github.com/underscore/>

</comment><comment><USER3> One might as well say "Learn from Lisp" or "Learn from ML" as there really isn't anything Haskell specific about these kind of higher order functions. If we want to learn from Haskell, the big ideas are functional purity and its type system.

<comment><USER4> The biggest idea is probably laziness.

In Haskell, everything is basically a function. Even the number 3 is really just a function that _if_ and when evaluated will return the value 3. I used that concept to to simply some JavaScript UI code a while back. I had SELECT element that I needed to populate dynamically but wanted the last option to invoke an action that allowed the user to add another option

         choice 1
         choice 2
         choice 3
         <add new choice>

I ended up populating the dropdown list using a bunch of javascript functions that looked like this

        function () { return { key: 1, value: 'choice 1' } }
        function () { return { key: 2, value: 'choice 2' } }
        function () { return { key: 3, value: 'choice 3' } }
        function () { /* do stuff that creates a new choice */ }

Not sure I would have thought of that if I had not first played with Haskell and grokked laziness.

<comment><USER5> 'In Haskell, everything is a function' is absolutely wrong. People who don't know much about Haskell often say this. There's a post by Conal Elliott about this incorrect meme: [http://conal.net/blog/posts/everything-is-a-function-in- hask...](http://conal.net/blog/posts/everything-is-a-function-in-haskell)

It's simply not true. In fact, because Haskell is statically typed, it's very easy to tell what's a function and what's not: If its type doesn't have an -> in it, it's not a function.

<comment><USER4> ... I know that 3 is not literally function in the Haskell type system but it's an easy way to explain it to people less familiar with the language (not that I assume freyrs3 is one of those).

Also, while it might be true that "people who don't know much about Haskell" often say that everything is a function, it's also the case that people who do know a lot about the language find the notion to be pedagogically useful: On page 13 of _The Haskell School of Expression_ , Paul Hudak offers that pi (which is of type Floating a => a and thus clearly not a function) _"can be thought of as a function with no arguments"_.

<comment><USER6> Also, the definition of an infinite list of ones

        ones = 1 : ones

is a non-function value, but is recursively applied to itself. Might help illustrate why this is a useful notion in Haskell.

<comment><USER7> To be precise.

"ones" is not "recursively applied to itself". "ones" is not a function. "(:)" is a function.

In actuality, "ones" is both an argument and a result of the (:) function (aka "cons").

This works in Haskell because "ones" is not an atomic value or function; "ones" is a "lazy" structure, where some of the elements's values depend on other element's values, and Haskell uses a "call-by-need" graph reduction algorithm to evaluate arbitrarily complex* computations down to values, not in any sort of sraihtforward order suggested by "argument -> function -> result -> lvalue" in an imperative or strict language.

Laziness is at the core of the runtime system's model for computing a result from a program, and it's not something you can translate line-by-line from a non-lazy program, even a functional language program.

I'm not just being pedantic. Haskell (with a runtime like GHC, required for this conversation to really make sense) really is different from other programming systems. ("Programming system"! Not just "language"!).

The runtime system ("RTS") is not just a C runtime that provides a statement language and shim over OS system calls.

The RTS is not "just" a VM like Java VM.

The RTS is (metaphorically) like perl's "perl -nple" or a SQL RDBMS query planner, where the runtime is itself a program that takes your code as input and does its own extremely sophisticated computation that is not at all visible in _your_ program's code.

[ _] Arbitrarily_ * complex, but still "causal" structures that admit at least one valid order of evaluation. Trying to define "ones = ones" or other non- disentanglable cyclic dependencies leads to a runtime failure ("<loop>" exception).

[ __] In some cases, the graph solver might practically fail to solve a graph that is theoretically solvable. Let's ignore that.

<comment><USER8> That's good info, GHC is an pretty amazing feat of engineering, there are some good summaries of STG, C--, etc for further reading:

<http://darcs.haskell.org/ghc/docs/comm/the-beast/stg.html>

[http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler...](http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/StgSynType)

[http://www.reddit.com/r/programming/comments/i4jb1/haskells_...](http://www.reddit.com/r/programming/comments/i4jb1/haskells_evaluation_isnt_magic/c21369j)

\</comment></comment></comment></comment></comment></comment></comment><comment></comment><comment>-

Also, Simon M started Google +ing about what he's up to

<https://plus.google.com/u/0/107890464054636586545/posts>

</comment><comment><USER9> I like this style of programming, but isn't there cause for concern in having such a deep call stack in JS?

<comment><USER10> Yes. V8 and other JS compilers optimize tail calls, but it's not guaranteed by the standard. (i think IE doesn't, for example)

<comment><USER11> I'm not sure where you got this idea. V8 does not optimize tail calls. It's easy to see this in the Chrome console, I just entered this now:

      var a = function(x) { if (x == 0) return 'done'; return a(x-1); };
      a(100000);
      RangeError: Maximum call stack size exceeded

<http://code.google.com/p/v8/issues/detail?id=457>

<comment><USER10> Wait, seriously? I didn't know that. Thanks for the link!

Guess it's time for me to stop relying on that behavior...

</comment></comment></comment></comment><comment><USER12> The currying function shown can be made more flexible:

       var _slice = Array.prototype.slice;

       var curry = function() {
         var args = _slice.call(arguments);
         return function() {
           var args2 = _slice.call(arguments);
           return args[0].apply(this, args.slice(1).concat(args2));
         };
       };

As can the composition func:

       var compose = function(f, g) {
         return function() {
           var args =_slice.call(arguments);
           return f(g.apply(this, args));
         };
       };

</comment><comment><USER13> I'm been experimenting with UHC's js backend. One of the things that struck me was that in Haskell if I have a function like:

        forever :: Monad m => m a -> m a

I can use it for either asynchronous or synchronous javascript, e.g

        forever :: IO a -> IO a
        forever :: ContT r IO a -> ContT r IO a

The same function can take a synchronous js function or an async js function and run it in an infinite loop. For this reason, I think that if you want to learn from Haskell in writing reusable js then you should look into monads.

<comment><USER14> Small nitpick, the type of forever is actually:

      forever :: Monad m => m a -> m b

Since it never returns a value, the resulting monadic action can be polymorphic in its return type.

</comment></comment><comment><USER15> Great article, I learned a lot from [http://blog.jcoglan.com/2011/03/05/translation-from- haskell-...](http://blog.jcoglan.com/2011/03/05/translation-from-haskell-to- javascript-of-selected-portions-of-the-best-introduction-to-monads-ive-ever- read/) as well.

</comment><comment><USER16> One bit of trouble I have with functional style programming is something like the following example: if I have an array of people with firstName and lastName properties, how would I go about returning the person with the longest full name without adding any properties directly to the objects? It is a simple map then reduce to return the maximum length, a fairly trivial modification thereof to return the full name, but when I want to return the original object, I can't think of a good way to do this.

The best I can figure is first mapping to a nested array where the first element is the object and the second is the computed property but that seems really messy. Thoughts?

<comment><USER17> The map is unnecessary. Just reduce:

        (* assuming: val total_len : string -> int *)

        List.reduce seq ~f:(fun a b ->
          if (total_len a) > (total_len b) then a else b)

It's not necessary in this case, but _fold_ is often a lot more useful than _reduce_. At least the way I think of it, the type of reduce is _'a list - > ('a -> 'a -> 'a) -> 'a_, whereas the type of fold is _'a list - > init:'b -> ('b -> 'a -> 'b) -> 'b_. The upside is that you can construct basically any type of thing you'd like, since 'b is a completely different type. The downside is that if 'a is different than 'b, you need some sort of initial value to give it.

 _edit:_ Yes, this does require you to compute string length multiple times...but keep in mind that getting string length is very cheap in languages with good strings. (That is, basically everything except C's null-terminated strings.) 99% of the time it's not going not going to matter at all. If you do care, you can map to a tuple of (original_struct,total_len) and then do the reduce and then another map to get back to your original structure, or use a fold, as I mentioned, or write a (tail-)recursive function that does it in slightly fewer operations. (Although I don't think JS has tail-call optimizations, so that's probably a bad idea if you're doing it in JS.)

<comment><USER16> Aren't I then computing the value of total_len for my largest object numerous times? That was why I went for the map, it made some sense to pre-compute the lengths and then find the largest one. Certainly I could implement some caching mechanism but that would come with some implementation complexity?

<comment><USER18> Like in a procedural language, you can precompute and keep the results. It's still more concise. I use Ocaml's tuples here to make a pair of the length/object but you could use a struct/object/array/whatever:

        let precomp = List.map lst (fun el -> ((length el), el)) in
            let get_max (l1, el1) (l2, el2) = el1 if l1 > l2 else el2 in
                List.reduce lst get_max

</comment></comment></comment></comment><comment><USER19> Funnily enough, it was learning Javascript that made my Perl use a lot more higher-order functions, so when it came to Haskell, I was already on that page...

</comment><comment><USER20> What bothers me in this with pure JS is the verbosity of "function (arg1,arg2) {return ...;}"

<comment><USER21> coffescript's sugar is pretty nice (haskell inspired)? function (a,b) {return a+b} becomes (a,b) -> a+b Hopefully in harmony we will see a shorter function syntax for environments where CS isn't an option

<comment><USER22> Not having to write `function` everywhere is pretty much the reason I started using CoffeeScript.

<comment><USER23> Why not just save snippets? I do this in emacs (yasnippet) all the time instead of constantly rewriting the same stub.

Not knocking coffescript here, just saying that "I don't want to write a specific word" is a pretty terrible reason to pick any language over another.

<comment><USER24> I guess he also doesn't want to read it everywhere and clutter up his code.</comment></comment></comment></comment></comment>


Ask HN: How do you manage your to-read articles? - <AUTHOR> I'm talking newsletter's articles or anything you find interesting but don't have time to read at that moment.I've tried Instapaper and Pocket but I'm would like to know if anyone has any more tips on this. <comment><USER2> Pocket.

Even though you already mentioned it, but it made my life so much easier.

Since I use it, I have no open tabs anymore. All articles are synced on my Mac, Tablet and Phone. When I wait on the train station for 5 minutes, it is time to read another article from my endless list of resources.

<comment><USER3> This.

Pocket is the best solution for me. It also offers the ability to add tags to each item in your list, which helps a lot. Moreover, it recommends articles that you might be interested! I really like this feature.

Also, I have a Kobo Aura H2O, which has integration with Pocket. It is amazing. I bought the e-reader for reading books, but most of the time I read the saved articles (especially the long ones). The list is endless and keeps growing.

Every few months I perform a clean-up in order to keep things manageable.

</comment></comment><comment><USER4> I have a sense of 'pressure' based on how many tabs and windows i have open. Every week or so, I'll go through them with a specific mindset (do I want self improvement, learn about math, new languages, etc) and read as much as I can stomach, and save off the rest in PDF form.

This mostly happens on my work laptop. I save these pdfs, or code snapshots, or whatever, into a nifty drive in the sd slot. Separate from work hardware. Usually I run minimum a 128gb drive. They're sorted into folders named by high level categories (ai, math, compsci, perspective, reference, etc).

Then I have a cronjob to rsync it to my home backup NAS (only when on my home net).

I do it this way because I've come to not trust the continuous availability of various online resources. Also, having done a lot of traveling in recent times, I like to take a nice fat archive of reading materials of interest with me wherever I go. It also has the benefit of providing a pseudo-index of reading items when I want to dive deeper.

</comment><comment><USER5> I use chrome extension hangout [https://chrome.google.com/webstore/detail/google- hangouts/nc...](https://chrome.google.com/webstore/detail/google- hangouts/nckgahadagoaajjgafhacjanaoiihapd) for this.

I use different chrome user profile for office & Home and suppose I don't have time to read some articles or anything,

I just send it to my home profile user (hangout) and If I found something at home which will be useful for my office work, I send it to my Office profile user.

Even TO DO List, Otherwise for long run I use Chrome Keep Extension [https://chrome.google.com/webstore/detail/google-keep- chrome...](https://chrome.google.com/webstore/detail/google-keep-chrome- extens/lpcaedmchfhocbbapmcbpinfpgnhiddi) with the labels So I would know Why I saved it.

</comment><comment><USER6> I used to use Pocket. I would save articles there, but never read them. I have saved over 10,000 links to Pocket.

Now I keep interesting articles in a new browser tab. It doesn't seem to work too well, as I have over 1000 tabs open on just my phone.

I wish Pocket (or it's alternatives) had a way to automatically group similar links together, include relevant saved links at the top of my Google search results, sort links by time-relevance (i.e., links to information that expires or become less relevant as time goes), sort links by time to consume (to create some kind of snowball effect, like paying the smallest debts first), etc.

</comment><comment><USER7> I use OmniFocus and make tasks for article/papers/books I want to read. Put them into an appropriate project, and get to them when I have time available or I'm working on that project. I imagine the same workflow would work well with any other task manager. This helps to keep it from being a pile of papers with no priority or context around them.

</comment><comment><USER8> Bookmark it, then read later? Not quite sure what problem are you running into.

I tend to have several directories - for places i asked questions or posted something, for things i want to read, but don't have time right now, for things that sound interesting, for "maybe later" and so on.

</comment><comment><USER9> Dude, go sign up for [https://pinboard.in/](https://pinboard.in/). changed my life. Perfect thing.

<comment><AUTHOR> Does it sync with more devices besides your laptop?

</comment></comment><comment><USER10> Just a folder called 'todo' in the Chrome bookmark bar. Chrome has pretty deep sync abilities these days so you can access your Chrome logins and bookmarks on any device you own.

<comment><AUTHOR> nice idea. I use Firefox and it also has a pretty decent bookmark management

</comment></comment><comment><USER11> I used pinboard, it's like a minimal version of Pocket

</comment><comment><USER12> Safari Reading List.

</comment><comment><USER13> send to kindle extension

</comment><comment><USER14> feedly</comment>


Apple cracking down on template apps - <AUTHOR> https://9to5mac.com/2017/12/08/app-store-template-applications/ <comment><USER2> This is just a blog spam reheat of:

[https://news.ycombinator.com/item?id=15881205](https://news.ycombinator.com/item?id=15881205)

[https://techcrunch.com/2017/12/08/apples-widened-ban-on- temp...](https://techcrunch.com/2017/12/08/apples-widened-ban-on-templated- apps-is-wiping-small-businesses-from-the-app-store/)</comment>


French telecom operator, Orange, threatens to sue NSA over cable tapping - <AUTHOR> http://rt.com/news/france-orange-sue-nsa-991/

<comment><USER2> > _Orange has reiterated that the privacy of correspondence and negotiations > can be broken only by special court order, and that the conditions and > reasons for such action should be clearly defined in French law_

So Orange is suing a U.S. government agency under French law? Unless the NSA or its EU affiliates beneficially own assets in the EU (that can be traced to it) this is a PR ploy.

<comment><AUTHOR> here I found more details [http://www.cbronline.com/news/tech/networks/telecoms/orange-...](http://www.cbronline.com/news/tech/networks/telecoms/orange- to-charge-nsa-for-using-cable-in-surveillance-project-311213-4153796)

"An Orange spokeswoman was quoted by Reuters as saying: "We will take legal action in the next few days because we want to know more about the eventuality that Orange data may have been intercepted."

Orange is yet to decide to whether to take an individual action or to join the current legal action launched against the federal project.

Under the surveillance programme, the federal government had collected metadata including telephone numbers, times and dates of calls, calling card numbers and the serial numbers of phones processed by various operators in the country."

</comment></comment><comment><AUTHOR> also mentioned here [http://www.cbronline.com/news/tech/networks/telecoms/orange-...](http://www.cbronline.com/news/tech/networks/telecoms/orange- to-charge-nsa-for-using-cable-in-surveillance-project-311213-4153796)

with all these "big brother" news, I almost forgot about the submarine cables - which is a simple way to get all the data.</comment>


Panolens.js: A JavaScript Panorama Viewer - <AUTHOR> https://pchen66.github.io/Panolens/ <comment><USER2> It's so hard spread the knowledge you need to link to versioned libraries. THREE.JS has a policy of basically ignoring backward compatibility with every new version prioritizing forward momentum yet this library tells you to just download the latest version which will likely break.

The library currently doesn't work if you actually follow the docs because it's not compatible with the current version of three.js

<comment><USER3> I've cloned the repo and built it with the latest three.js, v0.113.2, and it's working. There must be something in the CDN versions that's off. I've submitted a PR to the origin repo ([https://github.com/pchen66/panolens.js/pull/219](https://github.com/pchen66/panolens.js/pull/219)) but whether or not the maintainer will pick it up is an unknown. It does look a bit abandoned.

My patched repo is at [https://github.com/onion2k/panolens.js](https://github.com/onion2k/panolens.js) if you want to clone from something that works with a new version of three (it works, but some of the tests fail so that it might not be working _entirely_..)

<comment><USER2> Your PR gets several deprecated warnings and the docs still tell you to wrongly download the latest three.min.js and use panolens.min.js which are not compatible. If you actually try it you'll get an error from three.js, versions don't match

[https://jsfiddle.net/7b3p4txe/](https://jsfiddle.net/7b3p4txe/)

Yes I know I should submit a PR, but the point wasn't to fix the lib. The lib should use a versioned three.js and the docs should tell you to link to a versioned three.js, not top of tree. The point is conveying that is hard (easy to say, hard for people to discover and the knowledge to spread).

IMO Three.js should put the version in the pathname so that if you link directly their site you'll always get a specific version. This would remove the issue for all the people that don't manage to find out that linking to top of tree will break their stuff.

</comment></comment></comment><comment><USER4> Shitty page.

Can't open the examples in different tabs, because somebody thought it would be a good idea to "appify" simple webpages like this.

To everyone considering it: I beg you to stop doing things like that. Please!

<comment><USER5> There are some issues with the HTML as well: [https://twitter.com/simevidas/status/1230846370543755264](https://twitter.com/simevidas/status/1230846370543755264).

<comment><USER4> Yeah, spot on. Totally overengineered because iT's So FaNcY!

</comment></comment></comment><comment><USER6> It'd be wonderful if it worked with QTVR files, especially now that QuickTime Player 7 no longer works as of Catalina.

<comment><USER7> Hmm... since Javascript does everything nowadays, including reading and rendering PDF files which can be binary, I suppose writing a program to decode QTVR files is possible.

How about a VRML parser and renderer? Haha, the 90's is calling... [http://www.agocg.ac.uk/train/vrml2rep/part1/guide3.htm](http://www.agocg.ac.uk/train/vrml2rep/part1/guide3.htm)

</comment></comment><comment><USER8> Looks great. I've used Pannellum for viewing Photosphere images created on Android's Google Camera in the past.

[https://pannellum.org/](https://pannellum.org/)

</comment><comment><USER9> Nice! Makes me think I should put a website in front of the scrolling pano bg.

</comment><comment><USER10> Looks great, but the inertial panning doesn't quite feel right. Moves too quickly and stops suddenly.

Testing on Safari/macOS.

</comment><comment><USER11> Very cool. It works with the motion sensor

<comment><USER12> Not on the iPhone 7 though :/</comment></comment>