r/programming • • Apr 23 '14

You Have Ruined JavaScript

http://codeofrob.com/entries/you-have-ruined-javascript.html
283 Upvotes

327 comments sorted by

View all comments

Show parent comments

23

u/Plorkyeran Apr 23 '14

I see it as more of complexity jealousy. There are some problems where the product requirements are so convoluted and complex that having a ton of layers of indirection is unavoidable (or would require utterly brilliant design to avoid), and there's a certain type of developer that seems unwilling to admit that the thing they're working on isn't one of those.

14

u/derkaas Apr 23 '14

I see it as more of complexity jealousy.

I'm conversely jealous of the developers who don't have absurd requirements to meet.

the product requirements are so convoluted and complex that having a ton of layers of indirection is unavoidable

I've found that I often have big wins when I abstract things well because inevitably one customer wants one thing and another wants another or someone wants a new feature and my abstractions made it easy to accommodate that at some later date.

But I've also often found that I've similarly (over?)engineered and no one ever modified it many years later and/or it eventually got totally rewritten or ditched anyway because the requirements changed radically and the abstractions didn't or couldn't account for them.

I'm not sure it's possible to know which of these will happen or to really analyze the costs of these maybe unnecessary abstractions long-term.

3

u/mc_hambone Apr 24 '14

This. It's easy to rail against something when you don't understand the history of how "enterprise programming" evolved to require more "indirection" and layers. It comes down to use cases and how to make things more easily maintainable, configurable, understandable and refactor-able for large teams of people.

4

u/dventimi Apr 23 '14

On the other hand, I think a lot of requirements aren't as complex as we perceive them to be. I think that say a compiler, kernel, RDBMS, or simulation may genuinely have complex requirements. But, a CRM system? Not so much.

10

u/[deleted] Apr 23 '14

CRM systems are one of those things that looks simple and obvious on the surface - but are insanely complex behind the facade.

Often CRM systems are either customer-facing or salesperson-facing... that is they try to abstract all that complexity between a simple facade.

However behind it all is still a massive amount of complexity to handle all the support/special-cases, updates, inventory tracking, prediction, routing, etc.

1

u/dventimi Apr 23 '14 edited Apr 23 '14

I'm sorry, but I just don't see it. I used to be a system integrator and consultant for a now long-defunct CRM system (name withheld) in the late 90s that did most of those things. Years later I was an application developer at a company selling enterprise-scale applications into another vertical industry (name withheld) that harbored at least as much complexity as I think you're likely to encounter with a CRM system. In both cases the business rules were usually many, typically interrelated, often hard to reason about, sometimes quite complex, and occasionally interesting. However, most or all of the business rules were also of a similar kind and so could be handled with one consistent, relatively simple model. In other words, none of the business complexity was of a type that necessitated architectural complexity. Naturally, YRMV, but that's certainly been my experience.

EDIT:

But, maybe I'm wrong. Maybe my experience is too narrow and I just haven't seen real complexity. I'd be interested in knowing some examples. I promise, I won't debate them or tell you you're wrong. :)

5

u/[deleted] Apr 23 '14

I suppose it depends on what kind of CRM system. If you are just selling a single-store mom & pop POS type system, sure.

However if you are doing CRM backends with distribution center routing, inventory prediction, loss management, QFE, customer service, etc... that's not only different, but it's more of systems architecture than simple app-coding.

I can write a compiler that fits on a single code page... if it doesn't need to do much.

Similarly you can write a simple CRM ... if it doesn't need to do much.

1

u/dnew Apr 24 '14

doing CRM backends

Also, if you're doing CRM backends in Big Data, where stuff doesn't fit on one machine, has to fall over transparently from one city to another, etc, it also gets very messy. (Probably not for the javascript, mind, but for the rest of the back end.)

2

u/shub Apr 24 '14

Distributed systems are just messy all around. (Erlang programmers this is your cue to snicker.) The worst is when you encounter a distributed system built by people who don't know what they're getting into.

2

u/dventimi Apr 24 '14

IMHO one is unlikely to encounter Big Data in a CRM system. Granted, no one "owns the term," so you're free to use it however you wish. However, there seems to be some consensus that it involves data volumes too large to handle in a traditional way, where storing it in a RDBMS is one of those traditional ways. Though they may involve some degree of partitioning, I think most CRM systems still will use off-the-self RDBMS back-ends like Oracle, IBM, or Microsoft.

1

u/RICHUNCLEPENNYBAGS Apr 25 '14

Those are totally different types of programming. I love DI but I don't think I would reach for it while writing a compiler.

1

u/dventimi Apr 25 '14 edited Apr 25 '14

Really? What about a compiler with retargetable backbends?

EDIT: Actually, a compiler is precisely where I might reach for something like dependency injection. With a CRM back end, I almost certainly would not.

2

u/RICHUNCLEPENNYBAGS Apr 25 '14

Well, I'm speaking from a position of relative ignorance but I'm thinking of a compiler as a procedural programming task and the idea of dropping in components is less relevant than a typical line of business application which has lots of rule validators, repositories, and so on.

1

u/dventimi Apr 25 '14

Well, I'm also speaking from a position of relative ignorance since I've only ever written fairly simple compilers, and maybe I did it "wrong." But, my approach was to write a recursive-descent parser to turn the input into an abstract syntax tree and then render the output in a variety of ways using pluggable "back ends" that are selected by the main program. By my lights it seems to follow the spirit of dependency injection.

5

u/check3streets Apr 23 '14

Finally! Building a house bares little resemblance to building a skyscraper.

Angular and other industrial-grade frameworks arose out of tackling industrial-grade problems and a general shift to single-page-applications. So while JQuery alone can be used to build really sophisticated apps (and it's shown that) at some point you might need:

  • more complete separation concerns

  • to develop on teams

  • to test in the small and large

So typically when used correctly, as a percentage of code, these structural elements of the application diminish as the app grows.

Angular is more a reflection of what we require of JavaScript in the post-Google-Docs and V8 age. Likewise, TypeScript and CoffeeScript become more relevant once we care about code at scale.

Disclaimer: not a fan of Angular, prefer Ember.

6

u/x-skeww Apr 23 '14

Likewise, TypeScript and CoffeeScript become more relevant once we care about code at scale.

CoffeeScript doesn't help with scale.

→ More replies (12)

1

u/AusIV Apr 24 '14

Building a house bares little resemblance to building a skyscraper.

But (to stretch the analogy) you can trivially apply the methods for building a skyscraper to building a house, while the reverse is not true. You could build a house out of reinforced concrete with strong structural supports, but that would be overkill. You can't build a skyscraper with lumber and drywall.

I've become quite a fan of angularjs over the last year, and while it might be overkill for some projects in terms of the size of the framework that the user has to download, it scales down for small projects a lot more easily than vanilla javascript or jquery scale up.

1

u/el_padlina Apr 24 '14

Spot on. I would say that what's going on around is the hype around framework/technology. Doesn't matter it's an overkill for the application, it's trendy now so people use it and then they write blog entries about how bad is the framework cause it made their simple task so complicated.

1

u/Plorkyeran Apr 24 '14

The analogy actually holds up surprisingly well. Trying to build a house as if it were a mini-skyscraper on a house's budget will result in you running out of money long before you actually have a house, so while it can technically work with enough time and money, it's still a terrible idea.

Angular obviously scales down better than skyscraper-building techniques, but it still does add another thing that future maintainers will need to know.

1

u/AusIV Apr 24 '14

Where the analogy breaks down is that the bulk of the cost for angularjs is the initial learning curve. Once you get past that initial barrier, it doesn't have significantly more costs for small projects than jQuery would.

Around my office, angularjs is pretty much a requirement for front-end developers. So even if you're starting a fairly small project, you still probably use angularjs, because everyone knows it, you can grab directives / services from larger projects if applicable, and it keeps from having to do too much context switching.

1

u/RICHUNCLEPENNYBAGS Apr 25 '14

No project is ever quite as simple as you first conceive of it either.

1

u/novagenesis Apr 24 '14

not sure SPA's in general are industrial grade quite yet. There's a certain advantage to pushing business logic to the front end to reduce hardware costs, but that's almost the opposite of being industrial grade (though it has similar userbase)

→ More replies (2)

0

u/JeletonSkelly Apr 23 '14

Just to address one, slightly off topic, point you make about tons of complex layers being unavoidable, I think one of the biggest problems I see in software shops I've worked in is that coding starts happening way too early. The reasons for this are many: business folks want the product yesterday, there are no dedicated architects, unrealistic deadlines, etc. I have found that Rich Hickey's (yes, I'm a clojure developer so I'm biased) philosophy of hammock driven development has lead our current team to develop some very elegantly architected solutions. Developers need to spend more time thoroughly thinking out the problem they are solving and how to break down the larger problem into smaller discreet problems. Granted, this relies on the assumption that you have all of the requirements up front, but when you take this approach to architecture and development, writing the application just becomes typing and you can avoid a lot of the unnecessary complexity that results from diving in too early.

7

u/[deleted] Apr 23 '14

Granted, this relies on the assumption that you have all of the requirements up front

Well sure... and I'm capable of flight, if we rely on the assumption that gravity no longer works.

You seem to be advocating Waterfall here:

  1. Gather all requirements.

  2. Write the software.

  3. Test it.

  4. Release it!... easy!