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

> implicit returns

In my experience it has only been a problem when porting existing code bases. We only had to be a bit careful putting a return after a for loop at the end of a function so it doesn't build a list unnecessarily (otherwise implicit returns of unused random values don't hurt). For clarity, one of the few rules we have is to use return explicitly when a function is more than a single expression.

> objects without brackets

The language allows it but it doesn't mean you must use them. We have a loose style guide where we forbid a few confusing uses (like bracket-less one liners or returned objects). So loose it's shorter than this comment.

> no spread operator

It always had a spread operator (except for the first month of life). It's just called splat instead of spread, like in Python. Now it also allows ES6 syntax which is very similar (...foo vs. foo...).

> significant whitespace

That's not a bug, it's a feature ;)

> no variable declaration keyword

In the last year or two, that only bite us once. If it's more frequent than that your functions are way too long.

But as you say, it's a matter of taste.




some colleagues of mine have complained about the significant whitespace being difficult to understand. i can't argue with something subjective like that.

however i like to point that our entire codebase, CS, JS, TS, Python, Java, Swift, 100% of it already has significant whitespace.

...it's just that the JS/TS/Java also have curly brackets.


I'm not sure I understood. I don't know about Swift but do JS and Java have significant whitespace?


No, twykke is saying that in almost every language, even ones that don't technically have significant whitespace, people still use coding conventions and style guides that restrict whitespace to match the curly braces. Some people even use automated commit hooks to reject commits that don't follow the guide.

The end result (or arguably, driving force) is that even in languages where whitespace isn't significant, people read the whitespace, not the curly braces. So the curly braces are basically redundant noise.


Ok, thanks.

I agree about { } being mostly noise but I think they are the lesser evil. I'm making most of my money with Python and I still believe significant whitespace is a very bad idea. The Ruby alternative of using end is better even if not super elegant (and Ruby is my language of choice). It's on par with curly braces. After 30+ years of programming I still have to find a satisfying solution to the problem.


From the perspective of how it was intended to be used, you've got it exactly right. Just because you can implicitly return a braceless object, doesn't mean you should.


i tend to use an explicit return except in one-line functions; there are plenty of CS features you can forgo if you don't think they benefit you.




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

Search: