Summary for the impatient: I'm searching for good references on generating code for common language constructs but not parsing.
I am interested in programming languages and try to read the literature as much as possible. But most of them covers the topic in a functional and theoretical perspective that, I find them hard to understand le...
See: Understanding Pointers
In many C flavoured languages, and some older languages like Fortran, one can use Pointers.
As someone who has only really programmed in basic, javascript, and actionscript, can you explain to me what a Pointer is, and what it is most useful for?
Thanks!
...
I saw this thread, but I didn't see a JavaScript specific example. Is there a simple string.Empty in JavaScript, or is it just checking for "" ?
...
It seems quite a few mainstream languages support function literals these days. They are also called anonymous functions, but I don't care if they have a name. The important thing is that a function literal is an expression which yields a function which hasn't already been defined elsewhere, so for example in C, &printf doesn't count.
E...
I've done some Python but have just now starting to use Ruby
I could use a good explanation of the difference between "self" in these two languages.
Obvious on first glance:
Self is not a keyword in Python, but there is a "self-like" value no matter what you call it.
Python methods receive self as an explicit argument, whereas Ruby do...
I've read some of the recent language vs. language questions with interest... Perl vs. Python, Python vs. Java, Can one language be better than another?
One thing I've noticed is that a lot of us have very superficial reasons for disliking languages. We notice these things at first glance and they turn us off. We shun what are probabl...
Sorry in advance if the question is naive...
Is there a way of forcing a (child) class to have constructors with particular signatures or particular static methods in C# or Java?
You can't obviously use interfaces for this, and I know that it will have a limited usage. One instance in which I do find it useful is when you want to enfor...
I was trying to convert a string containing only base 10 digits (e.g. "124890") to an array of corresponding integers (for given example: [1, 2, 4, 8, 9, 0]), in Ruby.
I'm curious about how easily this can be accomplished in Ruby and in other languages.
...
A lot of useful features in Python are somewhat "hidden" inside modules. Named tuples (new in Python 2.6), for instance, are found in the collections module.
The Library Documentation page will give you all the modules in the language, but newcomers to Python are likely to find themselves saying "Oh, I didn't know I could have done it ...
C# 3/3.5 includes a set of new features which Java does not support
(linq, wwf, lambda expressions, etc).
C# 1.0,1.1 and 2.0 was comparable to Java in many ways.
What do you think of this? do you agree? Is this a good thing?
What is the future for both these languages compared to each other?
...
We're all familiar with the pre- and post-increment operators, e.g.
c++; // c = c + 1
++c; // ditto
and the "combined operators" which extend this principle:
c += 5; // c = c + 5
s .= ", world"; // s = s . ", world"; e.g. PHP
I've often had a need for a 'post-combined operator', which would allow:
s =. "Hello "; // ...
Every time I need to do something N times inside an algorithm using C# I write this code
for (int i = 0; i < N; i++)
{
...
}
Studying Ruby I have learned about method times() which can be used with the same semantics like this
N.times do
...
end
Code fragment in C# looks more complex and we should declare useless variable i...
Here are some gems:
Literals:
var obj = {}; // Object literal, equivalent to var obj = new Object();
var arr = []; // Array literal, equivalent to var arr = new Array();
var regex = /something/; // Regular expression literal, equivalent to var regex = new RegExp('something');
Defaults:
arg = arg || 'default'; // if arg evaluates to ...
This is the unabashed attempt of a similar C# question.
So what are your favorite F# hidden (or not) features?
Most of the features I've used so far aren't exactly hidden but have been quite refreshing. Like how trivial it is to overload operators compared to say C# or VB.NET.
And Async<T> has helped me shave off some real ugly code.
...
Does anyone know if it possible to define the equivalent of a "java custom class loader" in .NET?
To give a little background:
I am in the process of developing a new programing language that targets the CLR, called "Liberty". One of the features of the language is its ability to define "type constructors", which are methods that are e...
Which other restrictions are there on names (beside the obvious uniqueness within a scope)?
Where are those defined?
...
I tend to have a stereotype of Haskell as the most "advanced" (high-level, sophisticated, powerful, abstract) language. One which has lots of weird features that, if I could grasp them, would make me a super-hero programmer.
But what comes after Haskell? What languages and new kinds of abstraction are being invented now in academia whic...
This is not a question about which of the two languages is better than the other. I myself can't really decide. Pros and cons as always I guess.
Also, if you feel you always would prefer C over C++, this poll is not for you :-).
However, when I work in C projects I usually feel I'm missing a few language constructs more than others, wh...
Greenspunning. We've all had occasion to hack around a language's missing features to get what we need. Implementing pseudo-monadic patterns in Java, Y Combinators in Javascript, variable immutability in C...
What do you consider your most impressive workaround in search of greater functionality? In hindsight, was it worth the hack? E...
I wish we have "Usable" pattern in C#, when code block of using construct would be passed to a function as delegate:
class Usable : IUsable
{
public void Use(Action action) // implements IUsable
{
// acquire resources
action();
// release resources
}
}
and in user code:
using (new Usable())
{
// this code block ...