Angular 9.0 - <AUTHOR> https://blog.angular.io/version-9-of-angular-now-available-project-ivy-has-arrived-23c97b63cfa3 <comment><USER3> One of the nice things that Angular has you don't see in the post is... _very_ polite and courteous maintainers! [https://github.com/angular/angular/pull/33717#issuecomment-5...](https://github.com/angular/angular/pull/33717#issuecomment-553118863)

This was a fast release cycle. It was back in November 2019 we were talking about 3.7, and now it's in.

I'm not even thinking about Ivy. But it's nice to have all the nice comforts of typescript ready and working out of the box. (I mainly work in React, but dabble with angular/vue to stay up to date)

And what a smooth update process (abbreviated):

        ng update @angular/cli @angular/core
        ** Executing migrations of package '@angular/cli' **
        ** Executing migrations of package '@angular/core' **
        Your project has been updated to Angular version 9!
        For more info, please see: https://v9.angular.io/guide/updating-to-version-9

<comment><USER4> Igor seems like a good dude. I used to follow his talks and stuff from back in the AngularJS days.

</comment></comment><comment><USER5> After 2 years of Angular madness I will send my resignation and I hope I will never work with it again.

My app is a big stack of workaround stuff that might break anytime. Because that is how angular work. Some stuff work in a context and doesn't in an other. Nobody's know why ! They have so much issue on Github that they need a bot to close them after a while. They hope the bug disappear by himself ?

<comment><USER6> Meanwhile, the web apps I wrote in 2014 in react still work flawlessly.

Join us, you'll enjoy the ride!

<comment><USER7> On HN in general there is a disdain for anything other than react, probably more people of Facebook generation and admiration of it's technology like open graph, react and few other products.

