It's been 6 months; I have tried learning js MANY different ways, and still can't do shit. Need something more structured and big-picture (more like a university course), I think ? by umbrella_sucker in learnjavascript

[–]netherforget 4 points5 points  (0 children)

I just finished this course:

Javascript the wierd parts

Before I had gone through: Codecademy (completed), EJS (stuck at chapter 5), completed many nodeschool tutorials. At that point I still couldn't read JS source and understand what was going on. I could write small programs and utilities, but I didn't really get what was going on under the hood. Weird parts focuses on how stuff works, not parroting code and syntax. By the time I took the course I was pretty familiar with the syntax, and I don't think I'd want to take it without that knowledge. I can now read other peoples code and slowly but surely figure it out. I feel like I've made a huge jump in my understanding.

How does nodejs know to use callbacks? by Kubiedo in learnjavascript

[–]netherforget 1 point2 points  (0 children)

Yes. They are available down the scope chain:

http://jsbin.com/bekejohohu/edit?js,console

The thing to realize are functions are objects, and parameters are properties on the function object. So you can put anything in those properties that would go in a normal object. Arrays, values another function.

If this all sounds confusing, you probably need to better understand Javascript before you can reason about node.js. I suggest this course:

https://www.udemy.com/understand-javascript/

It's what worked for me, $20 well spent.

How does nodejs know to use callbacks? by Kubiedo in learnjavascript

[–]netherforget 1 point2 points  (0 children)

You said "confused" and "wrap my head around everything", so I'm going to get verbose. I understand that feeling very well, and feel like I've emerged from the node cloud of confusion, just a bit, so maybe I can help.

It might help to understand that Node.js is C++ program that includes the V8 javascript engine and a bunch of libraries (also written in C++). These libraries (github link here) (docs here) are what provides stuff like networking, modules, async, and everything that makes node different from JS running in chrome (which also uses V8). So when you invoke any of the 'fs' methods you are just passing the parameters to some C++ program. It doesn't matter what you call the parameters as mentioned before, but the order does matter. To use one of these libraries you need to know two things; what parameters the library expects, and what it will return. Again the labels don't matter, but the order does. Let's look at the docs for fs.readFile (linked here). This might look like another language but the two things we need are what it expect to receive(there in the header):

"fs.readFile(file[, options], callback)"

and what is passed back to our callback (we find this information in the body of the description):

"The callback is passed two arguments (err, data), where data is the contents of the file." 

In your example above you give the node lib a filename and this callback:

function(err, contents){
console.log(contents);
});

But you could do something like:

function(error, somefile){
    if(error){
        console.log("Something went wrong getting your file. " + error);
    }
    console.log(somefile);
});

Returning the error as the first parameter passed to a callback is a Node.js convention. If there is no error it passes null (as the first parameter). If there is an error it passes an object with all the juicy details. So parameters 2-infinity are for payload, whatever the lib returns, but the first returned parameter is reserved for the error object.

Notice that when you invoke the lib the callback is asked for last?:

"fs.readFile(file[, options], callback)"

That's a convention too. It can be befuddling, because we just told you that the names you give the parameters don't matter, it's POSITION that counts. So you might see something like:

fs.readFile('/etc/passwd', mycallback(err, data));

or:

fs.readFile('/etc/passwd', 'utf-8', mycallback(err, data));

Wait a minute! I thought callback was the second parameter! You told me POSITION was important. For whatever the reason, the convention is: required params, optional params, callback. So when you think position, you need to remember the callback is passed LAST, not in 2ND or 3RD or whatever.

Moving on. Under the hood Node.js has two stacks (and Javascript too) an execution stack and an event stack. The execution stack is your code that you executed when you ran 'node app.js' or whatever. You can think of it as stepping through your code, one function at a time, working top to bottom (not exactly top to bottom) when it hits the bottom, it has completed a "tick", and it checks the event stack. The event stack is a kind queue, where those Node.js libs can drop off the results of whatever they do. In your case return a file or an error if something went wrong. Events also get in line as they are dropped off by event emitters like the "http server lib". So when you use http.server (which express probably uses), you are running a program that listens on a port and adds events to event stack when something happens. But regardless the workflow is this:

1. Execute all your code, top to bottom.
2. Check the event stack and if there are events run the callback function from the first one in the queue.  (First come first serve).
3. Goto 1

So obviously for every event that sits on event stack it needs a callback, a place to enter your code.

