Why can't we have webapps coded in just a few source file?

3 points by gesman ↗ HN
There is a growing tendency in web frameworks to separate code into zillions of puny source code files, each with just a couple of lines of code spread in dozens to hundreds of folder trees.

Result is the code where to find something takes multiple clicks, tab switches, searches, spawning of external tools and other unproductive efforts totally unrelated to development.

IDE's makes it somewhat easy for pussies - but I quickly end up having multiple dozen of open tabs and forced to jump back and forth and do extra clicks to switch between tabs just to find and edit a pieces.

All above results in consistent unproductive housekeeping effort just to search for code pieces, snippets and references.

Back to my C++ days I had written utilities and class files represented just by a couple of files reaching between 50-100k long. Today I would be tortured and killed for that. The huge advantage of having one source code file - is that it made me much more productive and made it extremely easy and quick to find information, refer to existing code, and find anything without reverting to external tools.

I am looking at my Rails app right now and dreaming of having these 2 files: all_models.rb all_controllers.rb

I know it's heresy and extreme, but don't you think we're approaching an opposite extreme already?

7 comments

[ 0.23 ms ] story [ 41.3 ms ] thread
I'm working on a Python web application (using the Flask framework) and its a relatively small application. As of now I have the app.py file and two HTML templates along with the CSS files.

I think that apps become as complex as you make them - I plan to split my app.py into a models.py and views.py. It's easier, I feel, to manage them this way.

Keep in mind that I'm not using some large IDE - I switch between Vim and Chocolat.

Rails is an opinionated framework. Many very smart people already came up the best practices for building a web application through several dozens of releases over almost 10 years. Just follow the best practice. If you are not happy with Rails being what it is, just change it to some other framework.

Having 50-100k loc files sound horrible by the way. I would not want that to happen in Rails.

>IDE's makes it somewhat easy for pussies (...) Back to my C++ days I had written utilities and class files represented just by a couple of files reaching between 50-100k long

You were doing it wrong.

Plus, implying that IDEs are for "pussies" (whatever that even means) doesn't give the impression of you being particularly clever.

Think about it this way. If you work with a large team which is split between multiple locations and each developer has a set of tasks to work on, having everything in 1 source file means everyone has to update the same file regardless of what they are actually working on. Using your example, if you have all_models.rb, any change needed for any model would mean committing the entire source code in the file. Huge risk.

The idea of multiple files is to have a modular approach which means easy to divide tasks, collaborate and mange version controls. Sure it means having to traverse through multiple directories/paths/files but this small sacrifice is nothing compared to the risk of having large source files.

>IDE's makes it somewhat easy for pussies

Oh wow. You're in all sorts of trouble right off the bat. Not only are you missing out, but also and worse, the fact you say it is for "pussies" is a really bad sign. You're probably missing out on other great tools because you simply are prejudiced against them. And yes, I can use cat, vim, and even emacs. A good IDE is crazy-more powerful.

Why can't we have an IDE that provides a "single file" view into multiple files? It would display them one after the other in a single tab, allow search across multiple files, probably even cut-and-paste from one file into another without switching tabs. And of course it would be easy to choose which files go into this view - you could have all_models one moment, models_and_controllers_related_to_feature_X a moment later, without changing anything in real files.

Wouldn't such IDE feature provide all benefits of a single huge file - but with different physical files, e.g. for source control purposes?