Tag Info

Hot answers tagged

73

Ruby and Python both have benevolent dictators at their helm. They are languages deeply rooted in pragmatic concerns. Those are probably the most significant factors inhibiting fragmentation. Lisp and ML, on the other hand, are more like "design by committee" languages, conceived in academia, for theoretical purposes. Lisp was originally designed by ...


55

The problem is that because in theory any object can be a null and toss an exception when you attempt to use it, your object-oriented code is basically a collection of unexploded bombs. You're right that graceful error handling can be functionally identical to null-checking if statements. But what happens when something you convinced yourself couldn't ...


50

Because the math works. FALSE OR TRUE is TRUE, because 0 | 1 is 1. ... insert many other examples here. Traditionally, C programs have conditions like if (someFunctionReturningANumber()) rather than if (someFunctionReturningANumber() != 0) because the concept of zero being equivalent to false is well-understood.


46

I definitely think that functional programming languages will catch on, so my language will be functional. See Taming Effects with Functional Programming I think the CPUs soon will have hundreads of cores, and threads will he a hell to manage. So the Actor Model is a must instead of threads. See Erlang - software for a concurrent world I also think that OOP ...


43

Ditto @paxdiablo. The early programming languages were written by mathematicians--actually all of them were. In mathematics, by her own principle--reading left to right-- it makes sense in the way it works. x = 2y - 4. In mathematics, you would say this: Let x be equal to 2y -4. Also, even in algebra you do this. When you solve an equation for a variable, ...


42

It is very useful in every scenario where one part of class is generated by some custom tool because it allows you to adding custom logic to generated code without inheriting the generated class. Btw. there are also partial methods for the same reason. It is not only about UI but also other technologies like Linq-To-Sql or Entity Framework use this quite ...


36

Pass by value is often safer than pass by reference, because you cannot accidentally modify the parameters to your method/function. This makes using the language simpler to use, since you don't have to worry about the variables you give to a function. You know they won't be changed, and this is often what you expect. However, if you want to modify the ...


35

Languages have copied that from C, and for C, Dennis Ritchie explains that initially, in B (and perhaps early C), there was only one form "&" which depending on the context did a bitwise and or a logical one. Later, each function got its operator, & for the bitwise one and && for for logical one. Then he continues Their tardy ...


33