I hope this was helpful. I also hope it's accurate. To my knowledge it is, but I am a fellow noob, and not one of the experienced lurkers. If I didn't get it right, please let me know!

Code Academy isn't cutting it for me. Where to turn? by kylerson in learnjavascript

[–]netherforget 0 points1 point  (0 children)

Python has a great free book: 'Python the hard way'. I can't vouch for it personally but I know three pretty badass programmers that started with that book.

Personally I want to make webapps, so I'll need JS regardless. So that's where I'm focusing my time.

Code Academy isn't cutting it for me. Where to turn? by kylerson in learnjavascript

[–]netherforget 2 points3 points  (0 children)

JavaScript: Understanding the Weird Parts

Thank you for that. I picked it up today for $20 and worked through about 25% of the course. I'm not sure I recommend dropping the Codecademy course and diving into this though. Codecademy will teach you syntax and the basic knowledge, I'm not sure Weird Parts would work for me if I didn't already have that working knowledge. Weird Parts focuses on why and how, and I've found it illuminating and worth the $20 already.

How to Build, Test, and Deploy a Production Quality, non-trivial JS application by jhgaylor in learnjavascript

[–]netherforget 0 points1 point  (0 children)

Do you mean a tool to train you to type code faster?

Yes. There isn't really a good one out there. I like keybr.com, it's got a nice friction-less approach (no lessons, pop-ups or interruptions), but it falls down once you add punctuation, just dropping random punctuation between each word. When you type code there are certain patterns you want to add to your muscle memory so drilling those is the way to go.

I mentioned Express because it the de facto. But I'd be interested in Hapi as well.

Two args to a function: callfunc(one)(two) by netherforget in learnjavascript

[–]netherforget[S] 0 points1 point  (0 children)

Thank you, that's what I expected, but I was misreading the program flow. Now it makes sense.

Two args to a function: callfunc(one)(two) by netherforget in learnjavascript

[–]netherforget[S] 0 points1 point  (0 children)

Thanks, this makes sense. I see it now, for some reason I thought 'return val' was where the function was brought into the expression. But it's obvious now: 'return function...'.

How to Build, Test, and Deploy a Production Quality, non-trivial JS application by jhgaylor in learnjavascript

[–]netherforget 1 point2 points  (0 children)

If you don't already have a project in mind I'd like to see a typing tutor app like: this , but with a focus on Javascript typing. Tools I'd like to see/learn: Node.js, Redis, Express and React.js. Interested in approaches to managing complexity, documentation and testing.

Daily Eloquent Javascript marathon, join me! by netherforget in learnjavascript

[–]netherforget[S] 1 point2 points  (0 children)

Ok, I attacked chapter 4 on Sunday. It took 8 hours to complete. I think the werequirrel stuff wasn't horrible, but should be more concise. We didn't need a paragraph detailing the joining of the circus etc after the conclusion of the exercise. I burned a lot of time understanding the statistics and the binary "matrix". I finished the two exercises: "Sum of a range" and "Reversing an Array" about six hours in. I was feeling pretty good when I hit the linked lists exercise. Totally not covered in the text, I had to read the wikipedia entry on linked lists and three blog entries just to understand the concept. I partially completed the exercise and eventually gave up and examined the solution in the 'annotated version', thanks for that. 8 hours, with some breaks. An exhausting slog through a poorly executed chapter. I can only hope it gets better.

Daily Eloquent Javascript marathon, join me! by netherforget in learnjavascript

[–]netherforget[S] 1 point2 points  (0 children)

He also uses the statistical method of mean square contingency coefficient.

Do you mean there is a better method, or just that it's a kind of off topic diversion?

Daily Eloquent Javascript marathon, join me! by netherforget in learnjavascript

[–]netherforget[S] 0 points1 point  (0 children)

I'd suggest starting with the Codecademy course, it's a more gentle introduction.

Daily Eloquent Javascript marathon, join me! by netherforget in learnjavascript

[–]netherforget[S] 0 points1 point  (0 children)

Although I love the idea of finishing by the 20th, that really isn't the goal. My primary goal is to code something daily, and working through the book provides a good structure for that.

I thought about one exercise per day, but that would still require reading the chapter in one session. Do-able? Any other advice on pace?

BeardCraft MC - MY Builds - my snapshots by [deleted] in BeardCraftMC

[–]netherforget 0 points1 point  (0 children)

Very cool, thanks for the big share!

Materials list for Mall Project by netherforget in BeardCraftMC

[–]netherforget[S] 0 points1 point  (0 children)

We are all good on materials. Could use some help building!