HNHacker News
TopNewBestAskShowJobs

eliseumds

314 karma · joined October 30, 2013

submissionscomments
eliseumds··on 43% of South African youths are not in employment, education or training
It reminds me of a small coworking space I used in Sao Paulo, with three receptionists, a few "managers", lots of cleaning staff, someone doing just coffee, security, etc. They could do all of that with two employees total. In front of the building, there was a petrol station with one employee per pump. The pandemic was actually a relief for lots of companies that were able to fire expendable staff more easily.
eliseumds··on 43% of South African youths are not in employment, education or training
Same situation in Brazil at the moment, around 40% of the productive population working informally: https://agenciadenoticias.ibge.gov.br/agencia-noticias/2012-.... Uberization at an extreme level.
eliseumds··on React best practices
It's not about loose or tight coupling, it's about things that React Context enables you do to. You're literally also hiding contextual data when using a partially-applied singleton, and you end up with code that is not safe when writing an event-looped single-threaded application (any NodeJS server implementation). Users cannot use react-helmet when doing stream-rendering, for example, because it's a singleton. See https://news.ycombinator.com/item?id=27032394.
eliseumds··on React best practices
Sorry if you felt talked down. I am lucky to have worked in some very big and complex React applications and will share more experience with you:

* By using a singleton you're not able to easily test different LocaleData contexts in parallel.

* By using a singleton you're not able to make your NodeJS server deal with users with different locale settings because you have only one global instance. Multiple requests arriving at the same time would corrupt each other. You could spawn a separate process for each locale but that's inconvenient.

Does that make sense?

eliseumds··on React best practices
By reducing the surface area of a widely-used interface like a translation component/hook, you massively decrease the chance of generating bugs and fewer tests would bring you way more confidence. When testing, you just need to wrap that component with a fake context that adheres to your LocaleDataContext interface (or whatever you decide to call it).

> making them less transparent to readers of the codebase

Sometimes that's exactly what you want. It's the same as hiding CSS styles behind a set of props like `<Button buttonStyle="primary" buttonSize="large">Continue</Button>`. It actually makes your codebase much safer by reducing the combination of props and values you're able to pass.

eliseumds··on React best practices
What's your programming background? This is some quite basic stuff to be honest. Have you heard of dependency injection? Context is dependency injection in React, there you go. There's quite a few .Net/Java books that would offer you better examples and clearer reasoning than myself, like this one: https://www.manning.com/books/dependency-injection-principle....
eliseumds··on React best practices
It doesn't matter what your code is doing inside that component, you can still make it easily testable by having the core translation pipeline as pure functions.

See https://news.ycombinator.com/item?id=27031847 for more reasons.

eliseumds··on React best practices
It is not that simple. You could use the exact module in different environments: browser, NodeJS, React Native. If you don't use context, you either need to do some very ugly module replacement at build time or duplicate your code. Also, you lose lifecycle hooks (not that important in this case though).
eliseumds··on React best practices
They're definitely more than simple functions if you look at it from the the entire application point-of-view. With components you have access to context and lifecycle. Doing:

  import someFunc from 'someFunc';

  // ...
  return someFunc();
is not the same as:

  import SomeComponent from 'SomeComponent';


  // ...
  return <SomeComponent />
eliseumds··on React best practices
I beg your pardon? Even translation of pure text (and not numbers, date, currency) relies on locale data, like plurals and genders. It's just way more elegant to have this data inside a React context instead of importing a global translator or passing in locale data whenever needed (dangerous repetition).
eliseumds··on React best practices
It is indeed premature optimisation.
eliseumds··on React best practices
I guess you misunderstood it. It has nothing to do with optimistic updates. Optimistic updates are about rendering results that you hope will happen, like clicking on a "Like" button and immediately making it bold and disabled even before the request has finished. In case it errors, you simply revert to the previous state and display some feedback to the user.

Now, wishful thinking is about making it work even if not perfect, production-ready. It could be about rendering a hard-coded "Loading..." or "Success" or "Error" string before you hand it over to your translation team. Or just calling your param names `a` and `b` before you talk to your domain experts about the proper terms. This comes with experience.