Based on personal usage of React, it's no easier than angular or any JS based framework like Vue (which in my view more sensible than react). You add state management, templates, router and 1000's of npm packages to do anything simple and react soon becomes an unmaintainable nightmare with emany vulnerabilities if you do not upgrade. An app is not just simple react but many of the npm packages (although it's true in general for JavaScript eco-system which is by default is insecure and maintenance nightmare unless there is an extra amount of work done to secure it).

Angular at least provide a decent complete single framework to work with and a unified documentation, there are issues with it, but react is same when you need any reasonable size app from it.

React gives you an easy start with false sense that it's easy, than becomes just too convoluted and complicated with the addition of different components as soon as app starts growing. Maintaining and upgrading apps based on react is very difficult as one version to another it introduces breaking changes. Angular had similar thing from angularjs to angular 2, but slowly they made it much better but letting compiler do more work.

Ivy tree shaking compiler will give a fight to upcoming compiler framework like svelte and keep the size smaller and may be in some cases much smaller than react app bundles, will wait for the benchmarks and size comparisons.

I am still waiting for a simpler way of developing web apps, elm looked very nice, but it is still far from ready for use in the same way as Angular or react yet.

<comment><USER6> Maybe the disdain comes from the fact that people don't like getting a whole house (like angular) built on shaky grounds, but prefer a clean basic foundation (like react) where they can lay whatever bricks they like on top (routing, data management).

It feels cleaner and more solid.

<comment><USER8> Your argument is flawed with a very opinionative starting point, which is that Angular wouldn't provide a solid foundation.

This is, at the very best, very debatable.

In my experience, it's the very opposite. Angular gives you very solid foundations as it's a proper framework that ships everything you need to build scalable apps. So you start from something small, and as you grow you know you can do so without rethinking the foundations of the app, as they are provided by the framework, which is Google guys, which means most likely people with a lot more experience than the average front end dev.

On the contrary, react leaves basic choices (the bricks you mentioned) to the user. While freedom can be good, it also implies that errors will be made, so you are a lot more likely to build on shaky foundations.

<comment><USER9> They are not people with more experience you are appealing to authority. The cold hard truth is that Angular got it so wrong the first go around that they had to completely rewrite the framework. The very reason was that a lot of the early guys where just out of school and built a framework on theory. If you contrast this with React, guys in the trenched trying to build applications at scale for FB, they where built with totally different mindsets. The FB guys understood the render loops that has been a pattern in UI since the desktop days and has stuck around because it works. To this day two way data binding and template based logic are both a dumpster fire, that cause unmaintainable code and side effects that cause debugging to be more difficult.

This is just a bad idea: [https://angular.io/guide/template- syntax](https://angular.io/guide/template-syntax) Without writing the tooling to debug it, to this day there is not said tooling.

<comment><USER10> ...well...on THIS day there is said tooling. In Angular 9.

<comment><USER9> This is the most comprehensive document I can find on debugging in 9 and I still do not see a way to set a breakpoint in say a loop declared in a template. I may be missing something as I have not worked on an Angular project in probably 6 months. But I don't see template debugging I see being able to get reference to a component and then manipulate said component via dev tools.

[https://juristr.com/blog/2019/09/debugging-angular-ivy- conso...](https://juristr.com/blog/2019/09/debugging-angular-ivy-console/)

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER11> The only thing I like about Angular is the dependency injection of services. Having "services" managed for you and just picking and choosing what you want is pretty nice.

What I don't like is the verbosity and boilerplate... here's 2 examples:

\- Routing boilerplate is convoluted and time consuming. I think Nuxt.js has a much nicer implementation of SPA routing, where the filesystem is used to map the routes.

\- Angular modules are verbose, redundant and don't even truely encapsulate dependencies anyway. You can easily create implicit dependencies by relying on services instantiated in higher level modules.... which is bad

I love using Typescript though!

<comment><USER12> Another benefit in my mind is that Angular is "batteries included" \- you get everything you need in a single library, e.g. routing is a big one.

From what I understand of React, you need to pick and chose the libraries (and versions of those libraries!) to use for your app, and then keep the versions of all the different libraries up-to-date and in sync with each other. Sounds like a maintenance nightmare.

<comment><USER13> It has probably been improved since I last tried it but this is one of the reasons I picked Angular over React. Having a router, HTTP client, forms, i18n, etc. out of the box compared to having to find/evaluate/integrate/maintain the various libraries that build on React to get the same functionality was a great benefit.

The other reason is the first class TypeScript and RxJS support.

</comment></comment></comment><comment><AUTHOR> I just updated my mid-size app from v8.2 to v9 with Ivy, and the total es2015 bundle size decreased from 973 KB to 669 KB. An over 31% improvement with no effort on my part!

<comment><USER14> > _973 KB to 669 KB_

Is that minified and gzipped?

<comment><AUTHOR> Just minified. Gzipped size is now 225 KB.

<comment><USER15> Great!

</comment></comment></comment></comment><comment><USER14> Will be interesting to see how it fares in the Js Benchmarks:

[https://krausest.github.io/js-framework- benchmark/current.ht...](https://krausest.github.io/js-framework- benchmark/current.html)

<comment><USER16> What happened to React? It's on the wrong end of almost all of those micro benchmarks.

I know micro benchmarks don't tell the whole story, but when you consistently wind up on the slow end it's not a good look.

<comment><USER17> React was a mistake of the last decade. React itself is a great academic idea (i.e. pure functions, composability), but the whole React-Redux boilerplate mess (I dare not call it an "ecosystem" because that word implies harmony of some sort) is the the result of an entire generation of code monkeys and job seekers who didn't design their technology stack with any real engineering consideration, but rather on the basis of tool popularity, feeding a vicious cycle of "lean startup" companies spending a glut of VC money looking for the fastest way to hire more React code monkeys because they think "that is how you do engineering".

<comment><USER6> I have the exact opposite opinion. React is the only sane way to do web development. All other approaches are deeply flawed by either relying on imperative mutations of the DOM instead of clean declarative code, or by relying on ugly templating syntax and data attributes instead of just using JS basic constructs like react. The power of react is just at its beginning, as we can see with things like react-three-fiber that was coded in a weekend initially and which is unthinkable in any other framework.

Edit typo

<comment><USER18> I'm not a React hater (in fact, I like it a lot _when it fits_ ) but I think when people criticize React, they're actually after the one-size-fits-all attitude displayed in comments such as yours. No, React is clearly not "the only sane way of doing web development" considering the web hosts many types of markup applications, the most successful ones predating React by decades.

<comment><USER6> Only _sane_ way, you missed a word. Of course there are other ways, but they clearly flawed in my opinion. I used to hate web development before 2014 and now I love it. Php is an awful language, jquery was a nightmare. Angular makes no sense hence why it keeps reinventing itself, Vue forces you to have some logic expressed using an ad hoc language in templates like it's 2010 instead of just using JS constructs etc...

I stand by my point, I am yet to find a use case where some form of react is not the best solution. Whether it is server side rendered, a single page app, or statically rendered.

The only criticism I hear about react boil down to people complaining about bad practices that are not linked to react, but merely conflated with it, like not caring about bundle size, messing architecture or other aspects that are orthogonal.

<comment><USER19> > Vue forces you to have some logic expressed using an ad hoc language in > templates

That's not true, you can use JSX with Vue, we do use that for one of our clients and it hasn't raised issues whatsoever

<comment><USER6> You are right indeed, but from a developer point of view at that point you could be using a react based framework and your experience would be the similar to vue with JSX.

Render functions returning JSX is the key brilliant idea invented by react and the fact that vue adopted it just proves the point even more:

React or the ideas at the core of react are not the mistake of the last decade but the blessing of the last decade for web development (and more).

<comment><USER19> > from a developer point of view at that point you could be using a react > based framework and your experience would be the similar to vue with JSX

It will not, because Vue has a better integration with the data source (Vuex) and a better integration with the routing (Vue Router)

I mean, I agree that React is an awesome framework implemented upon great design ideas (pure functions and plain JS templates), but it has its shortcomings, that frankly make me still prefer Vue to React (mainly Redux and the router)

<comment><USER6> For routing react-router is just perfect. And for data source/state management there is plenty of choice, I use Apollo for global state/data source and useState for small state full interactions, I can't see how it could get simpler.

But whatever floats you boat really, the point is that the nice part of vue are inspired by react anyway. I wish the two community merged, to be honest, I see no point in dividing for such small differences.

<comment><USER20> > But whatever floats you boat really

You specifically argued against that, your arguments seem to be highly religious in nature.

I don't know how many years you've worked in the industry but if you think React will be the dominant way of building apps for the next ten years, I have some Adobe Flash developers who I'm sure would like to say a few words.

<comment><USER21> haha! Former hotshot Flash ActionScript 3 Ninja Developer reporting for duty as requested.

Seriously though, JSX and TypeScript are nothing new. Both were part of ActionScript 3, a big language backed by a powerful company (Adobe). 15 years later, nobody even remembers it existed. How am I still making a comfortable living coding today? By not getting too attached to any language or framework... they are all just tools in the end.

So let the young ones be, time will eventually teach them those lessons, sooner than they think.

<comment><USER14> Huh? AS3 had XML integrated into it?

I remember E4X and Flex but not a JSX like syntax.

<comment><USER21> It wasn't exactly like JSX, more powerful as the XML was just another program data type to work with like strings and arrays.

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER22> Huge thanks Angular team. A few years ago, my team desperately needed to pick and run with a frontend framework. After a couple months to learn the Angular fundamentals, we haven't looked back. We find the framework to be extremely intuitive and flexible enough to handle any scenario we've encountered. The productivity wins have been enormous. We have about a dozen apps and anyone on our small team can jump into any project and contribute. I can't imagine how fractured our knowledge would be if we had to stitch together multiple libraries and come up with our own constructs.

</comment><comment><USER23> Huge release with a lot of time and effort put into it. Congrats to the angular team. Couldn't imagine another framework putting in the amount of work they did in order to insure Ivy goes well.

<comment><USER24> Thank you! We're really excited to finally make Ivy generally available!

</comment></comment><comment><USER25> Just want to say that all the Angular React comparisons are dumb. It is comparing apples to oranges. Angular is a bigger framework for developing more complex stuff. Therefore of course there is a steeper learning curve. Here are comments like "react is so much more easier because it is just functions". Why not just using vanilla js because you have nothing to learn then? Or just use binary code? It is just 0 and 1.

<comment><USER20> I wholeheartedly agree, this is a false equivalency.

Angular was built specifically around avoiding an entirely different problem that the heavily debated issue here of overengineering: Multiple teams that build out complicated and feature laden systems in parallel need to make concessions to allow interoperability.

If your organization is culturally flat, Angular prevents the core of your application from diverging in unmaintainable ways.

</comment></comment><comment><USER26> Is there still a clear path from angularjs 1.x onto angular 9.0? Anyone done it recently?

Supporting a large 1.x codebase right now, and would love to start incrementally moving to angular.

<comment><USER27> AFAICT the upgrade path is still the same (0) and...it looked pretty painful when I first looked at moving from 1.x to 2.

I maintain a sizable 1.x codebase and am deciding what to move to, since 1.x is dead next year. I just don't see a good reason to go to 2+. It's a different framework. All of the UI libraries we built upon (ng-grid, angular- ui) are either gone or different enough that we will have to redo all of our code no matter what. If I have to switch frameworks anyway, I want to go with something simpler (no custom module nonsense, no annotations, no hierarchical dependency injectors, hell, no classes!) with a healthy ecosystem.

React with hooks, bootstrapped with CRA, is the clear winner for me. It's just so much more straightforward to reason about, and way faster to build things with too. I made a toy app in Angular a year ago to check it out, and had a hell of a time even getting the simple data model working right. With React, day two had me already wiring up a dashboard with charted details that responded to a calendar widget I had customized to show QoS at a glance. I was looking at Vue too before I read up on react hooks, but once I saw functional components everywhere I was...erm...hooked. Sorry.

Now if only I can convince them to let me use ClojureScript...

(0) [https://angular.io/guide/upgrade#using-a-module- loader](https://angular.io/guide/upgrade#using-a-module-loader)

<comment><USER28> What is with this bazaar conviction that classes are bad?

<comment><USER29> Objects and messages good, classes and inheritance mostly bad.

Except maybe for modelling/simulating concrete classes of objects (ie, as in Simula, the language).

Proper multiple dispatch (a la common lisp CLOS) seems rare - I'm guessing java/c++ seemed like a sane trade-off for some type safety - but they probably should've stuck to self/smalltalk (for Java) or looked to standard ml/common lisp (c++).

I still don't understand why Javascript got classes, rather than some paint on the prototype system.

</comment></comment></comment></comment><comment><USER30> I have spent a lot of time in Angular 2 and later in Angular 6. I had later switched to plain java script and used requireJS to modularize. I have my own orchestrator to route events like a pub-sub. HTML5 + CSS + plain JS is good enough for most simple UI.

<comment><USER31> This is a (currently) under-rated approach that would apply well to many sites today.

<comment><USER32> While I want to agree, at the same time I'm afraid of people creating their own frameworks, re-inventing the wheel, etc. Mind you, Angular feels like a very heavyweight framework, so that would be the other side of the coin.

Personally I wouldn't go for a vanilla JS application, not unless the script / application part of it are minimal.

<comment><USER31> I should have been more clear - my point is not so much that people should use vanilla JS rather than a framework, it's more that the majority of SPAs I'm forced to interact with could have been implemented just as well with HTML, CSS, and a relatively small amount of JavaScript - small enough to not beg for any kind of framework at all. If the nature of the app really truly demands a full-blown SPA, then by all means go all in on something like React.

</comment></comment></comment></comment><comment><USER33> How often do they release major versions? It seems every few months there's a new major version update. Having been burned once with angular, combined with this aggressive release schedule, by themselves are enough to make me not even consider angular. It could be the greatest framework in the world and I still wouldn't consider it. Not everyone is building throwaway prototypes and garbage startup code. Many people need stable libraries and frameworks that last many years and don't need time consuming updates and migrations constantly. Angular is clearly not this.

</comment><comment><USER34> Why is Angular so less popular than React?

<comment><USER35> Angular: Learn about property binding, event binding, pipes, templates, views, metadata, attribute directives, structural directives, services, modules, components, injectors.

React: Write a function that generates a piece of HTML. Use standard event handlers to manage user interactions. Update state via setState methods. Ship it.

<comment><USER36> The first time I saw this in Angular's material implementation I was completely floored: [https://material.angular.io/components/dialog/overview#shari...](https://material.angular.io/components/dialog/overview#sharing- data-with-the-dialog-component-)

The method for passing data to a dialog component is to import a magic constant and inject a data field into it's constructor? It's a completely over-engineered, nonsensical solution for a problem that doesn't even exist in React. There's so much stuff you have to be familiar with in Angular just to build the simplest features.

<comment><USER37> Don't use this library as an example of Angular code. I've written dozens of Angular apps and none of them were so over-engineered. AngularMaterial is a good example how to not design API. I'm sorry if it insults some people - <USER2> all make mistakes, it's ok, I'm sure you'll next library will be better and I understand it's too late to change API in a project, when some huge Google apps are using it.

<comment><USER36> Not only is @angular/material the most popular component library by a huge margin but it's maintained by the Angular team itself. If it's as bad as you say it is that really doesn't inspire confidence.

<comment><USER38> Yes.

Take a look at what you have to go through if you want to create a custom component in angular material (that can sit inside a form):

[https://material.angular.io/guide/creating-a-custom-form- fie...](https://material.angular.io/guide/creating-a-custom-form-field- control)

Something has gone completely wrong here.

</comment></comment></comment></comment></comment></comment><comment><USER39> I have a policy of only shipping "back-end" apps because I'm worried about performance, browser compatibility and SEO. I don't know if the situation has improved in Angular 9.

Does anybody here use Angular for their customer facing websites?

<comment><USER15> We follow the pattern Java/.NET traditional BE stacks, Vue and Angular (on this order).

So far I have only deployed Angular once in production for an IoT Dashboard.

It was based on Material Dashboard, it was good enough for the monitoring use case, but it was for on-premises deployment.

<comment><USER39> Yeah exactly. I do something similar (Angular, .NET Core) and use Angular for apps that the customer never sees.

</comment></comment></comment><comment><USER40> I've been running the RC's at least the last 6 months or more, upgrading usually within in day when the new one comes out. I've been impressed but what I've seen is that even though A9 is very good (Well done developers) when the real world hit you and your app. Its many times all the other nonsense you have to include in your app that makes it big and slow (GAnalytics,GAdsense, fb-pixel, crazyegg and and and) Still wouldn't want to code without it !:)

</comment><comment><USER41> There are no words on ESLint instead of the deprecated TSLint... :/ Would really like to do the switch, but official support by Angular is more important at my company.

<comment><AUTHOR> It's on the roadmap for Angular 10: [https://github.com/angular/angular- cli/issues/13732#issuecom...](https://github.com/angular/angular- cli/issues/13732#issuecomment-573149865)

</comment></comment><comment><USER42> What % of angular apps in production are <= 1.5?

</comment><comment><USER43> I tried updating to Angular v9 from v8 and am getting an error regarding strict mode and a "with" statement.

Anyone have any ideas?

[https://stackoverflow.com/questions/60114758/uncaught- syntax...](https://stackoverflow.com/questions/60114758/uncaught-syntaxerror- strict-mode-code-may-not-include-a-with-statement)

</comment><comment><USER44> I just upgraded and got 'Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain".' from my S3 through CloudFront.

Seems like it's not adding 'type="text/javascript"' to <script> in index.html. When adding this manually, everything works.

Just FYI if others upgrade and seem to get the same errors.

<comment><USER24> My guess is you hit [https://github.com/angular/angular/issues/30835](https://github.com/angular/angular/issues/30835). In version 8 we introduced differential loading to allow users on newer browsers to download smaller, modern bundles.

Modules, however, enforce strict mime type checking. As the comment below suggests, you should make sure your static file hosting serves JavaScript with the correct mime type.

</comment></comment><comment><USER45> Anyone know what the real world sizes of the bundles are now? Last I used Angular I couldn't get a bundle smaller than like 250-300kb

<comment><USER46> Real world e-commerce app without Ivy (Angular 8) is ~500kb gzipped

</comment></comment><comment><USER47> Angular 9 is out? The other day I thought version 4 was the latest one. It sure moves fast!

</comment><comment><USER48> What about AngularDart?

<comment><USER15> Flutter is now the only thing that matters to Dart devs.

[https://flutter.dev/web](https://flutter.dev/web)

<comment><USER49> It's interesting to see how Dart has almost been reduced to Flutter's Domain Specific Language.

</comment></comment></comment><comment><USER50> Can someone here please do a serious overview comparing the latest:

      Angular
      React
      Web Components

Things are changing so quickly, I just wanted to sort of have an overview for those of us who don't work with these frameworks daily.

[https://blog.usejournal.com/web-components-will-replace- your...](https://blog.usejournal.com/web-components-will-replace-your- frontend-framework-3b17a580831c)

Can Web Components pretty much do everything without a framework now? I think Ionic moved to it for example. If we already have our own code for loading and rendering components, using Handlebars templates, what would we need to do to make them into web components instead, or make all of ours compatible with the latest React or Angular?

 _The specifics for anyone who cares:_

When we began our own framework, way before React and Angular, we built our own, kinda "sane" reusable component engine. We called them "tools". One tool on an element is a component. But you could also add multiple tools on a component, to add or remove behaviors:

[https://qbix.com/platform/guide/tools](https://qbix.com/platform/guide/tools)

Basically, we figured it would be easier to just let Templates, HTML, CSS and JS each do what they were intended for.

 _HTML side_

1\. We had <div class="Q_Tool Streams_chat_tool" data-streams-chat='{"foo": bar, ...}'> easily exporting json from php or templating engines, very readable and completely standard (no JSX or custom components). It was just slightly longer to write but provided useful metadata. It used to be called _microformats_ back in the day. Multiple tools can be added on same element this way. The element didnt have to be a div.

2\. We had handlebars helpers like {{&tool "Streams/chat" foo=bar}} and Q.Tool.setUpElement("div", toolName, options), or pass an element instead of "div" to add a tool on an existing element. We also had a jQuery fn method like $("foo").tool("Streams/chat", options).activate() .

3\. Our users just called var element = Q.activate(Q.Tool.setUpElement("div"))) in vanilla JS or $("<div />").tool(...).activate() if jQuery was loaded.

* CSS side*

1\. We namespaced our CSS by Modulename_toolname_

2, Some tools took advantage of shared CSS classes defined in the module or a module they depend on

 _Javascript side_

1\. We just had Q.Tool.define(toolName, constructor, defaultOptions, methods) and the tool.state would be the options merged over the defaultOptions. It was all customizable and merging was done via a smart Q.extend() function that we tweaked to eg combine Q.Event handlers in the best way.

2\. Ways to access tools on an element would include Q.Tool.byId() and element.Q.tools etc. The tool ids would be autogenerated so as to establish a hierarchy of which tool was a parent. Then you could do tools.children([filterName]) and tools.parents() and so on. Traverse faster without touching the DOM.

3\. We had Q.activate(container, options) to activate tools within a certain container. Javascript for tools would be loaded on demand, and tools would be added/removed on demand. We had Q.Event.prototype.add(callback, key) take a String key or a Q.Tool, so events would be automatically removed when a tool was removed.

4\. You could also do Q.Tool.define([toolName1, toolName2], toolName, constructor, defaultOptions, methods) to have tools require that previously named tools already be activated on the element. This is for composability of tools, something more general than inheritance. Let's say you have a chatroom and you want to add support for @mentions to it and [https://linkscraping.com](https://linkscraping.com) as you type. So you'd make tools that work in top of Streams/chat.

It seems to me that ANYWAY your user will have to load a Javascript file that defined your web components. And ANYWAY they will have to load javascript on demand. And ANYWAY this javascript may be packed into a single file so you'll have to actually check whether a variable has been set before loading modules _dynamically_ so you dont want static loading. And ANYWAY your tools may want to use shared css so you may as well namespace your CSS. And ANYWAY your default options may include event handlers or other things you can't serialize easily into attributes of an element. And you may want to compose tools or find them with CSS so what's wrong with using CSS classes instead of the element name for that? And ANYWAY you will want to render your tools in a readable way so why not stuff JSON into data attributes which were allowed for exactly such purposes? And ANYWAY you may want to use a powerful templating engine like Handlebars. The only part I am not sure of is the last one.

Seems to me - but I am biased - that we have the optimal approach. If something else comes out we can just turn Q.Tool.define into a wrapper around window.customComponents.define. But our users won't have to change a thing. They can continue to use Q.Tool and Q.Page and Q.exports(arg, arg) and Q.requires(module, callback) without worrying what's underneath. Isn't it better and more stable?

But everyone got into Angular and React with its JSX etc. I think the main sell was the dirty checking (the model in Angular, the DOM in React). So you can just render a large chunk. I never saw the benefit of that. You _should_ reason about mutations imho. Components are views with their own viewmodel, that's all. You can update a bunch of state parameters and then call stateChanged("a", "b") which would requestAnimationFrame() and update stuff. Is it so hard to call stateChanged() after changing state.a and state.b ? Do you really need to instead grok digest cycles or a virtual dom??

</comment><comment><USER51> I've been going down the long road of learning Angular recently, and I love it and want to learn more, but I have a couple naive newbie questions whose answers I thought should be obvious, but I haven't been able to figure out:

Is there a standard way to define local variables in an Angular template so you don't have to repeat the same redundant expression again and again (or so you can at least give an expression a self documenting variable name so it's not so mysterious)? Or do you have to define an instance variable on your component and figure out how to initialize it to the right value before the template gets executed, with no way to lazily (or repeatedly) evaluate it by putting the calculation inside conditionals (or loops) in the template so they're not run if they're not needed (or to calculate the local variables independently for every loop iteration)? Is there an angular hook or technique that's meant for that, and efficient, and hopefully doesn't involve much arbitrary non-JavaScript gobbledygook syntax, and is at least somewhat standard and well supported? Please don't tell me I shouldn't ever want to do that for some reason of ideological purity or separation of concerns (as if a templating language could ever be called "pure" or "elegant"). The common legitimate use case is ngIf="some expression is not null" then {{some expression}}, and also ngIf="some expressions" ... ngIf="not some expression".

I googled for it, and the solutions of "abuse ngIf's special goofy syntax to name the result of the condition and pray to God it's truthy or don't bother" and "abuse ngFor to loop over an array of one item to give it a name" are not acceptable answers. There were also a few competing and possibly out-of-date "install this non-standard ngLet directive that I hacked up but don't support, but don't call it with an "ng" prefix because that's reserved for the Angular team" \-- but isn't there a standard way of doing such a simple essential thing, that the Angular team already thought of and included, such that other people will have some clue what's going on when they see it? And it would be nice to be able to define more than one variable at once per begin/end tag, if you know what I mean. Maybe even without using any begin/end tags, perchance to dream?

Also, is there a way to easily define simple light weight macros ("snippet reuse") so you can repeat the same pattern in one or more components, without defining a whole component in all its glory and splendor with multiple files that other multiple files need to import and declare? Or even a global file of shared macros that a bunch of other templates can import, like the globally shared css declarations you can include in local css files? I've seen "ng- template", but I am having a hard time getting my head around it, compared to the simplicity and power of Genshi's py:match, that's based on xpath, and py:def, that precisely follows Python function calling conventions and that you can easily call from any normal expression. And py:match is quite useful for defining concise custom tags (or xpath patterns) that can wrap embedded content. In comparison, ng-templates seems quite clumsy and limited, and confusing about calling and scoping and passing parameters and content, which is nothing like standard JavaScript calling conventions, and reminds me more of the abomination that is Zope METAL templates.

[https://zope.readthedocs.io/en/latest/zopebook/AppendixC.htm...](https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#metal- overview)

[https://en.wikipedia.org/wiki/Template_Attribute_Language#ME...](https://en.wikipedia.org/wiki/Template_Attribute_Language#METAL)

[https://en.wikipedia.org/wiki/Zope#Zope_Page_Templates](https://en.wikipedia.org/wiki/Zope#Zope_Page_Templates)

I've been using and loving Genshi with Python for more than a decade (and before that, Kid, which Genshi is almost the same as, and before that Zope page templates, TAL, and METAL templates, which inspired Kid and Genshi, but totally sucked), and I love its ability to drop into Python with <?python ... ?> to define some variables or import some functions locally in the template that you can use, with real honest to god multi-line indented Python "if" statements for logic (and Python comments for, err, commenting) instead of Christmas trees of deeply nested ternary ? : operators (or rather postfix conditional "foo if bar else baz" Python expressions). Genshi also has "with" for defining scoped local variables with tags, like <py:with vars="y=7; z=x+10">$x $y $z</py:with>.

And I also love Genshi's py:def for making locally defined or libraries of includable imperative "code snippet" templates you can call just like Python functions (with glorious optional named defaulting args, etc), and py:match for declaring xpath pattern matching templates that can wrap html content as a parameter (so the macro can cherry-pick out and transform different parts of the passed content with xpath), as well as taking attribute parameters.

Another nice feature of Genshi is that for all directives it supports both the attribute form like <div py:if="condition"> ... </div> attached to an element that you want to keep, or the element form that dissolves without leaving an element, like <py:if test="condition"> ... </py:if> . You can also attach multiple directive attributes to the same element, thanks to the way it executes them in a well defined ordered hierarchy that makes practical sense (like "for" above "if", so each iteration of the "for" loop can be conditionalized with its own "if" evaluation), and "def" above all else, so you can define a single tag macro that loops over something then conditionalizes each iteration, then sets attributes on and adds content to the included elements. It's quite concise and expressive!

<div py:def="FizzBusted(count)" py:for="i in range(count)" py:if="i % 3" py:attrs="{'class': 'orange' if i % 7 < 2 else 'blue'}" py:content="['odd', 'even'][i%2]"/>

[https://genshi.edgewall.org/](https://genshi.edgewall.org/)

[https://genshi.edgewall.org/wiki/Documentation/xml- templates...](https://genshi.edgewall.org/wiki/Documentation/xml- templates.html)

py:def

[https://genshi.edgewall.org/wiki/Documentation/xml- templates...](https://genshi.edgewall.org/wiki/Documentation/xml- templates.html#id4)

py:match

[https://genshi.edgewall.org/wiki/Documentation/xml- templates...](https://genshi.edgewall.org/wiki/Documentation/xml- templates.html#id5)

Processing order of multiple attributes (precedence rules you must remember, but they make practical sense, and at least Genshi is quite minimal and only has a few directives): py:def py:match py:when py:otherwise py:for py:if py:choose py:with py:replace py:content py:attrs py:strip

[https://genshi.edgewall.org/wiki/Documentation/xml- templates...](https://genshi.edgewall.org/wiki/Documentation/xml- templates.html#processing-order)

These two features (local variables and code snippets) are so important to me, and I'm having such a hard time figuring out how to do them in Angular, that I feel like there's whole a chapter in the Angular templating manual that I missed somehow. Thanks for any tips on how to do this kind of stuff with Angular templates!

I've written more opinions about Genshi and templating on hn before:

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

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

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

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

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

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

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

<comment><USER12> > Is there a standard way to define local variables in an Angular template so > you don't have to repeat the same redundant expression again and again

I usually define something in the component, and reference that. If you need to lazily evaluate it you can just reference a function in the component (e.g. "...{{ someFunction() }}...", and have the function do whatever lazy work and/or memoisation you need there.

If you need things to be initialised before the template is ready, you can use one of the life cycle hooks - e.g. ngOnInit(). More details of the different hooks here: [https://angular.io/guide/cheatsheet](https://angular.io/guide/cheatsheet)

... that said, it _might_ be easier (depending on context) to "learn to love the bomb" and just rely on Angular's binding to update the template as soon as the value becomes ready after the template has rendered - i.e. don't sweat about getting everything ready before the template loads, just let Angular handle the data binding and let it update the tempalte when the value _is_ ready. This is where the RxJS stuff really shines since you can forget about a lot of the sequencing and just let Angular handle getting the right value on the page when it becomes available. Unless you are doing long network calls or heavy computation, everything is usually in place by the time your brain registers seeing the page anyway so it mostly works out OK and no one notices any thrashing of templates going on under the covers (... although there is a part inside of me that dies when thinking about the performance/wasted CPU cycles).

> is there a way to easily define simple light weight macros ("snippet reuse") > so you can repeat the same pattern in one or more components

I have also suffered this recently. I am not sure how this is "meant" to be done, apart from making everything a separate component. I guess the argument is, if you need to use something in multiple places then it is an ideal candidate to become a component. For these "lightweight" components I will usually just use inline templates for the component decorator (rather than referencing a separate HTML template etc), e.g.

      @Component({selector: 'snippet-one', template:`<b>My First Snippet</b>`}) export class SnippetOne{}

You can put a load of them into a single "snippets" module, import the "snippets" module when you need it, and then simply include that where I need it in other templates with <snippet-one></snippet-one> and so on.

I agree though that sometimes it would be nice to just have a file you can just easily drop in where you need it.

<comment><USER51> Here's another newbie question, if you don't mind: What would be the optimal place to hook to get a callback to draw something in a canvas whenever the DOM is updated?

I'm currently subscribing to changes in a BehaviorSubject<any[]> instance variable of my selection service "god object":

selection service:

        public user$: BehaviorSubject<any[]>;

my subscribing component:

        constructor(
            public selectionService: SelectionService
        ) {
            this.userSubscription$ = selectionService.user$.subscribe(user => this.drawUserInCanvas(user));
        }

Is that a good way, or might I miss updates for changes to component instance variables and other reasons? Is there a canonical Angular callback that's recommended for stuff like drawing a canvas view after any changes have been made to the DOM?

Thanks for the advice!

<comment><USER12> You can use ngOnChanges callback to react to changes in the angular framework - i.e. if bindings/@Input()s/etc have changed and you want to do something special there when they change. But for just generic DOM changes happening outside of the angular framework that wont work (since angular does not know about random other DOM stuff going on elsewhere in the page and outside of the framework). E.g. if there is some static JS code in the page doing stuff to the DOM, angular won't trigger ngOnChanges for that.

For your approach, that looks reasonable to me in the 5 lines we have to look at :-) ... so long as you are consistent with the SelectionService and make sure all the changes go through that, you should be fine and your component will get all the updates.

This sort of requirement for consistent management of things like this - i.e. the application state - is a weakness of Angular I think. It is easy to start simple and end up coding yourself into a corner with god services etc. I have used a thing called NgRx in the past for managing state - its the redux pattern and seems to be quite good at making sure state is a bit more sane and well-mananged in the app (at the cost of some boilerplate). One day I hope that there is an official state management mechanism.

<comment><USER51> Thanks, that sounds like the right approach. I don't need to react to all DOM changes, but I have one jolly callback for changes to my one big happy god- owns-the-user-owns-the-world object (the observable), but the component has view-level properties like hiding and showing details, zoom and pan, etc, that aren't in the observable model, and I'd still like to redraw the canvas when they change. It doesn't take long to draw, but I just don't want to miss any updates, or have to pepper the code with explicit calls to redraw it every time I think something might have changed (causing a lot of pointless redrawing).

Fortunately my app is simple enough that I can just redraw everything whenever something changes, as long as I'm not doing it 37 extra times.

</comment></comment></comment></comment></comment><comment><USER52> How does Aurelia compare?

<comment><USER53> In my opinion, Aurelia has always been the less complicated and lighter option of the two. Aurelia 1 had some design choices that made it harder to tree shake down, but Aurelia 2 is around the corner with AOT and numerous optimisations that looks like will put it at the top of the benchmarks again.</comment></comment>


Rent out GPUs to AI researchers and make ~2x more than mining cryptocurrencies - <AUTHOR> https://www.reddit.com/r/gpumining/comments/86ofw2/_/ <comment><USER2> Disclosure: I work on Google Cloud (and launched Preemptible VMs).

Cool! Like you, I wish people would make productive use of spare cycles.

Can I suggest you add a note comparing this to BOINC/gridcoin as well? I think your marketplace is a better idea, but because of the security implications dgacmu pointed out downthread, it shouldn't be treated lightly.

Also, I really like your white paper ([https://vectordash.com/primer](https://vectordash.com/primer)) as it's nicely formatted and has pretty icons. I think you should update the comparisons to the cloud providers though. Comparing a Pascal-series (1080 Ti) part to a Kepler part (K80) isn't particularly fair, as NVIDIA charges about the same for that part as the later P100s and V100s. That is, people should be comparing what the best price/performance ratio is, and all three providers have better options. There's a secondary question about whether the right comparison is to AWS Spot / Preemptible VMs / Low Priority VMs, but I'm not sure from a quick skim what the likely preemption rate will be with your setup.

Finally, let me echo dgacmu in saying it's too bad that NVIDIA forces all providers to only provide the expensive parts. The best price/performance is certainly the consumer parts (that 1080 Ti compares favorably to a P100 at a fraction of the cost), but both the EULA and otherwise prevent it. You're not running a direct service / providing things in a data center which is a cool workaround! But you should definitely be more clear about the risks of letting untrusted third-party code to execute against your GPU.

Again, great project!

<comment><USER3> We at Gridmarkets have cracked this one(spare cycles) and are now further enhancing the model.

<comment><USER4> That's a nice word-salad you got there.

<comment><USER5> Talking to VCs will do this to a person. I dont know why they can't just speak normal English, but spewing marketese seems to be a rite of passage.

</comment></comment></comment></comment><comment><USER6> There's a lot of comments on that reddit thread about how awesome this would be as a service.

But there's a big problem of trust with this for ML.

How do I know you actually ran what I paid you for and not just generated random data that looks right in the shape I wanted it?

You could farm it out to two people and if the results disagree, then payment is decided by a third. But then you've just doubled the (paid) workload, and you've not really solved collusion by a significant portion of the workers.

<comment><USER7> It's pretty much letting people with GPUs become a sort of 'mini-cloud provider'. There's no job queue or fancy distributing computing setup. We just let you SSH into a container on someone's computer, and pay for the time used.

I was doing a lot of fun deep learning projects on the side & would often Venmo my friend who was mining Ethereum to use his GPU to train my models. He made more and I paid less than AWS spot instances or Paperspace.

This is just a fun side project hoping to let people who want to train their deep learning models do it cheaply (on other people's computers!)

<comment><USER8> > It's pretty much letting people with GPUs become a sort of 'mini-cloud > provider'. There's no job queue or fancy distributing computing setup. We > just let you SSH into a container on someone's computer, and pay for the > time used.

I had the same idea a few days ago - but in my head, the process would be wrapped up as a "cryptocurrency" where the AI researchers pay real money and the "proof of work" is useful/"real" work. I ran into 2 issues regarding trust: the first is that how do you verify that the hardware owner is running the real job an not NOOP'ing and sending false results? The second issue is how do you protect the hardware from malicious jobs? GPUs have DMA access - how do you stop task submitters from rooting your box and recruiting it into an AI botnet (for free)?I ended up dismissing the idea, but if you could work out these 2 issues, there's money to be made...

<comment><USER9> > the first is that how do you verify that the hardware owner is running the > real job an not NOOP'ing and sending false results?

Consensus. Have _n_ nodes perform the same work (if it's deterministic), and only accept (and pay) if all the nodes match - or at least the nodes that were part of the majority

I don't think this would be considerably different from SETI or folding@home, which have been going on for around twenty years.

For my senior project in college one of our ideas was a distributed render farm that operated like what we're talking about. There were some additional issues there (transfering assets, preventing node owners from extracting the output [say a studio was "letting" fans donate compute time to render a feature film], etc).

<comment><USER10> It would work well for problems that are computationally hard to solve, but easy to verify solutions for. Unfortunately, such problems are ubiquitous in cryptocurrency, but rare in machine learning.

<comment><USER11> Well, not really. Training a model is one such task. It's hard to train a network but easy to verify that it has good performance (training vs inference).

The real problem here, I believe, and I've seen this idea pop up several times on hackernews, is that almost no machine learning tasks are progress free.

If the cryptocurrency is just paid out to the person who solves the task first in a non-progress free problem, then the person with the fastest GPU would mine all the coins and nobody else can participate. One of the key ideas behind proof of work is that if two people have the same compute, and person A has a headstart, if person A has not succeeded by the time person B starts, they'll have the same probability of mining a block.

People seem to be just jumping on the crypto bandwagon and trying to come up with "useful" proof of work, but it's a pretty difficult task.

</comment></comment></comment></comment></comment></comment><comment><USER7> Creator of Vectordash here! If you have any questions about the platform, feel free to ask away!

P.S. I'm @samin100 on Twitter if you enjoy tweets about GPUs!

<comment><USER12> I saw people on the Reddit thread saying the Ubuntu requirement was a showstopper for a lot of them.

You might look into the Win 10 linux support, Ubuntu is one o the supported distros. Not sure if it would have full access to resources, have just used it a bit at work and setup was super simple.

<comment><USER7> I remember a few weeks ago a when some Microsoft software engineers came to the career fair at Univ. of Maryland. One of them was working on Bash on Ubuntu on Windows, so I ended up bugging him for about an hour on when they'd support GPU passthrough for Ubuntu on Windows.

He said it was on their list of most requested features, but refused give me a data on when it would be ready :/

</comment></comment></comment><comment><USER13> I wonder when people will start just renting a 99 Euro server with a GTX 1080 from [https://www.hetzner.de/dedicated-rootserver/ex51-ssd- gpu](https://www.hetzner.de/dedicated-rootserver/ex51-ssd-gpu) and sell it for $367.2 / month on Vectordash

</comment><comment><USER14> This uses LXC Containers. I've always heard that containers are not a replacement for a good security model. What's the risk that someone could use Vectordash to attack the host computer?

<comment><USER7> LXC unprivileged containers are actually pretty secure by design. The Canonical LXC page does a pretty great job of explaining why: [https://linuxcontainers.org/lxc/security/](https://linuxcontainers.org/lxc/security/)

<comment><USER15> Please (OP, and others allowing access to your machines), be cautious on this front. While LXC unprivileged containers are a start at isolation, LXC containers + GPU passthrough has a much, much larger attack surface (the nvidia binary blob drivers are complex and out of your control). The most common ways of giving GPU access to a container involve installing the CUDA drivers in the host and simply allowing the container to access them.

Depending on your threat model, this may be borderline OK, or may be insanely high risk. We've seen driver exploits in the recent past:

[http://nvidia.custhelp.com/app/answers/detail/a_id/3140/~/se...](http://nvidia.custhelp.com/app/answers/detail/a_id/3140/~/security- bulletin%3A-nvidia-unix-graphics-driver-exploit-advisory).

that can vector through the GPU to gain access to arbitrary host memory (aka, you're in deep trouble). The only "right" way to give access to your GPUs requires IOMMU support and running in a true guest VM, which Nvidia's consumer cards and drivers are explicitly prevented from doing (because they'd like you to buy the Tesla versions, thanks).

This may be a totally acceptable risk on an isolated mining rig, but people should be aware of the heightened risks they're exposing themselves to. Breaking your machine is _well_ within the capabilities of state-sponsored actors on this one, and from time to time (just after vulnerabilities get announced), could be decently within advanced-script-kiddie zone.

<comment><USER7> This is a very, very valid point. I'm going to mention this on the website & even advise people to run the client on an isolated machine (instead of their daily driver gaming rig).

Thank you for pointing this out.

Also, one of my friends working on this project is a sophomore in the CS dept at CMU, and given your interest in distributed systems & DL, would it be possible to meet up for a couple of minutes and discuss security a bit more in depth? (if yes, I'll shoot you an email)

<comment><USER15> Happy to. Drop me a note.

<comment><USER16> ^^^ This is why HN is amazing.

</comment></comment></comment></comment></comment></comment><comment><USER17> Great idea and I am glad somebody actually tries to make an implementation.

But unfortunately this won't replace mining: the large scale mining farms have high end GPUs in their rigs, but the rest of the HW is very low end, because that works perfectly for mining and they want their ROI as low as possible.

I have a 6 GTX 1070 GPU rig, which would be decent GPUs for AI/ML, but the rest of the rig has a Celeron CPU, 4gb RAM,and a 5400 RPM HDD. Oh, and to be able to see all the GPUs, I had to downgrade all the PCIEx slots to 1x.

I am curious what kind of ML tasks would be able to fully utilize these GPUs, on such a low end hardware.

<comment><USER18> The ones that train on a GPU? I'm not sure the rest of the system will have that much of an impact.

</comment></comment><comment><USER19> We're coming into the warm seasons in the northern hemisphere, but if this effort survives into autumn, it'll be quite tempting for home-heating.

Stoked to see distributed-compute as a paying service making another try. One of these days, it is going to fly.

<comment><USER20> People are trying this for mining: [https://techcrunch.com/2018/03/08/qarnot- unveils-a-cryptocur...](https://techcrunch.com/2018/03/08/qarnot-unveils-a- cryptocurrency-heater-for-your-home/)

</comment></comment><comment><USER21> "Airbnb but for GPUs" is a buzzphrase I never could have imagined being real.

</comment><comment><USER22> Considering for hosting. One concern is that I have to expose my IP address to unknown users. I don't know if it's possible, but it will be great that if I can hide my location and purely lend my GPU with less security concerns.

<comment><USER7> You don't need to expose your IP address at all! The AI/ML researchers can only connect to one of our proxy servers instead of directly connecting to your machine. This means hosts do not have to mess with port forwarding or networking (even if your computer is behind a university firewall, you can still be a host!)

<comment><USER22> Wow that's great! Another question. It is always possible that I have some downtime (unstable network connection, accidentally shutdown my pc, power outage, etc) and it may become unfair that users having significantly less downtime (better network, UPS, etc) having same earnings with users with much more downtime. Is there any plan to deal with such kind of concern?

By the way, Vectordash is the most interesting idea & service I have seen in a while :)

</comment></comment></comment><comment><USER23> [https://medium.com/@rendertoken](https://medium.com/@rendertoken) aims to do the same thing, but for 3D render farm customers.

</comment><comment><USER24> How do I know if I will make a profit given electricity costs?

<comment><USER7> This website has a pretty good calculator:

[https://whattomine.com](https://whattomine.com)

Just replace your miner earnings with the earnings listed on [http://vectordash.com/hosting](http://vectordash.com/hosting)

</comment></comment><comment><USER25> This sounds pretty awesome. I wish I had perminent internet to the house so I could offer my rigs. I hope this service takes off, it should be a much better use of electricity and gpus than mining. Please do keep developing this, with the down turn in mining there should be a large pool of potential gpus. If this service can connect those gpus to researchers then that should be a lucrative business Ling term.

</comment><comment><USER26> As others have already pointed out, there are trust issues.

The seller can fake the computation to return bogus result is one thing.

But even if there is no malicious intent, the resulting computation is still ended up bogus result, the malfunction of the hardware.

Commodity hardware isn't that reliable and there are so many commodity GPUs in the wild that looks like working but return incorrect result.

<comment><USER27> all of these issues can be worked around by random validation, sumbitting all/some blocks to multiple people (redundant calculation). This is no different from existing efforts such as SETI@Homr and Folding@Home. The difference being the compensation which increases the incentive for fraud.

The key to the trust issue is not trusting the remote computer, because you can't. You have to validate somehow.

<comment><USER26> That solution requires that all computation is deterministic and the result of computation can be easily comparable. I think not all the computation is that simple.

<comment><USER27> It only assumes that including incorrect results isn't catastrophic for the end result, and that using mostly correct results will give a mostly correct outcome. If that isn't the case I'd compute every block 2..n times instead.

</comment></comment></comment></comment><comment><USER28> GPUs are already too expensive for gamers and now you want to do this?!

<comment><USER29> AI research demand is a lot easier for AMD/Nvidia to project, which allows them to ramp up production and keep prices stable.

Side note: AI research is more beneficial to society than running a few instances of Crysis 9 at 4K 120HZ.

<comment><USER30> ... _potentially_ more beneficial. Also potentially very harmful depending on what it gets used for.

<comment><USER31> Let's just say that AI research _can be_ useful, and thus this use of GPU time and electricity _can be_ useful; in contrast to the alternative alternative- GPU-use, which is not useful in the first place.</comment></comment></comment></comment>


California to "aggressively seek new federal assistance" - <AUTHOR> http://www.calculatedriskblog.com/2010/01/california-to-aggressively-seek-new.html

<comment><USER3> California should just spend less or tax more. If they can't, that's the fault of Californians not the federal govetrnment. (My understanding is that the root cause of the situation is that it's hard to raise taxes in california due to proposition 13, but easy to increase spending commitments through referenda -- can any Californians comment?)

<comment><USER4> It's worth noting that CA is basically getting ripped off, as we receive only 0.79 for every $1 we pay in federal taxes. See: [http://www.taxfoundation.org/UserFiles/Image/Blog/ftsbs- larg...](http://www.taxfoundation.org/UserFiles/Image/Blog/ftsbs-large.jpg)

Also, there are a variety of problems at work here, in no order: 1 - <USER2> taxes are basically frozen as long as you own your home, eviscerating the most stable form of local tax revenue for cities and counties (and not to mention screwing any newcomers); 2 - government via direct balloting initiatives, freezing spending on various popular causes which cannot be changed via the legislature unless the ballot initiative specifically allows this (and none, to my knowledge, do). Note this essentially freezes certain spending, which means that when cuts come, other areas have to bear far more than their proportionate burden; 3 - the same law that created situation #1 also requires 2/3 vote to raise taxes; 4 - enough republicans in the senate from conservative areas of CA to basically veto all tax increases; 5 - long term mismanagement of the states finances, increasingly relying on borrowing to pay the bills, which is now starting to come due; 6 - term limits, which both inhibit professionalization of the legislature while simultaneously insuring that legislaters aren't around to be confronted with the consequences of their laws; 7 - horrific effects of the financial crisis, particularly the housing bubble, as the cost of even the most modest homes rose far above the median incomes (see commuter cities where 15+% of houses have been in foreclosure!); 8 - a populace which seems unwilling to bring the costs of desired government services in line with our net tax proceeds, though the fact that the politicians hasn't been blunt about delivering this message has massively compounded this problem; 9 - as mentioned, CA is getting utterly screwed on federal taxes; 10 - it's also worth noting that CA also has a very powerful prison industrial complex that is seemingly immune to reform, and we bear huge costs related to the US' retarded drug policy which goes out of it's way to line the pockets of both the police and prison guards while not actually, say, reducing the costs to society in any way, along with the moral burden of ruining so many peoples' lives; 11 - Arnold Schwarzenegger -- the man is a venal moron, directly responsible (via the cuts to the car taxes), for simultaneously cutting tax income while increasing spending; 12 - effects of the financial crisis, which have dramatically raised borrowing costs for the state. Note this is even after the effects of borrowing to pay bills; the state borrows to pay bills in the normal course of operations until tax revenues come in towards the end of the year; this suddenly costs a lot more. 13 - etc, etc; i'm sure there are more, but I think these are the primary drivers</comment></comment>


In southeastern Colorado, robots carefully disarm WWII-era chemical weapons - <AUTHOR> https://arstechnica.com/science/2017/02/in-southwestern-colorado-robots-carefully-disarm-wwii-era-chemical-weapons/ <comment><USER2> Pretty sad. We made all these weapons for WWII that were illegal by convention since 1925, never used them, and now have to destroy them at huge expense. Such a waste.

<comment><USER3> Well, there's the other interpretation: Such a government jobs program!

I mean, in many cases most of that "huge expense" is going to be salary for the people that manufacture and then dispose of these arms. Of course, that puts the automation of such disposal in an interesting light: the robots are taking our jobs! Admittedly, as in most cases of "robots taking our jobs", these aren't really the sorts of jobs that most people would want to do anyway, but it does change the economic calculus of the whole military- industrial complex.

</comment></comment><comment><USER4> I recently drove near Walker Lake, in Nevada. This place is pretty much in the middle of nowhere, between Reno and Las Vegas. Then suddenly, I see thousands of those little igloo bunkers start popping up, just dotting the landscape in strange patterns.

I was amazed at the simple engineering put into them, the spacing was perfect, they had been buried, but like a pill, a line had been cut into them with a door, to prevent the blast going through the door unprotected.

I later found out that I had driven past the Hawthorne Army Depot, which has one of the largest reserves of ammunition in the world. Very neat and strange. Something I would expect out of Nevada.

<comment><USER5> I had a similar experience driving through northern Oregon. Little bunkers dotting the landscape as far as you could see. It was the Umatilla Chemical Weapons Depot. It took maybe 30 minutes of driving at 70 mph to traverse it north to south. Massive complex again in the middle of nowhere.

</comment></comment><comment><USER6> Why do they need such protection against mustard? If I understand the article correctly it's a liquid that is only dangerous on contact. Why simpler protection akin to what Ebola responders wear (face shield, respirator, apron, gloves and boots) wouldn't do?

</comment><comment><USER7> I was just in Pueblo a few weeks ago. It seems to be thriving selling pot to college kids in New Mexico and the panhandle of Texas.

<comment><USER8> That is its best hope for economic growth, but I don't think anyone in the area would refer to Pueblo as "thriving."

</comment></comment><comment><USER9> Department of Defense motto: "Hold the mustard."</comment>


Show HN: Create and host websites from your dropbox - <AUTHOR> http://www.websrvr.in/?hn=2 <comment><AUTHOR> Would love to hear any feedback you guys have.</comment>


Ask HN: What to do with this meme? - <AUTHOR> Hello,
I made this little web app - iwl.me, which is just a box with a button. You give it some text, it analyzes it and tells you what famous writer you write like (I won't go into algorithmic discussion for now), and gives you a badge for blog and a link for sharing on Twitter/Facebook/Buzz. It's up for 3 days now, here are stats:

   2nd day - 12,000 uniques
   3rd day - 100,000 uniques
 It's spreading just like a perfect meme should :-) E.g. http://search.twitter.com/search?q=iwl.me
My question is, what should I do with it:
a) for monetary gain (It already achieved the SEO effect I planned, not sure what to do now).
b) for a good cause. I'm already thrilled to notice that people discover and re-discover writers and say "Oh, I write like [writer], I must read more of his works." What can I do to get more of this effect?
What do you think? I'm open to ideas or deals. Thank you!
PS Technical details: it's running on a single Rackspace Cloud instance with 512 MB RAM, Apache+web.py. <comment><USER2> How about then giving the user a list of works by that author via amazon? If the users really do want to read more of that writer's stuff, this might be a good way to get some affiliate business. You could possibly even point to specific works that they "write like". You might also take a look at the goodreads api (<http://www.goodreads.com/api>) for some possible social networking aspects? Maybe you could show people reading things they write like via goodreads or something along those lines.

<comment><AUTHOR> I thought about Amazon affiliate program, but I'm outside the US, and it's a huge hassle to deal with checks here.

Thanks for suggestions!

<comment><USER3> I presume you mean cheques of money sent you from Amazon?

If it's too much hassle to cash potentially huge affiliate checks then you're rich enough, give the site to someone else that wants more money.

Seriously FB has 400Million active uniques. If you capture one-hundreth of a percent of those and then of those 1% convert and you make $1 on each conversion that's $400.

Even if it took me a whole day to organise cashing the cheque that would be worth it.

For Amazon though the problem is that they fragment their affiliate scheme (to create less opportunity for small sites to break the cash-out threshold presumably) so AdWords or whatever might be better.

<comment><AUTHOR> I'm in a new country (Montenegro), haven't got residence permit here yet, don't have a permanent address, and don't speak the local language to figure out how to cash checks.

Anyway, I've added Amazon affiliate links now, maybe I'll cash out with gift certificates.

<comment><USER4> Can anybody confirm it's possible to join Amazon Associates outside "Amazon" countries? (US/UK/FR/DE/JP/CA)

Spent 5 minutes on Googling but didn't find the information.

<comment><AUTHOR> Yes, it's possible. Just sign up here <http://affiliate- program.amazon.com/join/getstarted>

</comment></comment></comment></comment></comment></comment><comment><USER5> 1\. Quickly send an email to the Top 20 writing sites out there. And make them an offer: they could get a white label version of your script to be on their URL with their logo for a fee. Strike while the iron is hot.

2\. On the results page, quickly create a form that asks for peoples email id. And then publish a newsletter that helps folks become better writers. Capturing email ids also give you a big base of folks with whom you can share your future apps with. Faster seeding.

<comment><AUTHOR> 2\. Done. Thanks!

</comment></comment><comment><USER6> I'll share some experience with your from cornify.com, which had the same effect and still goes strong 1.5 years later (this year invitation to ROFLCON, SXSW people's choice award, installed in 550000 web pages...). This is my experience with a project that's different from yours, so I hope it will help with your specific situation.

The main thing you need to achieve is to make your site about a bigger theme. This feature will remain the core, but you need to be associated with something bigger. With Cornify, it's always been about happiness. Unicorns and rainbows are (almost) second to that, which gives me much more room to work with. Make your site about famous writers, becoming a better writer, or something like that. Use imagery that matches the theme.

The second big thing is to make your tool deep, while keeping it simple. People know it for this one thing and the one thing only. Make it so you can find something new every time you use it, make it smart so it learns with the number of times you use it. Surprise people. Tweak, tweak, tweak.

Third recommendation is to build a voice and talk to people. Get Twitter and Facebook accounts. Decide on how you want to relate to people and what they should get out of being interested in you. I've gotten so many "Oh, I can't believe Cornify is on Twitter" comments, it shows that you care about the site. A brand would also be a big help. Maybe you can look into using imagery of famous writers.

Find a way that people can create things on your site. With Cornify, people really like the photo uploader. Find something that people can create on your site and then share. This keeps people coming back.

Most importantly, keep things fun. This is not serious business, this is a meme. If things stop being fun or get cluttered with ads, people will not take your serious and won't come back. Be very careful about monetizing. A meme that people like is an incredibly thing to have in your resume and a great talking point. I worked on projects for MTV, Nintendo, EA, etc, but people get way more excited when they find out I created Cornify. This is a meme and you may be more proud of other things you have done, but in terms of public recognition, you should take this very serious.

And congratulations. It's very exciting to see a project blow up like this. Hope you have a great time with it.

<comment><AUTHOR> Thanks for sharing your experience!

<comment><USER6> Just wanted to emphasize one more time that you need to act right now. Stop sleeping if you need to. The next few days are super important.

</comment></comment></comment><comment><USER7> Many of my FB friends are writers, this thing has spread like wildfire through them today. But the thing is it's a flash in the pan effect. It'll do huge for a very short period of time with no revisits. If you monetize, do it RIGHT NOW. Tomorrow is too late. Almost literally.

<comment><AUTHOR> I agree, just like almost every meme, it's short-lived.

<comment><USER8> A lot of the memes on the web are short-lived, however there's nothing about memes that makes them inherently short-lived. Some memes live extremely long.

<comment><AUTHOR> I'd be interested to see examples of long-lived memes like this.

<comment><USER9> <http://icanhascheezburger.com/>

<http://www.hotornot.com/>

<comment><USER10> Those at least give you neverending variety. There are novel thousands of new variations on the lolcat theme every day, and no end to the slot-machine-like fun of rating people hot or not in the hope of eventually getting to one who is either particularly hot or hilariously not.

But once you've posted in a sample of your own writing, gone "Hahaha, I write like Mario Puzo, hey guys, guess what?", I find it hard to imagine anyone coming back time after time.

<comment><USER9> That is true. There's a lack of stickiness to the original poster's app as it is. It might be interesting to see how other people's writing was rated.

The newsletter addition was a good idea. I have a feeling many "writers" would be upset to learn they wrote like Dan Brown, no matter how many novels he's sold. Possibly a "From Brown to Updike: How to Improve Your Writing" course.

The OP's idea is darn viral, however. I love the success he's had.

</comment></comment></comment></comment></comment></comment></comment><comment><AUTHOR> Clickable: <http://iwl.me>

</comment><comment><USER11> I know you said you're not discussing the algorithm, but to me, the biggest proof of silliness (I won't say "nonsense") is that when I entered 7 different blog posts of mine, I got 6 different results.

<comment><USER12> I tried two different posts I wrote (in fact, the entire contents of my rebooted blog, since RSI has kept me down lately), as well as one half-written post, and apparently they all appeared to be Dan Brown works.

I'm not quite sure what to think of that, but at least it was reasonably consistent for me.

<comment><USER13> It was completely inconsistent for me. I tried 4 posts and got 4 different results. I tried 2 different parts of the same post and got different results.

I suspect the webapp is just suggesting random writers.

Also, NLP classification is a hard problem. I don't think doing it reliably over a weekend is possible. I think that had OP done any good work on NLP, he would have discussed it. I am more inclined to think the app is just giving random results.

<comment><AUTHOR> _I suspect the webapp is just suggesting random writers._

Nope. It's just a Bayesian classificator :)

<comment><USER14> You realize that there is a niche of academia that works on using computers for analysis of writing samples in order to determine probable authorship, right? Algorithms exist that have been tweaked and improved over the years that you might be interested in reading about.

You might also connect with the people who try to identify students who turn in term papers and lab reports written by other people.

You could also add a game (who wrote the following paragraph? (Multiple choice)). That would be an avenue for return visitors.

You could also have "write like Hemingway / Dickens / Neal Stephenson / etc." contests. Kinda like painters going to famous museums and copying the works of famous painters, it's a way to extend and hone the craft of writing. I recall a good version of Twas The Night Before Christmas written as if Hemingway wrote it. Also, connect with specific writers' fanbases (especially Chuck Palahniuk), and with writers workshops, and fanfic groups. Poetry, too.

There are a lot of ways you could take this. Make sure your algorithm is effective, though!

<comment><AUTHOR> Yes, I even have been contacted by people who research this, and received a lot of pointers to interesting works. But I'm sure I wouldn't be able to integrate and figure out this in 3 days.

You suggestions are helpful. Now that I'm interested in this topic, I may release something better. Thanks.

</comment></comment></comment></comment></comment></comment><comment><USER15> upsell a relevant product

affiliate deals for the authors books

enjoy the seo :)

</comment><comment><USER16> I fetched a document I wrote and entered several paragraphs, and got a different author each time. What does that say about me (or your algorithm)?

Congratulations on the traction though!

<comment><USER17> I tried a couple of times, got Raymond Chandler, Margaret Atwood, Stephen King and... Dan Brown. All for different elements of the same page. In turns inpsiring and soul-crushing..

</comment></comment><comment><USER18> Obviously this would be something that would mean a lot more work, but how about.. Tracking a users's blog feed, parsing each post and see how their writing style evolves over time?

This would certainly increase the longevity of your app.

<comment><AUTHOR> This is a great idea. I'll do this when I have time, thanks.

<comment><USER19> on that note checkout 750words.com. Basically you write 750 words a day and it analyses the text to tell you about what you have written - whether it's extroverted, self-centred, positive etc. These stats are then displayed with nice graphs.

</comment></comment></comment><comment><USER20> There is no info about the 'famous writer'. At least an Amazon affiliate link to the author should generate some income. Also, the first paragraph from Wikipedia would be useful.

</comment><comment><USER21> Based on your post, you write like Dan Brown.

<comment><AUTHOR> :-) Here's some funny feedback: [http://www.codingrobots.com/blog/2010/07/13/funny- feedback-o...](http://www.codingrobots.com/blog/2010/07/13/funny-feedback-on- i-write-like/)

</comment></comment><comment><USER22> Depending on which paragraph within the same blog post I checked I write like Margret Atwood, Mark Twain or Isaac Asimov. By removing the last sentence from my Asimov-like paragraph: H.P. Lovecraft. Removing another sentence I write like Edgar Allan Poe.

I'm not sure what this tells me about my writing, but it does stroke my ego. Sometimes that's just what a writer needs.

</comment><comment><USER23> You might consider pinging somebody at Lulu (print-on-demand self-publishing company). They might be interested in partnering with you in some fashion... since they specialize in helping authors get published, there might be some synergy there; even if it were no more than a Lulu advertisement on your site. Other self-publishing outfits (CreateSpace, SmashWords, etc.) might have a similar interest.

Disclaimer: I'm a former Lulu employee and still like those guys a lot, which is why they came to mind first. :-)

Also, if you're interested and need any help making a contact there, feel free to email me. I still have a few connections left over there, I think.

</comment><comment><USER24> First, congratulations.

I think your first goal now should be encouraging users to return later.

I would definitely promise right on the results page that more writers would be added regularly and algorithms would be improved so that people had reasons to bookmark you or to subscribe to your twitter/facebook waiting for their favourite authors.

I would also make local pages for all writers you have. Link to Amazon in that place is unexpected.

You could also encourage showing off by enhancing badges. That could be percentages (e.g. I write like 7% of users) or cool portraits or even something like "I write like Stephen King - I could have written The Stand".

</comment><comment><USER25> Impressive uniques progression... what did you do on day 1? I mean, what strategy did you employ to launch the meme? I guess you launched it on codingrobots blog/newsletter/twitter, did you do anything else?

Regarding the spreading, a tweet from some real author will be great (how?). And what about publishing some real-time stats about the results? i.e. 30% of our users write like Dan Brown, 10% like xxx, etc...

EDIT: "Margaret Atwood, who is in our database of famous writers, tweeted about it (apparently, she doesn't write like herself… oops :)" Already happened... enjoy the exponential growth in visits :)

<comment><AUTHOR> Yes, newsletter, Twitter and blog. First "outside" referrals were from reddit ([http://www.reddit.com/r/reddit.com/comments/cnmny/what_famou...](http://www.reddit.com/r/reddit.com/comments/cnmny/what_famous_writer_you_write_like_check_with_this/)) and my HN comment on "What are you working on today?" (<http://news.ycombinator.com/item?id=1501078>). Total of 132 visits on the first day.

Currently:

      facebook.com 20.75%
      tumblr.com   8.24%
      twitter.com  5.57%

Of the popular writers, Margaret Atwood tweeted about it (apparently, she doesn't write like herself -- she is in the database :) <http://twitter.com/MargaretAtwood/status/18463485898> and William Gibson <http://twitter.com/GreatDismal/status/18450533599>

I don't track any stats regarding results of analysis, I can only see which result pages get more visits.

</comment></comment><comment><USER26> How about recommendations like "people who write like Bukowski enjoys Burgess"? Of course the author names are links to your affiliate program.

BTW, the banner at the bottom of your site is taking ages to load.

<comment><AUTHOR> _BTW, the banner at the bottom of your site is taking ages to load._

Hmm, it's hosted on Rackspace Files CDN.

</comment></comment><comment><USER27> Bit off topic, but it will be interesting to learn how you seeded the meme. Will be good for people like me who churn out such minor projects which always fail to get >100 visitors :)

As far as monetary gain is concerned, immediately you can find some of the writers books on Amazon and link them up in the results page with your affiliate id. Long term you can capture email ids and send them offers on email.

</comment><comment><USER28> It would be interesting to see a comparison graph of other users. For example, I would be interested to see how many other people write like Vladimir Nabokov, and maybe even what the top 10 writers are.

Congratulations on your success!

P.S. You said you're in Montenegro but don't speak the language -- just remember "pivo" (beer) and "poshto?" (how much) and you'll be fine ;)

</comment><comment><USER29> It says I write like James Joyce. You sure know how to pump up my ego! There must be money in that.

<comment><USER30> Makes the two of us. Want our money, you can have it.

</comment></comment><comment><USER31> Depending on how well it's done, I could imagine 'niche' writing analysis doing alright. What 18th-century philosopher do you write like? What CS textbook writer do you write like? Which Doctor Who do you write like? Etc.

</comment><comment><USER32> Dude, you have no facebook Like, Tweet this, Buzz it, links?

.... oh wait.... they do exist...

Umm ok... How about you use the regular icons for familiarity sake?

I also like the "bio" idea. Seeing a name I don't recognize makes the experience a bit hollow.

</comment><comment><USER33> Oh you should totally join forces with this guy - <http://www.finishstart.com/> \- it will be a whacko mashup.

</comment><comment><USER34> I just pasted some irc logs. IRC writes like Mark Twain...

</comment><comment><USER35> Amazon affiliate links for books by said authors?

</comment><comment><USER36> pg ~ kurt vonnegut

</comment><comment><USER37> I write like Joyce apparently and Defoe

</comment><comment><USER20> Lovecraft here.</comment>


Indices Point Between Elements - <AUTHOR> https://blog.nelhage.com/2015/08/indices-point-between-elements/ <comment><USER3> The visuals are definitely valuable in explaining this.

 _It used to be popular, and still is in some circles, to debate whether programming languages ought start array indexing at 0 or 1._

When talking about this with other programmers, I've discovered that a lot of the issues/confusion could be avoided by consistent use of terminology: Offsets/offsetting always being zero-based and indexes/indexing always being one-based.

Using rulers and birthdays also helps to explain differences. You're in the first year before your first birthday, being zero (whole) years old.

To make matters potentially more confusing, culturally, I remember something about the ground floor in the UK buildings not being "Floor 1" like it is in the United States.

[http://www.hacker-dictionary.com/terms/fencepost-error](http://www.hacker- dictionary.com/terms/fencepost-error)

<comment><USER4> _I remember something about the ground floor in the UK buildings not being "Floor 1" like it is in the United States._

Actually, that's perfectly explained with your offset vs. index terminology. In some countries, the floor number is an index within the array of floors. In others, it's an offset from the ground.

<comment><USER5> Except in the UK, where there often is a Mezzanine floor somewhere above the ground floor (usually, but not always, between the ground floor and the first floor).

Is there an Esolang that numbers its arrays with 0,M,1,2,3...?

<comment><USER6> A mezzanine is, by definition, a floor offset a non-integral number of storeys from the floors around it; a floor existing at a fractional floor number, in other words. A mezzanine "between the first and second floor" (in american parlance) would have a floor offset of 0.5 (or possibly ranging from 0.3 to 0.7, since mezzanines usually involve complex arrangements of stairs and landings.)

</comment></comment></comment></comment><comment><USER7> See also [https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...](https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html) ("Why numbering should start at zero")

<comment><USER8> And the HN discussion: [https://news.ycombinator.com/item?id=9761355](https://news.ycombinator.com/item?id=9761355)

</comment></comment><comment><USER9> People have taken different approaches to this in bioinformatics for numbering intervals of dna bases in chromosomes. I think this approach is catching on, though. In that realm, it's important to speak unambiguously about insertions and deletions, and the "interbase" mental model makes it a lot clearer.

edit: Probably the most popular genome browser, based at UC Santa Cruz, uses this zero-based, half-open numbering internally. But, at some point in the past, biologists developed an expectation that numbering would be 1-based. So the Santa Cruz genome browser actually adds 1 to the start position of everything for display purposes.

<comment><USER10> One interesting side-effect of using 1-based closed indexing (i.e. numbering the positions, not between the positions) is that a zero-width range (which is something that actually comes up in genomics) starts at position N and ends at N-1.

</comment></comment><comment><USER11> Once at a party I accidentally started an argument about which way toilet paper should hang from the roll (front or back) by mentioning how silly it was that people would argue about such a trivial matter.

<comment><USER12> Also at which and do you start pealing a banana?

</comment></comment><comment><USER13> I've found this a helpful way of explaining ranges in Python to students, it also makes Python's negative indices understandable for the same reason.

But it is contextual. When it comes to languages like C, where arrays are more directly mapped to pointers and memory layout, I've found it better to talk about pointers, and allow people to derive the behavior that way.

Either way, I'd be careful of trying to claim that 'this is what it _is_ ', rather than 'here is a way to remember it'.

<comment><AUTHOR> I get into this a bit later on, but I think the exact same model applies to pointers: You're much better off in most cases thinking of pointers as pointing at the zero-width points between elements, than at elements themselves.

<comment><USER14> I'm also having trouble meshing this way of thinking about indexes with the idea of a fixed bit-width, discretely addressable RAM, which would suggest that there is nothing "between" two storage elements.

I find it very useful, however, for imagining what the returned insertion point index of a binary search would mean, when the item you are looking for can not be found.

</comment></comment></comment><comment><USER15> He undermines his own argument right out of the gate. When he shows the part about which number should be used for the last element in the range there's still two valid choices, you could choose to stop at 3 with the understanding that the element to the right of that is the last element to be selected, or to stop at 4 with the understanding that in this context your indexing is "special" and you're actually selecting the element to the left of the index.

<comment><USER16> If you treat the indices as between elements and include all elements that are between the start and end elements, there is only one reasonable choice. It would be more "special" to include elements that are outside of the specified range (i.e., the element to the right of the final index).

<comment><USER17> Yeah, but I think that orclev was saying that you have a rule at the beginning that the element to the right of the index is important and then in ranges, the element to the right of the index is know longer important.

One way or the other, someone needs to know the same number of rules in order to understand how the indices work.

</comment></comment></comment><comment><USER18> When you talking about where zero-width regexes match, this mental model certainly helps, and I find it consistent otherwise too.

<comment><AUTHOR> zero-width matches (and empty lines) were a _huge_ source of stupid edge-case bugs in livegrep[1], and being rigorous about maintaining this mental model definitely helped a lot.

[1] livegrep.com

</comment></comment><comment><USER19> Further notes about half open intervals and why starting at zero is a good idea: [http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF](http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF)

</comment><comment><USER20> There is a reference to Emacs in the OP, but not directly to what immediately sprung up in my mind[0]. In Emacs, it has a cursor (the block) and a "point" which is described as an imaginary spot at the left edge of the cursor - <USER2> point is what's important when one is indexing data (ie: setting a mark and selecting a bunch of text). The model fits for lots of things... Unfortunately for me, tmux highlighting does _not_ follow this model.

[0] [https://www.gnu.org/software/emacs/manual/html_node/emacs/Po...](https://www.gnu.org/software/emacs/manual/html_node/emacs/Point.html)

edit: clarify Emacs reference in OP

</comment><comment><USER21> I have sometimes wondered whether it would be useful to have two different types for indices, depending on if we are indexing the elements themselves or the "gaps" between them. Let's say I'm thinking about some language like Haskell, where types are already a big deal.

That way the compiler would be able to tell if I accidentally mixed the two. Every conversion would have to explicit: for example, there might be two functions, "before" and "after", that take a gap index, and return an element index.

I think I might actually enjoy programming this way, but perhaps others would find it needlessly bureaucratic.

</comment><comment><USER22> Isn't this the classic fence post vs fence section analogy? I like this statement from Djikstra: "an element's ordinal ... equals the number of elements preceding it in the sequence"[1] [1][http://c2.com/cgi/wiki?WhyNumberingShouldStartAtZero](http://c2.com/cgi/wiki?WhyNumberingShouldStartAtZero)

Another nice link: [http://betterexplained.com/articles/learning-how-to-count- av...](http://betterexplained.com/articles/learning-how-to-count-avoiding-the- fencepost-problem/)

</comment><comment><USER23> And this is why JavaScript's `lastIndexOf` method gets it wrong, wrong, wrong. (`"foo".lastIndexOf("o", 2)` yields 2, whereas I, and probably a lot of other people, would expect it to be 1, with the search starting at the space between element 1 and 2)

</comment><comment><USER24> This is the mental model I use.

</comment><comment><USER25> Relevant [https://github.com/vr6/blog/blob/master/Zero- One.md](https://github.com/vr6/blog/blob/master/Zero-One.md)

</comment><comment><USER26> This is the same model used by the Cairo graphics library and the HTML5 Canvas (albeit in two dimensions). All the same benefits apply when you're addressing pixels as elements of an array.

</comment><comment><USER27> We need a different name for this. We're too used to "index". If the name is "Foo" then we can have fooSubString(i,j);

</comment><comment><USER28> This echoes the way unums work in "The End of Error". (Recommended read by the way.) Good way of thinking about ranges.

</comment><comment><USER29> Ugh. Please no.

This only adds to the confusion, as now there are 2 ways in which indices can be interpreted.

<comment><USER30> Specifically, this:

>"Indexing between elements, instead of indexing elements, helps avoid a large class of off-by-one errors."

It only replaces them with indexing-method errors. Instead of remembering if my ranges are open or closed, I have to remember if they are using between- element indices or on-element indices. It's still going to cause the same kinds of problems.

<comment><USER10> You always have to remember what kind of indexing you are using in order to avoid making errors. But using this mental model will help people avoid making off-by-one errors because they don't even understand the indexing in the first place.

</comment></comment></comment><comment><USER31> Great teaching tool, thank you.

</comment><comment><USER32> Some people spend too much time overthinking simple concepts...

<comment><USER33> Some people overestimate the simplicity of common concepts...</comment></comment>


Show HN: Personal Dining Concierge - <AUTHOR> http://www.hoppit.com

<comment><USER2> Hi all, I'm the Founder of Hoppit, and we recently launched a new ambience search engine for restaurants and bars. I really value the feedback in this community, so if you'd like to drop me a line, just hit up email@example.com!</comment>