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

WIP: Add Node.js to Perl 6 nutshell page #1975

Merged
merged 2 commits into from May 21, 2018
Merged

WIP: Add Node.js to Perl 6 nutshell page #1975

merged 2 commits into from May 21, 2018

Conversation

Kaiepi
Copy link
Collaborator

@Kaiepi Kaiepi commented Apr 29, 2018

DO NOT MERGE YET

Just looking for some feedback as I write the page.

Fixes #1968


=SUBTITLE Learning Perl 6 from Node.js, in a nutshell.

This page attempts to provide a way for users experienced in Node,js to learn
Copy link
Member

Choose a reason for hiding this comment

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

Node,js should be using a . instead of a ,.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is no comma in Node.js here

Copy link
Member

@Tyil Tyil May 2, 2018

Choose a reason for hiding this comment

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

This page attempts to provide a way for users experienced in Node,js to learn

Node,js

I'm pretty sure the exact line I referenced contains a , right there.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's in line 7, experienced in node,js

In Perl 6, there are two ways to write this in the same way:

=begin code
put 'Hello, world!';
Copy link
Member

Choose a reason for hiding this comment

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

The documentation on say comes with this line

Prints value to $*OUT after stringification using gist method with newline at end. To produce machine readable output use .put.

I'd consider using say in your examples, since this is the most commonly used (from what I gather in #perl6, that is).

Copy link
Member

Choose a reason for hiding this comment

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

since this is the most commonly used (from what I gather in #perl6, that is)

Whether you use one or another depends on your intent (but yes, most examples should probably use say)

console.log('Hello, world!');
=end code

In Perl 6, there are two ways to write this in the same way:
Copy link
Member

Choose a reason for hiding this comment

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

There are many more, actually. Like say.

say "What's up, " ~ $name ~ "?";
say "What's up, $name?";
say "What's up, ", $name, "?";
=end code
Copy link
Member

Choose a reason for hiding this comment

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

You're showing different quote styles in the Javascript example, one without interpolation and one with interpolation. Why not do the same for Perl 6, ie: single quotes and double quotes?

This is how the equivalent types of variables are defined in Perl 6:

=begin code
my $foo = 1; // Lexically scoped with blocks
Copy link
Member

Choose a reason for hiding this comment

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

» perl6 -e 'my $foo = 1;      // Lexically scoped with blocks'
===SORRY!=== Error while compiling -e
Null regex not allowed
at -e:1
------> my $foo = 1;      //⏏ Lexically scoped with blocks

Perl 6 uses # to start a comment, not //.

@Tyil Tyil changed the title Add Node.js to Perl 6 nutshell page WIP: Add Node.js to Perl 6 nutshell page Apr 30, 2018
@Kaiepi
Copy link
Collaborator Author

Kaiepi commented May 2, 2018

Updated

Copy link
Contributor

@JJ JJ left a comment

Choose a reason for hiding this comment

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

Please check also the test error and try to fix it in your next commit.

Since he didn't hear us, let's greet him again, this time in Perl 6:

=begin code
my $name := 'Joe';
Copy link
Contributor

Choose a reason for hiding this comment

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

Is let binding? If it's not, it's better to just use =

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you have a look at this?

Copy link
Member

Choose a reason for hiding this comment

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

let is not binding in Javascript, let makes it a block scope local variable.

logDupe(2); // 2
=end code

Perl 6 also allows this:
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see it clearly here, but we're using the unicode character non-breaking space for the space before 6. If you've done so, no problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

* is not, per se, a twigil; $* together are the twigil.

console.log('Hello, world!');
=end code

In Perl 6, there are two ways to write this in the same way:
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, there's "say" too... Maybe this example should include printing of variables, and how that is done in Perl using dd

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should show off dd as being a Perl 6 feature, as dd is a Rakudo specific feature.

@Kaiepi Kaiepi force-pushed the nodejs branch 2 times, most recently from 584ad81 to 6af128f Compare May 16, 2018 23:28
@Kaiepi
Copy link
Collaborator Author

Kaiepi commented May 16, 2018

Updated, corrected some parts of the basic syntax section that were incorrect


=SUBTITLE Learning Perl 6 from Node.js, in a nutshell.

This page attempts to provide a way for users experienced in Node,js to learn
Copy link
Member

Choose a reason for hiding this comment

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

I know you've told me twice already that you don't see a comma here, but it still reads Node,js.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whoops, thought I got that in the last commit

let foo = 2;
console.log(foo);
}
logDupe(2); // 2
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add console.log(foo) here to show that the original foo declared before the function is unaffected.

my $foo = 2;
say $foo;
}
log-dupe; # 2
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a say $foo here to show that the original $foo declared before the sub is unaffected.

The C<=> operator works the same across both languages.

The C<:=> operator in Perl 6 binds a value to a variable. This makes it so the
variable can't be reassigned. Binding a variable to another variable gives them
Copy link
Member

Choose a reason for hiding this comment

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

the variable can't be reassigned.

Oh? Afaik := just binds the value directly to the variable, but you can still reassign the variable:

> my $a := 5; $a := 4; say $a;
4

my %bound := %map;
%map<foo> = 'bar';
say %bound; # {foo => bar}
=end code
Copy link
Member

Choose a reason for hiding this comment

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

Can you show how a regular hash would look like, if it were assigned with =? This would make it more clear to see the differences between assignment done with = and :=.

@Kaiepi Kaiepi force-pushed the nodejs branch 6 times, most recently from cdffe91 to e0d3509 Compare May 17, 2018 18:17
@Kaiepi
Copy link
Collaborator Author

Kaiepi commented May 21, 2018

Updated with documentation on operators

@Kaiepi Kaiepi force-pushed the nodejs branch 4 times, most recently from d2930af to 91b1a70 Compare May 21, 2018 00:54
@JJ
Copy link
Contributor

JJ commented May 21, 2018

Please check the POD error and fix it.

@JJ
Copy link
Contributor

JJ commented May 21, 2018 via email

@Kaiepi
Copy link
Collaborator Author

Kaiepi commented May 21, 2018

Please check the POD error and fix it.

Done

I think that come a certain point, it's better to accept it so that anyone can work on it. It's better to have something there than to have something perfect.

I think this is a good idea. The rest of the first section is relatively straightforward to write, but the later ones are too complex to write comprehensive documentation for alone

Copy link
Contributor

@JJ JJ left a comment

Choose a reason for hiding this comment

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

I'm aproving this as it is now, and leave the rest for future improvements. The areas are well marked, and anyone can work on them now. I'll create an issue to that effect.

@JJ JJ merged commit 343c127 into Raku:master May 21, 2018
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.

None yet

4 participants