Hacker News new | past | comments | ask | show | jobs | submit login
Sosml: An Interpreter for Standard ML Written in TypeScript (github.com)
41 points by kristianp 6 months ago | hide | past | web | favorite | 6 comments

Just a quick look at the code. One of the first lines in the random first file I checked:

> function printBasis( state: any, dynamicBasis: any, staticBasis: any, indent: number = 0 ): string { ...

When Microsoft removes the 'any' type this language (and hype) is dead. I've never came across a TS code base that is actually 100% type safe, and that apart from the fact that at run time there is no type checking at all, just Javascript.. That's why I still prefer the ease and security of dynamic type checking, because it is real safety. I know TS can still help in a large code base especially for the less experienced dev's out there, but it comes with a very high price that no TS proponent dears to admit or cannot assess. We live in a world of dreamers.

I’ve never had any trouble avoiding usage of any thanks to how powerful TS generics and interfaces are. Also why would it type check dynamically? TS is a static typing utility, there are other ways to type check JS at runtime if you need to do so. These statements (and that you seem to think TS is most helpful for “less experienced secs”) make me think you’re not actually that familiar with its usage

I’ll be the first person to say that I’m eager for a viable front end solution without any JavaScript (shoutout vugu, an awesome but young and experimental go lib), but TS isn’t going to die with the removal of any lol

By "random first file" you mean "first file in the directory," which is for the cli. The printBasis function is the driver for the P part of the REPL, and it's not exactly something that the interpreter depends on for correctness. Poking around the codebase, it looks like they could give types fairly easily to this function, but they just haven't done it yet.

It looks to me like you found one of the only functions that use 'any' in the entire codebase. Others are things involving bindings in an environment (where anything really can appear, though one might argue a union type restricting to only ML value types would be more appropriate) or generic functions like for equality testing, which I'm not sure exactly why they take 'any'.

Dynamic type checking? What?

You can turn strict mode on and remove the 'any' type.

It's for transitioning your JS codebase or if you don't need 100% soundness.

I like to type the core of the app and slowly type other less important things when I have time.

I have not used TS, but I have used Flow, which is just a typesystem for JS from Facebook.

I was never confident that the typing I was adding was doing anything other than making the Flow interpreter(for lack of a better word) happy. I had no more confidence in my code that with out it.

So I removed it.

I believe that well maintained linting rules, and good code reviews (you are doing code reviews, aren't you) give you all the same protection, and less false sense(s) of security.

Like you imply (I think), it is still just JS. I beleive you are better served by understanding that, and coding carfully.

I think pretty much anyone who writes TS is well aware of the dangers of any. However, I think it is a necessary convenience since TS does not use nominative typing.

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