Questions tagged [programming-languages]
Artificial languages for instructing computers to do steps of computation in order to complete tasks. They allow programmers to communicate with computers.
1,405 questions
12
votes
7
answers
4k
views
Immutability across programming languages
I'm quite confused about the concept of mutability (or mutation?), especially across different languages. In a language like Python:
x = 10
x = 20
I believe this is called shadowing (or rebinding) ...
35
votes
10
answers
12k
views
Why don't programming languages or IDEs support attaching descriptive metadata to variables?
As developers, we often face the challenge of balancing meaningful variable names with code readability. Long, descriptive names can make code harder to read, while short names may lack context. For ...
0
votes
3
answers
290
views
Number of lines of code executed per line of code: Are there significant differences per language? [closed]
Having fewer lines of code per feature is typically better as it increases the developer productivity. Did anyone ever measure the number of code lines executions per line of code across multiple ...
3
votes
5
answers
840
views
How are strings simultaneously objects and primitive data types in C#?
In C#, strings can be used like objects with methods, properties, and other features of objects. At the same time, strings are treated the same as primitive data types like int or float in numerous ...
-3
votes
1
answer
143
views
Learn a framework on a project, or mix languages between backend services [closed]
I am designing my next project, which will do various domain-specific tasks, but all that will be controlled and used via a generic crud web app.
I have been professionally using Java with Spring for ...
1
vote
1
answer
490
views
Tagged pointers vs. fat pointers
I'm writing my own dynamic programming language. So far I've been using a tagged union for all values. Since this boxes primitive types needlessly, I've begun researching tagged pointers which seem to ...
0
votes
1
answer
384
views
How do function inlining and Tail Call Optimization affect call stack?
I've just accidentally came across this answer about inlined functions and I'd like to know how this affects call stack. But I can't add comments because I don't have enough rep so I decided to ask ...
0
votes
1
answer
155
views
Bytecode format and loading in language VMs
I am thinking about how to build a language VM. I have been able to get some of the basic constructs right, including jumps to functions within the chunk of bytecode that is currently loaded.
But now ...
4
votes
1
answer
331
views
What is the problem with whitespace in C that Ruby allegedly repeated?
I'm reading the book The Secret Life of Programs by Jonathan E. Steinhart. In it, he mentions in passing:
many consider the handling of whitespace in Ruby to be a replay of of a mistake in the ...
0
votes
2
answers
282
views
Advantage of implicit/explicit declaration of global symbols (like functions)
In C and C++ we need to declare a function before its usage, if its definition comes after where it is called. (Well, there is also the "implicit declaration" rule in C, but it is rarely ...
4
votes
3
answers
751
views
Is there a programming language other than Java, C#, and Go which includes null with its static object types?
I was reading the excellent book by Axel Raushmayer, Tackling TypeScript.
In this section of Chapter 7, the author makes the interesting claim
In many programming languages, null is part of all ...
0
votes
2
answers
532
views
Is there a language agnostic interface for programming language interop?
There are many packages for creating bindings of a library that's written in one language to be called from another language. Some programming languages also include such interop in the standard ...
1
vote
1
answer
556
views
Languages with PHP-like traits?
PHP have what it calls "traits" which despite the name is not like traits in Rust, Scala or other languages.
In many other languages with support for traits, a trait create a is-a relation. ...
0
votes
5
answers
633
views
Why don't languages auto import everything?
Why is there a such thing as import in programming languages? If a package does not exist, then trying to import it would cause an error anyway. So why don't languages just auto import ALL available ...
-1
votes
1
answer
145
views
Is it a good idea to let keywords have different lexical rules from names of types, variables, functions, etc? [closed]
For example, keywords have a special prefix. Objective-C has @interface, @implementation, but that's for compatibility with C. It inherits all the C keywords of course, with no @.
How about a language ...
0
votes
1
answer
229
views
Is it true that variable type before name makes compiler work easier? [closed]
I have seen information that at least one of reasons why type placed before variable name is that it allows compiler easier evaluate size and type of variable. If so then how (what way) it eases this ...
1
vote
5
answers
1k
views
Why do many programming languages lack standard vector types?
Many languages such as C or even C++ or C# or Java have no natively supported vector (SIMD) types or functionality. In such languages, one would have to either use non-standard extensions or third-...
0
votes
1
answer
234
views
How to decide when to increase the minimum supported C++ standard version?
I'm maintaining a library written in C++, which offers modern-C++ bindings for another API that's C-ish (it's this one, although I'm trying to make this question somewhat more general).
Now, when I ...
0
votes
1
answer
141
views
Are indirect implicit type declerations dangerous?
In the case of kotlin, rust and many other programming languages...
There are variables with direct implicit type declarations...
Where you can see the type of a variable at the same line where it's ...
0
votes
1
answer
576
views
How is it possible to store the AST nodes location in the source code?
I created a simple parser in Rust and defined the AST like this:
enum Expression {
Number(i32),
BinaryOperator(Box<Expression>, Operator, Box<Expression>),
Identifier(String),
}...
3
votes
1
answer
296
views
Do the maintainers of JavaScript remove features?
Really dumb question. I really like the new feature called "optional chaining" in JavaScript, and it's used in quite a few places in my front end code. However, I am concerned that whoever ...
0
votes
0
answers
543
views
Haskell where clause: is it more than just a matter of taste?
The traditional (Scheme, Pascal) way to structure code is this:
declare outer function
declare inner function
body of inner function
body of outer function
The where clause in Haskell moves ...
0
votes
2
answers
86
views
I've a doubt regarding Environment Model of execution
I came across Environment Diagrams,it is described below
Whenever Python needs to work with an object, that object is stored in
memory; and, additionally, Python also needs a way to associate names
...
2
votes
2
answers
447
views
Can access modifiers be completely replaced with programming to interfaces?
If we program to interfaces various parts of the implementation can be effectively hidden. We can define multiple interfaces for a single implementation and use them as needed, instead of 4 fixed ...
8
votes
5
answers
10k
views
Is code written inline faster than using function calls?
I wrote some script in Python that creates a giant 2D matrix (1000x1000 or bigger) and fills it with random numbers. And after that, it goes through every element of the matrix and changes the number ...
13
votes
8
answers
6k
views
How do compilers work in a language that doesn't allow recursion?
I'm recently learning the programming language, and I wonder how compilers work when the language itself does not allow recursion, like how the compiler or the runtime checkers makes sure that there ...
-3
votes
1
answer
224
views
Managing a project with an unfamilar programming language
Is there any common wisdom for managing a software project in an unfamiliar programming language?
Most software projects go for safety and use some mainstream language
but some opt for a niche ...
-2
votes
4
answers
244
views
Block structured iteration and recursion
Programming languages traditionally have blocks that specifically cater to controlling iteration.
There is the simple while-loop:
while (i < 3) {...};
Then there is the more complicated for-loop:
...
4
votes
2
answers
2k
views
Multidimensional vs nested arrays
A seemingly basic question here.
Is there anything you can do with multidimensional arrays that you can't do with nested arrays?
Many languages have been designed with both facilities and syntactical ...
1
vote
4
answers
758
views
Could a language allow for persistent allocations without heap?
Is it possible in theory to have a programming language that allows for object lifetimes that exist beyond the current scope but without using heap?
As a little background, in embedded development it ...
1
vote
2
answers
280
views
What does "legacy signature" mean?
I see the term legacy signature a lot in the documentation of programming languages. For example in the php documentation :
Passing the separator after the array (i.e. using the legacy signature) ...
2
votes
3
answers
936
views
Why does HTML collapse whitespace?
I've been trying to better understand (at least at a high level) why the early versions of HTML were designed the way they were. Most of the decisions make sense; I can deduce (at least at a high ...
0
votes
0
answers
244
views
What is it about kdb/q that makes the grammar not suitable for ANTLR style parser generators?
I want to build a code analysis tool for personal use when programming in kdb/q.
In order to do this, I need to be able to parse q code into an AST. I have never written a parser before. ANTLR4 seems ...
1
vote
5
answers
1k
views
Do state machine based programs have a processing loop - or even exist?
Short Version
If we had an application based on a state machine - transitioning between states to run the application: is repetition, and in fact the entire state machine, based on the presence of an ...
4
votes
2
answers
388
views
Moderate discussion on choice of programming language
Assume you have a small set of suitable programming languages (e.g., Python, C++, Julia), a clearly defined task (development of software services in the context of computational sciences), and a team ...
0
votes
1
answer
258
views
Excessively verbose and cryptic comparisons in Java
I don't know if this is the right place to ask more of a "philosophical" question.
The more I code in Java, the more I have to bear with Comparable<T>. And the more I bear with this ...
-1
votes
2
answers
277
views
Why do most AST trees use classes instead of vectors
I've noticed that most AST tree implementations use classes for nodes instead of something like a vector. I want to ask, why do most people use classes? Are there issues to using vectors to make AST ...
1
vote
2
answers
912
views
Implementing libraries for a programming language
Many programming languages have an implementation language (mostly a system language like C) which is used to implement important parts of the core of the language. Besides the libraries are written ...
0
votes
2
answers
328
views
Do lexers have to go word by word or can they go line by line
So I'm trying to write a interpreter with a lexer. Currently, it adds a token line by line and does some more processing later on. But when I look at sources online, they all seem to go word by word ...
1
vote
2
answers
707
views
Is there a simple algorithm for generating unit tests given a function's code? [closed]
Given the abstract syntax tree (AST) of each line of a function's code, I am asked to generate code for that function's corresponding unit tests, similar to what Microsoft's IntelliTest tool does here:...
0
votes
3
answers
903
views
Is it possible to make a compiler for any dynamic/script/interpreter language
Logically, not based on how cost we will spend or how much we will hire programmers to do it.
Can we (Is it possible to) make a compiler for any dynamic/script/interpreter language, like Lua, Python, ...
2
votes
1
answer
175
views
Is there a language implemented as a neuron network?
Does there exist some language whose execution model is implemented as a neuron network, or maybe as some other type of a network/grid (e.g. network of finite automata)? That is, specifically, without ...
2
votes
1
answer
119
views
Hot reloading anonymous functions in a custom scripting language
I am implementing anonymous functions (lambdas) in a scripting language that supports hot reloading. The language currently supports passing user defined functions (pointers) to plugin functions which ...
8
votes
2
answers
2k
views
How does the GLL parsing algorithm work?
I'm very interested in the topic of parsers, especially in the topic of parser combinators like Superpower. The problem with them is that the grammars that they can work with are a bit limited. For ...
3
votes
4
answers
1k
views
Do all dynamically typed languages not support function overloading?
I have noticed that JavaScript and PHP and Python do not support function overloading.
Do all dynamically typed languages not support function overloading? If the answer is yes, then why is that?
-2
votes
1
answer
160
views
Is it a good idea to implement a software application in C# and then convert it to Python? [closed]
My project is about an automatic HTML documentation generator. The final product can't be in C# because of some organizational and legal constraints.
To my experience, Python is harder to debug than C#...
0
votes
2
answers
163
views
Technology choice reasoning
I am tasked with making a program that will roughly have the same steps as a program that a former has written. The program that I'm trying to imitate doesn't seem to be open for extension, otherwise ...
0
votes
1
answer
364
views
Benefits of using a tokenizer/lexer before parsing for recusive descent parser
I am trying to build a static program analyzer for a proprietary progamming language for a school project, and am currently trying to implement the parser from scratch.
I was wondering, what are the ...
13
votes
5
answers
3k
views
How can I simulate a "negative" type system?
In my experience, all languages I know have a sort of "positive" type system. What I mean by "positive type system" is that when you are writing the source code, you always specify ...
5
votes
5
answers
6k
views
Why don't languages like C have NAND operators?
I know that some languages like APL have a dedicated NAND operator, but I'm thinking about languages like C, C++, Java, Rust, Go, Swift, Kotlin, even instruction sets, etc. since these are the ...