This is not something the author invented, it's a well-known technique.

eliseumds··on React best practices
It might be obvious to you. Hiding concrete implementations behind an elegant, easy-to-use interface, is not something we see every day. I've noticed countless codebases importing HTTP clients globally, mocking a ton of modules for testing, imperatively translating messages and so on. Wrapping implementations with components/hooks allows you to future-proof your application in case you need, for ex, to access some context data, to develop for a new environment (mobile, desktop), or for easier testing as already mentioned, including snapshots. I specially like that the author talks about wrapping third-party libraries.

Another benefit of components is lifecycle. Imagine a "RelativeTime" component; you could have called library functions directly to render "20s ago", but by making it a component you could tell it to update periodically. Cool stuff.

Now, I understand that having such granular components can lead to some performance overhead if you're working on a massive application. If only there was an easy way to do AST transformations that would hoist small stateless components/hooks. Damn, AST transformations could even hoist stateful ones! I'll keep dreaming about it :)

In regards to examples such as `Fetch`, `UserRead` and `EntityActionDelete` from the post, I'm kinda on the fence because, at the same time they are uglier than hooks, they're also more performant because updates would only re-render itself and its children, and not the entire parent component. There's no right or wrong here.

eliseumds··on Longest pedestrian suspension bridge opens in Portugal
https://brasil.estadao.com.br/noticias/rio-de-janeiro,telefe...

https://istoe.com.br/447384_A+CICLOVIA+MAIS+CARA+DO+MUNDO/

http://www.ihu.unisinos.br/78-noticias/579871-o-desastroso-l...

https://www.otempo.com.br/politica/mp-faz-operacao-para-apur...

eliseumds··on Longest pedestrian suspension bridge opens in Portugal
Yes, it sounds low to me. In Brazil they've have spent 10x that and would never finish it.
eliseumds··on Ask HN: Who doesn’t want to go back to the office?
I don't want to go back. I feel more productive being a digital nomad, staying in a different city every month, meeting different people, eating different food, in different climates.

I stay in the best neighbourhoods around the world, walk to coworking spaces, eat out almost every meal and still spend considerably less than what I did in Sydney.

eliseumds··on Why we switched from Webpack to Vite
Correct.
eliseumds··on Why we switched from Webpack to Vite
Plus effortless code splitting.
eliseumds··on Why we switched from Webpack to Vite
Have you seen SvelteKit's source code? It looks like a toy project. [1]

vite-plugin-ssr can't even be integrated with Vue Router (I saw you're working on deep integration though). They're both very rigid, early stage endeavours. [2] What happens, for ex, if you used nested lazy components in those pages, are they going to be included in the server render as well?

I mean, fair enough that there are people trying to do better, but it's extremely hard to find the right abstractions for such complex builds and Webpack is definitely on top here.

[1] https://github.com/sveltejs/kit/blob/5c2665ff2280947a2fc6001...

[2] https://github.com/brillout/vite-plugin-ssr/blob/master/src/...

eliseumds··on Brazil Rejects the Gamaleya Vaccine
The same organisation is putting pressure on Pfizer as well for lack of quality-control data: https://valor.globo.com/brasil/noticia/2021/04/26/impasse-co... (in Portuguese).

It looks like it shouldn't have been approved in the first place then.

eliseumds··on Why we switched from Webpack to Vite
I'd be dishonest if I told you I was able to compare them 1-to-1. I couldn't finish my Vite setup because of bugs and lack of proper SSR support.

I believe that, at this point, people are just nitpicking. When working on a client-side-only app, Vite is faster, but not by that much. In one of our apps, I saw it starting up in 1s compared to 2s with Webpack, and reloads in 100ms compared to 250ms. This is a Preact/TS/Emotion app that outputs almost 7MB of assets, 61 files to be precise, and works on IE11. And I hadn't even tried persistent caching with it yet. Webpack 5 with esbuild is a fast-enough solution.

