Hacker News new | past | comments | ask | show | jobs | submit login

> export default class extends Controller {

I know it is vanilla ES6, but at some point it starts looking more like Java than JavaScript. The boilerplate necessary to convey a simple instruction is directly proportional to the averaged speed of everything else (authorship, maintenance, execution, testing, frequency of reuse, and so forth).




Do you mind expanding on what you mean? When I look at the instructions here, they seem pretty concise.

`export` -> exports the thing

`default` -> if you require from this module, this is the default

`class` -> class definition

`extends` -> speaks for itself

`Controller` class it's extending.

You could maybe rework it so you don't export it on the same line:

```

class Foo extends Controller {}

export default Foo

```

The parallel I see here to Java is the object orientation - which is a fair criticism. There are probably ways to execute on this using other mechanisms other than inheritance. But then, sub-classing to me still feels better than assigning the prototype via direct assignment.


Java has no concept of default, but otherwise `public class Foo extends Controller {}` would be pretty similar. It's not that the keywords are overly verbose for the purpose they express, it's that they relate more to "code bureaucracy" than to direct functionality.

In a language with fewer developers/smaller projects/fewer interdependent modules, there would be no need for exporting (no privacy, everything public by default), there would be no special syntax for extending a class (after all, you could just write it yourself if you need it), there might not even be any classes at all (again, you could just implement them if necessary).

But as languages mature, code bases start to grow, and every project depends on a web of dozens of slightly incompatible packages, people begin to realize that they need some mechanism to enforce order and to standardize on a single, officially blessed implementation of all those things you could just do yourself (and everyone did, with no regard for compatibility).

Then, when the language feels bogged down with the ceremony necessary for programming "at scale", someone decides to just throw all that baggage over board and develops a fresh scripting language, where the cycle begins anew.


I've never written any java code, but I really love the module systems inspired by it. I've been using this kind of packaging in both javascript and golang, and it actually feels way simpler than in ruby where I'll always end up with `Namespace1::Namespace2::Namespace3::klass` to deal with the global scope of everything.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: