Better HN
topnewbestaskshowjobs
Log inSign up

kangoo1707

47 karma · joined Mar 23, 2017 (9y ago) · 39 submissions

Submissions

comment 6y ago · link · parent

I always use Nuxt by default for new projects, and it's a correct decision every time. People who choose to do Client Side Rendering (SPA) finally struggling on SEO and other tasks.

1. Nuxt can runs in SPA mode just like using Vue CLI. The opposite is not true

2. SEO is the winning feature of Nuxt, no doubt.

3. Real server status code: especially useful for redirections and 404 pages. For example if you do `curl -I /some-page-that-does-not-exist`, you will get back 404 status code, which is critical for sitemaps and uptime tools. (Instead in SPA you always get 200 for all the pages).

4. Pages written in Nuxt seems to display faster, because the HTML is sent immediately. I say "display" here, not necessarily "load" faster.

5. Real Express middleware helps a lot when doing route validations and authorizations. You can also make calls to private API without exposing them on the client side.

6. Can adjust the amount of HTML sent to client by wrapping client-side-only components in a <client-only> component. Which means that on the server you don't need to generate giant HTML for a simple datepicker, and let the browser does that

comment 6y ago · link · parent

Why are people slapping Static Site Generators to all the problems?

Imagine you build an e-commerce website that has ten thousands of products, that can be accessed by example.com/products/{product-slug}. Now what is making more sense: 1. Generating ten thousands of .html file for each products in the DB 2. Use routing in Nuxt like this "/products/$productSlug" and query for $productSlug in the database

To me the (2) approach is a clear winner here. And the performance only depends on how fast your API can query a single product from the database, which is pretty fast 99% of the time.

comment 6y ago · link · parent

When dealing with large tables with searching + sorting + paginating capabilities, I always use query params and let the API do the heavy lifting

comment 6y ago · link · parent

And what is the best solution? Client Side Rendering is worse, because users see a blank page until the script is parsed. 100KB is actually desirable, because it's included Vue and Vuex out of the box.

comment 6y ago · link · parent

All browser processes 100KB of scripts just fine. And they process the scripts in the background. The HTML is already parsed and displayed.

comment 6y ago · link · parent

Nuxt works fine for all the uses case that I have come across, even for ERP projects. With Nuxt you can have real redirects, real 404 pages, and a well-established project structure. The only hard thing is that server-side error is more difficult to inspect

comment 6y ago · link · parent

Phoenix too

comment 6y ago · link · parent

No native support for concurrency operators, no real event loop implementation, lack built-in support for non-blocking IO... I do Elixir regularly and Actor Model is not something PHP developers know

comment 6y ago · link · parent

Not at all. I have worked with both for a long time and I can clearly see the differences. They are used for different purposes. The people comparing any PHP frameworks to NextJS have not been very experienced with frontend development, IMO.

comment 6y ago · link · parent

still, no proper multithreading, in comparison with Java, C#, Elixir...

comment 6y ago · link · parent

no PHP framework is similar to the thing that NextJS/Reactis doing. The output is the same (well, isn’t the point of web framework is to spit out HTML?) but the methodology is totally different.

comment 7y ago · link · parent

Please take a look at my CV. I'm a fullstack developer (Elixir, Node, PHP, React, Vue, Flutter...)

https://www.dropbox.com/s/kqkm467cb9ay65f/Lam%20Huynh.pdf?dl...

comment 7y ago · link · parent

+1 for Ecto, the most powerful ORM that I have seen so far (among PHP, Node, Ruby, Python and Elixir)

comment 7y ago · link · parent

Exactly, I don't get why people are against it. All ORM allows you to write raw query and using ORM does not mean that you suck at SQL or vice versa.

comment 7y ago · link · parent

SSR can be used with React (NextJS), Vue (NuxtJS) and Angular (Universal Angular).

comment 7y ago · link · parent

More plastic but it's easy to clean - recycle.

At least more delivery = less traffic, less polution

comment 7y ago · link · parent

Server-side rendering is the best front-end architecture at the moment. Superior first content paint and is better at SEO than SPA, and have a better architect than MVC.

So in what way does if differ from traditional MVC? In MVC, the final output is HTML strings. Easy example: supposed you have an array of Posts in your controller, and a HTML template. The final result will be the combination of both of them. But when the HTML strings get sent to browser, you lose the array !!! It's gone. The client never receives an actual array, just DOM nodes.

In Front-end framework SSR (NextJS or NuxtJS), what you work with is a component. A component can have data (an array), and the data is pushed (serialize) as-is to browsers. On the browser, you won't ever have to work with low level DOM nodes. You continue to see the component and data in its original form. This is the biggest win of SSR that is easily overlooked.

comment 7y ago · link · parent

Use both. Many of the business logics are just as simple as query by id, filter/sort by a couple of columns. A smart ORM will handle fetching relationships without hitting N+1 problem

For advanced queries, you can write raw SQL

The way I see it, an ORM has three useful features:

- A migration/seed mechanism (you will need it anyway)

- A schema definition for mapping tables to object

- A query builder

If you feel that an ORM is too heavy, you can seek for just the query builder.

comment 7y ago · link · parent