NextJS is a well-established tool now and version 10.2 uses Webpack 5 under the hood. V11 is looking insanely fast (I suspect they replaced Babel with esbuild, and did some witchery): https://twitter.com/shuding_/status/1378086219708473344.

So yeah, slow performance with Webpack is definitely caused by a bad set of loaders/plugins. Eject a CRA app and you'll see a monster coming out.

eliseumds··on Why we switched from Webpack to Vite
Precisely. I'd advise having esbuild behind Babel if you really need an specific Babel plugin, for ex:

* Transform the file using esbuild first

* Then use Babel with that one specific plugin (Loadable Components, Styled Components, Apollo, React Refresh...)

This is much faster than letting Babel do all the work.

eliseumds··on Why we switched from Webpack to Vite
Vite is not a completely opinionated tool. You can still customise its behaviour and use plugins, so both installations would have very similar vulnerabilities at the end. For SSR, you need a self-written server entry point.

Webpack 5 has introduced asset modules, so now you can safely ditch raw-loader, url-loader and file-loader. [1]

You might have NextJS or CRA in mind.

[1] https://webpack.js.org/guides/asset-modules/

eliseumds··on Why we switched from Webpack to Vite
I literally just spent days trying out Vite and comparing it to Webpack 5, and I can comfortably say that they are in two very distinct leagues. It isn't fair to compare Vite to a CRA build with Webpack. You can greatly improve Webpack's performance by:

* Making sure `mode` is set to "development" (don't specify it all if in doubt)

* Ditching babel-loader and using esbuild-loader instead

* Adjusting build targets and making sure polyfills are not added in development

* Making sure you don't import the entirety of libraries like Lodash and MomentJS (prefer date-fns)

* [FUTURE] We'll soon be able to tell Webpack to output ES modules just like Vite [1]

Vite still has many problems:

* It just isn't suitable for proper server-side rendering, we'd need access to chunk names at build time

* It has a weird mix of own and Rollup config settings that seems somewhat unpredictable

* Many open issues regarding module imports, for ex, when a CJS module imports an ES one [2]

Our current bottleneck with Webpack is actually sass-loader, taking at least 70% of the time during a fresh build, and we'd have the same problem with Vite.

Something else that is worth pointing out is the ecosystem: Webpack's community has built tons of plugins for basically any use case you can imagine, and version 5 supports module federation, persistent caching, externals (very handy when doing SSR), customizable filename generators, performance hints, etc etc. Totally different game.

Try to keep your build config simple, avoid too many loaders, plugins, and you should be fine 99% of the time. If you hit a wall, install speed-measure-webpack-plugin to get some help.

[1] https://github.com/webpack/webpack/issues/2933

[2] https://github.com/vitejs/vite/issues?q=is%3Aissue+is%3Aopen...

eliseumds··on Apple commits $430B in US investments over five years
https://en.wikipedia.org/wiki/Double_Irish_arrangement
eliseumds··on Get better at Googling
Not only developers, literally anyone. I am shocked at the amount of time an average individual spends looking for solutions to everyday-life problems when I can find answers in seconds, it's crazy, and sad. I taught my family some more advanced queries and they're loving it.
eliseumds··on Starting a TypeScript Project in 2021
Yes, but it does much less. There are still many projects out there relying on Babel plugins (Loadable Components, Styled Components, Tailwind, Apollo, etc).

I love esbuild though, and use it a few of our packages, it flies

eliseumds··on Ask HN: Show me the sexy, sexy home page of your favorite free CLI project
Well, we can clearly see here that taste is indeed personal.
eliseumds··on Higher quality audio makes people sound smarter
I use Krisp on a daily basis from Brazil (a very noise country, terrible build quality) and it works incredibly well, better than most hardware-based solutions I've tried.
eliseumds··on Show HN: Map of active customers for landing page
Well, the server-side part of it needs to run somewhere. Looks pretty good to me, very straightforward.
← PreviousPage 3 of 5Next →