Live data from Hacker News

Interview with Douglas Crockford

evrone.com

91–100 of 107 posts

Re: Interview with Douglas Crockford

#91

Earlier quoted context omitted.

I vastly prefer functional programming to OOP. But I find my use of `class` in JS increasing for two reasons orthogonal to the paradigm distinction: 1. Particularly in pure JS projects which either haven’t yet or won’t migrate to TypeScript, classes are an excellent way to define data types . They needn’t be stateful, they can be used just like POJOs in otherwise pure functional code. But their shape is clear (or can…

Immutability in JS is painful and tedious, how can you enjoy write functional code in JS?

I don’t find it painful or tedious.

- Constructing flat POJO values is trivial (spread + define any changed properties).

- Immutable array operations are fairly robust, albeit not as expressive as some may want. Getting comfortable with reduce improves this dramatically.

- Map/Set constructors accept instances to create new values.

- Class instances used as value types are simple to derive, assuming their constructors accept objects in their shape. If they have a consistent shape, deeply nested clones with consistent descendant classes are equally trivial.

- Iterators could play nicer with other native interfaces, but they’re pretty handy even so. Custom iterators are exceedingly handy for shuttling data between types.

- More expressive operations over sequence-like structures is as simple as operating on iterators. This will feel more reasonable if you favor Map over POJO for mapped types.

- Imperative stateful functions are admittedly a pain, but wrapping them in functions which return meaningful state you’ll need later is pretty straightforward.

- Really though, starting from a functional perspective just makes these details a non-issue. If your primary tool is a pure function, any gap in these interfaces can be filled by writing a function and calling it rather than the imperative code.

If some or all of that sounds like it’s a performance nightmare… most of the time it isn’t. But if you have a hot loop where copy on write is a meaningful bottleneck:

- You can take inspiration from Clojure or other functional languages with persistent data structures. There are a ton of libraries.

- You can take inspiration from Clojure or other functional languages with a concept like transients, and isolate your mutable code in a function body. This doesn’t even need a library, it’s just bailing to the imperative code the language ostensibly wants you to write in the first place, and being thoughtful about how it’s encapsulated.

What I do find painful and tedious is trying to follow stateful imperative code which hasn’t been subjected to intense discipline. This is true regardless of the language. It’s true whether the code is “object oriented” or not.

Re: Interview with Douglas Crockford

#92
post #83

Earlier quoted context omitted.

Same here. I've never experienced a place where standups added value (at least from my perspective.). Quite the opposite actually.

Same. I don't hate them (they last at most 10 min.), but as someone who has been working for more than 12 years in the industry I think managers/teams do daily stand-ups because of cargo cult.

[deleted]

Re: Interview with Douglas Crockford

#93

Earlier quoted context omitted.

Javascript has GC and tail calls, and I don't think WASM is getting either anytime soon.

Isn't not efficiently implementing tail calls a current JS standard (in that implementing them means your implementation is technically broken) specifically to prevent software from relying on that optimization?

Someone should tell Ecma then: https://tc39.es/ecma262/multipage/ecmascript-language-functi...

I was wrong, though, tail calls are in ES14, and eliminating them is probably not implemented anywhere yet.

Edit: Wrong again, tail-call optimizations are in WebKit; iOS has had them since iOS 12 according to this: https://kangax.github.io/compat-table/es6/#test-proper_tail_...

Re: Interview with Douglas Crockford

#94
post #18

Earlier quoted context omitted.

ES6 is what makes JS bearable to write modern day. Totally don't understand his point here. Who wants endless nested promise chains?

> Who wants endless nested promise chains? Believe it or not, you can actually structure things so it's "flat" looking without async/await (or even without Promises for that matter, but Promises solve other problems too). Just because someone argues against something like async/await, doesn't mean they want the thing async/await is supposed to address.

No post body was provided.

Re: Interview with Douglas Crockford

#95

Earlier quoted context omitted.

Immutability in JS is painful and tedious, how can you enjoy write functional code in JS?

I don’t find it painful or tedious. - Constructing flat POJO values is trivial (spread + define any changed properties). - Immutable array operations are fairly robust, albeit not as expressive as some may want. Getting comfortable with reduce improves this dramatically. - Map/Set constructors accept instances to create new values. - Class instances used as value types are simple to derive, assuming their constructor…

Thanks

Your list sums up why I find it tedious ;), since you mention Clojure, in Clojure one doesn't have to think about those things and go through hoops(except for when doing Java interop). Unfortunately I don't think Clojurescript is worth the hassle(or even immutablejs or immer) and just prefer writing JS and applying your list.

