16 ms·
A few years back I wrote an JS+async to JS compiler. I made a very real attempt to forget everything I knew about statically typed languages. I organically fou
by zamalek 9y ago
A few years back I wrote an JS+async to JS compiler. I made a very real attempt to forget everything I knew about statically typed languages.
I organically found a very compositional form. The parser created a tree containing objects such as, for an if statement, { if: { ... }, accept: () => ... }. The next stage would decompose that into more compositions, maybe by adding a block and condition property. While it probably had garbage performance, the power of dynamic languages finally clicked.
I used to be an aspiring game developer; writing a component entity system in C# (my weapon of choice) required absurd amounts of carefully crafted code. Statically-typed languages have a ton of front-loaded overhead if you need something outside of their formula.
You can approach problems any way that you please in dynamic languages (such as the functional approach in the article) and, while they still really aren't for me, I completely understand why people use them.
- weberc2 9y agoIt's not clear to me what you mean by the power of dynamic languages. I'm inclined to think your perspective on static languages is limited to C# or some other OOP static languages. In particular, your example doesn't seem very novel for a statically typed language. Heck, I just built a reasonably elegant parser framework in Go and it doesn't even have generics. This makes me wonder if you're not attributing your OOP frustrations to static typing.
- zamalek 9y agoI really did mean to say OOP - I have been attempting a real project in Go and I'm smitten. Still, even Go has a prescribed way of approaching problems; as unusually broad as it is for a statically typed language. As a very relevant example, there is far more syntactical overhead in Go if you wish to fake FP (e.g. `func Foo(a A) func(b) func(c) func(d) e` to allow currying); where-as in JavaScript you simply bind or apply. I've yet to see an article gushing over how natural functional is in Go (which is fine, Go isn't designed for that). This must be the 20th article I've seen on HN about functional in JavaScript.
- weberc2 9y agoYeah, I agree with your assessments of Go. I didn't mean for it to sound like Go is a good example of expressive static typing--quite the opposite: I was able to build something elegant with Go in spite of its limited, static type system.