I recently have to touch Javascript and am horrified at the lack of a require/include function. Now I find out it doesn't have namespaces either.
FOR FUCK'S SAKE PEOPLE! Did these guys all sleep through the last 30 years of language design? If I had to enumerate the most important programming innovations in the last three decades namespaces and include would be near the top of the list. This isn't something "fancy" like OO, these are the basics of MODULAR DESIGN: the thing which separates spagetti code from real code.
Javascript isn't the only one to have made this mistake, not having namespaces. Lua comes to mind as well as earlier versions of Perl and PHP. Perl regretted it. PHP is still regreting it as they struggle with their new namespaces. Every C programmer which writes a header file regrets it. Lua is just now starting to regret it as they hack further and further around the limitation.
So maybe its not so obvious. Maybe we need a list. A list of early decisions which all language designers will eventually regret. And take it from the Perl programmers... we know. Oh god we know.
I'll start with the obvious ones. I'm no cross-language expert so my examples may be out of date or just plain wrong.
And throw in some less obvious ones.
And some controversial ones.
Add your own! Point out more violations! Its fun!
static typing (Score:1)
Static typing without type inference
If you're going to make a new language, please make a type-inferring version of C. kthxbye
Re:static typing (Score:2)
Re:static typing (Score:2)
That is, the function
sqis defined for all valuesa, such thatais an instance of the type classNum. Remember, Haskell is strongly typed, and this function is defined on all kinds of numbers (machine integers, bignums, floats, doubles, complex, etc.). Furthermore, it will be defined on all types you define that are also instances ofNum.This is a contrive
Re:static typing (Score:1)
All of these have entries posted at the shootout [debian.org].
None of these languages are suitable for low-level programming (kernels, databases, etc.), which is why we need a type-inferring version of something more like C.
Perl 4 had namespaces (Score:2)
Re:Perl 4 had namespaces (Score:2)
Dynamic Features (Score:2)
printfis just soooo lame)Now, with interpolation and eval, you can fake closures, but it's a royal PITA. Here's the classic make_adder example in Perl:
Re:Dynamic Features (Score:2)
Re:Dynamic Features (Score:2)
Reducing this down to "allow dynamic code generation" and "attach data to code" is a false economy in specification. Once you have true closures (which imply lexical scoping), a whole new way to code is opened up for you. Instead of writing ridiculously long classes to, say, find files, you can have small simple classes that are responsible for the algorithmic structure of finding files and nothi
Re:Dynamic Features (Score:2)
By changing the wording from "have closures" to "easily attach data to code" (with the implied "at runtime") I was attempting to restate the problem as a problem rather than as a solution. Closures are a solution to the problem and you've layed out the problem quite well. I would rather not assume that closures are the only way to do it. Or eval. Or pluggable functions (*foo = \&bar). Maybe there is a way to do it efficiently and concisely with anonymous cl
Re:Dynamic Features (Score:2)
As you stated the problem above, there are some design decisions that are fundementally wrong in language design today. Like no namespaces, no way to include files, etc.
"No Closures" is as big a design flaw as "no anonymous functions", "no eval" and "no interpolation". You can find all sorts of ways around that problem, but fundementally, there's no good reason to not have closures. Rephrasing that, there's no defensible reason for asking your users to jump through hoops to achieve the same result
Re:Dynamic Features (Score:2)
Anonymous classes are a form of closure. It's how Java fakes closures in particular, and it's a cleaner solution for some problems. (You could define anon classes with dynamic scoping rules a la Tcl, but why?)
The issues are very closely related, but not identical.
If you say no to closures and yes to anon classes, you're really saying no jam! and more orange marmalade!
Even more unbelievable (Score:2)
include (Score:2)
Though perhaps thinking static inclusion is not quite the same - Turbo Pascal had "uses foo, bar baz;" lines which were directives to the "linker" IIRC (though there was no stand-alone linker, I think; it was a compiler-and-linker all in one, so you couldn't link TP code to, say, C code, th
--
Esli epei eto cumprenan, shris soa Sfaha.
Aettot ibrec epesecoth, spakhea scrifeteis.
Perl 6 (Score:2)
Doesn't Perl 6 make this mistake, too? (I'm thinking of the int Type)
I'm re-reading the Smalltalk 80 book (last time I read it was about 10 years ago). Its really amazing how much they were ahead in 1980 compared to the state of most languages in 2005
Re:Perl 6 (Score:2)
Don't think so. I sure hope not. AFAIK Parrot doesn't make that assumption so there's no implementation reason why Perl 6 would.
Surprise! And people wonder why they should learn Smalltalk. If more folks learned Smalltalk instead of C++ in the early 90s
Re: (Score:1)
<script src="...">does that for you. Javascript is actually a pretty nice language. I far prefer writing JS over PHP, even over Python (though not as decidedly).iframe hacks (Score:1)
No regexes, no decent string handling (Score:1)
Anyone who's ever tried to do anything nearly useful with XSLT must have hit the same wall (no pun).
The very least you'd expect in a language is taking a substring at fixed position, and locating and optionally replacing a substring. But just how many C programs that do some form of string processing do you know that do not link against some regex library? Right.
javascript as a general purpose language (Score:1)