79

The problem isn't null itself. It's the implicit nullability of all object references, as is the case in Java, Python, Ruby (and previously C#, although that picture is changing). If you have a language where every type T really means T | Null. Suppose you had a system that takes such a nullable reference at its entry point, does some null checking, and ...


68

Can you give an example of things you can do with C++ but not with python. Sure. For instance, C++ gives you control over where objects are placed in memory. The programmer decides whether an object is stored on the stack or the heap - and can even control where on the heap by using a custom allocator. This can be helpful when exploiting memory locality ...


51

It is clear that C++ is much more efficient and that the C++ code compiles directly to machine code whereas in Python it is interpreted. This is wrong. C++ and Python are programming languages. A programming language is an abstract set of mathematical rules and restrictions. It is neither compiled nor interpreted. It just is. Any language can be implemented ...


29

As a very high-level overview, the IDE contains a compiler. (Well, most parts of a compiler: it doesn't need to generate code or optimize, but all the rest is there, lexing, parsing, semantic analysis, type inference, type checking, macro expansion, symbol resolution, etc.) From the information gleaned from this analysis, the IDE constructs a semantic model ...


17

The IDE understands the code. It is able to parse it and extract all the necessary information for autocomplete, like what classes are available, their names and all their members. The IDE team most probably had to implement this parsing themselves, or use private APIs in the compiler. And compilers do the same thing as their main function. The compiler ...


14

Exact syntax matters less than you might think. In an interview, you can say something like: I don't remember in this language if a set.add returns a boolean indicating if the item was already in the set or not. It doesn't really matter for this problem because it's easily looked up, but assuming it does return that indication, this is how I would write it.....


14

I'm not a logician, type theoretician, or programming language theorist, so my intuition may be wrong here, but I don't think it actually takes that much to be able to do this. People have twisted Java's type system into quite some amazing shapes, for example. I would not at all be surprised to find out that what you want can be encoded in Java or similar ...


8

Great question, many developers wouldn't even think or care about! keep thinking and asking! You are probably looking for optionals. Here, for example, in TypeScript that you use: http://dotnetpattern.com/typescript-optional-parameters The idea is to have explicitly state: A) if an object can be null or not B) unwrapping nullable objects before using them ...


8

What are programming languages written in? Programming language compilers and runtimes are written in programming languages — not necessarily languages that are older or are different than the one they take as input.  Some of the runtime code will drop into assembly to access certain hardware instructions or code sequences not easily obtained through the ...


8

Language comparisons are always source of heated discussion and painful confusions. Giving "more control" does not mean anything by itself: Both languages have very similar control flows. Python being a dynamic language, it allows to change control at runtime and even trick the inheritance tree: is it more control because C++ doesn't allow it? Or ...


7

How does the IDE become context aware? Code completion and refactoring features are generally implemented by building an abstract syntax tree from the source code. The nodes of the AST represent things such as variables, operators and method calls. When you type foo., the IDE uses the AST to resolve the variable foo to the type Foo and then displays a list ...


7

JavaScript was originally used for tiny things. Often, your entire script would be inlined in your HTML onclick attribute. A large use of JavaScript would be two or three functions in the HTML header. I remember thinking why would anyone ever want to use the ability to put a script in a separate file. It makes zero sense to precompile something that small. ...


7

Think of it this way. Python is written in C, No, it is not. You seem to be confusing a Programming Language like Python or C with a Programming Language Implementation (e.g. a Compiler or Interpreter) like PyPy or Clang. A Programming Language is a set of semantic and syntactic rules and restrictions. It is just an idea. A piece of paper. It isn't "...


6

The best is to write the actual code in C or C++, and then to just create interfaces for any other languages so that for example a python developer can use the library in their python code without ever knowing the actual language. Writing the implementation in multiple languages is a waste of time. It increases the number of bugs. With cryptography it is ...


6

Each machine has an instruction set it natively executes. That instruction set is the first language. The first higher level language was assembly, literally allowing the programmer to write a long expression like mov ax bx instead of the corresponding binary word. The first compiler was written in machine language, though more accurately it would have been ...


6

I have seen only a few languages that implemented a NAND keyword. Remember that source-code is designed to be expressive of the logic that is needed to solve the problem at hand. It is entirely up to the [optimizing ...] compiler to decide what machine instructions to generate to correspond to what that source-code says. If the chip has a useful NAND ...


5

Most of the statically typed OOP languages are build on the concept of class and of interface to make polymorphism happen at runtime: Sometimes it’s not called "class" in the language, but it is nevertheless a class in the broader OOP sense (e.g. struct in C++ are classes; struct in C# are a like classes but with value semantic). Sometimes it’s ...


5

It’s trivial in most languages to compose a conditional jump from existing features, for example If (x > 0) goto y; So there is very little demand for a conditional jump statement, and therefore you don’t see it. Having a statement like Ifgoto (x > 0, y); Would seem unnecessary, confusing, and stupid.


5

You should never have a non-initialised object (with the single exception of a short interval of time while you are initialising the object). Null specifies the absence of an object. The problem is not null pointers. The problem is that in older languages 1. You cannot specify that a pointer cannot be null, 2. You cannot specify that a pointer can be null, ...


5

For all practical purposes, bytecode is just a data structure that is convenient for an interpreter to use. The interpreter looks at each instruction in the byte code and immediately performs that action. A simple interpreter for arithmetic expressions might look like this when written in Python: bytecode = [ {'type': 'const', 'value': 40}, {'type': '...


5

Using the keyword let to declare constants is not a general convention. The keyword let is used that way in Swift, Rust and Haskell, but in Javascript it denotes a regular variable (just one with a special scope). As for where the use of let to declare variables come from, it's a very old tradition for mathematical proofs: (Source, due to popular demand: ...


4

Regex is a language. It doesn't look like much of one, but it is. Like every language, it is not written in anything. A language is a set of mathematical rules and restrictions. If we can say that it is written in anything at all, we would probably say that it is written in English. (Or in a specific English-based jargon for specifying languages, enriched ...


4

The distinction which the linked source makes is unclear. In my view, the distinction it is making is between structured flow control statements, and unstructured flow control statements. A "conditional jump" is simply an if statement and the like. if is also a structured statement. Most structured languages don't expose an unstructured conditional jump ...


4

Binding is a more general concept than dispatch. "Binding" means "resolving an identifier to something", whereas "dispatch" specifically means "resolving an identifier to a subroutine", and is most often used when talking about method dispatch in OO, but also e.g. Haskell type classes or methods of Abstract Data Types. As was pointed out in the comments, "...


4

This is hard to answer in isolation. A lot depends on the overall design of your language and the goals you want to reach. To quote Bjarne Stroustrup quoting Dennis Ritchie: “There are two kinds of programming languages: The ones that want to solve a problem and the ones that want to prove a point.” Which of the two is yours? What problem do your future ...


4

There are many factors that contribute to null being a "Billion Dollar Mistake". Based on your comments, you're looking specifically at TypeScript and the type of possibly-uninitialized values, so I'll boil it down to two key problems: type safety, and value semantics. The key - a.k.a., tl;dr Especially in TypeScript, null-ish values are perfectly ...


4

Mostly it's not the language itself but the implementations. For embedded programming where the ultimate control is required, there is absolutely nothing that requires processors to have registers mapped to memory addresses, and C++ standard is pretty explicit that memory space does not need to be flat and while pointers can be converted to integers and back,...


4

NAND doesn’t match the mental image of logic that normal people including software developers have. A nand B doesn’t make sense to a normal person. It’s absolutely fine in an instruction set, but not in a programming language. And compilers have no problem at all converting “not (a and b)” or “not a or not b” into a nand. Where it gets really bad is when you ...


4

There are so many levels in between the source code of some program and the circuits on a chip. While some microarchitecture details definitely have a high-level performance impact, the ability to specify a NAND operation wouldn't be one of them. High-level programs have little connection to circuits on a chip First, our program must be converted to machine ...


Only top voted, non community-wiki answers of a minimum length are eligible