language-design

interface for only certain classes?

Can you create an interface which can only be applied to certain classes and subclasses? If my interface is only added to different subclasses of JComponent, and I need to refer to both the methods of JComponent and my interface... how should I do this? Off the top of my head I can accomplish this by adding methods from JComponent to ...

What are the Practical Differences Between "associate" and "indexed" Arrays in PHP?

The PHP array type is actually more akin to an an ordered map than a traditional C array. It's PHP's original general use data structure. The manual goes as far to say The indexed and associative array types are the same type in PHP, which can both contain integer and string indices. However, there's a lot of cases where built-in lang...

Naming: BEGIN ~ END vs LIVE ~ EVIL block structured languages

Curly Bracket languages are well known: (wikipedia) Other programming languages can have BEGIN ~ END vs LIVE ~ EVIL block structuring. eg A) BEGIN ~ END, DO ~ END, IF ~ END IF - examples: Ada, Modula, Pascal, PL/I, Ruby etc... B) IF ~ FI, DO ~ OD, CASE ~ IN ~ OUT ~ ESAC - examples: Action!, ALGOL 68, Bourne shell, Co...

Python Critique

Hi, I'm using Python now for about two months, and to be honest, it really made me love programming again. After programming in C, Java, and worst of all, C++, Python is incredibly fun. Thinking that I approach such language with all positive bias, I would love to hear some critique of Python language. Beside its extremely rich library,...

What is this programming language?

mob/verb/test(N as num) What language is this code from? ...

Is Qt classified as a c++ library? If not a library, how would you classify QT?

I recently started looking into Qt (I installed Qt 4.5.2 and installed their Eclipse-CDT plugin called "qt integration v1.5.2" and I will do all my development in Linux-Eclipse-CDT-QTintegration). Originally I thought Qt was a straight vanilla C++ library but when I installed and started running Qt example code I saw lots of "weird" thi...

Writing Interpreters in Python. Is isinstance considered harmful?

I'm porting over the interpreter for a domain specific language I created from Scala to Python. In the process I tried to find a way that way pythonic to emulate the case class feature of Scala that I used extensively. In the end I resorted to using isinstance, but was left feeling that I was perhaps missing something. Articles such as ...

Why Is Dynamic Typing So Often Associated with Interpreted Languages?

Simple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in statically typed languages. However, almost every interpreted language I encounter uses dyn...

does a disaster proof language exist?

When creating system services which must have a high reliability, I often end up writing the a lot of 'failsafe' mechanisms in case of things like: communications which are gone (for instance communication with the DB), what would happen if the power is lost and the service restarts.... how to pick up the pieces and continue in a correct...

What makes PHP slower than Java or C#?

This is something I've always wondered: Why is PHP slower than Java or C#, if all 3 of these languages get compiled down to bytecode and then executed from there? I know that normally PHP recompiles each file with each request, but even when you bring APC (a bytecode cache) into the picture, the performance is nowhere near that of Java o...

Implications of not including NULL in a language?

I know that NULL isn't necessary in a programming language, and I recently made the decision not to include NULL in my programming language. Declaration is done by initialization, so it is impossible to have an uninitialized variable. My hope is that this will eliminate the NullPointerException in favor of more meaningful exceptions or...

C# - what's the major problem solved by "partial" classes?

I'm asking this because I find it quite a dangerous feature to distribute the class definition so that you can't really be sure if you know all about it. Even if I find three partial definitions, how do I know that there's not a fourth somewhere? I'm new to C# but have spent 10 years with C++, maybe that's why I'm shaken up? Anyway, th...

How have "modern OO languages pretty much eliminated [the] overhead for in-process calls"?

I'm reading through the Source Making site, specifically the Refactoring section. On the page describing the Long Method problem, the following statement is made: Older languages carried an overhead in subroutine calls, which deterred people from small methods. Modern OO languages have pretty much eliminated that overhead for...

Why doesn't a python dict.update() return the object?

I 'm trying to do : award_dict = { "url" : "http://facebook.com", "imageurl" : "http://farm4.static.flickr.com/3431/3939267074_feb9eb19b1_o.png", "count" : 1, } def award(name, count, points, desc_string, my_size, parent) : if my_size > count : a = { "name" : name, "description" : desc_st...

Zero-based month numbering

Some popular programming languages use month numbering which is off by 1 -- JavaScript comes to mind, as does Java, and if memory serves, C is another. I have some questions: If you are going to be ignoring the month numbering used by laypeople, then why not for the sake of consistency also ignore the day numbering used by laypeople, a...

What makes a language readable or not readable?

I heard people say they can understand their python code a year later but not their XYZ code. Why? I dont know what is good about python syntax or what is bad about another. I like C# but i have a feeling VB.NET code is easier to read. I am doing language design so what do you find makes code/syntax/language readable or not readable? ...

whats the difference between a command and a statement

Often when reading about Tcl (e.g. http://antirez.com/articoli/tclmisunderstood.html) you read that "everything is a command". Sometimes you also hear how other languages are, like Tcl, are "command languages." To me with my background in other languages, I just view these "commands" as statements. What precisely is the difference b...

Can't set attributes of object class

So, I was playing around with Python while answering this question, and I discovered that this is not valid: o = object() o.attr = 'hello' due to an AttributeError: 'object' object has no attribute 'attr'. However, with any class inherited from object, it is valid: class Sub(object): pass s = Sub() s.attr = 'hello' Printing s....

Why isn't SEL a class in Objective-C?

In Objective-C (at least, the Apple flavor of Obj-C), why is SEL not a class? Is it a matter of efficiency? Is it to prevent some sort of infinite recursion? Was there merely no incentive to make SEL a class? Speculation welcome, but please let me know if an answer is historical truth or speculation. ...

How to create a language these days?

I need to get around to writing that programming language I've been meaning to write. How do you kids do it these days? I've been out of the loop for over a decade; are you doing it any differently now than we did back in the pre-internet, pre-windows days? You know, back when "real" coders coded in C, used the command line, and quibbled...