The difference between stack and heap

stack

The stack is this chain of suspended function calls, because elements in the stack (function calls) depend on each other.

stack

In a stack of items, items sit one on top of the other in the order they were placed there, and you can only remove the top one (without toppling the whole thing over).

heap

The heap is simply the memory used by programs to store variables. Element of the heap (variables) have no dependencies with each other and can always be accessed randomly at any time.

heap

In a heap, there is no particular order to the way items are placed. You can reach in and remove items in any order because there is no clear ‘top’ item.

source: What and where are the stack and heap? (stackoverflow.com/)

Don Knuth On Programming

I think of a programming language as a tool to convert a programmer’s mental images into precise operations that a machine can perform. The main idea is to match the user’s intuition as well as possible. There are many kinds of users, and many kinds of application areas, so we need many kinds of languages.

I’ve attempted to organize many of the best ideas that have been discovered related to programming, and to explain them effectively, because I believe computer science is a beautiful body of knowledge.

via

THE END

When You should Not use node.js?

Node.js is very hot now. But just as Ruoyu Sun said, node.js has its own niche.

“Node.js was create to make writing concurrent web applications easier… It also chooses a coding style that is common in JavaScript – event driven and callback style, which is not a good way to organise complex logic. Luckily, the logic of most web apps are not that complicated. “

Only in some specific occations, node.js suits your needs best.

“When you start a new real time web app with not-so-complicated logic, try it.”

In other occations, you should think twice.

“If you are developing an online game, you might want to deal with concurrency more seriously – coroutines might suit you better. If you start a content-centric or CRUD web app, you don’t need Node.js. If you write it with Rails or Django, you can develop much faster and you don’t need to deal with callbacks mess on top of your logic. The thing is, for these apps, you don’t have lots of concurrent requests. And for a single request, most of the time is spent on network transfer and perhaps database query – Node.js does not solve the essential problem here. So instead of squeezing a few milliseconds out of perhaps a hundred, you are way better off getting a SSD or a better bandwidth.”

The suggestion is:

“So only use Node.js when you actually need it. Don’t just use it because it is cool / it is popular/ I heard it’s fast / I want to learn something new.”

THE END