Re: Stupid Language Designer Tricks

2012-06-14 Thread Peter da Silva

On 2012-06-13, at 10:41, David Cantrell wrote:

 On Wed, Jun 13, 2012 at 06:55:31AM -0500, Peter da Silva wrote:
 On 2012-06-11, at 13:08, Aaron J. Grier wrote:
 On Sat, May 19, 2012 at 03:49:15PM -0500, Peter da Silva wrote:
 On 2012-05-19, at 11:43, Michael G Schwern wrote:
 Or still using it, basically unchanged, as our primary system
 programming language in 2012.

 Yeh, it really sucks that in 50 years nobody has ever been able to
 develop a genuinely better alternative.

 is it because there are not genuinely better alternatives, or the cost
 of moving to them is too high?

 I don't know. I'm still waiting for someone to show me one.

 My first impressions of Go are good, but that means it's off-topic.

It looks way too high level to replace 'C'.

Oh, sorry, I mean optional semicolons? rant rant!



Re: Stupid Language Designer Tricks

2012-06-13 Thread Peter da Silva
On 2012-06-11, at 13:08, Aaron J. Grier wrote:
 On Sat, May 19, 2012 at 03:49:15PM -0500, Peter da Silva wrote:
 On 2012-05-19, at 11:43, Michael G Schwern wrote:
 Or still using it, basically unchanged, as our primary system
 programming language in 2012.

 Yeh, it really sucks that in 50 years nobody has ever been able to
 develop a genuinely better alternative.

 is it because there are not genuinely better alternatives, or the cost
 of moving to them is too high?

I don't know. I'm still waiting for someone to show me one.




Re: Stupid Language Designer Tricks

2012-06-13 Thread David Cantrell
On Wed, Jun 13, 2012 at 06:55:31AM -0500, Peter da Silva wrote:
 On 2012-06-11, at 13:08, Aaron J. Grier wrote:
  On Sat, May 19, 2012 at 03:49:15PM -0500, Peter da Silva wrote:
  On 2012-05-19, at 11:43, Michael G Schwern wrote:
  Or still using it, basically unchanged, as our primary system
  programming language in 2012.
  Yeh, it really sucks that in 50 years nobody has ever been able to
  develop a genuinely better alternative.
  is it because there are not genuinely better alternatives, or the cost
  of moving to them is too high?
 I don't know. I'm still waiting for someone to show me one.

My first impressions of Go are good, but that means it's off-topic.

-- 
David Cantrell | London Perl Mongers Deputy Chief Heretic

Aluminum makes a nice hat.  
All paranoids will tell you that.
But what most do not know 
Is reflections will show
On the CIA's evil landsat.



Re: Stupid Language Designer Tricks

2012-06-11 Thread Aaron J. Grier
On Sat, May 19, 2012 at 03:49:15PM -0500, Peter da Silva wrote:
 On 2012-05-19, at 11:43, Michael G Schwern wrote:
  Or still using it, basically unchanged, as our primary system
  programming language in 2012.
 
 Yeh, it really sucks that in 50 years nobody has ever been able to
 develop a genuinely better alternative.

is it because there are not genuinely better alternatives, or the cost
of moving to them is too high?

50 years of legacy code seems a difficult (if not impossible) momentum
to overcome.

-- 
  Aaron J. Grier | Not your ordinary poofy goof. | agr...@poofygoof.com



Re: Stupid Language Designer Tricks

2012-05-23 Thread Robert Rothenberg

On 14/05/12 17:28 Luke Kanies wrote:

On May 14, 2012, at 9:06 AM, Robert Rothenberg wrote:



[Snip!]



But Puppet is special in that it's intended to be a *descriptive* language.
So you describe how your servers are to be configured.

Sounds nice, except... it has side effects. Which makes the whole
descriptive vs imperative thing to be worthless.


Hmm.  I don't see side effects anywhere, just stupid language stuff.


Well, putting on my language theorist's hat: if the language is descriptive,
then the interpreter should do exactly what is described. If unexpected
things happen (like variables sometimes being undefined/blank because of
non-deterministic evaluation order), then those are side effects.


One example of my hatred for Puppet:

1. Execution order is non-deterministic. Well, not a problem, but…


Well, technically, the execution order of unrelated resources was, until 
recently, as random and inconsistent as the hashing algorithm in ruby.  It is 
now random (again, only for unrelated resources) but consistent across runs.


2. Evaluation order of parameters is also non-deterministic. Well,
  not as well documented, but is a bit more problematic because…


Hmm.  I was going to say that's not true, but that actually is true for the 
parameters in your example. (One of the stupidest parts of Puppet is the 
inconsistencies between types defined in the language, like below, and those 
defined in Ruby.)


Well, there's an outstanding request for a strict mode in Puppet.

Another idea would be to have it determine dependencies between parameters
based on variable interpolation, or even just to evaluate the parameters in
the order that they are specified.

I actually think that defaulting to the order that things are given in the
source code when there are no other dependencies is a good thing.


3. Undefined values are *silently* interpolated as empty strings!


I chose this because the shell does the same thing, and I figured sysadmins 
(our target user) would find it most convenient.  I think this is being 
reconsidered, but I'm not sure it doesn't actually make the most sense.  It's 
not up to me any more, though. :)


I can understand the decision, but I don't think it's good to replicate bad
behaviour on other systems, just because that's what users are used to.






Re: Stupid Language Designer Tricks

2012-05-22 Thread Tony Finch
Michael G Schwern schw...@pobox.com wrote:

 The third is distraction.  For some reason every language which started out to
 replace C gets distracted by dreams of being an application language.  I'm
 thinking Java (was originally supposed to run on set top boxes), Objective-C
 and C++  It is particularly curious that we haven't had a serious attempt in
 thirty years.  There's something about writing a pure system programming
 language that invites distraction.

Objective-C and C++ were intended to adapt C to be better for application
programming.

A more recent example of your observation is Go, though perhaps they are
using a strange definition of systems programming language. Perhaps also
(Digital Mars) D.

Rust is interesting.

The VPRI work on high-functionality small-LOC software is using a
Smalltalk-alike as its system programming language - e.g. metacircular
method dispatch.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Lundy, Fastnet, Irish Sea: Variable, mainly southerly, 3 or 4, backing
southeast 5 or 6 in Fastnet. Smooth or slight, but slight or moderate in
Fastnet. Fog patches, occasional drizzle. Moderate or good, occasionally very
poor.



Re: Stupid Language Designer Tricks

2012-05-21 Thread Tony Finch
Peter da Silva pe...@taronga.com wrote:

 I'll give you the fall-through in case.

There are some other things that were fixed in later versions:

Single namespace for structure and union members
No function argument type checking

There are some things that haven't been fixed:

const
Operators (particularly *  | ^)

And some things that have been fixed in C++

enum checking


A lot of the problems with C are due to the extremely small computer that
it had to fit into in the early days. The other contemporary languages
that we have been comparing it with ran on much bigger machines.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
South-east Iceland: Easterly or northeasterly 6 to gale 8, veering
southeasterly 5 or 6. Rough or very rough. Occasional rain. Moderate or good,
occasionally poor.



Re: Stupid Language Designer Tricks

2012-05-21 Thread Michael G Schwern
On 2012.5.20 4:40 AM, Peter da Silva wrote:
 Smalltalk was also not low level enough to be used as an alternative to C.
 It wouldn't even fit in the PDP-11 they started with.

Never claimed it was.


 The list was done evaluating C as a language we use and are heavily 
 influenced
 by in 2012.
 
 And why is that? Why hasn't anything that's _genuinely_ better caught on?

Just because something is the default, or even a category killer, doesn't mean
it doesn't have some glaring faults.  We should particularly look our defaults
straight in the eye and ask if we're using it because its great or because its
what we know.  Understanding your tools flaws is as important as understanding
its strengths.

I'll have a go though.

The first is the enemy of the best is good enough and C was good enough...
for a time.  It solved a problem (portable machine programming) better and
faster than its contemporaries and even much later languages.

The second is longevity.  It's only been in the last ten years that hardware
has become so cheap and powerful that we no longer have to be concerned with
performance at every level (alternatively, that CPU and memory are no longer
the bottleneck).  Thirty years is a long time to get entrenched and have the
entire industry wrap itself around a technology.

The third is distraction.  For some reason every language which started out to
replace C gets distracted by dreams of being an application language.  I'm
thinking Java (was originally supposed to run on set top boxes), Objective-C
and C++  It is particularly curious that we haven't had a serious attempt in
thirty years.  There's something about writing a pure system programming
language that invites distraction.

The fourth is that for 99% of developers, C is not an issue.  They've solved
the problem of C by writing in higher level languages and leaving it to a
handful of others to worry about writing their language or tool in C.  There's
no great drive to fix the problem, for most folks it isn't a problem.  This
isn't necessarily the most healthy way to manage your technical development,
see also IPv6.

Fifth, I think there's a broad overlap between people who want to write at
the system level and people who want to be really close to the hardware, C
fits this mentality.  The longer the two are wielded together, the more the
system programming community will think in C.