At my PHP-shop company, most projects are limited to MySQL 5.7 (legacy reason, dependency reason, boss-likes-MySQL reason...). They are all handicapped by MySQL featureset, and can't update to 8 yet. If they had used Postgres some years ago, they would get:

- JSON column (actually MySQL 5.6 supports it but I doubt if it's as good as Postgres)

- Window functions (available in MySQL 8x only, while this has been available since Postgres 9x)

- Materialized views, views that is physical like a table, can be used to store aggregated, pre-calculated data like sum, count...

- Indexing on function expression

- Better query plan explanation

comment 7y ago · link · parent

Nesting is okay for one-level.

However it violates the principle of least astonishment. How come a button inside .header differs from the button inside a .footer, then where are the differences defined, inside the button.scss or header.scss? Then one must take into consideration CSS Specifility and sprinkle !important everywhere.

Instead, use modifier (in BEM) or create two buttons (.header-button and .footer-button) or create 2 utility class (.is-header-btn, .is-footer-btn) or just use TailwindCSS and you're good to go for all kinds of requirements, without ever resort to !important

comment 7y ago · link · parent

A portion of Vue projects are not single page app: it can be used on top of a server-rendered frameworks like Laravel, Rails. Even the document mentions using Vue by a script tag inside the HTML.

This may contribute to Vue being downloaded through npm in lower volume than React

comment 7y ago · link · parent

Outside Angular, I have never heard about two way binding as a source of bug

comment 7y ago · link · parent

If you mix server-side rendered apps with Vue, this is the most common way. Second method is to push the data to a window.__data.staffMemberOptions = "{{ foo }}" and use it in Vue.

comment 7y ago · link · parent

I think OP does not mean that Vue is unstructured / non-disciplined. Vue does have a rigid structure and standard though, but it's pleasantly designed and doesn't get in your way. Maintenance has been a breeze for me.

comment 7y ago · link · parent

Not at all, people moves between libraries of the same framework, they will likely refactor jQuery mess into a framework, but it's unlikely for a team to move from React to Vue or Angular (and vice versa).

comment 7y ago · link · parent

JS on both backend and frontend is all about reusability, less context switch and unified toolings.

And don't associate less proficient engineers with Javascript dude !

comment 7y ago · link · parent

Do you have any concrete example for "For example, in java, scanning your classes and their annotations to generate code for them at compile time is a standardized feature"?

Tip: in JS, I don't want OOP class. If you really want class, could you show me the intention behind it?

comment 7y ago · link · parent

then write a method for it.

Instead of v-if="currentUser && currentUser.id && ..." you can just write v-if="canDoStuff(currentUser)"

comment 7y ago · link · parent

Where Vue is better:

1. Template syntax. While this is just my own preference, my Vue template is 20% shorter than JSX equivalent, mostly due to fewer brackets and better HTML's class support.

2. Computed property: this is so cool and efficient because computed properties are cached (equivalent to Mobx). We also have computed setter as well.

3. Built-in 2-way binding for inputs. Yes I know React people will condemn me to hell for this, but this has been a heaven for form-heavy application. This also makes the HTML you write much much shorter.

4. Prop mutation: this one is extremely controversial. Imagine this.props.foo = newFoo" in React (in Vue land it's "this.$emit('update:foo', newFoo)"). This is useful in situation where you want to mutate a parent's state without going to all the boilerplate of writing store/actions/dispatch. For example

  <div>
    {{ user.firstName + ' ' + user.lastName }}
    <popup-update-user user.sync="user>
    </popup-update-user>
  </div>
By looking at the above code, I can tell that <popup-update-user> will take an object called "user" in, modify it (and probably calls an API), then update the user object back to me. Of course I can do all that in the Vuex store (or in your favourite Redux flavor, but imagine all the code that has to be written)

5. Watch expression: it's beneficial and concise if you know what you're doing and not abusing it. This doesn't even exist in React. (edited: plain React doesn't have this, Mobx does)

6. Built-in Vuex support out of the box. Enough said.

7. Nuxt's offerings are superior to what Next can offer. Nuxt allows layout, param validation, node server middlewares, sass and Vuex integration, sensible configuration, and a system of plugins.

8. Filters: coming from functional languages that support pipeline operator, this has been dope to my eyes. Instead of writing:

  { formatDateTime(toDate(myDate), "DD-MM-YYYY") }
you can write it in a better way:

  {{ myDate | toDate | formatDateTime("DD-MM-YYYY") }}
Of course, the difference is just syntactic. But I hope in the future, Vue's filter can be cached just like computed properties.

9. It doesn't need Babel. I dropped Vue into a legacy PHP Symphony project, wrote the Vue's template in a <script type="x/template"> and wrote the components in plain ES5 object, and it just works !!!

10. The event emitter is a better pattern than calling prop as a function.

  <MyImageGallery onImageSelected={doStuff} />
vs

  <my-image-gallery @imageSelected="doStuff" />
Again, you may argue that this is syntactic sugar, but for me it's clear just at a glance which props are "in-ward", and which props are "out-ward"

11. Vue doesn't intefere with SVG attributes. in React, I have to convert "xlink:href" to "xLinkHref", which is annoying

comment 7y ago · link · parent

It can be use for form validation. If user doesn't enter an input, we can "wiggle" it for 2 seconds (together with a red error message). Recently I did just that :)
12