Artificial languages for instructing computers to do steps of computation in order to complete tasks. They allow programmers to communicate with computers.
4
votes
1answer
70 views
The bound mechanism by generics for a type variable to appear in its own bound
From Programming Languages: Principles and Paradigms
By Maurizio Gabbrielli, Simone Martini
The bound mechanism for type variables is fairly sophisticated and
flexible. In particular, a type ...
5
votes
2answers
105 views
What is the programming language concept for not evaluating an expression by default in bash?
In Bash, to increase an integer value stored in a variable, we need to explicitly use arithmetic expansion.
i=1
i=$((i+1))
Otherwise
i=1
i=i+1
will not evaluate the expression i+1, but assign ...
4
votes
4answers
283 views
Design Pattern for Indirectly Connecting Two Classes
Admittedly, this is a homework problem but I have tried to figure it out on my own. Just want to make sure I get it correct. So far, the only design pattern I believe to be correct would be the ...
31
votes
6answers
4k views
Why is SQL the only database query language? [duplicate]
For general-purpose programming there are literally hundreds of programming languages. But for interacting/querying the databases, why is SQL pretty much the only used language?
5
votes
2answers
373 views
How are generics implemented in a modern compiler?
What I mean here is how do we go from some template T add(T a, T b) ... into the generated code? I've thought of a few ways to achieve this, we store the generic function in an AST as Function_Node ...
40
votes
3answers
2k views
What is a type system?
Background
I am designing a language, as a side project. I have a working assembler, static analyser, and virtual machine for it. Since I can already compile and run non-trivial programs using the ...
0
votes
1answer
33 views
Two questions about Simula
I am looking over Simula language to see how it compares to C++/Smalltalk, and I have two questions that are difficult to find answers to because each time I type in Simula into Google, it gets ...
3
votes
3answers
248 views
How do programming languages work?
This is probably a dumb question, but how do programming languages work on a low level? If you go to the Go language GitHub page here, it says almost 90% of the source files are Go files. How is it ...
-2
votes
1answer
52 views
Rotate a matrix in place, moving elements? (How to write a part of flow/logic after understanding the problem?)
Following is a java solution of the classic question of rotating a nxn matrix in place clockwise by 90 degrees.
public void rotate(int[][] matrix, int n) {
for (int layer = 0; layer < n / 2; ++...
2
votes
1answer
152 views
Why is there such a fight for companies to produce new languages + frameworks
There's currently a huge growth in larger companies offering new languages and / or frameworks for us to use to create websites, apps or software and I'm interested to know for what reason do people ...
2
votes
2answers
158 views
Is a linked list considered a collection of objects?
Sedgewick's Algorithm 4ed says
Several fundamental data types involve collections of objects.
Specifically, the set of values is a collection of objects, and
the operations revolve around ...
61
votes
10answers
12k views
Syntax Design - Why use parentheses when no arguments are passed?
In many languages, the syntax function_name(arg1, arg2, ...) is used to call a function. When we want to call the function without any arguments, we must do function_name().
I find it odd that a ...
4
votes
2answers
220 views
Java Design Philosophy
I was reading through design philosophy of java and this line struck me:
"The VM checks whether the signature of the Java code is valid and would refuse to interpret if any change of the code is ...
1
vote
1answer
26 views
Relation and difference between recursively enumerable languages and Turing complete languages?
From https://en.wikipedia.org/wiki/Recursively_enumerable_language
a formal language is called recursively enumerable (also
recognizable, partially decidable, semidecidable, Turing-acceptable or
...
0
votes
2answers
194 views
Is there a need for thenif besides elseif?
For nested if constructs, some languages provide constructs similar to
if Bexp1 then C1
elseif Bexp2 then C2
...
elseif Bexpn then Cn
else Cn+1
endif
All I have seen provide elseif. I wonder ...
18
votes
6answers
5k views
What is the mathematics foundation for first/second/third class values in programming languages?
Added
Just found two related questions
http://math.stackexchange.com/q/1759680/1281
http://stackoverflow.com/a/2582804/156458
In programming languages, from Michael Scott's Programming Language ...
0
votes
3answers
67 views
Are commands for variable initialization ever used as expressions?
In C, the assignment command also returns the value assigned, so it is also an expression.
Similarly, initialization, which happens when defining a variable, also assigns a value to the newly created ...
1
vote
1answer
103 views
How does static scoping apply to recursive functions?
Under static scoping, by its definition, how can we determine the scope of a variable inside a recursive function?
For example, in a pseudo-language,
int i=1;
function myfun(){
if (i > 4){
...
0
votes
1answer
35 views
Relation between static and dynamic bindings and scopings?
From https://en.wikipedia.org/wiki/Name_binding
name binding is the association of entities (data and/or code) with
identifiers.[1] An identifier bound to an object is said to reference
that ...
0
votes
1answer
66 views
Differences between deep and shallow bindings for static scoping
I am self-learning Michael L. Scott's Programming Language Pragmatics. The following quote explains how deep binding and shallow binding are different in the presence of static scoping:
program ...
2
votes
1answer
71 views
Can dynamic typing and dynamic scoping lead to each other?
By definition, dynamic typing and dynamic scoping have different purposes. But some cases make me wonder if they can lead to each other sometimes.
Dynamic typing allows a name i.e. identifier to ...
22
votes
1answer
818 views
Why was the caret used for XOR instead of exponentiation?
Not that it's really a problem for anyone that has faced this syntactic issue before, but I see a wild amount of confusion stemming from the use of the caret (^) as the XOR operation in lieu of the ...
3
votes
0answers
84 views
Create in-browser IDE for own grammar
We are going to use our new own programming language. We have designed grammar, json parser and everything seems to work.
Code in my language is transpiled into javascript and interpreted by node.js ...
2
votes
2answers
146 views
How is a abstract syntax tree used to execute source code?
After researching how a parser generates an AST, I believe that I can know attempt to create one. Before I started on this project, I began to ponder what I should be done next after creating a AST ...
0
votes
2answers
141 views
How do I determine the visibility of “objects” as defined in the C programming language?
This question was asked by my professor in an exam and I couldn’t find an answer on Google, so here I am.
I don't understand what objects are in C at all.
-1
votes
1answer
92 views
Where does Firebase fit in?
I am a front-end developer who is familiar with HTML, CSS, JS and to a degree, AngularJS.
I've chanced upon Firebase (firebase.google.com) - and was wondering if I could, with my lack of knowledge ...
4
votes
4answers
204 views
Learning languages: high-level first, or low-level first? [closed]
Whenever I learn about a high-level language I want to learn about, part of me says, "I should probably learn the lower-level language it's built upon to really master it". For example,
Ruby => ...
1
vote
4answers
197 views
Why does string.find(“”) = 0? [closed]
I'm studying Python and hung up on a simple problem. Let's say we have:
string = "hello"
When we invoke the find method on the string to find an empty string like this:
string.find("")
Why does ...
0
votes
1answer
157 views
Two C program sharing same addresses
I was trying to understand structure padding , so i wrote a simple program as written below and i executed it .
just to make clear i made two copy of this program program1.c and program2.c and ...
1
vote
1answer
89 views
What is the best way to incorporate new language features into your code? [closed]
My main language is currently JavaScript, and I'd say I'm fairly proficient in it. That is, when I think "I want to do x", I don't (generally) Google "how to do x", but I think "I know! I will use ...
3
votes
1answer
1k views
Why is Lustre used for programming critical control software (Nuclear power plants etc)?
So, as stated on wikipedia:
Lustre is a formally defined, declarative, and synchronous dataflow
programming language for programming reactive systems. It began as a
research project in the ...
-1
votes
1answer
78 views
Why do we use 'assert not' in this example?
My code takes 2 dates and finds the age of those dates in days. In my daysBetweenDates method the instructor uses an assert statement:
assert not dateIsBefore(year2, month2, day2, year1, month1, day1)...
1
vote
2answers
91 views
Property of functions with same input => output independent of language or naming
Let's consider these four functions:
# Racket
(define (square x) (* x x))
(define (sqr a) (* a a))
# Javascript
function square(x) {
return x * x
}
function sqr(y) {
return y * y
}
All ...
0
votes
1answer
122 views
Commonalities between Programming languages [closed]
I've tried looking on google but can't get the answer I want to this. Is there a book or article or a video where various commonalities of different popular high level languages like Python, Java, C++ ...
-2
votes
1answer
199 views
What is an efficient way to implement 'Stack' without generics?
Today I was reading a lot of articles complaining about Java Generics or C++ Templates. Now, my question is: How can someone implement a collection data structure like Stack without using them?
4
votes
2answers
238 views
Runtime Inheritance
I recently came across the term "runtime inheritance" when reading this Wikipedia article. I tried to search for it and came across this article that tries to explain the difference between runtime ...
2
votes
3answers
210 views
Why do programming language authors choose not to implement UFloat?
I realized I haven't seen this type in Objective C or Swift. But we have UInt.
Is there some more Computer Science specific reason we do not have an Unsigned Float? Afaik it's not in c# too.
0
votes
1answer
156 views
What algorithm or program does Java use for arithmetic?
I was looking at bitwise ways to multiply and add numbers without using * or + operators. But I want to know that it might be possible that java may already be using a better approach underneath. I ...
1
vote
2answers
110 views
Different Number Base Systems
I am doing a summer assignment for AP Computer Science. For this I am learning about different number base systems and how to convert them. These topics led to me wondering about why programmers use ...
0
votes
3answers
104 views
Compiling methods in interpreted programming language as standalone c++ app
I'm writing an interpreted implementation of a new programming language (just for fun). In this implementation language is first being compiled to an intermediate language, which is then interpreted ...
8
votes
6answers
754 views
How is static typing really helpful in bigger projects?
While curiosing on the main page of a scripting programming language's site, I encountered this passage:
When a system gets too big to keep in your head, you can add static types.
This made me ...
1
vote
1answer
72 views
What is the connection between type inference and advanced type systems?
I don't understand the connection between type inference and advanced type systems. I don't see why Haskell or Standard ML or OCaml could not have existed without type inference. My only guess is that ...
1
vote
4answers
425 views
Why does C++ have auto, rather than simply doing the right thing when there are no explicit type declarations?
When auto was considered for addition to the C++ standard, was there any discussion of setting implicit types where there are no explicit declarations? And if so, was the discussion recorded anywhere?...
0
votes
4answers
407 views
Machine learning without programming?
I am old to programming and very beginner to Machine Learning and what make me surprise is the defination as i typed in google i found this.
Machine learning is a type of artificial intelligence (...
0
votes
1answer
91 views
Understanding streams
I have started learning streaming APIs and I found one of the good documentations here. There was a comparison given by author to demonstrate the effectiveness of the streams.
var http = require('...
3
votes
1answer
116 views
Adding behaviour to a part of a third party class
I am working with an effectively third-party library. This library has a base class that's used as the interface (C++ style), ComponentBase. ComponentBase has a number of methods and setters that are ...
-1
votes
1answer
107 views
What are the most reductionist/minimalist programming languages [closed]
By a reductionist or minimalist programming language I mean a language that tries to be as simple as possible, as long as it is still Turing complete. I would like a programming language so ...
3
votes
3answers
453 views
How Does An Interpreter Work? [closed]
I've been searching for tons of websites for how an interpreter works, but I found none of these explain how Interpreter works internally. But I found in many places how compiler works with all the ...
16
votes
6answers
4k views
A language based on limiting amount of arguments passed to functions
The idea is inspired by the fact operators such as +, -,%, etc. can be seen as functions with either one or two arguments passed, and no side-effects. Assuming I, or someone else, writes a language ...
53
votes
8answers
8k views
Are events only used for GUI programming?
Are events only used for GUI programming?
How do you handle in normal backend programming when something happens to this other thing?