Is there a reason to use Scheme over JavaScript? [closed] - javascript

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
As far as I know, JavaScript can be used to do everything that is possible in Scheme.
Every functional programming paradigm I've learnt in Scheme is doable in JavaScript.
I know that one may end up using JavaScript to write ungood code (ones with global variables, too many states and side effects) where as Scheme restricts one to write functional code.
But apart from that, is it really necessary to use Scheme anywhere over JavaScript?
For those of you who say JavaScript can be interpreted only on a browser kindly draw the same question to Python and Scheme.

Let me pose a similar question:
Is there a reason to use French over English? Anything that you can express in French you can express in English, so is it really necessary to use French over English? Kindly draw the same question to Russian, German, Spanish, or any other spoken language you choose.
No programming language is completely unique, anything you can do in one language can be done in a different language, some implementations might require a bit more creative thought but it can still be done.
Some reasons to use Scheme instead of JavaScript or Python:
You appreciate the simplistic and minimalist structure of the
language
Ease of implementation when compared to expressive power (lambda
expressions)
You are more familiar with Scheme
The client has existing code in Scheme
Specific implementations or algorithms might have a min/max calculation available to give exact benchmarks, but you would have to look at specific algorithms. In general there is no way to define one language as always better in all situations (or even 'never worse'), and trying to pigeon hole oneself into a single language is dangerous. In my opinion, open mindedness is one of the biggest strengths a programmer can have. Being able and willing to use different languages or techniques can be a powerful tool.
I personally suggest further reading by looking up Polyglot Programming. It isn't directly related to your question, but it is a mentality that speaks to the benefits of knowing and using a variety of languages.

Related

