Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,715 members, 7,816,947 topics. Date: Friday, 03 May 2024 at 08:50 PM

Javascript With NodeJS - Programming (6) - Nairaland

Nairaland Forum / Science/Technology / Programming / Javascript With NodeJS (16800 Views)

Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysql / Which is more awesome to use for 'server-side programming', NodeJS or PHP? / Javascript In One PIX: Understand Javascript With Just A LOOK (2) (3) (4)

(1) (2) (3) (4) (5) (6) (7) (Reply) (Go Down)

Re: Javascript With NodeJS by micodon(m): 12:40pm On May 02, 2015
Febup:


Closure gives you access to a variable even when it has gone out of scope. The code you posted involves accessing a variable, which made me to ask you if you were referring to a closure. I don't have a need for the code you posted so there was nothing wrong in asking you what you were referring to

Your first line.....soooo not true
Re: Javascript With NodeJS by Nobody: 12:51pm On May 02, 2015
micodon:


Let me give you a simple example.

Imagine that you have to display the name "guest" for users that are not logged in OR the user name for logged in users. Here's a code snippet using laravel


<?php
if (Auth::check()){
$name = Auth::user()->name;
} else {
$name = "Guest";
}

echo "Welcome " . $name;
?>


OR

<?php
$name = "Guest";

if (Auth::check()) {
$name = Auth::user()->name;
}

echo $name;
?>

you cant tell me that you write codes and you ve not had the need to access a value in a conditional statement from outside it


This just shows that you only code with a language you are used to and you believe that language is better that other languages. The fact that in one language you declare your variable in a conditional statement and access it from out side of that conditional statement does not make that program better than a language like C# where you declare your variable outside a conditional statement which in itself is a scope as it has an open and close {}. Man you just believe you know all and others should just follow you like that.

1 Like

Re: Javascript With NodeJS by micodon(m): 12:54pm On May 02, 2015
Febup:

C++ cannot handle dll hell, but you don't have this issue in C#.
Memory leak is very common in C++ applications but you don't get that in C# applications.
C++ does not support reflection but C# does by allowing you to declare objects at run-time and not just at design time.



Again, you need to do more research. DLL hell is a windows Problem. If in this world you think it doesnt affect C#, try reading about .NET hell.

Memory leak? seriously. Guy, are you sure you program? Memory leak is not a language problem. it is a programmer problem.

Wanna try it in c#? Open a database result set without calling dispose when done with it.

