News for hackers. Stuff that matters.
Re:Our long term plan to make GitLab as fast as possible wit... by jbhatab on Tuesday February 07, 2017 @02:24AM (#13587757)
disagree. React has amazing reasons why it is fundamentally better than most of the other libraries for projects at scale.

I think vue is a perfect fit for gitlab but not quite perfect for facebook or a more complex web app on the front end.

Re:Our long term plan to make GitLab as fast as possible wit... by phasecode on Tuesday February 07, 2017 @02:50AM (#13587836)
Are there any specific reasons you can point to, rather then a blanket statement?
Re:Our long term plan to make GitLab as fast as possible wit... by bobbytherobot on Tuesday February 07, 2017 @03:25AM (#13587964)
I'll take a stab, although I don't share the same absolute stance.

I've run the gambit when it comes to types of front-end projects. The React community has more focus on scaling React for large teams and companies. This isn't to say Vue can't do any of this, but there is a clear focus in the React community. I need to do isomorphic rendering because of SEO, there is a lot of React documentation on that and very little for Vue. I need static analysis for my code to prevent errors, Flow answers that. I need a replayable state for debugging errors, Redux gives you that.

None of what I mention about React is its sole domain. You can list off many alternatives.

Reading through why people choose Vue, many common needs come up. The one that I find interesting is needing a system that Designers can understand because they code up the HTML and CSS. I doubt that is something that comes up with React teams.

In my opinion, if you require a framework, Vue and React are two great options. It comes down to various small differences about your team needs. (Please stay away from Angular though.)

Re:Our long term plan to make GitLab as fast as possible wit... by burriko on Tuesday February 07, 2017 @04:34AM (#13588233)
I love both React and Vue, but I feel the need to step in and defend Vue a little here.

Of the 3 points you listed, Vue has a section in the official documentation dedicated to Server-Side Rendering, ditto for using it with Typescript for static typing, and it even gives you replayable state with Vuex (the official redux-style library for Vue).

They really are both great options.

Re:Our long term plan to make GitLab as fast as possible wit... by Tenhundfeld on Tuesday February 07, 2017 @11:44AM (#13590546)
A bit OT but just FYI: I think you mean gamut, not gambit.
Re:Our long term plan to make GitLab as fast as possible wit... by Longwelwind on Tuesday February 07, 2017 @09:41AM (#13589629)
React managed to make HTML "statically typed".

If I make a typo in the name of a component or the name of an attribute used in a HTML tag property, Typescript will catch it. Since Vue & Angular uses template strings, TS can't do the same check.

This makes catching errors and refactoring easier.

I used to prefer Vue, but since I've discovered Mobx, I only use React now. It took me a lot of time to properly learn the tools, but I'm pretty happy with them now.

Re:Our long term plan to make GitLab as fast as possible wit... by rdsubhas on Tuesday February 07, 2017 @03:17AM (#13587928)
Two-way binding I guess. Once we get used to one-way binding and immutable data structures, anything else feels indeterministic.

(Note: Just guessing what the commenter might have written. I'm a long-term VueJS user)

Re:Our long term plan to make GitLab as fast as possible wit... by vog on Tuesday February 07, 2017 @03:27AM (#13587975)
This. I just had a look at Vue and everything looked fine so far, until they started with two-way-bindings.

Two-way-binding failed already long before the web and SPAs. Many desktop GUI frameworks provided two-way-binding, but this concept constantly failed to deliver on its promises. Not sure why frameworks keep repeating this well-known anti-pattern.

I'd prefer framworks like React or Riot any time over two-way-binding.

Re:Our long term plan to make GitLab as fast as possible wit... by rk06 on Tuesday February 07, 2017 @06:05AM (#13588588)
There are two types of two-way binding.

1. Bad Two Binding i.e. Two way binding between components. Vue2 and most of the UI frameworks shun this.

2. Good two way binding i.e. Form model binding. Because form input can actually come from two sources (user input and javascript). this is naturally two-way and this is why frameworks continue to keep it.

Re:Our long term plan to make GitLab as fast as possible wit... by pluma on Tuesday February 07, 2017 @11:12AM (#13590303)
I think the second one isn't really a valid example. There are very few situations where you both want to have state mutations discard what the user has already entered and reflect user-provided state in real time. In other words even if it's supposedly "two-way" you don't actually want multiple inputs to share the same model and you likely don't want to represent the data the same way the form control needs to represent it internally.

As an example, let's say you have a formatted text input field that can be used to enter a decimal number. If the input contains no decimal separator, the decimal part is implicitly zero. But if you just use naive two-way binding with an actual decimal value this means you'll get in the way of the user trying to manually enter a decimal value (especially if the user tries to delete the decimal part starting with the separator).

As soon as any information is lost during the bind in either direction, you still need to explicitly think about where you want the data to flow into and out of the form field.

The archetypical example of two-way binding is definitely the auto-generated CRUD form that lets you edit a model in place, but IMO this is a tiny niche in practice because it falls apart as soon as you want to do anything non-trivial. It's great for prototypes though.

EDIT: To clarify, I think you're talking about two-way binding a form model to form inputs. But calling that two-way binding from an application developer's POV is kinda redundant because you still need changes from the form model to propagate outside the form in a more controllable and predictable way than two-way binding offers, so the two-way binding of the actual form fields becomes an implementation detail.

Re:Our long term plan to make GitLab as fast as possible wit... by rk06 on Thursday February 09, 2017 @10:38PM (#13613036)
>you just use naive two-way binding with an actual decimal value this means you'll get in the way of the user trying to manually enter a decimal value

Naive one way binding is useless as well.

>two-way binding of the actual form fields becomes an implementation detail.

Kinda. In fact in Vue two-binding is a syntax sugar for one way binding and on change events.

The difference between them, is one requires less lines of code and is less powerful.

If you do need react-style form input, then you can do it that way.

Re:Our long term plan to make GitLab as fast as possible wit... by GeneralMaximus on Tuesday February 07, 2017 @04:15AM (#13588160)
> Many desktop GUI frameworks provided two-way-binding, but this concept constantly failed to deliver on its promises.

Can you elaborate on this? The last time I wrote a native application was 6 or 7 years ago using Cocoa and Objective-C. If I remember correctly, Cocoa had a mechanism that was similar to two-way binding. Have things changed recently? What do modern iOS/Mac applications use?

Re:Our long term plan to make GitLab as fast as possible wit... by elsurudo on Tuesday February 07, 2017 @04:25AM (#13588205)
Cocoa Touch (iOS) got rid of bindings altogether and you manage updates manually (although I use a bindings library to emulate the old OSX bindings support in one of my apps).

Not sure on macOS, bindings may still exist there.

Re:Our long term plan to make GitLab as fast as possible wit... by vog on Tuesday February 07, 2017 @04:41AM (#13588253)
That's exactly my point. The concept of bindings (in the sense of two-way-bindings) hasn't proved to be successful - neither today nor in the past, neither on desktop or in the web.

As a more general throught:

When comparing concepts or patterns, there are often discussions about which one is better, comparing different but almost equally good options. Choosing the "best" one is hard. So the list of advisable patterns is constantly evolving and changing.

However, some concepts clearly didn't pay off over decades across a huge variety of settings. These anti-patterns are quite stable, and more or less just growing, not changing. It may make sense to collect these ones.

The "good" concepts may be subject to fashion and evolution, but the "bad" ones are stable and hence worth collecting.

Re:Our long term plan to make GitLab as fast as possible wit... by mkalygin on Tuesday February 07, 2017 @06:09AM (#13588608)
Could you explain why two-way binding is a bad pattern? Why it hasn't proved to be successful?
Re:Our long term plan to make GitLab as fast as possible wit... by pluma on Tuesday February 07, 2017 @11:31AM (#13590458)
Simply put: because it's magic.

Two-way bindings are great for prototypes because you no longer need to think about how your state gets from one place in your application to another, you just shove your mutable state blob into every last part of your application and the framework does the rest.

But what you lose in return is the ability to control when state should change and sight of where changes come from. In the case of POJO state implementations like AngularJS 1 it also means you have to constantly diff the state against what you've last rendered to be able to respond to changes nobody told you about.

AngularJS 1 actually tried to optimise this a bit but ultimately it needed to pretty much control everything asynchronous in order for that optimisation to work and more often than not that resulted in hapless beginners wondering why their changes aren't always reflected in the UI (answer: because nobody told Angular it should check).

So in other words, your state consists of big balls of mud that may change shape without notice and if you pass one of them to any piece of code you must expect it to do just that without any way to tell until it happens (and good luck trying to figure out where it happened exactly).

Compare this to the "one-way data flow" React made popular: your state is a bunch of impenetrable rocks that roll into your application, which can't modify them but can do whatever it wants in response to them (e.g. push pixels around on the screen). If the application wants different rocks, it needs to explicitly tell wherever they came from that they should be different, at which point the application will be fed a different (or maybe identical) set of impenetrable rocks again.

In a word this is basically the difference between mutability and immutability, taken to the extreme. Although there's nothing in React forcing you to use immutable data structures, the one-way data flow assumes everything it's fed is immutable unless you say otherwise, and you pass in callbacks to be notified when state should change.

On the other hand, in two-way binding your state is mutable and extremely malleable by definition, and thus the implicit expectation for every operation is that it may have changed the state.

As a side-note: React actually has a dirty little secret called "context" which is the equivalent of thinking with portals: instead of passing ALL the state into your ENTIRE application's root, you pass the state container to a magical Pez dispenser that wraps your application root and then each component can be wrapped in a container that knows about the dispenser and asks it for a specific part of the state. That's how React-Redux works among other things and it's not entirely unlike dependency injection (except it doesn't happen globally but only in the context of the specific instance of the application).

Re:Our long term plan to make GitLab as fast as possible wit... by wcarron on Tuesday February 07, 2017 @11:44AM (#13590549)
Vue.js 2 uses 1-way data binding by default
Re:Our long term plan to make GitLab as fast as possible wit... by mhd on Tuesday February 07, 2017 @03:17AM (#13587930)
"at scale"? I hear this a lot of when react gets sold, but apparently most of the time people are using this in the old MongoDB "web scale" meaning, not when it comes to scaling up to complex interfaces (i.e. "we use it like jquery, but get lot of hits/s", not "this is our enterprise CRM desktop that's on par with your average single developer Delphi program").
Re:Our long term plan to make GitLab as fast as possible wit... by M4v3R on Tuesday February 07, 2017 @03:33AM (#13587994)
> React has amazing reasons why it is fundamentally better than most of the other libraries for projects at scale

And yet somehow even on my quite powerful Macbook Facebook can halt to a freeze for me when scrolling long feeds or comment threads. One would guess that React would handle those scenarios gracefully, but that doesn't seem to be the case.

Re:Our long term plan to make GitLab as fast as possible wit... by pluma on Tuesday February 07, 2017 @11:36AM (#13590496)
You seem to think that because Facebook's website uses React it's a React app. Facebook is no different from other continuously developed applications that evolve organically. In other words: it's probably not a good example for a "best of breed" pure React app.

I'm guessing Facebook uses React more on facebook.com than it uses React Native in their mobile app (I think there was an article a while back on HN about the ridiculous amount of packages in their mobile app, which is a testament to their policy of bolting on new code instead of rewriting the old unless actually necessary) but it's a safe guess to say that there's more to facebook.com's frontend than just React.

Re:Our long term plan to make GitLab as fast as possible wit... by manigandham on Tuesday February 07, 2017 @02:30AM (#13587776)
what reasons?