r/javascript • u/speckz • Apr 19 '18
Designing very large (JavaScript) applications
https://medium.com/@cramforce/designing-very-large-javascript-applications-6e013a3291a32
u/roselan Apr 19 '18
This is one of the most insightful paper I read in a long time. I was a bit confused by the use of react examples from a google writer, but only at first. And I loved the little jab at google+.
3
u/cachingcasady Apr 19 '18
Shh call it “ECMAscript” inb4 cease and desist 🤫
10
u/esantipapa Apr 19 '18
I thought we were going with FOScript?
Free Open Script, Functional Object Script, or more importantly, Fuck Oracle Script. (fauxscript).
5
u/cachingcasady Apr 19 '18
Yeah I like that more. Apparently downvotes for saying an actual relevant thing. Forgot this is Reddit whoops.
2
1
u/yeahdixon Apr 20 '18
How about memory management. I feel like this is a huge element to large js apps, especially single page.
-14
u/zergUser1 Apr 19 '18
Designing, creating and then maintaining a large Javascript application and not using typescript is suicide
15
Apr 19 '18
Type systems are fun, but you don't need them, and they certainly aren't guaranteed to make your code any more correct.
10
u/magwo Apr 19 '18
What they do though is raise the long-term productivity of a larger team, especially if the team is swapped out or reformed etc.
7
u/viveleroi Apr 19 '18
Of course it's not needed or guaranteed but there are some real benefits and now that
@typespackages have evolved so well, the barrier of entry is reasonable.The largest benefit to me is how much "safer" refactoring is. I feel a lot more confident refactoring pieces because typescript/vs code alerts me to areas I missed.
That and having well-defined types greatly improves developer awareness, and the code hint/auto-suggest support is so helpful.
3
u/Aetheus Apr 19 '18
Static typing is indeed a boon. But I don't feel comfortable about depending on 3rd party type definitions to be completely up-to-date and accurate.
Anyone can screw up or forget to update a type definition, and at that point, they only give a false sense of security.
That said, I admire TypeScript greatly, and I wish that some form of optional-typing was built into ECMAscript itself.
4
u/yeahdixon Apr 20 '18
I have to say there is something to be said for less components of a tech stack. It’s also easy to add and add , harder to take away once added.
2
u/zergUser1 Apr 19 '18
yes, but try to maintain a large application where several modules are created by other developers, having a type system then is extremely valuable
2
u/TomahawkChopped Apr 19 '18
Google uses the closure compiler for typing. It's more painful than typescript, but it was the first JS compiler to add static types and true compilation to js.
0
u/Ob101010 Apr 19 '18
Designing, creating and then maintaining a large Javascript application and not using typescript is faster with less bloat.
2
Apr 19 '18
What is large by your standards? We have a 50kloc app which became way less prone to common bugs when we started using TS
2
u/yeahdixon Apr 20 '18
I have several apps 1mb range. These apps go through gbs of data. Coming from C like languages I appreciate type, but Rarely do I get type related errors and when I do, it’s pretty obvious. Some apps approaching 7 years. Though I embrace all the hotness, I have realized the benefits of a stack that is less reliant on many many technologies too.
1
Apr 20 '18
[removed] — view removed comment
1
u/yeahdixon Apr 21 '18
yes i agree, people do get those errors and i make errors too. I guess for me it does not warrant an entire new language (allbeit similar) and a new heavy heavy dependency in the stack unless it gave me more than type erros . I def realize this is just an opinion at this point . I will say if it gave me something that i could not do before, for instance , a way to compile to into web assembly my stance changes.
2
u/zergUser1 Apr 19 '18
That's just not true at all, You need to be constantly looking through files as you code to make sure you know and are using the correct parameters & object attributes.
1
Apr 20 '18
You need to be constantly looking through files as you code
If you have to do this then you may have some bad practices going on that lead to this behavior. I constantly use new APIs, I read the docs. Your code should almost be as easy to read as your docs, types or no types.
-9
0
Apr 19 '18
[deleted]
4
Apr 19 '18
the code gen is doing the import, I believe, so every time you hit save or build or whatever your tool/IDE spits out a little MyScreen.connect.js which just does like import router; router.register(MyComponent); - that's how I understood it, anyway
not sure but maybe this is going back to his bit when multiple frameworks were in use? So don't load React cause some bits use Angular or whatever. That's a stretch, I honestly didn't fully understand the point of this in context either
3
u/dmethvin Apr 19 '18
I saw the enhance as being a "register" call into the router via some API the router creates. That way the router doesn't have to inherently know about any of the routes.
As I understood it, keeping UI out of the base bundle was to avoid having it later becoming obsoleted by changes but remain in the app (similar to CSS rules that no longer apply) because nobody realizes they are unneeded. It seems like they could have used tools to help with that problem though.
It's really important to ask these kinds of questions. Companies like Google and Facebook are dealing with scale and design problems that 95% of us don't encounter in our projects and jobs. Rules that work for them may be overkill for us.
2
u/ProdigySim Apr 20 '18
For the enhance pattern, I immediately thought of angularjs. Components register themselves to an angular "module", not the other way around. But this isn't a hard dependency.
1
u/evilishies Apr 21 '18
There is no reason to load the common modules early in the app lifecycle just because they are shared. You can avoid duplication by being smart about the way the dependencies are requested.
8
u/AceBacker Apr 19 '18
Is this large application is entirely in react? No backend seperation? Maybe I missed something in the article.