Why should I use let instead of const inside functions? [closed] - ecmascript-6

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 6 years ago.
Improve this question
I add linters for js (es6) in my project, and for new configurations I found that they prevent using const inside functions - only for module-level constants. And inside functions I should use let. But I can't find any ground for such rule. Why?
For jscs it's for example
disallowConstOutsideModuleScope: const should only be used in module scope (not inside functions/blocks)
I understand that I can configure and switch off that rule, I just wonder what for it was enabled ? What is the motivation for such checking?
P.S. I have link https://madhatted.com/2016/1/25/let-it-be with block "Constantly const"
There is another school of thought on when to use let and const I’ll need to address. This strategy suggests developers use const as much as possible. Any variable that is not re-assigned should be declared with const.
I think this usage is poor practice. It adds an extra distraction to the process of programming, and results in code difficult to understand and change.
But I can't find that arguments valuable

It's just a coding guideline. They follow this school of thinking. If you do not wish to use it, feel free to turn it off in your .jscsrc file. Main points are:
Aggressive use of const devalues the operator
Choosing const first really means choosing to think about every declaration. Will the next line of code change this assignment? How
will I use this variable?
There is no known performance difference between let and const.

Related

Is cloud functions a valid replacement/implementation of a distributed system? [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 2 years ago.
Improve this question
I want to process a list of data parallelly; processing of each element of the data won't affect other.
With for example google pub/sub + cloud functions, I could achieve something scalable and parallel, which looks like a distributed system.
I have little knowledge about distributed programming, and it seems that it takes a lot of time to master.
So I would like to know is this a replacement or a valid implementation of distributed system?
For the specific use case you're talking about - dividing work among function invocations to run in parallel - yes, it sounds like that would be adequate.
I would be very hesitant to call it a full "distributed system" (at least not without your very strict definition of what that really is). If you take wikipedeia's explanation of distributed computing, you might have a very basic system in place, but lack of a peer-to-peer direct messaging system probably makes it unsuitable for many of the listed applications you see on that page.
The bottom line I think you should really consider is if it satisfies the requirements of the problem at hand. Whether or not it's a "distributed system" is mostly irrelevant - either it works or it doesn't for that use case.

How to compile HTML [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 6 years ago.
Improve this question
Is it possible to compile HTML? It wouldn't be that hard since all tags could easily be replaced with bytes which would speed up the lexical analyzer since it wouldn't have to query as much from the stream. It would also make the webpage a lot smaller and easier to send to the client.
If it is not possible are there specific reasons as to why not?
Why do you need to compile HTML ? HTML response, when sent from server to client is already in the form of bitstrings. Moreover, Even if you are applying any custom transformation, How'll you assure that at the client-side, decoding is performed to obtain original response.
However, If you concern is response-compression to use network bandwidth effectively, then there are other means to do the same :-
Minify minified CSS, JS files. You can even aggregate all
application-level CSS, JS files into one big file and send it in one
go, to avoid unnecessary network calls.
Set content-encoding as gzip(But make sure to check "Accept" header
in the request)
Use cache for static files.
For more info., refer to https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html.
Hoping it may help you.
Why do you need compile your html templates??
It is possible compile a html template in string for later used in other sites. absolutely you can do this with javascript frameworks like angularjs..
this is a example
http://blog.timsommer.be/using-compile-to-compile-html-strings-in-angular/

Should variables be commented in VBA? [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
Since I have started programming in VBA I have used
this website as basically my bible. However I don't see any mention of whether or not to comment my variables.
After doing a fair bit of research online I have been able to find very little regarding the topic at all. So I though I would see about getting your guys opinion on whether or not commenting variables is worth it. Any feedback is appreciated.
I tend to comment my variables when I think their purpose might be confusing. Generally, I try to create descriptive variable names so that I can tell at first glance to what they refer. However, with some calculations, and in some circumstances, it's difficult to determine just from the variable name its intended function. In these cases, I'd throw in a comment.
I'd say overall, it should be left to the user's discretion. Do you think it's difficult to understand what it does? If so, comment it.

What is "overkill"? [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 9 years ago.
Improve this question
Programmers often wonder if the use of a certain library or programming style is overkill. They also often claim that this is the case (and they are often believed).
What does "overkill" mean in the context of programming?
"overkill" is typically used to mean deploying overly flexible and/or over-engineered solutions to solve what is ostensibly a simple and highly localized problem. The canonical example is FizzBuzz Enterprise Edition.
The term "Overkill" literarilly (if there was ever a literal use of it) refers to the action of killing something or someone, with more resources than necessary. Something like shooting a deer 50 times to make sure it dies.
In programming it applies for the same principle: making use of more resources than necessary or to find an overly complex solution to a simple problem.
Some simple examples are
for i=1 to 100
x[i]=2^z[i];
y=x;
end
Where copying the entire array x in every iteration step achieves the desired result but you could also copy it elementwise y[i]=x[i] saving you some 900 operations and is thus an overkill.
Using the OpenCV library to threshold an image is definetley possible but uses many more resources than strictly necessary and is an exagerated example of an overkill.

Which coding abbreviations is widely used and generally understood? [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
Sometimes it is difficult to invent short and accurate name for a method or variable that is clear on the first glance. Abbreviations are not recommended today. But, for instance, if we use
src and dest in function params, it is contextually clear what they mean
i often means index: for(int i=0; i<size; i++).
Are there any other abbreviations like these used in more than one language?
There are a lot of abbreviations that are common and generally understood ("args", "i18n", "HTTP", …).
I'm not sure if I get your question right, less that there is a good answer to it. A good abbreviation is short (dooh) and easily understood by the readers. So the choice of an abbreviation depends on audience; what is obvious for a particle physicist might seem far fetched for a finance analytic or a games developer.
Maybe, the misleading word is abbreviation. The choice of a good abbreviation is the same problem of naming things in general (which is known as one of the two hard things in computer science). Readability is more important than conciseness.
Conclusion: if you know your audience (and your problem domain of course), you should be able to find understandable (and not too long) namings.
[Update]
Robert Martin wrote a whole 14-page chapter on "Meaningful Names" in his book on Clean Code, which for me is a Must-Read for every serious developer.