The only thing is that Visual Studio (which is not C#) will detect this.

Reflection in C++? Reflex library, bro
Re: Javascript With NodeJS by micodon(m): 12:58pm On May 02, 2015
Febup:


This just shows that you only code with a language you are used to and you believe that language is better that other languages. The fact that in one language you declare your variable in a coditional statement and access it from out side of that conditional statement does not make that program better than a program like C# where you declare your variable out a conditional statement which in itself is a scope as it has an open and close {}. Man you just believe you know all and others should just follow you like that.

I can write the above code in C# if u like.

Why re u fretting? You said youve not had the need to access variables in conditional statements and i gave u a simple example.

2. Like ive said, You cant say one language is better than the other.

3. The world is reading through this thread
Re: Javascript With NodeJS by Nobody: 1:06pm On May 02, 2015
micodon:


Memory leak? seriously. Guy, are you sure you program? Memory leak is not a language problem. it is a programmer problem.

Wanna try it in c#? Open a database result set without calling dispose when done with it.

The only thing is that Visual Studio (which is not C#) will detect this.

Reflection in C++? Reflex library, bro

Man you are just saying what you don't know. What is garbage collection for in .Net which you need for C#, the garbage collector will that care of this for you, unless you are working with unmanaged resources.

Ok try doing this in C++: At run-time try to inspect by iterating over members of a type, enumerating its methods and so on.
Re: Javascript With NodeJS by micodon(m): 1:08pm On May 02, 2015
...and to be fair to myself, my C# skills are much better than my C/C++ skills.

There's a fundamental truth in programing: when you have good knowledge of a language, its quite easy to get the knowledge of other languages especially when they are on the same level of machine language abstraction
Re: Javascript With NodeJS by micodon(m): 1:14pm On May 02, 2015
Febup:


Man you are just saying what you don't know. What is garbage collection for in .Net which you need for C#, the garbage collector will that care of this for you, unless you are working with unmanaged resources.

Ok try doing this in C++: At run-time try to inspect by iterating over members of a type, enumerating its methods and so on.




You are the one saying what you dont know. Garbage collector will only clean up garbage i.e what you no longer use. If u open a result set, and keep it open, The garbage collector will not clean it up because it ll believe that its still in use and that open result set could lead to memory leak.

Or when you attach an event listener and you dont remove it when its no longer needed. The garbage collector will leave it because its attached to an element or object or watever. could lead to memory leak

So Memory Leaks are from bad programming practise. it happens in all languages. ALl. it just depends on the programmer.
Re: Javascript With NodeJS by micodon(m): 1:23pm On May 02, 2015
Febup:


Man you are just saying what you don't know. What is garbage collection for in .Net which you need for C#, the garbage collector will that care of this for you, unless you are working with unmanaged resources.

Ok try doing this in C++: At run-time try to inspect by iterating over members of a type, enumerating its methods and so on.




The garbage collector will only clean up garbage. when you leave a result set open, the garbage collector will not clean it up because it feels that its in use because its in use. this could lead to memory leak.

When you attach an event listener and refuse to remove it when its no longer needed, the garbage collector wont clean it because its still attached. This could lead to memory leak.

Memory leaks result from bad programming practise. Its a function of the programmer not on the programming language.

Remember that people are reading this thread. Dont post if you are not sure

Bro, dont go googling without understanding how stuff works.
Re: Javascript With NodeJS by micodon(m): 1:31pm On May 02, 2015
and this is going to be my last comment here.
Thanks Pcguru1 for enlightening me on some things.
Re: Javascript With NodeJS by Nobody: 1:35pm On May 02, 2015
micodon:


I can write the above code in C# if u like.

Why re u fretting? You said youve not had the need to access variables in conditional statements and i gave u a simple example.

2. Like ive said, You cant say one language is better than the other.

3. The world is reading through this thread

To show that you are the one fretting. This was your question:
micodon:
Why the heck cant one declare a variable in a conditional block and access it outside?

And I asked you "But why would I need to access a value in conditional statement from outside of it, I have never had the need to do so." This is correct because in C# if need to use a variable outside a conditional statement, I declare it outside of the conditional statement, so that I can access it from outside the conditional statement, but if I don't need that variable outside of the conditional statement I just send the data directly from within the conditional statement. A conditional statement is a scope in itself this shows you have limited knowledge of programming terminologies.

This is why is not good to be a jack of all trade because you become master of none , which you have proved to everyone on this forum. It is better you mastered only the language, framework and tool that is needed for a web, windows or mobile application.
Re: Javascript With NodeJS by Nobody: 1:42pm On May 02, 2015
micodon:
and this is going to be my last comment here.

Of course you will run away because you have shown everyone reading this forum that you are a jack of all trade but master of none , which you have shown here.
Re: Javascript With NodeJS by Nobody: 2:01pm On May 02, 2015
micodon:

Memory leaks result from bad programming practise. Its a function of the programmer not on the programming language.

This was part of the reason for creating languages like C# and Java, to take care of bad programming practices. You don't understand the meaning of managed and undamaged resources in C# and .Net if you do then you'll understand that when you work with unmanaged resources in C# then your program can have memory leak due to bad programming practices and Microsoft has giving a caution before using such: C# supports the concept of "unsafe" code for those cases in which direct memory access is absolutely critical. Source: https://msdn.microsoft.com/en-us/library/z1zx9t92.aspx
Re: Javascript With NodeJS by Nobody: 2:03pm On May 02, 2015
.
Re: Javascript With NodeJS by Nobody: 2:27pm On May 02, 2015
micodon:


Let me give you a simple example.

Imagine that you have to display the name "guest" for users that are not logged in OR the user name for logged in users. Here's a code snippet using laravel


<?php
if (Auth::check()){
$name = Auth::user()->name;
} else {
$name = "Guest";
}

echo "Welcome " . $name;
?>


OR

<?php
$name = "Guest";

if (Auth::check()) {
$name = Auth::user()->name;
}

echo $name;
?>


you cant tell me that you write codes and you ve not had the need to access a value in a conditional statement from outside it


The PHP you are hyping here has no standard so you can write poorly designed code compared to the C# you are condemning that has these standards: 2000, ECMA, ISO[15] .
Re: Javascript With NodeJS by micodon(m): 2:32pm On May 02, 2015
Febup:


This was part of the reason for creating languages like C# and Java, to take care of bad programming practices. You don't understand the meaning of managed and undamaged resources in C# and .Net if you do then you'll understand that when you work with unmanaged resources in C# then your program can have memory leak due to bad programming practices and Microsoft has giving a caution before using such: C# supports the concept of "unsafe" code for those cases in which direct memory access is absolutely critical. Source: https://msdn.microsoft.com/en-us/library/z1zx9t92.aspx

Have to comment on this.

1. First of all, you said that C# programs cant have memory leaks. Now you are saying memory leaks only occurs in unmanaged resources. This second concept is wrong. whenever you refuse to release any variable, object etc that u no longer use, a memory leak could occur.

2. Microsoft strongly discourages the use of unsafe codes.

3. when you do use unsafe codes, they cant work in an untrusted environment, namely networks

4. C# and Java cannot prevent bad programming practises
Re: Javascript With NodeJS by Nobody: 2:46pm On May 02, 2015
micodon:


Have to comment on this.

1. First of all, you said that C# programs cant have memory leaks. Now you are saying memory leaks only occurs in unmanaged resources. This second concept is wrong. whenever you refuse to release any variable, object etc that u no longer use, a memory leak could occur.

2. Microsoft strongly discourages the use of unsafe codes.

3. when you do use unsafe codes, they cant work in an untrusted environment, namely networks

4. C# and Java cannot prevent bad programming practises

I can rely on the information provided by Microsoft below, your information is baseless. In C# and .Net memory leak can only happen when you write your code outside of the managed environment provided by the .net framework, which Microsoft dose not recommend

"The garbage collector only handles managed memory, though. There are a number of places where unmanaged memory is used in Microsoft® .NET Framework-based applications, either by the common language runtime (CLR) itself, or explicitly by the programmer when interoperating with unmanaged code." Source: https://msdn.microsoft.com/en-us/magazine/cc163491.aspx
Re: Javascript With NodeJS by micodon(m): 2:55pm On May 02, 2015
im not hyping PHP. when did i do dat?

im not saying c# is bad. im only saying, that there is no language that does it all. there are shortcomings here. there re strengths there.

i was expecting you as a c# expert to resolve the issue of conditional variables. The reason y u cant do that is because in c#, a variable declaration is a statement not an expression, no value is returned.
Re: Javascript With NodeJS by micodon(m): 2:58pm On May 02, 2015
Febup:


I can rely on the information provided by Microsoft below, your information is baseless. In C# and .Net memory leak can only happen when you write your code outside of the managed environment provided by the .net framework, which Microsoft dose not recommend

"The garbage collector only handles managed memory, though. There are a number of places where unmanaged memory is used in Microsoft® .NET Framework-based applications, either by the common language runtime (CLR) itself, or explicitly by the programmer when interoperating with unmanaged code." Source: https://msdn.microsoft.com/en-us/magazine/cc163491.aspx

and so, a doesnt fall within the scope of managed memory? you need to understand how garbage collection works.
Re: Javascript With NodeJS by Nobody: 3:15pm On May 02, 2015
micodon:
im not hyping PHP. when did i do dat?

im not saying c# is bad. im only saying, that there is no language that does it all. there are shortcomings here. there re strengths there.

i was expecting you as a c# expert to resolve the issue of conditional variables. The reason y u cant do that is because in c#, a variable declaration is a statement not an expression, no value is returned.

This is why C# has standards it has to follow, its not that C# cannot be designed to work that way but because it has to keep to standards to assure the companies who pay thousands of $$$$ for it that C# is following best practices, unlike your PHP that has no standard it follows.
Re: Javascript With NodeJS by micodon(m): 3:24pm On May 02, 2015
Febup:


This is why C# has standards it has to follow, its not that C# cannot be designed to work that way but because it has to keep to standards to assure the companies who pay thousands of $$$$ for it that C# is following best practices, unlike your PHP that has no standard it follows.


What standards does C# follow. give me a link let me understand it
Re: Javascript With NodeJS by Nobody: 3:35pm On May 02, 2015
C# has these standards: 2000, ECMA, ISO[15]. You will need to research about these standards yourself.
Re: Javascript With NodeJS by Nobody: 3:38pm On May 02, 2015
micodon:

Again, you need to do more research. DLL hell is a windows Problem.

You do not know about C# and .Net applications if not you will know that C# applications do not have issues of dll hell.
Re: Javascript With NodeJS by Nobody: 3:58pm On May 02, 2015
micodon:


and so, a doesnt fall within the scope of managed memory? you need to understand how garbage collection works.

The only time your C# code is outside the control of the .Net garbage collector is when you are using unmanaged resources, such as COM resources written in C++. You will need to declare an "Attribute" with [ComImport] on a method to use unmanaged resources this is the only time the garbage collector has no control over the resources you are using in your C# .Net application. This is what Microsoft has explained below but it appears you don't understand what they are talking about.

"The garbage collector only handles managed memory, though. There are a number of places where unmanaged memory is used in Microsoft® .NET Framework-based applications, either by the common language runtime (CLR) itself, or explicitly by the programmer when interoperating with unmanaged code." Source: https://msdn.microsoft.com/en-us/magazine/cc163491.aspx
Re: Javascript With NodeJS by Nobody: 5:26pm On May 02, 2015
micodon:

Again, you need to do more research. DLL hell is a windows Problem. If in this world you think it doesnt affect C#, try reading about .NET hell.
bro

.Net hell? Where can I read about this .Net hell?
Re: Javascript With NodeJS by Nobody: 7:16pm On May 02, 2015
Re: Javascript With NodeJS by Nobody: 7:22pm On May 02, 2015
pcguru1:
http://devproconnections.com/net-framework/net-framework-and-dll-hell

Thanks bro. Notice it says Related: "New Features in Visual Studio 2013 and .NET Framework 4.5.1" I have used .Net 1.0, 2.0, 3.5, 4.0 and 4.5, none of these versions had this issue. I'm sure is just a bug and it will be fixed soon.
Re: Javascript With NodeJS by Nobody: 8:23pm On May 02, 2015
Febup:


Thanks bro. Notice it says Related: "New Features in Visual Studio 2013 and .NET Framework 4.5.1" I have used .Net 1.0, 2.0, 3.5, 4.0 and 4.5, non of these versions had this issue. I'm sure is just a bug and it will be fixed soon.

Sorry i only pasted that link i do not have such .NET experience like that only C# Knowledge
Re: Javascript With NodeJS by Chimanet(m): 9:13am On May 03, 2015
micodon:


What standards does C# follow. give me a link let me understand it
@micodon,
Am really impressed we have some advance JavaScript users here. I tot I was the only one doing core js stuffs .I have a MEAN app am building. Will lyk to get suggestions of free or very cheap host that are easy to work with that you have used in your app. Do you use Grunt for build?
Re: Javascript With NodeJS by GoodBoi1(m): 2:24pm On May 03, 2015
We more discussiond like this in this section. Pls one of you pros should answer my question. What is the nodejs equivalent of PHP's apache? As in what web server should I use for my nodejs website for production environment? I'm trying to understand this
Re: Javascript With NodeJS by Nobody: 2:37pm On May 03, 2015
GoodBoi1:
We more discussiond like this in this section. Pls one of you pros should answer my question. What is the nodejs equivalent of PHP's apache? As in what web server should I use for my nodejs website for production environment? I'm trying to understand this

Node.JS as I understand it works like a web server which you have to code with JavaScript. PHP on the other hand runs on an apache web server, You don't need to code your apache web server before you can use PHP on it.

Will your production environment be on a shared hosting or do you have your own dedicated web server?
Re: Javascript With NodeJS by GoodBoi1(m): 2:42pm On May 03, 2015
Febup:


Node.JS as I understand it works like a web server which you code with JavaScript. PHP on the other have runs on an apache web server, I don't need to need to code you apache web server before you can use PHP on it.

Will your production environment be on a shared hosting or do you have your own dedicated web server?
Shared hosting

(1) (2) (3) (4) (5) (6) (7) (Reply)

Which Is The Best Place To Learn Programming In Nigeria? / Front-End Developer Or Back-End Developer: Which Job Title Has A Higher Salary? / I Want My Son To Be A Programmer, How Do I Go About It

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 72
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.