language-features

Assigning const value to const error in php

<?php class Lala { const a = "a"; const b = a . "b"; } ?> Parse error: syntax error, unexpected '(', expecting ',' or ';' on line 4 What's the problem with it? ...

Languages and VMs: Features that are hard to optimize and why

I'm doing a survey of features in preparation for a research project. Name a mainstream language or language feature that is hard to optimize, and why the feature is or isn't worth the price paid, or instead, just debunk my theories below with anecdotal evidence. Before anyone flags this as subjective, I am asking for specific examples ...

Does this language feature already exist?

I'm currently developing a new language for programming in a continuous environment (compare it to electrical engineering), and I've got some ideas on a certain language construction. Let me explain the feature by explanation and then by definition: x = a U b; Where x is a variable and a and b are other variables (or static values). ...

What features are important in a programming language for young beginners?

I was talking with some of the mentors in a local robotics competition for 7th and 8th level kids. The robot was using PBASIC and the parallax Basic Stamp. One of the major issues was this was short term project that required building the robot, teaching them to program in PBASIC and having them program the robot. All in only 2 hours ...

Why can I access private/protected methods using Object#send in Ruby?

The class class A private def foo puts :foo end public def bar puts :bar end private def zim puts :zim end protected def dib puts :dib end end instance of A a = A.new test a.foo rescue puts :fail a.bar rescue puts :fail a.zim rescue puts :fail a.dib rescue puts :fail a.gaz rescue puts :f...

List of Lua derived VMs and Languages

Is there a compendium of virtual machines and languages derived or inspired by Lua? By derived, I mean usage beyond embedding and extending with modules. I'm wanting to research the Lua technology tree, and am looking for our combined knowledge of what already exists. Current List: Bright - A C-like Lua Derivative http://bluedino.ne...

Objective-C: how to prevent abstraction leaks

I gather that in Objective-C I must declare instance variables as part of the interface of my class even if these variables are implementation details and have private access. In "subjective" C, I can declare a variable in my .c file and it is not visible outside of that compilation unit. I can declare it in the corresponding .h file, a...

Is there a name for a language feature that allows assignment/creation?

This is a bit hard for me to articulate, but in PHP you can say something like: $myArray['someindex'] = "my string"; and if there is no index named that, it will create/assign the value, and if there IS an index, it will overwrite the existing value. Compare this to Javascript where today I had to do checks like so: if (!myObject[key...

What is the best way to attach static methods to classes rather than to instances of a class?

If I have a method for calculating the greatest common divisor of two integers as: public static int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); } What would be the best way to attach that to the System.Math class? Here are the three ways I have come up with: public static int GCD(this int a, int b) { return b == ...

What particular practices, designs, languages/features enable very easy to maintain code?

What particular practices, designs, languages/features enable very easy to maintain code? ...

Programming Language Suggestion App / Database

Is there an website anywhere that allows you to select required facets of a programming language and then suggests matching options for you to choose from? For example, say I wanted an object oriented language that was functional its would suggest F#, Python, etc. ...

What can you do with AppleScript?

Everything I know about AppleScript I taught myself and was wondering if I missed any cool features. I know you can make the computer talk to and control applications but is there anything else it can do or is it time to move on to a new language? ...

What languages have a while-else type control structure, and how does it work?

A long time ago, I thought I saw a proposal to add an else clause to for or while loops in C or C++... or something like that. I don't remember how it was supposed to work -- did the else clause run if the loop exited normally but not via a break statement? Anyway, this is tough to search for, so I thought maybe I could get some CW ans...

What are the features of dynamic languages (like Ruby or Clojure) which you are missing in Scala?

What do you lose in practice when you choose a statically-typed language such as Scala (or F#, Haskell, C#) instead of dynamically-typed ones like Ruby, Python, Clojure, Groovy (which has macros or runtime metaprogramming capabilities)? Please consider best statically-typed languages and best (in your opinion) dynamically-typed languages...

Do you know any other programming languages that have interactive mode like Python?

Python language has a well known feature named interactive mode where interpreter can read commands directly from tty. I tipically use this mode to test if a given module is in the classpath or to play around and test some snippets. Do you know any other programming languages that has Interactive Mode? If you can, give the name of the...

ASP-style tags for Perl web development?

I feel like I'm traveling 10 years back in time by asking this, but... Are there any modules, patches, or any "new" version of Perl (released in the last 10 years) to enable writing web-oriented Perl scripts using ASP-style tags? e.g. from ASP/JSP some html <% some code %> more HTML e.g. from PHP some html <? some code ?> more...

Methods in Ruby: objects or not?

Inspired by this discussion, after some googling I wasn't able to find an answer to a pretty simple question regarding methods in Ruby: are methods objects or not? There are different opinions here and there, and I would really like to hear, let's say, an in-depth explanation. I'm aware of Object#method method, which takes a method nam...

Anonymous type and tuple

What is the difference between anonymous type and tuple? ...

Syntax choice for type parameter variance in C# and VB

In both C# and VB, type parameter modifiers are used to express the variance of type parameters. For example, the C# version looks like: interface Foo<in X, out Y> { } and the VB version looks like: Interface Foo(Of In X, Out Y) End Interface Since variance specifications basically restrict where and how a type parameter can be us...

Should I use C++0x Features Now?

With the official release of VS 2010, is it safe for me to start using the partially-implemented C++0x feature set in my new code? The features that are of interest to me right now are both implemented by VC++ 2010 and recent versions of GCC. These are the only two that I have to support. In terms of the "safety" mentioned in the first...