programming-languages

Why interpreted langs are mostly ducktyped while compiled have strong typing?

I just don't know that, is there any technical reason for that? Is it more difficult to implement a compiler for a language with weak typing? What is it? ...

What are some other languages that support "partial specialization"?

Partial template specialization is one of the most important concepts for generic programming in C++. For example: to implement a generic swap function: template <typename T> void swap(T &x, T &y) { const T tmp = x; y = x; x = tmp; } To specialize it for a vector to support O(1) swap: template <typename T, class Alloc> void swa...

On what platform did these popular programming languages originate?

Perhaps you know the story of HTTP and HTML being developed on a NeXT computer. I am curious which platform served as the first home for these programming languages: Ada C C++ C# D Erlang Fortran Haskell Java Javscript Lisp Logo MATLAB ML Perl PHP Prolog Python R Ruby Scheme SQL Smalltalk I thought it might be interesting to reflect ...

Invent new language, syntax check?

i been thinking of a new programming language. Before trying to implement it i would like to check the syntax of code to see if there is much ambiguity. (i find it funny that its possibly to do var++++ to a class) ...

Good APIs for scope analyzers

I'm working on some code generation tools, and a lot of complexity comes from doing scope analysis. I frequently find myself wanting to know things like What are the free variables of a function or block? Where is this symbol declared? What does this declaration mask? Does this usage of a symbol potentially occur before initialization?...

JavaScript: correct prototype chain for Function

What is the correct output (meaning correct by the ECMA standard) of the following program? function nl(x) { document.write(x + "<br>"); } nl(Function.prototype); nl(Function.prototype.prototype); nl(Function.prototype.prototype == Object.prototype); nl(Function.prototype.prototype.prototype); Chrome and IE6 agree in saying: functio...

JavaScript - check if in global context

When a function is attached to an object and called: function f() { return this.x; } var o = {x: 20}; o.func = f; o.func(); //evaluates to 20 this refers to the object that the function was called as a method of. It's equivalent to doing f.call(o). When the function is called not as part of an object, this refers to the global object...

JavaScript implementation that allows access to [[Call]]

The ECMA standard defines a hidden, internal property [[Call]], which, if implemented, mean the object is callable / is a function. In Python, something similar takes place, except that you can override it yourself to create your own callable objects: >>> class B: ... def __call__(self, x,y): print x,y ... >>> inst = B() >>> inst(1...

Relation between [[Prototype]] and prototype in JavaScript

From http://www.jibbering.com/faq/faq_notes/closures.html : Note: ECMAScript defines an internal [[prototype]] property of the internal Object type. This property is not directly accessible with scripts, but it is the chain of objects referred to with the internal [[prototype]] property that is used in property accessor resolution; t...

How does Java pick which overloaded function to call?

This is a purely theoretical question. Given three simple classes: class Base { } class Sub extends Base { } class SubSub extends Sub { } And a function meant to operate on these classes: public static void doSomething(Base b) { System.out.println("BASE CALLED"); } public static void doSomething(Sub b) { System.out.println...

How does C++ pick which overloaded function to call?

Say I have three classes: class X{}; class Y{}; class Both : public X, public Y {}; I mean to say I have two classes, and then a third class which extends both (multiple-inheritance). Now say I have a function defined in another class: void doIt(X *arg) { } void doIt(Y *arg) { } and I call this function with an instance of both: ...

What language(s) have you learned, and how?

Currently I am in college to be a business app developer of sorts. We're learning C#, and VB.NET almost exclusively right now. This makes me think as to why we are. I've read that C# is efficient with almost anything you could ever want to do with it, and that's great. We tend to do a lot of those out of the book review projects, which g...

What programming language implementation benchmarks are there?

I remember from my old BASIC programming days that for extra performance, you could use a BASIC compiler (instead of the runtime interpreter), but for ultimate performance, the answer was assembly code. Today, when performance is crucial, I guess assembly language is still the ultimate optimisation answer. Going for a less extreme solut...

Why wasn't the Java "throws" clause (in method declaration) included in C#?

Why wasn't the Java "throws" clause (in method declaration) included in C#? ...

JavaScript - Identify whether a property is defined and set to 'undefined', or undefined

Say I have the following code: function One() {} One.prototype.x = undefined; function Two() {} var o = new One(); var t = new Two(); o.x and t.x will both evaluate to undefined. o.hasOwnProperty('x') and t.hasOwnProperty('x') will both return false; the same goes for propertyIsEnumerable. Two questions: Is there any way to tell t...

Why would I want to learn to use C# instead of C/C++?

I enjoy using Microsoft Windows and I've used C in the past and now I'm starting to learning C++, but it's going to take me some time to get proficient with it. I expect to write some simple applications and DLLs, not any low level stuff like 3D games, Operating System features or drivers. However C/C++ can be hard work with which to get...

How does JavaScript treat the ++ operator?

JavaScript does funky automatic conversions with objects: var o = {toString: function() {return "40"; }}; print(o + o); print((o+1)+o); print((o*2) + (+o)); will print: 4040 40140 120 This is because +, if any of the arguments are objects/strings, will try to convert all the arguments to strings then concatenate them. If all argume...

Is Java incomplete?

Why do I always feel that Java never worried about growing its own API (the one that comes with it)? I've got several examples.. File upload. Servlet API does not handle it. Easy XML reading Connection pooling HttpClient support Good logging Encoders And so goes on... several lacks that we have to look for third party APIs and...

Best language to learn (for a solo web designer looking to program)

I have a background in visual design. I also have a good knowledge of (X)HTML and CSS and several CMS's. However, I am beginning to hit a wall with respect to what I can accomplish without learning a web-focussed scripting/programming language. I am a solo web designer and really want to be able to broaden my horizons with respect to wha...

Getting started with .NET

I am not new to programming, but most of my experience has been in Java for the last few years. I was introduced to programming in VB 6, and then moved to Java when I started university, and have been using that almost exclusively since. I've taken courses that used other languages (C, Lisp and Prolog, Eiffel) and have worked with SQL an...