Yes, and yes. Yes there's such a language, and yes, many people find it more readable once they get used to it. In Objective-C, the method would be: - (NSArray*)getTop:(int)count customersOfTheYear:(Year)year; That's actually a pretty contrived example that doesn't read very well, so here's a better one from actual code: + (UIColor ...


32

Yes, the designers of C# (and, I'm sure, Java) specifically decided against deterministic finalization. I asked Anders Hejlsberg about this multiple times circa 1999-2002. First, the idea of different semantics for an object based on whether its stack- or heap-based is certainly counter to the unifying design goal of both languages, which was to relieve ...


31

It could be useful to have sometimes, no doubt. Several points argue against such an operator: The characters - and > are valuable, both in isolation and combined. Many languages already use them to mean other things. (And many can't use unicode character sets for their syntax.) Implication is very counter-intuitive, even to logic-minded people such as ...


31

Exceptions were invented to help make error handling easier with less code clutter. You should use them in cases when they make error handling easier with less code clutter. This "exceptions only for exceptional circumstances" business stems from a time when exception handling was deemed an unacceptable performance hit. That's no longer the case in the ...


31

Concurrency Java was defined from the start with considerations of concurrency. As often been mentioned shared mutables are problematic. One thing can change another behind the back of another thread without that thread being aware of it. There are a host of multithreaded C++ bugs that have croped up because of a shared string - where one module thought it ...


31

As others have said, the math came first. This is why 0 is false and 1 is true. Which math are we talking about? Boolean algebras which date from the mid 1800s, long before digital computers came along. You could also say that the convention came out of propositional logic, which even older than boolean algebras. This is the formalization of a lot of the ...


30

The fundamental problem with "void" is that it does not mean the same thing as any other return type. "void" means "if this method returns then it returns no value at all." Not null; null is a value. It returns no value whatsoever. This really messes up the type system. A type system is essentially a system for making logical deductions about what ...


29

When executing your code, the Java runtime does the following: Cast null to an object of class Integer. Try to unbox the Integer object to an int by calling the method intValue() Calling a method on a null object throws a NullPointerException. In other words, null can be cast to Integer without a problem, but a null integer object cannot be converted to ...


29

0 is false because they’re both zero elements in common rings. Even though they are distinct data types, it makes intuitive sense to convert between them because they share the same algebraic structure: 0 is the identity for addition and zero for multiplication. false is the identity for Boolean OR and zero for Boolean AND. You can think of OR as addition ...


28

null is evil There is a presentation on InfoQ on this topic: Null References: The Billion Dollar Mistake by Tony Hoare Option type The alternative from functional programming is using an Option type, that can contain SOME value or NONE. A good article The “Option” Pattern that discuss the Option type and provide an implementation of it for Java. I have ...


28

When should an exception be thrown? On the high level for some people the answer is clear and for some it is more a philosophical question. For many it is something in between and a question of judgment. However when it comes to code, I think that following explanation for the term exception is very helpful: An exception is when a member fails to complete ...


28

But it does. You can create local scopes anywhere by wrapping lines with {} switch (criterion.ChangeAction) { case BindingType.Inherited: { var action = (byte)ChangeAction.Inherit; return (x => x.Action == action); } case BindingType.ExplicitValue: { var action = (byte)ChangeAction.SetValue; return (x => ...


27

Lisp, Smalltalk. Coincidentally, those are also the best languages in the whole bunch. Both Lisp and Smalltalk are languages which are built around strong unifying metaphor. Lisp's metaphor is "everything is a list; this list represents both data and code (as functions)". Smalltalk's metaphor is "everything is an object; the only way to invoke a behaviour ...


27

An interface is a contract specifying what its implementer promises to be able to do. It does not need to specify state because state is an implementation detail and only serves to constrain implementers in how this contract is fulfilled. If you want to specify state you might want to rethink you use of interfaces and look at abstract base classes instead.


26

Is it "wrong"? In what sense could it possibly be wrong? Every programming language ever designed (except, I suppose, for the mythical Ur example) has borrowed concepts and designs from other languages. It's possible (and rather easy) to plot all extant languages on a family tree that shows their derivation. I can give you nearly endless examples of modern ...


26

One likely factor is simply age. Lisp and ML are a lot older than Python and Ruby: Lisp: 1958 ML: 1973 Python: 1991 Ruby: 1995 Lisp and ML have obviously seen much greater change in hardware capabilities, more trends in computer science, and a great many more Ph.D students looking for something to work on.


26

Call-by-value and call-by-reference are implementation techniques that were mistaken for parameter-passing modes a long time ago. In the beginning, there was FORTRAN. FORTRAN only had call-by-reference, since subroutines had to be able to modify their parameters, and computing cycles were too expensive to allow multiple parameter-passing modes, plus not ...


25

In Makefiles, it's annoying. In python, I find it very apropos and it makes the syntax a lot cleaner. I think the thing that makes it better in python is that no special characters are required, the only requirement is that you be consistent. You should be doing it anyway, so you get no cost added by following it.


25

In terms of language design, there isn't really anything that should make Go slower than Java in general. In fact, it gives you more control of the memory layout of your data structures, so for a lot of common tasks it should be somewhat faster. However, the current primary Go compiler, scheduler, garbage collector, regexp library, and a lot of other things ...


25

I always think of things like accessing the database server or a web API when thinking of exceptions. You expect the server/web API to work, but in an exceptional case it might not (server is down). A web request might be quick usually, but in exceptional circumstances (high load) it might time out. This is something out of your control. You users' input ...


23

I'd say the number 1 thing is a poor library. Most experienced programmers are capable of reinventing the wheel but are really loathe to do so. As soon as I see a language and think "I can do that in half the code in [favorite high-level language]", I know I'll never give it a real shot. Even worse if I can replace the chunk of code from the new language ...


23

The problem is that recursive comments force you to actually parse the comments section, pushing it outside the scope of a normal lexer and possibly introducing more problems. As a refresher: A compiler usually has a number of distinct stages with different jobs, and the first stages are the lexer, which gets the input program and separates it into a ...



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