This is a personal observation, folks to code C like details of bits and
registers and hardware details and such.  They like to feel in total control
(even if an advanced compiler means they're not).  If your system language
tries to abstract this, a lot of systems people won't touch it.  Myself?  I'd
like to be able to work my languages and operating systems and databases
without having to care about hardware.  But C won't let me do that, so I
ignore system programming.

Finally, C has a TOTAL lock on the subject.  Application programming has
always been multilingual, and ready to accept new languages, but systems
programming is nothing but C.  None of the disruptive technologies which have
created new niches for application languages (mobile, web, desktops, cheap
RAM, cheap CPU, Unicode, new operating systems, multiple CPUs, corporate power
plays) seem to be creating the new niches at the system level.  Maybe they
just don't have as big an impact.  Maybe system programmers are used to their
language being kinda clunky.  Maybe C is just very adaptable because their
standard features and libraries are so slim.  Probably a bit from all that.
It's very difficult to get a break in a decades old monoculture.


-- 
s7ank: i want to be one of those guys that types s/jjd//.^$ueu*///djsls/sm.
   and it's a perl script that turns dog crap into gold.



Re: Stupid Language Designer Tricks

2012-05-21 Thread David Parsons


On May 21, 2012, at 2:22 PM, Michael G Schwern wrote:


This is a personal observation, folks to code C like details of bits and
registers and hardware details and such.


   Novices like to prattle on about C being just another assembly
language, but they don't know what they're talking about.  It's like
hipsters talking about the philosophical purity of fixed-gear bicycles,
and should be treated with the same contempt (but these days, now that
there are more thrice-damned vanity languages out there than you can
shake a stick at, about the only people chattering on about how C is
a glorified assembly language are the people who are trying to dump on
C because it's not Perl, P*th*n, or any of those other tdvls.



I'd like to be able to work my languages and operating systems and databases
without having to care about hardware.  But C won't let me do that,



   I've programmed primarily in C for the past 30 years now, and I've
never given a damn about the hardware.   If I have to poke at hardware,
I do it in assembly language like G-d Himself intended, and leave C for
high-level work.



Finally, C has a TOTAL lock on the subject.


   No it doesn't.  You don't have to dig very deeply to find
systems that have huge gobs of code written in C++, ObjC,
PL/I(excuse me, PL/X) or, godhelpus, BLISS. It's not C's
fault that it's a more expressive language than any of these
alternatives.


   -david parsons


Re: Stupid Language Designer Tricks

2012-05-21 Thread Peter da Silva

On 2012-05-21, at 16:22, Michael G Schwern wrote:

The first is the enemy of the best is good enough and C was good enough...
for a time.  It solved a problem (portable machine programming) better and
faster than its contemporaries and even much later languages.


Not just good enough, I used several of its competitors, both structured 
languages and macro-assembler level alternatives. It was enormously better, and the few 
that had advantages over C in a few areas had huge lacunae elsewhere.

It also actually addressed many of the problems you listed significantly better 
than the majority of the alternatives, in that it at least tried to address 
them, even if only to place them explicitly outside the scope of the language.

But, yeh, it's hard to move C now. But that wasn't always the case.

So forget the last 30 years. Let's set the wayback machine for the late '70s.

Why didn't anyone come up with a better alternative to C 30 years ago, when it wasn't so 
entrenched? I know people tried. I was a total language geek back then (to the extent that I showed 
up in the Berkeley version of Adventure as a substitute dwarf, the mad Australian on a 
skateboard who throws a stack of Adventure printouts in many different languages at 
you), and I desperately jumped on everything that wasn't C. I skipped at least one course at 
Berkeley because it was in C, and waited for a professor who was teaching it in something else.

For a while I was hopeful about Modula, until I bought two different Modula-2 
compilers for the Amiga and discovered it was pretty much impossible to write a 
non-trivial Modula-2 program that would compile on both of them. Modula-3 only 
had better success because it was basically a front end to C.

Bad as you claim C was, it was much batter than all the alternatives long before it 
reached category killer status.




Re: Stupid Language Designer Tricks

2012-05-20 Thread Peter da Silva

On 2012-05-19, at 16:54, Michael G Schwern wrote:

Smalltalk was in production in 72 making it a contemporary with C.  Smalltalk
80 was the first released version, roughly coinciding with the KR book.  And
Simula had all the trappings of a modern OO language (and a lot most still
don't have) in 1967.


Smalltalk was also not low level enough to be used as an alternative to C. It 
wouldn't even fit in the PDP-11 they started with.


The point of the list was not to show alternatives to C as a system
programming language, but to show that there's only so much it was 1970,
computers were primitive, and nobody knew what they were doing can forgive
C's design.


It was 1970, the computers that C was designed for were even more limited than most, and 
what they were doing was pretty damn new. The only widely used systems programming 
languages in 1970 were assembler and Fortran. The big name system programming 
languages were, well, big. Bigger than Fortran. And running a good Fortran on a PDP-11? 
Have you actually done that?


The list was done evaluating C as a language we use and are heavily influenced
by in 2012.


And why is that? Why hasn't anything that's _genuinely_ better caught on?


Basic language features done by a preprocessor.


Like Lisp.


I let the rest slide, because it's all in historical context, but not this
one.  Just because another language does it don't make it right.


It's not just another language. It's Lisp. The god language. The one that all 
other languages wish they were.


And any other systems programming language I've used has been worse. If PL/1
had caught on, you'd have been pissed.



More so than I already am? ;)


Fuck yes. I've had to work on PL/1 code.




Re: Stupid Language Designer Tricks

2012-05-20 Thread demerphq
On 18 May 2012 22:07, Michael G Schwern schw...@pobox.com wrote:
 switch fall through. (still a classic mistake).

I guess you mean defaulting to falling through? Yeah that probably
should have defaulted to the other way, even though C's approach
matches what actually happens. On the other hand i seem to remember
that a  number of modern languages hatefully support a switch
statement but do not support fall through at all. I recently did some
C where I really came to appreciate of the value of switch
fall-through.

Despite all its hateful aspects, and indeed perhaps *because of them*
I find the occasional foray from my comfortable Perl-world to the
harsh and unforgiving terrain of C-land to be quite refreshing. Its
like going camping in the wilderness for a vacation from city life,
rustic, simple, and actually quite pleasant despite the lack of
amenities.

cheers,
Yves

-- 
perl -Mre=debug -e /just|another|perl|hacker/



Re: Stupid Language Designer Tricks

2012-05-19 Thread Aristotle Pagaltzis
* Michael G Schwern schw...@pobox.com [2012-05-19 18:50]:
 Or still using it, basically unchanged, as our primary system
 programming language in 2012.

Indeed: why oh why… One has to wonder.



Re: Stupid Language Designer Tricks

2012-05-19 Thread Greg McCarroll


On 19 May 2012, at 21:38, Aristotle Pagaltzis wrote:


* Michael G Schwern schw...@pobox.com [2012-05-19 18:50]:

Or still using it, basically unchanged, as our primary system
programming language in 2012.


Indeed: why oh why… One has to wonder.




Just to play the devil sitting on the devil's advocates shoulder, could i 
suggest that while C is low level, it reflects hardware accurately.  And there 
hasn't been a better alternative for a system programming language.

Lisp machines[1] didn't exactly take off. C++/STL didn't have anyone build upon 
it for other languages significantly (i'm sure i'm about to be proven wrong 
here) , just for sheer mischief i'll mention Topaz[2].

So we now live in a world of x86 hardware, in big computing clouds, that are a 
mixture of hard working sysadmins finally thinking like engineers (flameproof 
suit on) and marketing people making me want to get a TARDIS so I can go back 
and suggest to Dante a new level of hell.

Application as a service seems a good way forward for the cloud, but when it 
comes to languages, i'd personally stick an Erlang hacker, an MPI hacker and 
BPEL hacker (for loose definitions of hacker, it is BPEL)  in a room and see 
what crack they come up with. And at some level down the chain it will still be 
implemented in C.

G.

[1] http://en.wikipedia.org/wiki/Lisp_machine
[2] http://www.perl.com/pub/1999/09/topaz.html





Re: Stupid Language Designer Tricks

2012-05-19 Thread Peter da Silva

On 2012-05-18, at 15:07, Michael G Schwern wrote:

Bagging on C is like bagging on Shakespeare.  They were severely limited in
hardware, didn't have a whole lot of prior art to go on and not a whole lot of
people to talk to about it.  Smalltalk, ML, Pascal, Prolog, Lisp and SQL all
came out about the same time, and had solved most of the problems below (in
pieces), so there's only so much I can forgive.


Smalltalk came out ten years later.
Pascal was basically useless, so much of the language was undefined.
SQL is not a procedural language, I don't know what it's doing in the list, you 
might as well add runoff.
Lisp and Prolog are not low enough level to be used in the problem space that C 
addresses. Even PL/1 and most other other systems programming languages of the 
time required more runtime support.

Compare it with languages that can be used to solve the same problems as C, 
like Bliss and Forth and Fortran and PL/M

And most of the problems you list are complete bullshit, if you mean them as 
problems they should have avoided 50 years ago.


Lack of memory protection.
Lack of overflow protection.


You can't write memory allocation code if you the language doesn't let you do 
arbitrary things with pointers.


Lack of automatic memory management.


That's not a problem, that's a requirement. C was the language that memory 
management code was being written in.


Fixed size strings.


Changing that requires memory management, which can't be part of the language.


Magic data in strings (null character).


The debate between null-terminated and counted strings was huge at the time, 
and counted strings produce their own failure modes. For example, on version of 
Pascal I used had a hard 255 character limit on strings.


Fixed size data structures.


See fixed size strings.


Basic string and memory functions which are unsafe at any speed.
Type system tied to hardware definitions.


Far less than in other languages of the time, and C actually made an effort to 
force programmers not to use hardware-specific sizes. I had to port code in 
PL/1 and we finally threw it out, one of the big problems was fixed 35-bit 
integers (yes, 35-bit, on a 36-bit system).


   How much hell does 64 bit computing still cause because of this?


Less than if people had standardized on PL/1.


Very static but very weak typing (makes it more a chore than a protection).
No arbitrary precision math (still a modern mistake).


See fixed size strings.


Unsafe type casting.


See lack of memory protection.


No way to define new types (typedef just renames).


I've never run into a language that had that, that could be used for what C is 
used for.


Awful I/O design (I'd need time to make that less subjective).


C doesn't have I/O, any more than Lisp or Modula does. However, the usual C 
runtime library is var better than that for contemporaries like FORTRAN, 
Pascal, APL, and anything that made non-UNIX native system calls.


Basic language features done by a preprocessor.


Like Lisp.


Awful variable argument function interface.


There was no variable argument function interface in C, it was patched on later 
to allow people to write printf without assembly glue. Most languages of the 
time don't have one.


Strings are just arrays (and the sins you can commit with that).
Arrays are just pointers (ditto).


See fixed size strings and lack of memory protection.


Generally unportable (much critical functionality is outside the language).


The only systems programming language I've used that's easier to write portable 
code in is Fortran.

Etcetera, etcetera, etcetera.

I'll give you the fall-through in case.

And any other systems programming language I've used has been worse. If PL/1 
had caught on, you'd have been pissed.


Re: Stupid Language Designer Tricks

2012-05-19 Thread Peter da Silva

On 2012-05-19, at 11:43, Michael G Schwern wrote:

Or still using it, basically unchanged, as our primary system programming
language in 2012.


Yeh, it really sucks that in 50 years nobody has ever been able to develop a 
genuinely better alternative.





Re: Stupid Language Designer Tricks

2012-05-19 Thread Michael G Schwern
On 2012.5.19 1:46 PM, Peter da Silva wrote:
 Smalltalk came out ten years later.

Smalltalk was in production in 72 making it a contemporary with C.  Smalltalk
80 was the first released version, roughly coinciding with the KR book.  And
Simula had all the trappings of a modern OO language (and a lot most still
don't have) in 1967.

But...


 Pascal was basically useless, so much of the language was undefined.
 SQL is not a procedural language, I don't know what it's doing in the list
 Lisp and Prolog are not low enough level to be used in the problem space
 that C addresses.

The point of the list was not to show alternatives to C as a system
programming language, but to show that there's only so much it was 1970,
computers were primitive, and nobody knew what they were doing can forgive
C's design.


 And most of the problems you list are complete bullshit, if you mean them as
 problems they should have avoided 50 years ago.

No, that's why I avoided bagging on C until Jarkko trolled^Wasked.

The list was done evaluating C as a language we use and are heavily influenced
by in 2012.  It's worth doing because so many languages are still influenced
by C and are repeating its sins (particularly with regard to types and strings
and I/O).  And Jarko asked.

Evaluating C in its historical context is a different exercise, and has a
totally different utility, which you've done.


 Basic language features done by a preprocessor.
 
 Like Lisp.

I let the rest slide, because it's all in historical context, but not this
one.  Just because another language does it don't make it right.

Furthermore, if you're referring to Lisp macros, Lisp made the correct choice
to have their macros be part of the grammar (a nice side effect of the grammar
being so simple).  C macros just jam themselves in wherever.


 I'll give you the fall-through in case.

Why you're so very generous.


 And any other systems programming language I've used has been worse. If PL/1
 had caught on, you'd have been pissed.

More so than I already am? ;)  I kinda would have liked to have seen a worse
language be the popular one.  Maybe it would have been bad enough we'd have
junked it by now for something better.

I continue to put my hopes in Go.  They so far have avoided the most important
mistake in designing a system programming language: forgetting its a system
programming language.


-- 
The past has a vote, but not a veto.
-- Mordecai M. Kaplan



Re: Stupid Language Designer Tricks

2012-05-19 Thread Michael G Schwern
On 2012.5.15 1:41 PM, Jarkko Hietaniemi wrote:
 Otherwise I haven't come across this problem in other major languages...
 except maybe C.  And original C has so many design flaws that the list would
 become useless.
 
 You will have to back that up somehow, laddie.  And get offa my lawn.

I've been to your house, you don't have a lawn!


-- 
ROCKS FALL! EVERYONE DIES!
http://www.somethingpositive.net/sp05032002.shtml



Re: Stupid Language Designer Tricks

2012-05-19 Thread Aristotle Pagaltzis
* Greg McCarroll g...@mccarroll.org.uk [2012-05-19 23:00]:
 Lisp machines[1] didn't exactly take off. C++/STL didn't have anyone
 build upon it for other languages significantly (i'm sure i'm about to
 be proven wrong here) , just for sheer mischief i'll mention Topaz[2].

Bagging on C as a language is like bagging on the web as a networking
architecture. It’s a sport everyone likes because it’s so easy – in both
cases the target is worse than the alternatives in every way except for
the fact that it works whereas the alternatives don’t.

(Personally I’m more interested in understanding what is right about
such things such that they work, than I am in enumerating the nine
billion names of how they suck. But I realise that that is off-topic
on this list.)

Regards,
-- 
Aristotle Pagaltzis // http://plasmasturm.org/



Re: Stupid Language Designer Tricks

2012-05-18 Thread Michael G Schwern
On 2012.5.15 1:41 PM, Jarkko Hietaniemi wrote:
 Otherwise I haven't come across this problem in other major languages...
 except maybe C.  And original C has so many design flaws that the list would
 become useless.
 
 You will have to back that up somehow, laddie.  And get offa my lawn.
 
 (I can somewhat understand if your basic premise is simply that if X
 isn't a modern scripting language, X is flawed, though I wouldn't
 take that as the basic premise.)

Bagging on C is like bagging on Shakespeare.  They were severely limited in
hardware, didn't have a whole lot of prior art to go on and not a whole lot of
people to talk to about it.  Smalltalk, ML, Pascal, Prolog, Lisp and SQL all
came out about the same time, and had solved most of the problems below (in
pieces), so there's only so much I can forgive.

Just because they have an excuse for being flawed doesn't mean modern
languages should be modeled on it.  Since its so pervasive it helps to be
objective about its many flaws.  Most of them are not worth discussing because
nobody in their right mind would consider them these days.

And since you asked, off the top of my head...

Lack of memory protection.
Lack of overflow protection.
Lack of automatic memory management.
Fixed size strings.
Magic data in strings (null character).
Fixed size data structures.
Basic string and memory functions which are unsafe at any speed.
Type system tied to hardware definitions.
How much hell does 64 bit computing still cause because of this?
Very static but very weak typing (makes it more a chore than a protection).
No arbitrary precision math (still a modern mistake).
Unsafe type casting.
No way to define new types (typedef just renames).
Awful I/O design (I'd need time to make that less subjective).
(non(grammatical(macros))).
Cut  paste libraries (#include).
Basic language features done by a preprocessor.
Awful variable argument function interface.
Strings are just arrays (and the sins you can commit with that).
Arrays are just pointers (ditto).
Generally unportable (much critical functionality is outside the language).
Must declare variables all at once.
switch fall through. (still a classic mistake).
Terrible concurrency support. (fork + IPC and C threads are both nightmares)
Terrible non-ASCII string support. (not even Unicode, just Latin-1)
Byzantine compile and link process.
Lack of exceptions.
Mixed return/error codes.

With enough tools and libraries, and forty years of language upgrades, most of
this can be solved... kinda... but the traps are still there lurking.  If
you're going to wrap C up in tons of library calls and bolt on protections,
why are you coding in C?  Some people realized this and took it to the logical
extreme: use C to write a new language!

C had one purpose: be as fast as possible while remaining vaguely portable.  C
is the hot rod of programming languages.  They stripped out every bit of
convenience and safety gear to make it go as fast as possible and do whatever
the programmer wanted.  Portable assembly (only portable compared to
assembly).  This was great for pushing the limits of hardware 20, 30, 40 years
ago, but now compilers can do a much better job than a human, and safer.

We live in C's shadow: the cultural belief in micro-optimization; its the only
widespread system programming language; and I'd say C's strings, I/O and
memory management are still one of the largest causes of crashes and security
holes.

The idea that you need to strip out all the safeties and conveniences to be
fast is a long, long legacy of C and IMO has held up system programming
language development for decades.  Its finally been broken by languages like
Go and amazing adaptive compiler and virtual machine design, but the idea
still hangs on and still holds us back.


-- 
I am somewhat preoccupied telling the laws of physics to shut up and sit down.
-- Vaarsuvius, Order of the Stick
   http://www.giantitp.com/comics/oots0107.html



Re: Stupid Language Designer Tricks

2012-05-18 Thread Jarkko Hietaniemi
 And since you asked, off the top of my head...

[ a long list snipped]

Now, tell us how you *really* feel about C?

In case you didn't guess it yet, I was playing advocatus diaboli in
reverse here.  (In modernese: trolling.)  In other words, your list
and argument was good, though many items were kind of like the same
thing.

But: calling them design mistakes is like saying quills don't work
well on flatscreen displays.  If you are really good, you can foresee
five years ahead, and design accordingly.  30 years?  No way.  The one
making a design mistake would be the one repeating C's design
deficiencies at this day and age, as you pointed out.

-- 
There is this special biologist word we use for 'stable'. It is
'dead'. -- Jack Cohen



Re: Stupid Language Designer Tricks

2012-05-18 Thread Michael G Schwern
On 2012.5.14 9:38 AM, demerphq wrote:
 On 14 May 2012 14:34, David Cantrell da...@cantrell.org.uk wrote:
 I wouldn't mind if it was disabled by default and if I had to explicitly
 enable it per file, with something like 'no strict cpp'.
 
 Couldnt this just be a filter/preprocessor thingee?

Filter::cpp has existed for a very, very long time.


-- 
ROCKS FALL! EVERYONE DIES!
http://www.somethingpositive.net/sp05032002.shtml



Re: Stupid Language Designer Tricks

2012-05-16 Thread Peter Corlett
On Tue, May 15, 2012 at 01:41:09PM -0700, Jarkko Hietaniemi wrote:
[...]
 Otherwise I haven't come across this problem in other major languages...
 except maybe C. And original C has so many design flaws that the list
 would become useless.
 You will have to back that up somehow, laddie. And get offa my lawn.

OK, I've got one: C strings. They're error-prone to use and thus result in
security problems, have lousy performance, and you can't store a NUL in
them. That alone is enough to break out C++ and use std::string.

 (I can somewhat understand if your basic premise is simply that if X
 isn't a modern scripting language, X is flawed, though I wouldn't take
 that as the basic premise.)

I'd like to see somebody try and write an operating system kernel in Perl :)




Re: Stupid Language Designer Tricks

2012-05-16 Thread Peter da Silva


On 2012-05-15, at 15:39, Michael G Schwern wrote:

I've heard that same story but about the hard tab in make.  Smells like an
urban legend... or proof that programmers care too much about backwards
compatibility.


Well, he really did say there were N sites using it, and N was small. But it 
was a private conversation at Usenix so I have no record of what N was.


Re: Stupid Language Designer Tricks

2012-05-16 Thread Robert G. Werner

On 05/16/2012 03:22 AM, Peter Corlett wrote:

On Tue, May 15, 2012 at 01:41:09PM -0700, Jarkko Hietaniemi wrote:
[...]

Otherwise I haven't come across this problem in other major languages...
except maybe C. And original C has so many design flaws that the list
would become useless.

You will have to back that up somehow, laddie. And get offa my lawn.


OK, I've got one: C strings. They're error-prone to use and thus result in
security problems, have lousy performance, and you can't store a NUL in
them. That alone is enough to break out C++ and use std::string.


(I can somewhat understand if your basic premise is simply that if X
isn't a modern scripting language, X is flawed, though I wouldn't take
that as the basic premise.)


I'd like to see somebody try and write an operating system kernel in Perl :)



I'm sure it could be written,  ... once

--
In Reach Technology:http://www.inreachtech.net/

Robert G. Werner
rob...@inreachtech.net

Tel: 559.304.5122

When you're dining out and you suspect something's wrong, you're 
probably right.




Re: Stupid Language Designer Tricks

2012-05-16 Thread Peter Corlett
On Wed, May 16, 2012 at 10:22:55AM -0700, Robert G. Werner wrote:
 On 05/16/2012 03:22 AM, Peter Corlett wrote:
[...]
 I'd like to see somebody try and write an operating system kernel in Perl
 :)
 I'm sure it could be written, ... once

There is the Perlix userspace:

http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/TPJ/2000/vol5_2/tpj0502-0009.html




Re: Stupid Language Designer Tricks

2012-05-15 Thread Peter da Silva

On 2012-05-14, at 10:58, H.Merijn Brand wrote:
 Reminds me of an April-fools article introducing COME FROM to the
 language to ease debugging. In the end of that article they also
 described COME FROM ON  Hilarious
 
 http://en.wikipedia.org/wiki/COMEFROM
 http://www.fortran.com/come_from.html

FORTRAN DO is basically COME FROM.

  DO 10 I = 1, 10
  ...
10FORMAT(1X,23HGUESS WHAT HAPPENS HERE)




Re: Stupid Language Designer Tricks

2012-05-15 Thread Peter da Silva

On 2012-05-14, at 07:51, David Cantrell wrote:

For extra excitement, perl has this nifty feature where you can index
from the end of an array using negative numbers:

 @array = ('ant', 'bat', 'camel', 'dolphin');
 print $array[-1]; # dolphin
 print $array[-2]; # camel


That really _is_ a nifty feature, it makes all kinds of code so much simpler 
when origin is zero.

But it interacts oddly with ANY origin changes. What happens to it when origin 
is 1? Does it mean array[0] is the last element?




Re: Stupid Language Designer Tricks

2012-05-15 Thread David Cantrell
On Tue, May 15, 2012 at 05:15:56AM -0500, Peter da Silva wrote:
 On 2012-05-14, at 07:51, David Cantrell wrote:
  For extra excitement, perl has this nifty feature where you can index
  from the end of an array using negative numbers:
   @array = ('ant', 'bat', 'camel', 'dolphin');
   print $array[-1]; # dolphin
   print $array[-2]; # camel
 That really _is_ a nifty feature, it makes all kinds of code so much simpler 
 when origin is zero.

Indeed.  It seems like such a little thing, but even in a language where
you know how long your arrays are like you do in perl, $array[-3] for
the third element from the end is so much easier to read than
$array[$#array - 2] ($#array is the index of the last element in the
array).

 But it interacts oddly with ANY origin changes. What happens to it when 
 origin is 1? Does it mean array[0] is the last element?

It gets far more exciting than that!

array: [ant, bat, camel, dolphin]

origin: 0index: 0ant
origin: 0index: 1bat
origin: 0index: -2   camel
origin: 0index: -1   dolphin

origin: 1index: 0ant
origin: 1index: 1ant
origin: 1index: -2   camel
origin: 1index: -1   dolphin

origin: -1   index: 0ant
origin: -1   index: 1camel
origin: -1   index: -2   camel
origin: -1   index: -1   dolphin

origin: -2   index: 0ant
origin: -2   index: 1dolphin
origin: -2   index: -2   camel
origin: -2   index: -1   dolphin

which is All Kinds Of Fucked Up.

I believe that most of what's happening there is accidental.  $[ was
invented for the use of the a2p awk-to-perl translator, awk using 1 as
its array origin and perl using 0 by default, and it was never intended
to be set to anything other than 0 or 1.  Provided that you set $[
to 0 or 1 (or any other positive number) and provided that you never try
accessing any index less than $[, it behaves as you would expect.

-- 
David Cantrell | Hero of the Information Age

I think the most difficult moment that anyone could face is seeing
their domestic servants, whether maid or drivers, run away
  -- Abdul Rahman Al-Sheikh, writing on 25 Jan 2004 at
 http://archive.arabnews.com/?article=38558



Re: Stupid Language Designer Tricks

2012-05-15 Thread Darrell Fuhriman

Well, while we're ranting about stupid language design desisions...

I would like to dish out a special platter of hate for Puppet.

Well, not a programming language per se.

But Puppet is special in that it's intended to be a *descriptive* language.
So you describe how your servers are to be configured.


Ugh… let's not even talk about the broken-ass scoping and inheritance rules. (Which they are slowly improving, but ugh.) Oh and the false is a boolean if it's internal, but a string of it's from facter. That caused no end of confusion when if $var was continually evaluating as true, even though it was clearly defined as false, I mean false. 


I'm personally of the opinion that they should abandon the custom DSL in favor 
of a pure ruby implementation, but I seem to be on the losing end of that 
argument.

d.




Re: Stupid Language Designer Tricks

2012-05-15 Thread Tony Finch
Darrell Fuhriman darr...@garnix.org wrote:

 I'm personally of the opinion that they should abandon the custom DSL in
 favor of a pure ruby implementation, but I seem to be on the losing end
 of that argument.

This is one of the weirder design decisions of Puppet, given how
fashionable embedded DSLs are in the Ruby world.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Fair Isle, Faeroes, South-east Iceland: Northerly or northwesterly 6 to gale
8, decreasing 4 or 5 later. Very rough or high, becoming rough or very rough.
Wintry showers. Good, occasionally poor.



Re: Stupid Language Designer Tricks

2012-05-15 Thread demerphq

On 15 May 2012 12:22, Peter da Silva pe...@taronga.com wrote:


On 2012-05-14, at 10:58, H.Merijn Brand wrote:

Reminds me of an April-fools article introducing COME FROM to the
language to ease debugging. In the end of that article they also
described COME FROM ON  Hilarious

http://en.wikipedia.org/wiki/COMEFROM
http://www.fortran.com/come_from.html


FORTRAN DO is basically COME FROM.

     DO 10 I = 1, 10
     ...
10    FORMAT(1X,23HGUESS WHAT HAPPENS HERE)


Ah, Hollerith Strings. Brings a tear to my eye

Yves



--
perl -Mre=debug -e /just|another|perl|hacker/



Re: Stupid Language Designer Tricks

2012-05-15 Thread Michael G Schwern
On 2012.5.14 2:44 AM, Numien wrote:
 But, that is another good point:
 * We'll add file access and persistent storage later

Still don't count that as a design mistake in Javascript, but a design
feature.  It was designed as a secure language and that means very, very
restricted I/O and storage.

Otherwise I haven't come across this problem in other major languages...
except maybe C.  And original C has so many design flaws that the list would
become useless.


-- 
If you want the truth to stand clear before you, never be for or against.
The struggle between for and against is the mind's worst disease.
-- Sent-ts'an



Re: Stupid Language Designer Tricks

2012-05-15 Thread Michael G Schwern
On 2012.5.14 5:08 AM, Aristotle Pagaltzis wrote:
 * Peter Corlett ab...@cabal.org.uk [2012-05-14 12:20]:
 On Mon, May 14, 2012 at 11:06:59AM +0200, demerphq wrote:
 I kinda wish perl had an interface like

 my $iter= iterator(%hash);
 while (my ($key,$value)= $iter-each) { }

 Which I think would be sane. You could even pass the iterator
 without passing the hash itself. (Preventing modifications to the
 hash but allowing 3rd party code to iterate it).

 I suspect it would be relatively simple to write a module to provide
 that syntax.
 
 6 lines for the most minimal pure-Perl implementation. But to really do
 it right (i.e. not eat memory for a copied key list) requires access to
 the hash data structure at a level that AFAIK requires XS.

What was that?  Is that the sound of someone volunteering to fix a bug?!
https://github.com/schwern/perl5i/issues/210


-- 
101. I am not allowed to mount a bayonet on a crew-served weapon.
-- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
   http://skippyslist.com/list/



Re: Stupid Language Designer Tricks

2012-05-15 Thread Michael G Schwern
On 2012.5.14 2:06 AM, demerphq wrote:
 On 14 May 2012 02:17, Michael G Schwern schw...@pobox.com wrote:
 So much hate for tying the iterator to the data and not the op.
 
 Indeed. I see this bite people regularly at $work (non Perl
 programmers converting seem to get bitten by each() at least once in
 their career).
 
 In the case of hashes I think tying it to the op would also be bad.
 
 I kinda wish perl had an interface like
 
 my $iter= iterator(%hash);
 
 while (my ($key,$value)= $iter-each) {
 }

perl5i has that.  Through the magic of autoboxing you don't even need the
iterator.

use perl5i::2;

my %things = ( foo = 23, bar = 42 );
%things-each( func($k, $v) {
say Key: $k, Value: $v
});



-- 
Look at me talking when there's science to do.
When I look out there it makes me glad I'm not you.
I've experiments to be run.
There is research to be done
On the people who are still alive.
-- Jonathan Coulton, Still Alive



Re: Stupid Language Designer Tricks

2012-05-15 Thread Michael G Schwern
On 2012.5.14 2:47 AM, H.Merijn Brand wrote:
 * undef/NULL handling
 
   * Oracle converts  to NULL on varchar2 fields
   * MySQL considers the date -00-00 both NULL and NOT NULL at
 the same time

I would boil that down to trinary logic.  A good idea that NOBODY gets it
right.  If you do get it right, you're still wrong; the implementation will
cheat and confuse null with false... sometimes.


-- 
184. When operating a military vehicle I may *not* attempt something
 I saw in a cartoon.
-- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
   http://skippyslist.com/list/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Philip Newton

On Mon, May 14, 2012 at 1:58 AM, Michael G Schwern schw...@pobox.com wrote:

The only other instance I can think of is... damn I can't remember the name.
It's the one that makes URLs like /foo/bar/123,3598,235.html.  You write in
Java and everything, even the templates, is stored in Oracle.


Vignette StoryServer?

I had a bit of a go with that... back when the language was Tcl, not Java.

Fun times. Especially counting the backslashes. Do we need four here?
Five? Seven?

It was not unheard of to need ungodly numbers of backslashes in various places.

Plus you had things like set vs SET with one being the built-in
Tcl command and one being a special StoryServer Tcl command.

I remember one developer who decided he had had enough of trying to do
something in Tcl and wrote a template that was effectively

   [exec perl -e {
    about 150 lines of Perl snipped ...
   }]

(or whatever the syntax for calling external commands was). Worked wonderfully.


If you think you need that, step away from the keyboard, take a nice walk
outside and rethink your design.  Or write out open + eval long hand.


Or do filename?

Cheers,
Philip
--
Philip Newton philip.new...@gmail.com



Re: Stupid Language Designer Tricks

2012-05-14 Thread Josh Juran

On May 14, 2012, at 12:00 AM, Aristotle Pagaltzis wrote:


* Peter da Silva pe...@taronga.com [2012-05-14 02:45]:

* Imagining that there's some relationship between computer languages
  and human languages.
  * See COBOL
  * See Perl


* Imagining that there's no relationship between computer languages  
and

  linguistic cognition.
* Mathematical notation is ideal for programming!

The only reason to design a programming language is so humans can read
it, after all the computer is just as happy to run machine code  
written

by humans manually as machine code written by a compiler.

But confusing designed for human cognition with let's make it look
like English is certainly stupid and hateful. Aside from COBOL, see
also AppleScript.


See also HyperTalk.

Josh





Re: Stupid Language Designer Tricks

2012-05-14 Thread Aristotle Pagaltzis
* Peter da Silva pe...@taronga.com [2012-05-14 02:45]:
 * Imagining that there's some relationship between computer languages
   and human languages.
   * See COBOL
   * See Perl

* Imagining that there's no relationship between computer languages and
  linguistic cognition.
* Mathematical notation is ideal for programming!

The only reason to design a programming language is so humans can read
it, after all the computer is just as happy to run machine code written
by humans manually as machine code written by a compiler.

But confusing designed for human cognition with let's make it look
like English is certainly stupid and hateful. Aside from COBOL, see
also AppleScript.



Re: Stupid Language Designer Tricks

2012-05-14 Thread Philip Newton
On Mon, May 14, 2012 at 9:00 AM, Aristotle Pagaltzis pagalt...@gmx.de wrote:
 * Mathematical notation is ideal for programming!

See also: the thousands of new programmers confused by x = 5; not
meaning x is equal to 5, despite what they had learned in maths
class.

(I'm reminded of a BASIC dialect on our 64K Z80 machines at school ca.
1985, which had an option to make the assignment operator either = or
:=, IIRC. I think the switch had becomes in its name.)

Cheers,
Philip
-- 
Philip Newton philip.new...@gmail.com



Re: Stupid Language Designer Tricks

2012-05-14 Thread Michael G Schwern
On 2012.5.13 11:06 PM, Philip Newton wrote:
 On Mon, May 14, 2012 at 1:58 AM, Michael G Schwern schw...@pobox.com wrote:
 The only other instance I can think of is... damn I can't remember the name.
 It's the one that makes URLs like /foo/bar/123,3598,235.html.  You write in
 Java and everything, even the templates, is stored in Oracle.
 
 Vignette StoryServer?

YES!  Oh god, the horror.


 I had a bit of a go with that... back when the language was Tcl, not Java.

It's all coming back to me now.  It was TCL 7.  Oh god, it didn't even have a
bytecode compiler!  There was no debugger!  You had to type everything into a
special Java editor (back when Java worked even less) that you couldn't paste
into!


 I remember one developer who decided he had had enough of trying to do
 something in Tcl and wrote a template that was effectively
 
 [exec perl -e {
  about 150 lines of Perl snipped ...
 }]
 
 (or whatever the syntax for calling external commands was). Worked 
 wonderfully.

HAHA!  Oh god I wish I'd thought of that.  Amongst the reasons I was fired
from my first job was my refusal to touch StoryServer ever again.


 If you think you need that, step away from the keyboard, take a nice walk
 outside and rethink your design.  Or write out open + eval long hand.
 
 Or do filename?

That preserves lexical encapsulation.


-- 
170. Not allowed to defect to OPFOR during training missions.
-- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
   http://skippyslist.com/list/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Michael G Schwern
On 2012.5.13 11:18 PM, Numien wrote:
 On 13/05/12 07:58 PM, Michael G Schwern wrote:
 I can forgive Javascript of that because it has no file operations by (good)
 design and thus no way to load other files.

 Sure it does. See XMLHttpRequest the new HTML5 web storage, app cache, and
 socket thing, and all the other libraries derived from them.

AFAIK none of that is part of the Javascript language (ie. the ECMAscript).
They're all special objects with their own standards and require special
implementations.  I don't believe you can write them in Javascript.  And it's
all fairly recent history for Javascript.


-- 
I went to college, which is a lot like being in the Army, except when
 stupid people yell at me for stupid things, I can hit them.
-- Jonathan Schwarz



Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter da Silva


On 2012-05-14, at 02:00, Aristotle Pagaltzis wrote:


* Peter da Silva pe...@taronga.com [2012-05-14 02:45]:

* Imagining that there's some relationship between computer languages
 and human languages.
 * See COBOL
 * See Perl


* Imagining that there's no relationship between computer languages and
 linguistic cognition.


Not nearly as much as people think, and no more than between human languages 
and mathematical notation. Less so, in some ways.


* Mathematical notation is ideal for programming!


This has nothing to do with the notation. Perl uses maths-like notation but it's still a horrible 
example of this kind of confusion. There is a linguistic structure to mathematics as 
well... and some of that linguistic structure is similarly inappropriate for 
programming languages.


The only reason to design a programming language is so humans can read
it, after all the computer is just as happy to run machine code written
by humans manually as machine code written by a compiler.


s/read/write and understand/

It still has to express operations that will be run by a computer, and throwing 
in linguistic fluff that makes it harder for humans to understand what's going 
on (COBOL, Perl) isn't helping anywhere.




Re: Stupid Language Designer Tricks

2012-05-14 Thread Tony Finch
Peter da Silva pe...@taronga.com wrote:

 * Imagining that there's some relationship between computer languages and 
 human languages.
   * See COBOL
   * See Perl

See AppleScript. Here's an epic rant on the subject:

http://daringfireball.net/2005/09/english-likeness_monster

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Viking, North Utsire: Southwesterly 6 to gale 8, veering westerly 5 to 7. Very
rough or high. Rain or squally showers. Good, occasionally poor.



Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter Corlett
On Sun, May 13, 2012 at 07:35:39PM -0500, Peter da Silva wrote:
[...]
 Like *x for indirection. Even Dennis agrees that was a mistake. He said
 that by the time he noticed it there were three sites using C so they
 thought it was probably too late to fix it.

I heard the there were three sites using it story about why the precedence
of  and || are wrong. Trust Perl to come up with a rather special way of
fixing *that* one.




Re: Stupid Language Designer Tricks

2012-05-14 Thread Tony Finch
Andy Armstrong a...@hexten.net wrote:
 On 13 May 2012, at 18:48, Michael G Schwern wrote:
  * Lists count from 0
   * Everybody does it
   * Everybody's wrong
   * See also let's just paste what C does

 I find it very hard to live with Lua's 1-based arrays. I don't think
 it's just familiarity - lots of index calculations work out
 significantly more verbose and ugly with 1-based arrays.

There are good reasons to prefer a zero base with an open upper bound.

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Fair Isle: Westerly or northwesterly 6 to gale 8, occasionally severe gale 9
in north. High. Squally wintry showers. Moderate or poor.



Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter da Silva

On 2012-05-14, at 05:03, Peter Corlett wrote:

On Sun, May 13, 2012 at 07:35:39PM -0500, Peter da Silva wrote:
[...]

Like *x for indirection. Even Dennis agrees that was a mistake. He said
that by the time he noticed it there were three sites using C so they
thought it was probably too late to fix it.



I heard the there were three sites using it story about why the precedence
of  and || are wrong. Trust Perl to come up with a rather special way of
fixing *that* one.


Thinking back, I may be mixing up another three sites story with the 
conversation I had with him, but he did mention some small number of installations by 
today's standards. Or he could have told that story so many times that he automatically 
used that same number.




Re: Stupid Language Designer Tricks

2012-05-14 Thread Abigail
On Mon, May 14, 2012 at 10:54:39AM +0100, Tony Finch wrote:
 Andy Armstrong a...@hexten.net wrote:
  On 13 May 2012, at 18:48, Michael G Schwern wrote:
   * Lists count from 0
* Everybody does it
* Everybody's wrong
* See also let's just paste what C does
 
  I find it very hard to live with Lua's 1-based arrays. I don't think
  it's just familiarity - lots of index calculations work out
  significantly more verbose and ugly with 1-based arrays.
 
 There are good reasons to prefer a zero base with an open upper bound.
 
 http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
 


It's worse if languages don't do it consistently:

for (X .. Y) {
...
}

not equivalent with

for ($_ = X; $_  Y; $_ ++) {
...
}



Abigail



Re: Stupid Language Designer Tricks

2012-05-14 Thread demerphq
On 14 May 2012 02:17, Michael G Schwern schw...@pobox.com wrote:
 So much hate for tying the iterator to the data and not the op.

Indeed. I see this bite people regularly at $work (non Perl
programmers converting seem to get bitten by each() at least once in
their career).

In the case of hashes I think tying it to the op would also be bad.

I kinda wish perl had an interface like

my $iter= iterator(%hash);

while (my ($key,$value)= $iter-each) {
}

Which I think would be sane. You could even pass the iterator without
passing the hash itself. (Preventing modifications to the hash but
allowing 3rd party code to iterate it).

Yves

-- 
perl -Mre=debug -e /just|another|perl|hacker/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Numien

OOn 14/05/12 04:03 AM, Michael G Schwern wrote:

AFAIK none of that is part of the Javascript language (ie. the ECMAscript).
They're all special objects with their own standards and require special
implementations.  I don't believe you can write them in Javascript.  And it's
all fairly recent history for Javascript.


While this is true, it's the case of many languages that the functions 
aren't strictly part of the language, they're part of the standard 
library set. And being a hosted language you can't really write most of 
its significant functions in Javascript itself.


But, that is another good point:
* We'll add file access and persistent storage later




Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter Corlett
On Mon, May 14, 2012 at 11:06:59AM +0200, demerphq wrote:
[...]
 I kinda wish perl had an interface like

 my $iter= iterator(%hash);
 while (my ($key,$value)= $iter-each) { }

 Which I think would be sane. You could even pass the iterator without
 passing the hash itself. (Preventing modifications to the hash but
 allowing 3rd party code to iterate it).

I suspect it would be relatively simple to write a module to provide that
syntax. Without looking, I bet it's already in CPAN.




Re: Stupid Language Designer Tricks

2012-05-14 Thread Aaron Crane
Peter Corlett ab...@cabal.org.uk wrote:
 I'd like to throw in the fun breakage caused by the combination of adding
 two unnecessary bits of syntactic sugar to Perl. Somebody decided that
 auto-deref would be nice, so you can do each $hashref and pop $arrayref.
 And then somebody else clearly huffed a bit too much PHP and decided that
 hash operations should also work on arrays where possible, even if it
 doesn't make sense.[0] Quick now, what does each $foo do, buried 94 levels
 deep in the call stack of your Enterprise Quality Software?

I've heard that complaint before, and I honestly don't understand it.
Among the reasons people use OO is so that the meaning of `$obj-meth`
can be determined at run time, not compile time.  If `each $x` is so
confusing in Perl 5.14+ that it shouldn't be used deep in the call
stack, isn't that also true of method invocations?

-- 
Aaron Crane ** http://aaroncrane.co.uk/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Aaron Crane

Michael G Schwern schw...@pobox.com wrote:

On 2012.5.13 11:36 AM, Peter Corlett wrote:

I'd like to throw in the fun breakage caused by the combination of adding
two unnecessary bits of syntactic sugar to Perl. Somebody decided that
auto-deref would be nice, so you can do each $hashref and pop $arrayref.
And then somebody else clearly huffed a bit too much PHP and decided that
hash operations should also work on arrays where possible, even if it
doesn't make sense.[0] Quick now, what does each $foo do, buried 94 levels
deep in the call stack of your Enterprise Quality Software?


You have the history of that backwards.

Hash operations working on arrays are the unfortunate, ultimate evolution of
an unfortunate failed performance hack called pseudo-hashes where arrays were
made to act like hashes.


Assuming you're talking about the ability for the `keys`, `values`,
and `each` builtins to take either a %-prefixed hash or an @-prefixed
array as their argument, that's not quite true.  Pseudo-hashes were
finally removed in Perl 5.10, to universal rejoicing; extending
keys/values/each to arrays was done in 5.12.

(And furthermore, that extension was to permit a useful feature —
`each @array`, for iterating over the indexes and values of an array
in parallel — not as a performance hack, and not out of some misguided
notion that hashes and arrays are the same thing.  I know that because
it was at least partly my fault: I wrote the CPAN module where that
behaviour was prototyped, and I accidentally persuaded Nicholas Clark
to port it to the core.)

Then 5.14 acquired another new feature: the option to omit the @ or %
from the argument to certain builtins, including `keys`, `values`, and
`each`, by prototyping the relevant argument using the + character.
Since these two enhancements aren't entirely compatible, the current
situation is unfortunate: a +-prototyped argument must be an
unblessed array or hash ref — not a blessed reference, and not an
autovivifying undef (so `push $x, list` doesn't work on undef, even
though `push @$x, list` would work fine).


So much hate for tying the iterator to the data and not the op.


I fully share your hate for that.

--
Aaron Crane ** http://aaroncrane.co.uk/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Tony Finch
Walt Mankowski waltman-hates-softw...@mawode.com wrote:

 * Everything is a string.
   * Tcl

I like the term stringly typed.

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Shannon: Northwest 5 to 7, perhaps gale 8 later. Rough or very rough. Showers.
Good, occasionally moderate.



Re: Stupid Language Designer Tricks

2012-05-14 Thread Abigail
On Sun, May 13, 2012 at 10:48:13AM -0700, Michael G Schwern wrote:
 
 * Auto declare undeclared variables
   * PHP, Ruby
   * Typo protection out the window

* Perl (unless you enable 'use strict vars', and don't fully qualify
your vars; no such protection possible on subs if you use parentheses,
and no protection at all on method names)

 * Terminate statement on newline
   * Ruby, Javascript, Kurila

* Python, shell

 * Arrays are just hashes with numbered keys
   * (Maybe not such a bad idea)

That would be: * AWK

 * Significant whitespace
   * Python
   * Oh god why Kurila
   * YAML does it right
   * So does Ruby

* Perl6
* Perl (when using heuristics)

 * Objects are just magic hashes
   * Perl

In practice, but not enforced by the language.

* Objects are just magical references, with no build in support to keep state
  * Perl

 * Lists count from 0
   * Everybody does it
   * Everybody's wrong
   * See also let's just paste what C does

* Let's make where to count from a switch -- globally
  * Perl (till it got removed from the language)

 * Let's compare case-insensitively by default
   * Powershell, MySQL

* But be not consistent about this default
  * MySQL

 * A typed language with no way to define new types
   * SQL
 * No namespaces
   * Lua, Javascript

* AWK, C, SQL, Pascal, shell, BASIC, ...

 * Use the same function for two totally different things.
   * eval BLOCK; eval STRING
   * select FILEHANDLE; select BITS, BITS, BITS, TIMEOUT

* do STRING; do BLOCK; do BLOCK (while|until) CONDITION

 * We'll add threads later.
   * Perl
 * We'll add Unicode later.
   * Perl (FULL RECOVERY!)

* We'll add objects later.
  * Perl



Abigail



Re: Stupid Language Designer Tricks

2012-05-14 Thread H.Merijn Brand
On Sun, 13 May 2012 10:48:13 -0700, Michael G Schwern
schw...@pobox.com wrote:

 * A typed language with no way to define new types
   * SQL

* Follow the standard only optionally

  All SQL dialects allow spaces as the SQL standard sais

  SELECT bar, count (*) FROM frublt GROUP BY bar;
 ^ ^

  MySQL only allows the space on count (*) (and other functions)
  when sql_mode=IGNORE_SPACE in [mysqld] section in my.cnf

* undef/NULL handling

  * Oracle converts  to NULL on varchar2 fields
  * MySQL considers the date -00-00 both NULL and NOT NULL at
the same time

 * Let's compare case-insensitively by default
   * Powershell, MySQL

What about SQL in general considering Data Dictionary commands?
And Oracle UPping everything by default? HATE!

* Allowing spaces in table and field names
  And other special characters too

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.14   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Philip Newton

On Mon, May 14, 2012 at 11:47 AM, H.Merijn Brand h.m.br...@xs4all.nl wrote:

 * Oracle converts  to NULL on varchar2 fields


Oh goodness yes. Whoever thought that was a good idea? And built such
an SQL incompatibility into a major database engine?

Cheers,
Philip
--
Philip Newton philip.new...@gmail.com



Re: Stupid Language Designer Tricks

2012-05-14 Thread H.Merijn Brand
On Sun, 13 May 2012 10:48:13 -0700, Michael G Schwern
schw...@pobox.com wrote:

 * Significant whitespace
   * Python
   * Oh god why Kurila
   * YAML does it right
   * So does Ruby

One more (besides what I wrote about MySQL)

C-preprocessor. The only compiler I know of that does it wrong allways
is the very expensive IBM ANSI compiler. The standard allows


#define foo(a) ((a)-1)

to be equal to

# define  foo(a) ((a)-1)
 #define  foo(a) ((a)-1)
 # define foor(a) ((a)-1)

None of those are actually reliably the same with IBM

Many precompiles mis-parse

#define foo(a) ((a)-1)

when a has been defined before

some precompilers allow

#define foo (a) ((a)-1)

to be the same.

Confused? You won't be after the next episode of ...

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.14   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Tony Finch
Michael G Schwern schw...@pobox.com wrote:

 * No namespaces
   * Lua, Javascript

Lua does have namespaces, by changing which table is used for globals.
There are amusing incompatibilities in this area between 5.1 and 5.2 ...

Tony.
-- 
f.anthony.n.finch  d...@dotat.at  http://dotat.at/
Fisher, German Bight: Southwest 4 or 5, becoming variable 3 or 4. Moderate or
rough, occasionally very rough at first in Fisher. Rain or squally showers.
Moderate or good.



Re: Stupid Language Designer Tricks

2012-05-14 Thread Aristotle Pagaltzis
* Peter Corlett ab...@cabal.org.uk [2012-05-14 12:20]:
 On Mon, May 14, 2012 at 11:06:59AM +0200, demerphq wrote:
  I kinda wish perl had an interface like

  my $iter= iterator(%hash);
  while (my ($key,$value)= $iter-each) { }

  Which I think would be sane. You could even pass the iterator
  without passing the hash itself. (Preventing modifications to the
  hash but allowing 3rd party code to iterate it).

 I suspect it would be relatively simple to write a module to provide
 that syntax.

6 lines for the most minimal pure-Perl implementation. But to really do
it right (i.e. not eat memory for a copied key list) requires access to
the hash data structure at a level that AFAIK requires XS.



Re: Stupid Language Designer Tricks

2012-05-14 Thread David Cantrell
On Mon, May 14, 2012 at 08:06:28AM +0200, Philip Newton wrote:
 On Mon, May 14, 2012 at 1:58 AM, Michael G Schwern schw...@pobox.com wrote:
  The only other instance I can think of is... damn I can't remember the name.
  It's the one that makes URLs like /foo/bar/123,3598,235.html.  You write in
  Java and everything, even the templates, is stored in Oracle.
 Vignette StoryServer?
 I had a bit of a go with that... back when the language was Tcl, not Java.
 Fun times. Especially counting the backslashes. Do we need four here?
 Five? Seven?

No, IIRC it was always a power of two.

 It was not unheard of to need ungodly numbers of backslashes in various 
 places.

I was told by their support people to keep adding slashed until it
works, the number of slashes required being a function of how deeply
nested your code was.  Note that you couldn't keep a standard library of
functions and use the same function at different nesting levels.

Vignette really were a comedy company.  Storyserver was supposed to be a
content management system, but when I used it it couldn't handle binary
file uploads - so you couldn't use it to upload images.  Their
solution to this was to send us some C source which was untested,
because we don't have a compiler in the UK.

-- 
David Cantrell | Godless Liberal Elitist

THIS IS THE LANGUAGE POLICE
PUT DOWN YOUR THESAURUS
STEP AWAY FROM THE CLICHE



Re: Stupid Language Designer Tricks

2012-05-14 Thread Roger Burton West
On Mon, May 14, 2012 at 01:28:45PM +0100, David Cantrell wrote:

Storyserver was supposed to be a
content management system, but when I used it it couldn't handle binary
file uploads - so you couldn't use it to upload images.  Their
solution to this was to send us some C source which was untested,
because we don't have a compiler in the UK.

Obviously they should have insisted you xxencode the images first.

(Because uuencode's not safe through an EBCDIC gateway, that's why.)




Re: Stupid Language Designer Tricks

2012-05-14 Thread Philip Newton

On Mon, May 14, 2012 at 2:28 PM, David Cantrell da...@cantrell.org.uk wrote:

On Mon, May 14, 2012 at 08:06:28AM +0200, Philip Newton wrote:

Vignette StoryServer?
I had a bit of a go with that... back when the language was Tcl, not Java.
Fun times. Especially counting the backslashes. Do we need four here?
Five? Seven?


No, IIRC it was always a power of two.


I thought I sometimes needed 2^n+1... but memory is hazy.


It was not unheard of to need ungodly numbers of backslashes in various places.


I was told by their support people to keep adding slashed until it
works, the number of slashes required being a function of how deeply
nested your code was.


Which was what we mostly ended up doing.


Vignette really were a comedy company.  Storyserver was supposed to be a
content management system,


That's how it was sold to us as well.

After we actually installed the thing and kicked the tyres and found
it wasn't really one, they back-pedalled and said that it could be
used to implement a content management system. (Perhaps in the way
that git plumbing can be used to implement a version management system
but isn't one itself... I think.)


because we don't have a compiler in the UK.


That makes me wonder whether UK refers to the Ukraine in this context

What an extremely odd thing for a company to say.

Cheers,
Philip
--
Philip Newton philip.new...@gmail.com



Re: Stupid Language Designer Tricks

2012-05-14 Thread David Cantrell
On Mon, May 14, 2012 at 03:01:05PM +0200, Philip Newton wrote:
  because we don't have a compiler in the UK.
 That makes me wonder whether UK refers to the Ukraine in this context
 What an extremely odd thing for a company to say.

What our client said was odder.  They said we want you to use
Storyserver.

It was our client (NSPCC) who insisted on us, the experts to whom they'd
outsourced building their webshite, using Storyserver, despite none of
us having ever touched it or even touched tcl before.  We told them that
if they didn't spend six figures (actually, it might have been 7, I
disremember) on a Storyserver licence, then we could do the job faster
for less money then what they were paying us to do it in Storyserver, and
they wouldn't have to spend as much on hardware either.

I bear this in mind whenever one of their begging letters falls through
my front door.

-- 
David Cantrell | Bourgeois reactionary pig

  You know you're getting old when you fancy the
  teenager's parent and ignore the teenager
-- Paul M in uknot



Re: Stupid Language Designer Tricks

2012-05-14 Thread David Cantrell
On Sun, May 13, 2012 at 04:58:49PM -0700, Michael G Schwern wrote:
 On 2012.5.13 3:41 PM, David Cantrell wrote:
  Perl used to have this.  It was called #include.  It's a damned shame
  that -P got killed off.  Removing it was hateful.
 Let's run one language through another language's preprocessor!  WHAT COULD
 POSSIBLY GO WRONG?!  Let's just see what the old 5.10.1 perlrun man page says
 about it...

None of which stops it from being a damned useful tool.  You just need
to be careful with it.  I thought that perl was all about giving you a
gun and if you shot your own foot off that was your own stupid fault.

 I can't imagine why they removed it.  Wait, yes I can!  Jarko and I wrote
 those warnings after trying like hell to make it work in anything like a
 reliable manner.

I wouldn't mind if it was disabled by default and if I had to explicitly
enable it per file, with something like 'no strict cpp'.

-- 
David Cantrell | London Perl Mongers Deputy Chief Heretic

Feature: an incorrectly implemented bug



Re: Stupid Language Designer Tricks

2012-05-14 Thread demerphq

On 14 May 2012 14:34, David Cantrell da...@cantrell.org.uk wrote:

On Sun, May 13, 2012 at 04:58:49PM -0700, Michael G Schwern wrote:

On 2012.5.13 3:41 PM, David Cantrell wrote:
 Perl used to have this.  It was called #include.  It's a damned shame
 that -P got killed off.  Removing it was hateful.
Let's run one language through another language's preprocessor!  WHAT COULD
POSSIBLY GO WRONG?!  Let's just see what the old 5.10.1 perlrun man page says
about it...


None of which stops it from being a damned useful tool.  You just need
to be careful with it.  I thought that perl was all about giving you a
gun and if you shot your own foot off that was your own stupid fault.


I can't imagine why they removed it.  Wait, yes I can!  Jarko and I wrote
those warnings after trying like hell to make it work in anything like a
reliable manner.


I wouldn't mind if it was disabled by default and if I had to explicitly
enable it per file, with something like 'no strict cpp'.


Couldnt this just be a filter/preprocessor thingee?

use C::Preprocessor;

I was really pleased I finally managed to write a script that uses it,
and then discovered they had deprecated it. :-(

Yves


--
perl -Mre=debug -e /just|another|perl|hacker/



Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter da Silva

On 2012-05-14, at 06:07, Aaron Crane wrote:

Since these two enhancements aren't entirely compatible, the current
situation is unfortunate: a +-prototyped argument must be an
unblessed array or hash ref — not a blessed reference, and not an
autovivifying undef (so `push $x, list` doesn't work on undef, even
though `push @$x, list` would work fine).


Is this describing alchemy or cabala?




Re: Stupid Language Designer Tricks

2012-05-14 Thread Peter Corlett
On Mon, May 14, 2012 at 11:20:37AM -0400, Sean Conner wrote:
[...]
 Are you kidding? It can get much worse than that. I came across a language
 [1] that allows for patterm matched random GOSUBs (and that's the general
 case---it can do GOSUBs like other langauges, but it can also do random
 GOSUBS, calculated GOSUBs, and pattern matched GOSUBs with randomness
 thrown in for free).

qw/ foo bar baz /)[rand 3]-('The goggles, they do nothing!');




Re: Stupid Language Designer Tricks

2012-05-14 Thread David Cantrell
On Mon, May 14, 2012 at 11:13:05AM +0200, Abigail wrote:

 * Let's make where to count from a switch -- globally
   * Perl (till it got removed from the language)

Nope.  From the manpage:

 As of release 5 of Perl, assignment to $[ is treated as a compiler
  directive, and cannot influence the behavior of any other file. 

So it was at least made a bit less stupid many years before being
finally killed off.

For extra excitement, perl has this nifty feature where you can index
from the end of an array using negative numbers:

  @array = ('ant', 'bat', 'camel', 'dolphin');
  print $array[-1]; # dolphin
  print $array[-2]; # camel

I leave it as an exercise for the reader to figure out what the hell
should happen if $[ is set to -2.

  * Let's compare case-insensitively by default
* Powershell, MySQL
 * But be not consistent about this default
   * MySQL

viml:

 String comparisons normally honor the local setting of Vim's
  ignorecase option, but any string comparator can also be explicitly
  marked as case-sensitive (by appending a #) or case-insensitive (by
  appending a ?) 

-- 
David Cantrell | even more awesome than a panda-fur coat

 Nuke a disabled unborn gay baby whale for JESUS!



Re: Stupid Language Designer Tricks

2012-05-14 Thread Philip Newton

On Mon, May 14, 2012 at 2:51 PM, David Cantrell da...@cantrell.org.uk wrote:

For extra excitement, perl has this nifty feature where you can index
from the end of an array using negative numbers:

 @array = ('ant', 'bat', 'camel', 'dolphin');
 print $array[-1]; # dolphin
 print $array[-2]; # camel

I leave it as an exercise for the reader to figure out what the hell
should happen if $[ is set to -2.


Or 1 (or 7), for that matter.

(I believe the answer is documented, but it's not as immediately
obvious without some mental arithmetic.)

Cheers,
Philip
--
Philip Newton philip.new...@gmail.com



Re: Stupid Language Designer Tricks

2012-05-14 Thread Abigail
On Mon, May 14, 2012 at 01:51:11PM +0100, David Cantrell wrote:
 On Mon, May 14, 2012 at 11:13:05AM +0200, Abigail wrote:
 
  * Let's make where to count from a switch -- globally
* Perl (till it got removed from the language)
 
 Nope.  From the manpage:
 
  As of release 5 of Perl, assignment to $[ is treated as a compiler
   directive, and cannot influence the behavior of any other file. 
 
 So it was at least made a bit less stupid many years before being
 finally killed off.

Of course, you're correct. Which probably meant that for the handful of 
people that actually used $[, upgrading their Perl broke their programs
in mysterious ways.

 For extra excitement, perl has this nifty feature where you can index
 from the end of an array using negative numbers:
 
   @array = ('ant', 'bat', 'camel', 'dolphin');
   print $array[-1]; # dolphin
   print $array[-2]; # camel
 
 I leave it as an exercise for the reader to figure out what the hell
 should happen if $[ is set to -2.

Luckely, tieing $[ doesn't work, and I don't think it ever did.

   * Let's compare case-insensitively by default
 * Powershell, MySQL
  * But be not consistent about this default
* MySQL
 
 viml:
 
  String comparisons normally honor the local setting of Vim's
   ignorecase option, but any string comparator can also be explicitly
   marked as case-sensitive (by appending a #) or case-insensitive (by
   appending a ?) 


I was more thinking of:

  mysql create table foo (bar int);
  Query OK, 0 rows affected (0.08 sec)

  mysql insert into foo (BAR) values (1);
  Query OK, 1 row affected (0.00 sec)

  mysql insert into FOO (bar) values (2);
  ERROR 1146 (42S02): Table 'xxx.FOO' doesn't exist
  mysql 


Case insensitive column names, case sensitive table names (and IIRC, if you
use MyISAM tables on a case insensitive file system, your table names are 
case insensitive as well, which makes for fun upgrade paths)

Although it wouldn't surprise me if MySQL used a configuration option that
turns on case insensitive table names. Probably one that can be configured
both on the client and server side. (But if it doesn't, I didn't write the
paragraph above; I don't want to put any good ideas into anyones head).


Abigail



Re: Stupid Language Designer Tricks

2012-05-14 Thread Robert Rothenberg

Well, while we're ranting about stupid language design desisions...

I would like to dish out a special platter of hate for Puppet.

Well, not a programming language per se.

But Puppet is special in that it's intended to be a *descriptive* language.
So you describe how your servers are to be configured.

Sounds nice, except... it has side effects. Which makes the whole
descriptive vs imperative thing to be worthless.

One example of my hatred for Puppet:

1. Execution order is non-deterministic. Well, not a problem, but...

2. Evaluation order of parameters is also non-deterministic. Well,
   not as well documented, but is a bit more problematic because...

3. Undefined values are *silently* interpolated as empty strings!

So, let's say you create a Puppet class (not really classes in the OO or
mathematical sense, but that's a separate rant...):

  class foo(
$owner  = foo,
$prefix = /opt/foo,
$config = /etc/${prefix},
  ) {

file { $config:
  ensure = directory,
  owner  = $owner,
  mode   = 0600,
}

...

  }

You'd expect this class to create a directory /etc/opt/foo (for storing
configuration files for your custom foo application).

But sometimes, Puppet might randomly set the value of config before it sets
the value of prefix.  So you'll mess up the permissions of the /etc
directory. With no warning (unless of course, you read the logs closely to
see what it did  but the only errors you will see are when everything
else starts to fail).






Re: Stupid Language Designer Tricks

2012-05-13 Thread Numien

On 13/05/12 01:48 PM, Michael G Schwern wrote:

The rpmbuild post reminded me of my list of stupid language designer tricks.
This is a file I add to every time I read about some stupid mistake (or
brilliant feature) in a language and think if I ever write a language I am
remembering not to do THAT!


Also:
* No simple include statement
  * Javascript is one of the worst, but this is a far too common one.




Re: Stupid Language Designer Tricks

2012-05-13 Thread Andy Armstrong

On 13 May 2012, at 18:48, Michael G Schwern wrote:

* Lists count from 0
 * Everybody does it
 * Everybody's wrong
 * See also let's just paste what C does



I find it very hard to live with Lua's 1-based arrays. I don't think it's just 
familiarity - lots of index calculations work out significantly more verbose 
and ugly with 1-based arrays.

--
Andy Armstrong, Hexten






Re: Stupid Language Designer Tricks

2012-05-13 Thread David Cantrell
On Sun, May 13, 2012 at 02:13:28PM -0400, Numien wrote:
 On 13/05/12 01:48 PM, Michael G Schwern wrote:
 The rpmbuild post reminded me of my list of stupid language designer 
 tricks.
 This is a file I add to every time I read about some stupid mistake (or
 brilliant feature) in a language and think if I ever write a language I 
 am
 remembering not to do THAT!
 
 Also:
 * No simple include statement
   * Javascript is one of the worst, but this is a far too common one.

Perl used to have this.  It was called #include.  It's a damned shame
that -P got killed off.  Removing it was hateful.

-- 
David Cantrell | even more awesome than a panda-fur coat

  Sobol's Law of Telecom Utilities:
Telcos are malicious; cablecos are simply clueless.



Re: Stupid Language Designer Tricks

2012-05-13 Thread Peter Corlett
On Sun, May 13, 2012 at 10:48:13AM -0700, Michael G Schwern wrote:
[...]
 * Lists count from 0
   * Everybody does it
   * Everybody's wrong
   * See also let's just paste what C does

0's good because it avoids fencepost errors. Perhaps you would prefer the
Stan Kelly-Bootle compromise of 0.5?

[...]
 * Use the same function for two totally different things.
   * eval BLOCK; eval STRING
   * select FILEHANDLE; select BITS, BITS, BITS, TIMEOUT

Don't forget the three forms of goto: ugly but useful performance hack,
break out the BASIC interpreter and fondue set, it's eighties night, and
computed GOTO, just kill me now!

I'd like to throw in the fun breakage caused by the combination of adding
two unnecessary bits of syntactic sugar to Perl. Somebody decided that
auto-deref would be nice, so you can do each $hashref and pop $arrayref.
And then somebody else clearly huffed a bit too much PHP and decided that
hash operations should also work on arrays where possible, even if it
doesn't make sense.[0] Quick now, what does each $foo do, buried 94 levels
deep in the call stack of your Enterprise Quality Software?

And on the subject of Perl and hashes:

* iterators not general-purpose and only available on hashes
  * and you can only have one per hash


[0] say keys ['a'..'z'];




Re: Stupid Language Designer Tricks

2012-05-13 Thread Michael G Schwern
On 2012.5.13 3:41 PM, David Cantrell wrote:
 On Sun, May 13, 2012 at 02:13:28PM -0400, Numien wrote:
 On 13/05/12 01:48 PM, Michael G Schwern wrote:
 The rpmbuild post reminded me of my list of stupid language designer 
 tricks.
 This is a file I add to every time I read about some stupid mistake (or
 brilliant feature) in a language and think if I ever write a language I 
 am
 remembering not to do THAT!

 Also:
 * No simple include statement
   * Javascript is one of the worst, but this is a far too common one.

I can forgive Javascript of that because it has no file operations by (good)
design and thus no way to load other files.

The only other instance I can think of is... damn I can't remember the name.
It's the one that makes URLs like /foo/bar/123,3598,235.html.  You write in
Java and everything, even the templates, is stored in Oracle.  Its include
statement took not a filename, not any sort of name, but the row ID of the
template you wanted to include.  Like include 39593 because I totally know
what template 39593 is!


 Perl used to have this.  It was called #include.  It's a damned shame
 that -P got killed off.  Removing it was hateful.

Let's run one language through another language's preprocessor!  WHAT COULD
POSSIBLY GO WRONG?!  Let's just see what the old 5.10.1 perlrun man page says
about it...

Because both comments and cpp directives begin with the # character,
you should avoid starting comments with any words recognized by the
C preprocessor such as if, else, or define.

Oh.

The #! line is stripped, so any switches there don't apply.

Oh dear.

All lines that begin with (whitespace and) a # but do
not look like cpp commands, are stripped, including
anything inside Perl strings, regular expressions, and
here-docs .

Oh my.

In some platforms the C preprocessor knows too much: it
knows about the C++ -style until-end-of-line comments
starting with //.  This will cause problems with
common Perl constructs like

s/foo//;

Well that's not good.

It requires not only a working C preprocessor but also a
working sed.

I can't imagine why they removed it.  Wait, yes I can!  Jarko and I wrote
those warnings after trying like hell to make it work in anything like a
reliable manner.

And if that all works, or if you implemented it sanely as an include()
keyword, you have a language construct that cut  pastes code without regard
to lexical encapsulation.  Greeeat.

If you think you need that, step away from the keyboard, take a nice walk
outside and rethink your design.  Or write out open + eval long hand.


-- 
29. The Irish MPs are not after Me frosted lucky charms.
-- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
   http://skippyslist.com/list/



Re: Stupid Language Designer Tricks

2012-05-13 Thread Aristotle Pagaltzis
* Andy Armstrong a...@hexten.net [2012-05-13 20:05]:
 I find it very hard to live with Lua's 1-based arrays. I don't think
 it's just familiarity - lots of index calculations work out
 significantly more verbose and ugly with 1-based arrays.

Ever since I’ve dealt with them in XPath I would add

Humans start counting from 1 so the computer should too

to whatever else would be on my list in the spirit of Schwern’s.



Re: Stupid Language Designer Tricks

2012-05-13 Thread Michael G Schwern
On 2012.5.13 11:36 AM, Peter Corlett wrote:
 I'd like to throw in the fun breakage caused by the combination of adding
 two unnecessary bits of syntactic sugar to Perl. Somebody decided that
 auto-deref would be nice, so you can do each $hashref and pop $arrayref.
 And then somebody else clearly huffed a bit too much PHP and decided that
 hash operations should also work on arrays where possible, even if it
 doesn't make sense.[0] Quick now, what does each $foo do, buried 94 levels
 deep in the call stack of your Enterprise Quality Software?

You have the history of that backwards.

Hash operations working on arrays are the unfortunate, ultimate evolution of
an unfortunate failed performance hack called pseudo-hashes where arrays were
made to act like hashes.  This was done years and years ago.

This was back in the day when people were writing things like this to shave
off a little memory and CPU time.

use constant KEY1 = 0;
use constant KEY2 = 1;
use constant KEY3 = 2;

$obj-[KEY1] = $value;

Because array access was perceived to be faster and use less memory than
hashes.  It was decided to make this a language feature!  So you could write...

my $struct = [{foo = 1, bar = 2}, FOO, BAR];

# Equivalent to $struct-[ $struct-[0]{foo} ]
print $struct-{foo};# prints FOO

But for some very special situations where Perl could do some compile time
optimizations that nobody took advantage of, this was actually SLOWER than a
normal hash because now it required two array look ups and a lot of extra code
and Perl hashes were already pretty fast.  Worse, because all the hash ops had
to check for a psuedo-hash it slowed all hashes down by about 15%.  Whoops.

None of this micro-optimizing really matters because you're going to put an
accessor method around it anyway and method calls are relatively expensive.
But Perl developers didn't really grok OO then.

Nobody noticed that until it was too late and large efforts were made to make
psuedo-hashes work well (a lot of them by a young, naive programmer called
me).  This included enhancing arrays so that all the hash operations were
supported.  Unfortunately, somebody noticed that arrays support all the hash
operations anyway... why not expose it at the language level?  For some reason
that person was not immediately stoned.

Psuedo-hashes were removed, with prejudice, but the hash/array operations were
not. :-(


 And on the subject of Perl and hashes:
 
 * iterators not general-purpose and only available on hashes
   * and you can only have one per hash

So much hate for tying the iterator to the data and not the op.


-- 
If you want the truth to stand clear before you, never be for or against.
The struggle between for and against is the mind's worst disease.
-- Sent-ts'an



Re: Stupid Language Designer Tricks

2012-05-13 Thread Peter da Silva

On 2012-05-13, at 19:09, Aristotle Pagaltzis wrote:

* Andy Armstrong a...@hexten.net [2012-05-13 20:05]:

I find it very hard to live with Lua's 1-based arrays. I don't think
it's just familiarity - lots of index calculations work out
significantly more verbose and ugly with 1-based arrays.



Ever since I’ve dealt with them in XPath I would add

   Humans start counting from 1 so the computer should too

to whatever else would be on my list in the spirit of Schwern’s.


Oh yes, add to the list of stupid language designer tricks:

* Imagining that there's some relationship between computer languages and human 
languages.
 * See COBOL
 * See Perl

The fact that the word language is overloaded to mean completely different 
things is a good example of why this is a bad idea.


Re: Stupid Language Designer Tricks

2012-05-13 Thread Peter da Silva

On 2012-05-13, at 12:59, Andy Armstrong wrote:

On 13 May 2012, at 18:48, Michael G Schwern wrote:

* Lists count from 0
* Everybody does it
* Everybody's wrong
* See also let's just paste what C does



I find it very hard to live with Lua's 1-based arrays. I don't think it's just 
familiarity - lots of index calculations work out significantly more verbose 
and ugly with 1-based arrays.


Zero based arrays and lists and other collections make so much sense in so many ways, including 
simplifying iterators and calculations on subranges. When I went from Fortran to just about any 
other language in the world including ones written before C was a twinkle in Dennis' eye... I had 
about 30 seconds of WTF followed by OMG, why does anyone do it any other 
way?

On the other hand, there's a number of really stupid things I find in other 
languages that are obviously just copy and paste from C.

Like == for comparison in statement-based languages where a = b is not a 
valid expression.
Like == for comparison in languages that don't *have* an assignment statement.
Like (type) for coercion in languages that don't support derived types, so 
all the types are one word anyway.
Like *x for indirection. Even Dennis agrees that was a mistake. He said that by the 
time he noticed it there were three sites using C so they thought it was probably too 
late to fix it.


Re: Stupid Language Designer Tricks

2012-05-13 Thread Walt Mankowski
On Sun, May 13, 2012 at 10:48:13AM -0700, Michael G Schwern wrote:
 * We'll add threads later.
   * Perl

* We'll add classes later.
  * C
  * Perl

* Everything is a string.
  * Tcl




Re: Stupid Language Designer Tricks

2012-05-13 Thread Peter da Silva

On 2012-05-13, at 20:55, Walt Mankowski wrote:

* We'll add classes later.
 * C


Classes were still a kind of experimental idea in 1970, and it wasn't at all clear they'd ever be able to be implemented efficiently in something like C. 


Re: Stupid Language Designer Tricks

2012-05-13 Thread Walt Mankowski
On Sun, May 13, 2012 at 09:07:56PM -0500, Peter da Silva wrote:
 On 2012-05-13, at 20:55, Walt Mankowski wrote:
  * We'll add classes later.
   * C
 
 Classes were still a kind of experimental idea in 1970, and it
 wasn't at all clear they'd ever be able to be implemented
 efficiently in something like C.

Yeah, I probably should have put a smiley after C. I was thinking
about the schism into C++ and ObjC, but we can't really blame Ritchie
for that.




Re: Stupid Language Designer Tricks

2012-05-13 Thread Josh Juran

On May 13, 2012, at 7:13 PM, Walt Mankowski wrote:


On Sun, May 13, 2012 at 09:07:56PM -0500, Peter da Silva wrote:

On 2012-05-13, at 20:55, Walt Mankowski wrote:

* We'll add classes later.
 * C


Classes were still a kind of experimental idea in 1970, and it
wasn't at all clear they'd ever be able to be implemented
efficiently in something like C.


Yeah, I probably should have put a smiley after C. I was thinking
about the schism into C++ and ObjC, but we can't really blame Ritchie
for that.


Fortunately, C++ supports diamond inheritance, so there's also ObjC+ 
+.  Best of both worlds!


Josh





Re: Stupid Language Designer Tricks

2012-05-13 Thread Peter da Silva
On 2012-05-13, at 21:13, Walt Mankowski wrote:
 On Sun, May 13, 2012 at 09:07:56PM -0500, Peter da Silva wrote:
 On 2012-05-13, at 20:55, Walt Mankowski wrote:
 * We'll add classes later.
 * C

 Classes were still a kind of experimental idea in 1970, and it
 wasn't at all clear they'd ever be able to be implemented
 efficiently in something like C.

 Yeah, I probably should have put a smiley after C. I was thinking
 about the schism into C++ and ObjC, but we can't really blame Ritchie
 for that.

Pity about CO2 (C O squared / C Object Oriented)

Stupid language designer tricks #2^n-1

* Keep it proprietary
  * Smalltalk
  * CO2