News for hackers. Stuff that matters.
Re:How porting to TypeScript solved our API woes by Analemma_ on Wednesday April 08, 2020 @06:58PM (#22818108)
I programmed professionally in C# for about eight years and in that time I can count on one hand the number of times I saw the ‘dynamic’ keyword. Nobody seems to think it’s worth the effort or confusion.
Re:How porting to TypeScript solved our API woes by WorldMaker on Thursday April 09, 2020 @02:42PM (#22825801)
In a past life I did some real wizardry with dynamic in C#, drastically improved performance on a thing that had been using strange combinations of T4 compile-time templates, Reflection.Emit, and some very kooky multi-database lookups with a custom IDynamicMetaObject provider.

It was definitely worth the effort then. I also recognize why it is a very unlikely scenario to repeat.

The other place where I used dynamic most heavily in C# was that it was really great for IronPython interop where you could have a bit of "data science" done in a Python module, build that to a .NET assembly and call into the Python module from C#. (Though the other direction was more common, using IronPython to do data science around a bulk of C# models and code.) With so much more data science since that past life of mine having moved to Python, it's almost a shame that IronPython hasn't really kept up.

Re:How porting to TypeScript solved our API woes by Ididntdothis on Wednesday April 08, 2020 @07:50PM (#22818438)
Agreed. It’s also not as easily used as “any” in TypeScript. I would probably reject a C# codebase that uses dynamic widely. It’s only good for very local use like some serialization or deserialization.
Re:How porting to TypeScript solved our API woes by yyyk on Wednesday April 08, 2020 @07:54PM (#22818462)
That's my experience as well, I just wanted to note that the escape hatch exists.

Maybe I should have amended my comments for 99% of the time? Or perhaps that there are other functionalities (e.g. tuple types, reflection) to to make working with types almost as easy as without? I use reflection very frequently...

Re:How porting to TypeScript solved our API woes by Fellshard on Wednesday April 08, 2020 @09:43PM (#22819066)
However, in JavaScript-world, where the external types you interact with - from other libraries, from APIs, from the browser itself - are poorly defined, having that escape hatch becomes a sanity-saver, does it not? That's where the power comes from: the squishy, fuzzy, less structured edges.
Re:How porting to TypeScript solved our API woes by dpc_pw on Wednesday April 08, 2020 @10:25PM (#22819250)
The parent-parent comment was "I want an escape hatch in the language" and then the argument for it is "someone else used an escape hatch, and now I need an escape hatch". :D
Re:How porting to TypeScript solved our API woes by RobertKerans on Thursday April 09, 2020 @12:44PM (#22824415)
Well, yes, most of the packages available in the JS ecosystem were written in JS. The easiest way to retroactively write typings is to use `any` all over the place.
Re:How porting to TypeScript solved our API woes by yakshaving_jgt on Thursday April 09, 2020 @07:38AM (#22821567)
> having that escape hatch becomes a sanity-saver, does it not?

No, it does not. There is no difference between static languages and dynamic languages when parsing data at runtime.

Re:How porting to TypeScript solved our API woes by jgalentine007 on Thursday April 09, 2020 @02:05AM (#22820204)
Samesy.I almost used dynamic last week for maybe the first time ever, but ended up with a simple generic class instead.