Why would I like to execute scripting language in JVM [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
I am not able to understand why and in what kind of scenario I would like to run scripting language inside JVM at server side. I mean we already have great libraries available in JAVA... why wouldn't I use use them to do stuff instead of running scripts in JVM?
Please help me understand this concept, Can someone please tell me one or two use cases where running scripting in JVM at server side will have advantages over using JAVA libraries.
The more general question here is "Why would I want to execute code in <some scripting language> in Java?", where Javascript is simply one example of such a language.
Quoting this article:
Some Java applications' requirements make integration with a scripting language necessary. For example, your users may need to write scripts that drive the application, extend it, or contain loops and other flow-control constructs. In such cases, it's sensible to support a scripting language interpreter that can read user scripts, then run them against your Java application's classes.
Basically: if you want to allow your users to customize your application in a way that requires the richness of a programming language.
Why Javascript specifically? That depends upon your application. There may be reasons to pick that (e.g. your target users already know Javascript), or not (e.g. Lua is more popular for scripting in the games industry).
One use i can think of is:
Javascript engine can be used to evaluate arithmetic expressions
which are in a String format.
example :: String expression = "2+4";
The below is the link to a example which uses java script engine to do this.
https://stackoverflow.com/a/3423360/4626402

Variable name length in C vs newer languages [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 6 years ago.
Improve this question
It seems to me that C programs should tend to have longer variable names, since the names will be destroyed by the compiler and won't make any difference to the performance or binary size of an optimized executable. I don't understand why in fact the opposite happens, in newer, interpreted languages where the name of the variable/method can actually affect performance, variables and methods routinely have much longer names compared to those in C. Is it just a product of the times, or is there a real reason behind this?
This is a pretty subjective question--it probably depends on who you ask. But if you ask me, the reason is that C is not Object-Oriented, and is an old language that has a lot of developers following old rules. There's no good reason not to use descriptive variable names in C--you're right, the compiler discards things like variable names anyway.
But the teachings of descriptive naming are still relatively new (relative to, say, the existence of C). So I think the reason that descriptive naming is more prevalent in modern languages is simply because the same group of people that tend to change and adapt to these new methodologies, also are more open to using newer languages.
But again, OOP is a very core reason as well. The Java Coding Conventions of old put a lot of focus on naming things clearly, and that has permeated the culture of Object Oriented Programming. You'll find that C++ projects often use longer, better names than C projects.
Short code should never be your goal. Even in languages like JavaScript, where the amount of bytes transferred can affect performance, use names that are descriptive (but not too verbose), and minify it later using the many available minification tools.
Computers have gotten so staggeringly powerful that shorter or longer variable names make very little to no difference. But poorly named variables and functions, in any language, can cost a whole lot more money and waste way more time than any perceived performance hit you might take from using a longer name. The extra nanosecond of processing costs nobody anything, but the 45 minutes it takes a senior developer to figure out what the code is even doing costs everybody something.

QML vs Javascript [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
What are the differences and similarities between QML and Javascript?
I am doing research on it, as I will probably give of a small presentation about QML soon. I have already looked at it on wikipedia, but I was hoping to get some answers from people with experience.
Note: I know some QML, I don't know any Javascript.
QML is a declarative language describing a tree of objects (in the QtQuick case a tree of visual items). The documentation has a fairly comprehensive documentation of the language. QML is used in the Qt framework only.
Javascript is an imperative language. Javascript is a very popular language used in many different places, for example embeddded in HTML sites or as part of node.js servers.
QML can actually include Javascript snippets, for example for bindings and signal handlers.
QML and Javascript serve very different purposes, so I don't see how to provide a list of similarities and differences.
Getting some downvotes there, my guess is that it is because you didn't research enough before coming here. And possibly because it doesn't sound like you are quite ready for a presentation on these languages.
But I'll see if I can at least point you in the right direction; QML is what is called a "markup language", not unlike XML, whereas Javascript is an "imperative language", like many others such as Python, C and Rust. More similar to Python, as it is also an "interpreted" language, whereas the others mentioned are "compiled" languages.
Hope it helps!

Should I use Lua? [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
I am going to work on my new project where client has demanded to use 'Lua' if possible, I have never used it before and by searching on it I found it is fast compare to javascript and getting popular nowadays.
As I am very confused I had never use it before so I want to know something
Is it really better(in terms of performance and use) then javascript?
Will I get enough resources(because I don't want to move over after starting development due to lack of resources or it becomes hard to me develop)?
Will it needed anything other than C compiler to run?
Please guys it is really important to know about such thing before starting. Any help will be appreciated.
I'm assuming you're writing a standalone application in C or C++, and you're looking for a language to enable people to extend that application by embedding another language. That's pretty much Lua's territory.
Lua's strong point is that it's very easy to embed in your (C) application. It compiles quickly, it's tiny, licensing is liberal and using C functions from Lua is relatively easy. Standard Lua has enough performance for most things you'd use a language like this for; if you need more raw speed you could look into LuaJIT, the JIT-compiler for Lua.
As for your questions:
LuaJIT will probably be pretty much as fast as you can get for a dynamic language. Lua is used in games (Sim City, Far Cry, World of Warcraft), where performance is very important.
If by 'resources' you mean documentation: sure. Lua is a very simple language, much simpler than JavaScript; the manual should help you get started with the language itself, the wiki is tasty for tips about the embedding process. This article has an example you can copy/paste.
Lua pretty much runs everywhere a C program will run. It doesn't even need an operating system, and it doesn't depend on anything at runtime if you bundle it correctly.
Embedding a full JavaScript environment in your application, and interfacing your application to the JS environment, can be a lot of work (even though Google's V8 engine has some functionality to help you; see here).

Are there any good design practices or standards for JavaScript development? [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 6 years ago.
Improve this question
When developing with object-oriented languages like Java or C#, it's not uncommon for developers to use design tools like UML to make class diagrams, create interfaces, define major components and interactions, outline an API, etc., before beginning the implementation.
I know for most small JavaScript applications, these software engineering principles may be overkill, but if you're developing a library (jQuery, YUI) or creating a large application (Gmail, Google Docs), it's a good idea to create a design and plan ahead before you start writing any code.
Are there any similar practices used in JavaScript development or web development in general?
Edit:
Just to clarify, I'm not interested in creating classes/interfaces or making UML for JavaScript. JavaScript is a different paradigm from the likes of Java/C# and therefore needs different design tools. I'm interested in knowing what those JavaScript design tools/practices are, if any.
Maybe this question better asks what I'd like to know: If a company like Google created a large web application and had several dozen team members create it, what processes, documents, and practices would such a team use to successfully create, collaborate, and solidify a design? What tools (e.g., UML, flow charts, scribbled notes on a piece of paper) would they use to work on and share the design of the application (without writing a single line of code)?
I'm a fan of the Google Javascript Style Guide:
https://google.github.io/styleguide/javascriptguide.xml
I think the answer depends largely on which libraries, if any, you are using client side.
Jquery code looks very different from Sencha or Sproutcore code, for example. In Sencha and Sproutcore, the framework provides you with a 'class' system for developing components, so these frameworks lend themselves to the canonical forms of design patterns.
Also note that javascript is very different then Java or C#. You can impose an interface type system on your code, but many would argue that you are killing the javascript dynamic-language awesomeness if you do.
That said, its always good to have a plan. If you can stay DRY by extending JS objects, then I think you should. And it always makes sense to put some high level design in place.

Categories

Resources