News for hackers. Stuff that matters.
Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @01:40PM (#15066171)
Do you guys use any public websites that are based Vue, React or alike?

Everytime I search for sites that use frameworks like Vue or React, I came up with mostly empty hands. Except for example pages or pages by coders for coders. Or pages that "use" one of the frameworks but seem to make no use at all of the functionality.

When I ask around people usually tell me "Well, at my company we make a dashboard for another company and it's based on ..."

Any popular public sites (Aka no login needed to access it. So Facebook doesn't count.) for non-coders out there that use these frameworks?

Re:Vue.js and Brunch: Webpack Alternative by jameshush on Monday August 21, 2017 @01:46PM (#15066207)
We're using React on NFL.com's new home page and Vue on https://nextgenstats.nfl.com/ (two different teams). AirBnB is mostly React too.
Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @01:57PM (#15066297)
Interesting. What would you say are the main advantages over simply passing the data through a server side rendering library?
Re:Vue.js and Brunch: Webpack Alternative by IgorPartola on Monday August 21, 2017 @02:09PM (#15066393)
Not the grandparent, but it makes things a lot easier.

Basically, think of something as trivial as form validation. You need to do it both client and server-side regardless, but client side you might have additional complexity, like "if paying by credit card, show those fields, and if paying by PayPal, redirect." This means that your server might need to be aware of these branches of state that might happen, and it means complexity.

On the other hand, if you keep UI state to the UI layer on the client, the server side becomes super simple: you have an API that says something like "here are the shipping and billing details using a credit card. Charge it" or "shipping and billing details + PayPal token. Charge it." There is no "if we are rendering a PayPal processing error, re-render the entire state of the page, preserving all the checkboxes and showing the right bits of the DOM." It's just pure business logic.

Something like Vue is also much better geared at doing a UI than a server-side rendered template. It's dynamic by nature, and directly affects the DOM. The state is kept in such a way that it pertains to the UI. If you are processing something like a request to /orders?filter=recent&order=amount&page=3, you have to re-parse the state from the URL and then get the results every time. Vue/VueX will keep the state in a convenient fashion and the URL can be instructed to reflect it. No need to write custom code to interpret it.

Simple CRUD stuff is super easy with Vue + VueX + Bootstrap + Django. That's been my stack and I like it. Complicated stuff if much faster to develop using this than to try to use something like Django templates + jQuery.

Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @02:14PM (#15066432)
Well, these are the general arguments for these frameworks. But how do they apply to the linked page? I used it for a while and did not come across a Credit Card vs Paypal form.
Re:Vue.js and Brunch: Webpack Alternative by IgorPartola on Monday August 21, 2017 @03:08PM (#15066876)
The linked page simply talks about Using a simpler compilation toolchain than the Vue standard one (Webpack), at the cost of it supporting fewer features. It's sort of like the argument of using clang vs GCC: it assumes you already are using C for your project, just talking about which compiler. Actually a better example would be autotools vs CMake.
Re:Vue.js and Brunch: Webpack Alternative by bigmanwalter on Monday August 21, 2017 @04:02PM (#15067368)
In my opinion, client-side rendering is here as a justification for the unfortunate splitting of the Fullstack developer into Frontend/Backend roles.

Frontend developer used to be a designer who also knew HTML/CSS but the problem with that is that in order to do CSS well, you need to be a programmer. Especially if you're trying to achieve effects that work best as a mix of JS/CSS. Unfortunately, when it comes to design, UX and UI, most developers are lazy and refuse to learn the basics of it. So in order to prevent PMs from assigning them design-related tasks, the role of Frontend developer was born.

And once there was a separate role, it only made sense to isolate the Frontend developers' environment from the backend developers' so that they could stop stepping on each others toes.

Essentially, the whole Single Page Application architecture is because there is a class of developers who imagine that it's sensible to completely ignore design considerations and who built a moat around their responsibilities in the form of an unnecessary abstraction. Now rather than our views having direct access to our databases, we need a separate API endpoint for every single database call and since we can't trust client code, we need to authorize/authenticate every single little action rather than being able to blindly trust the code that's being run like we used to.

Re:Vue.js and Brunch: Webpack Alternative by jdavis703 on Monday August 21, 2017 @05:31PM (#15068023)
Boy I don't mess the days of dealing with SQL queries inside of PHP "view" files. Reminiscing aside, you can build server-side applications in both Vue and React.
Re:Vue.js and Brunch: Webpack Alternative by bigmanwalter on Tuesday August 22, 2017 @12:28AM (#15069703)
I'm not advocating for SQL in views. MVC and ORM are great. As is free auth and form generation from database models. I haven't seen a framework that gives me everything that Django or Laravel does for free.
Re:Vue.js and Brunch: Webpack Alternative by k_sh on Monday August 21, 2017 @10:46PM (#15069354)
You are _completely_ missing the point of frontend applications, here's a few to get you started:

- Ease of creating complex user flows.

- Decentralization of application work: app runs on client, less CPU cycles for my server!

- Separation of concerns: API does one thing, client application does another, there is a bright red line between the two.

Re:Vue.js and Brunch: Webpack Alternative by bigmanwalter on Tuesday August 22, 2017 @12:33AM (#15069731)
You can build complex user flows with JavaScript on top of server rendered views. Ajax works great with server side rendering, see Pjax https://github.com/defunkt/jquery-pjax or Intercooler http://intercoolerjs.org/

The server is rendering JSON anyway, more or less just as expensive to serve HTML. Besides, the bottleneck is usually database access.

It's a false separation and forces you to expose far more than necessary. It's nice to have my full database available on every page render without needing to define explicit endpoints.

I also like having forms generated from database models.

Re:Vue.js and Brunch: Webpack Alternative by ericmcer on Monday August 21, 2017 @02:06PM (#15066371)
You don't have to render stuff on the server?
Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @02:14PM (#15066433)
I never felt any pain that my servers do rendering. Did you encounter any problems with it?
Re:Vue.js and Brunch: Webpack Alternative by abledon on Monday August 21, 2017 @03:48PM (#15067255)
Just install the React Developer Tool extension on chrome: https://chrome.google.com/webstore/detail/react-developer-to...

It will light up whenever you are navigating a page built w/ React. Plus, you can dig around and see how they structured it.

Some times you get funny surprises, like how the Microsoft node js page was using React, but they had deployed a Development build instead of a Production build.

Re:Vue.js and Brunch: Webpack Alternative by tym0 on Wednesday August 23, 2017 @09:32AM (#15081363)
Isn't it Slack that deploys a Dev build because "it's easier to debug people's problems this way"?
Re:Vue.js and Brunch: Webpack Alternative by dingle_thunk on Monday August 21, 2017 @09:00PM (#15068963)
... Microsoft keep doing that. They've deployed development builds to Office 365 production.

Incidentally, Office 365 SharePoint is built on React.

Re:Vue.js and Brunch: Webpack Alternative by literallycancer on Monday August 21, 2017 @04:18PM (#15067492)
For Vue, you can use the Vue Devtools extension to do the same. If they deploy in production mode you won't see any details though.
Re:Vue.js and Brunch: Webpack Alternative by CapnCrunchie on Monday August 21, 2017 @02:20PM (#15066473)
We use Vue at GitLab. You can see why we chose Vue as written by our front-end lead.

https://about.gitlab.com/2016/10/20/why-we-chose-vue/

Re:Vue.js and Brunch: Webpack Alternative by ElatedOwl on Monday August 21, 2017 @03:24PM (#15067015)
>A simple, but practical example we're using in production: on a GitLab Issue, the issue's state is displayed as either closed or open. That simple value can change often and needs to be represented in several views. With JQuery, we had about 30 or so lines of code to propagate those changes, and those lines involved multiple classes and querying the DOM by hand.

Yep, been there. That type of jQuery gobbledygook has resulted in more bugs than I'd like to admit slipping past my team.

Vue has been an absolute life saver.

Re:Vue.js and Brunch: Webpack Alternative by pythonaut_16 on Tuesday August 22, 2017 @09:01AM (#15071900)
Is there any plan to do a follow up post to this?

I'd love to see what work flows or examples you guys are using to progressively upgrade pieces of the application to use Vue.

For example, it would be really great to see a blog post with a before and after for a feature that you've converted from jQuery to Vue.

Re:Vue.js and Brunch: Webpack Alternative by CapnCrunchie on Wednesday August 23, 2017 @09:05PM (#15086784)
This was the followup post our front-end lead wrote:

https://about.gitlab.com/2017/02/06/vue-big-plan/

I don't think it's exactly what you were asking for, but I'll pass this suggestion along to our front-end lead that wrote these two posts.

Re:Vue.js and Brunch: Webpack Alternative by tylerlh on Monday August 21, 2017 @02:45PM (#15066683)
Netflix.com is built using React, including the non-authenticated experience (sign up, sign in, title pages, etc)
Re:Vue.js and Brunch: Webpack Alternative by jdavis703 on Monday August 21, 2017 @02:13PM (#15066431)
At issuu we do a lot of React work. Our document viewer and document page are built with it: https://issuu.com/mintymagazine/docs/minty_magazine_issue_10.... Our search page also uses React for everything: https://issuu.com/search?language=all&q=fashion&sortby=date&....
Re:Vue.js and Brunch: Webpack Alternative by zer0tonin on Monday August 21, 2017 @03:27PM (#15067058)
Re:Vue.js and Brunch: Webpack Alternative by holtalanm on Monday August 21, 2017 @05:46PM (#15068105)
I built my (super simple) budgeting app with the vue-pwa template with vue-cli. https://budgetme.surge.sh

Disregard the extremely bootstrap-esque css. I threw it together in a matter of hours to just experiment with Vue.

Not popular at all, as far as I know, but then I don't even have analytics on it to even know if it is popular or not.

Re:Vue.js and Brunch: Webpack Alternative by Method-X on Monday August 21, 2017 @01:44PM (#15066197)
Here's a project I'm working on that uses react: https://edabit.com
Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @01:48PM (#15066229)
Thanks!

Tried it a bit and thought: "Hmm.. it's probably react that causes all these spinning "loaders" everytime I click somewhere. Wouldn't it be better without?". How do you see that?

EDIT: Ups, why the downvotes? With spinning "loaders" I mean the "loading" animation the website shows. The spinning circle. Anything bad about this question?

Re:Vue.js and Brunch: Webpack Alternative by JasonSage on Monday August 21, 2017 @02:02PM (#15066334)
> Anything bad about this question?

You didn't ask a question, you jumped to a (wildly inaccurate) conclusion.

Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @02:08PM (#15066386)
In which sense inaccurate? If the server would just send a rendered page, why would a loading animation be needed?
Re:Vue.js and Brunch: Webpack Alternative by JasonSage on Monday August 21, 2017 @02:16PM (#15066444)
> it's probably react that causes all these spinning "loaders" everytime I click somewhere

Statistically speaking it's _probably_ jQuery or pure JavaScript. These loading spinners have been around to make site loading more attractive for a long time, predating React, Vue, Ember, even Backbone. I have tons of clients on Wordpress that love this kind of thing even if all it does is make their site load without a flash of unstyled content (FOUC).

> If the server would just send a rendered page

React is primarily a client-side framework, but it's possible to render it on the server using Node. However, a lot of sites still use React to enhance an existing frontend, and therefore do not port their entire server to Node to render with React.

> why would a loading animation be needed?

Alright so lets assume you've server-rendered with React, do you still need a loading animation? Maybe. All these sites you click on that have loading spinners are all server-rendered pages too, but that doesn't stop people from throwing jQuery plugins at it to make their sites look fancy and prevent a FOUC. It's more a question of how many images the site wants to display above the fold. If there's a bunch of images, your site will not load fast and you can choose between letting users see a gappy page gradually get filled in or sit and look at a spinner for 1.5s.

EDIT: not to mention all the advertising trackers these sites have enabled. This makes your image-loading all the more laggy.

Re:Vue.js and Brunch: Webpack Alternative by Method-X on Monday August 21, 2017 @02:17PM (#15066453)
The loading spinners happen when data is being fetched from the database. The app itself is downloaded upon initial load and anything from the database will trigger a loading spinner as it's being fetched.
Re:Vue.js and Brunch: Webpack Alternative by Hedja on Monday August 21, 2017 @05:13PM (#15067904)
Just thought I'd share my experience with this, since I had a similar problem.

Spinners make it look like the app is taking ages to load data, even if it's not. If you delay showing the spinner until around a second of loading, it makes things feel a lot faster.

The user doesn't need to always know when the app is loading data until there's a significant pause and they need to know stuff is happening.

Re:Vue.js and Brunch: Webpack Alternative by TekMol on Monday August 21, 2017 @03:07PM (#15066868)
Yup, I got that. But couldn't a bit of text be loaded instantly instead?

Is the time the spinners run determined by the time the server needs to deliver the data? Would they go away when you put the site behind a CDN that delivers the data faster?

Re:Vue.js and Brunch: Webpack Alternative by chickenfries on Monday August 21, 2017 @04:24PM (#15067546)
> But couldn't a bit of text be loaded instantly instead? Yep. You could code your website in such a way to use a mix of serverside rendering and ajax components. This has always been true. Consider something like a server-rendered blog post that has a client-rendered Disqus widget.

> Is the time the spinners run determined by the time the server needs to deliver the data?

Basically. But you can also render your react app or vue on the server and then have client side rendering take over once the page is loaded. This is perhaps the ideal case but it's more complicated and takes some work to set up (I haven't actually done it).

Re:Vue.js and Brunch: Webpack Alternative by wehere1 on Monday August 21, 2017 @03:14PM (#15066938)
lol what kind of websites do you make? internationaloilandgas.com? drbronvillesfootcream.com?
Re:Vue.js and Brunch: Webpack Alternative by bricej13 on Monday August 21, 2017 @03:21PM (#15066991)
I built my side project with Vue: https://wherecaniwatchmy.team

Client side rendering saved my bacon when it went mini-viral a few weeks ago. My little home server probably would have keeled over and died had it been rendering all the pages, but just serving static files is a piece of cake.

Re:Vue.js and Brunch: Webpack Alternative by nickthemagicman on Monday August 21, 2017 @05:13PM (#15067903)
How do you do SEO?
Re:Vue.js and Brunch: Webpack Alternative by christilut on Monday August 21, 2017 @04:43PM (#15067703)
My new headless CMS uses Vue: https://www.headless.rest

It uses webpack with alot of code splitting so instead of 1 big bundle its many small bundles which should help loading times alot.

Re:Vue.js and Brunch: Webpack Alternative by jazoom on Monday August 21, 2017 @05:13PM (#15067905)
Uses all features of Vue, including SSR, async-loaded components, etc.: https://pricehipster.com
Re:Vue.js and Brunch: Webpack Alternative by TekMol on Tuesday August 22, 2017 @07:02AM (#15071229)
Man, this is so slow that I am typing this comment while the page is loading...

Now it loaded. It says:

Connection timed out

The initial connection between Cloudflare's network and the origin web server timed out. As a result, the web page can not be displayed.

Re:Vue.js and Brunch: Webpack Alternative by jazoom on Tuesday August 22, 2017 @07:16AM (#15071295)
That's odd because this website is lightning fast. Perhaps there was a network issue?

It may be slower for you if you're on the other side of the world, but you shouldn't be able to do much more than switch tabs during the load even if that is the case.

Re:Vue.js and Brunch: Webpack Alternative by timdorr on Monday August 21, 2017 @02:17PM (#15066455)
https://mobile.twitter.com/ uses React, Redux, and React Router.
Re:Vue.js and Brunch: Webpack Alternative by Zalastax on Monday August 21, 2017 @04:12PM (#15067450)
https://youpic.com/ (press explore) uses React and Redux.
Re:Vue.js and Brunch: Webpack Alternative by djmashko2 on Monday August 21, 2017 @01:47PM (#15066217)
New york times uses React: https://www.nytimes.com/
Re:Vue.js and Brunch: Webpack Alternative by arcosdev on Monday August 21, 2017 @02:22PM (#15066494)
Re:Vue.js and Brunch: Webpack Alternative by zackify on Monday August 21, 2017 @03:12PM (#15066921)
react / react router for 100% of https://constructionjobs.com
Re:Vue.js and Brunch: Webpack Alternative by jensvdh on Monday August 21, 2017 @05:08PM (#15067868)
Airbnb uses React extensively FWIW
Re:Vue.js and Brunch: Webpack Alternative by eat_veggies on Monday August 21, 2017 @01:56PM (#15066292)
Quizlet uses react.