language-features

Accessing internal property out of the assembly scope.

I have class with internal property: internal virtual StateEnum EnrolmentState { get { ..getter logic } set { ..setter logic } } However I want to be able to access to this property outside of the assembly so I created method that simply returns this property: public StateEnum GetCurrentState() { return EnrolmentState; ...

Python 3.0 - dict methods return views - why?

dict methods dict.keys(), dict.items() and dict.values() return “views” instead of lists. http://docs.python.org/dev/3.0/whatsnew//3.0.html First of all how is a view different from an iterator? Secondly, what is the benefit of this change? Is it just for performance reasons? It doesn't seem intuitive to me, i.e., I'm ask...

Should Microsoft avoid implementing a feature in .Net just because internationalising it is too difficult?

I raised a request over at Microsoft Connect regarding the formatting of dates ("DateTime Formatting should caluclate the correct suffix for the day"). Basically I wanted to have a formatting string code for adding the suffix to the day number. So "1 Jan" would be formatted "1st Jan" and "2 Jan" formatted "2nd Jan" etc. This is quite ea...

Which are your favorite programming language gadgets?

There are some gadgets/features for programming languages that I like a lot because they save a lot of coding or simply because they are magical or nice. Some of my favorites are: C++ increment/decrement operator: my_array[++c]; C++ assign and sum or substract (...): a += b C# yield return: yield return 1; C# foreach: foreach (MyClass...

Should inheritance (of non-interface types) be removed from programming languages?

This is quite a controversial topic, and before you say "no", is it really, really needed? I have been programming for about 10 years, and I can't honestly say that I can recall a time where inheritance solved a problem that couldn't be solved another way. On the other hand I can recall many times when I used inheritance, because I...

Is there a Python equivalent to `perl -pi -e`?

I know of python -c '<code>', but I'm wondering if there's a more elegant python equivalent to perl -pi -e '<code>'. I still use it quite a bit for things like find and replace in a whole directory (perl -pi -e s/foo/bar/g * or even find . | xargs perl -pi -e s/foo/bar/g for sub-directories). I actually feel that that which makes Perl ...

JavaScript Hashmap Equivalent

As made clear in update 3 on this answer, this notation: var hash = {}; hash[X] does not actually hash the object X; it actually just converts X to a string (via .toString() if it's an object, or some other built-in conversions for various primitive types) and then looks that string up, without hashing it, in "hash". Object equality i...

Why would one want to use ruby over python or vice versa?

I wanted to know, while deciding which language or technology to use for implementing an idea; a design, what are the factors involved in making a decision? Specifically talking about popular scripting languages, why would one choose to use ruby over python or perl or vice-versa? All these scripting languages have proved their worth, so ...

What is the tilde (~) in a C# enumeration?

I'm always surprised that even after using C# for all this time now, I still manage to find things I didn't know about... I've tried searching the internet for this, but using the "~" in a search isn't working for me so well and I didn't find anything on MSDN either (not to say it isn't there) I saw this snippet of code recently, what ...

Which Language I should use for real time application

I am going to develop real time application which will receive stock market data and doing some processing then disseminates to client application. I decided to divide the calculations between the server and client the server will make the basic calculations then will send the basic data to the client which calculates the final variables...

Ruby: More flexibility than Java/C#?

Is is that I'm a newbie learning Ruby, or does it really have more ways to write (the same) things than Java/C#? Also, if it is more flexible than Java, are there any linguistic features of Ruby that are generally not used to avoid confusion? Examples might be parallel assignment and all the different ways to write Strings, perhaps? No...

What is the VB.Net Code Equivelant for c# Anonymous Type code?

Can someone tell me what the code equivelant in VB.Net to this C# code is? new {name="value"} ...

What does the 'static' keyword do in Java?

To be specific, I was trying this code: package hello; public class Hello { Clock clock = new Clock(); public static void main(String args[]) { clock.sayTime(); } } But it gave an error like 'Cannot access non-static field in static method main'. So I changed the declaration of clock to this: static Clock clock ...

What is the purpose of long, double, byte, char in Java?

So I'm learning java, and I have a question. It seems that the types int, boolean and string will be good for just about everything I'll ever need in terms of variables, except perhaps float could be used when decimal numbers are needed in a number. My question is, are the other types such as long, double, byte, char etc ever used in no...

What programming language features do you like?

I want to make up a program language and write some code for it. Maybe I can use ANTLR for syntax checking. What I want to know is what features of a programming language you like? I'll start with a few: Python's use of variables. Python lists and dictionaries Python strings Python's multiple return values templates reference operator ...

Should Java break backwards compatibility in future versions for the benefit of a cleaner language?

Are primitives worth keeping? Should all the deprecated stuff be deleted? Do we need 2 GUI frameworks? ... ...

Feature differentiation: Rails / Django

Are there any important features in Rails or Django which do not exist in the other framework? Is there anything important missing - for an enterprise web app - in either one? This question is not intended to be argumentative - I am trying to make an informed technology decison for an upcoming project. Two of the concerns I ha...

VB.net equivilant of C# Property Shorthand?

Is there a VB.net equivalent to the C#: public string FirstName { get; set; } I know you can do Public Property name() As String Get Return _name.ToString End Get Set(ByVal value As String) _name = value End Set End Property But I can't seem to google up an answer on a vb shorthand. ...

What are you looking forward to in Java 7?

Java SE 7 is the next major release for Java SE. The details are sketchy, same goes for timelines, although Alex Miller has a nice round-up, and generally a good place to start. Also, here is a summary of Java 7 update by Mark Reinhold, cheif engineer for Java SE. So, what major features scheduled for release are you looking forward t...

Why is there a `null` value in JavaScript?

In JavaScript, there are two values which basically say 'I don't exist' - undefined and null. A property to which a programmer has not assigned anything will be undefined, but in order for a property to become null, null must be explicitly assigned to it. I once thought that there was a need for null because undefined is a primitive va...