Functional programming languages spoil you in this regard.

Re: Interview with Douglas Crockford

#96

Earlier quoted context omitted.

I don’t find it painful or tedious. - Constructing flat POJO values is trivial (spread + define any changed properties). - Immutable array operations are fairly robust, albeit not as expressive as some may want. Getting comfortable with reduce improves this dramatically. - Map/Set constructors accept instances to create new values. - Class instances used as value types are simple to derive, assuming their constructor…

Thanks Your list sums up why I find it tedious ;), since you mention Clojure, in Clojure one doesn't have to think about those things and go through hoops(except for when doing Java interop). Unfortunately I don't think Clojurescript is worth the hassle(or even immutablejs or immer) and just prefer writing JS and applying your list. Functional programming languages spoil you in this regard.

> Your list sums up why I find it tedious ;)

Weird!

> Unfortunately I don't think Clojurescript is worth the hassle(or even immutablejs or immer) and just prefer writing JS and applying your list.

Seems like we agree actually?

Re: Interview with Douglas Crockford

#97
post #90

Earlier quoted context omitted.

The good question is how to hire people that will care, and whether or not it can be incorporated into a culture.

Let's hire people good at programming and let's leave the fluff behind.

After many years, defining "good at programming" is hard. I would say, reading your code is part of that. I used to read all the code that got checked-in for one of my large projects.

The other part is that you can also grow people into being good. This is one of the more important roles of big-tech where college grads come in as n00bs and become engineers.

Re: Interview with Douglas Crockford

#98
post #66

Earlier quoted context omitted.

> I started to get a bad feeling when the class keyword became popular, but all of the old good parts are still there. I actually like many of the new parts - the class keyword being a notable exception. The other (much much milder) exception is async/await syntax - I love Promises but the async/await sugar on top of it this seems a little too much like magic. At the end of the day, they're still just Promises, just…

I think async/await could perhaps have been better used as more general threading primitives to shift the language more toward multithreading. I do like them in comparison to raw promises though.

> I do like them in comparison to raw promises though.

Promises can get a little unwieldy raw - working on making that easier is a noble goal. But I'm never a fan of systems that actively obscure how something works. We now have plenty of people throwing asyncs and awaits around their code without a clue about how Promises work. It's significantly easier to learn how specific control flows work while writing raw Promises.

Re: Interview with Douglas Crockford

#99
> But since then, there has been strong interest in further bloating the language instead of making it better. So JavaScript, like the other dinosaur languages, has become a barrier to progress.

Strange that he says this, because the original "Good Parts" principle is that you can use the "good" subset of the language.

No matter how many new features they add, that same "good" subset is still there ready to use due to backward compatibility.

Re: Interview with Douglas Crockford

#100

Earlier quoted context omitted.

We tried this in a team a few years ago, and the problem we faced was developers literally falling asleep during readings. We found that the Team wasn't really engaging with the process and instead just tuned out until it was their turn. That doesn't mean I think Crockford's "Dailies" model is a poor one, it's just one issue to be aware of. Though I often find the same in Scrum teams. Folks aren't listening, they're…

> literally falling asleep during readings Dailies in film is watching not quite the final product, but still an output of the process. Maybe the issue was reading code as a team (that's code review/PR) rather than reviewing the output of the code? I think Dailies as a metaphor to me sounds like a call for more regular QA/UAT style review sessions as team. (This metaphor is new to me, but regular "use the product as…

Though he doesn't mention it in this video, I have seen Crockford promoting the 'Dailies' idea in talks before - and he does promote it as a replacement for code review and stand up.

One hour, every morning, where the entire Team reads the code written the previous day and offers feedback. Juniors learn from seeing real-world code presented and explained, Seniors get peer review, more eyes means fewer bugs, etc.

It didn't work for my Team, but I would be interested in trying it again in future.

Post reply on HN