Live data from Hacker News

DeviceScript – TypeScript for Tiny IoT Devices

github.com

151–160 of 160 posts

Re: DeviceScript – TypeScript for Tiny IoT Devices

#151
post #46

Earlier quoted context omitted.

What exactly do you miss? JS has built-in reflection, eg `typeof instance`, `instance.constructor.name`. Even multiple dispatch can be hacked together if you really need it, eg there is a library @arrows/multimethod.

Those don't change that the type system is structural; the type system is actually not fully safe if you use the things you mention, eg: class Dog { woof(){} } class Cat { meow(){} } function f(a: Dog|Cat) { if (a instanceof Dog) { a.woof() } else { a.meow() } } let dogish = {woof: ()=>{}} f(dogish) This compiles because dogish is structurally a dog, the type system allows instanceof to narrow the type but "dogish in…

The fact that it compiles is due to the TypeScript’s goal of being pragmatic rather than sound. If an instance isn’t derived from the class Dog, it doesn’t mean that it doesn’t conform to the type/interface Dog, yet TypeScript assumes it means that for the instance of check. It has more to do with TypeScript being a bolt-on over JavaScript that has to take into account existing codebases rather than with TypeScript being structurally typed.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#152

Earlier quoted context omitted.

Good luck understanding things like `if(!!!c) { ... }` or why a line-break after a return statement matters in JavaScript/TypeScipt ;) JS has its own footguns and legacy baggage.

I've never seen `!!!` in JavaScript, and I do a lot of it. Care to share?

Shouldn't have made an example in the if-statement as it is mostly useless there. But triple ! is very common to negate-and-convert a possibly falsy statement (undefined, null, false/true):

const x: boolean | undefined | null = getValue(); const not_x: boolean = !!!y

I added TS type annotation for clarity, although could be inferred if `getValue` is typed accordingly.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#153

Earlier quoted context omitted.

I've never seen `!!!` in JavaScript, and I do a lot of it. Care to share?

Shouldn't have made an example in the if-statement as it is mostly useless there. But triple ! is very common to negate-and-convert a possibly falsy statement (undefined, null, false/true): const x: boolean | undefined | null = getValue(); const not_x: boolean = !!!y I added TS type annotation for clarity, although could be inferred if `getValue` is typed accordingly.

I've seen `!!` and I've seen `!`, but what would `!!!` get you here that the other two don't?

Re: DeviceScript – TypeScript for Tiny IoT Devices

#154

Earlier quoted context omitted.

Shouldn't have made an example in the if-statement as it is mostly useless there. But triple ! is very common to negate-and-convert a possibly falsy statement (undefined, null, false/true): const x: boolean | undefined | null = getValue(); const not_x: boolean = !!!y I added TS type annotation for clarity, although could be inferred if `getValue` is typed accordingly.

I've seen `!!` and I've seen `!`, but what would `!!!` get you here that the other two don't?

negation plus cast to boolean. See this for more info: https://stackoverflow.com/questions/21154510/the-use-of-the-...

Re: DeviceScript – TypeScript for Tiny IoT Devices

#155
post #46

Earlier quoted context omitted.

Those don't change that the type system is structural; the type system is actually not fully safe if you use the things you mention, eg: class Dog { woof(){} } class Cat { meow(){} } function f(a: Dog|Cat) { if (a instanceof Dog) { a.woof() } else { a.meow() } } let dogish = {woof: ()=>{}} f(dogish) This compiles because dogish is structurally a dog, the type system allows instanceof to narrow the type but "dogish in…

My classic example case is actually even simpler IMHO: type userId = string; type subscriptionId = string; const uid: userId = 'userA'; const sid: subscriptionId = uid; // compiler is OK with this

Those are just type aliases. They're just different names for `string`.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#156

Earlier quoted context omitted.

I have never used it. I just remember reading on the README that is compiles to human readable C.

I that case it might be useful to check previous threads here since vlang has been quite controversial. Or check what they have implemented versus promised.

>...it might be useful to check previous threads here since vlang has been quite controversial.

The majority of controversy has been generated by competitors and detractors using various social media platforms to spread misinformation. To include identified troll accounts created specifically for the purpose of launching such attacks. Something like, "throwing stones and hiding their hands".

It would arguably be better to try the language out for oneself, and form one's own opinion, versus allowing known competitors and evangelists who are purposely spreading misinformation to shape one's mind. Just like it is common sense to not expect a used car dealer trying to make sales to give fair and honest opinions or assessments about competitor's cars.

> Or check what they have implemented versus promised.

Yes, totally agree that the best way is to check something out, and form one's own opinion. Also, these are free open-source languages that we are referring to. People are free to go to their GitHub and make suggestions, discuss, or join the effort to help implement whatever they feel is needed.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#157

Earlier quoted context omitted.

I could be wrong, but doesn't vlang and nim do this?

