Not official in any way but I have a very large file and im curious how it compares
- < 1000 lines
- < 2000 lines
- < 4000 lines
- < 8000 lines
- < 16000 lines
- < 32000 lines
- < 64000 lines
- Beyond 64000 lines
0 voters
Not official in any way but I have a very large file and im curious how it compares
0 voters
Wow 1,000 is the lower bound? Once I get to like 300-400 I start thinking it’s too long
Right not talking about whats the best file size but whats the largest.
In terms of large id say 1k is not so large.
I have many 1k line files, or even larger. I hope NextJS is doing tree-shaking and all of those good optimizations
haven’t verified
Now would like to hear from the outliers about how you got there…more than 64k?!
This one, taken from the parser, an used to test scalability of the vscode extension, is 7K lines long:
My largest shipping source code file is just under 1000 lines. The codebase does have a 6700 line test file, and some other big test files, but we deal with HTML so test file size and line count is dominated by object structures defining documents or schemas.
$ find . -name *.res -type f -printf '%s %p\n' | sort -nr | head -10
163784 ./modules/sometest.res
57992 ./modules/sometest.res
51459 ./modules/sometest.res
47055 ./node_modules/rescript-webapi/src/Webapi/Dom/Webapi__Dom__EventTarget.res
44365 ./modules/anothertest.res
38682 ./modules/testcode.res
37530 ./modules/largest-shipping-file.res
Interesting…I would guess your codebase is the most idiomatic around.
I think there may be a [big] gap between the patterns that ocaml-oriented rescripters and js oriented will reach for, with Js maybe preferring to write more code vs strong module interfaces and functors?
How do you deal with bindings? Webapi is very heavily split into files, would you do that for an api that was provided as a single file?
Yes, this was a greenfield project that had the luxury of being well designed as we built it.
Webapi is split not just because it’s good code style. The way nested modules compile to JS cannot be tree shaken by JS bundling tools unless they’re aliases to other modules. Each nested API that the developer might want to use (for example Webapi.Dom.EventTarget
) needs to be a separate file.
I may have started with splitting because I am familiar with OCaml, but make no mistake once a JS oriented person learns how nested modules compile in ReScript they’ll consider doing the same.