Why does NodeJS use JavaScript? [closed] - node.js

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have to admit that I don't fully understand NodeJS. But I am thinking about using it. However what I don't understand why did the founder of NodeJS go with JavaScript? Why not with a language where for example OOP is more simple?
Ok I found some answer.
JavaScript is perfect for event loops with first class function
objects and closures. People already know how to use it this way
having used it in the browser to respond to user initiated events.
A lot of people already know JavaScript, even people who do not
claim to be programmers. It is arguably the most popular programming
language.
Using JavaScript on a web server as well as the browser reduces the
impedance mismatch between the two programming environments which can
communicate data structures via JSON that work the same on both sides
of the equation. Duplicate form validation code can be shared between
server and client, etc.
Source: What is Node.js?
But I still don't get why is it so difficult to use basic things like classes in NodeJS. Ok maybe not difficult but all the solution look like some kind of a hack job.
Edit: Why the down vote?

This question will, undoubtedly, get closed, since it's looking for opinions, but there are some objective questions in your post, so I'll answer those.
Classes are only "basic things" in OO languages that are class based, like in Java.
JavaScript is what's known as a prototypal OO language. This means that it is prototype based.
A prototype is an object that is used for generating other object. In fact, there's actually nothing special about an object that is being used as a prototype. As such, any object can be used as the prototype for a new object.
Prototypal OO can certainly be tricky if you're not used to it. However, as implemented in JS, it brings a lot of flexibility. However, with great flexibility comes great opportunities for writing bad code.

Related

What exactly does it mean for a programming language to be simple? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
What factors are important? How do you know if a given programming language is "simple" or "simpler" than another language?
I'm not sure if this is a fair question to ask, since different languages serve different purposes and it might not really be comparing apples to apples.
However, with that said, memory management would come to mind. One can argue that Java is a "simpler" language than C++, since it has a garbage collector that can deal with some of the complexities around memory management, instead of forcing you to do it yourself.
In my perspective, these are the points that define the complexity of a language.
Variation of syntax from common pseudocode and constructs
Ease of developing a structure for real-life entities like objects
Methods of structure enforcement at compile time.
Memory management strategy allocation/deallocation
Code reusability
Ease of code headers and directives management
Inbuilt libraries
Relative installation package sizes
Data exchange capabilities like over network of files
Process handling like thread management
Relative brevity of the code
Speed of compilation
Developer community size and documentation
OpenSource implementations
Platform dependence
And many more could be added to this list.

Reason for using 4-spaces instead of 2-spaces? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Is there any rationale why HapiJS endorses using 4-space indentations?
Source: http://hapijs.com/styleguide
Short answer: No better reason than anyone else - styleguides are typically only rules for project maintainers. They had to adopt some convention and that was the choice. As a user, you don't really need to care.
Long answer: Hapi is a great framework, built by the folks at Walmart. and specifically a person named Eran Hammer who was unhappy about some architectural choices made by Express, another server framework for Node. It is somewhat opinionated in general, it was effectively created in an environment of opinion, not to mention a large company (which means it desperately needed a convention). That said, you can safely use the Hapi API with any indentation you want, including tabs, though. Likewise, the Hapi internals could have been written the same way. Their specific choice likely comes down to established tools or conventions already in use at the company. Many different projects make different choices for a variety of reasons. In my experience, many large JavaScript applications go with 2 spaces and the Node.js core itself is written with 2. But there's nothing wrong with those that do otherwise.

Do real software Projects use automatic code generation from UML? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have come across tools like visualparadigm demo which could automatically generate code from the class diagram which is modelled in UML. Since I have no industry experience, I am curious to know whether this is the way companies start working on their projects after the system is modelled in UML. since the skeleton of the classes needed is automatically generated, I assume it is a good way to save time. If this is not the way, then why is it so?
Also Can you provide me some other tools which can automatically generate code from UML class diagrams (prefer opensource).
Are there OOP software projects which do not get started with the class diagrams, so that this method can be of no use?
Most of UML are able to generate code from UML class diagram you just have to google it and you will find them.
Concerning the way companies start working, I guess it depends of the companies but from my experience companies try to avoid useless work.
If they spend some time on modeling it is because they can use it for something for example code generation, documentation, or just because its a client request. If companies do not find any interest in modelling they simply do not use it I guess that alot of OOP do not start with models.

Learning functional programming after other programming paradigms [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have taught myself C, Python, Java and a few other procedural or object oriented languages to an intermediate degree from resouces on the internet (thanks SO :D) and in books. When I tried to learn Haskell, I couldn't wrap my head around what the code actually did.
Is there a better functional language for someone coming from a background in procedural or object oriented programming to learn? Are there any resources meant for people in my situation?
Thanks!
It's probably varies with people (and this question is bound to get closed over that), but the way I see it: there isn't a stair you need to step on before you can be within reach to Haskell.
So I'd say you're not driven temporarily off necessarily by the language, but by your sources of learning. For the only truly gentle introduction, I recommend LYAH. It keeps things within reasonable difficulty and it has some really entertaining points every now and then.
However, if you still want to almost-soften your transition, you can check out F# which isn't a functional language but it will give you a good taste of FP, and it will be very familiar to you because you still live in an OO world.
You can also check out basically any other functional language and it will give you some of the mindset (Scala, ML, etc.).
Keep in mind that I say "almost-soften", because Haskell is very different (especially because of purity), and that gives you a very logical and mathematical mindset to things and that has been very different for me than any other language I learned. It's incredible. It was much beyond learning different syntax, it's a way to think about things and I can always find myself learning more and a truly amazing part of it is that (since it's so logical, mathematical, reasonable, etc.) the new ways of thinking I acquire with Haskell don't leave me both when I use other languages and even in my personal daily life.
That being said, the only thing truly horrible with Haskell is that it ruined me for other languages. I used to like C#... :(

Reading Material on Async Programming Practices [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Asynchronous programming is the next up-and-coming paradigm... or so it seems. I have been programming in Node.js for the past few months and have been learning to write code this way. I have a coworker who works in Silverlight and I have been trying to teach him how to use the TPL. I have also been showing him the "await" keyword and how it works.
After a while, using callbacks becomes pretty normal. In Node.js, I am using the caolan/async project to avoid deeply nested callbacks. I have taken a peek at the source code, but it is like reading the STL for the very first time.
Even though I have learned a lot of techniques that work in this environment, I worry I am missing others. I was curious if there were any reading materials/videos that explained async programming techniques and how to build an async library like the TPL or caolan/async.
Just trying to master the paradigm before it's everywhere.
Well even though I know most of Async source code and how does it work, but I still use async mostly. So don't worry about that, you don't need to know exactly how it works. But as of learning, well I suggest you to read these articles:
http://book.mixu.net/node/ch7.html
http://stella.laurenzo.org/2011/03/bulletproof-node-js-coding/
http://howtonode.org/promises
http://web.archive.org/web/20120111150910/http://nodebits.org/distilled-patterns?
http://raynos.github.com/presentation/shower/controlflow.htm (from Raynos comment)
These are the best things that I've seen on the net explaining async control flow at without any abstractions.

Resources