Has vlang managed to get past its controversies and actually deliver on its promises? Last I heard it was still promising too much, under delivering and not handling the feedback too well.

>Last I heard it was still promising too much, under delivering and not handling the feedback too well.

This is an odd statement, as if pushing along an artificially generated negative narrative. It comes across as not using or having never used what one is talking about. Therefore using hearsay and rumor ("last I heard"), which easily can come from competitors and trolls, as the basis of information versus facts.

Constructive feedback would be going to their GitHub and making suggestions, filing useful bug reports, or helping to implement some feature (for those who are really as technically skilled as they claim elsewhere).

> Has vlang managed to get past its controversies and actually deliver on its promises?

The V project is constantly delivering. This can be seen by their near weekly updates, projects on VPM, projects on Awesome V, etc...

The so-called "controversies", have much to do with competitors and trolls, as with anything else.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#158

Earlier quoted context omitted.

I think a language that just transpiled to the equivalent C would be pretty awesome. I know Google is building Carbon, but it is more focused on C++. They pitch it as Typescript to JavaScript, Scala to Java, Carbon to C++. Instead of Rust or Zig trying to replace C++ or Java, is seems better to just integrate with it without linking through some FFI. I'm working on some C code for some microcontroller since it was to…

I could be wrong, but doesn't vlang and nim do this?

In the case of V, it's already there to do much of what is being wished for. V (an easier higher level C family language) can be transpiled to readable C. Even more, V can transpile C to V (C2V) and can be used like a scripting language, even though it's a compiled language.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#159
post #157

Earlier quoted context omitted.

Has vlang managed to get past its controversies and actually deliver on its promises? Last I heard it was still promising too much, under delivering and not handling the feedback too well.

>Last I heard it was still promising too much, under delivering and not handling the feedback too well. This is an odd statement, as if pushing along an artificially generated negative narrative. It comes across as not using or having never used what one is talking about. Therefore using hearsay and rumor ("last I heard"), which easily can come from competitors and trolls, as the basis of information versus facts. Co…

To be clear: Vlang overpromised and underdelivered on many features. It also included features by shelling out to other executables like curl.

It might have all been fixed by now, but it is a fact that Vlang has had listed many, many, features on its homepage (without any indication that they were work in progress) that had no implementation and that had no proper prototype.

The defensiveness of Vlang supporters is not a good look.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#160
post #157

Earlier quoted context omitted.

>Last I heard it was still promising too much, under delivering and not handling the feedback too well. This is an odd statement, as if pushing along an artificially generated negative narrative. It comes across as not using or having never used what one is talking about. Therefore using hearsay and rumor ("last I heard"), which easily can come from competitors and trolls, as the basis of information versus facts. Co…

To be clear: Vlang overpromised and underdelivered on many features. It also included features by shelling out to other executables like curl. It might have all been fixed by now, but it is a fact that Vlang has had listed many, many, features on its homepage (without any indication that they were work in progress) that had no implementation and that had no proper prototype. The defensiveness of Vlang supporters is n…

> ...overpromised and underdelivered on many features...

We could argue that all programming languages that aren't 1.0, have not delivered yet. So, with that same energy, it will be interesting to go chase around supporters of Jai, Mojo, Zig, Odin, etc... with the same rhetoric.

Vlang is "delivering" to its users, as evident by its near weekly updates, VPM, or Awesome V site. It's an open-source project and language. Developers are free to join the project to ensure "delivery of the product".

Else if they are not using said product, they don't have to worry about it. It would be bizarre for any person to be so obsessed with something one doesn't want to use, unless maybe competitors who are afraid of that language.

> ...shelling out to other executables like curl.

Vlang doesn't use curl in its modules. Everyone is free to check its source code. It has it's own such functionality, written in V. So that's looks like misinformation.

> ...defensiveness of Vlang supporters...

Didn't know about this new rule, where if one posts a response 16 days later, the other isn't allowed to make a counter point.

By the way, don't represent "all" Vlang supporters. Just giving my personal opinions, here on HN, like others are allowed to and for the languages they like.

> It might have all been fixed by now...

If one doesn't know about the thing they are talking down on ("It might"), then that looks like something very odd is going on. Doesn't make sense to worry and talk about something that one doesn't use, except again a competitor or just out to troll.

> features on its homepage (without any indication that they were work in progress) that had no implementation and that had no proper prototype...

Maybe there is confusion about what year or what time period being talked about. This is the year 2023. Perhaps what is being referred to is 2019, the first day(s) of the language being released, or mistakes on its website. Here's the thing though, its a free open-source language. Pretty sure such mistakes have happened on websites and with other languages before (especially just released ones).

Not seeing people on HN chasing down supporters of Jai, Mojo, Zig, Odin, etc... about stuff on their website from 4 and 5 years ago that nobody cares about. Furthermore, people freely choose to use, support, or donate. Not understanding being upset over what languages other people like to use, well unless...

Post reply on HN