What's new in PHP 8? - <AUTHOR> https://stitcher.io/blog/new-in-php-8?ref=hn <comment><USER2> You know, I used PHP back in the early 2000s and sometimes I miss it after having worked with Python, Ruby and Elixir over the years but it's not necessarily related to the language itself.

I use this one program called Sendy (a PHP app) to help manage my email list. It's a typical LAMP set up.

It's been running on a $5 / month server uninterrupted for 905 days with no down time related to the app malfunctioning. The whole system uses around 300mb of memory.

Yesterday I decided to spin up a new server to finally retire the old one since it was using Debian Jessie that just went EOL 2 weeks ago. This required migrating a ~3 year old version of Sendy to the newest one (dozens of database schema changes included) and export / import my entire database.

Everything just worked and all I had to do was rsync the PHP files to a directory and access the site in a browser, and it was upgraded and ready to go.

I even ran into what I thought was a bug because my existing forms weren't working, so I looked into the single PHP file that was the form's action and within 5 minutes determined I was missing a hidden field (something Sendy added in a recent version). That was the first time I ever looked at its source code and PHP in a long time.

It very much reminded me of my PHP cowboy days. No complicated build process, no dependencies (the whole app uses PHP's standard library), no having to restart the server between deploys, etc.. I know there's downsides to that and I'm very aware of them, but after having worked with increasing complexity for the last 10 years of web dev, man it felt nice for a change.

<comment><USER3> Sendy is without a doubt one of the worst written pieces of software I've ever had the displeasure of (a) supporting in product And (b) having to patch.

I would quit working in software dev and become a fucking gardener before I would work on Wordpress projects all the time, and Sendy makes Wordpress look well written.

Edit: cowboy is a very apt term for Sendy. If the cowboy were drunk, and tried to make babies with the cows.

<comment><USER4> "Sendy is without a doubt one of the worst written pieces of software I've ever had the displeasure of (a) supporting in product And (b) having to patch."

So you're saying you've never worked with Magento?

<comment><USER5> My thoughts exactly. Sometimes I think I hate Magento for being so overly complex, slow, resource-intensive, and feature-poor yet bloat-rich that only Adobe could be interested in it. Then I think of the poor people paying me to maintain and write extensions for it.

</comment></comment></comment></comment><comment><USER6> As someone who wrote their last lines oh PHP in something like PHP 5, this list tickles my desire to take PHP for a spin again. Not only does the language appear to be much improved, but also the frameworks look so appealing! I'm seriously over dealing with all the low-level plumbing that comes with building Node/REST SPAs just for what's essentially a bunch of forms.

<comment><USER7> Laravel is a great framework to work with, I would seriously recommend giving it a try.

As for NPM and the JavaScript packages, this is a flipping nightmare and I hate working with it!

<comment><USER8> I hate to state the obvious, but it's the matter of familiarity.

I've been working almost exclusively with javascript and typescript for the last 4-5 years; so that now, while trying to write an amateurish Symfony project (because shared hosting) and appreciating the maturity of Symfony, I still hate almost every moment of it and hope I could have used typescript.

Anyway, what's wrong with npm and how is it so different than composer?

<comment><USER9> One that I can think of:

The way npm install always check latest package version and use them, even if package lock already exists. Which broke apps build many many times due to developer does not recognize this behavior. I know there are npm shrinkwrap and npm ci. Its just other package manager usually follow lockfile on install and have other command to upgrade the lockfile.

Also npm install download gazilion file for each dependencies. With deep directories.

In the past, there are problem because npm way of installing dependencies and hitting this infamous windows file path length limitation.

All are now already fixed or have alternative. But at that time, composer definitely much simpler and reliable.

</comment></comment></comment></comment><comment><USER10> "This RFC fixes the very strange case in PHP where 0 == "foo" results in true. There are some other edge cases like that one, and this RFC fixes them."

It's good they fixed it I suppose, but yikes. As much as people say PHP has advanced from its fractal of awfulness days, a lot of those fixes are shocking if you come from other languages.

<comment><USER11> Most (non-strongly-typed?) languages have weird edge cases of this sort. There's a very funny presentation by Gary Bernhard highlighting some of these for Ruby/Javascript: [https://www.destroyallsoftware.com/talks/wat](https://www.destroyallsoftware.com/talks/wat)

If you look hard enough, you'll probably find some site that shows surprising behaviors of your favorite language. Examples:

Python: [https://github.com/cosmologicon/pywat](https://github.com/cosmologicon/pywat)

Javascript: [https://loomcom.com/blog/0097_the_wats_of_javascript.html](https://loomcom.com/blog/0097_the_wats_of_javascript.html)

Ruby: [https://idiosyncratic-ruby.com/29-limitations-of- language.ht...](https://idiosyncratic-ruby.com/29-limitations-of- language.html)

<comment><USER12> Are there real use cases for type coercion?

<comment><USER13> For example, it is helpful to avoid having to do tons of explicit integer parsing when working with the DOM, which uses strings for everything

</comment></comment></comment></comment><comment><USER14> I used to use PHP as a web backend and then moved to Go. Forgetting the debate about the actual languages, it makes so much more sense to me for a web app to be a full-fledged, self-contained program which happens to listen on a network interface and respond when things make HTTP requests at it.

The old-school style, where routes map to scripts or parts of scripts and a separate web server like Apache or Nginx sits in front of the app, feels harder to reason about (does this thing persist across requests?), harder to debug (where did that error message end up?) more brittle (did this fail because of my script or my web server config or something else?) and more dependent on configuration magic (i.e. various text files lying around governing the behaviour of things).

So although some of these changes look cool, I don't think it's the language itself that most needs improving.

<comment><USER15> Funny. I completely disagree, and actually find it odd someone actually wants desktop style application state on web apps. One of the beauties of the PHP style of app execution is that application state is a lot simpler. Instead of having a running application server-side, which can be in a continuum of states, PHP forces you to start every request with a blank slate. Application state must be explicit (with serialized server-side sessions or browser-stored cookies). This makes it trivial to reproduce requests, trivial to debug, trivial to scale horizontally.

To each his own, I guess. I just find your position genuinely surprising.

<comment><USER16> By starting every request from a clean slate, you have much less mental overhead (did I accidentally reuse a variable from a previous request?) and it eliminates an entire class of programming bugs. It's the best thing about PHP, and despite this approach PHP still runs faster than many similar languages.

<comment><USER14> I think the "clean slate" benefit is achievable almost for free in a monolith though - each request is a separate invocation of a handler function which is given the context it needs to run (e.g. an HTTP request, an output stream and user-defined context).

The user-defined context is the only route into the application state and can be as wide or narrow as you need. So you can share persistent state deliberately, e.g. by having that context contain a pointer to a db conn, but this is always a conscious, opt-in choice, and errors like accidental reuse should be impossible unless you're doing something inadvisable like using global variables.

<comment><USER17> After doing Java Spring I realized that the Java monolith was very leaky and inflexible. That is why you have strong trend of micro services.

In 99.9% of cases in web development you want the PHP model of doing things. The 0.1% case is the asynchronous background job, that can be solved, maybe not as elegant as in other languages, but why optimize the edge case?

<comment><USER18> My backend is written in php and I simply have a separate container running a copy of the same php codebase that has a long running process pulling from a pubsub queue in a loop.

So anything that needs to be processed asynchronously, like say, sending out a few dozen emails or notifications, I just publish the task to the queue and that other container handles them.

This could be simplified even further if you use a pubsub service that can post data to a url as it comes in. Thus allowing the single php container to asynchronously process the tasks all in their own individual threads.

This didn't work for me as Google cloud's pubsub seems to absolutely flood it's target with requests seemingly ignoring 503 or any other error code and not backing off until it has dos'ed your server.

</comment></comment></comment></comment></comment></comment><comment><USER19> > The JIT — just in time — compiler promises significant performance > improvements ... There haven't been any accurate benchmarks done at this > point, but they sure will come.

They wrote a new compiler, for performance reasons, and don't have any accurate benchmarks? Really?

<comment><USER20> The only benchmarks done before adding it to the core were on maths-heavy code samples, something PHP is seldom used for.

You can read about it here: [https://stitcher.io/blog/php- jit](https://stitcher.io/blog/php-jit)

</comment></comment><comment><USER21> > Right now PHP 8 is in feature freeze, meaning no new features can be added > anymore.

> Starting with new features, remember that PHP 8 is still in active > development, so this list will grow over time.

Something doesn't seem right here :)

<comment><USER22> PHP 8 adds support for quantum superpositions. (Well, it does and it doesn't.)

</comment></comment><comment> dynamite-ready I've never quite understood the common reasons for bashing PHP. When I first got into web development, it was effectively the only real choice available. What it offered the beginner over the likes of Java and ASP (at that time) was ease of setup, a coherent model for simple data driven web page development (especially when compared to the likes of JSP), a great suite of built in functions, and comparatively excellent documentation. If I had to teach someone how to code now, I'd probably still consider PHP for the reasons above. Though Python has probably eclipsed PHP for many novice friendly reasons (docs and built ins).

</comment><comment><USER23> I'm most excited about str_contains(), str_starts_with(), and str_ends_with(). Call me simple but I'm so glad I don't need to come up with weird work arounds for those functions.

<comment><USER24> For those who need them

EDIT: Actually, there are polyfills here: [https://php.watch/versions/8.0/str_starts_with- str_ends_with](https://php.watch/versions/8.0/str_starts_with-str_ends_with)

</comment></comment><comment><USER25> I'm eagerly looking forward for union-types since I heard first of them.

PHP APIs (both core and frameworks) suffer greatly from inconsistency. Union types in function/method signatures can greatly help static analysis. It is great that PHP gets this built in.

</comment><comment><USER26> The thing I love most about PHP is that regardless of the new features they seldom break backward compatibility. I have a site created with PHP 5 that runs absolutely fine with PHP 7.0 and I don't remember we had to ever update anything in that huge codebase.

It's a pretty big achievement and avoids a lot of hassle for users as you don't have to maintain different versions of programming languages on a server.

<comment> john-shaffer I've had the exact opposite experience. It's unusual for an upgrade to not break something.

There are dozens of breaking changes in this release alone: [https://github.com/php/php- src/blob/96c7d42a3ca9d822a08b3dd4...](https://github.com/php/php- src/blob/96c7d42a3ca9d822a08b3dd48060abca8240413a/UPGRADING#L20)

Some of the changes are sadistic. "The precedence of the concatenation operator has changed relative to bitshifts and addition as well as subtraction." Have fun debugging code that worked perfectly well for years and now produces unpredictable results.

<comment><USER27> PHP7 will still be supported for a while. Debian will probably support it even further. You'll have a long ass time to fix these.

Even if you wanted to push the 8.0.0 to production as soon as it came out, you'd still have until November to run your tests on the RC branch and report any mishaps to the development team.

The backwards compatibility is mostly targeted to major platforms (Wordpress, Drupal, Magento, Symfony, etc).

> Have fun debugging code that worked perfectly well for years and now > produces unpredictable results.

This describes my everyday experience with any language or codebase.

The cause for the unpredictable results are often human-related though, not version-related.

> Some of the changes are sadistic. "The precedence of the concatenation > operator has changed relative to bitshifts and addition as well as > subtraction."

I would gladly remove any code that does concatenation and math/bitwise on the same expression relying on the operator precedence. Sadistic is the person who writes these.

More than 2000 packages were analyzed and only 5 instances of that particular use were found[1], all bugs. This is a good change.

[1]: [https://news-web.php.net/php.internals/105442](https://news- web.php.net/php.internals/105442)

<comment> john-shaffer > > Have fun debugging code that worked perfectly well for years and now > produces unpredictable results.

> This describes my everyday experience with any language or codebase.

That is horrifying. That should absolutely not be normal. I don't know what you work with normally, but it's clear that we are working in _completely_ different worlds.

<comment><USER27> I don't know any programming context immune to human errors.

Stuff just breaks. Sometimes I get lucky and the guy before me wrote a cool test that prevents me from having to start a debugger, but the contrary is often the reality. OSS stuff is usually better, but not much better (OS upgrades always break, for example).

</comment></comment></comment></comment></comment><comment><USER7> I would love to see PHP get some more/new love, it has a great community, fantastic tutorials and the package manager (composer) well just WOW!

</comment><comment><USER28> PHP was just PHP for years.

Now I don't even recognize what's going on when reading code in a language I've used for my entire software development career.

It's like a new language.

I want to be done with tech some days.

I just want to do my job, not relearn a language I've used for 20 years.

<comment><USER29> It seems every language has a group of people with an unrelenting urge to turn it into Java.

<comment><USER30> As long as weak typing is not abandoned, the Java-like language features are great.

I am really looking forward to generics in PHP.

<comment><USER29> Weak typing and generics, isn't that the worst of both worlds?

</comment></comment></comment></comment><comment><USER31> My prediction is that Annotations will be a game changer for PHP-based frameworks. Finally people will get something like in JAXR in Java, just being able to write @@Path("/users") over their listUsers function to have it be called when someone accesses the URL "/users" on the host.

Having to setup routing the cumbersome way has been the bane of being productive in Laravel.

<comment><USER32> Was it really cumbersome to declare a route in laravel? Isn't it just one line in a web.php file where you associate an endpoint to a Controller function?

<comment><USER31> The issue is that routes are declared in web.php.

In some cases, web.php routes aren't automatically updated if you use `artisan serve`, so you have to restart that sometimes.

And of course, it means there is a lot of distance between the file in which the controller and function are defined and the route definition. The route definition is in "routes/web.php" and the controller will likely sit in "app/Http/Controllers/Something.php", so if your Laravel project is moderately sized, you'll be scrolling a bit if you don't find the editor tab.

<comment><USER33> On the other hand, I don't think it's a good idea to mix the controllers with the route definitions. How I configure or set up the routes should not be in the controller classes, that should be a separate thing.

It's easier to see all the routes in that file instead of searching for them in the controller, especially as you said, in a moderately sized project, I can't be bothered to search or check the controllers. (You can counter argue that I can just Ctrl+F it). When you open up the routes file, you can see all your definitions in one place, which might ease the onboarding of new devs for example.

<comment><USER31> Well, I'd still argue it would be cleaner if they're defined _at_ the controller (I would also say the controller does not define them, the controller has them defined as attributes to it's class). Java devs don't seem to have a problem handling the "look for what path this is" either, in reality it's a grep or global search from your IDE away to be found.

The routes file for any moderately sized project will likely be sufficiently complex that you cannot simply Ctrl-F it.

</comment></comment></comment></comment></comment><comment><USER34> I like the constructor property promotion, union types, improvements to exceptions and try/catch. Lots to like here.

Attributes worry me. Annotations are generally an eye sore to me, but in some places could be justified. For the most part, outside of Symfony, they were not used much. I'm worried that some developer will go bonkers with them, create a nightmare, and that will be the next legacy code base I inherit 5 years down the line.

Named arguments is okay I suppose, but IDEs solve knowing the order of arguments. I guess the IDEs will implement an auto complete for named arguments? I guess thats okay, but it will require more vertical code if you care about your lawn and keep your code in the PSR margins.

All in all I think this is a solid major, not the quantum leap we got from 5 to 7, but these are good additions. I'm sure we'll see plenty of decent additions in the minors.

<comment><USER35> > Named arguments is okay I suppose, but IDEs solve knowing the order of > arguments.

Named arguments are incredibly helpful for functions with a bunch of optional parameters, like setcookie() -- instead of

        setcookie("cookiename", "value", 0, "", "", false, true);

to set httponly (the last argument), you can now skip over the unused parameters and write:

        setcookie("cookiename", "value", httponly: true);

Not only is this more concise, but it's also self-documenting!

<comment><USER36> I would have personally been happy with

        setcookie("cookiename", "value", , , , , true);

As I used in VB.Net 15 years ago, I have no idea if other languages (C#?) support that

</comment></comment></comment><comment><USER37> for some reason (probably a bad one) i love switch statements and i look forward to the match expression

<comment><USER34> nothing wrong with switch statements.

<comment><USER38> Coerced-typed (weak) comparisons and easy accidental fallthrough are the problems commonly associated with switch statements.

The new match construct fixes both of these and is also an expression instead of a statement, allowing for more expressive code.

</comment></comment></comment><comment><USER39> Hooray! Named arguments finally!

</comment><comment><USER40> After years of being a laughing stock, it's nice to see PHP finally becoming a nicer language instead of basically being the "three languages in a trenchcoat" of programming.

</comment><comment><USER41> I've used PHP for many years, but decided to stop in 2018 for my sanity. Surprised it has basic pattern matching now, it is good for people to stop using imperative and mutable code where it isn't needed. Anyway, since I started to play with FP languages such as Clojure, Elixir and Elm, I am not interested in most of OO/procedural languages anymore.

<comment><USER42> Any appetite to try Scala?

</comment></comment><comment><USER43> I dont see the big deal to be honest. If youre using == you're probably approaching the conditional too sloppily to begin with

</comment><comment><USER44> When they add generics there will not be anything i really miss from other languages when writing php. Ok tuples or simple struct types (type enforced arrays?) would ne useful too, but phpstan/psalm can solve this problem too

</comment><comment><USER45> What is the point of "Non-capturing catches"?

These kind of features would make debugging harder as people just ignore the actual error object and write weird common error message which could be useless.

</comment><comment><USER46> > Note that void can never be part of a union type, since it indicates "no > return value at all".

The empty set is the identity element for set union! It seems very weird to exclude it.

<comment><USER47> But "void" is not an empty set, it is no set at all...

<comment><USER48> if we want to squint and talk about sets and functions from sets to other sets...

      function voidy() : void {
        return;
      }

      echo json_encode(voidy()); // -> "null"

so i'd say that for most purposes

      void ≡ {null}

a singleton set, more or less[1], sometimes called a "unit type". that's because a void function does return _something_ , it's just entirely uninteresting :) that's different from an "empty" type

      impossible ≡ {} // or ∅

with no values. there are no values of type `impossible`, so `foo() : impossible` can never return _anything at all_ , like this:

      function foo() : impossible {
        while(1){}
      }

see mypy's `NoReturn`, Rust's `!`, Haskell's `Void`. it's used for giving a type to functions like `exit()`

[1] kind of, because it won't let you `return null` explicitly.

</comment></comment></comment><comment><USER49> That's some huge release feature-wise.

</comment><comment><USER50> Oh I read this as "What's New in PDP-8?"

Was hoping for some awesome mods for a refrigerator-sized computer...

</comment><comment><USER51> An ancient evil is awakening</comment>


Beware of Coinbase. They Reversed My BTC Sale - <AUTHOR> I sold 5 BTC on December 6th: http://d.pr/i/n9Zc
Couple of days later the BTC showed up again in my account saying they needed to "offset" my transaction which makes no sense because I originally purchased the BTC using Coinbase. I let it be. On December 13th I got a notice saying that the sale had finally completed and so I waited hoping any day my bank account would be credited with $4,118.94.
Instead of the money, they added a transaction to my account saying that I had "Purchased" 5 Bitcoins which I never did. So now instead of having sold 5 BTC at $832. I'm holding 5 BTC at a much lower price which I never wanted. How convenient Coinbase. You obviously benefited from my sale because you sold my coins to someone. And now you conveniently added it back into my account since the price is lower.
The worst part of all this is that I have opened support tickets, tweeted at them, wrote an email directly to the CEO Brian Armstrong. And there is nothing but silence. I even wrote a blog post: amit.roon.io/an-open-letter-to-coinbase
Things can go wrong in a fast growing startup but ignoring customers is the worst thing you can do. <comment><USER2> I will refrain from calling out coinbase for their alleged improper management and execution of transactions(alleged by me in great details in the previous threads) due to retracting a couple of my comments (on my own behest) due to drawing conclusions based on misunderstanding a reply to one of my posts. I have decided to subdue my biases against CoinBase practices for a few days for health reasons.

But, some of the issues that were highlighted may be prevalent here, as they do seem to behave like an exchange (even though they are allegedly not one even though they fit the definition).

Before someone points this out, its true that bitcoin is not recognized as a currency in the US, but it is considered a security by SECs definition of what a security is.

By CoinBase's definition they buy and subsequently sell or buy-back BTC like an ecommerce product. Wonder why an e-commerce product previously sold by them would be "offset" or reversed due to potentially fraudulent activity?

Also, it can be alleged that the OP is not being completely forthright about the full story? I don't believe that the OP is hiding anything.

If the OP did send and receive BTC thus technically having different BTC than the ones CoinBase sold to the OP is there any reason that all incoming BTC transactions cannot be classified as fraudulent?

I will not personally answer any of these questions even though I want to.

The previous threads are at: [0] [https://news.ycombinator.com/item?id=6929705](https://news.ycombinator.com/item?id=6929705) [1] [https://news.ycombinator.com/item?id=6933360](https://news.ycombinator.com/item?id=6933360)

edit: spelling and grammar

</comment><comment><USER3> Time to stop these posts. This isn't coinbase support and it isn't a forum to air your problems.

<comment><USER4> I'm glad all of these threads happened. Now I know that Coinbase isn't a reputable company and I should never trust them with my money.

All of these posts show the truth, even when YC posts things like this:

[http://blog.ycombinator.com/coinbase-yc-s12-is-becoming- the-...](http://blog.ycombinator.com/coinbase-yc-s12-is-becoming-the-most- trustworthy-consumer-brand-in-bitcoin)

<comment><USER5> I've been more than pleased with the service Coinbase provides. I have been a customer for almost three months and have bought and sold several thousand USD worth of BTC in that time.

How do you know these posts show the truth? What if these poor experiences we see posted on Hacker News are occurring at a rate of 1 in every 1000 Coinbase transactions or even 1 in 10,000 transactions? I agree that with money the error rate should be low, but BTC is the wild west.

You're taking on risk wherever you buy and sell BTC these day. As a US citizen, I'd rather take a little bit of risk with Coinbase, a US-based company supported by reputable US-based VCs, than take on the risk of sending my money to Slovenia or Japan -- not to mention the extra fees to do international wire transfers to/from those countries.

</comment></comment></comment><comment><USER6> You only need to know two things about BTC. Both courtesy of @ReformedBroker (but origin may of course be elsewhere).

Don't get me wrong, I really really really wish that a practical and honest and low-friction anonymous virtual currency existed. It doesn't currently. Bitcoin isn't it.

1) "You know what's cooler than a million dollars? Virtual currency backed by nothing and nobody."

2) The second explains BTC using a Venn diagram. If you don't understand this diagram, you're the ideal BTC user. [http://www.thereformedbroker.com/2013/11/20/bitcoin- likely-u...](http://www.thereformedbroker.com/2013/11/20/bitcoin-likely-users- venn-diagram/)

</comment><comment><USER7> They probably reversed it because they (wrongly) suspected fraud. I'm sure it's well within their Terms of Service.

You're the one gambling money on an unproven digital currency, created by an anonymous person on the internet, via an unproven and completely overwhelmed little startup. If you can't handle losing money on a failed transaction then don't play the game.

<comment><AUTHOR> It wasn't a failed a transaction. They never said the transaction failed. I got a confirmation that the sale was completed.

<comment><USER7> It's failed if Coinbase suspected fraud and it's reversed.

<comment><AUTHOR> From their Terms of Service:

> 3.5 When buying or selling bitcoin, you are buying or selling from Coinbase > directly. Coinbase does not act as an intermediary or marketplace between > other buyers and sellers of bitcoin.

<comment><USER7> Also from their Terms of Service:

> _Coinbase may cancel or reverse potentially high-risk buys or sells of > bitcoin, including those made using reversible payment methods._

Could very easily be that your transaction was flagged and then reversed. Your BTC was returned in full. If the price had gone in the other direction I doubt you would be offering to compensate Coinbase for the difference.

<comment><AUTHOR> If it failed then why did they take 7 days to return my BTC? That's the benefit of BTC that things can be verified in a matter of minutes.

<comment><USER8> coinbase has been overwhelmed with increased volume and rapid fluctuation in the last two weeks. As staunch has said, to have only lost time in the transaction process and missed chances to get in or out at a particular price was an inherent risk in placing the transaction in the first place.

I have also been held up by coinbase delays in transactions over the last few days (though nothing was reversed), so I empathize with the pain. If you know of a more reliable and more quickly servicing online bitcoin exchange, I know many who would be happy to hear about it.

</comment></comment></comment></comment></comment></comment></comment><comment><USER9> Heh, they're not exactly _IGNORING_ customers. They're using them as milking cows.</comment>


Dave McClure's Investment Thesis - <AUTHOR> http://www.fastcompany.com/1676896/moneyball-for-startups-invest-before-productmarket-fit-double-down-after

<comment><AUTHOR> Actually I should have pointed to Dave's own site.

[http://500hats.typepad.com/500blogs/2010/07/moneyball-for- st...](http://500hats.typepad.com/500blogs/2010/07/moneyball-for- startups.html)</comment>


Ask HN: Which payments processors to use for recurring subscriptions in India? - <AUTHOR> Hi,
What are Indian startups using to create recurring subscriptions, especially for SaaS sites?
1. Right now Stripe is not available in India (big hopes for Stripe atlas).
2. Paypal is what everybody loves to hate but so far it looks the most promising (unfortunately they prohibit India to India transactions)
3. I used a site called 2Checkout in the past but my experience was horrible. I lost a good amount of money with them because their fraud detection is very poor, and customer support is even worse.
4. Most other services also require a US/UK bank merchant account, TIN number, etc about which I don't have even the slightest idea.
So what other options are there? Right now I'm going with Paypal but would love to hear what other SaaS startups in India are using (especially those catering to a Global audience) <comment><USER2> About 3 years ago I was researching the same thing. There wasn't a lot of options then, and I still don't think there's a lot of options now.

Wrote a blog post to document what I found: [http://www.redbridgenet.com/indian-payment-gateways-no- recur...](http://www.redbridgenet.com/indian-payment-gateways-no-recurring- billing-services-available/).

There's some links in there to discussions of the same. The Quora discussion is starting to fill up with what I think is spam for services that don't exactly solve the problem, but it might be worth checking out.

<comment><AUTHOR> Thanks. I did come across this link from Google and also the said Quora post. It's very unfortunate that even though there are so many good Payment processors like Stripe, Google, Amazon, Authorize, etc they're mostly restricted to the US.

Also I think a lot of these companies are having a hard time because RBI has this strict OTP only policy so this isn't going to change anytime soon (like you said it was same 3 years ago also).

Anyway, I came across few companies that will setup a US bank account and register a Delaware corp for about $500. It's throwing money down the drain because they don't guarantee anything but it may be worth a shot? I think the founder of SupportBee did this [1]

[1] [https://www.quora.com/How-does-SupportBee-or-any-Indian- star...](https://www.quora.com/How-does-SupportBee-or-any-Indian-start-up-use- Stripe-to-collect-payments)

</comment></comment><comment><USER3> [https://razorpay.com/](https://razorpay.com/) [https://instamojo.com/](https://instamojo.com/)

definitely some more

<comment><AUTHOR> I don't think either of them support recurring subscriptions like Paypal or 2checkout

<comment><USER4> The problem with recurring billing in India is that it doesn't work at all with the RBI 2 factor guidelines. We do have Standing Instructions, but they are harder to support for SaaS companies.

If you rely on a service like PayPal/2Checkout, you face other issues:

1\. Only international credit cards work. Indian market is heavily biased towards Debit Cards as of now 2\. your money is processed internationally, which has it's own share of issues.

Disclaimer: I work at Razorpay

<comment><AUTHOR> This is fine for my use since I have a SaaS startup and most of our customers are from US/UK only. I think less than 2% of our customers are from India right now and they were able to pay with 2checkout with automatic recurring billing (without requiring otp).

<comment><USER5> The RBI regulation is for companies incorporated in India only. This is one of the reason why Indian startups incorporate out of the US, Singapore etc.

</comment></comment></comment></comment></comment><comment><USER5>
        @vijayshekhar  Mar 4
        "@ConversionChamp @vijayanands @RajanAnandan @dkhare we offer recurring on CC too!"

Paytm now supports recurring payments on wallets. [https://twitter.com/vijayanands/status/705993389620092928](https://twitter.com/vijayanands/status/705993389620092928)</comment>


Free JetBlue Wi-Fi for Amazon Prime Instant Video - <AUTHOR> http://phx.corporate-ir.net/phoenix.zhtml?c=176060&p=irol-newsArticle&ID=2044079

<comment><USER2> Ouch for Netflix and others as it looks like movies will cost about $18 to watch.

"Services for bandwidth-heavy applications like streaming movies and large downloads will be available for purchase on our Fly-Fi® Plus plan at $9/hour"

[http://www.jetblue.com/flying-on- jetblue/wifi/](http://www.jetblue.com/flying-on-jetblue/wifi/)</comment>


Startups should make something people want - <AUTHOR> http://www.gooddinosaur.com/2010/03/kevin-costner-is-full-of-sht.html Kevin Costner is full of sh*t ... when it comes to startups at least. Build it and they will come. I implore you, do not listen to this man! This line of thinking is out in left field (har har).<p>I have to admit, I used to subscribe to this tag line. A few years back, I felt that if the idea was there, all that was barring a venture from success was time, effort, and determination. As a result, several of my early projects were drastically over engineered and tragically under utilized. <comment><USER2> I don't recall Kevin blogging about startups. It was a movie. Honestly, this title seems a little over the top.

As for the advice... It's good but there is a world of difference between testing something you've built and asking people if they'd want something you haven't built. In "The Innovator's Dilemma," the case of excavators is used as a case study.

If you had asked construction managers whether they wanted hydraulic excavators instead of cable excavators, they would have laughed you out of the industry. The hydraulic excavators of the day were flakey and much smaller than the cable excavators. Nobody who was using excavators would want one.

The point was that hydraulic excavators ended up creating entirely new markets. Likewise, my own personal example is the GUI. I remember when this was just a research fancy at Xerox. I used a Xerox Star at Humber College in Toronto. Great stuff, but priced in the stratosphere.

If you'd asked anyone whether they needed a mouse and bitmapped screen to replace their CP/M word processor, you would have been laughed out onto the sidewalk.

Yet look at what we have today. Some things should be shown, and even then you might have to keep plugging until a light goes on and some entirely new market (like desktop publishing) springs up to use your innovation.

<comment><AUTHOR> I think testing / getting feedback on your vision is vitally important. You aren't going to get buy in from all (or any), but it will give you more of a sense about your venture's risk profile. You can then better evaluate if you want / can continue your time and effort investment.

I'm running on a dime and a dream quite often so this exercise is very important. I'd argue that your examples (which are very, very good ones) demonstrate market participants that could take on a much riskier venture than many would be capable of undertaking.

My point is to not blindly push forward (a mistake I have made many a time, and one that I've seen others around me committing as well), but to size up what you are venturing into whenever possible. I'm completely fine with attempting to turn the tides of an industry or make a new one, but I want to know if that is the fight I'm gearing up for ahead of time if possible.

Thank you for your insights!

<comment><USER2> I agree with your caution. Again with my example, if you look at Xerox, Apple, Microsoft, IBM, and a plethora of companies that have tried to make money selling PC hardware, you see that although the mouse and GUI have obviously "won," actually making money from them has been a challenge.

</comment></comment></comment><comment><USER3> I completely agree with this. As the article mentions with shoestring resources it's helpful to make "bang for the buck" choices. For any given successful product, there will be a few things that really resonate with or significantly help the user. The trick is figuring out what these things are. If you hit upon a truly valuable function, chances are your user base will grow even if there is not much else other than that available. A great example of this is Google. When Google was just starting out there were many popular search engines, and the biggest, Yahoo, had tons of money, resources, and content/features available from their homepage. By contrast, Google had a simple search box on their page - but the results returned were clearly superior. The rest, of course, is history. Sure Google now has email, docs, apps, calendar, social services, etc. but they didn't start out that way, and didn't need to. I believe the best strategy is to try and figure out what will really benefit users, not the nice to haves, but what really benefits them, and focus on building that to the best of your ability. Don't sacrifice quality. How you solve the problem should be as top notch as you can make it, but solve the problem and that's it; don't get distracted. Then test it out and see where you stand.

</comment><comment><USER4> I always find it funny when people who write link bait titles can't seem to find the guts to spell out their curse words.

</comment><comment><USER5> I think usability testing is important(Shout out to Steve Krug:<http://bit.ly/dloM7j>) but you can't be a slave to it. These days one of the criteria I use when picking services is "how dedicated does the company seem". After having my stuff disappear with a few failed startups I've come to value someone who goes all-in.

When I see a startup shooting for "minimally viable" I head in the opposite direction.

<comment><USER6> Interesting perspective. I tend to agree -- and with the MVP concept taking hold, it can be tempting to release _too_ early. Figuring out where to draw the line can be tough though, especially when you are operating on a shoestring.

One thought/question: How much of an impact does a high-quality graphic design have on your perception? I'm betting that going the extra mile on the visuals can strongly aide the perception that the company is legit.

<comment><AUTHOR> prosa, great question - 100% think you must have a graphically appealing product out of the gate, but like you said, it is a fine line that you must walk. I try to test my thesis early and often, but my tests will only be taken serious if I put something out that is engaging. Quality must be there, but be mindful to not get caught up in the "extras" that will delay seeing if you should continue down your current path or course correct.

</comment></comment></comment><comment><USER7> I am curious at how Apple does it. With their secretive nature, do they go out to show customers what they are building? Or Steve Jobs just has great insight into what customers need and build it for them.

<comment><AUTHOR> I wonder the same thing - personally, I think AAPL and Jobs are just that talented that they can "get it right" (extremely hard to do) ... I'm sure they do get out of the lab and get some real world feedback to some degree. But also remember, Jobs has seen his fair share of failed product introductions!

</comment></comment><comment><USER8> I don't remember that being Kevin Costner's line. Shouldn't it be "James Earl Jones is full of Sh __t"?

</comment><comment><USER9> Wouldn't some commentary or analogy on _Waterworld_ be more apropos?

</comment><comment><USER10> celeb name + "sh*t" => HN homepage</comment>


What Americans Keep Ignoring About Finland's School Success - <AUTHOR> http://www.theatlantic.com/national/archive/2011/12/what-americans-keep-ignoring-about-finlands-school-success/250564/

<comment><USER2> tldr; Finland educational policy is driven mainly by ensuring equity to all, and is the primary factor in producing the excellent PISA results.

Executive summary:

\- Focus on equity ("every child should have exactly the same opportunity to learn, regardless of family background, income, or geographic location"); all pupils get free school meals, easy access to health care, psychological counseling, and individualized student guidance.

\- Lack of standardized testing (only exception is the National Matriculation Exam, which everyone takes at the end of a voluntary upper-secondary school, roughly the equivalent of American high school).

\- Teachers are trained to assess children in classrooms using independent tests they create themselves.

\- Periodic testing of a few sample groups across a range of different schools to track national progress.

\- Lack of institutionalized accountability of teachers and administrators; if a teacher is bad, it is the principal's responsibility to notice and deal with it.

\- Teachers and administrators are given prestige, decent pay, and a lot of responsibility; a master's degree is required to enter the profession.

\- Finland is a relatively homogeneous country (<5% born in another country); however, PISA comparison with Norway suggests that educational policy "is probably more important to the success of a country's school system than the nation's size or ethnic makeup". ("Like Finland, Norway is small and not especially diverse overall, but unlike Finland it has taken an approach to education that is more American than Finnish.")

Per <http://en.wikipedia.org/wiki/Education_in_Finland> : Finnish education system consists of: (1) daycare programs for babies and toddlers; (2) one-year "pre-school" (or kindergarten for six-year olds); (3) nine-year compulsory basic comprehensive school starting at age seven and ending at the age of sixteen; (4) post-compulsory secondary general academic and vocational education; (5) University and Polytechnical higher education; and adult (lifelong, continuing) education.</comment>


How Do You Like We Now - <AUTHOR> https://www.bloomberg.com/opinion/articles/2019-10-23/how-do-you-like-we-now <comment><USER2> When you've got supermajority shares, you can basically put a gun to your own head.

Great summary of the situation from the article: "Neumann created a company that destroyed value at a blistering pace and nonetheless extracted a billion dollars for himself. He lit $10 billion of SoftBank's money on fire and then went back to them and demanded a 10% commission. What an absolute legend."

<comment><USER3> It amazes me that they didn't call his bluff. They could have said, "We'll let you keep some of your shares, so if this ever works out, you'll make some good money." Because if somebody didn't put up a lot of money, Neumann would get bupkis. His negotiating position was extraordinarily weak.

But clearly this is about preserving Masayoshi Son's ego. And reputation, of course. Why would he care if he burns another 5 billion if it helps him keep getting future $100bn investments from his LPs?

<comment><USER4> > It amazes me that they didn't call his bluff. They could have said, "We'll > let you keep some of your shares, so if this ever works out, you'll make > some good money."

If they had said that, Neumann would have just continued to nuke the company until SoftBank's remaining $8 billion of equity in the company went to $0. SoftBank paid him off to prevent him from further destroying the company.

<comment><USER3> Why exactly would have he done that? His shares would go to zero as well, and he'd have been more clearly associated with the failure.

</comment></comment></comment></comment><comment><USER5> Watching WeWork's IPO fall apart was satisfying because it felt, in part, like a small bit of justice being served.

Sadly, this outcome for Neumann is the undoing of both that sense of satisfaction and of justice.

(Note to self: don't let this jade you. Keep focusing on creating wealth by creating value.)

<comment><USER3> Steve Blank, I think in his original, self-published "Four Steps to the Epiphany", said something like, "But if another bubble comes along, ignore all this, because my advice only makes sense if creating value for customers is rewarded".

I think he was right, and I really hope WeWork is the end of the "Uber for X" wave, wherein losing gobs of money was somehow seen as a sign of success, and not a cause for great shame. It's be nice to get back to actually serving customers.

</comment></comment><comment><USER6> [https://outline.com/V5eEFX](https://outline.com/V5eEFX)

</comment><comment><USER7> "[SoftBank] put into WeWork, an astounding total of more than $18.5 billion for a company it values at $8 billion."

Wow. I think when they do end up writing that HBS case, this will also serve as a wonderful example of sunk cost fallacy.

<comment><USER8> Not really - they just bought it on a Huuuuuuge discount compared to what, a month ago?

<comment><USER9> It being the value they already tied themselves to? It's technically correct, but Neumann seems to have understood they could either buy him out now and save some of that value, or not buy him out now and lose most of it.

</comment></comment></comment><comment><USER10> The penultimate slide (132/133) of the Softbank Vision Fund deck from 6/25/2010 is just the words "We (movie)". This now sounds prophetic. If you're curious, you can see the whole strange deck here: [https://cdn.group.softbank/en/corp/set/data/irinfo/presentat...](https://cdn.group.softbank/en/corp/set/data/irinfo/presentations/vod/2010/pdf/press_20100625_01.pdf?fbclid=IwAR1SyvfHXENSyQ_0eT6IRGDRK5g0dhdkLm9J34EI9GfxXqBI8H1jVzTIxQ8)

<comment><USER11> Are we on pace for the CPU, Memory, and Network projections for 2040?

It has microprocessor transistors to go from 3bn to 3 quadrillion. Memory to go from 32Gb to 32Pb. And network speed to go from 1Gbps to 3Pbps.

I was under the impression that it's looking very unlikely for CPUs to transistors to keep growing exponentially, and that Moore's Law stopped a few years ago? Will we not run into similar physical (?) limitations for memory and bandwidth in the near future?

<comment><USER10> I have no idea. I meant my comment in jest— this episode is likely to end in a movie about We— since there's no evidence MS had heard of WeWork as early as 2010.

</comment></comment></comment><comment><USER12> Matt Levine is amusing as always, but I'm wondering what really happened at Softbank? How did they end up trusted with huge amounts of money?

<comment><USER13> S__D_ _R_B__

Would you like to buy a vowel?

<comment><USER14> Which makes me think, MBS may not be as amused as we are and the odds of Neumann falling in a meat grinder are non null...

<comment><USER13> If I were him I'd be more worried about being seen on the street in any city where there's a WeWork by a current/former employee who went from planning how they were going to spend their options windfall to wondering how they were going to pay the mortgage next month.

</comment></comment></comment></comment><comment><USER15> I like We even less since Neumann was handsomely rewarded for his misbehavior.

</comment><comment><USER16> [http://archive.is/SHVCO](http://archive.is/SHVCO)

</comment><comment><USER17> It is pretty interesting watching Neumann get demonized in realtime. It's not like he broke into people's homes and stole a billion dollars. Softbank gave it to him, and apparently thought everything was going great until a couple months ago. That was their money to set on fire, I have no skin in this game and no reason to hate him.

The part I do agree with is the workers who are angry at him for getting rich while they're about to lose their jobs. Terrible optics, for one thing.

<comment><USER3> Do the math on how many seed and A rounds that could have been funded with what he burned. That certainly gets me mad, all those entrepreneurs who didn't get a shot.

<comment><USER18> Fuck seed rounds. How many homeless people could be given shelter with that money? How many starving people could have been fed? How many people who died needlessly because they were unable to afford medical treatment could have lived if this money had been given to them instead? There is a tremendous moral rot at the core of American capitalism, and the story of We is exhibit A.

<comment><USER19> The wealth that was being destroyed from the perspective of society, or the starving, is the losses of WeWork day by day and year by year.

I think it's important not to confuse that with the wealth that was merely transferred from one book entry to another.

The spectacular destruction of the abstract entity ensures that the slow bleeding doesn't go on.

Like, if I have $1B, which is really just a note in a computer and you steal it from me by hacking that computer, or playing a confidence game, that's not the same as if a billion dollar factory burns down.

<comment><USER15> > you steal it from me by hacking that computer, or playing a confidence game, > that's not the same as if a billion dollar factory burns down.

I honestly don't follow this logic. What is the essential difference?

<comment><USER19> The difference between kicking a stuffed toy and a live pet?

<comment><USER15> I don't see how that's an apt analogy at all. Both of the circumstances you cite appear to be the same fundamental thing to me -- they're both live pets, just of different breeds.

<comment><USER19> Money in an account is just a note that someone is entitled to actual resources at some indefinite time in the future. You don't see a difference between erasing that note and destroying the resources it quantifies? I mean, I'm not saying that what people write down can't affect the real world, but it's a fundamentally different thing from the physical world. Erasing a number could have any positive or negative consequence, maybe soon, maybe far in the future. It's very tenuous. Destroying the _stuff_ has a specific cost, for certain, that applies to society and not just the owner. Destroying or wasting _stuff_ in large amounts is obviously "stealing" from the needy, while numbers changing because of people having their hopes and dreams deflated is not.

When hopes and dreams die, the cost or benefit depends entirely on how it motivates humans, which is very complex and often unpredictable, but can as easily be good as bad, even if it's painful.

Perhaps I am talking to a being from another dimension, or a ghost who exists only on the internet, in which case I'm probably wasting electrons.

How about this:

Suppose you have a lottery ticket, and you think you've won $1M. But then you notice that you read a number wrong, and it's actually worthless. You may feel like you've lost $1M, but actually you just gained something extremely valuable - if you continued thinking you'd won, you might have done something destructive like quit your job before you found out you didn't. And that action in the real world, would have had negative consequences for you, your employer, your loved ones, and so on. Society in other words. For some reason, even (or maybe particularly) people who think money is evil fall into the trap of thinking it's real as...(google says "a donut").</comment></comment></comment></comment></comment></comment></comment></comment>


HTC Hero Kernel Source Code Released - <AUTHOR> http://phandroid.com/2009/10/22/htc-hero-kernel-source-code-released/

<comment><USER2> Correct me if I'm wrong. But it seems that HTC is the more developer friendly company among the various Android packagers.

I was so keen on getting a Samsung I7500, but HTC seems to be much better in packaging the latest release and also releasing the source.

<comment><USER3> I would tend to agree, but it might be unfair, I have a bias towards HTC because of their overall high level of quality.

Bias aside, they seem to be very committed to the nature of AOSP and they also seem motivated to help it grow.

</comment></comment><comment><USER4> To be clear, HTC was legally required to provide the source code and it apparently took prodding from developers of the code they used to make it happen[1].

They may be more developer friendly than other Android packagers, but I wouldn't consider the release of this code as evidence of that.

[1] [http://www.phonenews.com/htc-releases-hero-source-code- for-d...](http://www.phonenews.com/htc-releases-hero-source-code-for- developers-9308/)

</comment><comment><USER5> I love my HTC Hero! :)</comment>


Ask HN: Who Is Baking? - <AUTHOR> I've been baking a lot while working from home. I posted a video today on how to make ciabatta during your pomodoro breaks. Check it out! <comment><USER2> I mentioned in your other post that I made bread earlier today. It's cooling off now. [https://imgur.com/gallery/E0xaCys](https://imgur.com/gallery/E0xaCys)

I think if I got the camera angle and lighting right, I could totally make an Instagram shot of it. Funny how there's always that ONE part that wants to stick out.

<comment><AUTHOR> Nice! All for the gram... all for the gram

</comment></comment><comment><USER3> I make sourdough breads. I highly recommend Mick Hartley's recipes and ebooks at [https://thepartisanbaker.com/](https://thepartisanbaker.com/)

His approach really appeals to me, and to other hacker-y types that I've shared it with. He's tested a lot of the various steps that people recommend during baking, and documented which of them actually seem to make a difference.

<comment><AUTHOR> I like this approach

</comment></comment><comment><USER4> I baked some pandesal and some gluten free, egg free carrot cake. Still trying to perfect the pandesal. I skipped the second rise on first try. It came out too dense.

I will make some banana bread today. I usually make it every two weeks.

</comment><comment><USER5> Great work! happy to hear that also other people bake! I started baking croissants, and I couldn't believe that I could get such good results at home. Next challenge is bread and then homemade pasta!

<comment><AUTHOR> I need to get started on croissants, or better yet pain au chocolat. What recipe do you use?

<comment><USER5> this one; [https://www.weekendbakery.com/posts/classic-french- croissant...](https://www.weekendbakery.com/posts/classic-french-croissant- recipe/)

my suggestions would be to focus a) on ingredients (make sure you get the right flour and butter, plays a huge role) and b) temperature. The colder it is the easier it will be to get a good result!

P.S: the website contains a lot of interesting recipes

</comment></comment></comment><comment><AUTHOR> [https://www.youtube.com/watch?v=ig6vqqHHulw](https://www.youtube.com/watch?v=ig6vqqHHulw)

</comment><comment><AUTHOR> If you take 10 min tonight to make the starter (poolish), you'll be good to go to make the main dough in the morning!

</comment><comment><USER6> thats dope man</comment>


Web app listing ALL transactions between gov and private sector in Slovenia  - <AUTHOR> http://supervizor.kpk-rs.si/ Anti-corruption office in Slovenia publishes a web app that lists _all_ transactions between governmental entities and private sector from 2002 till now. With a great user interface.<p>They got geeks to do it right. And now shit is starting to hit the fan. <comment><USER2> people are already scavenging over data and finding dubious and interesting(funny?) transaction info

to give just two samples (on funny side) of how the data looks:

police seems to be mostly buying meat

<http://supervizor.kpk-rs.si/organ/17140/>

they smoke huge amounts of tobacco in some retirenment homes

<http://supervizor.kpk-rs.si/podj/31627528/>

Of course the real point is in exposing the corruption!

<comment><USER3> Union, country's largest beer brewery gets most of their (public sourced) income from Ministry of Defense ;)

[http://translate.google.com/translate?js=n&prev=_t&h...](http://translate.google.com/translate?js=n&prev=_t&hl=sl&ie=UTF-8&layout=2&eotf=1&sl=sl&tl=en&u=http%3A%2F%2Fsupervizor.kpk- rs.si%2Fpodj%2F43304699%2F&act=url)

</comment></comment><comment><USER4> What a great idea.

Apart from things that have a desperate need for privacy (and there really shouldn't be that many of those) - shouldn't every single financial transaction of every single publicly funded organisation be open to scrutiny?

<comment><USER5> I agree in principle, but it has the downside of raising the transaction costs significantly. When you hire someone to do a job, you need to be able rely on their best judgment. If you're going to expect being held accountable for buying a pencil from your brothers stationary shop, this encourages rampant unproductive CMA.

(Not that this isn't already a problem in government organisations).

</comment></comment><comment><AUTHOR> Twitter stream of what people are finding in the data: <http://twitter.com/#!/search/realtime/supervizor>

</comment><comment><USER2> While most gov's are locking down on people it's nice to see one (ours) that does it's job in this one, but major instance. Do something to serve it's people better.

<comment><USER6> What would really be good if deals were published before any contract is signed. That would enable fair competition.

</comment></comment><comment><USER7> We also have such a tool in Portugal for quite some time: <http://www.base.gov.pt/_layouts/ccp/ajustedirecto/list.aspx>

A more user-friendly frontend also available at <http://transparencia-pt.org/>

</comment><comment><USER8> People should not be afraid of their government. Governments should be afraid of their people...

Great job!

</comment><comment><USER9> This is great! If anyone has a link to a story done using this info please share. I really hope that Slovenians find a way to export this tool to other ex-YU republics. We _really_ need it.

<comment><USER6> Well, we already have one in Serbia: <http://portal.ujn.gov.rs/>

<comment><USER9> Hm, I checked the website but only managed to find a list of ads for public procurement. Slovenian app shows the flow of money from each particular public office to each private company. I might be wrong though.

<comment><USER6> Go to "search and review" and then to "public procurements".

On that page you can either search the database or click on today's data on the right side of the screen.

</comment></comment></comment></comment><comment><USER10> That should keep Slovenia off the Anonymous radar for a while :)</comment>


Bling – the $ of jQuery without the jQuery - <AUTHOR> https://gist.github.com/paulirish/12fb951a8b893a454b32 <comment><USER3> Yes, you can re-implement jQuery in 10 lines of code... if you only support 0.1% of the functionality of jQuery.

jQuery was a game changer for web client side development. Thousands of work hours have been spent on it. It had a specially important role of dealing with all the inconsistencies between browsers. If you don't use all the features, nowadays you can just create a custom build with the stuff you want.

If you don't need jQuery, maybe because you only care about modern browsers, or you use another library or you don't mind a bit of extra boilerplate for DOM manipulation, that's perfectly fine. But these kind of posts seem like mockery on the developers of a library that has provided extreme value for thousands for developers over many years.

<comment><USER4> You are arguing against a strawman - no one is claiming otherwise. All paul_irish wanted to show is that people often use jQuery without realizing that most of what they do is also possible with the current browser APIs. jQuery does a ton more (animation, ajax etc) - the point was not to "rewrite jQuery in 10 lines" (that's Zepto)

<comment><USER5> Zepto is more of a "provide the jquery interface you're used to" (and that people often find easier, probably by habit) for modern browsers without all the added compatibility in jquery. I don't like the way they present themselves (or at least did in the early days) but I believe they have a place.

<comment><USER6> I tried "Flot" charts library with zepto as a smaller replacement for JQuery, but it was incompatible with JQuery and uses a weird code style that is incompatible/slow with Firefox (and Zepto devs refuse to fix their code). In the end I replaced the few Jquery dependencies in Flot by hand. It's a shame that Flot still requires Jquery, it's a good charts library.

 _The primary problem is that the zepto.Z function overrides dom.__proto__, which prevents many JIT optimizations. Overriding an object 's __proto__ property is strongly discouraged and will be deprecated in ES6_ \--Firefox bug 947048

</comment></comment></comment></comment><comment><USER7> If you are using $ signs all over your code, they'd better refer to jquery and nothing else.

jQuery has, for better or worse, become such an integral part of web development, the $ namespace is pretty much owned by it at this point.

If you do want to use it for not-jquery, it should be something that is drastically different so someone new trying to patch a bug on prod doesn't run around in circles wondering why their code that should be working is not.

The bling.js project by repurposing $ into something that looks like it might be jquery but isn't, is just a bad idea.

<comment><USER8> It's not even a project, it's a GitHub Gist. Talk about a lot of fuss being made over nothing.

<comment><USER9> Sure, this is just an illustration. I hear Eric Meyer's normalization css was too -- more intended as a to-do list of elements you might want to consider reseting than something to include and then override. But then a lot of people ran with the idea of leveling all margins and padding with a global override to start with and then overriding that override (usually inadequately).

Of course, the horse is out of the barn on the personal $ library front, so maybe Irish doesn't have to worry about inadvertently influencing people badly. There already was a no-library/micro-library trend 4-5 years ago where lots of people would write their own tiny jQuery-like DOM utilities, and I've worked on a few projects where someone used jQuery-like idioms for their partial reimplementation (I call them "nayQuery"). Even the better ones are a pain where they subvert expectations. And of course, when someone later decides to add jQuery to the project (makes sense, jQuery does more and has an ecosystem around it), now you're using $ for the custom library and jQuery for jQuery, which is disorienting.

I've written my own version of what Irish presents here -- it's a useful exercise, I appreciate his contribution (helps me think about some different ways to approach it), and sometimes it's even concretely useful when you're getting started on a small project with a limited browser target where the rest of the codebase is going to be smaller than jQuery itself.

But when I write something like this, I _always_ name it differently than $.

</comment></comment></comment><comment><USER10> This does three things:

1\. Alias document.querySelectorAll to $. 2\. Alias node.on to node.addEventListener. 3\. Make NodeList a sub-type of Array (so you can use forEach etc on node lists as you would on arrays).

The $ of jQuery also does a few other things, e.g. create HTML elements from text ($('<div class="foo"/>') creates a div element with CSS class "foo") and wrap elements in a node list ($(document.body) creates a node list containing document.body).

<comment><USER11> 4\. Add NodeList.on, which adds the event listener to all nodes in the list

<comment><USER12> Without the eminently useful support for delegation.

<comment><USER13> This fork[0] adds delegation.

[0]: [https://gist.github.com/MadeByMike/7e7707eff116229a5948](https://gist.github.com/MadeByMike/7e7707eff116229a5948)

</comment></comment></comment></comment><comment><USER14> "jQuery is not need anymore with modern browsers."

Bull. Shit.

This document proves why, and is written by the _same guy_ that is now pushing this "you don't want jQuery!" stuff.

[https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0Rlh...](https://docs.google.com/document/d/1LPaPA30bLUB_publLIMF0RlhdnPx_ePXm7oW02iiT6o/edit#)

<comment><USER15> >> "jQuery is not need anymore with modern browsers."

> Bull. Shit.

Depends on the target environment(s). If you only want to support evergreen browsers then there is no reason you need jQuery; you're going to have the native DOM APIs and you don't care about compatability.

jQuery's big win is two fold, in my opinion. One it has awesome, chain-able syntax and two (most important) it has awesome backwards compatibility with terrible browsers. If you don't need two then is one worth bringing in another dependency? Maybe or maybe not.

<comment><USER14> > If you only want to support evergreen browsers then there is no reason you > need jQuery

False.

Read the _first sentence_ of the document I linked to.

"…developers should be aware that ditching libraries, like jQuery, can easily require large amounts of research on their end to avoid bugs ( __even in modern browsers __)."

Bear in mind it's _Paul Irish_ who wrote that.

<comment><USER15> > False

> Read the first sentence of the document I linked to.

Oh I did. Look through many of the bugs they outline; many are incredibly minor and inconsequential unless you're doing things related (or semi related) to supporting older browsers.

> Bear in mind it's Paul Irish who wrote that.

Yup; I don't see his posts being quite in conflict like many here seem to think. Plus his opinion has probably evolved overtime anyway (he wrote that document a year and a half ago).

</comment></comment></comment></comment><comment><USER16> This is all I personally ever need.

      function $(q) { return document.querySelector(q) }

<comment><USER17> I prefer:-

      function $(q, parent) { return (parent || document).querySelector(q); }

<comment><USER18> I'd also wrap it in a `[].slice.call`:

        function $(q, parent) {
            parent = parent || document;
            return [].slice.call(parent.querySelectorAll(q));
        }

<comment><USER19> Also see ES2015's Array.from()

        Array.from(<NodeList or other iterable>)

[https://developer.mozilla.org/en- US/docs/Web/JavaScript/Refe...](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)

</comment></comment></comment></comment><comment><USER20> Can someone explain the new trend to not use jQuery?

<comment><USER21> A lot of developers originally used jQuery as a cross-browser compatibility library when that was still a major concern. Along the way, jQuery has added tons of extra helper functions and wrappers (ie, .ajax(), .post(), event binding helpers, etc). This has been amazing for web development, but it's also been such a major pillar of web development that a lot of front end developers don't actually know what's happening under the hood when they use jQuery.

jQuery as a library has now become huge, and a lot of projects probably don't use the full feature set. With modern browser support converging and older browsers being edged out of the usage stats, there's not as much need for the cross-browser portions of the library anymore. Enough so that newer versions of jQuery have dropped support for those browsers as well.

So if you can cut down your cold cache loading times by not including the full jQuery library, that's probably a win (especially on mobile). You can do this by using a custom build of jQuery, but I guess some developers are taking this opportunity to go "back to their roots" and see how Javascript has changed since jQuery became a de-facto include in every project.

I think there's a lot more maturity in the language these days, and by using native JS methods there's probably opportunities there for browser optimisations that aren't available using helper methods written in JS that accomplish the same functional goals.

But I'm not a browser devevloper or a JavaScript expert, just a long time web developer who remembers the times before jQuery was in every project. If it's a crutch, it's one I will remember fondly.

<comment><USER22>
      > jQuery as a library has now become huge

      > So if you can cut down your cold cache loading times by not
      > including the full jQuery library, that's probably a win

jQuery 1.11.3 is 38.4 KB when minified and gzipped.

jQuery 2.1.4 is 34.1 KB when minified and gzipped.

I'm all for eliminating unnecessary bloat, but it's not as if a jQuery download is a huge amount of data to fetch. While jQuery is not a framework, most front-end JS frameworks are the same size or bigger and don't receive as much attention for being bloated.

If you can get by without jQuery, or if you have a very large number of mobile users and first-load performance is mission-critical for your application, or if you have a large percentage of users from countries with slow or intermittent internet connections, then sure, avoiding jQuery makes sense as a priority. But for most applications, jQuery is a smaller download than a single medium-resolution highly optimized image, and it can be cached forever.

<comment><USER23> Loading over 30 Kb of minified/gzipped Javascript over a 3G connection on a mobile phone is very problematic, as the bandwidth is poor, the CPU capacity for decompressing and parsing is poorer than on the desktop, so the latency can many times be measured in seconds, therefore loading over 30 Kb of stuff that you don't need gets to be a tough pill to swallow. Also the argument of caching is often brought up, but in my tests this can be very non- deterministic, as mobile phones are pretty aggressive in their used storage. JQuery is supposed to be cached, yet in our A/B testing the load times and consequently the conversion rates improved greatly after we dropped JQuery.

Your comparison with "a single medium-resolution highly optimized image" doesn't hold for mobile phones. On mobile phones users expect latency when loading images, but not when loading the UI. Another problem is that JQuery is not the only commonly used library. You add Underscore, you add Angular, or whatever libraries du-jour we have and pretty soon we are talking about 100 Kb of stuff or even more that is rarely used as a whole.

Of course, my use-case is about having really simple interfaces augmented by Javascript and meant for mobile phones. Well, for complex interfaces I think bringing in JQuery as a dependency may be worth it, but then again, I then start thinking that JQuery is not enough. It's because I want more, I want a virtual DOM that's saner by design, I want to work with immutability, I want much better performance without unpredictable behavior (like what you get with Angular) and I want to only pay for the features I use. JQuery is incompatible with React and is incompatible with Google Closure in advanced mode.

<comment><USER24> It sounds like you've done the work to validate the fact that 30Kb is too much for your use case.

However, let's be clear here: most people who complain about the size of jQuery are doing so without any basis whatsoever. And even if people are measuring, they may not be measuring the right things. If not using jQuery causes you to reduce your Ajax usage, and reload entire pages as a result instead of only reloading the content, the end result is a slower site.

<comment><USER23> I totally agree and I exposed my use-case - really simple interfaces augmented by Javascript and served to mobile phones, so JQuery was basically unneeded, taking it out improved latency and thus it improved conversions. But of course, most people don't measure and most people need the features in JQuery to work reliably and to behave well cross-browser, in which case 30 Kb cached by a CDN is a steal.

</comment></comment></comment></comment></comment></comment><comment><USER25> My worry about using this is you'd better be damn sure you never actually use jQuery or libraries that integrate with jQuery if you're going to use it. I think this is a cool demonstration of the difference between some of the "convenience" functions of jQuery many are familiar with and the MEAT of jQuery which is the functionality and cross-browser issue smoothing.

</comment><comment><USER26> I don't really know what to think about that.

On one hand it may be a nice way to show to people that what they use in jQuery can be written in a few lines of pure JS.

On the other hand it encourages people who could use pure JS (because they only use a small portion of jQuery) to stick with some non-standard helper syntax.

<comment><USER27> > to stick with some non-standard helper syntax.

Or in other words - replacing an ugly, verbose API with a widely recognised alternate syntax!

<comment> anton-107 Yes "document.querySelectorAll(selector)" is a bit verbose, but jQuery API is no better, do you know what would "$(selector)" actually do? You can't - <USER2> depends on what "selector" is.

<comment><USER14> > "document.querySelectorAll(selector)" is a bit verbose

Right. 35 characters.

> "…but jQuery API is no better"

Your jQuery example is 11 characters.

I can't believe you're using verbosity as a measurement, while at the same time claiming 35 and 11 are the same.

Does. Not. Compute.

<comment> anton-107 Sorry for confusion, what i meant was: yes DOM API is a bit verbose, but jQuery is exactly the opposite in a bad sense: it's using too few words to express too many different things.

<comment><USER28> jQuery uses CSS selectors, which is fairly clear if you have a general understanding of them.

<comment> anton-107 So does querySelectorAll, that's not the issue with jQuery API.

The problem is that "jQuery" function, aliased as "$" has 9 signatures (doing 9 different things, depending on which arguments you send to it), while querySelectorAll does only one thing

</comment></comment></comment></comment></comment></comment></comment><comment><USER29> Well, the thing with jQuery is that if you use a CDN to get it from, then it is a very high chance that the client already has the library cached, so the bandwidth problem is actually not that much of a problem now.

<comment><USER30> It's probably better for most sites to minimize the number of DOM lookups by combining jQuery with the rest of your vendor code in a vendors.js (or similar) file. The chance for a cache hit is very low (and getting lower with the trend away from jQuery).

That said, test the 2 approaches and see which works better for your site.

</comment></comment><comment><USER31> > [].slice.call( document.querySelectorAll('.foo'), function(){

When do you need to do that?

<comment><USER32> querySelectorAll returns a NodeList instead of a real array, so you can't call things like `.forEach` on the result. `[].slice.call(x)` turns x into an array, so that becomes

        [].slice.call(document.querySelectorAll(...)).forEach(function () {})

Because a lot of array methods are "generic", i.e. operate on array-like objects instead of just arrays, that can be "compacted" to

        [].forEach.call(document.querySelectorAll(...), function () {})

but neither are very nice.

</comment></comment><comment><USER33> Here's an idea for a jQuery replacement: a website that allows you to select what browsers/versions you want to support, then it generates you a polyfill.

Then aliases `$` as a selector function.

</comment><comment><USER34> Shameless self promotion for something I threw together ages ago and may be implemented in a better way these days. [https://github.com/matt1/doc.js](https://github.com/matt1/doc.js)

So it uses "doc" instead of "$" but feel free to fork :-)

</comment><comment><USER35> When some part of jQuery can be replaced by native APIs so easy, it only shows how good jQuery was designed.

</comment><comment><USER36> I wrote a similar small dom module[0] which also fits in a gist with docs and tests :P --shameless-self-plug

[0] [https://gist.github.com/awalGarg/8a0e18c6fe87456d885f](https://gist.github.com/awalGarg/8a0e18c6fe87456d885f)

</comment><comment><USER37> Then you have the "" of jQuery: [http://www.francisco.io/fun-extending-native- javascript-stri...](http://www.francisco.io/fun-extending-native-javascript- string)

</comment><comment><USER4> Note that work is being done to give `NodeList`s the `Symbol.iterator` property so in new browsers it's trivial to use the native DOM with `for(let x of nodeList)` loops making our lives easier.

This will make our lives easier :)

<comment><USER38> But I must say that I don't really like the list comprehensions syntax in JS.It leaves a lot to be desired.

</comment></comment><comment><USER39> If you quite literally want "what jQuery uses to select things" and nothing else, you're really looking for Sizzle.

[http://sizzlejs.com/](http://sizzlejs.com/)

<comment><USER40> These days it's not Sizzle, which is mostly support for non-qSA browsers and support for custom pseudo-selectors. jQuery's modern element selection is [https://github.com/jquery/jquery/blob/master/src/selector- na...](https://github.com/jquery/jquery/blob/master/src/selector-native.js)

<comment><USER39> Nice, thanks for the update.

</comment></comment></comment><comment><USER41> I use jquery because I use bootstrap and it requires it for some features I use.

I wish that someone would write a drop-in javascript replacement for jquery in the context of bootstrap.

<comment><USER42> There's zepto.js, which is supposed to be a drop-in replacement for jQuery. Not sure how it fares wrt Bootstrap, though.

<comment><USER43> It is easy enough to just write a shim. Google "bootstrap zepto shim" to get you started.

</comment></comment></comment><comment><USER44> Nice. So where is my $.text(), $.css(), $.html(), $.val(), $.first(), $closest(), etc.?

<comment><USER45> With bling.js:

        .text: $('.selector')[0].textContent
        .css $('.selector')[0].style
        .html: $('.selector')[0].innerHTML
        .val: $('.selector')[0].value
        .first: $('.selector')[0]
        .closest: n/a

<comment><USER44> jQuery's $.text/html() set the text of all matched nodes, not just the first one.

I can use key-value object to assign multiple css property, and it can set the style on all matched nodes.

If there are no matched elements, Bling's $()[0].xxx = value" will raise exception.

<comment><USER45> That's the thing, Bling.js also makes it easy to set the text/css on all nodes:

        $('.foo').forEach(el => el.textContent = 'bar')
        $('.foo').forEach(el => el.style.top = '0px')

</comment></comment></comment></comment><comment><USER46> Tries to play it cool by wrecking jQuery? Check. No semicolons? Check. Put together by Paul Irish? Check.

Yep, this submission is Hipster 1.0 Certified.

<comment><USER47> 1) Paul Irish is a former jQuery team member and he has blog entries about how much he's learned from reading jQuery's source code, not sure exactly how he's "wrecking jQuery".

2) Semicolons are still in debate amongst the JS community, I don't think there's a consensus on whether they're needed or not and it seems to boil down to personal preferences.

3) This reeks of ad hominem, how exactly is Paul Irish "hipster"? Strikes me as someone who's done a lot of work to make the web a better place for all of us, fine with me.

<comment><USER48> > 2) Semicolons are still in debate amongst the JS community, I don't think > there's a consensus on whether they're needed or not and it seems to boil > down to personal preferences.

They are needed.

This

        var func = function(x) { console.log(x); };
        func;
        (42);

is different from this

        var func = function(x) { console.log(x); }
        func
        (42)

<comment><USER49> They aren't needed at all. Semicolons in JS are optional.

Knowledge about how ASI works, on the other hand, is mandatory.

<comment><USER15> > They aren't needed at all. Semicolons in JS are optional.

So they're not really _optional_. What they are is necessary and if omitted the engine attempts to put them in automatically. The rules for automatic semicolon insertion are in section 7.9 of the ECMAScript 5 standard ([http://www.ecma-international.org/publications/files/ECMA- ST...](http://www.ecma-international.org/publications/files/ECMA- ST/Ecma-262.pdf)).

This means you're omitting something that is required by the _engine_ but not necessarily required in the syntax which boils down to you losing control of where semicolons end up possibly making your code do something you did not intend because you either misunderstood the rules of automatic semicolon insertion or there was a bug in the syntax parser being used.

<comment><USER49> You're only "losing control" if you don't know how ASI works, which is well- defined in the ECMAScript standard.

Bad programmers that can't understand ASI will be also confused by the floating point semantics, promises and other basic concepts — there are many ways of "making your code do something you did not intend" in JS, but that's no excuse for bashing language features.

Fact check: ASI is a fully legitimate part of the language (as in, it's in standard, it's documented, and supported across the board), so demonizing it is every bit as silly as e.g. deprecating C macros.

Learning the language helps with the the issues you outlined, while magical thinking ( _uguuu, semicolons good, no semicolons bad, uguuu_ ) for the most part doesn't.

<comment><USER15> > Bad programmers that can't understand ASI will be also confused by the > floating point semantics, promises and other basic concepts — there are many > ways of "making your code do something you did not intend" in JS, but that's > no excuse for bashing language features.

This is a terrible attitude. There is no reason you may not understand every case in which a semi colon is automatically inserted but can still understand floating point, promises and other things. Automatic semicolon insertion isn't really a "basic concept"; it's a convenience for those who elide them and nothing more (the ECMAScript 5 standard even states this).

> Fact check: ASI is a fully legitimate part of the language (as in, it's in > standard, it's documented, and supported across the board), so demonizing it > is every bit as silly as e.g. deprecating C macros.

I'm not "demonizing" it but if you look at the standard the engine still _requires_ semicolons it just fills them in for you if you miss them. This is vastly different than your deprecation of C macros example. Yes it's documented but it's non-obvious unless you've literally looked it up to learn it. I'm also not sure why you insisted on letting me know it's a "fully legitimate part of the language (as in, it's in standard, it's documented, and supported across the board" when I linked to the standard and stated exactly where to look for its definition...

> Learning the language helps with the the issues you outlined, while magical > thinking (uguuu, semicolons good, no semicolons bad, uguuu) for the most > part doesn't.

Sigh. Automatic semicolon insertion is only documented. There are no errors or warnings or other information. Many developers, who understand more advanced topics, may not even know about it. The language does nothing to help with this. It's far better to be more explicit than assuming everyone who looks at your code understands the full ECMAScript 5 standard.

<comment><USER50> It's the same reason that, yes, you can put "var x" in an if-block, but it's bad practice because it misleads the reader (even one who _knows_ that Javascript is function scoped) into thinking that x is block-scoped.

<comment><USER15> I'm almost embarrassed to say it took me way to long to realize JavaScript wasn't block scoped.

<comment><USER50> Same here! It's probably the norm, honestly.

Javascript never should've had C-like syntax if it was to have the feature set it does. Its syntax descends from a tradition of languages that have _none_ of its actual features. Most other C-like languages have block scope[0]. So the syntax PLUS the terrible, awful, no-good very bad name lead you to believe it's more-or-less dynamic Java, when nothing could be further from the truth.

[0] ...and require declaration before usage, and have sensible 'this' semantics, and are class-based, and have function parameters that are more than just syntactic sugar, and have ACTUAL arrays, and...

</comment></comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER51> jQuery the useful parts.

</comment><comment><USER14> Let's replace non-standard JavaScript syntax-sugar with more non-standard JavaScript syntax-sugar. Except we don't like that the first non-standard thing is so terse so let's improve it with a more verbose notation. We don't want it to be too verbose though, so let's drop the semicolons.

This is definitely progress. I'm quite convinced that the users of our applications will feel the difference, and they'll love us for it.

Wow.

</comment><comment><USER52> funny! I had the same idea a few months ago, 1 extra feature: .off binding to removeEventListener ;)

[https://gist.github.com/vectorsize/feda8ac1ebc889c33b6f](https://gist.github.com/vectorsize/feda8ac1ebc889c33b6f)

not as tested as yours…</comment>