Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build platform enum #1909

Merged
merged 3 commits into from
Mar 11, 2019
Merged

Add build platform enum #1909

merged 3 commits into from
Mar 11, 2019

Conversation

zekth
Copy link
Contributor

@zekth zekth commented Mar 11, 2019

added an enum for the build platform and exported it to be exposed to user. And make it consistent for any other plaform update. To be used like:

if(Deno.plaform == BuildPlatform.win) {

js/build.ts Outdated

/** The GN build arguments */
gnArgs: string;
}

/** The operating system platform. */
export enum BuildPlatform {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to OperatingSystem.
And export this from js/deno.ts too.

CI is failing because of formatting. Run tools/format.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm OperatingSystem sounds like a really long name, personally preferring OSType, OSKind (we already have ErrorKind) or other similar names...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure OSKind is fine. I think the longness doesn't matter much, since this is a fairly internal bit of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @kevinkassimo . So i rename it to OSType ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Copy link
Contributor

@kevinkassimo kevinkassimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kitsonk
Copy link
Contributor

kitsonk commented Mar 11, 2019

What is the use case? I am not sure enums really add any value here over string literals. It requires an extra export too and string comparison is impaired. Just because you can doesn't mean we should.

@zekth
Copy link
Contributor Author

zekth commented Mar 11, 2019

As users may compare it, it's more revelant to add it to an enum instead of making string comparison. Avoiding mistakes. IMO as a user i don't really want to be bothered by OS is win / windows / win10 etc.

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 830ce93 into denoland:master Mar 11, 2019
@kitsonk
Copy link
Contributor

kitsonk commented Mar 11, 2019

When using TypeScript, which you would for an enum anyways, string literals are just as "safe" as enums. You get errors as well as code completion in IDEs and you don't have to reference the type. I am still opposed to this.

@zekth
Copy link
Contributor Author

zekth commented Mar 11, 2019

And if for some reason you migrate the string from win to windows . Refactor of calling code is needed, not in the case of the enum.

@kitsonk
Copy link
Contributor

kitsonk commented Mar 11, 2019

But that is solving a problem we don't have. You can just as easily decide to rename BuildPlatform.win to BuildPlatform.windows as well. That argument doesn't make sense.

@zekth
Copy link
Contributor Author

zekth commented Mar 11, 2019

What ever, revert the PR if it's such a huge problem ....

@zekth zekth deleted the enums branch March 11, 2019 19:27
@kevinkassimo
Copy link
Contributor

kevinkassimo commented Mar 11, 2019

I think this boils down whether we really want to enforce that all users to use TypeScript (or preferring at least CheckJS)...
There is so much uncertainty at this point whether Deno would be treated by the users as a real TS runtime or an alternative JS runtime. Similar debates happened months ago over adding runtime parameter type checks.
I'm personally ambivalent on this topic at this point. Guess I'll just wait and see public responses as Deno gradually improves and stabilizes...
(RN I'm looking forward much more on performance boost than ergonomics discussions. I've realized that I myself haven't actually used Deno for any real scenarios except for developing Deno itself, mostly due to performance issues)

@ry
Copy link
Member

ry commented Mar 11, 2019

I'm sorry I merged before this conversation happened. I think Kitson has a point - I've asked him to set a fix PR which will change the enum to a type alias. (I also think it should be renamed to OperatingSystem from OSType...)

I think this boils down whether we really want to enforce that all users to use TypeScript

I definitely want this to be usable for normal JS too. This is part of browser compatibility, but also eschewing types is useful in many situations where I want to use Deno: prototyping, data cleaning, plotting.
If we were going to program in super strict type systems all day, we might as well use Rust - the benefit of this system is that we can opt in to different levels of type checking. Deno and deno_std obviously need the most strict linting and type checking, since these are complex bits of code meant for mass consumption. But we shouldn't force user code into that - only give them the option to opt-in.

ry added a commit to ry/deno that referenced this pull request Mar 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants