language-features

Suggest Language for my project

Hi, I am working on a project for which we have to decide for a language to work on. Requirements are as follows: Client should work both as web browser based and standalone desktop application.Both will have same feature. Gui should be rich in graphics but still light weighted.It should not use much memory for rendering views. Clie...

Generic methods and method overloading

Method overloading allows us to define many methods with the same name but with a different set of parameters ( thus with the same name but different signature ). Are the two methods overloaded? class A { public static void MyMethod<T>(T myVal) { } public static void MyMethod(int myVal) { } } thank you EDIT: Shouldn't sta...

var: a Type or a keyword

MSDN categorizes var under Types. variables that are declared at method scope can have an implicit type var what does 'implicit type var' mean in this context? Strictly said, if I have it to explain to fellow programmers. Can I say; var is a Type, or do I have to say; var is a keyword that instructs the compiler to determine t...

Problem understanding C# type inference as described in the language specification

The C# language specification describes type inference in Section §7.5.2. There is a detail in it that I don’t understand. Consider the following case: // declaration void Method<T>(T obj, Func<string, T> func); // call Method("obj", s => (object) s); Both the Microsoft and Mono C# compilers correctly infer T = object, but my underst...

What are some highly-regarded books on (modern or historic) programming language design?

I greatly enjoyed Douglas Crockford's recent lecture series, particularly the talk which covered the history of programming languages. I'd like to learn about this subject in more detail. Consider this question language agnostic. I'm not interested in books that teach programming. I'm interested in books which discuss decisions made dur...

C#: Property overriding by specifying the interface explicitly

While attempting to override the explicit interface implementation of the ICollection<T>.IsReadOnly property from the Collection<T> class, I came across some documents stating that explicit interface member implementations cannot be overridden because they cannot have modifiers such as virtual or abstract. On MSDN they even go as far as ...

Package accessibility for function and/or class

In Java they have package access specifier which enables the function to be used only by classes from this same "package" (namespace) and I see good things about it. Especially when design of models are in play. Do you think that something like this could be useful in C++? Thanks. ...

Is Java *really* less complex than Scala?

I frequently hear claims that Scala is much more "complex" than Java. Can anyone therefore provide an example of Java code that can't be improved by writing it in Scala, or Scala code that can be improved by writing it in Java (but not by just rewriting within Scala) By "improve", I mean that the code is better with regards to one (or ...

Why static Structures are not allowed in C#?

I always used to consider structures as some sort of lesser privileged things, or something with lesser features. Maybe because of the OOP concepts blowing everything into Classes. From the little amount of exposure to C#, I understand that Setting a class static, ensures that all its members & functions are static. Also we cannot have...

Question regarding implicit conversions in the C# language specification

Section 6.1 Implicit conversions defines an identity conversion thusly: An identity conversion converts from any type to the same type. This conversion exists such that an entity that already has a required type can be said to be convertible to that type. Now, what is the purpose of sentences such as these? (In §6.1.6 Implicit ...

Real number arithmetic in a general purpose language?

As (hopefully) most of you know, floating point arithmetic is different from real number arithmetic. It's for starters imprecise. Many numbers, especially decimals (0.1, 0.3) cannot be represented, leading to problems like this. A more thorough list can be found here. Are there any general purpose languages that have built-in support fo...

Why do we need this special === operator ?

I've used C++ and Java before and they don't have this === operator. How come they manage without it but in languages like PHP its key. ...

Programing language concise and systematic description

Can you describe in few sentences or bullets program language you know best? It should be concise, not too long, lets say for one or two slides in presentation, but that contains important classifications of that language. Some details about usage and spread, supported platforms and available libraries. Some strengths and weaknesses. Mos...

What do the * and & operators operate on if the argument is complex?

Simply, is &someObject->someAttribute.someMember; equivalent to &(someObject->someAttribute.someMember); or (&someObject)->someAttribute.someMember; or (&(someObject->someAttribute)).someMember; Or should you really put explicit parenthesis there just to be safe? ...

Why has C# steered clear of this pattern? And how would you implement it instead?

SHORT FORM(!) In response the Jon Skeet's comment, what I want C# to be to do is to allow a generic, at compile time, to expand out and derive from one of it's generic parameters (as Kirk Woll demonstrates): public class Generic<TBase> : TBase { } This class, of course, would not be able to override any members of TBase (unless perh...

What's the best language for physics modeling?

I've been out of the modeling biz, so to speak, for a while now. When I was in college, most of the models I worked with were written in FORTRAN, which I never liked. I'm looking to get back into science, so I'm wondering if there are modern languages with feature sets suited for this kind of application. What would you consider to be an...

Is it bad practice to use C features in C++?

For example printf instead of cout, scanf instead of cin, using #define macros, etc? ...

Default method return value in Java

While working with annotations I stumbled accross the following piece of code (it's the Hibernate @NotNull annotation): @Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) @Retention(value = RetentionPolicy.RUNTIME) @Documented @Constraint(validatedBy = {}...

F# shorthand to call method on object in lambda

I think this is somewhat related to this question, but being not sure and since there's no real answer there, here I go: in Scala there's you can write code such as: aStringArray.map(_.toUpperCase()) which is shorthand for: aStringArray.map(s => s.toUpperCase()) Is there anything like this in F# or a way to implement it (without the...

equivalent of Python's "with" in Ruby

In Python, the with statement is used to make sure that clean-up code always gets called, regardless of exceptions being thrown or function calls returning. For example: with open("temp.txt", "w") as f: f.write("hi") raise ValueError("spitespite") Here, the file is closed, even though an exception was raised. A better explanat...