Slashdot Mirror


Ask Slashdot: What Are the Strangest Features of Various Programming Languages?

itwbennett writes: Every programming language has its own unique quirks, such as weird syntax, unusual functionality or non-standard implementations -- things that can cause developers new to the language, or even seasoned pros, to scratch their heads in wonder (or throw their hands up in despair). Phil Johnson has rounded up some of the strangest — from the + operator in JavaScript to the trigraphs in C and C++ and indentation level in Python. What programming language oddities cause you the most grief?"

729 comments

  1. Powershell by Anonymous Coward · · Score: 5, Interesting

    -eq as the equality operator in Powershell is pretty odd.

    1. Re:Powershell by Anonymous Coward · · Score: 0

      Bash has it too, just one of the many ways to check for equality. Also the bash trait of not liking spaces before or after an '=' and the obscure error it gives.

    2. Re:Powershell by i+kan+reed · · Score: 1

      And bash having it is precisely why powershell has it. They wanted to capture every bash user as instantly friendly for neo-dos, and stole as many nix commands as they could. I haven't actually tried, but I have this suspicion that a fair number of bash scripts would just work in powershell.

    3. Re:Powershell by Austerity+Empowers · · Score: 1

      Per uses eq for string equality checks, making the distinction between that and == for numerics. I'm not sure that one is weird.

      Verilog has a nice one though ===, meaning two wires are in exactly equal states, including more abstract states like "don't care" or "high impedance", rather than simple == which is a logical comparison. It has no real physical meaning, it's purely for programming purposes.

    4. Re:Powershell by Anonymous Coward · · Score: 2, Informative

      I would suspect that none of them would work. While PowerShell did borrow a lot of syntax from shell batch languages and dynamic languages it is quite dissimilar to both.

    5. Re:Powershell by Anonymous Coward · · Score: 0

      $ [ a = a ] && echo I AM FINE WITH THIS
      I AM FINE WITH THIS
      $

      From which century dates your bash?

    6. Re:Powershell by Anonymous Coward · · Score: 0

      -eq and the others in Powershell come from Bourne Shell, which in turn takes them in a modified form from FORTRAN's .EQ. operator and friends.

      It's FORTRAN all the way down.

    7. Re:Powershell by Anonymous Coward · · Score: 0

      STRING1 = STRING2
                                  the strings are equal

                    INTEGER1 -eq INTEGER2
                                  INTEGER1 is equal to INTEGER2

      Are you stupid?

    8. Re:Powershell by Jeremiah+Cornelius · · Score: 1, Troll

      This is SYNTAX, not FEATURE.

      When I think of a languages strangest feature? No doubt, it's the ear lobes. And the crinkly bits at the corners of their eyes, when they smile. :-)

      --
      "Flyin' in just a sweet place,
      Never been known to fail..."
    9. Re:Powershell by Vlad_the_Inhaler · · Score: 5, Funny

      I'm from a different generation. When I was learning things there were attempts made to make languages somewhat failsafe by avoiding ambiguity. Then I saw the C syntax.
      - if (a = b) assigns the contents of b to a and executes the code following if b <> 0. Who the hell thought that would be a good idea?
      - sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string. Who the hell thought that would be a good idea?
      - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

      Kids grew up with this idiocy, I program in Fortran, Cobol, even Assembler to avoid that mess. Oh, and buffer-overruns have been a serious security problem for years now. Well what a f****** surprise.

      --
      Mielipiteet omiani - Opinions personal, facts suspect.
    10. Re:Powershell by Anonymous Coward · · Score: 0

      Not him, but apparently you are. The GP said "Also the bash trait of not liking spaces before or after an '=' and the obscure error it gives." and he showed that it doesn't. Which part of that are you struggling with?

    11. Re:Powershell by angel'o'sphere · · Score: 4, Informative

      C was designed to be a portable assembler.
      In assembly it is very common to reuse the "register flags" that get set after an assignment.
      E.g. the famous and simple strcpy function in C (a two liner plus signature) is in 68k assembly also only a two liner:

      loop:
            move.b (A0)+, (A1)+
            bne loop

      The loop runs until a zero value is moved.

      izeof(string)
      That does not return the size of a byte but the size of a pointer as a string is a pointer 'char's. Seems you missed the existence of the strlen function.

      - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?
      Well, age old argument. Basically a matter of taste or sadly a historical "evolution".
      Modern languages like Java and C# allow arbitrary long strings and store ofc the size.
      In older times we only had the Pascal world, where the first byte indicated the size of the string and the C world where a zero byte terminated the string.
      Other 'worlds' like Fortran and Cobol only had fixed sized strings and padded the end of the string with blanks.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    12. Re:Powershell by MightyMartian · · Score: 3, Informative

      Powershell is just enough like Bash to make me groan after ten minutes and ask "Why the f--- didn't they just make an integrated Bash shell?"

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    13. Re:Powershell by i.r.id10t · · Score: 2

      PHP does the same/similar, but the === checks not just the data contained but the data type since PHP uses untyped variables.

      So

      $a=$b assigns the value in $b to $a
      $a==$b returns true if the value contained is the same.
            $a="1"
            $b=1
      $a==$b returns true

      BUT... given
            $a="1"
            $b=1
      $a===$b is FALSE since one is stored as a string and the other as an integer

      Which kinda makes sense for a language that has untyped variables.....

      --
      Don't blame me, I voted for Kodos
    14. Re:Powershell by Fwipp · · Score: 1

      For assignment, not comparision.
      $ useful_var="so good"
      $ second_var ="no good"
      bash: second_var: command not found
      $ third_var= "oh no"
      bash: oh no: command not found

      It makes sense if you know how bash works, but it's definitely a gotcha to newbies.

    15. Re:Powershell by Anonymous Coward · · Score: 1

      Powershell pipes objects, not strings. Everything in powershell is an object, making it very, very, VERY different from most other shells.

      ie: if you wanted to list all files larger than a size, you'd get all files in a directory, which would return to you a list of file objects, with properties and methods like in any other language. You'd then filter by that property. Fairly different from returning the data as text and filtering it.

    16. Re:Powershell by asmkm22 · · Score: 3, Interesting

      A lot of bash and *nix stuff is in PowerShell, which I think it's the point. I remember the first time I opened a session and instinctively typed "ls" without it giving an error.

    17. Re:Powershell by Vlad_the_Inhaler · · Score: 1

      Both Fortran and Cobol allow you to pass slices of a string to a subroutine or anything else, the syntax is in each case stringvar (x:y) although the meaning of y is different. In Fortran it is (from:to) and in Cobol it is (from:bytecount).
      When I was learning we used Algol68 and - although I have not used it for a good 35 years - most other languages come up wanting when compared.

      --
      Mielipiteet omiani - Opinions personal, facts suspect.
    18. Re:Powershell by Anonymous Coward · · Score: 0

      Holy Jeebus! Where does that come from??

    19. Re:Powershell by LoneTech · · Score: 3, Informative

      - sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string.

      A number of things misleading here, which do stem from C's archaic background: Firstly, sizeof is not a function (those parenthesis are not needed and only make it confusingly resemble a function call), it is a rather special operator both in that it looks like a name and operates on types instead of values. There is no string type at all. There are two types frequently used as strings, char arrays and char pointers; only in the case of the array would sizeof return the storage size (which is larger than the string length, unless you've already encountered a buffer overflow). Otherwise you get the size of a pointer, notably also since arrays cannot be passed around but get translated into pointers. In neither case do you get the size of a character.

      Of course, the more you explain about C the less sensible it appears. ;)

    20. Re:Powershell by Jamu · · Score: 1

      strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

      One advantage to null-terminated strings is that there's typical only one format - well one for each character type at least. For length encoded strings, the format depends on the register size, and the endianness of the platform. Of course C does not enforce the use of zero-terminated strings. Not even for string literals.

      --
      Who ordered that?
    21. Re:Powershell by Anonymous Coward · · Score: 0

      Isn't an "object" just a formatted string of 1s and 0s? Isn't everything just a little smaller than we think it is? Man! This computer shit is heavy! I think I've seen the face of God.

    22. Re:Powershell by lister+king+of+smeg · · Score: 4, Funny

      Powershell is just enough like Bash to make me groan after ten minutes and ask "Why the f--- didn't they just make an integrated Bash shell?"

      Powershell - the ugly the bastard child of Bash and Batch.

      --
      ---Saying gnome 3 is better than windows 8 not so much a compliment as it is damning with light praise.
    23. Re:Powershell by Anonymous Coward · · Score: 0

      If you think those are some of the worst abominations in C, you should really take a look at this particularly disturbing use of the fall-through behavior in case statements: Duff's Device

    24. Re:Powershell by Anonymous Coward · · Score: 0

      - True, but compilers have improved and you actually have to set them to NOT report that situation. It's hardly a problem today.
      - There is no such thing as string in the C language. I know, I know, you are inferring from the word sizeof that you get the char's array length, but that's like presuming scanf will scan bar codes from the side of your machine with a laser. Words have different meanings, and you are meant to RTFM before shooting yourself in the foot (or you might shoot your collegues!).
      - Null terminated strings are such a good idea the world has effectively settled on UTF8 for nearly everything. Disagree as much as you can, but it is actually a good idea if you look at some multibyte alternatives programmers are forced to support to be compilant.
      - Oh yeah, assembler, you avoid the mess of all of the above with it. Obvious troll is obvious. Write me a 3d video shader in Fortran or Cobol please.

    25. Re:Powershell by wonkey_monkey · · Score: 2

      if (a = b) assigns the contents of b to a and executes the code following if b 0.

      It makes sense to me. The statement inside the () gets evaluated, and = is the assignment operator only (which is better than forcing it to double up as comparison operator, isn't it?). For return value, what else could it return?

      --
      systemd is Roko's Basilisk.
    26. Re:Powershell by slazzy · · Score: 1

      All equality operators and not created equal.

      --
      Website Just Down For Me? Find out
    27. Re:Powershell by Anonymous Coward · · Score: 0

      Well:

      const char foo[] = "hello";
      const char* bar = "hello";

      sizeof foo; // 6, i.e., length of string including NULL terminator
      sizeof bar; // size, in bytes, of a char* (4 on 32 bit platform, 8 on 64 bit platform)

    28. Re:Powershell by Anonymous Coward · · Score: 1

      Simula FTW.

      I was required to use it in school (obviously long ago) for one assignment in a "survey of languages" course. Little was said about it, but it was instantly obvious to me that the general paradigm made a lot of sense. Of course it was 15 years into my professional career before I got to use an OO language (C++ in that case) on the job (mostly in server development).

    29. Re:Powershell by Anonymous Coward · · Score: 0

      But you can always use strlen to get the length of the string (it just may not be as efficient as sizeof applied to arrays).

    30. Re:Powershell by makq · · Score: 1

      Are you sure that we did not settle on UTF8 because of C, ASCII assuming legacy code and null terminated strings? With those in place, UTF8 makes sense. When stuck in a crappy situation, it may have been the best alternative?

    31. Re:Powershell by VGPowerlord · · Score: 3, Insightful

      - sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string. Who the hell thought that would be a good idea?

      Hey, just because you don't know the language doesn't mean it's necessarily wrong. Documentation for sizeof would have told you that it's for telling you the size in bytes of datatypes on a particular system. It's often paired with malloc to allocate memory for something.

      The C specification is remarkably lax on the size of its numeric datatypes, too. To the point where eventually a bunch of bit-specific sizes were introduced because the basic versions weren't. example: uint32 is a 32-bit unsigned integer, where as uint is an unsigned integer that's 16-bits or larger depending on the platform.

      For that matter, even pointer size changes depending on systems. For instance, it's 4 bytes for 32-bit Intel systems and 8 bytes for 64-bit Intel systems.

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    32. Re:Powershell by itzly · · Score: 2

      - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

      Zero termination is simpler, and more flexible. Also, it avoids having to choose the appropriate number of bytes for the size field. Besides, if you want strings with size field, it's simple enough to implement that yourself.

    33. Re:Powershell by Bacon+Bits · · Score: 5, Interesting

      Two reasons:

      1. POSIX environments have already been done on Windows, and they universally suck. SFU/Interix is shit. Cygwin is shit. MKS Toolkit is shit. MinGW/MSYS, which does a better job than any of them, is mostly shit. Even UnxUtils, which is just binaries modified for use with the actual Windows cmd shell are mostly shit. There are so many fundamental differences of philosophy that make working with a Windows system as though it were a POSIX system fundamentally untenable. You're stuck with mostly just munging text files in a binary world.

      2. Powershell is what .NET developers think Windows administrators want in a shell. That's why you're allowed to do stuff like import .NET assemblies and use essentially unmodified C# code, but there's still no native SFTP client or server.

      Powershell is about 90% of what an administrator actually wants in a shell, and it's actually not that bad. Compared to cmd.exe or VBscript it's balls out fantastic. However, an administrator shouldn't need to learn about .NET objects to be able to write a script, and they shouldn't feel like there's such a fundamental separation between what the shell can do with .NET piping and what executable programs can do. There's a very real encouragement to make everything in Powershell written in and with Powershell exclusively. Like no calling of a binary to do something unless you have no other choice. The shell and the community philosophy very much discourage that... for no real reason other than it's more difficult to get a .NET object out of a binary file and manipulate it with arbitrary .NET methods. I've seen people re-implement a command line zip program with [System.IO.Compression] instead of just using 7z.exe. Why? Just so they can use .NET objects that they never do anything with.

      Honestly I really love Powershell, but I wish the philosophy were geared more around getting shit done than getting shit done with .NET.

      --
      The road to tyranny has always been paved with claims of necessity.
    34. Re:Powershell by Anonymous Coward · · Score: 0

      All of these are actually really good examples of good, flexible language design. The if (a = b) thing is one of the things that bites everyone on the arse once, but it is also very useful in some situations. Especially if you are doing things like "if (a = functionCall() )" and you want to do an assignment and test at the same time.

      NULL terminated strings is also very useful in a lot of cases. Compare C's method to Pascal's. In Turbo Pascal you could never have a string longer than 255 bytes. That is a pain when dealing with large lines of text. C, on the other hand, will let you allocate massive arrays to load in entire documents of text. Pascal's way has better error checking, but C is much more flexible and powerful. This is why Pascal is a great teaching language while C is used in so many more places.

      I've coded in just about anything from COBOL to Assembler to PHP and I think the above exampels are things C does pretty well. There are plenty of things C doesn't do nicely. Weird usage of "const" comes to mind. Most compilers won't warn when really sketchy code is compiled either, but that is more of an implementation issue than a language quirk.

    35. Re:Powershell by i+kan+reed · · Score: 1

      No, an object has the rather important distinction of carrying behaviors along with it.

    36. Re:Powershell by __aaclcg7560 · · Score: 1

      I read somewhere that Powershell came about because the Microsoft programmers didn't want to rewrite the command shell. Refactoring old spaghetti code isn't as sexy as writing new spaghetti code.

    37. Re: Powershell by Anonymous Coward · · Score: 0

      So are most thingies. WOW 'THINGIES' is in my spell checker !

    38. Re:Powershell by rmstar · · Score: 2

      Of course, the more you explain about C the less sensible it appears. ;)

      It's funny, really.

      Quote:

      both in C and certainly in C++, it is uncommon to see a screenful containing only well defined and conforming code.

      That's what proper language design is supposed to avoid. Oh well.

    39. Re:Powershell by brokenin2 · · Score: 1

      I don't think that bash really has it.. It seems like it does, but at least on most systems I've used, that's part of the program "test".

      "Test" usually has a symlink to it under the name "[" which is actually what you're running when you type something like "if [ 5 -eq 7 ]"... Note.. the program "test" ignores any parameter of "]" making them completely optional most of the time..

      It sure looks like syntax, but I think that "[" is just like any other character in bash.. "if" is just testing the return value from the program "["..

    40. Re:Powershell by Anonymous Coward · · Score: 0

      It's pretty odd, if you're discussing a programming language.
      But powershell is descended from the command prompt trying to use = or | or > in the command line causes all sorts of escape character issues.
      Powershell throws it out the window and falls back on what makes the most sense for a command line, - lead command line options. So it does feel really odd, especially if you've been coding in C# all day, but it makes perfect sense if you've ever fought with trying to get a .BAT file to behave.

    41. Re:Powershell by UnknownSoldier · · Score: 1

      > if (a = b) assigns the contents of b to a and executes the code following if b 0. Who the hell thought that would be a good idea?

      There are indeed times it is useful but I 100% agree, using the _same_ syntax as assignment was full retard. They should of used:

      :=

        to tell the compiler, yes, I know that I am assigning inside an if statement -- a programmer couldn't accidently use it by mistake then.

      i.e.

            if( a := b ) { // do true logic
            }

      I know one game shipped with buggy AI because somebody forgot to use two equal signs inside an if statement!

      The other part of the problem was that stupid compilers didn't warn about an assignment inside an if statement.

      The C/C++ community doesn't have a clue about standardizing compiler warnings, errors, and pragmas.

    42. Re:Powershell by david_thornley · · Score: 1

      both in C and certainly in C++, it is uncommon to see a screenful containing only well defined and conforming code.

      Really? Whoever writes that crap, please don't apply here. We write good C++ here, and enforce it with code reviews.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    43. Re: Powershell by i+kan+reed · · Score: 1

      A. Yes, thingies is a word.
      B. Most "thingies" don't bear behavior with them. A series of 1's and 0's doesn't bear any sort of self interpretation.

    44. Re:Powershell by luis_a_espinal · · Score: 1

      And bash having it is precisely why powershell has it. They wanted to capture every bash user as instantly friendly for neo-dos, and stole as many nix commands as they could. I haven't actually tried, but I have this suspicion that a fair number of bash scripts would just work in powershell.

      Oh my god, this post hurts to read. Powershell scripting is nothing like Unix shell scripting in general (and Bash scripting in particular). Completely different beasts, syntactically and semantically. It's like suggesting PL/SQL scripts would work when executed by a Python interpreter.

    45. Re:Powershell by luis_a_espinal · · Score: 1

      Two reasons:

      1. POSIX environments have already been done on Windows, and they universally suck. SFU/Interix is shit. Cygwin is shit. MKS Toolkit is shit. MinGW/MSYS, which does a better job than any of them, is mostly shit. Even UnxUtils, which is just binaries modified for use with the actual Windows cmd shell are mostly shit. There are so many fundamental differences of philosophy that make working with a Windows system as though it were a POSIX system fundamentally untenable. You're stuck with mostly just munging text files in a binary world.

      2. Powershell is what .NET developers think Windows administrators want in a shell. That's why you're allowed to do stuff like import .NET assemblies and use essentially unmodified C# code, but there's still no native SFTP client or server.

      Powershell is about 90% of what an administrator actually wants in a shell, and it's actually not that bad. Compared to cmd.exe or VBscript it's balls out fantastic. However, an administrator shouldn't need to learn about .NET objects to be able to write a script, and they shouldn't feel like there's such a fundamental separation between what the shell can do with .NET piping and what executable programs can do. There's a very real encouragement to make everything in Powershell written in and with Powershell exclusively. Like no calling of a binary to do something unless you have no other choice. The shell and the community philosophy very much discourage that... for no real reason other than it's more difficult to get a .NET object out of a binary file and manipulate it with arbitrary .NET methods. I've seen people re-implement a command line zip program with [System.IO.Compression] instead of just using 7z.exe. Why? Just so they can use .NET objects that they never do anything with.

      Honestly I really love Powershell, but I wish the philosophy were geared more around getting shit done than getting shit done with .NET.

      Powershell can get anything done for automating things on Windows, but I sure wish they had done a better job defining the syntax and the cmlets. Seriously, that is some convoluted, dirty shit going on right there. So bad that at times I've considered IronPython a better, more modular alternative (in some circumstances obviously.)

      OTH, I do like Powershell's ability to integrate with .NET. That really helps automating certain things when developing, delivering and customizing complex turn-key solutions in Windows. At least that has been my experience, and quite naturally YMMV.

    46. Re:Powershell by SecretAsianMan · · Score: 1

      As a fluent PowerShell and bash user, I would bet money that PowerShell was designed by some poor sot from the Visual Basic team after watching a 15-minute presentation on bash.

      --

      Washington, DC: It's like Hollywood for ugly people.

    47. Re:Powershell by The+MAZZTer · · Score: 1

      < and > are used for input/output redirection so they used -gt and -lt. Not sure why they didn't just use = for equals but they might have wanted to just be consistent?

    48. Re: Powershell by jader3rd · · Score: 1

      Given that most PowerShell scripting is developed against live environments it seems necessary to be very explicit that you want to do a comparison instead of an assignment. A mistake we've all made in C. = and == are just too close to each other.

    49. Re:Powershell by KingMotley · · Score: 1

      OR maybe it had it because DOS and CMD had a similar operand (EQU)

    50. Re:Powershell by BasilBrush · · Score: 1

      Hey, just because you don't know the language doesn't mean it's necessarily wrong.

      And just because you do know it doesn't make it right. Just because a language operates according to it's documentation isn't any evidence that it wasn't a bad feature idea.

      It's often paired with malloc to allocate memory for something.

      So to allocate a string you have to multiply sizeof with strlen and add 1 for the null terminator? This kind of nonsense should have been obsolete decades ago.

    51. Re:Powershell by BasilBrush · · Score: 1

      Zero termination is simpler, and more flexible.

      And far slower, more buggy and more insecure.

      Also, it avoids having to choose the appropriate number of bytes for the size field.

      Pointer sized means that you couldn't handle a longer zero terminated string in memory anyway.

      Besides, if you want strings with size field, it's simple enough to implement that yourself.

      Heck implement all the rest of a language too and you won't have to put up with C at all.

    52. Re:Powershell by Anonymous Coward · · Score: 0

      - if (a = b) assigns the contents of b to a and executes the code following if b <> 0. Who the hell thought that would be a good idea?

      It's a matter of taste. Many languages have it, not just C. If you find it too confusing to have = mean assignment instead of equality, that's up to you, but most current languages do use = for assignment and ==, === for (kinds of) equality. That an assignment statement is also an expression is a good thing IMO. I find this construct very useful, but if you find it confusing you can just say a = b; if (a) instead. When I use it I write if (a= b) (note the missing space) as a hint that it's actually b that is getting evaluated, and a is just a variable to save its value for further use.

      Your other two points are indeed WTFs, they are eliminated in most modern languages.

    53. Re:Powershell by Anonymous Coward · · Score: 0

      It makes even more sense if you understand Unix shells in general. It's not a Bashism (not that I assumed you thought so, but I think proper terminology is important to prevent cargo culting). It's a by product of Unix shell syntax, including Bourne, Korn, and Csh flavors.

      The shell syntax is really quite simple. The most recent POSIX specification is here: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

      Note that that page usually displays in the main frame of an HTML document with 3 frames. It's much easier to navigate the framed version.

      Anybody who programs in a Unix environment, regardless of language, should either have the online POSIX specification bookmarked, or should have downloaded a local copy (you can download the entire HTML version). It's free either way, although you're supposed to create an account on the Open Group website, which is also free. The specification cuts through 80% of the cargo culting on forums such as Stack Overflow, and _should_ be the primary goto source for questions of any self-respecting programmer in a Unix environment.

      It saddens me that such a useful, free resource is so poorly used by the masses. POSIX has done wonders for portability and consistency. Even if someone is just a stubborn Linux-only developer who doesn't understand the value and relative ease in portability (particularly wrt to bugs, because different environments exercise corner cases differently) the POSIX specification is still more concise and easier to navigate than local man pages. It's easier to jump around and understand the grander scheme of things. And FWIW Red Hat and the glibc project in particular have been extremely active in the POSIX committee. In fact, most of the interfaces added since 2008 come straight from glibc, for better or worse. (IMHO BSDs often have better designed APIs than GNU because they tend to be more carefully thought out and subject to the consensus of a small community, plus only get adopted by other BSDs if they prove worhwhile, whereas GNU APIs are usually one-offs by individuals--smart, but still individuals--such as Stallman, Drepper, or McGrath, and so subject to their sometimes peculiar preferences. But at least the standard is evolving forward, and the BSDs are implementing the standardized GNU routines without much complaint.)

      The BSDs, OS X, AIX, Solaris, HP-UX, and Linux are all compliant or nearly compliant to POSIX 2001 aka SUSv3 Issue 6. Almost without notice POSIX has made obsolete 90% of the portability horror stories passed down from the 1980s and 1990s. And everybody is moving toward compliance with POSIX 2008, with OS X perhaps moving the slowest.

    54. Re:Powershell by Darinbob · · Score: 1

      A botched Batch of Bash.

    55. Re:Powershell by rmstar · · Score: 1

      We write good C++ here, and enforce it with code reviews.

      So you do but you don't? Very good, my friend. Very good.

    56. Re:Powershell by Darinbob · · Score: 1

      Right, trying to be fully POSIX in a broken Windows environment is really hard. But they could have had sh compatible scripting done trivially.

      The godawfulness of Powershell (hint, I don't know that much about it but get my brain into knots trying to decipher it) is that it wants to be able to script the use of libraries and APIs, whereas most command line scripting languages are all about scripting commands. That may be ok for other scripting languages which aren't intended to be used from the command line (python, ruby, etc), but for something with the word "Shell" in it, PowerShell is amazingly clumsy to use for quick off-the-cuff scripts. If it wanted to just be another scripting language not intended for interactive use, then it should not have put "shell" in the name.

      Seriously, for all the problems in Cygwin at least it works and is invaluable to getting actual stuff done on Windows in a sane way.

    57. Re:Powershell by Darinbob · · Score: 2

      I thought 'test' in Bash is built in, whereas in older shells it relied on the Unix command 'test'.

    58. Re:Powershell by chispito · · Score: 1

      Comparing PS and Bash isn't really fair. Your tolerance or affinity for either will probably equal your tolerance or affinity for the OS. If you believe in the Unix philosophy bit about flat text, you're probably not going to be impressed with PS's object orientation (though PS can do flat text just fine).

      For my part, I would love to learn bash, but my job doesn't really involve any *nix. PS came easy because I already needed a better way to work in Windows.

      --
      The Daddy casts sleep on the Baby. The Baby resists!
    59. Re:Powershell by Anonymous Coward · · Score: 0

      > myvar = 1
      myvar: command not found
      > myvar= 1
      1: command not found

      obviously, bash loves white spaces before and after '='.

    60. Re:Powershell by nine-times · · Score: 4, Insightful

      You know, I kind of hated Powershell until I was forced to use it.

      I still hate it. But then I have to write a bash script, and I run across some specific problem while writing a bash script, and find myself thinking, "This would be easier in Powershell." So that's something.

      It's really not like Batch files, though. It really isn't that bad of a scripting language.

    61. Re:Powershell by nyet · · Score: 1

      if (ret = fun()) printf ("fun failed, ret=%d\n", ret);
      Now, of course most compilers warn you when you do that...

    62. Re:Powershell by NoOneInParticular · · Score: 2

      One of my favourites in C:

      int* a = ...
      2[a] = 5;

      Not sure if this is still allowed by the latest standards, but it used to work.This makes use of the fact that the bracket operator x[y] is syntactic sugar for *(x+y). So:

      a[2] = *(a + 2) = *(2 + a) = 2[a]

      Now try that somewhere else!

    63. Re:Powershell by Anonymous Coward · · Score: 0

      It is old skool unix test compatible.

    64. Re:Powershell by Bigbutt · · Score: 1

      I used a program called Megabasic back in the mid 80's that used paren'd colons to slice up a string.

      [John]

      --
      Shit better not happen!
    65. Re:Powershell by MightyMartian · · Score: 3, Interesting

      Apart from anything else, what I truly dislike about Powershell is how verbose it is. Perhaps it's my *nix heritage, but I like tidy little mnemonic commands like "mv", "rm" or "grep". Less typing, less things to wrong when you're writing scripts. I also find the syntax rather awkward. It's far better than the alternatives (like vbscript or jscript with WMI), but it's still a long ways away from what I would consider a decent scripting language.

      Actually, the worst part of about Powershell is how awfully slow it is. I'm sure that is because it's basically an interface sitting on top of .NET. The *nix shells are, for the most part, self-contained binaries, so bringing up a Bash script is very fast. But then again, sh and its descendants aren't trying to create a "do it all" environment, but rather create control structures and variables to expand upon existing *nix commands.

      I wrote a Powershell scriptlet a few months ago to dump Exchange 2010 mailboxes based on some criteria. Works like a charm, and like I said, despite my dislike of Powershell itself, I'm very grateful that it exists. But loading the Exchange scriptlets library takes something 10 to 20 seconds, and you can see Powershell nailing system resources like crazy to get to that point.

      While its roots, or at least its inspiration, are the Unix shells, in very important ways, it ignores key Unix principles. It is indeed what Bash would work like if it had been written by Microsoft.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    66. Re:Powershell by LanceUppercut · · Score: 1

      `sizeof(string)` never "returns the length of a single byte".

      `sizeof(string)` evaluates to the byte-size of `string` object. E.g. it evaluates to the full size of the character array, if `string` is a character array. Or it evaluates to the byte-size of a pointer, if `string` is a pointer.

    67. Re:Powershell by MightyMartian · · Score: 2

      Compared to other scripting languages (I'm thinking Bash, Python, heck even Perl), yeah, Powershell kind of sucks. But compared to the incredible hacks that had to be used a decade ago to do scripting on Windows servers, it's a 1000% improvement. But, at the end of the day, it has to be one of the worst scripting languages I've ever used.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    68. Re:Powershell by LanceUppercut · · Score: 1

      There's no dedicated feature in C language that makes specifically `if (a = b)` possible. Your `if (a = b)` example is just a side effect of the fact that `=` operator in C behaves just like any other operator: it has a result and it can have side-effects. This is perfectly logical and useful way to design an operator.

      You decided to make an `if` that depends on the result of `=` operator? Yeah, you can do that in C, but if you don't like it - it is your fault. Don't like it? Don't do it! Blaming it on the language is like hitting your thumb with a hammer and then blaming it on hammers.

    69. Re:Powershell by Anonymous Coward · · Score: 0

      C - all of the power of assembly, combined with all of the portability of assembly.

    70. Re:Powershell by Darinbob · · Score: 1

      Remember some of those early languages were designed when keyboards were a lot more painful to use. Some people actually preferred "="/"==" in preference to ":="/=" as being much easier to type.

      Then again you could get mistakes even if "=" is test for equality, as in a statement written "a = 1" by mistake instead of "a := 1", but does not give a syntax error as it's legal (an expression is also a statement in C and many languages). So to be really safe you need ":="/"==", but at the point people think it's too verbose.

      Strings terminated by 0 is common sense. Strings with physical size is ALSO common sense. Both ideas have their merits and flaws. There is no right answer here! Which is best depends upon which operations you do and which combinations of operations are done. Ie, knowing the length of a string extremely quickly is good, but if you're also going to be operating on every character of the string (as in string comparisons) then it doesn't save you any time. Similarly, counted strings limit the maximum length of your strings (early languages would have one character only as length which was a severe limitation).

      Buffer overruns are a problem indeed but when the first goal of the language was efficiency then it's always left to the programmer to write correct code. Enforcing array lengths at run time can be big performance hit and increase the size of the code. With this attitude, I'm surprised you use assembler where the programmer is allowed to make all sorts of mistakes.

      sizeof("somestring") returns 11, not 1. Whereas sizeof(char*) returns the size of the pointer, not 1.

    71. Re:Powershell by Anonymous Coward · · Score: 0

      - if (a = b)...
      If you really want to complain, complain about the ASCII code table not having a left arrow character. Originally it did have that - UNFORTUNATELY, it was replaced in the standard with the underscore (_). Since there was no character available for an assignment, and the closest one was =, guess what got used... Pascal/Algol on the other hand, decided to use :=. Sort of reasonable... except that the := digraph was originally meaning "is defined to be". Which is not an assignment.

      In math, the "=" doesn't mean assignment either - it means "is equal to"... which is not an assignment either...

      But the lack of symbols meant that FORTRAN (that other "first language") used "=" for assignment. And nearly every language since has followed.

      - sizeof(string).
      You missed it. Sizeof is not a function. It is compiler directive that retrieves the number of bytes of a storage unit, which could be a byte, integer, array, structure.... To get the length of a string, use strlen (or preferably strnlen).

      - strings terminated by a binary zero rather than their physical size
      It goes back at least to the PDP-8, and likely back to the PDP-1, but I've never programmed the PDP-1.

      In PAL-8 the ASCIZ in assembler used a packed format in a 12 bit word -

      first byte: 8 bits left justified, first word (so shift right 4 places).
      second byte, 8 bits left justified, second word (so shift right 4 places).
      Third byte: low order 4 bits first word, shifted left 4 places, low order 4 bits second word, added to the 4 bits from the first word.

      If any byte come up zero you were done.

      Since the machine started with only 4K 12 bit words, every bit was important, so no storing of a string length.

    72. Re:Powershell by Darinbob · · Score: 1

      UTF8 is certainly better than wide characters. Multibyte makes a lot of sense. Easy to get number of characters, easy to get number of bytes with strlen, easy to copy with strcpy, no endianness issues to deal with. The only fault really is that it's Unicode so you get the political wrangling.

    73. Re:Powershell by next_ghost · · Score: 1

      - if (a = b) assigns the contents of b to a and executes the code following if b <> 0. Who the hell thought that would be a good idea?

      Somebody who thought that adding unnecessary special cases to otherwise very simple and straightforward language was a bad idea. And he was absolutely right.

      - sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string. Who the hell thought that would be a good idea?

      First of all, sizeof is a compile-time operator. The compiler replaces it with a fixed constant which indicates how many bytes are needed to store the argument (which is either a symbol or another constant) in memory. If you pass a pointer, you'll get the size of the pointer (4 bytes on x86). If you pass a statically allocated array, you'll get the total size of the array (int foo[9]; sizeof foo; will give you 36 on x86). If you pass a constant, you'll get the total size of the given constant in memory (sizeof "foo bar baz"; will give you 12). But all of that happens at compile time.

      When foo is a variable of simple type or instance of structure, sizeof tells you the size of foo itself. But when foo is a pointer, you want sizeof to tell you the size of some completely unrelated block of memory? The fact that foo can point somewhere to the middle of the memory block makes the idea even more ridiculous. Now tell me, who the hell would ever think that making sizeof behave inconsistently like that is a good idea?

      - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

      Somebody who realized that zero-terminated strings have the lowest possible overhead for the most common string operations. Both from the machine's point of view and from the programmer's point of view. And it also avoids artificial limits on string length (Pascal's 255-byte strings say hi!).

    74. Re:Powershell by david_thornley · · Score: 1

      Lisp has various equality operators, such as eq, eql, equal, equal-p, =, string-=, string-equal, char-=, and char-equal. I'm not sure I got all of them. In general, the longer the operator name in a given type, the more things will compare equal (except that eql is a combination of the = versions of the others, plus things ruled equal by eq).

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    75. Re:Powershell by spitzak · · Score: 2

      Null-terminated strings were considered superior to using a length because they allowed strings to be > 255 bytes long (using 16 bits for the length would allow longer counted strings, but at that time with 4K of memory nobody in their right mind would suggest wasting a byte like that!).

      Null-terminated strings also have the nice property that getting the "tail" is a very fast operation, since you just return a pointer to the middle. This meant that searches could return strings, rather than indexes. This then meant that every function that worked on text only needed one argument, a string, rather than two (a string and an index). The savings due to this were pretty significant.

    76. Re:Powershell by beelsebob · · Score: 1

      What you just wrote is a strong indicator that you have no clue how much undefined behavior you have in your programs, and just happen to be getting away with just now.

    77. Re:Powershell by Anonymous Coward · · Score: 0

      Null-terminated strings were considered superior to using a length because they allowed strings to be > 255 bytes long (using 16 bits for the length would allow longer counted strings, but at that time with 4K of memory nobody in their right mind would suggest wasting a byte like that!).

      2 bytes? In 8 bit era, some considered even 0-termination to be a waste of precious limited space and used (char&0x80) as string termination test, which can be simply translated to "jump if negative" when treated as signed 8 bit.

      Here's Sinclair BASIC, for example.

    78. Re:Powershell by pubwvj · · Score: 1

      "- strings terminated by a binary zero rather than their physical size." ...
      "I program in ... Assembler to avoid that mess."

      I take it you never never worked in tight memory situations of the early processors. Just about everything people cite as example has an explanation related to the environment it occurred in. Very evolutionary. Things make sense when you understand the context. If you try you might.

    79. Re:Powershell by WalrusSlayer · · Score: 1

      Hey, just because you don't know the language doesn't mean it's necessarily wrong.

      And just because you do know the language doesn't mean it's necessarily right!

    80. Re:Powershell by Anonymous Coward · · Score: 0

      I'm not convinced you've ever used Powershell. It is an abortion, most of the commands look like:

      GetWMISelectionObject._Interface[0] | Select -Property $whatnow | Select-Skip -1 | ConvertTo-Csv -anotherobscureflag

      Powershell feels like a Windows programmer (as opposed to computer scientist) looked at Unix, decided "I want to do incredibly complicated things too", and crapped out all his thoughts in one long stream, aided by 3 lb of Taco Bell and a bag of gummi bears.

    81. Re:Powershell by Anonymous Coward · · Score: 0

      I personally don't even think about .net while using Powershill, excuse me, Powershell. My ancient text file dependent cmd-scripts turned into Powershell scripts with rather minimal effort thanks to the Powershell ISE and the online help. The greatest gotcha for me was with using the parentheses correctly, an issue warned about in the Powershell help quite visibly.
        That 7z avoidance might be something to do with an acute case of open source installation ban -syndrome.

    82. Re:Powershell by solidraven · · Score: 1

      Compilers actually started reading code though :(

    83. Re:Powershell by Aardpig · · Score: 1

      Video shader in Fortran? Check, done that.

      --
      Tubal-Cain smokes the white owl.
    84. Re: Powershell by Anonymous Coward · · Score: 0

      As a windows admin I really like powershell, and the ability to add blocks of .net has been helpfull if say you want to script the creation of exchange 2003 accounts which don't have native cmdlets.

      The thing that drives me nuts is the inconsistency amount cmdlets. Some are really full featured and others are like school projects done at the last minute.

    85. Re:Powershell by Anonymous Coward · · Score: 0

      You've got your head up your ass. You can't "terminate" a string with the string length. A space is ASCII 32. if the 33rd byte is value 32, is that saying string length is 32, or that this character in the string is a space?

    86. Re:Powershell by Anonymous Coward · · Score: 0

      > Powershell is what .NET developers think Windows administrators want in a shell.
      Well, certainly not this .NET dev! PowerShell feels like a gimp'ed .NET language with a insanely weird syntax (-eq ? seriously?) and which also makes using .NET objects far too hard and overly complicated for nothing (god forbid you even think about using LINQ!) while also not being good at interoperating with other tools. The only reason it gets used at all is Exchange. Even VBScript is a lot less cryptic despite the VB syntax, more powerful for many "custom" things, and a LOT more entrenched.

      scriptcs is MUCH better in every way! It's far more powerful and a lot easier to read. Install via chocolatey :)

    87. Re:Powershell by david_thornley · · Score: 1

      I've studied the language pretty well. I've read the Standard enough to know that a lot of stuff is well defined, and when I go through the program, I see only constructs I recognize as defined (or implementation-defined, or unspecified, and we won't write code that depends on anything unspecified).

      Okay, one caveat. We don't check for integer overflow, although I'm pretty sure it almost never happens. I know where and how we use integers.

      It is possible to write conforming C++ programs. It isn't always easy.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    88. Re:Powershell by dlingman · · Score: 1

      a[2] = *(a + 2) = *(2 + a) = 2[a]

      You're missing a ; at the end. Other than that, an optimizing compiler should notice that you're assigning something to itself, and make that entire line go away...

    89. Re:Powershell by nine-times · · Score: 1

      Out of curiosity, can you explain what's so bad about it?

      Honestly, I thought it was awkward and confusing until I got used to it, and then it seemed... not so bad. Is it really bash itself that's so good, or is it tools like awk, grep, and sed?

      Because Powershell has some nice little things built-in like parameter validation for function parameters, and extremely simple XML parsing, without even using other tools. I'm not much of a programmer, but for my purposes, I can sometimes write simpler and more readable code in Powershell than I know how to do in Bash-- I usually often write my scripts in Ruby because I feel like my complex Bash scripts become unreadable to me. I'm curious what, from a real programmer's point of view, is so bad about Powershell?

    90. Re:Powershell by kenshin33 · · Score: 1

      size of IS NOT a function. it is a unary OPERATOR that get's replaced at compile time not at runtime by the size in bytes of what ever you passed to it (generate assembly of simple code using size of and you'll see that it sizeof(int) gets replaced by the constant 4 but as of C99 if the operand is a variable length array things get complicated as it will compute the size at runtime, so the assembly code is way more complicated )

    91. Re:Powershell by Tom · · Score: 1

      C is for grown-ups. It is solidly based in the same core assumption as the Unix commandline: That the user knows what he's doing and the system shouldn't try to know better.

      if (a = b) is crazy useful and I'm most happy that PHP retains this convention. I use it all the time because it does the same but is much more readable than

      a = fopen("filename.ext");
      if (a) {
      ...
      }

      sizeof tells you what you ask it, and if you ask it about a pointer (strings are pointers in C), then it will tell you about the pointer because it assumes that is what you want to know and if you'd wanted to know the length of the string, you would've asked for the length of the string via the strlen() function, for example.

      String termination as well is an example of doing only what is needed, revealing how close C still is to assembler. Not doing nonsense like manipulating counters that may never be needed is one of the reasons C is fast.

      Kids grew up with this idiocy, I program in Fortran, Cobol, even Assembler to avoid that mess.

      You program in Cobol and talk about mess? This ranks high in the top list of crazy things I've heard on /.

      --
      Assorted stuff I do sometimes: Lemuria.org
    92. Re:Powershell by Anonymous Coward · · Score: 0

      - if (a = b) assigns the contents of b to a and executes the code following if b <> 0. Who the hell thought that would be a good idea?

      Smart people. Things like if ((c = getchar()) != EOF) are very useful. When the left side is an lvalue, as in your example, modern compilers will warn you.

      sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string.

      You got the name right, but everything else wrong ... it's not even a function, it's an operator, and it will return the length of string (including the terminating NUL) if it's an array. If it's a pointer, it will return the size of the pointer ... how odd that something called "sizeof" would do that. To calculate the string length, use strlen. It's not the language's fault that you don't know how to use it. Hey, who the hell thought that it was a good idea to put a sharp blade on a kitchen utensil? That's so dangerous!

      strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

      Smart people who wanted to be able to point into the middle of a string.

      I program in Fortran, Cobol, even Assembler to avoid that mess. Oh, and buffer-overruns have been a serious security problem for years now. Well what a f****** surprise.

      That statement wouldn't be nearly so foolish if you hadn't put Assembler in there.

    93. Re:Powershell by Anonymous Coward · · Score: 0

      Yes, and are not all those "behaviors" determined by strings of 1s and 0s? You're stuck in high level abstractions.

    94. Re:Powershell by rmstar · · Score: 1

      I've studied the language pretty well. I've read the Standard enough to know that a lot of stuff is well defined, and when I go through the program, I see only constructs I recognize as defined (or implementation-defined, or unspecified, and we won't write code that depends on anything unspecified).

      Or, put another way, you have spent a very large number of hours to master this stuff. This is a failure of language design, as it is known that you can write languages that do not require such a high time investment.

      It is possible to write conforming C++ programs

      I don't think anyone is disagreeing with you on this point. The critique is that is needlessly difficult. Even an expert has a bad day now and then, and when that happens, in C++ he is exposed to a much larger number of pitfalls and traps than in other languages.

    95. Re:Powershell by chiguy · · Score: 1

      a[2] = *(a + 2) = *(2 + a) = 2[a]

      You're missing a ; at the end.

      Other than that, an optimizing compiler should notice that you're assigning something to itself, and make that entire line go away...

      I think he meant that as equivalence instead of assignment, but I'm not sure.

      --
      passetspike!
    96. Re:Powershell by spiralx · · Score: 1

      Nope, it's actually heavily influenced by Perl of all things, one of the guys who created it has also written a book on PS which has various sidebars about the design of the language.

    97. Re:Powershell by BadDreamer · · Score: 1

      When strings are built from a chunk of data and a piece of metadata denoting their length you run the risk of heartbleed style bugs in all code, everywhere. You run into issues of how to handle when the string actually is one length, and the metadata says it's another - especially when the metadata says it's longer.

      Zero terminated strings is a damn good idea for cases when computing power and memory are limited, or where performance matters more than solid string performance, such as in kernels and embedded programming. Yes, when you develop a business process middle layer they're a liability, but if you're doing that in C you've got bigger problems.

    98. Re:Powershell by psmears · · Score: 1

      The compiler replaces it with a fixed constant which indicates how many bytes are needed to store the argument (which is either a symbol or another constant)

      No, it can be any expression or any type. Doesn't have to be a symbol, and doesn't have to be constant.

    99. Re:Powershell by Anonymous Coward · · Score: 0

      You are correct. Pipes work very differently in PowerShell than bash. PowerShell pipes carry objects, not text. Despite the Unixy aliases, bash scripts will not work in PowerShell.

    100. Re:Powershell by next_ghost · · Score: 1

      Ah, yes, of course. Thanks for the correction.

    101. Re:Powershell by dcpking7700 · · Score: 1

      Too right, Tom - C is definitely for grown-ups!

      RTL/2 was fun. There waere two commands - CODE and RTL - between which you could write plain assembler code. It only compiled if you used the right compiler switch! You could also do things like copying a Char to and In to find out which char it was by ansi number if you used that magic compiler switch!

      Least-used feature in a language?

      Has GOT to be the FORTRAN keyword in C, which allows you to embed FORTRAN inside a C program !

      Mike
      --
      You have the right to remain sentient. If you give up that right you shall be elected.

    102. Re:Powershell by smellotron · · Score: 1

      So to allocate a string you have to multiply sizeof with strlen and add 1 for the null terminator?

      Since you specifically mentioned strlen, I can tell that you are doing the wrong thing. It is guaranteed that sizeof(char) == 1, so you can skip the sizeof. And then instead of allocating strlen(x)+1, you could use the standard function strdup .

      Aside from this particular example, what is your beef with sizeof? Do you know an alternative for compile-time size calculations?

    103. Re:Powershell by Anonymous Coward · · Score: 0

      I think you missed the proper place to use C, and from whence it came.

      I imagine you had to see why the single-equals assignment was done; I don't know if you've looked, but the behavior was based on the coding it replaced. Look at it a different way: it let you do that behavior, but you probably wanted a == for most of your comparisons. Yes, that leads to mistakes in novices, which is not to judge you as a novice, but to acknowledge that any language with something risky, well, poses a risk in experienced engineers as well. I'm not trying to be negative.

      The sizeof() operator is really about size, not length. You were asking about the size of a character-pointer probably. Did you expect any answer other than the size of a pointer? If you were looking for the length of a string, you might have wanted to use strlen(), which is a function named after the length of a string. I'm not trying to be a dick, but pointing out that size vs length are differentiators that -- in other languages -- are moot. Also, other languages have complex types wherein the length of the string is within 4 bytes of the size of the entire variable instance.

      And that brings us to strings terminating by marker rather than length. I think what you prefer is the "Pascal" method, which might have been the first algol-like language with length/data encoding of strings very similar to setup messages in SS7. If you consider though the size-vs-length issue, even a string with one byte for length has a size unequal to its length by one, and that's a nuance that might continue to trip you up in the future.

      FWIW, the "=" assignment gave many of us the habit of reversing our booleans: if (0 == x) { ...} ... this is not to say that it's needed, but it's a habit that shows "yes, I checked, and I really do mean a constant-comparison" so that whomever edits our code later sees that there's no mistake made.

      These odd habits, and others, will pop up from time to time, and are often based on having started coding in that world before Pascal, before C#, Java, C++, etc, where filesystems had VMT-like jump-tables before there was object-oriented complex types.

    104. Re:Powershell by shutdown+-p+now · · Score: 1

      PowerShell is really more of a bastard child of Bash and C#.

      (Rumor has it that the coupling was so unnatural that the prodigy is sterile.)

    105. Re:Powershell by flargleblarg · · Score: 1

      Documentation for sizeof would have told you that it's for telling you the size in bytes of datatypes on a particular system.

      s/bytes/chars/

      example: uint32 is a 32-bit unsigned integer,

      s/uint32/uint32_t/ (unfortunately)

    106. Re:Powershell by flargleblarg · · Score: 1

      They should of used:

      :=

      s/of/have/

      I know one game shipped with buggy AI because somebody forgot to use two equal signs inside an if statement!

      That's not C's fault. That's the developer's fault for ignoring the compiler warning about it. (Or for not having enabled the warning.)

    107. Re:Powershell by BasilBrush · · Score: 1

      It is guaranteed that sizeof(char) == 1, so you can skip the sizeof.

      I see that it is in C99. But it wasn't when I was learning C in the 1980s.

      Since you specifically mentioned strlen, I can tell that you are doing the wrong thing.

      Well I don't use C strings at all, except in the infrequent occasions I'm using a C library from Objective-C that uses them.

      Aside from this particular example, what is your beef with sizeof? Do you know an alternative for compile-time size calculations?

      Sure. Don't use a language that encourages pointer calculations. If you're working in the kernel or hardware drivers maybe. But for applications C is probably the wrong tool.

    108. Re:Powershell by smellotron · · Score: 1

      I see that it is in C99. But it wasn't when I was learning C in the 1980s.

      Well! I'll get off your lawn now. I learned on C99, I did not know that the guarantee was new.

      Don't use a language that encourages pointer calculations. If you're working in the kernel or hardware drivers maybe.

      That is hardly an argument against sizeof as a language feature. I think we both agree—outside of the first learning experience—developers who are getting tripped up by sizeof should't be using C in the first place; but it is not the fault of the language or a misfeature.

    109. Re:Powershell by Shirley+Marquez · · Score: 1

      Embedded assignment in C came from a different era - one when both computers and compiler technology were much more limited. Using it made it possible to generate more efficient code for the common sequence of operations where you want to calculate a new value and both save it and make a test based on it.

      Let's look at the code that a naive compiler would produce for two hypothetical sequences. (These are given in a simple hypothetical assembly language, but the examples are representative of what real code would have looked like. Details such as which register was used, relevant to the PDP-11 but not to many of its predecessors, are omitted.) First, the straightforward one without embedded assignment:
      a=b
      LOAD A
      STORE B
      if (a)...
      LOAD A
      BEQ NOTA
      (code that follows the comparison)
      NOTA: (code after the if)

      Next up, the code generated when the conditional assignment is used:
      if (a=b) ...
      LOAD A
      STORE B
      BEQ NOTA
      (code that follows the comparison)
      NOTA: (code after the if)

      The redundant load operation is now gone, yielding a 25% reduction in code size and execution time for this test on computers that were in use when C was invented.

      The original implementations of C had to run on computers that were hopelessly limited by modern standards; a typical configuration would be a PDP-11 with 16K bytes of memory. To put that into perspective, that is less powerful than the microcontroller that runs your neighborhood traffic light. Any decent modern C compiler will recognize the unnecessary load and optimize it out unless a is declared volatile, a declaration that didn't exist back in the early days of C because there was also no such thing as register variables, let alone compilers that would automatically promote some variables to that status. But the compiler that ran on that 16K PDP-11 did not perform that optimization, and attempting to add that capability to the compiler would have resulted in something too slow to be usable.

    110. Re:Powershell by Anonymous Coward · · Score: 0

      I have coded in C for 35 years and I have not once had a problem with the things you mention. The reason for the designs is speed and predictability.
      - Of cause the if statement works that way? Why should it not? And there are warning levels for people who cant code and wants to try it anyway.
      - You are wrong, sizeof() returns the size of the pointer. What else should it do? Are you really complaining that it to much work to find out how a function works before you use it?
      - Well written null terminated string handling will work 100% of the time. Automagic string handling... not so much.

      C is NOT designed for amateurs, it never was and it never will be.

    111. Re:Powershell by UnknownSoldier · · Score: 1

      That was back in the 90's, there was _no_ compiler warning. That was the problem. :-/

    112. Re:Powershell by denis-The-menace · · Score: 1

      http://batsh.org/

      No this IS.

      "Batsh is a simple programming language that compiles to Bash and Windows Batch. It enables you to write your script once runs on all platforms without any additional dependency."

      --
      Obama's legacy: (N)othing (S)ecure (A)nywhere and (T)error (S)imulation (A)dministration
    113. Re:Powershell by flargleblarg · · Score: 1

      Ok, so it's the developer's fault for not using lint then.

      :-)

    114. Re:Powershell by Anonymous Coward · · Score: 0

      sizeof is a compile time evaluation and string is just a pointer.

    115. Re:Powershell by david_thornley · · Score: 1

      Well, yes. I've put in a lot of work learning C++, and so have many of my colleagues. The fact that this is necessary to write good C++ is indeed a fault of the language, but we do have what are in general conforming C++ software. I don't know how many other C++ shops can reasonably make that claim.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    116. Re: Powershell by Anonymous Coward · · Score: 0

      Not Invented Here, that's why.

  2. a fucking slideshow? by Anonymous Coward · · Score: 5, Insightful

    Posting a slideshow on Slashdot? Lame. What, was Buzzfeed not available?

    1. Re:a fucking slideshow? by Anrego · · Score: 4, Insightful

      I don't even bother with infoworld links any more. It'll be a bunch of slides with a sentence of text, an unrelated image, and ads everywhere (ads on the slides, ads before the slides, an add in the middle of the slideshow, and an ad at the end). Content wise, usually they find one or two interesting things, then fill the rest of the slots with stupid shit everyone already knows.

    2. Re:a fucking slideshow? by Anrego · · Score: 1

      * itworld (reading another post where they messed it up, so I messed it up!)

    3. Re:a fucking slideshow? by Tukz · · Score: 3, Insightful

      And not only that, the slides slides to advertisements WHILE YOU'RE READING THEM!
      Closed the tab at that point.

      --
      - Don't do what I do, it's probably not healthy nor safe. -
    4. Re:a fucking slideshow? by Anonymous Coward · · Score: 0, Insightful

      Posting a slideshow on Slashdot? Lame. What, was Buzzfeed not available?

      second this. I'm not going to click 12 times for a couple paragraphs worth of information.

    5. Re:a fucking slideshow? by amicusNYCL · · Score: 4, Insightful

      That was my experience. I opened the page, clicked Next past the intro slide, saw a picture of apples and oranges, some text talking about "+" in Javascript, clicked Next again, it faded out to show an ad that I blocked, and I closed the page. Bunch of crap.

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    6. Re:a fucking slideshow? by Anonymous Coward · · Score: 1

      "8 annoying programming features, plus 2 you've never thought of!" "Developer posts annoying language features, you won't believe what happens next!"

    7. Re:a fucking slideshow? by QuietLagoon · · Score: 2

      I don't even bother with infoworld links any more....

      Earlier this week I removed ComputerWorld from my bookmarks. They just went through a site redesign, and the page content has dropped dramatically, plus there's an automatic slideshow scrolling horizontally on the top of your screen as you're trying to focus on and read something else on the page.

    8. Re: a fucking slideshow? by Anonymous Coward · · Score: 0

      Sorry, which language were you referring to?

    9. Re:a fucking slideshow? by fustakrakich · · Score: 1

      itwbennett...

      C'mon folks open your eyes..

      --
      “He’s not deformed, he’s just drunk!”
    10. Re:a fucking slideshow? by smartkid88 · · Score: 1

      I don't even get to see the intro slide. All that loads is a broken empty kind of shell with no content.

    11. Re:a fucking slideshow? by Anonymous Coward · · Score: 0

      That would explain why the slideshow failed to load at all for me running NoScript. Even after I enabled the hosting site and likely CDN sites, it still wouldn't load, and everything that was left was either a tracking site or an ad site.

      Almost as unacceptable as banks running ads from outside sites after you've completed secured login.

    12. Re:a fucking slideshow? by wiredlogic · · Score: 1

      I didn't see any of that thanks to NoScript. Just a partially rendered layout with no content. If Devs can't get their shit together to make a web site usable without Javascript I move on and find something else to do.

      --
      I am becoming gerund, destroyer of verbs.
    13. Re:a fucking slideshow? by Darinbob · · Score: 1

      With noscript, it takes ages to figure out what to enable to allow the actual text to appear. Everything on these sites is hidden behind a maze of scripts. It's job security for webbies I suppose.

    14. Re:a fucking slideshow? by Darinbob · · Score: 1

      I got it to work by temporarily enabling a set of scripts. When the "ad" came it was blank with only a message saying "click here to resume" :-)

    15. Re:a fucking slideshow? by Anonymous Coward · · Score: 0

      I was very curious to see these slides, even for a laugh. But itworld's webpage had 16 cookies or more, 15 from outside of their site. I played cookie roulette for a bit but no slideshow. Can someone please post this on pastebin, 4chan, buzfeed or someplace where you can see the slides without web-invasion dramas?

    16. Re:a fucking slideshow? by Anonymous Coward · · Score: 0

      I opened and saw nothing where a slide should have been. Checked my chrome scriptsafe and it showed everything was already marked unwanted or distrust. I just closed the tab.

    17. Re:a fucking slideshow? by Anonymous Coward · · Score: 0

      I did the same and left a comment with my feelings.
      Maybe more people could do the same.

  3. Database Identity by Baby+Duck · · Score: 2, Insightful

    It's outdated database security models that cause me the most grief. I don't want jsmith logging in from gatech.edu to be considered a DIFFERENT HUMAN BEING that jsmith logging in from whitehouse.gov. I want to say, there's ONE PERSON, John Smith, username jsmith, who is allowed to login from BOTH domains with the SAME PASSWORD and GRANTS. Nope. Can't do it. Newer versions MIGHT allow you to swap in your own authentication module instead, but NOT the authorization piece, so I'm still screwed!

    --

    "Love heals scars love left." -- Henry Rollins

    1. Re:Database Identity by tompaulco · · Score: 1

      I think it is the opposite of outdated. It used to be that jsmith was jsmith. Now, with all this fancy Windows Authentication, you can be guaranteed no end of hassle. For instance, at my company, our laptops are on a different domain than production, for some sort of security reason. However, one of the database servers is set up with windows authentication, which means, yup, you can't log into it from your laptop. You have to first remote desktop into something on the production domain, and then run SQL enterprise manager from there.

      --
      If you are not allowed to question your government then the government has answered your question.
    2. Re:Database Identity by tepples · · Score: 1

      I want to say, there's ONE PERSON, John Smith, username jsmith, who is allowed to login from BOTH domains with the SAME PASSWORD and GRANTS.

      Same password, yes, that's what OpenID and OAuth-based authentication are for. But why would someone have the same grants on gatech.edu as on whitehouse.gov? Just because you're allowed to manage a professor's presence on Georgia Tech's web site doesn't mean you should be allowed to deface Barack Obama's site.

    3. Re: Database Identity by Anonymous Coward · · Score: 0

      Its either a security measure or a lousy AD implementation

    4. Re:Database Identity by Baby+Duck · · Score: 1

      That's the opposite direction. The user is coming FROM those gatech.edu and whitehouse.gov domains to a third one. It's the third domain you are reading/writing data for.

      --

      "Love heals scars love left." -- Henry Rollins

    5. Re:Database Identity by Anonymous Coward · · Score: 0

      TBH that's just Windows having presentation issues. In email, everybody understands that there's no global jsmith@world, you need something like jsmith@example.com to disambiguate. If Microsoft would have stuck to that standard, things would have been a lot more obvious.

      Oh, and your Windows admins suck too. It makes sense that production doesn't trust dev, but the other way around should be fine. If you have credentials to the production environment, your laptop should be configured to accept them as well. At the very least, you should have a VM on your laptop which is in the production domain - that's a lot easier than a remote desktop.

    6. Re:Database Identity by asmkm22 · · Score: 2

      Maybe I'm missing something here, but why can't you just specify the domain name before the user name when you attempt to login to the database from your laptop?

    7. Re:Database Identity by angel'o'sphere · · Score: 1

      That has nothing to do with windows authentication nor is it fancy.

      If you do it right you have subdomains like: production, prelife, test, development, admin. And firewalls prevent any access from development to prelife or production.
      If you do it really right all hostnames in production are mirrored in prelife and test, or you have another level of subdomains if you need several "test domains".

      If a certain developer needs access to production or prelife he ofc has to go via a special admin "realm" and ofc needs to have a special authentication. That is a no brainer. To sad that it "complicates your live" and you "don't grasp the reason" for it. (Hint: such a connection through an extra 'admin pc' can be automated ... it just likes you connect directly to the host behind it ... ask your sys admin)

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    8. Re:Database Identity by suutar · · Score: 1

      I think it's meant not so much as "this person has the same rights in two different databases" as "this person has the same rights regardless of which ISP he's using to get to this database".

    9. Re:Database Identity by NemoinSpace · · Score: 0

      Because in most production domains logins from IP addresses resolving to the airport bar are restricted by fw rules.

    10. Re:Database Identity by Jane+Q.+Public · · Score: 1

      I'm not sure how that would play out in Postgres, but if you're using MySQL or a variant like MariaDB, you can

      GRANT ALL ON *.* TO 'username'@'*' IDENTIFIED BY 'password';

      Works for me.

    11. Re:Database Identity by Anonymous Coward · · Score: 0

      You can, but Microsoft decided to put three pieces of information in two fields. They can't even get something as basic as logging into a system right. I still find Windows IT people that don't know to put the domain (sigh, another source of confusion since Microsoft tried to change the definition of that word) name in the login box followed by their typical assbackwards slash. The last IT director here would login to one domain with his laptop and the other with his desktop. He'd have to go back to his desk to work on the production domain and couldn't access anything in the corporate domain from his desktop. I think he did that for nearly a year before someone finally told him how to switch back and forth.

    12. Re:Database Identity by jrumney · · Score: 1

      Perhaps because the Production domain does not trust the Developers domain? And nor should it. Seriously - developers working directly on the production servers?

    13. Re:Database Identity by asmkm22 · · Score: 1

      If that's the case, just start the SSMS from the command line using "runas /netonly /user:domain\user"

    14. Re:Database Identity by Anonymous Coward · · Score: 0

      He's using integrated authentication - therefore the credentials used are the domain/user of the account which he's using.

      At work we have a rule that admin accounts are only used for db access - joe user accounts don't touch them. Therefore, I'll just use runas to launch SSMS as an admin account. This works OK.

      But this is only good when either (1) both accounts are on the same domain or (2) accounts on the production domain are granted login rights on the laptop domain. Without (2) you wouldn't be able to start SSMS as proddomain\produser.

    15. Re:Database Identity by Anonymous Coward · · Score: 0

      For instance, at my company, our laptops are on a different domain than production, for some sort of security reason

      Dude, seriously, if you can't get past it being "some sort of security reason" you're a fucking moron.

      When your secretary downloads her stupid screensavers and themes, and your sales guys click on every link in their email, do you really want your production machines sharing a network with that level of stupidity?

      In any organization your users are your primary security risk, because they do stupid things.

      You can't trust your staff to be on the same network as your production systems.

      Keeping the users physically separated from the mission critical stuff is a very important thing to do. Especially since you seem to be a Microsoft shop.

  4. Infoworld... pass by Anonymous Coward · · Score: 3, Insightful

    I envision an add filled slideshow with almost no content, and what content is there to be boring and well known so I’ll skip the article.

    To answer the question, most of perl seems to be built around bizarre unintuitive constructs that you just have to kinda know about, so pointing out any of that would seem unfair.

    In C, the first time I saw the size of elements of a struct specified (i.e. int something : 3) it threw me (and that’s a hard problem to google). It was being used to essentially overlay a struct onto a chunk of memory being received via an interface and extract values, which was actually kinda a cool use of the feature (though a comment woulda been nice unknown dev!).

    Some of the type erasure mechanics of Java can be a bit confusing the first time you hit up against them.

    The way javascript does dates, and timezones

    I dunno, most languages have their weird bits, but I can’t think of anything that is egregiously terrible.

    As far as tools, I'd say pacman (Arch's package manager) and git (yes, I'm an SVN fanboy) have the highest concentration of "the hell were they smoking" flags and usage instructions. Pacman seemed to pick it's arguments randomly, and git seems to go straight off the deep end if you want to do anything non-trivial.

    1. Re:Infoworld... pass by sconeu · · Score: 1, Informative

      In C, the first time I saw the size of elements of a struct specified (i.e. int something : 3) it threw me

      Considering that you misunderstand/misunderstood the syntax, I'm not surprised.

      It's not saying it's a 3 byte int, it's saying it's a 3-bit field.

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    2. Re:Infoworld... pass by Anonymous Coward · · Score: 0

      .. that should be interpreted as an int .. where did I imply I thought it was in bytes (I may have made that assumption at the time, but I get/got how it worked.. )..

    3. Re:Infoworld... pass by marcosdumay · · Score: 1

      From the GNU C manual (in the section about bit fields):

      You can also specify a bit field of size 0, which indicates that subsequent bit fields not further bit fields should be packed into the unit containing the previous bit field. This is likewise not generally useful.

      I guess now I have a new favorite C feature... Well, as soon as I actually understand what this means.

      Also, GCC accepts empty structs, and they use no memory! I should look at the C specs more often.

    4. Re:Infoworld... pass by xvan · · Score: 1

      That's also used by the CMSIS for ARMs ... There, struct pointers are pointed to the pheripherals registers memory map, so you can make calls like TIMER->value.

    5. Re:Infoworld... pass by angel'o'sphere · · Score: 1

      Actually he did not mention bytes but only "size".

      But I guess many C/C++ programmers never digged (how is that spelled right?) into it, so your comment is likely welcome.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    6. Re:Infoworld... pass by stderr_dk · · Score: 1

      The way javascript does dates

      Are you talking about getYear() being years since 1900 or something else? You might want getFullYear() or getUTCFullYear().

      and timezones

      Javascript only does UTC and "whatever timezone the browser is using". If you need other timezones, you'll need a third party library (such as this shameless plug).

      --
      alias sudo="echo make it yourself #" ; # https://pipedot.org/~stderr & http://soylentnews.org/~stderr
    7. Re:Infoworld... pass by AdamHaun · · Score: 1

      C's bit fields are a really helpful feature in embedded programming. Unfortunately their implementation is strongly tied to the target CPU architecture. In particular, the endianness of the fields cannot be redefined in code, and bit fields are usually not allowed to cross word boundaries.

      --
      Visit the
    8. Re:Infoworld... pass by lgw · · Score: 1

      In C++, empty classes are a nice thing because they can' be a useful trick for overloading. (Instead of passing an enum to select function behavior at runtime, you pass an instance of a content-free class to select function behavior at compile time.) Not sure what the point would be in C - you can give a type to an arbitrary pointer, and do strongly typed enums that way?

      --
      Socialism: a lie told by totalitarians and believed by fools.
    9. Re:Infoworld... pass by Menkhaf · · Score: 1

      I'm not a native English speaker either, but it's past tense, so I believe it should be "dug". English is weird (but not any weirder than German with their unrecognizable genders or Danish with en/et)...

      --
      A proud member of the Onion-in-Hand alliance
    10. Re:Infoworld... pass by angel'o'sphere · · Score: 1

      Ah, you are right, 'dug' but the damn spelling correction did not provide that as a possible solution, I'm getting old!
      Thanx :)

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    11. Re:Infoworld... pass by DrJimbo · · Score: 1

      In C, the first time I saw the size of elements of a struct specified (i.e. int something : 3) it threw me (and that's a hard problem to google). [...] (though a comment woulda been nice unknown dev!)

      The first hit from Google(struct) is the Wikipedia(struct) entry which starts with:

      A struct in the C programming language (and many derivatives) is a complex data type declaration that defines a physically grouped list of variables to be placed under one name in a block of memory, allowing the different variables to be accessed via a single pointer, or the struct declared name which returns the same address. The struct can contain many other complex and simple data type in an association, so is a natural organizing type for records like the mixed data types [...]

      Furthermore, I really don't think a comment should be used to explain a language element that is clearly defined in The C Programming Language (K&R) by Brian Kernighan and Dennis Ritchie. A C programmer should assume the reader is familiar with what is in K&R, otherwise the comments become a language tutorial.

      As for Perl, once I really learned Perl I found it to be extremely intuitive. It is a very powerful and very expressive language. All of the sigils (and related "line noise" characters) make the code much easier to read and they make it extremely trivial to define and understand complicated data structures. Larry Wall, the creator of Perl, got an undergraduate degree in natural and artificial languages and then went on to do graduate work in linguistics. The Wikipedia says:

      Wall's training as a linguist is apparent in his books, interviews, and lectures. He often compares Perl to a natural language and explains his decisions in Perl's design with linguistic rationale.

      Your comment about Perl seems to boil down to the fact that it is different from languages you are familiar with and you never bothered to learn it so it makes no sense to you. Your gripe about the C struct element seems to be similar, like everyone else in the world, you have trouble reading languages you are not familiar with. I have the same problem with Russian and other languages I have never learned.

      BTW, have you ever noticed that nuclear missiles tend to be only targeted at countries that use a different alphabet? Perhaps it is only a coincidence but I think it may be related to your problems with Perl, an oversimplification that equates foreign with bad.

      --
      We don't see the world as it is, we see it as we are.
      -- Anais Nin
    12. Re:Infoworld... pass by Anrego · · Score: 1

      Furthermore, I really don't think a comment should be used to explain a language element that is clearly defined in The C Programming Language (K&R) by Brian Kernighan and Dennis Ritchie. A C programmer should assume the reader is familiar with what is in K&R, otherwise the comments become a language tutorial.

      I generally agree that comments shouldn't be required to explain language mechanics unless they are obscure (which the bitset stuff isn't, I mean if you've never run into them they might be, but that would be the same for any language construct and as you said, you generally assume a developer is going to know the language they are working with).

      What I personally would generally include would be a comment along the lines of "this struct represents the KillAllHumans message body as per <some specification;>" where the struct is defined, and then a comment along the lines of "overlay our message structure over the buffer to extract our data". This way even if someone wasn't familiar with the bitset notation, they could probably infer it.

      As for Perl, once I really learned Perl I found it to be extremely intuitive. It is a very powerful and very expressive language. All of the sigils (and related "line noise" characters) make the code much easier to read and they make it extremely trivial to define and understand complicated data structures. Larry Wall, the creator of Perl, got an undergraduate degree in natural and artificial languages and then went on to do graduate work in linguistics.

      Perl... easy to read... ok back to your room now ;p

      I'll grant you that perl is very organic, probably the best "code as you think" language that I know of, but the vast collection of syntax and the functional density one can achieve (and some seem compelled to do so) makes it a pain to read if you didn't write it.

      I've read the camel book cover to cover, and at one point I was fairly good with it, but after a few years of neglect that skillset has completely dissolved. I have a feeling if I tried to do anything with it now, I'd be hitting up google for things like "how do you iterate through an array of hashmap references".

    13. Re:Infoworld... pass by DrJimbo · · Score: 1

      What I personally would generally include would be a comment along the lines of "this struct represents the KillAllHumans message body as per " where the struct is defined, and then a comment along the lines of "overlay our message structure over the buffer to extract our data". This way even if someone wasn't familiar with the bitset notation, they could probably infer it.

      I agree, comments are for the information you add, although well thought out variable names go a long way to making code understandable:

      /* as per some specification */
      struct KillAllHumans_Body {
      ...
      }

      I'll grant you that perl is very organic, probably the best "code as you think" language that I know of, but the vast collection of syntax and the functional density one can achieve (and some seem compelled to do so) makes it a pain to read if you didn't write it.

      I am not disputing that it is easy to write obfuscated Perl but Perl style guidelines have come a very long way with Perl Best Practices by Damian Conway and the Perl::Critic module and the perlcritic program. There is a lot of Perl code written by other people that I find very easy to read. The key is to write clear code and use good variable and function names. The sigils provide context (and higher information density) which is what makes good Perl code easier to read than good Java or C code. YMMV.

      Gregory Chaitin, one of the founders of algorithmic information theory once said in jest:

      The LISP interpreter is about three-hundred lines of Mathematica code. Then I redid it in C, and it's a thousand lines of C, and the program is incomprehensible, which means that I'm a good C programmer!

      Perl does tempt you to show off by writing incomprehensible (and perhaps incompressible) code. The style guidelines and experience can help you avoid this temptation.

      IMO, the Camel Book is informationally dense. One reading was not nearly enough for me. I probably have read it all at least a half dozen times. I haven't used it in years because it is almost all on-line now and also part of the perldoc system.

      [...] how do you iterate through an array of hashmap references [...]

      for my $hash_ref in (@Array_of_hash_refs) {
      ... $hash_ref->{$key} ...
      }

      IMO, with descriptive variable names this construct is both easy and clear. I think it is beautiful. If you want to access just one element then use:

      $Array_of_hash_refs[$index]->{$key}

      For nested data structures like this I prefer to make the top level structure a reference so this becomes:

      $Array_of_hash_refs->[$index]->{$key}

      Which I think is a little more consistent.

      I've taught Perl in college and I admit there are some (perhaps many) people who will never master it. OTOH, I once wrote a CSM system in Perl in the time the Java folks said they would need to come up with an estimate for how long it would take them to do it.

      --
      We don't see the world as it is, we see it as we are.
      -- Anais Nin
    14. Re:Infoworld... pass by marcosdumay · · Score: 1

      you can give a type to an arbitrary pointer, and do strongly typed enums that way?

      Strongly typed... C... Those things do not belong in the same sentence.

      The point is probably that there must be some behaviour, and it's better to define it. Thus, they defined. I hightly doubt it has any practical application, besides minimizing the damage in case of some kind of error.

      But yeah, it's amusing.

  5. cmp %rdi,%rax by ColonelPanic · · Score: 1

    Goddamn AT&T assembler syntax with its reversed operands. Quick, you want to compare two registers, and jump if %rdi %rax. Which order do you place the operands to the comparison, and what's the predicate to use on the jump? Drives me nuts.

    --
    "Skill shows through where genius wears thin." -Wittgenstein || Religion: uniting aviation and architecture.
    1. Re:cmp %rdi,%rax by bluefoxlucid · · Score: 4, Interesting

      I always liked the target-first approach of Intel. Like strcpy(dst, src). I know I'm mucking with (dst) string, and not doing anything with (src). The same with (MOV %eax, 0xdeadbeef).

      Imagine strcpy(src,dst), which many people would say is more logical because you're saying "Perform a string copy from (src) to (dst)." We say "Copy from source to destination" all the time--it's how we think, right? And then: strncpy(src,dst,32). So with strcpy(), the last argument is the thing we mess with; while strncpy() it's some argument in the middle.

      This is why strcpy(dst,src) and strncpy(dst,src,len) are set: the first argument is the target. These calls immediately tell you what they actually change. printf() changes nothing, but uses the first argument as its format--it emits a modified content of the first argument based on subsequent arguments; sprintf() changes the first argument to a modified copy of the second argument using all further arguments. If something is changed, it's the first things that are changed.

      In Intel assembly, a glance down the left side of the screen rapidly tells you what's roughly going on. You don't need to read the whole line; you just look at opcodes and targets, quickly recognizing which opcodes modify their targets. This immediately tells you flow; and attaching the source data for the modification provides you with logic. This is less decoding than trying to interpret an individual opcode, rearrange it in your head, extract its behavior, extract its logic, and build incrementally with that.

    2. Re:cmp %rdi,%rax by mferero · · Score: 1

      Hear hear! Those of us that learned assembler on the big iron (IBM mainframes) totally agree. Teaching new students to assembler in AT&T format was something I was NOT going to do.

      --
      Honor est omni
    3. Re:cmp %rdi,%rax by GbrDead · · Score: 1

      Or you can use the following argumentation:

      We say "assign the value of b to a" but write "a = b".

    4. Re:cmp %rdi,%rax by bluefoxlucid · · Score: 1

      That doesn't tell anyone why it's favorable to write 'a = [long equation]' than '[long equation] => a'. In mathematics, it's also the ability to rapidly assess flow in long, algorithmic calculations.

  6. coffeescript by iozozturk · · Score: 0

    Indentation syntax is pretty odd

    --
    twitter.com/ismetozozturk
  7. Lua[0]? by ThisIsSaei2561 · · Score: 5, Interesting

    Lua's standard is, for things like arrays, to start counting from 1. The unlearning of old habits made this a hard adjustment.

    1. Re:Lua[0]? by Anonymous Coward · · Score: 5, Funny

      Bookkeepers, shepherds, scientists and mathemaitcians have for centuries counted starting with 1. It is recent computer scientists that started this crazy standard break, as if they knew better how to count.

    2. Re:Lua[0]? by Anrego · · Score: 1

      In general I found it difficult to twist my brain into doing things the lua way.

      It seems to go out of it's way to be slightly different.

    3. Re:Lua[0]? by nicolastheadept · · Score: 2

      I would say it's more a weird feature of C to count from 0 (and everything copied it). Fortran and COBOL count from 1 (in fact, Fortran counts from whatever the hell you want it to)

      --
      09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
    4. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Bookkeepers and shepherds, sure. But scientists and mathematicians?

      http://pad1.whstatic.com/images/thumb/5/58/Read-a-Ruler-Step-1-preview.jpg/550px-Read-a-Ruler-Step-1-preview.jpg

    5. Re:Lua[0]? by angel'o'sphere · · Score: 2

      Most languages start array indices with 1 ... only coming from C later languages that adopted C "syntax" also adopted the start with zero paradigm.

      But of course, habits cause problems. In Pascal you count until 'i == end' in C/Java etc. you count while 'i < end' ... had the same trouble often enough in reverse transition :D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    6. Re:Lua[0]? by Dagger2 · · Score: 1

      That's fairly unusual, but it's not quite as strange as Perl's $[, which you can assign to to select where arrays count from.

    7. Re:Lua[0]? by Uecker · · Score: 2

      there are some reaons why starting with zero might be better:

      http://www.cs.utexas.edu/users...

    8. Re:Lua[0]? by Anonymous Coward · · Score: 1

      Computing uses definitive or absolute numeric values, also known as cardinal numbers. These are typically used to state quantities or identifying values.

      People counting things in their heads for centuries have traditionally used relative-to-nothing numeric values, also known as ordinal numbers. These are typically used to state the order or position of things.

      So a shepherd counting sheep begins by counting the first, then the second, third, fourth, and so on until he has passed each sheep through his field of view or a counting chamber or funnel (there are many ways to do this, but basic gist is that each sheep is counted once, and is in a position in the count order). Then, when he is done, he converts that into a quantity. So everything you've just mentioned starts as an ordinal and is converted to a cardinal at the end of a batch process.

      Computers keeping an array of values are not counting. They're not keeping track of the order as such. They're simply identifying where something is located. At its most basic, an array is a pointer to the first item, and the array index is an offset to add to that pointer to find each item. This is a cardinal (identifying) number sequence, with a cardinal (quantifying) limit. It's pure cardinality. And cardinal numbering is absolute, not relative. You're not differentiating "has an array index" from "doesn't have an array index". Everything in an array has an index, and the array is positioned absolutely at the pointer address, and each item is identified absolutely by its index/offset.

      It's not that computer scientists "knew better how to count", it's that they recognized that counting isn't the answer to this problem.

    9. Re:Lua[0]? by Jamu · · Score: 1

      It kind of makes sense in C, as arrays are basically pointers. e.g. p[i] == *(p + i)

      --
      Who ordered that?
    10. Re:Lua[0]? by Framboise · · Score: 1

      The discussion is not on measuring continuous quantities
        but counting discrete objects. Physicists and mathematicians have indexed, say, vectors, starting with 1 for ages, except in recent times where sometimes they use 0 for very special reason (like chapter 0 in a book).

    11. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Then you don't understand the reasoning behind 0-indexing. It's the natural way to index on a computer since the base address of an array points to the first element of that array. To get to other elements in the array you simpily add the base address with the index. In this context 1-indexing makes no sense because you'd have an unused first element at worst, or have to subtract one off the index before calculating addresses (essentially 0-indexing) at best.

    12. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Obviously, you and I ~= Lua-experts .. all numbers are strings, some string can be numbers, thou shalt not check if a number is a string whilst iterating a table in the C-api. Also being able to compile the damn thing in C++ so it uses exceptions for errors and only later noticing that in fact this means it does a blanket catch(...) leaving the whole thing in undefined state should my code cause an exception (it shouldn't/doesn't intentionally, but suppose it runs out of memory etc on a mobile device? It will quietly fail afaik)

    13. Re:Lua[0]? by Anonymous Coward · · Score: 0

      I'll leave this here: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

      Tables in Lua, overall, was a bit of an adjustment.

      I've been working on a .NET program that uses Lua as an embedded scripting language where I still have some 0-indexed arrays exposed.
      Having to switch between the two keeps you on your toes.

      https://hyperplaneinteractive.com/blog (alpha available by logging in and visiting Account page)
      Screenshots: http://imgur.com/a/p6Obn

    14. Re:Lua[0]? by camperdave · · Score: 0

      Bookkeepers, shepherds, scientists and mathemaitcians have for centuries counted starting with 1. It is recent computer scientists that started this crazy standard break, as if they knew better how to count.

      No. Computer scientists count starting from one, just like normal people. What we do not do is confuse cardinal numbers (which you use for counting) with ordinal numbers (which you use for coordinates, such as the position in an array).

      --
      When our name is on the back of your car, we're behind you all the way!
    15. Re:Lua[0]? by Anonymous Coward · · Score: 0

      That was removed 4 years ago.

    16. Re:Lua[0]? by preaction · · Score: 1

      Deprecated, thank YHWH, in 5.20 or .22. To be removed "not soon enough."

    17. Re:Lua[0]? by david_thornley · · Score: 2

      If I'm counting three things, I say "one, two, three". If I'm counting events, I might count "first, second, third". You'll notice that the first example is cardinal and the second example is ordinal. If things worked like you seem to be thinking, I'd count events "zeroth, first, second".

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    18. Re:Lua[0]? by Anonymous Coward · · Score: 0

      When you have all of the bits off in your register, counting starts at zero, unless you want to add extra silicon/complexity/QA/verification to your chip design process.

    19. Re:Lua[0]? by UnknownSoldier · · Score: 1

      One is an absolute total.
      One is a relative offset.

      i.e.

            *(pArray + 0) = pArray[ 0 ]; // same location

    20. Re:Lua[0]? by The+MAZZTer · · Score: 1

      The math tends to be simpler in many cases if you start counting at 0. In C's case, a[1] is == a + 1 if a is an array of bytes.

    21. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Actually it's for the good reason that the index is an offset, so when a pointer points to the start of a list its first element is at start+0.

      As for 'Bookkeepers, shepherds, scientists and mathemaitcians [sic]'... they actually start at 0. It's possible to have $0.00, 0 sheep etc. Zero is one of the most important numbers in mathematics - the earliest number systems lacked it and were unable to express many ideas as a result, limiting the advance of those societies.

    22. Re:Lua[0]? by Anonymous Coward · · Score: 0

      And, to be fair, this is because they were lazy.

      thing[4] is shorthand for:
      1) go to the memory location of thing
      2) advance 4 times the memory length of type contained in thing

      Since the first element was stored at the memory location of thing, thing[0] was the way to access this location.

      Admittedly, I have grown accustomed to this notation, but I do recognize that its origin is in laziness.

    23. Re:Lua[0]? by Bloke+down+the+pub · · Score: 1

      It's the natural way to index on a computer since the base address of an array points to the first element of that array.

      No, it's the natural way to do it for a computer.

      Isn't it the compiler's job to sort out shit like that?

      --
      It's true I tell you, feller at work's next door neighbour read it in the paper.
    24. Re:Lua[0]? by viperidaenz · · Score: 1

      If you have a list of items that start at an address, what number to you add to this address to get the first one?

    25. Re:Lua[0]? by wiredlogic · · Score: 1

      That and the global scope to variables is why I won't use Lua. Shame, It's a good language other than those warts.

      --
      I am becoming gerund, destroyer of verbs.
    26. Re:Lua[0]? by Half-pint+HAL · · Score: 1

      It's not that computer scientists "knew better how to count", it's that they recognized that counting isn't the answer to this problem.

      That doesn't really tally with what you said. Arrays were originally "pointer+offset". Fine. That was a technical solution in low-level languages. But in high-level languages that are specifically aimed at better matching humans' natural tendencies, counting is the correct answer to this problem.

      --
      Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    27. Re:Lua[0]? by Half-pint+HAL · · Score: 2

      This is not about cardinal or ordinal numbers. Conceptually, to a human being, the elements of an array map to natural numbers. The conceptual difference between 0-indexed and 1-indexed arrays is best viewed as the argument over whether 0 is a natural number or not. I'm in the "not" camp, which says that if it wasn't for low-level languages needing the pointer+offset notation, 1-indexed arrays would be superior as an analogue of the programmer's natural thought process. All of us who code had to learn 0-indexing, and it took a fair bit of time to overcome the unnaturalness of it all. Which is why I consider 0 non-natural.

      --
      Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    28. Re:Lua[0]? by Darinbob · · Score: 1

      This isn't wierd, it's perfectly normal for many languages. Back when C was new it was sort of the oddball by starting from 0. Fortran for example starts from 1. Quite a lot of languages let you choose your own starting index (ie, "array 10..20 of array 1..100 of float").

    29. Re:Lua[0]? by Anonymous Coward · · Score: 0

      In a language that actually has a concept of arrays, I don't.

      Compiler either adds (index-first_index) to array base or index to (base-first_index) for me. With this it doesn't matter if I want to index from 0, 1 or 100.

    30. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Do you mean _default_ global scope? Because Lua most definitely has proper lexically scoped local variables.

      Hell, if you hate them so much, you can even do something (a bit more involved, but) like:
      setmetatable(_G, {
          __index = function(t, k) error('Reading undefined global '..k, 2) end,
          __newindex = function(t, k, v) error('Assigning to undeclared global '..k, 2) end
      })

      and have it scream at you if you access any global not assigned before you ran that snippet.

    31. Re:Lua[0]? by Greyfox · · Score: 1
      You can index negatively in C as well, if you want to.

      If you REALLY want your array to start at 1, why not just subtract one from its pointer? Then it'll start at 1 just fine!

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    32. Re:Lua[0]? by solidraven · · Score: 1

      Lua at least has a standard, can't say the same about Fortran where you just sort of decide whatever the hell you want to use at the time of writing your code. Oh, and you'll just love VHDL where you can make up array indices as you go, no questions asked.

    33. Re:Lua[0]? by T.E.D. · · Score: 3, Interesting

      It is recent computer scientists that started

      Not "computer scientists". Just C programmers. The first two languages designed, Fortran and Cobol, start at 1. Algol('68) and all the languages descended from or influenced by it let the programmer set the starting bound (this includes Ada, Pascal and all the other Wirth languages).

      Pretty much every language that uses 0 as the only allowable starting index is either descended from C, or borrowed large amounts of its syntax from it. (Some BASICs use 0, but that language is so egregiously unstandardized that its tough to say anything about it with certainty).

    34. Re:Lua[0]? by demonlapin · · Score: 1

      Well, crap. Posting to undo accidental redundant mod. This is insightful.

    35. Re:Lua[0]? by rasmusbr · · Score: 1

      The math tends to be simpler in many cases if you start counting at 0. In C's case, a[1] is == a + 1 if a is an array of bytes.

      Yeah, it's usually easier to start with 0 in pure math too. Remember that an N:th degree polynomial can be written as:

      sum from n=0 to n=N of c_n*x^n, where c_n are constants

      Here you avoid having to invent a special case for the constant (zeroth degree) term by exploiting the fact that x^0 = 1.

    36. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Nonsense. Everyone has always started at zero. The bookkeepers, shepherds, mathematicians didn't feel the need to mention zero. They felt that it was obvious. (i.e. I have nothing. Add one sheep. I have one sheep.) But, it's not obvious to a computer. Computer scientists just felt the need to remove the ambiguity.

    37. Re:Lua[0]? by Anonymous Coward · · Score: 0

      Recently had to redo a colleague's VBA excel macro (my second time writing anything in VBA. Wouldn't shed many tears if it was my last). Zero indexing lets you do stuff like the following:

      stuffToWrite = Array("a","b","c")
      firstRow = 15
      column = 4
      for offset in 0 to 2
              Cells(firstRow + offset,column).Value = stuffToWrite(offset)
      next offset

      If we started at one instead you would be looking at renaming that variable rowBeforeFirstRow or headerRow (which could be a little confusing if there is no header row and the first row of this output range is actually the first row of the sheet. headerRow = -1 anyone? :/ ) or having the line be 'Cells(firstRow - 1 + offset,column)...etc' and manually remembering later on (i.e. when reading those values) to do something similar if using array indexes to determine what row is being read (not that uncommon a situation?).

      At least to me it just feels neater to have something called firstRow for me to be able to refer to at this part of the code and later, and to have it be the....first row.

    38. Re:Lua[0]? by david_thornley · · Score: 1

      Most languages do not have a list of items that start at an address, formally, but rather it's an implementation detail and not part of the language standard. C does, and a lot of other languages have picked up on it.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    39. Re:Lua[0]? by Patman64 · · Score: 1

      This is exactly why there's no problem with Lua being 1-indexed instead of 0-indexed. It's not C, so you aren't doing pointer arithmetic on some address. If you want the first element in a table it's index is 1 and the second is 2. The first letter in a string is 1, second is 2.

      If anything, other high(er) level languages being 0-indexed is the oddity. I would imagine it's to make C programmers feel comfortable.

    40. Re:Lua[0]? by viperidaenz · · Score: 1

      Go have a look at Visual Basic.
      It's 1-based, unless you need to interface with any system libraries or other DLL's, then it's 0-based.

    41. Re:Lua[0]? by TeknoHog · · Score: 1

      Physicists and mathematicians have indexed, say, vectors, starting with 1 for ages, except in recent times where sometimes they use 0 for very special reason (like chapter 0 in a book).

      One common example of vector indices is in relativity. Since we traditionally used indices 1 to 3 for spatial dimensions, it made sense to keep them that way. The spatial dimension was given index 0 probably to denote its special/fundamental position (e.g. energy in the energy-momentum vector).

      The traditional programming language of scientists, Fortran, starts its arrays with 1 by default, but it can also be instructed to start wherever you want. For example -n to +n is sometimes quite convenient.

      --
      Escher was the first MC and Giger invented the HR department.
    42. Re:Lua[0]? by TeknoHog · · Score: 1

      The positional argument for starting with 0 makes sense in C, because it's such a low-level language. It makes sense to expose this low-level view on arrays so you can do things like pointer arithmetic.

      For anything higher-level, you'd think the language should make things easier for people who deal with everyday countable items. But even in an otherwise nice high-level language like Python you can find some thoroughly messy array logic, because it basically takes the positional idea even further. While a[0] is the first item, a[0:2] is a range of the first two items, instead of three. The logic is called slices: you start at position 0, which is just before the first item, and end at 2, just after the second one. You've spanned a distance of 2, over the first 2 items.

      --
      Escher was the first MC and Giger invented the HR department.
    43. Re:Lua[0]? by shutdown+-p+now · · Score: 1

      What we do not do is confuse cardinal numbers (which you use for counting) with ordinal numbers (which you use for coordinates, such as the position in an array).

      Last I checked, they still use 1-based addressing for vectors and matrices in math.

    44. Re:Lua[0]? by Salgat · · Score: 1

      But it represents an offset. An index of 0 represents no offset from the start, 1 is a single offset from the start, etc. It makes perfect sense. I'm not saying using 1 as the start doesn't make perfect sense either, it's just a different way of representing the data.

    45. Re:Lua[0]? by alexo · · Score: 1

      It is recent computer scientists that started

      Not "computer scientists". Just C programmers. The first two languages designed, Fortran and Cobol, start at 1. Algol('68) and all the languages descended from or influenced by it let the programmer set the starting bound (this includes Ada, Pascal and all the other Wirth languages).

      Pretty much every language that uses 0 as the only allowable starting index is either descended from C, or borrowed large amounts of its syntax from it. (Some BASICs use 0, but that language is so egregiously unstandardized that its tough to say anything about it with certainty).

      That's because C does not have arrays, they are just syntactic sugar for pointers. array[index] is another way of writing *(pointer + offset)
      Therefore: a[5] == *(a+5) == *(5+a) == 5[a]

    46. Re:Lua[0]? by angel'o'sphere · · Score: 1

      I don't want C++ arrays to start at 1, I either want them to start arbitrary like in Pascal
      myNumbers : Array of Integer [-7 .. +13]
      or at 0, as in Java they start at zero as well ... and I can not do neat tricks there :D

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    47. Re:Lua[0]? by Greyfox · · Score: 1

      Arrays in C++ start at 0. I'm pretty sure you can set a pointer into the middle of the array in C++ and do this by indexing the pointer. I know you can do it in C -- a couple companies ago I deployed something that did that into production code, mainly to keep the design review board on their toes. They weren't, and it got deployed that way. I thought it made more sense that way anyway, so I never mentioned it. It's entirely possible it's already confused the hell out of a code maintenance guy, but hopefully he'll think it makes more sense that way too.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  8. APL: A Programming Language by Anonymous Coward · · Score: 3, Informative

    Requiring a graphics card and special character set to program in the language:

    Because of the unusual character set, many programmers use special keyboards with APL keytops for authoring APL code. Although there are various ways to write APL code using only ASCII characters, in practice, it is almost never done.

    http://en.wikipedia.org/wiki/APL_%28programming_language%29

    1. Re: APL: A Programming Language by Anonymous Coward · · Score: 0

      Yes, but you can invert a matrix with three characters, one of which is a backspace.

    2. Re:APL: A Programming Language by msauve · · Score: 1

      I used to have a Centronics 761 teleprinter with an APL keyboard/charset. I never used it for APL, but it sure looked cool.

      --
      "National Security is the chief cause of national insecurity." - Celine's First Law
    3. Re:APL: A Programming Language by Anonymous Coward · · Score: 0

      how about being able to create your own in-program operators in SNOBOL ?

    4. Re:APL: A Programming Language by Anonymous Coward · · Score: 1

      I used such a keyboard on a DEC teleprinter terminal for APL programming. You have no idea how cool the language is... I had a circuit synthesis class in college a long time ago that required us to write a matrix exponentiation routine. Fellow students were struggling with FORTRAN and the like. It was a one-liner in APL.

    5. Re:APL: A Programming Language by Misagon · · Score: 1

      I find it kind of weird that while APL requires you to use proper symbols from mathematics and various branches of logic (binary, predicate, etc..), it doesn't have operator precedence that we are used to from mathematics and logic.

      Most languages have some cases where the precedence between operators is equal, but in those cases the evaluation order is almost always left to right. In APL, it is backwards: always from right to left.

      --
      "We mustn't be caught by surprise by our own advancing technology" -- Aldous Huxley
    6. Re:APL: A Programming Language by Darinbob · · Score: 1

      When it was new it didn't require stuff that was necessarily weird, because every machine was unique and thus weird. At the time there were lots of unusual keyboards out there. No graphics card required at all, these were just characters and even ASCII characters required special support to be displayed on a CRT. For a teletype you just needed a different type head and no graphics at all.

    7. Re:APL: A Programming Language by tgv · · Score: 1

      And the fact that APL evaluates from right to left. APL is QBASIC on LSD.

  9. question colon by Ken+D · · Score: 2

    Since this operator exists in C/C++, Java and Perl at least, it's hardly obscure

    1. Re:question colon by nedlohs · · Score: 1

      Probably why no one except you seems to think anyone claimed it was.

    2. Re:question colon by Anonymous Coward · · Score: 0

      Ah, continuing the fine slashdot tradition of not even reading the article summary, I see, then criticizing a poster for having done so!

      Let me help: look for the phrase "trigraphs in C and C++" in the summary.

    3. Re:question colon by tanderson92 · · Score: 2

      Since this operator exists in C/C++, Java and Perl at least, it's hardly obscure

      It's called the ternary operator.

    4. Re:question colon by nedlohs · · Score: 2

      ?: is not a trigraph, which should be obvious since it doesn't have three characters in it.

    5. Re:question colon by Anonymous Coward · · Score: 0

      It's right in the summary as "some of the strangest"...

    6. Re:question colon by Ken+D · · Score: 1

      Yeah my bad. Damn slideshow wouldn't run and of course it was after I hit submit that I was thinking "wait.. is that called trigraph or some other cryptic operator?"

    7. Re:question colon by nedlohs · · Score: 1

      Well I stand corrected on the "no one except you" bit. Apparently more than one anonymous coward also doesn't know that tri means three. Or maybe that graph mean character. Or maybe that ?: is only two characters...

    8. Re:question colon by bluefoxlucid · · Score: 1

      A ? B : C;

      ABC, ?:;

    9. Re:question colon by Fwipp · · Score: 1

      Trigraphs aren't ternary operators. Tri-graph roughly mean three-characters, so "??!" = "|".

      If a statement seems obviously wrong, maybe you don't understand it well enough.

    10. Re:question colon by Anonymous Coward · · Score: 0

      Correct. Which is why it is a trinary operator: it has three parts (the comparison, what to do if true, and what to do if false). As opposed to binary operators (two parts; eg, addition), and unary operators (one part; eg, logical not). I think those anonymous cowards saw a word that started with the prefix "tri" and went "squirrel!" before reaching the end, and didn't realize that the English language contains more than one word with that prefix.

    11. Re:question colon by Anonymous Coward · · Score: 0

      The operator is called a trinary, and Brian Kernighan regrets ever putting it into C. He said it was his biggest mistake in C.

    12. Re:question colon by Anonymous Coward · · Score: 0

      The ternary operator. Once you're converted, you don't want to go back. It's like Lisp's (cond x a b) for C. I think of it as a gateway drug into the world of functional programming. I'm sure I made a few maintenance programmers hate me though.

    13. Re:question colon by Quirkz · · Score: 1

      Sadly, ternary doesn't actually start with "tri."

      I think it comes from old Norwegian, based on a decision-making process akin to flipping a coin, except it was throwing rocks at birds, and the decision was determined by which arctic tern was hit first.

    14. Re:question colon by lgw · · Score: 2

      More specifically, trigraphs solve the problem that Stroustrup's keyboard didn't have certain punctuation characters. (OK, a keyboard he used some of the time had this problem, being a Scandi keyboard that replaced odd punctuation with needed letters.) It's not crazy at all to have a conversion from "??!" to "|" when you're writing the language on a keyboard that doesn't have a "|" character.

      I believe that AND and OR are trigraphs for "&&" and "||" too - I always meant to try that, but was too lazy to hunt for the command line switch to enable them.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    15. Re:question colon by Anonymous Coward · · Score: 0

      Hey Dr Wisenheimer, what do you think ternary means?

    16. Re:question colon by 91degrees · · Score: 1
      Unless I missed something, the article was talking about trigraphs rather than ternary.

      The following is valid C (probably)

      ??=define DOUBLE(x) ((x)+(x))

      int func(int i)
      ??<
      int array??(10??) - ??<1,2,3,4,5,6,7,8,9,10??>

      return array??(i??) ??' 0xFF;
      ??>

    17. Re:question colon by david_thornley · · Score: 1

      Technically, it's called the conditional operator, but since it's the only ternary operator in most languages it gets called as such.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    18. Re:question colon by Anonymous Coward · · Score: 0

      Trinary (as opposed to binary) operator

    19. Re:question colon by Anonymous Coward · · Score: 0

      It is strange considering syntax like:

      if(condition):
            foo
      else:
          bar

      The "proper" way for me would be :? instead of ?:

    20. Re:question colon by spitzak · · Score: 1

      In Python you write "a?b:c" as "b if a else c". I think that is pretty obscure, and hard to read too.

    21. Re:question colon by fisted · · Score: 1

      Ternary.

    22. Re:question colon by jrumney · · Score: 1

      Let me help YOU: search for trigraphs on Wikipedia.

    23. Re:question colon by shutdown+-p+now · · Score: 1

      I'll grant you that it is 1) unusual for a PL and b) does not respect order of evaluation. But it is very easy to read. Sans comma, it's almost exactly how you say those things in many natural languages, including English.

  10. The idea of variant (var) by randomErr · · Score: 1

    I understand in some learning languages (Apple ][e flavor of Basic comes to mind) it can useful for beginners. But why have it languages like C#, VB,NET and even JavaScript? It would make everyone's life easier and most code run faster if you pushed your objects to strongly type variables.

    --
    You say things that offend me and I can deal with it. Can you?
    1. Re:The idea of variant (var) by Anonymous Coward · · Score: 3, Informative

      The "var" in C# is not a variant. It's simply a syntactic shortcut to allow the developer to not repeat the type in the declaration if the type can be inferred from the initialization expression. The behavior is identical to C++ "auto".

      var x = 1; // x is an int
      x = "1"; // compiler error, x is an int and cannot be set to a string

      var y; // compiler error, the type cannot be inferred
      var y = null; // compiler error, the type cannot be inferred

    2. Re:The idea of variant (var) by TheDarkMaster · · Score: 1

      Because variants are useful when you want to (or most common, you need to) make a generic function to handle some information where you have no way of knowing if the input parameter will be a string, integer, long, etc. Of course it is slower than dealing with a defined type, but is usually more convenient than trying to create a separate function for each possible entry type.

      --
      Religion: The greatest weapon of mass destruction of all time
    3. Re:The idea of variant (var) by i+kan+reed · · Score: 3, Interesting

      I can tell you why C# has it.

      The normal way intellisense works, you often have to do the end of your line of code then go back to the beginning to type out what type of variable the method you're calling returns now that you know. Var obviates this task by going "oh, of course, it's the type returned by this method".

      As usual with language features, it comes from us developers being very very very lazy people.

    4. Re:The idea of variant (var) by randomErr · · Score: 2

      I realize that but its seems a waste. My point was that you should already know your data types. I like the readability of strongly typed code. You also make you compiler and debugger work extra. On small stuff no big deal. But on large projects those extra compiling seconds can become minutes easily. Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      --
      You say things that offend me and I can deal with it. Can you?
    5. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I like the fact that this is perfectly valid code in C#

      var var = 1;

      as var is not a reserved keyword, merely a contextual keyword.

    6. Re:The idea of variant (var) by ThisIsSaei2561 · · Score: 1
      var var = "binks";

      ...I'm sorry.

    7. Re:The idea of variant (var) by Megane · · Score: 1

      So, in other words, it's just like the new 'auto' keyword from C++, except that C++ re-used an existing keyword so that people who had variables named 'var' wouldn't have to change their code?

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    8. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      Right, so nothing at *all* to do with anonymous types, where you can't actually write the name of the type involved, because it doesn't have one (from a language perspective). I'm sure it's *complete* coincidence that the two features both arrived in the same version.

    9. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      The ddebugger doesn't care at all. It gets the types from the compiler, which figured out the type. And the compiler needs to check types left and right even if you're explicit: int i = " five"; needs to be rejected. It has to compare two types. So, for the "var" case the compiler in fact saves time on not checking for a type error, because it needs to deal with just a single type.

      Note that the "var" code is not an iota weaker. Type safety is not influenced in the least by /how/ a type is spelled out. I could write " System.Object i;" and that would be weak, but that's not "var i".

    10. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I like the readability of strongly typed code.

      Code using var is still strongly typed. It's just *implicitly* typed.

      But on large projects those extra compiling seconds can become minutes easily.

      I very much doubt you've ever measured the difference in compiler performance between using var and not. When you use an explicit type, the compiler still has to check that the actual type is convertible to the declared one... arguably there's *more* work to do with explicit typing, as the name has to be resolved first.

      Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      If code only differs by using var vs explicitly using the type the compiler would have inferred, the output will be identical IL.

    11. Re:The idea of variant (var) by PRMan · · Score: 1

      Yeah, but they just added dynamic. Javascript is all dynamic, and many programmers prefer it.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    12. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      As mentioned previously, the following is perfectly legal C#:

      var var = "binks";

      Why? The "var" keyword is contextual. It can only be used in place of a data type in a local variable declaration. If you named variables or members "var" you were perfectly fine.

      The only case of collision with the "var" keyword would be if you named a type "var" in which case the compiler would go with the type and not the keyword. If you wanted to forbid the use of "var" throughout a project you could add a class "var" under the System namespace.

    13. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      It is also very useful to work with anonymous types. ie:
      var someVariable = new {Id =1, Name = "SomeName" };

      Without the var keyword we wouldn't be allow to access the members of this anonymous type like this:
      someVariable.Name

      This is used extensively in Linq, keeping the strongly typed benefits of C# intact while giving a lot of flexibility.

    14. Re:The idea of variant (var) by tibit · · Score: 1

      "My point was that you should already know your data types." And you do. And the compiler does. It's somewhat silly to have to repeat yourself and type in the type twice. A literal has a fixed, known type, by definition. Types are also known and fixed in other circumstances, such as function return types. This becomes especially handy when a method returns a parametric type that may be hard to write. I've personally written expression template code where the specialized concrete type is a few lines long.

      Do you really claim you'd rater write [4 lines of type] foo = bar(); instead of auto foo = bar()? Even for shorter types, it can be arduous.

      This for (std::vector::const_iterator a = b.begin(); a != b.end(); ++a) vs for (auto a = b.begin(); a != b.end(); ++a)

      --
      A successful API design takes a mixture of software design and pedagogy.
    15. Re:The idea of variant (var) by turp182 · · Score: 1

      Regarding "var": Our C# standard (which is part of a couple of actual standards, iDesign's is one off the top of my head) is as follows:

      Var is only used if it is explicitly clear what the data type is when the variable is defined.

      So these are fine:
      var aString = String.Empty;
      var someVariable = new TypeOfSomeSort();

      The variable should be explicitly declared otherwise:
      string aString = SomeMethodThatReturnsAString();

      Of course I ignore the standard and just explicitly state the type, it's how I've always done it...

      var is handy for non-fetched Linq queries as well. Do a ToString() on it (if it is for a database operation) and you get the SQL that will execute.

      --
      BlameBillCosby.com
    16. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      var var = "binks";

      ...I'm sorry.

      We all are...

    17. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I realize that but its seems a waste. My point was that you should already know your data types. I like the readability of strongly typed code. You also make you compiler and debugger work extra. On small stuff no big deal. But on large projects those extra compiling seconds can become minutes easily. Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      First of all you are confusing strong typing and static typing. The word you are looking for is static typing. Some languages which are strongly typed are not statically typed.

      Secondly, the var keyword is still statically typed. It simply infers types based on the code.
      It is quite helpful and I wouldn't mind if java had it. For example, suppose you want a dictionary with a key of type string and a value of an IEnumerable of Tuples of strings and ints. This:
      var dictionary = new Dictionary>>();

      is much more readable than this:
      Dictionary>> dictionary = new Dictionary>>();

      Although var was introduced to deal with LINQ, which relies on anonymous types, it is very useful for avoiding the unnecessary repetition described above where it is perfectly clear from the initialization what the type is, and static typing is maintained.

    18. Re:The idea of variant (var) by david_thornley · · Score: 1

      The "auto" feature in C++ is similar. There's two problems with "you should already know your data types". First, when using template programming in C++, you don't already know your data types. You're writing the code that will be instantiated with different data types at compile time. Second, data types in C++ can get pretty long to type, and at that point are effectively not read by humans and merely provide a chance to mess up.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    19. Re:The idea of variant (var) by qbast · · Score: 1

      First of all you are confusing strong typing and static typing. The word you are looking for is static typing. Some languages which are strongly typed are not statically typed.

      Secondly, the var keyword is still statically typed. It simply infers types based on the code. It is quite helpful and I wouldn't mind if java had it. For example, suppose you want a dictionary with a key of type string and a value of an IEnumerable of Tuples of strings and ints. This: var dictionary = new Dictionary>>();

      is much more readable than this: Dictionary>> dictionary = new Dictionary>>();

      Check lombok library. It adds implicit typing ('val a=new HashMap();') and lots of other syntactic sugar like auto-setters/getters, autogenerated constructors, extension methods and more.

    20. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      var is still a valid variable name. Heck, it's still a valid *type* name, although that would seriously confuse anyone using it. (Fortunately it was never a *conventional* type name.)

      It's not a keyword - it's a contextual keyword, like select, where, yield, async, await, order etc.

    21. Re:The idea of variant (var) by david_thornley · · Score: 1

      Pretty much yes, as I understand it. In C++, "auto" was already a keyword, so nobody could use it as a variable name, and nobody used it as a keyword, since unspecified variables were "auto" by default, so it was a logical word to repurpose.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    22. Re:The idea of variant (var) by Half-pint+HAL · · Score: 1

      This for (std::vector::const_iterator a = b.begin(); a != b.end(); ++a) vs for (auto a = b.begin(); a != b.end(); ++a)

      Congratulations. You've just highlighted the weakness of the three-argument "for" statement. A weirdness that Google went and made worse in Go.

      --
      Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    23. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I can tell you why C# has it.

      The normal way intellisense works, you often have to do the end of your line of code then go back to the beginning to type out what type of variable the method you're calling returns now that you know. Var obviates this task by going "oh, of course, it's the type returned by this method".

      Oh no, that's not how Intellisense works at all. You should learn how it works though, I see a 110% productivity increase in your future.The var keyword in C# is to support anonymous types, such as:

      var perp = new { User = "i kan reed", WrongnessLevel = 11 };

      Of course a more realistic usage involves LINQ, like:

      var perpPosts =
              from p in slashdotPosts
              where p.WrongnessLevel > 10
              select new {
                      User = p.Uid, // probably unnecessary, can assume == 749298
                      Wrongness = p.WrongnessLevel
              };

      It'd be confusing to only permit the var keyword where anonymous types are allowed, eh? Wouldn't it? Eh little fella? Eh? Of course it would! Of course it'd be confusing! SUCH A GOOD BOY. SUCH. A. GOOD. BOY!

    24. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      var is short for variable, not variant. Almost every new language has that or something like it ... C++ has auto. There's nothing at all weird about it.
      And it's not just about laziness ... with generic programming some types are extremely long and complex and in some languages, like Java, there are types produced by the compiler that can't even be represented in the source language.

    25. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I realize that

      If you realize that then why did you call it "variant"?

      but its seems a waste.

      I do not think that word means what you think it means.

      My point was that you should already know your data types.

      The correct point is called DRY. You should not overcommit.

      I like the readability of strongly typed code.

      I do not think that word means what you think it means. Dynamically typed languages like Python, where there are no type annotations, are strongly typed.
      var appears in statically typed languages like C# and Scala that are also very strongly typed.

      You also make you compiler and debugger work extra.

      I don't think they mind.

      On small stuff no big deal. But on large projects those extra compiling seconds can become minutes easily.

      For type inference? Uh, no.

      Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      Type inference costs nothing in code size.

      Basically, everything you said was wrong, ignorant, and unintelligent.

    26. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      At least in the case of C#, it is mainly used to handle anonymous types returned from LINQ queries. The type doesn't exist until runtime, so you can't specify it. It must be inferred.

    27. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I realize that but its seems a waste. My point was that you should already know your data types. I like the readability of strongly typed code. You also make you compiler and debugger work extra. On small stuff no big deal. But on large projects those extra compiling seconds can become minutes easily. Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      You seem to (still) not get what "var" does in C# (or "auto" in C++.) This feature can only be used when you are initializing your declared value in the same statement, which means there is no ambiguity about the type (and less redundancy, which is A Good Thing and mostly why these languages have this feature after all.) It has absolutely no effect on being strongly-typed. It has no runtime effects or costs. And I really seriously highly doubt that it has any impact at all on the compile time, even in multimillion-line projects (you see, the compiler already has to work out the type of the initializing expression for compile-time type checks; assigning that type to the declared variable would be a piece of cake.)

    28. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      I can tell you why C# has it.
      ...
      As usual with language features, it comes from us developers being very very very lazy people.

      I agree with you, and truer words than your have seldom been spoken; but "var" in C# and "auto" in C++ and equivalent features in other languages also eliminate (some) redundancy, which is always a good thing.

      Also, at least in C++, there are some lambdas that can have types that you cannot write (or know) at compile-time. Also, many a generic code is simpler and easier to read because of "auto" in C++ (without which one would have to write whole scaffolds of types and metadata for which there would be no other use except to name a type in generic code by the programmer (as opposed to the compiler, which would know the type of everything at instantiation time anyways.))

    29. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      There are many statically (and more strongly and strictly, compared to C/C++ etc.) typed languages that use type inference and almost never specify type names explicitly.

      Using objects for everything can cause much more confusion with regard to knowledge of types than using e.g. ML-style sum types.

    30. Re:The idea of variant (var) by shutdown+-p+now · · Score: 1

      "var" is strongly typed code. You're confusing "strongly typed" with "explicitly typed". This:

      >> Also I've had a few cases where when I've done compares on C# compiled code the strongly typed program usually came out smaller.

      Is plainly false - literally impossible - if by "strongly typed" you mean explicitly typed vs var.

      If you're so fond of explicit typing, are you also inserting casts every time you chain function calls? E.g. when you write Foo(Bar()) or Bar().Foo() - note how these also completely omit the return type of Bar; yet everyone is seemingly fine with that. Because the type is there, and it is still checked against the parameter type of Foo. But that is not at all different from:

      var x = Bar();
      Foo(x);

      Except that you give the name to the result of intermediate computation. If you're fine with chaining, then you should also be fine with this.

    31. Re:The idea of variant (var) by shutdown+-p+now · · Score: 1

      In C#, "var" (just like all the other keywords added since v1.0 of the language) is a "context keyword" - in other words, it is treated as a keyword only when it is a position where it can be meaningfully parsed as such, and the grammar is designed in such a way that no old valid code that used "var" as an identifier could have a meaningful interpretation of it as a keyword under new rules. Consequently, the following is perfectly valid C#:

      var var = 0;
      var += var;
      var x = var;

      In fact, if you write it in VS, it will correctly highlight the keyword "var" as a keyword, and the identifier "var" as identifier.

      OTOH, in C++, they have actually reused the existing keyword in an incompatible way. It used to be legal to write something like "auto int x = 0" in C++03 - it was utterly meaningless, and there was no instance where adding "auto" would actually change the meaning of the declaration, so no-one did it - but it was legal, and in theory someone might have done it just cuz, and be broken by C++11.

      C# is actually one of the most backwards compatible languages that I know of. They do occasionally introduce true breaking changes (like foreach loop variable scope in C# 5.0), but this is extremely rare, and most additions are very carefully designed to allow the old code to compile with no semantic changes. Heck, even for breaking changes, it takes them ages to actually decide to change it... e.g. with the foreach change, the problem first appeared in C# 2.0 (when they first added closures, and with them the ability to close over the loop variable), and it took them three major versions to finally bite the bullet and fix it - and even then only after a thorough investigation showed that most code that is affected by the change, is in fact broken code (that people didn't notice is broken) that would be fixed by the change.

    32. Re:The idea of variant (var) by shutdown+-p+now · · Score: 1

      "dynamic" in idiomatic C# is rare, but still very useful for those cases where you do have to interop with some data structure with a dynamic schema (e.g. JSON). But the main reason why they added it was in fact easy interop with COM IDispatch, and dynamic languages like Python or Ruby. So you usually have it at the transitional boundary or at the site where you crack open the data, but from there you stick it into something strongly typed.

    33. Re:The idea of variant (var) by Anonymous Coward · · Score: 0

      It's very useful with Linq expressions. Eg
      var result = from x in objectCollection where x.Length > 2 select x

      foreach(var output in result)
      Console.WriteLine(output)

      Without var I'd have to write to declare result like
      IEnumerable\ result ....

      This obviously only works if objectCollection is a collection of strings but with var I can pass a collection of any types in. It's also very useful if your LINQ expression returns an anonymous type. EG

      var result = from x in objectCollection where x.Length > 0 select new {value=x.Value, count=x.Count}

      Without var I'd have to create a new class just for the result variable! I find var useful when I don't know what class a variable will be or it's awkward to declare an instance of a class.

  11. Perl: TMTOWTDI by i_want_you_to_throw_ · · Score: 5, Insightful

    I used to think that Perl's feature of "There's More Than One Way To Do It" was great until I had to start modifying and maintaining the code of other developers, (several over the years). 20+ years I've been with Perl and I gotta say that through the years this has probably caused me more frustration than anything. Python, comparatively speaking, is a dominatrix and I'm starting to enjoy "There's Only One Way To Do It".

    1. Re:Perl: TMTOWTDI by mark-t · · Score: 2, Interesting

      I think I'd have to agree with this. I never nailed it down to that particular aspect of perl before now, but I can easily see how this characteristic of perl makes it very difficult to identify idioms in the language. With so many ways to do things that you can't always quickly identify what is being done simply by looking at the source code, unless it has been quite rigorously commented.

      Code written in an idiomatic style rarely needs much commenting, because people familiar enough with the language to do what the code needs to accomplish will also be familiar with the idioms in the source code, and in practice, only minute or two of examining the source code fragment is ever necessary, even for code that has never seen before, have a general understanding of what the code is trying to accomplish, even if they do not necessarily understand the bigger picture of how the code is being used.

      Of course, it's entirely possible, and not even particularly hard, to write obsfuscated code in almost any language, but with perl, my experience is that it takes a special kind of discipline to *NOT* write such code, while at least in other languages, in my experience, writing in a readable style tends to require only a modest amount of discipline.

    2. Re:Perl: TMTOWTDI by i+kan+reed · · Score: 4, Interesting

      You just haven't run into another python developer who's "clever" enough yet.

      for a,b,c,d in [x.q for x in y if x.z]+[x.r for x in y if x.z]:
              a.m=b or c and d

      (none of these variables are boolean)

    3. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      Hmm... Now that _is_ clever. I didn't know I could use the boolean operators in Python the way I can use them in Javascript and Bash... Other than that, if your list comprehensions implement a well-defined algorithm (solution to a problem, mathematical operation on sets), it's not too bad.

    4. Re:Perl: TMTOWTDI by tompaulco · · Score: 2

      I used to think that Perl's feature of "There's More Than One Way To Do It" was great until I had to start modifying and maintaining the code of other developers,

      Maintaining the code of others? Heck, I have found in perl, that it was easier to rewrite a program than try to debug it even if I wrote the original program.

      --
      If you are not allowed to question your government then the government has answered your question.
    5. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      "There's only one way to do it" isn't true any more with Python if it ever really was. Getting output from an external program can be done several different ways from several different libraries all of which are terrible. There's the fact that not only is there a urllib, urllib2 and urllib3, 2 and 3 are completely different. Those are just off the top of my head.

    6. Re:Perl: TMTOWTDI by preaction · · Score: 1

      I thought someone would mention "lists" vs. "arrays" in Perl, and how @_ is really just an alias onto the current Perl stack. "list context". Types are declared by the operation being performed, not the data stored in the variable. The fluid definition of "compile time" and "run time" and how you can switch between the two.

      I'm sure I could come up with more reasons I love Perl, but they'd all sound like reasons to avoid it like the plague.

    7. Re:Perl: TMTOWTDI by david_thornley · · Score: 1

      Yeah. I tended to get confused by the fact that, say, element 3 of the array @A (you know A's an array by the "@") (I'm assuming you're over being confused by Perl's use of sigils to show whether a variable is a scalar, a list or array, a dictionary, a typeglob, and I may be forgetting one or two) is $A[3], which is a scalar from the $, and you know it's an array reference and not a dictionary reference because the 3 is inside square brackets rather than curly braces.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    8. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      I think I'd have to agree with this. I never nailed it down to that particular aspect of perl before now, but I can easily see how this characteristic of perl makes it very difficult to identify idioms in the language. With so many ways to do things that you can't always quickly identify what is being done simply by looking at the source code, unless it has been quite rigorously commented.

      Code written in an idiomatic style rarely needs much commenting, because people familiar enough with the language to do what the code needs to accomplish will also be familiar with the idioms in the source code, and in practice, only minute or two of examining the source code fragment is ever necessary, even for code that has never seen before, have a general understanding of what the code is trying to accomplish, even if they do not necessarily understand the bigger picture of how the code is being used.

      Of course, it's entirely possible, and not even particularly hard, to write obsfuscated code in almost any language, but with perl, my experience is that it takes a special kind of discipline to *NOT* write such code, while at least in other languages, in my experience, writing in a readable style tends to require only a modest amount of discipline.

      Jesus! Tell me about it! Try English as the obfuscated language and reread your post (and some others on here). Trying to figure out what people are trying to say when they drop entire words and phrases from their code is so confusing!

      [yeah, that was a wee bit of sarcasm, but seriously! I wish people put as much time into their posts as they (supposedly) do with their code. suspect on the do-with-their-code part]

    9. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      Actually I've always found in all languages, including Python, there's always multiple ways to do it.

    10. Re:Perl: TMTOWTDI by schitso · · Score: 1

      Is it bad that that doesn't look all that confusing to me? Though it seems like having two list comprehensions that are exactly the same save for the property of "x" that they access is inefficient.

    11. Re:Perl: TMTOWTDI by i+kan+reed · · Score: 1

      Seems inefficient, but it's not really possible to reconstruct the exact behavior without more lines of code(i.e. less "cleverness")

    12. Re:Perl: TMTOWTDI by Darinbob · · Score: 1

      I found the Python style to be some what odd myself. Not only is there only one way to do it, but if you actually do it a different way there will be an army of purists to chase you down with tar and feathers. (technically not true, Python has many ways to do the same thing)

      A language with really only one way to do things is in my view, a limited language with no flexibility. Granted better than Perl, but the argument of "but Perl!" is not good enough to justify the rigidity of thinking.

    13. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      Lines of code is often a stupid metric if the lines can be made much simpler... and if the "exact behavior" includes order of evaluation of the x.q and x.r references or the x.q[0] and x.r[0] assignments, the programmer needs to be shot repeatedly with a very slow-moving projectile.

    14. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      I'd really like an example of this. I keep hearing TMTOWTDI is an awful feature of Perl yet people never back it up with examples of what they mean.

      There might be more than one way to do it, but usually only one or two ways are obvious and people are highly apt to choose either of those. It does not mean 'We must code it every way.'

    15. Re:Perl: TMTOWTDI by dotancohen · · Score: 1

      That list comprehension is actually very much the reason why Python is terrific. C# programmers will be familiar with the idea from Linq.

      for: This is a for loop
      a,b,c,d: Each value of the iterator is itself composed of 4 values. In Python this is called a tuple, but you can think of it as an array if it helps. The first value is bound to a, the second to b, etc. Thus, the variables a,b,c, and d are defined in the loop body.
      in: The next thing mentioned is the iterator
      [x.q for x in y if x.z]+[x.r for x in y if x.z]: This iterator is a mess, let's look at it's parts, which are:
      [x.q for x in y if x.z]
      +
      [x.r for x in y if x.z]:

      [x.q for x in y if x.z]: y is an iterator. Return only the q property of each item in y, only if the z property is defined. This results in a list (another Python datatype which you can think of as an array) being return, of q properties.

      [x.r for x in y if x.z]: y is an iterator. Return only the r property of each item in y, only if the z property is defined. This results in a list being return, of r properties.

      +: Combine the list of q properties with the list of r properties.

      Like learning another (human) language, it it incomprehensible at first. However, I'm no Pythonista and even for me it was very simple to figure out what this does.

      --
      It is dangerous to be right when the government is wrong.
    16. Re:Perl: TMTOWTDI by dotancohen · · Score: 1

      Maintaining the code of others? Heck, I have found in perl, that it was easier to rewrite a program than try to debug it even if I wrote the original program.

      I've often heard of Perl being referred to as a write-only language.

      --
      It is dangerous to be right when the government is wrong.
    17. Re:Perl: TMTOWTDI by Anonymous Coward · · Score: 0

      (b and c or d) is the Python precursor to its modern ternary operator (c if b else d); (b or c and d) is somewhat logical if you've seen (b and c or d) enough times (and/or used a language like Lisp where this sort of "non-Boolean things as Boolean logic" stuff was even more common)... As with similar languages the actual bool "type" (more like pseudo-constants in Python) was also a late addition so you quickly get used to the fact that empty lists, zeros, and empty strings are falsy. (A trait shared with other languages like Lisp and JavaScript...)

  12. java events by bumba2014 · · Score: 1

    Java Events, need a whole new class to handle them...

    1. Re:java events by ubersoldat2k7 · · Score: 2

      Not any more with lambdas:


      button.setOnActionEvent(e -> doSomethingWith(e));

    2. Re:java events by bumba2014 · · Score: 1

      still looks strange, but at least an improvement...

    3. Re:java events by viperidaenz · · Score: 1

      or a proxy, or an instance of any class that implements the event listener interface.

    4. Re:java events by shutdown+-p+now · · Score: 1

      Why does it look strange? It's the standard mechanism adopted by every single mainstream PL by now.

      And how would you handle them otherwise? Do you prefer just passing in a function pointer / method reference? You can do it too in Java 8, it would be something like SetOnActionEvent(this::eventHandler).

  13. My keyboard nearly died by Anonymous Coward · · Score: 0

    My alphanumerics on my keyboard failed leaving only symbols. That's why I started using Brainfuck in the mid 90's.

  14. Trinary by Anonymous Coward · · Score: 0

    Malbolge uses a trinary virtual machine.
    I'm pretty sure there are thumbscrews involved, too.

    1. Re:Trinary by Anonymous Coward · · Score: 0

      DSSP is a Soviet programming language developed for Setun, a ternary computer. They actually built 50 of them.

    2. Re:Trinary by qbast · · Score: 1

      With states 0,1, 'whatever you say tovarisch!'.

  15. Slideshows... by QuietLagoon · · Score: 1

    I think the trend on the web towards using slideshows when prose would work better is really quirky. Since each slide acts like a page hit, slideshows are a good way to drive up the ad revenue that is based upon page hits....

  16. Nastiest? by whitroth · · Score: 1

    The alter command in COBOL.

    Lo, these many years ago, when I'd just read it in a manual, and discussed it with my boss (who would have given Dilbert's a run for his money, but...) and asked him if he'd defenestrate anyone using it before or after firing them, and he told me before.....

                        mark

  17. C++03 had one that was corrected in C++11. by sconeu · · Score: 3, Interesting

    Namely, the >> symbol. Because templates use angle brackets for template parameters, if you had a nested template such as T<int, T1<double> >, you HAD to put the space between the two closing angle brackets. Otherwise the lexer would interpret the two angle brackets as the shift operator.

    --
    General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    1. Re:C++03 had one that was corrected in C++11. by Anonymous Coward · · Score: 1

      The behaviour is more quirky now. As >> is still a single lexical element, and not two (unless I'm mistaken, it's been a while since I looked at the C++11 standard). It's only two if you insert the space. However, the single lexical element, >>, can be treated by the parser as two angle brackets if it's used for a nested template. It makes sense for the preprocessor to take as many characters as possible for an object, as otherwise ab would be two identifiers, a and b, and >== would be three.

    2. Re:C++03 had one that was corrected in C++11. by david_thornley · · Score: 1

      Which means that, if you're using the right-shift operator inside a template heading (and that's legal because you can specialize on numbers), you have to parenthesize the expression to avoid syntax errors.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    3. Re:C++03 had one that was corrected in C++11. by Barlo_Mung_42 · · Score: 1

      I work in a shared code environment. Visual Studio has no issue with nested templates without the space. But I still have to add the space so my Mac friends down the hall stay happy.

    4. Re:C++03 had one that was corrected in C++11. by flargleblarg · · Score: 1

      Namely, the >> symbol. Because templates use angle brackets for template parameters, if you had a nested template such as T<int, T1<double> >, you HAD to put the space between the two closing angle brackets. Otherwise the lexer would interpret the two angle brackets as the shift operator.

      That's a really dumbass lexer. Glad that shit got fixed.

    5. Re:C++03 had one that was corrected in C++11. by flargleblarg · · Score: 1

      That's a really dumbass lexer. Glad that shit got fixed.

      Or should I say... a really dumbass parsing layer to go and use a lexer that doesn't understand the local context when it constructs a lexeme from the input stream.

  18. Since 1975 by Anonymous Coward · · Score: 0

    What Are the Strangest Features of Various Programming Languages?

    Fanboism.

    It's still tool in the end, and a hammer of all things is what every programming language appears to be destined nowadays.

  19. Prolog by Anonymous Coward · · Score: 0

    Pretty much the entire language of Prolog.

    I do think it's an interesting language, and I can see why some people would like it, perhaps even a lot. But I never could get past the basics back when I first encountered it, and I haven't returned to it since then. The whole thing with relations, anonymous variables, and backtracking could lead to some pretty surprising results to a beginner.

    1. Re:Prolog by CodeArtisan · · Score: 1

      Pretty much the entire language of Prolog..

      How many Prolog programmers does it take to screw in a lightbulb?

      Yes.

    2. Re:Prolog by Anonymous Coward · · Score: 0

      bag of...

  20. Column Position Requirements in FORTRAN 77 by EmagGeek · · Score: 1

    I'd say that the column position requirements in FORTRAN 77 take the cake.

    1. Re:Column Position Requirements in FORTRAN 77 by Anonymous Coward · · Score: 1

      That was fine and useful back in 1977 when people were still using Hollerith Cards.

      Those blank columns were used to number the cards in case you dropped the stack. And the first column was for a comment.

    2. Re: Column Position Requirements in FORTRAN 77 by Anonymous Coward · · Score: 0

      That has nothing on the computed GOTO of f66 when combined with the 7character variable me restriction and used to implement while loops

  21. Many languages and... by bobbied · · Score: 2

    That pesky ";" statement terminator... I guess you had to uses something, but it causes me the most trouble..

    C, C++, Pascal, Perl, Java, C#, bash/sh, ksh, JavaScript..... The list goes on..

    --
    "File to fit, pound to insert, paint to match" - Aircraft Maintenance 101
    1. Re:Many languages and... by Anonymous Coward · · Score: 0

      It's much, much worse in Pascal. Oh, the bugs we hunted for in high school!

    2. Re:Many languages and... by the+eric+conspiracy · · Score: 2

      It's not a quirk if pretty much every fukin language does it.

    3. Re:Many languages and... by xvan · · Score: 1

      for bash / sh, the ; is not mandatory... What else do you propose to separate to commands in the same line?

    4. Re:Many languages and... by Megane · · Score: 3, Interesting

      Well, whether ';' is a statement terminator (like in C) or a statement separator is one thing.

      But Javascript takes it to a whole new level. You can decide not to put them in, and if you break your lines a certain way, you may get the effect of a semicolon where you didn't expect one. And this is part of the language specification.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    5. Re:Many languages and... by Anonymous Coward · · Score: 1

      One of the few decisions which are known to be correct. Separator errors are far more common than terminator errors.

      (Separators are placed between statements, which means there's no separator after the last statement. Programmers tend to get confused what exactly counts as a/the last statement inside if-else statements. With terminators, all statements are equal)

    6. Re:Many languages and... by Megane · · Score: 1

      Grrrr, I meant to say "statement separator (like in Pascal)"

      Anyhow, if you prefer to not religiously bracket your if/else conditions, the behavior of semicolons in your language can cause problems.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    7. Re:Many languages and... by fermion · · Score: 1

      The line terminator in C and C++ are pretty easy to find and fix. The conventions in FORTRAN are much more difficult to fix as the errors are non nonsensical. On of the first things I learned when I learned to code is a page of errors meant you had a mismatched type in a subroutine.

      --
      "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
    8. Re:Many languages and... by jader3rd · · Score: 1

      That pesky ";" statement terminator... I guess you had to uses something, but it causes me the most trouble..

      C, C++, Pascal, Perl, Java, C#, bash/sh, ksh, JavaScript..... The list goes on..

      They should have used the '.' character to end a statement. It's the same one used in written language.

    9. Re:Many languages and... by jader3rd · · Score: 1

      It's not a quirk if pretty much every fukin language does it.

      Yes, but if you're learning your first programming language you wonder why the end of statement character differs from the same one that you use when writing.

    10. Re:Many languages and... by EmperorArthur · · Score: 1

      Anyhow, if you prefer to not religiously bracket your if/else conditions, the behavior of semicolons in your language can cause problems.

      Some people hate this because brackets "clutter" the code, but Apple's goto fail bug was caused by a developer accidentally duplicating a line, and not bracketing the if() statement.

      --
      So lets pretend that we've just completed writing this code, as opposed to having just completed sabotaging it -Altera
    11. Re:Many languages and... by The+MAZZTer · · Score: 1

      Oh JavaScript is fun with that, because it's optional, which means even if you want to continue onto the next line, if a line is a valid standalone statement it will imply the ; terminator.

      Example:

      function() { return
      true; }

      This stumped me for a bit.

    12. Re:Many languages and... by david_thornley · · Score: 1

      Two reasons not to do that. First, "2." in at least some of those is a floating-point 2, so "i = 2." by itself would be ambiguous: does this assign an integer 2 and end the statement, or assign a floating-point 2. (and writing 2.0 doesn't really clarify, but rather raises the question of whether the 0 starts another statement). Second, all the old COBOL programmers who escaped that ecosystem would have something like anti-LSD-style flashbacks, and that can be dangerous.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    13. Re:Many languages and... by david_thornley · · Score: 1

      If the line had been bracketed with the brackets on the same line, duplicating the line would have done the exact same thing. If not, it would have made the function longer and harder to read. Can't win.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    14. Re:Many languages and... by LanceUppercut · · Score: 1

      Well, it is your fault entirely. Real C programmers know how to write C programs without using `;` at all. Here's an example for you

      int main()
      {
            if (puts("Hello World!")) {}
      }

      See?

    15. Re:Many languages and... by jader3rd · · Score: 1

      Two reasons not to do that. First, "2." in at least some of those is a floating-point 2, so "i = 2." by itself would be ambiguous: does this assign an integer 2 and end the statement, or assign a floating-point 2. (and writing 2.0 doesn't really clarify, but rather raises the question of whether the 0 starts another statement). Second, all the old COBOL programmers who escaped that ecosystem would have something like anti-LSD-style flashbacks, and that can be dangerous.

      That's still workable. A period followed by an end of line, or whitespace is the end of statement. A period that's between two numbers is a floating point number. A period surrounded by non-numbers and non-whitespace is a compilation error. I realize that the ship might have sailed as far as this is concerned, but if done originally I think it would have helped a lot of people ramp up on how to code.

    16. Re:Many languages and... by Darinbob · · Score: 1

      Pascal used ";" as statement separator I thought, not a statement terminator. This is true for many from the ALGOL family. Which meant that having a final semicolon before a closing block would lead to a syntax error (though later versions certainly relaxed this rule).

    17. Re:Many languages and... by Anonymous Coward · · Score: 0

      Writing a server in python and client in javascript is no fun...

      So many semi-colon related mistakes, but at least it's just a small personal project and not some kind of nuclear power plant cooling system software. Not that javascript or python would ever be used to write extremely critical software.

    18. Re:Many languages and... by shutdown+-p+now · · Score: 1

      In Pascal it actually made some sense, since the main program was wrapped in begin .. end. - with a terminating period. So the entire program was the "sentence".

    19. Re:Many languages and... by shutdown+-p+now · · Score: 1

      You can also cheat it by introducing a null statement that consists of zero tokens; then "a;" is really the same as "a;null", and it's still a separator - even if it behaves as a terminator in practice.

      It's a useless trick in a statement-oriented language, but in expression-oriented ones, where it's all expressions and not statements, it's useful to be able to define";" as the sequencing operator that evaluates left side first and right side second, and then returns the right side.

    20. Re:Many languages and... by Gunstick · · Score: 1

      I love all languages which do not require the ;
      So why bash, ksh and javascript listed?
      If you do one liners, you need the ; but on separate lines the newline does the job as well.
      Probably a reason why I may try to lean python. No ; there.

      --
      Atari rules... ermm... ruled.
    21. Re:Many languages and... by Eunuchswear · · Score: 1

      Maybe you'd better stick to Cobol then.

      --
      Watch this Heartland Institute video
  22. ALTER in COBOL by Anonymous Coward · · Score: 0

    It makes your GO TO's GO TO somewhere other than where they say they GO TO.

  23. Perl by wisnoskij · · Score: 0

    Perl handles everything strangely. Their classes are so strange, and there is not a language out there that has a worse way of passing variables to methods. And by far the best unique feature, in any programming language, is its handling of regular expressions. After using Perl Regular Expressions, searching and conditionals feel like such a chore in any other language.

    --
    Troll is not a replacement for I disagree.
    1. Re:Perl by Megane · · Score: 1

      For me one of the most annoyingly strange things about Perl is the post-if. (apparently the official name is "Statement Modifiers") You can do something like "statement if (condition); WHY? They just tend to make it harder to read the code flow.

      A lot of strange things in Perl have explanations in its origins, where it merges grep/sed/awk style with sh/ksh/bash style and C style, but I have no idea where post-if came from, unless it was just stunt programming. ("Hey, look at this, I put the if at the end of the statement!")

      I think the even more crazy part is that this language feature (and others, fwiw) can be disabled by code written in the same language. Yep, just include a few blocks of code, and the basic features of your programming language change.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    2. Re:Perl by Anonymous Coward · · Score: 0

      For me one of the most annoyingly strange things about Perl is the post-if. (apparently the official name is "Statement Modifiers") You can do something like "statement if (condition); WHY? They just tend to make it harder to read the code flow.

      Shrug. I oftentimes find it reads much better. if (expr) { statement; } requires silly braces.

      I think the even more crazy part is that this language feature (and others, fwiw) can be disabled by code written in the same language. Yep, just include a few blocks of code, and the basic features of your programming language change.

      That doesn't disable the construct. It's a Perl::Critic policy to make the Perl::Critic lint tool to warn on those constructs.
      Also, Perl::Critic is moreorless an advertisement for Conway's book. I personally find many of its default policies stupid.

    3. Re:Perl by dskoll · · Score: 2

      I actually like Perl statement modifiers; they can make code more readable if used judiciously. Something like:
      return unless $DEBUGGING;
      can be pretty useful. Obviously, something like:
      $a += $b * complex_function($c, $d, $e) unless ($x > 100.7 && pre_condition($d, $c, $e));
      is not good.

    4. Re:Perl by preaction · · Score: 1

      5.20 finally added proper subroutine signatures, so you don't have to unwind the @_ (alias to the Perl stack) yourself, but I'm glad someone else mentioned this one as "strange".

      It's less strange when you finally grok the technical details behind it, but I was doing Perl for 12 years before I finally got it.

    5. Re:Perl by preaction · · Score: 1

      Perl::Critic, the link you mentioned, doesn't disable things for you (but you're right in that you can get modules that disable core language things, like "no indirect"). Perl::Critic is a linter.

      Devel::Declare and now hooks into Perl's parser allow you to define your own parsing contexts! You can declare a keyword and say that inside here, I control the parsing, not perl. So many wild things one can do with that...

    6. Re:Perl by Anonymous Coward · · Score: 0

      I love postfix if in Ruby. Used right, it actually makes code more readable:
      def some_function (x) {
          return if x==0
          do_stuff
          return if some_other_condition
          do_more_stuff
          do_lots_of_stuff
      }

      The first thing you see in lines 2 and 4 is the return statement, it sits right at the beginning of the line. And that's where it should be. The return is what matters most in terms of program flow: Here is a point where the function may be aborted (dependant on some condition).
      Having prefix and postfix (and sometimes infix) grammar mixed in a language is a bit confusing as you have to switch between thinking left-to-right and right-to-left, but it's the same with math and natlang. We do that because it allows for more expressiveness and elegance. I'd say most languages have a mix of prefix and postfix elements: function f(x) versus property/method x.f, loop for (x in a) f(x) versus generator [f(x) for x in a], etc.

    7. Re:Perl by Anonymous Coward · · Score: 0

      A phrase like "die if $broken;" is beautifully concise and mirrors natural language. This carried over to Ruby, by the way. I use it all the time.

    8. Re:Perl by benthurston27 · · Score: 1

      Lol I guess that's why they don't have an obfuscated perl contest it would be too hard to decide who won.

  24. golang: iota by bwhaley · · Score: 1

    The iota enumerator in Golang is elegant and unique. Writing idiomatic Golang code is so implicit in the language itself that I've been able to easily read almost any Go code I find.

    http://golang.org/doc/effectiv...

    --
    "I either want less corruption, or more chance
    to participate in it." -- Ashleigh Brilliant
    1. Re:golang: iota by shutdown+-p+now · · Score: 1

      How is iota any better than the conventional C-style enum syntax (or better yet, true ADTs), other than being quirky?

  25. php for sure. heck, java too. by nimbius · · Score: 0

    PHP: in constant and ubiquitous employ despite existing for 20 years without a formal specification. Just as strange is a feature of programming teams where they became capable of willfully disregarding this fact for two decades.

    --
    Good people go to bed earlier.
  26. S3 Classes by Anonymous Coward · · Score: 0

    The implementation of S3 classes in R. I mean, seriously, how lazy could they have been? (and S4 classes are only marginally better.)

  27. + operator for string concat? by jfbilodeau · · Score: 3, Informative

    How is that a language quirk for JavaScript? The + operator has been used for string concatenation in a number of programming languages (C++, Java, Python...) long before JavaScript. It is still implemented as such in newer programming languages like C#.

    --
    Goodbye Slashdot. You've changed.
    1. Re:+ operator for string concat? by TheDarkMaster · · Score: 4, Insightful

      The difference is that the "+" operator in a strong-typed language works without causing nasty surprises for you.

      --
      Religion: The greatest weapon of mass destruction of all time
    2. Re:+ operator for string concat? by Jamu · · Score: 1

      "one" + "two" = "three"?

      --
      Who ordered that?
    3. Re:+ operator for string concat? by PRMan · · Score: 1

      Also in VB, although they have recently changed it to &.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    4. Re:+ operator for string concat? by Anonymous Coward · · Score: 1

      The + operator for JavaScript mentioned is for converting strings to numbers:

      typeof( '12' ); // prints "string"
      typeof( '1' + '12') // prints "string"
      typeof( + '12' ) // prints "number"

      Confusion such as yours is precisely why it was mentioned. :-)

    5. Re:+ operator for string concat? by phantomfive · · Score: 1

      Because of the lack of strong typing. It's fairly common for programmers to try something like this:

      total = price + tax

      And end up with total being a string like: "50.237.25"

      Then you start seeing code that forces it to numbers, like

      price = price + 0.0
      tax = tax + 0.0
      total = price + tax

      It's kind of funny, but not really a big deal.

      --
      "First they came for the slanderers and i said nothing."
    6. Re:+ operator for string concat? by ubersoldat2k7 · · Score: 1

      This is why I find JavaScript such a dangerous language. I mean, if you can fuck this up:


      var a = "1";
      var b = 1;
      a + b; // gives you "11"

      Imagine the crapfest a complex application would mean.

      P.S: For any JS fanboy, here's the Python way of handling this:


      TypeError: unsupported operand type(s) for +: 'int' and 'str'

    7. Re:+ operator for string concat? by heson · · Score: 1

      Yes "clever" operator overloading comes up high in my list.
      Scripting languages are full of it like in Pike: str/" " Divide a string by space to get an array of the words.
      But I dislike it way more when operator overloading abuse is done in user code than when it is a language construct.

    8. Re:+ operator for string concat? by evenmoreconfused · · Score: 1

      Actually IIRC '+' was used for string concatenation in the version of PC-BASIC included in the firmware of all the original (1980) IBM PCs. But apparently it wasn't in the original (1973) Wang 2200 BASIC that at least some of us first learned BASIC on.

      See the third example here: http://www.wang2200.org/basic_...

      I was trying to look up some of my earlier languages (WATFIV and IITRAN in my case), but I can't find any detailed documentation on the web.

      --
      No. Well...maybe. Actually, yes. It really just depends.
    9. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      Not having that is only a surprise if you don't understand what a string is.

    10. Re:+ operator for string concat? by angel'o'sphere · · Score: 1

      C++ never used + as string concatenation.
      Except you write your own string class and overload the + operator (did they do tat in std::string? std::string is imho younger than JavaScript)
      It is a huge difference it if it is an operator in a class, like in a C++ String class or a feature handled by the compiler/interpreter as in Java/C# (compiler) and JavaScript (interpreter).
      For JavaScript it is a quirk as it is inconsistent and behaves completely different depending on what is left and right from the operator +.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    11. Re:+ operator for string concat? by TheDarkMaster · · Score: 0

      I usually have a worse problem, which is when Javascript arbitrarily decides that my string variable is an integer or vice-versa. You create a string, but then you discovers - when trying to use a string function like split() - that Javascript decided to treat your string as a integer, making the split() fails without error messages.

      --
      Religion: The greatest weapon of mass destruction of all time
    12. Re:+ operator for string concat? by asylumx · · Score: 1

      "1" + 1 in Java or C# will give you 11 just like it does in Javascript. I don't understand why Javascript is getting blamed for this one.

    13. Re:+ operator for string concat? by Yunzil · · Score: 1

      You missed the point. It's not just concatenating strings, it's concatenating strings and... things that aren't strings. In C++ you can't add a string and an int (well, you can but you have to go out of your way to do it). You will get a long-winded error about not having a '+' operator that takes arguments of those types.

    14. Re:+ operator for string concat? by TheDarkMaster · · Score: 0

      Is because JavaScript seems to randomly decide whether it will return a "11" or "2", while in a strong-typed language the result is deterministic. On Java you knows that "A" is a string and "B" is a integer, so A + B will always returns a string "11". Whereas Javascript are not sure about the types used in A and B, so therefore is no way to be sure about what he is going to return.

      --
      Religion: The greatest weapon of mass destruction of all time
    15. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      PHP suffers the same problem as Javascript.

      x = "1" + 1

      In Javascript, you get... "11". The original value is a string, so the integer is coerced to a string and concatenated.
      In PHP, you get... 2. The second value is an integer, so the original value is coerced to an integer and the second value is added to it. (Note: This was done on PHP 5.2, which was current the last time I used PHP, so they may have changed this behavior. But I clearly remember having to teach this wonky crap to newbies back then.)
      In C#, you get... "11". It does the same thing as Javascript, except probably not by coercion, but by using the System.Int32.ToString() (inherited from System.Object) method. Though if you chain it, like "1" + 1 + "1", then it evaluates it as "1" + (1 + "1"), and the 1 + "1" part will fail with a compilation error.

      When I started this post to reply, I didn't expect that C# output at all. So don't expect strongly-typed languages to save your butt with a compiler error every time. Sometimes even they will stab you in the back with a "you meant this instead, right?" You have to be smart and, if you're in doubt, test it.

    16. Re:+ operator for string concat? by Jaime2 · · Score: 1

      Also in VB, although they have recently changed it to &.

      Recently, as in 1995 (it was introduced in VB4)? Having a distinct string concatenation operator has been a strength if VB for a very long time, however it does the same type coercion that JavaScript does. But, at least you don't look at it and assume it's doing addition.

    17. Re:+ operator for string concat? by turp182 · · Score: 1

      Holy shit, you are correct. In fact there's more to it than what you described.

      Here's some C# code, the last examples (z, z2) really bother me (in those cases the string was cast to a number):

                              int i = 1;
                              string j = "1";
                              double k = 1.15;

                              var x = "1" + 1; // string "11"
                              var y = i + j; // string "11"
                              var x2 = j + i; // string "11"
                              var z = k + i; // double 2.15
                              var z2 = i + k; // double 2.15

      --
      BlameBillCosby.com
    18. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      JavaScript's binary + operator is a bit quirky, as the behavior can change from an arithmetic + into a string concatenation + based upon the types involved. Looking at the expression 5+val+5, when val is 0 the result is a numeric 10, but if val is an empty string "" then the result is a string "55"

      In JavaScript you can also use + or - as unary operators that change the type of the operand to a number. +"12" results in 12, while -"12" results in -12.

      Put it all together, and you end up with +(3 - + "2" + 4 + "5") resulting in a numeric 55

    19. Re:+ operator for string concat? by narcc · · Score: 2

      So, you think js sucks because, if you're a total moron, you'll do dumb things?

    20. Re:+ operator for string concat? by narcc · · Score: 1

      Randomly?

      Look like you don't understand the basics of how the language works.

      You can't blame that language for your gross incompetence.

    21. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      How about the fact that parseInt defaults to parsing as Base 8...
      That has caught me off guard far more often than loose type stupidity.

    22. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      Next time you should consider trying your examples instead of making up the results. The last two are strings in both LINQPad and Visual Studio.

    23. Re:+ operator for string concat? by david_thornley · · Score: 1

      Use the standard string class. That's what it's there for. Unless you have really special needs, don't write your own, it'll just make your program harder to read.

      And, yes, given std::string s1, s2;, you can write s1 + s2, s1 + "s2", "s1" + s2 and it'll be string concatenation, but "s1" + "s2" doesn't do anything useful (and is, I think, undefined behavior).

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    24. Re:+ operator for string concat? by david_thornley · · Score: 1

      On the other hand, "1234" + 2 is legal C and C++. It returns a char * that points to the 3, so if you print it you'll get "34".

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    25. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      Pointer addition is forbidden, so "s1" + "s2" has no behaviour. You could use something like "s1"_s + "s2"_s though.

    26. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      Oh, sorry? The language behaves in a non-deterministic way and this is my fault? From what basement you are, clueless guy?

      --
      Religion: The greatest weapon of mass destruction of all time
    27. Re:+ operator for string concat? by jfbilodeau · · Score: 1

      I beg to differ ;)

      int x1 = 10;
      int x2 = 20;

      String message = "Total: " + x1 + x2;

      --
      Goodbye Slashdot. You've changed.
    28. Re:+ operator for string concat? by Tablizer · · Score: 1

      I wonder what the heck the designers of JavaScript were thinking when they added that feature. Did they fail to consider to consequences in a dynamically typed language, or did they judge "matching Java conventions" to be more important than utility alone (for marketing and/or familiarity to reduce the learning curve)?

      I'd like to see the mental mistakes documented so that future language designers don't make similar mistakes.

    29. Re:+ operator for string concat? by wiredlogic · · Score: 1

      I would say it's more of a quirk in both Java and Javascript because they eschew operator overloading in the name of some notion of academic purity and then they go and implement special semantics for the '+' operator that you can't replicate with a user defined type. Same with C++'s abuse of literal 0 before the advent of nullptr.

      --
      I am becoming gerund, destroyer of verbs.
    30. Re:+ operator for string concat? by Darinbob · · Score: 1

      That was added I think mostly to whine that JavaScript isn't strongly typed. The "+" itself or its behavior is in no way weird or unusual in languages, except for those who feel only strongly typed languages should exist. And here I am defending a language I don't like...

    31. Re:+ operator for string concat? by angel'o'sphere · · Score: 1

      That where my words.
      "s1" + "s2" is not really undefined, in C it would add the two pointers (addresses) pointing to the tow literals. On C++ or modern C (ANSI C after 99) it might be a compiler error. (because it implicitly converts addresses into ints).

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    32. Re: + operator for string concat? by narcc · · Score: 1

      The language behaves in a non-deterministic way and this is my fault?

      The language does NOT behave in a non-deterministic way. That you believe it does IS your fault.

      Yeah, it's not language's fault that you didn't bother to learn it.

    33. Re:+ operator for string concat? by pspahn · · Score: 1

      Well, + is addition in PHP, not concatenation.

      I know it's kind of bastardy, but I would expect to get 2 from that in PHP, since the 1 might have come from a database type INT and the "1" might have come from user input as a string, and your intention is to add them.

      I will certainly agree that casting to a type in PHP feels like voodoo. Sometimes you need to, most of the time you don't. It's those "sometimes" that mess you up debugging since the type is often the last thing you think of as the problem.

      --
      Someone flopped a steamer in the gene pool.
    34. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      You're dumber than I thought. If you were better at interpreting text and had dealt more with the case described, you would have understood what I mean by random is that there is no way to say with certainty what the interpreter will do since there's no telling for sure if he will treat the "+" operator as a sum of integers or a concatenation of strings. It's happened to me more than once, I thought I made it clear to the interpreter that a variable would be a string (for example: var some_variable = "1") and later I found out he decided to treat the variable as a integer anyway, and the only solution was to force the variable as string immediately before the desired operation using a ugly hack. while in Java if you use the "+" operator between a string and an integer you will always have a string as a result, regardless of the variables positions or operations that have been made with them previously.

      --
      Religion: The greatest weapon of mass destruction of all time
    35. Re:+ operator for string concat? by viperidaenz · · Score: 1

      long before? Java and Javascript both came out in 1995

    36. Re:+ operator for string concat? by Carnildo · · Score: 1

      The problem isn't the lack of strong typing in JavaScript. The problem is the combination of dynamic typing and operator re-use.

      In Perl, I can tell you at compile time what "5 + $val + 5" will return: a number 10 greater than the numeric value of $val (and there are clear rules for converting strings to numbers). In JavaScript, I can't tell if "5 + val + 5" will be a string value or a numeric value, except by carefully tracking the possible data flows for "val" and seeing if it comes from a string source or a numeric source (or worse, both string and numeric sources).

      --
      "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
    37. Re: + operator for string concat? by narcc · · Score: 1

      If you were better at interpreting text and had dealt more with the case described, you would have understood what I mean by random is that there is no way to say with certainty what the interpreter will do since there's no telling for sure if he will treat the "+" operator as a sum of integers or a concatenation of strings.

      It's like I'm talking to a wall.

      There IS a "way to say with certainty what the interpreter will do". You just haven't taken the few minutes required to find out how!

      It's happened to me more than once

      Then you're either ridiculously lazy or a complete moron. You'll find that if you actually learn the language before you use it, you won't struggle with simple things.

      Again, it's not the language's fault that you're unwilling or unable to learn how it works!

    38. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      There IS a "way to say with certainty what the interpreter will do". You just haven't taken the few minutes required to find out how!

      And I figured, dumb guy. But the fact that I have determined how to overcome this defect of the language does not make this anomalous behavior becomes "acceptable" as you seem to think. Fixable or not is still a behavior that the Javascript should not have.

      --
      Religion: The greatest weapon of mass destruction of all time
    39. Re:+ operator for string concat? by Anonymous Coward · · Score: 0

      How is that a language quirk for JavaScript? The + operator has been used for string concatenation in a number of programming languages (C++, Java, Python...) long before JavaScript. It is still implemented as such in newer programming languages like C#.

      None of these languages automatically convert between numeric and string types in such a way that you often cannot even be sure which you have in a particular variable. Unless you're careful, however, it's quite possible to end up in that situation with Javascript.

    40. Re: + operator for string concat? by narcc · · Score: 1

      No, you didn't. You still don't know how the + operator works. You just came up with a convoluted way to avoid learning how it works.

      If you had actually learned how the + operator works, you wouldn't say ridiculous things like "random" or "there is no way to say with certainty what the interpreter will do".

      Perhaps you shouldn't post about things you know nothing about. If nothing else, when someone points out how ridiculous you sound, you read the docs to make sure that you're not continuing to spread nonsense.

    41. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      Wow... You are just like "The Clueless One" (another Slashdot "super-genius"). Sorry dumb guy, but I know how the "+" operator works, and I also knows that it is not a very good idea on a weak-typed language for reasons I already explained before and I will not repeat again. The ugly hack I mentioned earlier just makes sure that a given string variable will be interpreted as a string when I need it to be a string, just that. Something it would be completely unnecessary if the Javascript was strong-typed.

      --
      Religion: The greatest weapon of mass destruction of all time
    42. Re: + operator for string concat? by narcc · · Score: 1

      So you rescind your claims that "the language behaves in a non-deterministic way" and "there is no way to say with certainty what the interpreter will do since there's no telling for sure if he will treat the "+" operator as a sum of integers or a concatenation of strings"?

      That's what this whole thing was about, after all. If you're willing to accept that those nonsense claims are total nonsense, then we're in complete agreement.

      If you're not, then you're 100% wrong when you claim to "know how the '+' operator works".

      I wonder, as you double-down on your lunacy:

      The ugly hack I mentioned earlier just makes sure that a given string variable will be interpreted as a string when I need it to be a string"

      You wouldn't need your "ugly hack" if you knew how the + operator worked, after all.

    43. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      This is not funny, dumb guy. Learn how to read, or I need to use pictures? Well, I try again: I said the behavior of the "+" operator in Javascript is non-deterministic because you have no way to guarantee the type of the variables involved (string, integer, double, etc). The parser sometimes assumes the type correctly but sometimes not, and that is the problem when you use the operator, it needs to know the type of the variables involved in order to decide whether it will be a sum or a concatenation. And the best part is that what you thought set as a string can be transformed into integer and vice versa depending on the interpreter operations that you may have done previously or user inputs, so that depending on the user input your variable may turn in some type different from the expected and thereby generates an unexpected result when using the "+" operator (and therefore the hack to ensure that what should be a string remains a string so that the operation using the "+" return the expected result for a string).

      In short, my problem with this is not "nonsense". Is simply the result of having a "+" operator for both concatenation and sum in a language without strong-typed variables. As an example Java does not have this problem because a string variable would always be a string, and so the operation with the "+" becomes deterministic. The problem is two-fold and you blindly read only half of it, super-genius... ;-)

      --
      Religion: The greatest weapon of mass destruction of all time
    44. Re: + operator for string concat? by narcc · · Score: 1

      Well, I try again: I said the behavior of the "+" operator in Javascript is non-deterministic because you have no way to guarantee the type of the variables involved

      Nice change. (You never said that! At least you're trying to learn from your mistakes.) Of course, all it does is make you look like an idiot. 1) because you don't know what the term "non-deterministic" means 2) because variables in JS don't have types, values do.

      Let me guess: You're an autodidact?

      (and therefore the hack to ensure that what should be a string remains a string so that the operation using the "+" return the expected result for a string).

      This has been driving me crazy. Since when is an explicit cast an "ugly hack"? How long have you been programming, half an hour?

    45. Re: + operator for string concat? by TheDarkMaster · · Score: 0

      Nice change? Uh... Dumb guy, you are the very first one that I have to give a full explanation and you still could not understand what I mean. You can stop swinging your virtual d*** and pay attention please? You claim to have knowledge of "super-genius" to come here for gratuitous offends a person that you do not have a clue who he is, and yet you're showing me the knowledge of a script kiddie :-(

      Last time: I see is only you that do not know what is "deterministic". When you can't say what will be the result of an operation using the "+" because it is not possible to determine which will be the type of the variables involved (or values if you prefer which gives the same), then the result of the operation is non-deterministic. You simply have no way to tell for sure if the result will be a concatenation or addition without being sure if the variables involved are strings, integers, etc. This happens because Javascript can guess wrong the type used (or change it because of previous operations), after all it do not have strong-typed variables (or values if you like, but is the same in pratice).

      The "ugly hack" is something simple as this:

      var test = (unknow type input) + "";

      to be sure the "test" will be recognized as a string. I call it "ugly" because in my humble opinion the correct way to do this would be:

      String test = (unknow type input);

      or better:

      String test = function_to_convert_to_string((unknow type input));

      but this will only works on a strong-typed language.

      Footnote: I'm not going to answer any more because I have more important things to do than try to explain to you something you do not want to understand, Dumb guy... Think what you want about me, since the only thing that matters to me is that my several clients are very happy with my supposed "terrible job" and their systems work perfectly, even in situations they should not be able to function ;-)

      --
      Religion: The greatest weapon of mass destruction of all time
    46. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      JS sucks because it won't tell you that you're being a moron. Since that's where most people start their careers, using a language like JS (or PHP) leads to them believing that their moronic habits are really "best practices" and such, and results in heaps of unmaintainable code.

    47. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      Of course JS knows what types A and B are, it just happens at runtime. The behavior is fully deterministic every time, it just so happens that it varies with inputs, and therefore can differ for subsequent evaluations of that same expression (but, again, every particular evaluation is still deterministic).

    48. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      Your last two examples add together an int and a double - where did you see any string there, much less an implicit cast?

      C# will indeed let you apply + to an arbitrary object, so long as another operand is a string, and will convert that other object to a string by calling ToString on it (or using an empty string if it's null). This is the same behavior as Java. It is bad, but not so bad as JS, in which strings can also magically become numbers on the right context.

    49. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      It's not undefined - it won't even compile. Pointer arithmetic does not allow the addition of two pointers - the operation is meaningless. You can subtract a pointer from another pointer (the result being an integer difference), or you can add an integer to a pointer. This is definitely true for any version of ANSI/ISO C (including those before C99). I think it's also true for K&R C.

    50. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      Unfortunately, he's right in that many other languages have adopted the same rule, that if one operand of + is a string, the other can be anything and will be turned into a string. Java and C# are two particularly prominent abusers.

    51. Re:+ operator for string concat? by TheDarkMaster · · Score: 0

      I understand, but part of the problem is not knowing for sure what kind of type Javascript will set for your variable. As example, the first time I saw this was one occasion where I had to get input from a user where it should be an integer, but the interpreter assumed it was a string and then the "+" operator made a concatenation instead of an addition (the other variable in the operation was an integer). That's why I consider the operation as non-deterministic, because you know that the "+" operator will do a concatenation for strings, but the interpreter may decide that your variables are integers (or vice versa).

      --
      Religion: The greatest weapon of mass destruction of all time
    52. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      This is not what "deterministic" means, though. Deterministic means same inputs given same outputs. In your case, you're getting different inputs.

      The difference that you're describing is compile-time determinism vs runtime determinism.

    53. Re:+ operator for string concat? by flargleblarg · · Score: 1

      Yes "clever" operator overloading comes up high in my list. Scripting languages are full of it like in Pike: str/" " Divide a string by space to get an array of the words. But I dislike it way more when operator overloading abuse is done in user code than when it is a language construct.

      So, if you take that array of words and multiply it back by " ", do you get the original string? Because that would make it cool.

    54. Re:+ operator for string concat? by angel'o'sphere · · Score: 1

      You are right of course, I simplified to much.
      In K&R C however function arguments have no (enforced) types. Everything is considered to be a 'thing' that fits into a register. Never actually tried it, but with casts you certainly can add pointers or multiply them if you wanted.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    55. Re:+ operator for string concat? by shutdown+-p+now · · Score: 2

      In K&R C however function arguments have no (enforced) types. Everything is considered to be a 'thing' that fits into a register.

      I think you're confusing K&R C with B. It's B which doesn't really have types at all other than "machine word".

      Function arguments in all versions of C always had types. I think that what you're referring to here is that it is possible in C (ANSI as well as K&R, actually) to call a function without having it declared at all, or having it declared but without specifying the argument list (when parens are empty - this necessitated the later use of (void) argument list to declare true argument-less functions in ANSI). When you do that, there are some implicit promotions that happen before the call known as "default argument promotions" - e.g. any integral type shorter than int is promoted to int, and float is promoted to double. However, after those promotions, the formal argument types for the function that you're calling must match the types of the actual arguments you pass in there - even though there's no compiler diagnostic for it (since, well, it doesn't know the prototype at the point of the call), any mismatch is undefined behavior. The only exception is that you can pass signed int/short/long where unsigned int/short/long is expected, and vice versa, but only if the value you're passing is representable in both types; and you can pass char* in place of void* (+/- any cv qualifiers) and vice versa. Anything else is U.B. In particular, passing a char* where int is expected is U.B.

      With casts, you can of course cast two pointers to ints, and then do whatever you want with them. This makes sense, since you're not doing pointer arithmetic then, it's just the standard operator + defined for ints with appropriate semantics. But the original discussion was in the context of trying to concatenate two C strings (i.e., char* pointers), which will not compile with any version of C.

    56. Re:+ operator for string concat? by TheDarkMaster · · Score: 1

      *clap clap clap* What a big moderation system failure we have here... "The Dumb Guy" (a freak from another topic, nothing with the "shutdown now") seens to have friends with infinite mod points. Well done ./ well done. (sarcasm)

      --
      Religion: The greatest weapon of mass destruction of all time
    57. Re:+ operator for string concat? by angel'o'sphere · · Score: 1

      Function arguments in all versions of C always had types.
      I believe that is wrong, but I can later check my book.

      In K&R you wrote it more or less like this:
      func(arg1, arg2, arg3)
      int arg1, char arg2, tSomeType* arg3 // semicolon needed here?, don't think so
      { // your code here // the types in the second line of the function definition are only a reminder for the coder, they are not enforced by the compiler whatsoever and unknown to the outside world // headers did not have those types ...
      }

      But time to get home and get my book, funnily I had it my hands on saturday and considered if I should throw it away but kept it for historical reasons (it is a controversial "bad" german translation, if it was an original I would never had considered to throw it away)

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    58. Re:+ operator for string concat? by shutdown+-p+now · · Score: 1

      Yeah, the syntax was like that.

      I think you might be right in that the compiler didn't enforce the types at the point of the call. But I'm still fairly sure that a type mismatch was undefined behavior, and if you somehow got it working, it would not be guaranteed to be working henceforth. It was certainly not just one parameter = one word, since K&R already had long and float and double, and those would normally be wider than a word on most machines of that time

        So basically, types were always there, but type checks weren't.

      When they added ANSI-style function declarations, you could actually have parameters listed with their types, and that was checked... but for compatibility they still retained the old-style function calls without seeing the definition, where you had to match the arguments carefully.

    59. Re:+ operator for string concat? by angel'o'sphere · · Score: 1

      Well, I digged a bit into it last days. But I'm "on the road again"
      I used Aztec C on an Apple ][ at home (and school) in 1985/1986. Perhaps Atztec C was a bit more nasty, not sure.
      I only remember (and wanted to investigate over the next days) that there regulary where errors in my code, type related. However that as well can be because I was unexperienced.
      Later around 1989 I worked mainly with Ansi C, not sure if it was already called like that, on Sun 3 Workstations, we did not have Sparc yet.
      For historical reasons it is interesting to figure what exactly the differences where (besides promoting etc.)
      The 'problem' with Aztec C might have been, that it 'emulated' a 16 bit processor with 6502 code, don't remember if the sizes between short, int and long even differed, or in what extend. The generated 6502 code looked awfull :)
      The main reason why I stopped using it was that it was so slow in turn around times: it generated .asm files, assembled them to .o files, it in fact used .a files for libraries, erm, archives, it had .lib files, too! So a simple hello world took minutes to compile, obviously considering it was done on a 5 1/4" floppy disk.
      Pascal on the other hand (UCSD Pascal, not the shortly later introduced Turbo Pascal) was very quick with its 'integrated environment'.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  28. In VHDL you use loops to write code :) by Obscene_CNN · · Score: 1

    In VHDL and Verilog you use loops to write code :)

    --
    I don't want to do a sig now
  29. Ruby and string/symbols by Parker+Lewis · · Score: 2

    I started with Ruby about 1 year ago. And until now, work with strings and the symbols is not natural yet to me. I mean, most of the languages I handled until now have only strings.

    1. Re:Ruby and string/symbols by Anonymous Coward · · Score: 0

      Symbols are like C enums, strings are strings. That's about all there is to know about it.

      Or you can think of it this way: a symbol is a constant without a value; its value is its name. They make good hash key literals.

    2. Re:Ruby and string/symbols by Anonymous Coward · · Score: 0

      Don't think of symbols as strings. Think of them as constants where the value of the constant doesn't really matter, only that it is distinct from other constants. Like an enum.

    3. Re:Ruby and string/symbols by rwa2 · · Score: 1

      Heh, yeah, I'm surprised I haven't seen more Ruby yet in this thread, esp. with the proliferation of Chef and gems and rvm and other parts of that ecosystem to keep it puttering along.

      For a language that seems to pride itself on its complete OOP-ness, there's so much syntax and different ways of accessing that syntax. I had wondered where all of the PERL masochists had gone...

      In my limited experience wrangling with Ruby, it seems very schizophrenic... at once it's supposed to be very clean, yet it's so littered with syntactic sugar. The "best practices" guidelines always seem to be changing, so a common pattern one year will be an anti-pattern the next. There's a little cottage industry of dependency management that has grown up around it, so even as it has become something of a cross-platform glue language like PERL and python, it's such a pain to even maintain consistency among its own minor releases, so we have to use rvm gratuitously to spawn different ruby environments to run different "core" ruby utilities on the same box (chef, foodcritic, rubocop all needing different versions of ruby and libraries and gems, etc.). And it's so slow compared to its peers... for an automation language, I find myself taking a lot of coffee breaks while it goes out and does its thing, and of course that also means all of the code check tools like foodcritic spam me with warnings to do all of the little optimizations like converting my string objects into symbols, so much for the pure object-orientism.

      Anyway, I have yet to have an experience with Ruby where it does something that impresses me compared to something else. It seems to be used to write templates for config files a lot, so I suppose that might be its strength. But even there, it seems to be a combination of the worst parts of other languages... all the indeterminate pieces of XSLT, more verbosity than XML, much slower and resource-hungry than other interpreted languages, almost as ugly as PERL, scattered package management in competing and overlapping gems since a lot of the base functionality is somewhat broken ( http://stackoverflow.com/quest... ), and yet seems harder to debug and less accessible too noobs than even compiled languages.

      From my experience with Ruby, I'm not exactly sure why this language was developed, other than to provide job security for some devops types. Oh, and I suppose https://github.com/mame/quine-... is cool from an academic standpoint.

    4. Re:Ruby and string/symbols by Darinbob · · Score: 1

      This is a copy from Smalltalk. So it's not "weird" or unique at all. It's also something common in many Lisp dialects. Ie, symbols are immutable and unique, strings don't have to be unique and don't have to be immutable.

      There are many scripting languages where strings are all immutable constants so that's not strange (ie, changing a string makes a new string), and some others where strings are unique (ie if they're equal then they're the same object as well).

    5. Re:Ruby and string/symbols by slew · · Score: 1

      When programming Ruby, just wait until you try to figure out how to match the vertical bar block parameter delimiters in your editor...

    6. Re:Ruby and string/symbols by Concerned+Onlooker · · Score: 1

      I can say that I use Ruby because of the way it implements regular expressions. They are really easy to use, no need to import a library or compile your regex. Just put some stuff between a couple of slashes and you're off and running.

      Since most of what I end up using a scripting language for is parsing text I use Ruby instead of Python.

      --
      http://www.rootstrikers.org/
    7. Re:Ruby and string/symbols by Anonymous Coward · · Score: 0

      In my limited experience wrangling with Ruby, it seems very schizophrenic...

      Indeed. From the free online 1st edition of Programming Ruby (in the "Expressions" chapter, section "Loops", right before sub-section "Iterators"):

      There's one wrinkle when while and until are used as statement modifiers. If the statement they are modifying is a begin/end block, the code in the block will always execute at least one time, regardless of the value of the boolean expression.

      print "Hello\n" while false
      begin
          print "Goodbye\n"
      end while false

      produces:

      Goodbye

      I think South Park's Stan Marsh said it best: That's pretty fucked up, right there. I don't know if that weirdness has been changed in Ruby 1.9 or later.

      - T

  30. Alter by Anonymous Coward · · Score: 0

    The worst I have ever seen was the alter statement back in the days of COBOL. Alter X to Proceed to Y. It causes a run time modification of the code such that after encountering such a statement, any references to X, actually link to Y instead. You would spend three weeks in a a 2 inch thick mass of spaghetti trying to understand how it worked, and then hit a chain of statements like:

    Alter X to proceed to Y.
    Alter W to Proceed to X.
    Alter Z to proceed to F.
    Alter J to Proceed to I.

    And now you get to start over because all you knew just changed.
       

    1. Re:Alter by tepples · · Score: 1

      Alter X to proceed to Y.
      Alter W to Proceed to X.
      Alter Z to proceed to F.
      Alter J to Proceed to I.

      Sounds like a primitive version of function pointers.

      void (*x)() = y;
      void (*w)() = x;
      void (*z)() = f;
      void (*j)() = i;

    2. Re:Alter by shutdown+-p+now · · Score: 1

      Well, except labels don't necessary point to the function entry.

      But the craziest version of this that I've seen is in Algol-60. There, "label" is actually a data type of sorts - while you cannot declare variables of that type, you can use it to declare procedure (function) arguments. At runtime, the procedure can then goto such a label argument, which allows for a nonlocal exit to the point designated by the caller (in effect, this is setjmp/longjmp - devised in 1958!).

      They also had the notion of a "switch", which is basically an array of labels - either locally declared, or also passed as a procedure argument in a similar fashion.

  31. Re:php for sure. heck, java too. by Warbothong · · Score: 2

    PHP's list of oddities is never-ending. From "catchable fatal error" to "unexpected T_PAAMAYIM_NEKUDOTAYIM".

    There are some nice collections at http://eev.ee/blog/2012/04/09/... http://phpmanualmasterpieces.t... and http://www.phpwtf.org/

  32. Grief? by sgunhouse · · Score: 1

    Does it have to be grief? One of the strangest features of XBasic is ragged arrays. It's sort of somewhere between a linked list and an array, as long as the types match you can access it as an array (as in, arrayname[x,y,z] ).

    Full disclosure: since all the other official developers seem to have run off, I'm technically the lead developer at this point.

  33. Python Loop Else by Anonymous Coward · · Score: 0

    For Else in Python very strange

  34. Ada and abstract generic tagged type instances by mekkab · · Score: 1

    specifically with regards to accidentally freezing types. You've got to declare stuff with similar signatures to get your instances all nice and defined. But if you put something on the wrong line or do things in a different order... YOU'VE BROKEN IT!

    --
    In the future, I would want to not be isolated from my friends in the Space Station.
    1. Re:Ada and abstract generic tagged type instances by Anonymous Coward · · Score: 0

      I've come to Ada from a Java background.

      I find it weird that you can make a type which is just a string of a restricted length. To use this string where a string is expected, such as concatenating with a string literal, you need to cast it to string. BUT, any integer based type, needs you to use the 'Image attribute. Why don't string subtypes have a 'Image attribute? And why can't I write my own 'Image attribute for record types that I define? That just seems all too logical, after living with being able to override toString() everywhere for so long.

      I also find it weird that there are fixed strings, bounded strings, and unbounded strings. Why can't Ada just have one string type that can handle any length string, and then let us subtype that to constrain the length?

      And the worst part? A lot of packages that can help deal with this string-weirdness are not part of the standard library, like in more modern languages, but are in fact separate, GPL'd libraries. Writing a split function when you're working with fixed strings is non-trivial.

  35. Re:PHP by tepples · · Score: 4, Interesting

    Many of us have read the PHP is a fractal of bad design article and a commonly cited rebuttal. I tried to reconcile the two and ended up with about a half dozen legit complaints.

  36. Actionscript Scoping by BenJeremy · · Score: 1

    Not crazy about scoping, or should I say, lack of scoping of local variables in ActionScript. If I bracket a chunk of code, and define local variables, they should stop being defined when I exit the scope.

    If I define a for statement in C, C++ or C#, I can go: for( int i=0; i10; i++) { something...; } and follow it up by another statement that looks the same.

    In ActionScript, the second for loop gets a complaint that I am re-defining a variable.

    Over the years of developing C/C++ applications, I had gotten into the pattern of using scoping, particularly in switch statements, to define local variables specific to that block of code.

    1. Re:Actionscript Scoping by Jamu · · Score: 1

      for (int i = 0; i < 10; ++i) { something(); }

      I remember when some compilers would treat this like:

      int i; for (i = 0; i < 10; ++i) { something(); }

      and others like this:

      { for (int i = 0; i < 10; ++i) something(); }

      As the standard, for whatever reason, decide to change it. So much for not breaking existing code.

      --
      Who ordered that?
    2. Re:Actionscript Scoping by Anonymous Coward · · Score: 0

      That's actually broken syntax in C.
      You've defined the variable OUTSIDE the scope of the statements in the block following the for loop, why should it be scoped as inside the block?
      I understand why people want it to work that way, but it's different then all other scoping rules in C.

    3. Re:Actionscript Scoping by david_thornley · · Score: 1

      If different compilers did different things, the standard had to change something. The pre-standard compilers I used all did the first version, so for all of them it was a change.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    4. Re:Actionscript Scoping by Jamu · · Score: 1

      The first version was the standard ANSI C behaviour.

      i.e. for (expr1; expr2; expr3) statement

      was basically the same as

      expr1;
      while (expr2) {
      statement
      expr3;
      }

      --
      Who ordered that?
    5. Re:Actionscript Scoping by Dragonslicer · · Score: 1

      I ran into one really bizarre bug in ActionScript several years ago. I can't remember all the details exactly, but I think that if you try to redeclare a variable as a different type in the same function, the redeclaration is ignored and the type stays the same.

      Integer a;
      ... bunch of code ...
      String b;
      b = "foo";

      That code would give an error about assigning a string to an integer variable. Of all possible ways to handle redeclaring a variable, ActionScript picked the worst.

    6. Re:Actionscript Scoping by david_thornley · · Score: 1

      At the time of C++ standardization, C was still C90, and required all variables to be declared at the beginning of the enclosing block. There was no declaration in a for statement.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    7. Re:Actionscript Scoping by shutdown+-p+now · · Score: 1

      This is actually a generic problem with JavaScript (of which ActionScript is a derivative). I don't know whose smart idea it was to introduce the notion of local variable declarations and code blocks, but then completely ignore the interactions between the two.

      And JS doesn't get a pass for being dynamic. I know of at least two languages which get this right. In Lua, "local" declarations are actually scoped to the block they are in. And in Python, all variables are local by default unless declared global, so there's no confusing local declaration that looks like it's scoped to something that it is not actually scoped to.

      The good news is that they're fixing it in ES6 with "let".

    8. Re:Actionscript Scoping by shutdown+-p+now · · Score: 1

      The standard didn't decide to change it - the old behavior predates the standard (assuming that we're speaking about the ISO one here). ISO C++ always required the second interpretation, but it came fairly late in 1998, and a lot of code was already written using the former, so many compilers didn't switch right away.

      It was particularly bad on Windows, where VC++ 6.0 (also shipped in 1998) was such a compiler, and it also happened to be the one on which many people stayed for many years to come, taking a strong dislike with newer versions shipped with VS 2002 and above. On the other hand, some people actually hacked the old compilers to make this work, by doing something like:

      #define for if(false);else

      Then every for would implicitly be inside an else-branch, which guaranteed its own scope. But doing that before including any third party headers would break them if they had inline functions, so you had to be very careful...

  37. Best feature ever: Intercal (and others) COMEFROM. by lowen · · Score: 3, Interesting

    Heh, all of Intercal is strange.... but COMEFROM is just.... elegant.

    It's been implemented for Python, of all things.....

    See: https://en.wikipedia.org/wiki/...

  38. Assignement in Python by Framboise · · Score: 2

    Assigning a number or a list in Python and many other languages (Julia) is a different operation. Such as

    >>> a = 2
    >>> b = a
    >>> a = 1
    >>> b
    2

    >>> a = [2]
    >>> b = a
    >>> a[0] = 1
    >>> b
    [1]

    Octave (Matlab) is more consistent on this point, every assignement is a memory copy.

    1. Re:Assignement in Python by Warbothong · · Score: 2

      Assigning a number or a list in Python and many other languages (Julia) is a different operation. Such as

      >>> a = 2
      >>> b = a
      >>> a = 1
      >>> b
      2

      >>> a = [2]
      >>> b = a
      >>> a[0] = 1
      >>> b
      [1]

      Octave (Matlab) is more consistent on this point, every assignement is a memory copy.

      I'd find it alarming if Python *didn't* act that way! In Python, everything is an object and objects are passed by reference; hence altering the contents of "a" in your second example is clearly going to alter the contents of "b", since they're references to the same object. In the first case, you're altering *which object* "a" points to. It's completely consistent.

      The alternatives would be crazy (from an OO perspective).

      To make your second example act like your first one, we would need to *pass* everything by value. This means we couldn't, for example, use a "Logger" to collect messages from different parts of the program. Instead, each method would end up with its own copy of the Logger, containing only those messages from function activations which are still on the stack. As soon as any method returns, its Logger would be lost, along with all of the messages, unless we bypassed the language via the filesystem or a DB. This is *exactly* the situation you describe, except with "Logger" instead of "List" and "message" instead of "number". Note that this is exactly the situation in Haskell, which is why it needs things like the Writer Monad.

      To make your first example act like your second, we'd need to *assign* everything by reference, in which case your first example would replace the "2" object with the "1" object, which is a pretty bad idea ( http://everything2.com/title/C... )

    2. Re:Assignement in Python by Framboise · · Score: 1

      Observe that one needs two operators, memory copy, and "point to".
      What is wrong is to use only one symbol for the two, and change the meaning according to operator content.

    3. Re:Assignement in Python by bluefoxlucid · · Score: 1

      Python's list comprehension is extremely strange when you really get into it, but also one of my favorite features of the language. It's possibly the best single feature of the language.

    4. Re:Assignement in Python by LoneTech · · Score: 1

      No, these are not different operations; you just altered references in different places (first in your locals, second in a list that you held two references to). I see people getting similarly confused about vector or elementwise operations in Matlab, frequently resorting to blindly slapping on a period.

    5. Re:Assignement in Python by JesseMcDonald · · Score: 1

      Observe that one needs two operators, memory copy, and "point to".
      What is wrong is to use only one symbol for the two, and change the meaning according to operator content.

      No, the problem is in how you're thinking of the data. There is only one operation: "point to". When you execute "a = 2", you're making the variable "point to" the number two (which you can think of as an immutable object). Storing small, immutable objects directly inside pointers instead of allocating memory for each instance is an implementation detail, nothing more. So long as the data is immutable, it doesn't matter whether you're making a copy or a reference.

      Note that larger integers (like 2**80) are actually allocated as regular objects on demand rather than stored inside the pointers. Python breaks referential transparency a bit here through the "is" keyword, since the program can observe that equal numbers are actually separate objects in memory ("2**8 is 2**8 ==> True"; "2**80 is 2**80 ==> False"). If it kept a cache and reused the objects the program wouldn't be able to tell the difference.

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    6. Re:Assignement in Python by Anonymous Coward · · Score: 0

      Everything is NOT an object in python. Integers have no methods, for example.

      But assignment is by reference.

    7. Re:Assignement in Python by Anonymous Coward · · Score: 0

      I take that back, apparently integers DO have methods - try dir(1) - but you can't invoke them by the dotted notation, as you can with, say, strings.

    8. Re:Assignement in Python by shutdown+-p+now · · Score: 1

      I actually prefer to think of it in reverse: there's only one operation, and that is "copy", but there's also only one data type for storage locations (like variables, list elements etc), and that is a reference. So you're copying the references around.

      By the way, (C)Python doesn't do any kind of fancy tagged pointer representation for integers regardless of their size - they're always pointers to an actual PyLongObject value. However, it does preallocate a bunch of "small integer" values in a static array, and for many (but not all) code paths it will give you a cached value. From the language spec point of view, the meaning of "is" for integers is basically implementation defined (and not really useful at all, since, them being immutable, there's nothing meaningful that you can derive from comparing them for identity).

  39. Python False = True by underqualified · · Score: 4, Interesting

    False and True are variables and you can assign one to the other. False = True print False Not that anyone sane would do this in real code, but the thought is still scary.

    1. Re:Python False = True by LoneTech · · Score: 2

      As of Python 3, True and False are keywords and cannot be assigned.

    2. Re:Python False = True by Just+Some+Guy · · Score: 4, Informative

      In Python 3, they're keywords:

      Python 3.4.1 (default, Aug 24 2014, 21:32:40)
      [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      >>> True = False
      File "<stdin>", line 1
      SyntaxError: can't assign to keyword

      --
      Dewey, what part of this looks like authorities should be involved?
    3. Re:Python False = True by Anonymous Coward · · Score: 0

      While it may be true for Python 2...

      Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> False = True
      >>> False
      True

      ...it is no longer true for Python 3.

      Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> False = True
          File "", line 1
      SyntaxError: can't assign to keyword

    4. Re:Python False = True by Anonymous Coward · · Score: 0

      As others have mentioned, this has been fixed in Python 3.

      The reason for it was that "False" and "True" (and the existence of a distinct boolean type) were relatively recent additions (Python 2.3). Before they were introduced, you just used the (C-like) integer values of 0 and 1. Not very "Pythonic", so some people got into the habit of adding the statements "True = 1" and "False = 0" to the top of their modules to get a symbolic value. The upshot of this was that you couldn't just make assigning to True and False illegal, as it would break a number of pre-Python2.3 scripts. So what they did instead is pre-define the variables but allowed for reassignment, to allow for backward compatibility for those people who used their own definitions in existing scripts. When they did the big backward-compatibility eschewing redesign with Python3, that was one of the explicit things they fixed.

    5. Re:Python False = True by The+MAZZTer · · Score: 1

      In JavaScript it is perfectly valid to make a variable called "undefined" and assign it any value you want. Of course, to its credit, any assignment on the global scope (window.undefined is defined as undefined in Chrome) is ignored and it will still have the value of undefined, so it only works inside a function. Still odd though. null, true, and false are all keywords and thus cannot be assigned to.

    6. Re:Python False = True by Anonymous Coward · · Score: 0

      I would suspect then that it wasn't done in Python 2.x for backward compatibility. Still, it seems they should have done this from the start.

    7. Re:Python False = True by Just+Some+Guy · · Score: 1

      Python didn't originally have True and False probably for the same reason C didn't: they already had well-defined truthy and falsey values. Besides, you don't often need them. Instead of writing if expr is True:, you'd just write if expr:. To this day, the most common use I see for them is as default values for keyword arguments.

      By making True and False variables with preset values, they could be added to the language without breaking code that already used those names for other things. By the time Python 3 rolled around, such code would probably have to be re-written for other reasons anyway and there was no longer a compelling backward compatibility story for not making them actual keywords.

      --
      Dewey, what part of this looks like authorities should be involved?
    8. Re:Python False = True by LordKronos · · Score: 1

      I'm not sure Id say this is "due to the nonsensical autoboxing syntactic sugar". This only works because you "hacked" the system.

      1) You aren't allowed to modify the value of an Integer object, as the value is both private and final. You worked around that by using reflection to get at the object's variables in the roundabout way.
      2) Even then, you wouldn't be allowed to modify it because of security restrictions. However, you also explicitly turned off the security restrictions.
      3) The only reason you were even able to turn off the security restrictions is because you were running in an unmanaged environment. In that situation, it is assumed you have full access to do pretty much anything you'd like. However, if you were running in any sort of managed environment with a security manager installed, you wouldn't have been able to do that.

      This is really not much different than C++, where it's assumed you have full access to everything. You can take a const, get a const pointer to it, cast that to a non-const pointer, and then modify it. Even if that constant value were stored in a non-writable code page, you could make the code page writable if you were running in an environment that allowed you to alter those permissions. I haven't done such a thing in a VERY long time, so I'm not sure if Admin access under windows these days gives you that level of access, but I'm almost certain linux root level would allow it.

    9. Re:Python False = True by roman_mir · · Score: 0

      Ok, you are not sure that the problem is autoboxing, well here, this code:

      Integer a = new Integer(2);
              Integer b = new Integer(3);
              for (int i=0;i<10000;i++) {
                  System.out.println( a.intValue() + b.intValue());
              }

      will print 5 every time under the same conditions.

      Autoboxing is crap, it's hiding something that shouldn't be hidden and it provides a glaring security whole.
      Generics are crap, I can't reuse the same Iterator for different loops? Fuck that nonsense. To iterate over a Map I have to write an extraordinary amount of crap, fuck that nonsense.
      "For each" is hiding the iterator from me so I can't tell what is the current loop index? Fuck that nonsense.

      Basically near all syntactic sugar is garbage.

    10. Re:Python False = True by LordKronos · · Score: 1

      OK, if autoboxing is crap, then you should just consider it invalid to assign a primitive type to an object type. Thus I guess you made a coding error when you wrote the code that did autoboxing. Shame on you.

      Now, back here in the real world, you went OUT OF YOUR WAY, even going so far as to explicitly circumvent 2 levels of security measure, just to FORCE the problem to occur. That's like claiming the scissors you bought are unsafe because they made you go blind when you jammed them into your eyes.

      Sorry, but the autoboxing is completely safe unless you take explicit measure to attempt to make it unsafe. Don't go whining just because the language didn't protect you from yourself. It actually tried, but you told it not to. If you can't trust yourself not to be an idiot, then just run all of your code with an appropriate security profile in place and you'll be all set.

    11. Re:Python False = True by LordKronos · · Score: 0

      Do your new hires routinely circumvent 2 layers of security mechanisms just to alter the values of Integer objects? Sounds like you have some shitty new hires. What you really should be teaching them is that, if they have an Integer object with a value of 2 and they want it to be 3, then rather than use the reflection API to bypass private and final modifiers and turning off the accessibility restructions, they could just do "new Integer(3)" or "Integer.valueOf(3)" and be done with it.

      I'm sure as hell glad I don't have your shitty new hires working with me. Nor your stupid ass teaching/hiring my coworkers.

    12. Re:Python False = True by roman_mir · · Score: 0

      I'm sure as hell glad I don't have your shitty new hires working with me. Nor your stupid ass teaching/hiring my coworkers.

      - ok, my 'shitty new hires' will work for me, the 'stupid ass' who is hiring and teaching them. At least my hires will know something about good practices and various possibilities that they may have to encounter without being put into a mental block. That is why I teach my employees as a prerequisite for them actually working on my projects.

  40. COBOL but spell like a repulican by Anonymous Coward · · Score: 0

    Never ever seem to compile and by some miracle of God's hand, that btw aborting your unbord child will put you straight to hell, it abends.

  41. OPS5 by hedley · · Score: 1

    A rule based language. 1000's of productions can be waiting to fire by querying a database (lhs waits, fires, triggers rhs updates). In my mind, its a bit like a seeing a VHDL language meet a database wrt the parallelism that comes out from it.

    Programs written in it don't look at all like programs you normally would write in the life of a typical coder.

    1. Re:OPS5 by ubersoldat2k7 · · Score: 1

      Wow, I mean, I don't even...

      (object-class request
        ^action)

      (startup
        (strategy MEA)
        (make request ^action hello)
      )

      (rule hello
        (request ^action hello)
        (write |Hello World!| (crlf))
      )

  42. Some COBOL features I like by Nutria · · Score: 1

    - Variables can start with a numeric, since whitespace is the token separator. This has some distinct uses in a globally scoped language, when combined with PERFORM THRU.
    - "Concatenated OR". It lets you write code like IF 8 = A OR B OR C OR D OR E THEN ...
    - 88 Level variables

    --
    "I don't know, therefore Aliens" Wafflebox1
  43. Regexp by Z00L00K · · Score: 1

    Anyone coding in Regular Expressions knows that the whole language is extremely compact and is only built upon the understanding of strange features.

    If any code is "Write Only" that must be the top contender.

    --
    If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
  44. Most Vexing Parse in C++ by Anonymous Coward · · Score: 0

    https://en.wikipedia.org/wiki/Most_vexing_parse

    C++11 fixed it, but boy was it annoying before that.

  45. Move Corresponding by khb · · Score: 1

    Removed from modern versions of COBOL, the traditional "MOVE CORRESPONDING" was unique. Given two records with differing layouts, MOVE CORRESPONDING would shuffled the values based on the names (putting in default values where needed, or tossing aside unneeded ones).

  46. If you print a lot and want a ink spare language by NotInHere · · Score: 5, Funny

    use whitespace. Be warned, several problems have been reported when posting source code to the internet.

  47. PowerShell - the whole language by ErichTheRed · · Score: 1

    I'm not saying PowerShell isn't extremely cool -- it is, and I'm working on wrapping my brain around it. But I do have a lot of experience in multiplatform environments, and PowerShell's syntax is stitched together from so many sources that it gets very confusing.

    - You have extensive pipeline use a la UNIX/Linux, but those pipes don't necessarily contain text, they contain references to objects.
    - You have very long command syntax a la OpenVMS DCL. A line of PowerShell can perform lots of operations, but that line can be hundreds of characters long. Also, since it references .NET-style objects/properties, these names tend to be very long and add to the number of characters.
    - You have branching/looping/basic structure syntax from everywhere. A little looks like Perl, some like bash, some like Java/C#.

    Granted, VBScript and the various ways to interface with stuff like WMI and the XML parser were awful. I'm converting a lot of my old scripts now, and see hundreds of lines of wasted code doing stuff like opening a file, parsing fields, checking a WMI variable, executing some COM-exposed method, etc. etc. etc. It just takes a very long time to get used to the syntax, and the fact that Windows is basically doing everything for you and you're just gluing it all together.

    1. Re:PowerShell - the whole language by The+MAZZTer · · Score: 1

      The fun stuff is that you can use any .NET object in addition to PowerShell commands and syntax. And then you can also use command line apps as well (though there are annoying issues with delimiting arguments depending on which method of invocation you use).

    2. Re:PowerShell - the whole language by laughingskeptic · · Score: 1

      The first couple of chapters of this book explain the decision making behind the syntax which really helps. http://www.amazon.com/Windows-...

  48. C and C++ by Anonymous Coward · · Score: 0

    The best feature of C and C++ is that they run like a bat out of hell.
    So what is the difference you might ask? With C++ you sacrifice executable size for a lot of nifftiness.
    And please don't give me that "real soon now language X will be as fast when better JITs come around". I have heard that since Java was introduced in 1995. All other languages (except FORTRAN) trade speed for even more nifftiness.

  49. IDL language by Khashishi · · Score: 3, Interesting

    Odd integers are true; even integers are false.

    Arrays can be indexed with () or []. This leads to namespace problems with functions which are also called with (). For example:
    x=a(1,2)
    error: undefined variable a.
    If you want to call function a, you have to forward declare it for this reason.
    There's a different syntax for procedures (which don't have a return value) and functions (which do).

    It is required to assign the result of a function to something. You have to write
    dummy = foo(1,2,3)
    as writing
    foo(1,2,3)
    will give an error.

    Most of the time, a single element array is treated the same as a scalar. But not always, and not being very careful will lead to weird errors.
    There are no zero length arrays.
    An array can be length 1; a multidimensional array can be length [1,2,2], but a multidimensional array cannot be length [2,1,1]. If the last dimension has length 1, it simply vanishes to a smaller dimension, unless already 1 dimensional. Example:
    a = make_array(1,2,2)
    ; a has dimensions [1,2,2]
    a = make_array(2,1,1)
    ; a has dimensions [2]
    This means special code must be written to handle any array operations that might end with last dimension 1.

    Array slices are weird.
    b = a[3,*,2]
    means to take a slice of a along the second dimension. I'd expect the answer to be 1 dimensional, since there's only 1 scan in the slice. But the result has dimensions [1,3]
    On the other hand, a[3,2,*] has dimensions [1,1,3], and a[*,3,2] has dimensions [3]. It makes sense in a convoluted way, but it sucks.

  50. assert side-effects and gcc fp optimizations by robbo · · Score: 1

    Gotchas more than quirks:
    - the day you realize you put a side effect in an assert() call.
    - the day you realize GCC, maybe it was V2, not sure this is still an issue, exploits extra bits of precision in the Intel FPU, *only if* optimizations are enabled, which causes certain iterative floating point algorithms (eg SVD) to fail to converge.

    In both cases everything works great in debug builds but goes to hell in release builds and it's incredibly painful to get to root cause.

    --
    So long, and thanks for all the Phish
    1. Re:assert side-effects and gcc fp optimizations by shutdown+-p+now · · Score: 1

      the day you realize GCC, maybe it was V2, not sure this is still an issue, exploits extra bits of precision in the Intel FPU, *only if* optimizations are enabled, which causes certain iterative floating point algorithms (eg SVD) to fail to converge.

      This is still normal behavior for most C/C++ compilers for IEEE platforms. It is also the expected behavior for Java and C# both. It's just much easier (and faster) to do floating point math if you don't have to truncate every intermediate result to fit the original precision on platforms where it is not normally the case.

  51. Head Scratchers? by Princeofcups · · Score: 1

    More like, "doesn't behave like I think it should." Nothing to see here. Move along.

    --
    The only thing worse than a Democrat is a Republican.
  52. Instantly thought of.. by TFlan91 · · Score: 1
  53. Strange indeed by Anonymous Coward · · Score: 0

    Chuck = Norris/0

  54. Duck typing by CODiNE · · Score: 1

    Yeah with Javascript being such a huge language these days a lot of youngsters don't know how entirely bizarre and hackish it's type system seemed back in the day.

    "Huh? NO type?? You just slap things on it?? But, but, what about classes??"

    --
    Cwm, fjord-bank glyphs vext quiz
    1. Re:Duck typing by narcc · · Score: 1

      It has types, and you really don't need classes. Prototypes are better in just about every way.

    2. Re:Duck typing by viperidaenz · · Score: 1

      Except for performance.

    3. Re:Duck typing by narcc · · Score: 1

      True.

  55. Ruby and the default blank array by mekkab · · Score: 1

    catches every newb screwing around with hashes!

    --
    In the future, I would want to not be isolated from my friends in the Space Station.
  56. VB6 and no copy deep. by Hussman32 · · Score: 1
    Old VB6.

    Foo has object property Foo2, which has object property Foo3.

    Dim aFoo as Foo

    Dim bFoo as Foo

    Dim b = Foo2

    Set bFoo = aFoo

    b = bFoo.Foo2

    Why is that object not referenced?

    Oh, no copy deep.

    Drove me crazy writing copy methods.

    --
    "Who are you?" "No one of consequence." "I must know." "Get used to disappointment."
    1. Re:VB6 and no copy deep. by shutdown+-p+now · · Score: 1

      It's not about "copy deep" - it's about the fact that your variables are references to objects, not objects themselves, so copying copies the reference. It's the same exact thing in any language with reference semantics, including C#, Java, Python etc.

      (Sometimes I wish we made it standard to make that referencing explicit in type declarations, even though it would have to always be there and so be redundant - but at least it'd remind people that they're dealing with references!)

      The real WTF in VB6 was the difference between "Let" and "Set" - the fact that you had to write "Set x = y" vs "Let x = y" (or omit the "Let", since it was the default) depending on the type of "y" - "Set" for object references, and "Let" for everything else. The double-WTF here is that the version with "Let" would in fact compile and run if "y" was an object and "x" returned an object, as well - it just wouldn't do what you expected it to do, but instead assign "y" as the new value of the property of "x" that was designated as a default (and only fail if there was no such property). The triple-WTF was that, when variants were involved, the behavior was decided based on the actual runtime type of the assigned variant. And on the other side of that equation, when defining a property setter, it was actually possible to define two separate methods handling the "Let" and the "Set" (I'm not actually sure if it was so in VB, but you could definitely do it when authoring a COM component in C++, and VB would then understand that).

      All so that people could write things like "textBox = 123" instead of "textBox.Text = 123".

  57. LISP by whitroth · · Score: 3, Interesting

    Ok, someone has to mention lisp.

    Item from 15 or so years ago: a guy posted online that he'd broken into the Pentagon's computers, and found the code for SDI, and it was written in lisp. He didn't want to break US security, but he did post the last five lines of the code.... (stupid slashdot edit filter - 5 lines of ) was not junk... at least, not in lisp....)

                      mark

    1. Re:LISP by Anonymous Coward · · Score: 1

      (was (see (I comment)) redacted)

    2. Re:LISP by Anonymous Coward · · Score: 0

      It was a joke, of course. It was originally posted by Bryce Jasmer on rec.humor.funny in 1990.

      https://groups.google.com/forum/#!searchin/rec.humor.funny/SDI$20LISP/rec.humor.funny/HjP_hKi49Ws/2Kj2xqbrF1cJ

      Here's a link with all the headers (Google won't display full headers, obscuring e-mail addresses).

      http://www.talisman.org/~erlkonig/humour/Technical/SDIlispProof.shtml

    3. Re:LISP by david_thornley · · Score: 2

      That is why you NEVER EVER write Lisp code with an editor that's not parenthesis-aware. I've tried it. Don't make my mistake.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    4. Re:LISP by Anonymous Coward · · Score: 0

      hahaha, that's hilarious. Having written a variant of Lisp for years, that strikes a major funny bone with me.

    5. Re:LISP by Gunstick · · Score: 1

      I put my closing parenthesis on a single line. Made the programs way shorter

      ( code
         ( more lisp
            ( some code
               ( finaly done
      )  )  )  )

      Funny code, but it worked. Never had errors related to rearranging parenthesis like that.

      --
      Atari rules... ermm... ruled.
  58. Stackoverflow's got a list by Tridus · · Score: 5, Informative

    http://stackoverflow.com/quest...

    That's a list of very strange language features. Unsurprisingly, Javascript makes many, many appearances.

    --
    -- "So they told me that using the download page to download something was not something they anticipated." - Bill Gates
    1. Re:Stackoverflow's got a list by Anonymous Coward · · Score: 0

      Also unsurprisingly, ITWorld literally lifted their quotes (and probably the rest of the content) from that post to make the slideshow.

      I suggest reading that post instead.

    2. Re:Stackoverflow's got a list by Jaime2 · · Score: 1

      Apparently, that StackOverflow page is the source for the article. Even many of the comments that are in the article come from that page.

    3. Re:Stackoverflow's got a list by Anonymous Coward · · Score: 0

      http://stackoverflow.com/quest...

      That's a list of very strange language features. Unsurprisingly, Javascript makes many, many appearances.

      TUTOR -- compute -- search -- vocabs stuff. Yeah!

    4. Re:Stackoverflow's got a list by rasmusbr · · Score: 1

      But TFA apparently got it wrong. '1' + 1 does not yield 11, it yields '11' like one would expect in a modern language. The odd thing is that '1' - 1 apparently yields 0.

      Disclaimer: I don't write JavaScript, thank God.

    5. Re:Stackoverflow's got a list by Trailer+Trash · · Score: 1

      http://stackoverflow.com/quest...

      That's a list of very strange language features. Unsurprisingly, Javascript makes many, many appearances.

      That list is the source for the linked "article".

  59. Java Unsigned Int by Rob+Riggs · · Score: 1

    Lack of unsigned numeric types, especially when dealing with binary (octet) data streams. Drives me up the fracking wall.

    --
    the growth in cynicism and rebellion has not been without cause
  60. if(allocation_succeeded) by tepples · · Score: 4, Interesting

    if (a = b) assigns the contents of b to a and executes the code following if b 0. Who the hell thought that would be a good idea?

    If b is an expression that returns a reference to a newly allocated resource, such as fopen or malloc, this if statement represents trying to allocate a resource and then skipping the following compound statement if the allocation failed. It's what they had before exceptions, and it's what they still have on microcontrollers too small to have the overhead of a full-featured exception handler.

    strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?

    Probably the same way that most popular operating systems store text files as a list of lines separated by newline characters, encoded as 0x0A on UNIX or Windows but 0x0D on Apple II or classic Mac OS. VMS is an exception in that its "non-stream" text files have each line prefixed by its length.

    1. Re:if(allocation_succeeded) by ultranova · · Score: 1

      If b is an expression that returns a reference to a newly allocated resource, such as fopen or malloc, this if

      So it's a tradeoff: get neat one-liners for a thing most C programmers don't bother to do, at the expense of adding a hard to notice source of bugs to every if statement.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    2. Re:if(allocation_succeeded) by macs4all · · Score: 1

      Probably the same way that most popular operating systems store text files as a list of lines separated by newline characters, encoded as 0x0A on UNIX or Windows but 0x0D on Apple II or classic Mac OS.

      Bzzt! Wrong! Thanks for playing...

      Due to a hardware shortcut involving the Keyboard (Keyboard Strobe was expressed as the MSB of the Value when the Keyboard location ($C000) was Read, which extended to the Keyboard Input routines in the Monitor ROMs, Apple ][ systems used a unique "High-Bit ASCII" character-set (but not as "Unique" as the C-64 version of "ASCII"!!!), such that the MSB was ALWAYS "1".

      Therefore, in Apple ][ world, a CR was expressed as $8D (0x8D), rather than $0D (0x0D).

      Fortunately, this little peccadillo was NOT carried into the Lisa or Mac, which operate as the Parent noted.

    3. Re:if(allocation_succeeded) by tepples · · Score: 1

      in Apple ][ world, a CR was expressed as $8D (0x8D)

      This is true of DOS 3.3, not of the ProDOS and GS/OS that succeeded it.

    4. Re:if(allocation_succeeded) by UnknownSoldier · · Score: 1

      > but 0x0D on Apple II

      You mean 0x8D. :-)

      Castle Wolfenstein on the Apple ][ actually used C strings! There will be a post reverse engineering the game in c.e.a2 soonish once the next version of AppleWin 1.25 is ready ...

      Applesoft ROM used low-ascii, and a high-ascii as a end of terminator. The assembler directive was DCI for Merlin and official Apple Assembler.
      i.e.
      http://i.imgur.com/lD9Na9K.png

    5. Re:if(allocation_succeeded) by Half-pint+HAL · · Score: 1

      This was an early example of "good practice" vs "lazy programmers". The war rages on to this day.

      --
      Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    6. Re:if(allocation_succeeded) by davidwr · · Score: 1

      if (a = b) assigns the contents of b to a and executes the code following if b 0. Who the hell thought that would be a good idea?

      If b is an expression that returns a reference to a newly allocated resource, such as fopen or malloc, this if statement represents trying to allocate a resource and then skipping the following compound statement if the allocation failed.

      I think you are missing the point. The point is "Why use the '=' as the assignment operator instead of some other symbol, like Pascal's ':='?"

      If I could go back and whisper something into K&R's ears, I would tell them to make "=" the comparison operator and pick something else as the assignment operator.

      --
      Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    7. Re: if(allocation_succeeded) by Anonymous Coward · · Score: 0

      I think people are missing the point.

      If(a=b) works, not because it was designed into the language as such, but as a side effect of how very simple and flexible the C language was constructed.

      There are two statements there: the assignment a=b andthen the conditional. In the original language the only thing a conditional tested for was zero/non-zero value. The compiler let you put any expression into the conditional, and it just tested for a zero result.

      The convention of conditionals returning a bool 1/0 was not adopted into c until the first standard c86. In K&R C you would never do ((a==b) || (c==d)) ==1 because compilers usually implemented == as a simple integer subtraction and so conditionals rarely resulted in a value of 1

      The if(a=b) pattern was quickly adopted into common usage, simply because it was so useful.

    8. Re:if(allocation_succeeded) by Sanhedran · · Score: 1

      If b is an expression that returns a reference to a newly allocated resource, such as fopen or malloc, this if statement represents trying to allocate a resource and then skipping the following compound statement if the allocation failed. It's what they had before exceptions, and it's what they still have on microcontrollers too small to have the overhead of a full-featured exception handler.

      That completely misses the problem of accidentally performing an assignment when you meant to do a comparison, and is also completely unallowable in safety-critical code, which is a good amount of what runs on microcontrollers in the first place.

    9. Re:if(allocation_succeeded) by tepples · · Score: 1

      That completely misses the problem of accidentally performing an assignment when you meant to do a comparison

      If you wrapped your assignment-that-was-supposed-to-be-a-comparison in one pair of parentheses, -Wparentheses will pick it up. If you wrapped it in two, then it wasn't quite accidental.

  61. Intransitive equality and comparison in PHP by Barandis · · Score: 1

    One of the many lovely things about PHP, though this time it's not the only culprit.

    $ php -r 'var_dump("foo" == TRUE); var_dump("foo" == 0); var_dump(TRUE == 0);'
    bool(true)
    bool(true)
    bool(false)

    $ php -r 'var_dump(NULL == 0); var_dump(NULL < -1);'
    bool(true)
    bool(true)

    Strange, and not in a good way. Makes the mathematical part of my brain explode.

    1. Re:Intransitive equality and comparison in PHP by Anonymous Coward · · Score: 0

      "foo" == TRUE makes sense, in that you are casting a string to a bool. It makes sense for a non-empty string to cast to TRUE, although "" == TRUE would be odd.

      "foo" == 0 makes sense for the same reason. Casting a string to an integer, the value of "foo" is not an integer and therefore == 0. Unless you can come up with a better value such as 'nan' which doesn't have an integer representation 0 seems the best available choice. This implementation is required for testing whether a string is valid as a conditional without a special function call and if you want to be able to store integers in the format of a string and use them interchangeably. The solution would of course be a strongly-typed version of PHP.

      NULL == 0 and NULL -1 I can't provide an answer for. Ideally you would think such things should throw an exception although it is entirely possible they also have logical reasons for their implementation as such.

  62. Bunch of things by Anonymous Coward · · Score: 0

    Multithreading in python sucks due to the GIL (global interpreter lock)

    C++ Templates are *way* more complex than they need to be.... especially when I'm mostly trying to do compile-time reflection for things like serialization. Nope, need a PhD to do anything crazy. (I always thought just a compile-time variable that describes the fields of a class plus a find/replace mechanism would work for 90% of what people want. But no you need type-traits and a PhD.

    In Python I have been burned by the fact that default arguments for a method parameter are only evaluated once, even if the expression contains variables that have changed. Kinda like the function set_value_for_name(value, name=player.name). As you change player objects the default value for name will *always* be whatever the first player object was. Where as I originally thought that expression after the equal sign was evaluated *each* time I invoked the method. That's quirky and non-obvious. Not even a warning.

    I dislike python's hard to follow pass-by-reference or pass-by-value semantics. Passing a list to a method is a reference, but if it's a class member list passed without calling a method, then it's silently copied and side-effects performed on the list are lost despite it seeming obvious that it would call by reference. That's a weird issue depending on how you run into it.

    C++ has a bunch of quirks but it really gets interesting when you start passing C++ classes across a DDL/SharedLibrary barrier. There's chicken-egg problems, issues with who owns/destroys what, whether both sides know how much memory to allocate, whether both sides try to free/delete the same object, deadlocks from sharing mutexes across the the boundry then hitting blocking IO..... all sorts of strangeness. Then you can forget to bind with the right symbol visibility and really trash things later at runtime if there's a conflict. Also anonymous namespaces must be used to prevent globals with the same name from leaking over the boundry..... it's a lot of thinking that requires a lot of computer science concepts to be applied all at once.

  63. PHP's associativity of ?: is backward by tepples · · Score: 2

    By now, the only strange thing about the ternary operator condition ? value_if_true : value_if_false is how PHP has the operator's associativity backwards from everything else. Everything else interprets a?b:c?d:e as a?b:(c?d:e), where a chain of ternary operators means use the value associated with the first true condition. It's equivalent to SQL's case when a then b when c then d else e end. PHP, on the other hand, interprets a?b:c?d:e as (a?b:c)?d:e, which means using one condition to select which other condition shall apply. In my opinion, PHP's interpretation is less useful.

    1. Re:PHP's associativity of ?: is backward by Anonymous Coward · · Score: 0

      In my opinion, anyone typing a?b:c?d:e as (a?b:c)?d:e into anything other than one-off code deserves worse than having it operate differently in PHP than in other languages.

  64. COBOL ALTER verb wins no question by Anonymous Coward · · Score: 0

    Do some research on COBOL's old ALTER verb that allowed self-modifying code. That wins as the strangest feature ever.

  65. Numeric equality in PHP by tepples · · Score: 1

    In PHP, 1 === 1.0 and 1 === '1' are both false, and 1 == 1.0 and 1 == '1' are both true. What operator should the programmer use if he wants 1 to equal 1.0 but not '1', where integer numbers are equal to float numbers but strings aren't equal to either?

    1. Re:Numeric equality in PHP by tibit · · Score: 1

      Just write a function that checks the argument types and does what you wish.

      --
      A successful API design takes a mixture of software design and pedagogy.
    2. Re:Numeric equality in PHP by amicusNYCL · · Score: 1

      What operator should the programmer use if he wants 1 to equal 1.0 but not '1', where integer numbers are equal to float numbers but strings aren't equal to either?

      How about just checking if you're dealing with a string and casting it if necessary?

      --
      "Our two-party system is like a bowl of shit looking at itself in a mirror." - Lewis Black
    3. Re:Numeric equality in PHP by MightyYar · · Score: 1

      My approach is generally to always use "===" and explicitly cast things. It makes your errors more explicit.

      --
      W..w..W - Willy Waterloo washes Warren Wiggins who is washing Waldo Woo.
    4. Re:Numeric equality in PHP by meloneg · · Score: 1

      In PHP, 1 === 1.0 and 1 === '1' are both false, and 1 == 1.0 and 1 == '1' are both true. What operator should the programmer use if he wants 1 to equal 1.0 but not '1', where integer numbers are equal to float numbers but strings aren't equal to either?

      Since (almost) no computer actually stores 1.0; your request is, at best, naive.

    5. Re:Numeric equality in PHP by Anonymous Coward · · Score: 0

      I typically program how I'd write it out - so following what you wrote -

      $var = 1;

      ($var == 1.0 && $var !== '1')

    6. Re:Numeric equality in PHP by tepples · · Score: 1

      What you say is helpful when one of the side is a literal constant. It's not so helpful when both sides are variables.

    7. Re:Numeric equality in PHP by Anonymous Coward · · Score: 0

      What.

      If it's a poke at binary floating point vs decimal - nope, 1.0 is just 1 * 2^0 (or 10^0, or 3^0 if you manage to find a trinary computer somewhere) and is stored exactly.

      Unless you meant something else, then you'd better elaborate.

    8. Re: Numeric equality in PHP by Anonymous Coward · · Score: 0

      It's a language semantics thing.

      0 and 0.0 are different in most typed languages, and they are different sizes in Java.

      They are also differently sized in C on some platforms, where an int can be bigger or smaller than a float.

    9. Re:Numeric equality in PHP by beelsebob · · Score: 1

      You shouldn't. You should (in all languages), explicitly convert the type, and then compare things of equal type. For bonus points, you should only use languages that enforce that the arguments to == are of equal type.

    10. Re:Numeric equality in PHP by tepples · · Score: 1

      For bonus points, you should only use languages that enforce that the arguments to == are of equal type.

      Good luck converting all legacy software to meet bonus points, and good luck finding affordable entry-level web hosts that meet bonus points.

    11. Re: Numeric equality in PHP by Anonymous Coward · · Score: 0

      A==B && type of A == type of B

    12. Re: Numeric equality in PHP by tepples · · Score: 1

      I understand what === means. It's just that sometimes I want a middle ground between "exactly the same type" and "convertible to the same type even if it requires relying on behavior that depends on the default locale". I want to check whether they're equal and have similar types, with a useful definition of similar. For example, Python 2 allowed 8-bit strings and Unicode strings to compare equal, both being of type basestring, and allowed integers, long integers, and floats to compare equal, all being of type numbers.Number, which was informal initially but formalized in PEP 3141.

      That and PHP lacks an operator for object identity for arrays. I'm not aware of any practical way to tell whether mutating one array will cause another array to be mutated without (slowly) checking them element-by-element and (potentially unsafely) trying to actually perform the mutation.

    13. Re:Numeric equality in PHP by smellotron · · Score: 1

      Since (almost) no computer actually stores 1.0

      Since almost every computer nowadays implements IEEE floating-point, they can all store 1.0 exactly. From the link:

      Any integer with absolute value less than 2^24 can be exactly represented in the single precision format, and any integer with absolute value less than 2^53 can be exactly represented in the double precision format.

    14. Re:Numeric equality in PHP by Anonymous Coward · · Score: 0

      It's sad when people think they understand floating point better than "those idiots", but actually don't understand it at all.

    15. Re:Numeric equality in PHP by shutdown+-p+now · · Score: 1

      There's no particular reason to not have comparable values of different types, especially where there's a clear subtyping relationship (even if it's not exposed directly in the language). For example, it's patently obvious that integer 1 should be equal to floating-point number 1.0 - they both represent the same abstract concept, "number", with the same value, and there is one and only one way to compare those for equality.

      The reason why 1=="1" is evil is because there's no useful unambiguous way to define such a comparison - should it convert the string to a number, or the number to a string? There's no universally good answer to that question, so the language must force the programmer to decide which one he had in mind (by casts, or by defining different comparison operators - it doesn't matter, so long as semantics is explicit).

      Ditto for overloading + for different types. With something like 1+1.0, the result is clearly 2 - the dispute is only over whether it should be float or int, and clearly in the most general case it has to be float. In a language where you can freely substitute one for the other so long as the value is the same (such as most dynamically typed language), it is largely irrelevant. On the other hand, something like 1+"2" can be interpreted in two different ways with no clear reason to prefer one over the other, so it should definitely be an error.

      It just so happens that PHP made pretty much all the wrong choices, while e.g. Python made mostly right ones.

    16. Re:Numeric equality in PHP by beelsebob · · Score: 1

      There's no particular reason to not have comparable values of different types

      Sure there is - they have different types, therefore they're not equal. It's a ridiculous, useless operation, because it doesn't actually do anything more than always return false.

      That said, there's good reason to have an "isSimilarTo" function, but that's not at all the same thing as equality.

    17. Re:Numeric equality in PHP by Anonymous Coward · · Score: 0

      -1, Needlessly Pedantic

      Plus, this is PHP we're talking about. With all the other bewildering things it does, PHP arbitrarily storing fixed point numbers wouldn't surprise me.

    18. Re:Numeric equality in PHP by shutdown+-p+now · · Score: 1

      Types are an artifact of an imperfect system - what matters is the meaning. The only reason why we even have separate int and float types, for example, is performance, and legacy semantic differences (like different behavior for division by zero or overflow) - from a common sense perspective, the type should just be "rational number", and whether the underlying representation is integer, or floating-point, or a true rational, does not matter in the slightest. In languages which still choose to expose that difference in their typing system, it still makes sense for them to try and patch over that difference by at least making the values largely interchangeable (or even directly introducing some form of subtyping relationship to codify that, like Scheme's numeric tower).

  66. Flipping arrays by blueshift_1 · · Score: 1

    I occasionally do some work in Fortran (and even rarer with matlab) and arrays that begin with an index of 1. It's so subtle and simple that I have to take a step back and try to reroute my thought process. WHY U NOT START AT 0?!?

    1. Re:Flipping arrays by Anonymous Coward · · Score: 0

      It a language for discrete math and I've never seen in a math text an array indexed from zero (though I've not checked them all). I know it's an issue. Several coders have had to translate my stuff in to c/c++ and it's one of the usual gripes. I frequently explicitly index from zero, which you can easily do in fortran, to make they lifes easier.

  67. Prolog by WindowPane · · Score: 1

    The whole language of Prolog. Only took a semester of it in college 20 years ago but what a strange recursive language.

    --
    No Brains, No Headaches
  68. Anything pythonic or lambdaish by Anonymous Coward · · Score: 0

    Specially when they use it just because they can. Which is always.
    Hopefully those fugly trends will be replaced with some other shit in a few years...

  69. significant whitespace by Anonymous Coward · · Score: 0

    I'm surprised nobody has mentioned significant whitespace yet. We can forgive Make since it was invented when puchcards were popular, so we were used to Fortran's 6 columns reserved for line numbers. Still, requiring a tab character instead of spaces is a little onerous, but you should be slow and deliberate when editing Makefiles.

    But Python? Come on, this is the 21st century. I'd much rather use semicolons and braces to indicate code structure. How many of us use an editor that matches pairs of braces, either by highlighting the partner when the cursor is at a brace, or by giving us a commnand to jump to the partner? With Python your choices are either Right,Right,Right,Right,Down,Down,Down,Down, or printing it out in fixed-width font and using a pencil and ruler.

    I'm sure a lot of you are thinking it's not that bad, but why am I bending over backwards to serve the language? The language should be serving me!

  70. Typing by Anonymous Coward · · Score: 0

    Or, rather, the lack of strong, static, parametric typing with inference.

  71. I'll tell you something I love in AS3/AIR by GoodNewsJimDotCom · · Score: 1

    You can call objects with "this" as one of the parameters you pass.
    Then the class can then save it to a global to the class variable.
    Then that class has the ability to call functions in your main class :)
    I discovered this because Eclipse for AS3(Flashbuilder) has a bug if you go over 25,000ish lines that it slows down your typing.
    I started making separate classes which were just a place to put methods.
    Since a lot of people are coding with AIR for Android/iOS, I'm sure someone will love using this.

  72. Tabs in Make by gatkinso · · Score: 1

    Because why not base syntax on an invisible character?

    Blahblahblah show whitespace. Whatever. I was showing your Mom whitespace before she met your father, whippersnapper.

    --
    I am very small, utmostly microscopic.
    1. Re:Tabs in Make by Animats · · Score: 1

      The guy who made that mistake realized the next morning he'd made a serious design error. But by then, he writes, he already had three users. Really.

    2. Re:Tabs in Make by Darinbob · · Score: 1

      I interviewed with the author of make, Stu Feldman.

      I don't think it's that big a deal myself. I wish it used just any white space, but... If that's the big fault then it's doing great. It's a simple system but very powerful, and none of the many make replacements come anywhere near its usefulness.

  73. Re:Best feature ever: Intercal (and others) COMEFR by Anonymous Coward · · Score: 0

    I wrote a branching animation system entierly based on the comefrom concept. It's how animators think so that's what I did.

  74. scheme blows them all away by Anonymous Coward · · Score: 0

    don't believe me?

    (call-with-current-continuation foo)

    RTFM and weep

  75. Python scope by Warbothong · · Score: 2


    def mkCounter():
            c = 0
            def counter():
                    c = c + 1
                    return c
            return counter

    count = mkCounter()
    print str(count())
    print str(count())
    print str(count())

    You'd expect "1", "2" and "3", right? Wrong!


    $ python test.py
    Traceback (most recent call last):
        File "test.py", line 9, in
            print str(count())
        File "test.py", line 4, in counter
            c = c + 1
    UnboundLocalError: local variable 'c' referenced before assignment

    When Python parses the definition of "counter", it sees the assignment "c = ..." and assumes that we must be defining a local variable "c", so it creates a slot in "counter" to contain "c". This local slot shadows the "c" inherited from "mkCounter", so when we get to evaluating "c + 1" we get this "referenced before assignment" error.

    Note that it's perfectly fine to *use* inherited variables, just not to *assign* them:


    def mkPrinter(s):
            def printer():
                    print s
            return printer

    p = mkPrinter("hello world")
    p()

    This prints "hello world" as we'd expect.

    1. Re:Python scope by Anonymous Coward · · Score: 0

      Isn't this what the "nonlocal" keyword is for?

    2. Re:Python scope by shutdown+-p+now · · Score: 1

      It's kind of quirky, but at least it's better with JS where you have blocks and variable declarations inside those blocks, but for some mysterious reason the variable declaration is not scoped to the block in which it is declared, but to the entire function. You'd think that the sensible thing to do would be to either disallow "var" inside blocks and require it to be on top level (and, since it's visible throughout the function, at the beginning of it - like in C89), or else to do proper scoping like Lua did. In Python, the scope is implicit but it doesn't lie.

      And, of course, they did add "nonlocal" in Python 3 for those cases where you really do want to assign to an outer variable.

  76. That's called a function pointer by tepples · · Score: 1

    All that means is that the argument of a GOTO that has been ALTERed is a function pointer. I don't see how that's any stranger than the Lisp family's feature of assigning a function to a variable and then tail-calling the function through the variable.

    1. Re:That's called a function pointer by david_thornley · · Score: 1

      It's not really a function pointer. If the paragraphs in COBOL were separate functions, then yes. However, since they're executed sequentially it's a GOTO.

      Another interesting thing about paragraphs is that you can write "PERFORM PARAGRAPH1 THROUGH PARAGRAPH2" (if I remember the syntax aright), so the flow of execution is determined at the spot the PERFORM is written rather than anywhere around PARAGRAPH1.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  77. nodejs by slashdice · · Score: 1

    pretending synchronous code is magically asynchronous when you add a 10-story callback pyramid.

    --
    Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
    1. Re:nodejs by shutdown+-p+now · · Score: 1

      Callback pyramid is not a language feature, it's a framework feature.

      And it does actually make it asynchronous. I'm not sure what you even mean by "magic" - there's nothing magical about callbacks, it's a pretty obvious idea that just took a while to catch on. If you want actual magic in the same vein, that's C# "await".

  78. Apples to apples, please by Anonymous Coward · · Score: 0

    Please stop comparing C & C++ to Javascript & Python. They (can) do different things and were designed from scratch to this purpose.

  79. Mixed arithmetic in Matlab by ClickOnThis · · Score: 3, Interesting

    This was a stunner for me when I first encountered it. When you mix double and int types in Matlab, it demotes the double to an int! Same with float and int.

    Of course, you must create the int explicitly as such (double is the default) but I mean, WTF Matlab??

    --
    If it weren't for deadlines, nothing would be late.
    1. Re:Mixed arithmetic in Matlab by Anonymous Coward · · Score: 0

      If you have to explicitly create ints, wouldn't it be weird if Matlab promoted them back to the default doubles?

    2. Re:Mixed arithmetic in Matlab by Anonymous Coward · · Score: 0

      IIRC integer types are sort of a red-headed stepchild in MATLAB; much of the core framework doesn't support them. I presume they were forced to add them in order to support the fixed-point toolbox..

      logicals (1-bit data type) _do_ however follow 'natural' upcasting rules.

    3. Re:Mixed arithmetic in Matlab by Hotawa+Hawk-eye · · Score: 1

      Do you really want this:

          A = ones(10000, 10000, 'int8'); % 10000-by-10000 matrix each entry of which is 1, stored using the 8-bit signed integer type
          B = 1; % double precision
          C = A+B;

      to blow C up into a 10000-by-10000 matrix of doubles, requiring eight times as much memory as A?

      There's also the question of false precision.

    4. Re:Mixed arithmetic in Matlab by ClickOnThis · · Score: 1

      What I'm saying is this (pardon my Matlab, it has been awhile):

      a = int8(1);
      b = 1; % double;
      c = a + b; % c is type int8, not double

      --
      If it weren't for deadlines, nothing would be late.
    5. Re:Mixed arithmetic in Matlab by ClickOnThis · · Score: 1

      Do you really want this:

              A = ones(10000, 10000, 'int8'); % 10000-by-10000 matrix each entry of which is 1, stored using the 8-bit signed integer type
              B = 1; % double precision
              C = A+B;

      to blow C up into a 10000-by-10000 matrix of doubles, requiring eight times as much memory as A?

      Obviously not. But it should be my choice as to whether precision is thrown away, not Matlab's.

      --
      If it weren't for deadlines, nothing would be late.
  80. Powerbuilder variable init by Anonymous Coward · · Score: 0

    In Powerbuilder (a C++ based rapid development IDE) variables are always are initialized at "compile" time and not at run time. Meaning if you try to initialize a variable to a value that can change at run time, it doesn't actually work, yet there is no pre-processor warning for doing this.

    For example:

    Function1(int arg)
    { int foo = arg
         
    }

    Function2(int arg)
    { int foo
          foo = arg
         
    }

    Say you call these functions passing a value of "3", the output of Function1 is "0" (default value of integers in Powerbuilder), the output of Function2 is "3". This has caused quite the number of headaches for fresh programmers coming in with C++/C#/Java experience.

    You can use this "feature" to do some creative trolling of your fellow programmers though. For example, Powerbuilder has a native global function to run any Windows command line command. You can initialize a variable to a function return, and because variables are initialized at compile time, if you call a Powerbuilder native global function, it actually executes that function upon compiling the object! So you can write a function like the following and any programmer that tries to recompile this object (which happens automatically in PB any time you make a change to an object and save it) will find themselves being logged off. You can obviously use this to do MUCH more nefarious things, but this is generally what we've deemed professionally acceptable as a prank.

    TrollingFunction()
    { int foo = Run("shutdown -l") //got you!
    }

  81. coffeescript by slashdice · · Score: 1

    It's just javascript! Plus the worst parts of python and ruby....

    --
    Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
  82. Null Terminated Strings by Comboman · · Score: 3, Interesting

    - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea?
    Well, age old argument. Basically a matter of taste or sadly a historical "evolution".

    I'm pretty sure null-terminated strings come from the days of punch cards/punch tape where an unpunched area is read as null (binary zero). Wherever the data-entry clerk stopped typing was the end of the string and the string could be appended to latter (impossible with a non-zero end-of-string symbol or a string length in the header which can't be rewritten on card/tape).

    --
    Support Right To Repair Legislation.
    1. Re:Null Terminated Strings by BasilBrush · · Score: 1

      Interesting. It's a shame C wasn't abandoned at the same time as punch cards.

    2. Re:Null Terminated Strings by mferero · · Score: 1

      Nope. Punched cards was the era of fixed length fields . . . You described each field with a size, including packed decimal numbers.

      --
      Honor est omni
    3. Re:Null Terminated Strings by zephvark · · Score: 5, Funny

      Nonsense. C is a more elegant weapon for a more civilized age. It's a shame that mass-produced coders have to rely on blasters.

    4. Re:Null Terminated Strings by BasilBrush · · Score: 1

      If C were a weapon it'd be a wooden club.

    5. Re:Null Terminated Strings by KingMotley · · Score: 2

      Well it was also kind of important for being able to process data that you didn't know the size of until you actually hit the end, especially if you couldn't hold the whole contents in memory at one time, and you needed to be able to do something with it. Think streams where you can't just go back and write the size of the string at the beginning after you've already copied the string. NULL terminated strings are also smaller since it always only uses a single byte, even if the string is (or could be) longer than 255 characters. The size aspect typically isn't all that important today, but it still can be quite useful in memory constrained systems even today.

    6. Re:Null Terminated Strings by SpaghettiPattern · · Score: 4, Insightful

      I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.) That is the epitome of KISS. If you use an 8 byte character at the beginning then you are limited to a string length of 255. A structure with a length and a string pointer (or a character array) is much more complex and that would reflect in more complex library functions.

      C was invented by exceptionally bright people. For a language that was primarily designed to program kernels its remarkably versatile. If you are seeking a language to write administrative applications then you should look further. COBOL back in the days or Java nowadays would suit you better. And yes, there is a difference in programming prowess between kernel / library programmers and application programmers. The latter "just" have to get the business logic going and are allowed to use every trick in the book. The former must be very concise and consider that their code will be used by a huge amount of other programs.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    7. Re:Null Terminated Strings by BasilBrush · · Score: 1

      I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.)

      You're missing something. You can't have a string longer than the amount of memory that is reachable by a pointer. Hence my comment that you wrongly think incorrect.

      C was invented by exceptionally bright people.

      A VERY long time ago. We've learned a lot about what makes good and bad language features since then. What made for a good language in the 70s, sucks now.

      And yes, there is a difference in programming prowess between kernel / library programmers and application programmers.

      You don't say. Sounds like this is relatively new to you.

      The former must be very concise

      That's complete nonsense. Source code size has nothing to do with object size, let alone suitability of a language for different problem domains. C's conciseness was useful in the 1970s and 80s, where memory used for source code whilst editing and compiling was a significant factor. Nowadays 10s or hundreds of K of source code is irrelevant in GB sized PC memories. The conciseness is worthless.

    8. Re:Null Terminated Strings by Darinbob · · Score: 1

      C++ is a wooden club with some nails stuck in it.

    9. Re:Null Terminated Strings by BasilBrush · · Score: 1

      Well it was also kind of important for being able to process data that you didn't know the size of until you actually hit the end, especially if you couldn't hold the whole contents in memory at one time, and you needed to be able to do something with it. Think streams

      They're typically handled in blocks, regardless of language. And blocks are either fixed size or store their length in a header.

      stdin and stdout are character streams but they come about as part of the philosophy of C, rather than C's null terminated strings being a good way to deal with them. And in any case they never actually hit their end, so neither termination nor length are relevant.

    10. Re:Null Terminated Strings by saigon_from_europe · · Score: 1

      I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.)

      The problem is that you usually don't know where the the allocated memory is finished.

      I understand the rationale behind the pointers like they are, but I'd still prefer if pointers could keep both address and size of the buffer. But it's too late now for such kind of redesign or upgrade.

      And yes, I do code in C every working day.

      --
      No sig today.
    11. Re:Null Terminated Strings by John_Sauter · · Score: 1

      - strings terminated by a binary zero rather than their physical size. Who the hell thought that would be a good idea? Well, age old argument. Basically a matter of taste or sadly a historical "evolution".

      I'm pretty sure null-terminated strings come from the days of punch cards/punch tape where an unpunched area is read as null (binary zero). Wherever the data-entry clerk stopped typing was the end of the string and the string could be appended to latter (impossible with a non-zero end-of-string symbol or a string length in the header which can't be rewritten on card/tape).

      Actually, an unpunched column on a card was a space. You are right about paper tape.

    12. Re:Null Terminated Strings by solidraven · · Score: 1

      I would like to add one thing: People forget that a kernel has to run on pretty much bare metal. If you're lucky you have BIOS there helping you a bit at the start, but not really. (Yay for obscure backwards compatibility tricks that the folks at Microsoft, IBM and Intel came up with.) So your standard libraries are usually quite limited, if you have them at all. And even then they're usually too slow to deal with anyway, so you end up rewriting everything in X86 assembly anyway.

    13. Re:Null Terminated Strings by Nutria · · Score: 1

      If you are seeking a language to write administrative applications then you should look further. COBOL back in the days or Java nowadays would suit you better.

      Too bad that Computer Scientists are a bunch of elitist Haters who only know COBOL from legend. Even back in the day, CompSci professors loathed/disdained it, and the most popular textbook series was from the grossly incompetent Shelly & Cashman.

      Once I re-learned it from people who grokked the language, I discovered how powerful it is at it's intended task.

      Finding people willing to write in it is hard, though, so -- before Java -- many managers decided that business apps would be written in C rather than the appropriate language.

      --
      "I don't know, therefore Aliens" Wafflebox1
    14. Re:Null Terminated Strings by Anonymous Coward · · Score: 0

      C used null terminated strings because BCPL did. Richie stated that it didn't restrict string length and he found it convenient to use.
      It was a debarcle 40 years later when people started wiring computers together and needed reliable and secure string processing.

    15. Re:Null Terminated Strings by Teckla · · Score: 1

      I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.) That is the epitome of KISS.

      And a written language with just two letters in the alphabet is simple too, right? So, let's do that!

      There's KISS and then there's KISS. C strings aren't the right kind of KISS.

    16. Re:Null Terminated Strings by davidwr · · Score: 1

      [kernel/library programmers] must be very concise

      That used to be but these days it's frequently okay or even desirable to add functionality like input-parameter-validation rather than be concise and skip the validation, leaving a gaping security hole in kernel or other code which may run with privileges high enough to be dangerous.

      Likewise, it may be desirable to have a larger piece of code that can test for the presence of hardware that may or may not be present and exploit it if it is there than to have smaller, simpler code that does things in a way that will work everywhere, but which will not take advantage of hardware that might be available.

      Notice that I said "may be." Part of the art and science of engineering your code is knowing the trade-offs between "smaller, simpler, but less feature-rich" and "bigger, more complicated, but more feature-rich" and knowing the intended and possibly-un-intended uses of your code and how much time and effort you and others have to create the code and maintain it later, then make the correct engineering choice for your particular situation.

      --
      Knowledge is how to play a game, intelligence is how to win, wisdom is knowing what game to play.
    17. Re:Null Terminated Strings by skids · · Score: 1

      I'd still prefer if pointers could keep both address and size of the buffer.

      Then use a struct with pointer and length. Use the right tool for the right job. ZTSs are for things that utilize the efficiency of knowing nothing is sending you strings longer than you can handle efficiently and can take advantage of not having to worry about syncing a length counter in RAM. If you use the functions that use ZTSs for multimegabyte content that you need to find the length of frequently, you're using them wrong.

      As crotchety as C is, at least they realized that a toolbox full of nothing but powered hammerdrivers is less than fully useful.

      (If only they had handled endianness better. Or at all.)

    18. Re:Null Terminated Strings by Anonymous Coward · · Score: 0

      A structure with a length and a string pointer (or a character array) is much more complex and that would reflect in more complex library functions.

      Not to mention that sticking a length value up front in a string would require either limiting to 255 length strings, or choosing a preference for "endian-ness". When you're trying to make a hardware-agnostic language, it was probably deemed wise to stay away from the issue and just null terminate.

    19. Re:Null Terminated Strings by gnupun · · Score: 1

      When you're trying to make a hardware-agnostic language, it was probably deemed wise to stay away from the issue and just null terminate.

      Yeah, imagine null-terminating a 2 MB string and then trying to obtain its length in some operation... too much processor time wasted.

    20. Re: Null Terminated Strings by Anonymous Coward · · Score: 0

      If you have a char * (not a string that's a C++ class) that is 2MiB long in a program I'd suggest a comp sci course in data structures rather than using a square peg in a round hole.

      Saying programming language X doesn't handle extreme case Y that is rarely if ever something anyone does is a great exercise in mental mastibation.

    21. Re: Null Terminated Strings by gnupun · · Score: 1

      Okay, but we're dealing with C and even in C++ you have to deal with null-terminated strings. Here's a case that is not extreme at all: copying a 100-byte string to another. Read below how inefficient the null char makes this very common and very basic operation.

      One example is FreeBSD's libc, where the bcopy(3)/memcpy(3) implementation will move as much data as possible in chunks of "unsigned long," typically 32 or 64 bits, and then "mop up any trailing bytes" as the comment describes it, with byte-wide operations.

      If the source string is NUL terminated, however, attempting to access it in units larger than bytes risks attempting to read characters after the NUL. If the NUL character is the last byte of a VM (virtual memory) page and the next VM page is not defined, this would cause the process to die from an unwarranted "page not present" fault.

      http://queue.acm.org/detail.cf...

    22. Re:Null Terminated Strings by bingoUV · · Score: 1

      I agree with the argument of having limitless strings - KISS principle is followed in C correctly, but only because limitless strings are desirable.

      It is not true that this is simpler than storing size separately. If storing size separately is a complication, inability to store \0 in a string is a limitation. We can work-around it by escaping, but then it adds complication, which was supposedly avoided by not storing size.

      So it was a choice between 2 kinds of complications, one of the complications was chosen because limitless strings were more useful than the ability to store evere possible byte in a string. Not an unconditional KISS.

      --
      Bingo Dictionary - Pragmatist, n. A myopic idealist.
    23. Re:Null Terminated Strings by SpaghettiPattern · · Score: 1

      You can't have a string longer than the amount of memory that is reachable by a pointer.

      Did you reread what you wrote? A pointer is nothing more or less than a memory address. A string pointer points to the first character in the string and the string can have any length (theoretically.)

      Do you mean, perhaps, that you can't have a C string that doesn't fit into memory all at once? Let's assume you do. That would be an academic limitation. I have never ever encountered a string so big. If you have the need to handle such enormous strings then you probably should study streaming (of characters or bytes.)

      You don't say. Sounds like this is relatively new to you.

      That's a silly tone you'd better ditch buddy.

      The former must be very concise

      That's complete nonsense. Source code size has nothing to do with object size, let alone suitability of a language for different problem domains. C's conciseness was useful in the 1970s and 80s, where memory used for source code whilst editing and compiling was a significant factor. Nowadays 10s or hundreds of K of source code is irrelevant in GB sized PC memories. The conciseness is worthless.

      I give to you that concise was the wrong word to use. However, well abstracted problems result in concise code and object, while at the same time the code remains readable. Beating the optimizer is foolish, but shouldn't be mistaken with well analyzed problems. Simply punching away in order to scratch the itch is a guarantee for revisiting the code unnecessarily.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    24. Re:Null Terminated Strings by BasilBrush · · Score: 1

      Do you mean, perhaps, that you can't have a C string that doesn't fit into memory all at once? Let's assume you do.

      That would be a very bad assumption, both because it isn't what I mean, and because it's irrelevant to the issue. Every element of a C string is addressable by a pointer. Regardless of whether it is real or virtual memory addressing. If you're talking about a stream that isn't addressable by a pointer, that's NOT a C string. A C string is a char*. A stream is NOT a C string even if it happens to be null terminated.

      Think I'm wrong? Then tell me what the result of strlen(). It doesn't even make sense.

      However, well abstracted problems result in concise code and object

      That's a quality of the algorithms and patterns used by the programmer, not the language.

      Simply punching away in order to scratch the itch is a guarantee for revisiting the code unnecessarily.

      Well that's a whole different discussion, for which you are just stating your point of view. Agile development methods tend towards writing the minimum code for a limited feature set, and adding and refactoring constantly. I'm not advocating either here as it would take us down a different path, but I just mention it because it shows you're just presenting your opinion, not anything objectively right.

    25. Re:Null Terminated Strings by SpaghettiPattern · · Score: 1

      The problem is that you usually don't know where the the allocated memory is finished.

      I understand the rationale behind the pointers like they are, but I'd still prefer if pointers could keep both address and size of the buffer. But it's too late now for such kind of redesign or upgrade.

      I understand what you mean. For most projects I do I share your desire to be slightly more casual with memory management. Although I am in the fortunate position to be able to choose a different language (I'm happy to use Java's StringBuilder to append ad infinitum), I cherish the basics I learned when I programmed C. Being able to think in the most basic elements is yet another perspective.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    26. Re:Null Terminated Strings by SpaghettiPattern · · Score: 1

      Too bad that Computer Scientists are a bunch of elitist Haters who only know COBOL from legend.

      It's cheap to knock a language with a huge installed base as COBOL, mostly because the syntax and the conventions are slightly awkward for "modern" eyes. (I say modern but the elitist dislike for COBOL I believe started in the 70ies.) COBOL is damn good at solving the kinds of problems it was designed for. I have even seen a shop that had/has a COBOL backend to the web applications it offered/offers.

      --

      I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
    27. Re:Null Terminated Strings by alexo · · Score: 1

      I believe none of you actually programmed in C. A string terminated by \0 can be represented by a single pointer and an have any length. You can also easily let the string keep growing (until the allocated memory is finished.) That is the epitome of KISS. If you use an 8 byte character at the beginning then you are limited to a string length of 255. A structure with a length and a string pointer (or a character array) is much more complex and that would reflect in more complex library functions.

      Some of us have been programming in C for 3 decades and have gained some sense of perspective. While the choice of using null-termination vs. explicit size may have been the correct one given the '60s and '70s state of the art, it is a poor one today.

      Null-terminated strings have several serious deficiencies:
      They cannot be used to store binary data, requiring another, redundant set of functions (with separate lengths)
      Similarly, they cannot be used to store UTF-16
      They are less efficient. In order to find the length of the string, get it's last character(s) or append to it, you must traverse it. If the string is long, parts of it may reside on pages that have been swapped out and touching them will trigger expensive IO operations.

      There is a reason that every OO library uses a length+data for string objects

    28. Re:Null Terminated Strings by angel'o'sphere · · Score: 1

      You got it all wrong, it is screws!
      Screws with a screw nut on the other side.
      Very carefully aimed holes to put the screw through. Very carefully arranged and finally fitted with a screw nut and finally made tight with a spanner!

      How can you mix that up with a mere baton spiked with nails?

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    29. Re:Null Terminated Strings by Anonymous Coward · · Score: 0

      I wonder why didn't they prescribe some sort of escape character (like in octet-oriented HDLC) which would allow any long memory object to have arbitrary content and still be end-character (zero or whatever) terminated? Like, 0x0 is end of object, say 0x01 is escape character which precedes null bytes in object contents and if there was an actual 0x01 in the object contents, it is replaced with a pair of 0x01s. For ASCII strings it would fall back to what we have now, but it could also accommodate binary byte strings. I understand that than you would have no safe estimate of storage space needed, but null-termination kind of pretends to solve exactly that "length not pre-known" problem, only for a subset of all possible contents.

  83. Obvious answer by Anonymous Coward · · Score: 0

    It's obvious. The intention was to do evil. -- my opinion, shared by millions

    1. Re:Obvious answer by DeputySpade · · Score: 1

      +1 insightful! dark, dark evil.

      --


      This space intentionally left blank
  84. Best feature ever: Intercal (and others) COMEFROM. by slashdice · · Score: 1

    I prefer Intercourse's COMEIN feature.

    --
    Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
  85. The C pre-processor by Chelloveck · · Score: 2

    The C pre-processor. The whole thing. The CPP is without a doubt the biggest WTF in language design. Hey, this C language is neat and all, but how about if we make it so that before you compile it you have to run it through a whole separate language processor with different syntax designed to do string substitution? And let's use that language to implement comments. And hey, how about using it to import common files? But since it's really just a string substitution, the import really just dumps a verbatim copy of the common file into the one being processed. If you have two identical include lines you get two copies of the common file inserted. Wouldn't that be *great*!?

    Okay, I understand the historical context and why it made sense at the time. I really do. But from a modern perspective it's definitely not in any way the sane way to do it.

    And for an honorable mention, how about the use of leading whitespace in Makefiles? Not only is leading whitespace significant, starting a line with spaces has a different meaning than starting a line with tabs!

    --
    Chelloveck
    I give up on debugging. From now on, SIGSEGV is a feature.
    1. Re:The C pre-processor by 91degrees · · Score: 1

      If you have two identical include lines you get two copies of the common file inserted. Wouldn't that be *great*!?

      The real beauty is that they can (and usually do) behave differently.

    2. Re:The C pre-processor by Jamu · · Score: 1

      The C pre-processor is the duct tape of C programming.

      --
      Who ordered that?
  86. Scheme by Anonymous Coward · · Score: 0

    As opposed to scheme which has =, eq?, eqv?, and equal?

  87. csh by dskoll · · Score: 1

    csh is one big wtf. Those of you on Linux/UNIX boxes with csh active, start csh and then type:

    else

    Keep typing stuff in.

    breaksw does the same thing. Who wrote that parser?

    1. Re:csh by beschra · · Score: 1

      That's just evil.

      --
      It is unwise to ascribe motive
  88. Who by Anonymous Coward · · Score: 0

    gives a shit?

  89. Re:PHP by Anonymous Coward · · Score: 1

    I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

    You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

    You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

    You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

    And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

    Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

    That’s what’s wrong with PHP.

    Yup. That sums it up for me.

  90. TenCore by Anonymous Coward · · Score: 0

    ...All of it. Just...All of it.

  91. R data.frame subsetting by pmarinus · · Score: 1

    A subset of a data.frame is a data.frame, unless you haven't set drop = FALSE, and "select" only one column.
    By default "the result is coerced to the lowest possible dimension. The default is to drop if only one column is left, but not to drop if only one row is left."
    When a result is reduced to 1 dimension its type changes, and R will throw an error if you use a data.frame method on the result.
    I advise anyone using R seriously to read The R Inferno to learn to avoid the many non-obvious features of R

  92. Re:PHP by countach74 · · Score: 0

    Wow I had never seen that rebuttal. I've stopped reading because it's mostly really bad--specifically, when I got to the "PHP error handling is fine" bit. I program all day long in PHP because that's what the shop I work for uses. It is simply not as productive as other languages. The writer of "PHP is a fractal of bad design" gives mostly-accurate, concrete reasons why developing in PHP is more time consuming than in another, sane language (I realize that his point is that its design is bad, which I think is true, but pragmatically speaking, most of us care about time spent than how "perfect" something is). Good luck proving otherwise.. argh, this "rebuttal" is just so bad, drawing on obvious straw mans, etc. Okay, /rant. I'm done. Thank you for linking it, though. :)

  93. MSSQL by netsavior · · Score: 3, Interesting

    I love the various different parsers MSSQL uses, and how very wrong things can go. Run this in SQL management studio and it will work fine... run it from the command line and it will give the below error. It will find \r\nGO\r\n and treat it as a block terminator... even if it appears in comments. This is the only command that it will find and execute within comments.

    declare @var as int
    set @var = 10
    print @var
    /*
    this is totally in the comments
    GO
    */
    print @var
    ------------
    output -
    ------------
    10
    Msg 137, Level 15, State 2, Line 1 Must declare the scalar variable "@var".

    1. Re:MSSQL by Anonymous Coward · · Score: 0

      That would be because GO doesn't exist in the language. GO is designated as the default statement delimiter by the common client tools, which happily parse it blindly from the text to split the whole file into commands that it will execute serially. You can even change the statement to something arbitrary.

      This, like much of the less sane stuff in MSSQL, was inherited from Sybase.

    2. Re:MSSQL by shutdown+-p+now · · Score: 1

      This is because "GO" is not actually a feature of Transact-SQL (the language itself) - it's a feature of the command line REPL, to signify end of input and beginning of execution. So it's not parsing the SQL there, it's just looking for a line that matches "GO", and then takes all the preceding text and hands it over to the server - which then actually parses it as SQL.

  94. Everything in Objective-C by JoeyRox · · Score: 0

    An absolute cluster-fuck of inconsistent syntax and bolt-on extensions.

    1. Re:Everything in Objective-C by Maury+Markowitz · · Score: 1

      @sythesize MY_ASS

      When I first used it, circa '99, it was small, light, and looked great.

      Now, not so much.

  95. Iverson's notation in APL by Anonymous Coward · · Score: 0

    It's pretty strange, in the best possible way.

  96. In VHDL you use loops to write code :) by Anonymous Coward · · Score: 0

    And?? They will get unrolled/flattened in more environments than just VHDL. Still much nicer and clear than flattening everything manually.

  97. Array indexing in C behaves like pointer math by tboulan · · Score: 1

    "I don't see it as a feature - so much as exposing the core of what C is about. Its all about pointers and getting to the memory directly with as little indirection as possible. Kind of beautiful, really." Michael Neale

    You could replace "Michael Neale" with NSA or credit card black hats, and make the quote even better.

  98. Impossible triangle of string comparisons by tepples · · Score: 1

    My approach is generally to always use "===" and explicitly cast things. It makes your errors more explicit.

    What you suggest is helpful for equality but not inequality, as I'm not aware of any <<< or >>> operator that means "less than and of the same type as" or "greater than and of the same type as" in the same sense that === means "equal to and of the same type as". The following impossible triangle of comparisons returns true in PHP:

    var_dump('123' < '123a' && '123a' < '45' && '45' < '123');

    1. Re:Impossible triangle of string comparisons by Anonymous Coward · · Score: 0

      O.o

    2. Re:Impossible triangle of string comparisons by MightyYar · · Score: 1

      Sorry, I didn't mean to accidentally defend PHP :)

      --
      W..w..W - Willy Waterloo washes Warren Wiggins who is washing Waldo Woo.
  99. Metapost by Required+Snark · · Score: 2
    Metapost is a part of Knuth's TeX suite of languages. http://en.wikipedia.org/wiki/MetaPost. It is a graphic language that emits Postscript and supports spline line drawing. It was derived from Metafont, the font generation language for TeX.

    First, Metapost is implemented as a macro language, so it is similar to C shell languages in the way it is evaluated. The symbols x, y, and z are predefined macros. For a location x the construct 3x is three times x. There are built in lengths, so 2cm and 1in are lengths. You can extend the language by defining you own macros for prefix or uinary and binary operations, which is the way that many of the operators are implemented.

    The if and loop syntax

    if boolean1 : expr1; else: expr2; elseif boolean2: expr3; fi

    for i=1 step t until n: statement; statement; endfor

    There are four levels of precedence. This is why multiplication by a constant can be expressed by putting a number in front of a value.

    These are just some of the syntax features. The data types include splines, transforms, colors and numeric pairs for points. Built in operations can find points where two curves intersect and sub-curve sections between intersections.

    It's fun in a strange fashion, and you can make some interesting geometrical pictures.

    --
    Why is Snark Required?
    1. Re:Metapost by NJRoadfan · · Score: 2

      Postscript itself can be fun and interesting. Many folks have taken it well beyond a page description language. Don Lancaster has been using it as a general purpose programming language for years: http://www.tinaja.com/post01.s...

      How about a Postscript web server? http://www.pugo.org:8080/

  100. CDC3300 FORTRAN: I=I by Anonymous Coward · · Score: 0

    The CDC3300 FORTRAN compiler would compile indexed array accesses as pointer accesses, keeping the pointers in one of the three index registers on that system. If you changed the index variable, the compiler would of course update the corresponding pointers.

    Unless you managed to update the index variable in a way invisible to the compiler, for example, by doing I/O into it. In which case, the pointers would not reflect your update. So for an index I, you had to type "I=I" after doing such I/O.

    And just why would you do such a daft thing as I/O into your index variable? Well, this wasn't FORTRAN 2015. Or even FORTRAN 77. Or even FORTRAN IV. This was FORTRAN II with a few extensions. It did not support anything like a C struct. But you could emulate a C struct using a named common block. And there was a CDC extension to do bulk I/O into common blocks called BUFFER IN and BUFFER OUT. So if your pseudo-struct contained an index variable (call it "I") used to indicate an element in an array in that pseudo-struct, every time that you did BUFFER IN into that pseudo-struct, you had to do "I=I".

    Needless to say, lots of confusing bugs from this one. ;-)

  101. gcc -Wall includes -Wparentheses by tepples · · Score: 1

    get neat one-liners for a thing most C programmers don't bother to do

    Not bothering to check whether an allocation succeeded is a problem.

    at the expense of adding a hard to notice source of bugs to every if statement.

    Several compilers display a diagnostic for if (variable=value) which is silenced with if ((variable=value)). GCC for example offers -Wparentheses to warn "when there is an assignment in a context where a truth value is expected, or when operators are nested whose precedence people often get confused about."

  102. drawfillmapleleaf by Anonymous Coward · · Score: 0

    Turing has a drawfillmapleleaf procedure that....draws a filled maple leaf.

    Reference here: http://www.beens.org/turing/Turing_Graphics_Summary.htm

  103. COBOL WHILE loops by hudsucker · · Score: 1

    Standard COBOL (COBOL-85) has both DO WHILE and DO UNTIL loops. But UNTIL loops are actually WHILE loops: they test the exit condition before executing the loop.

    If you really want an UNTIL loop you have to code extra syntax:

    perform until condition with test after
      statements...
    end-perform

    1. Re:COBOL WHILE loops by shutdown+-p+now · · Score: 1

      This seems perfectly logical to me. There's nothing about "UNTIL" that implies that condition will be tested after the loop - the only meaning that the word carries is the negation of the condition. I suspect that this confusion comes from Pascal, where "repeat .. until" was the way to write loops with condition testing after the body - but there it was more a quirk of a language, and "until" by itself still just meant negation of the condition; the order of evaluation was defined by the relative ordering of parts of the loop in the syntax:

      while condition do staement;
      repeat statement until condition;

      In your example, "perform until condition" comes before "statements", so it makes perfect sense to check the condition first.

      The best syntax for such loops was actually in MS dialects of BASIC (QBasic, VB etc) - it had WHILE, UNTIL and pre- and post-conditions in all the possible combinations, as well as infinite loop, all syntactically uniform and very obvious:

      DO
      ..
      LOOP
       
      DO WHILE condition
      ..
      LOOP
       
      DO UNTIL condition
      ..
      LOOP
       
      DO
      ..
      LOOP WHILE condition
       
      DO
      ..
      LOOP UNTIL condition

    2. Re:COBOL WHILE loops by hudsucker · · Score: 1

      Yeah, but remember that inline statements didn't come until the addition of explicit scope delimiters. The most common form actually is:

      perform routine-name
        until condition

      and in that case, the UNTIL really does come at the end. But it still is really a PERFORM ... WHILE.

      The fact is that this trips up programmers. They forget that they need to init the condition before the PEFORM, lest it never execute.

    3. Re:COBOL WHILE loops by shutdown+-p+now · · Score: 1

      Now that makes sense. Yeah, the way I'd read it is definitely by assuming that order of execution follows textual order.

      It sounds a lot like one of the quirks in ancient languages that slowly evolved over time. More recent BASIC dialects are also chock full of these (which is why it was very nice when QBASIC did a clean new syntax for loops).

  104. Java iterators by tomhath · · Score: 1

    I never understood why an object has a method that returns an interator instead of having the methods themselves. There might be a good reason, but it has always escaped me.

    1. Re:Java iterators by Nedmud · · Score: 1

      It's because iteration needs to maintain state (namely, where you're up to in the collection). If this was stored on the object, then you wouldn't be able to have 2 iterations active at once. Things like this wouldn't work:

      // print all possible pairs
      for (Person x: people) {
      for (Person y: people) { // oops, now we're interfering with the iteration that's already happening over people
      System.out.println("Pair (" + x + ", " + y + ")");
      }
      }
      (Ugh, I forgot how to include code in a slashdot comment.)

    2. Re:Java iterators by shutdown+-p+now · · Score: 1

      Because iterator has iteration state, and you might want two parts of code to iterate over the same collection concurrently (it doesn't even have to be threads - it might be just nesting, e.g. a function is iterating over an array, and during one iteration calls another function which also iterates over the same array).

  105. Map multiple OpenIDs to a single account by tepples · · Score: 1

    The user is coming FROM those gatech.edu and whitehouse.gov domains to a third one.

    An OpenID relying party is allowed to map multiple identifiers to a single user account. So if gatech.edu and whitehouse.gov are OpenID providers, you can register using your identifier from gatech.edu, add your identifier from whitehouse.gov to the same account, and then get the same userid (which maps to the same grants) no matter which identifier you used. Stack Exchange supports this feature if I remember correctly, and I know the authentication system I wrote for PhilsHobbyShop.com supports it.

  106. Shared hosting by tepples · · Score: 0

    Perhaps one of the reasons PHP endured despite being such a slapdash language was that some commercial shared web hosting providers tended to charge less per year for packages that allow only PHP than for packages that also allow Perl, Python, or especially Java.

  107. Pascal boolean operators by chubs · · Score: 1

    FreePascal: logical and bitwise 'and' and 'or' are the same operator, it just chooses one for you based on the operands. Example: "if (i < 5 and j < 10)". The compiler tries to do a bitwise and of 5 and J, then compare it to i, and then it gets confused about how that result (a boolean) can be less than 10

    1. Re:Pascal boolean operators by shutdown+-p+now · · Score: 1

      This is standard Pascal, not specific to FreePascal. IIRC it was also the case for Modula-2, Delphi and other derivatives.

      It is actually fairly logical in a statically typed language. The only reason why C needs different operators for this is because it didn't have the boolean type originally, so you needed some way to tell whether these two integers are to be treated as bools or as collections of bits. Since Pascal always had proper booleans, it could just overload the same operator.

  108. Powershell by plopez · · Score: 1

    When I first saw PowerShell my first thought was it borrowed syntax from COBOL.

    --
    putting the 'B' in LGBTQ+
  109. Or things you can't do by phorm · · Score: 1

    I've always wished that you could do the following

        if ( a == b == c)
    or even
        if ( a c )
        etc

    But most languages you need

        if ( a == b && b == c)
    or
        if ( a b && b c )

    1. Re:Or things you can't do by phorm · · Score: 1

      UGH, htmlization ate my greater and less than signs!

    2. Re:Or things you can't do by david_thornley · · Score: 1

      In Lisp, you can do (= a b c) or (< a b c).

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  110. Python False = True by plopez · · Score: 1

    Programmers are rarely sane.

    --
    putting the 'B' in LGBTQ+
  111. Swift's ? and ! by Maury+Markowitz · · Score: 1

    No more needs to be said.

  112. Rather non-intuitively, by Anonymous Coward · · Score: 0

    in brainf**k, you use . to accept one byte of input and store its value in the byte at the data pointer.

  113. SLIM in robots: a horrible clone of Darmouth Basic by Anonymous Coward · · Score: 0

    Robot programming language named SLIM.

    Let's see:
      In principle, you have wiggle room of 500 integers (suffix: %), 500 floats (suffix: !), 50 strings (suffix: &), 8 robot positions, 8 shifts (kind of offset value applied to a robot position to to dynamically modify it), 8 buffers (may contain 64kb of data, instead of 200 bytes the strings have; handy with socket communications) and 8 shift registers (used mainly with serial port) but global and another set private to "unit". Keep in mind though that top part of the integer, real and string areas are also occupied by built in PLC.

    There are no variable names! Instead one refers to variables just by number L10 %by reference: L%[10], so at leas there are arrays. Variable names are bolted on the system via preprocessor, but unlike CPP, it does not do tokenization by white space, so definitions "count,L10%" and "countervar,L11%" interfere with each other. At least it causes a compilation error instead of bug, with "L10%ervar" ending into the program.

    Oh, and there are variables with names, defined with DIM command, but they can't be used with most built in commands, so they can only really be used to hold intermediate values in calculation. Local variables wont work with all commands either, specially I encountered that _optional_ TCP/IP socket functions refused to work with local variables, but confusingly one could use a "DIM variable" as a parameter to those. I don't know what is supposed to be a bug here and what not...

    There are two types of subroutines. Classic basic like "GUSUB", and something called "user procedures", that may contain above mentioned useless "DIM variables" and supposedly allow writing safe code (much use for that with maximum 999 lines). Maximum stack depth is 8 and maximum parameters per user procedure 3. Also, the user procedure defining line can't be longer than 100 characters, elsewhere the maximum line length is 255. I want to hit every member of the committee that decided on this broken feature and hug the poor programmer who had to implement it.

    Line numbers are present too! Labels can be used, but not everywhere, as some robot movement command take line number as as a step to go to if an error occurs. The programmer does not supply the line numbers though, instead they are implicitly the same as the line count of the program, meaning blank lines count! This is possible because most of movement oriented programs are entirely done on teach pendant, which keeps the line numbers updated. This, and the fact that commands with "expressions" can't be edited with teach pendant at least promote modularity, as one must separate the program's movement parts and business logic parts to different files.

    This,my friends in a product released in 2011! The worst thing is, all the robot controllers, PLC's, smart cameras etc. program quite similarly. The best system so far I have met was in cognex cameras, where the environment was modeled after _spread sheets_. Sounds horrible but was 10x nicer than the abominations that take inspiration from commodore basic.

  114. FORTH by david_thornley · · Score: 2

    : CELEBRATE FORTH LOVE IF HONK THEN ; and remember that : ? . ! ; is a straightforward part of the language definition.

    --
    "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  115. == operator in Java by vbguyny · · Score: 1

    The == operator in Java is similar to the == in C++ for strings where is compares the memory address and not the string value. I understand why this is in C++ because strings are pointers to chars but in Java the datatype is String. I was pulling my hair out in college on this one! Fyi, you need to use the equals function on Java to compare values.

  116. + operator for string concat? by HiddenL · · Score: 1

    '1' + 1; returns '11'. It's weird when you have javascript's type coercion.

  117. Lua[0]? by Anonymous Coward · · Score: 0

    IBM's RPG language also starts with 1.

  118. Re:I don't know about programming languages... by Anonymous Coward · · Score: 0

    I think it has more to do with younger web devs being taught to not have more than one screen of content on a page. I taught an HTML class at a local community college and got in trouble for teaching students to put more than a single screen of content on a page. The head of the department believed users weren't able to scroll so you shouldn't even have a vertical scrollbar. Too many teachers misunderstand the guideline to put important things "above the fold" is a law rather than a good design rule of thumb.

  119. String concatenation operator in awk by Medievalist · · Score: 1

    In all the various awks the string concatenation operator is implicit. Brian Kernighan is quoted as saying "It seemed like a good idea at the time".

    Thus, awk literally has an invisible operator. Most coders make this a little more obvious with an explicit space, ASCII code 32 (decimal), but it's still invisible. Hijinks ensue.

    Other that this, awk is admittedly a great language for text processing. And the GNU awk is an exceptionally good version - it permits fixed fields and socket I/O and has numeric conversion operators.

    1. Re:String concatenation operator in awk by Anonymous Coward · · Score: 0

      The HAL/S language used for the Space Shuttle General Purpose Computers also uses the space character (actually, adjacency of terms) for multiplication. Again, I'm sure it seemed like a great idea at the time. Shuttle software tends to include a lot of math and it made reading that code uniquely irritating.

    2. Re:String concatenation operator in awk by Gunstick · · Score: 1

      well, looks like awk borrowed stuff from everywhere.
      Like the invisible string concat reminds me of what echo does with it's parameters in the shell.

      and it's still my preferred way of doing things.
      I solved a lot of problems on codeeval.com with awk, and got quite good results. The code is really fast.

      --
      Atari rules... ermm... ruled.
  120. Quirk in MATLAB array syntax by jdagius · · Score: 1

    MATLAB was one of the first languages to allow lists of comma-separated numbers between square brackets e.g. [1,2,3,10] to be interpreted as indexed numeric arrays or vectors. A lot of languages do that now, but MATLAB was perhaps the first to do this in 1984. A little-known quirk is that the commas are optional! [1 2 3 10] etc. This was probably introduced as a 'convenience' feature (though typing a space isn't that much faster than typing a comma). But there is a glitch ("feature") in the syntax that interprets space-separated negative numbers differently than you'd expect. So [ 1 2 -3] is interpreted as [1,2-3] (value = [1,-1]) because the precedence of arithmetic operators is higher than list operations.

    MATLAB hasn't fixed this 'feature' yet, because it would undoubtedly break a jillion apps around the world. So you must be careful to type [1 2 (-3)] if you are allergic to commas.

    BTW it's been fixed by default in OCTAVE, MATLABS free-software clone, but you turn 'quirks' on, if you want to preserve the quirky behavior.

  121. Optional braces after if by eminencja · · Score: 1

    The parens in the condition should be optional instead. I think new languages (go, Perl6) do it like that.

  122. Platform lock-in by Shompol · · Score: 3, Insightful

    Platform lock-in is the strangest feature of some languages that purposely defeat all the progress we made since Assembler. This is why I will never C#

    1. Re:Platform lock-in by brystar · · Score: 1

      Actually I spent this week writing C# in Visual Studio for Android and IOS devices. The new Xamarin.Forms is fantastic, native UI but still cross platform C#. Microsoft doesn't seem to be locking anyone in and even standardized the platform enabling cross platform development.

    2. Re:Platform lock-in by Anonymous Coward · · Score: 0

      C# isn't a closed platform. It is a completely open standard based on ECMA-334 and the latest C# compiler "Roslyn" is totally open source (download it from http://roslyn.codeplex.com/ ) and so can be built on any platform. Anyone is free to implement the C# specification and use the compiler. Also, a large part of .NET (that framework that C# is part of) is now open source - http://roslyn.codeplex.com/ - and is cross-platform. For instance, ASP.NET vNext runs perfectly on Windows, Mac and Linux - and is open-sourced on https://github.com/aspnet/Home

    3. Re:Platform lock-in by Shompol · · Score: 1

      Beware of Greeks bearing gifts

    4. Re:Platform lock-in by Anonymous Coward · · Score: 0

      So this github project is "lock-in" in your biased POV
      http://www.mono-project.com/do...
      OR https://roslyn.codeplex.com/
      But not Java?

  123. Sloppy typing in javascript by MichaelSmith · · Score: 1

    Pass the wrong type of object to a javascript library. The library happily accepts your crud, passing it through 14 levels of function calls and then says something useful like "a is not a function".

  124. Yes, there's only one right way - my way by raymorris · · Score: 1, Troll

    Perl is my preferred language for the majority of tasks that I do. I really like Perl overall. TIMTOWTDI annoys me, though. There is a right way to do it. Once is a great while, there are two correct ways, and still one best way.

    TIMTOWTDI seems more appropriate for PHP, "do it however, as long as it looks like it kinda works for now. It's not like we're actual programmers who know what we're doing".

  125. Checking enough? Careful programmers like post-* by raymorris · · Score: 1

    These two are very, very handy for careful programmers, who don't just assume that everthing always works, and that noone is trying to hack, or enter "weird" input like a name with a single quote, such as o'Malley.

    Examples:
    open(INPUT, $file) or die "Couldn't open input: $!");

    compare other languages, where being careful requires that every other line start with "if (!":
    if(!open(INPUT, $file) ) {
            die "Couldn't open input: $!";
    }

    Similarly:
    die ("That's an awfully long name") if (($name > 1024));
    vs:
    if ($name > 1024) {
            die("That's an awfully long name");
    }

    If you're regularly checking your assumptions, I think the syntax is very handy.

  126. magical extra parens by raymorris · · Score: 1

    I'm not sure how I ended up typing those extra parens. Odd.

  127. Objective-C by LihTox · · Score: 1

    No one's mentioned Objective-C's bracket notation for calling methods. Instead of obj->method(argument) or obj.method(argument), it's [obj method:argument]. Perfectly logical I'm sure, but the few times I've tried to write Objective-C code I've always had a hard time wrapping my brain around it.

  128. Tcl by LihTox · · Score: 1

    Tcl is strange in a number of ways. One is that you don't assign variables by saying "x=5", you write "set x 5" instead. Nor can you do any calculations outside of the expr command (in most cases), so instead of writing "x=5*y+3", you would write "set x [expr 5*$y+3]"

    I'm still fond of Tcl/Tk, in spite of that. :) What other language can give you a text editor in one line? "pack [text .t]"

  129. Ruby is great, but ... by Anonymous Coward · · Score: 0

    ... with C, C++, Objective-C, java and perl you can say "function name/method name (args)" Ruby chokes if there's whitespace between the function/method name and the arg list.

  130. MUMPS by jdschulteis · · Score: 1
    MUMPS, where every keyword has a 1-to-3 letter abbreviation, resulting in code like this:

    %DTC
    %DTC ; SF/XAK - DATE/TIME OPERATIONS ;1/16/92 11:36 AM
    ;;19.0;VA FileMan;;Jul 14, 1992
    D I 'X1!'X2 S X="" Q
    S X=X1 D H S X1=%H,X=X2,X2=%Y+1 D H S X=X1-%H,%Y=%Y+1&X2
    K %H,X1,X2 Q
    ;
    C S X=X1 Q:'X D H S %H=%H+X2 D YMD S:$P(X1,".",2) X=X_"."_$P(X1,".",2)
    K X1,X2 Q
    S S %=%#60/100+(%#3600\60)/100+(%\3600)/100 Q
    ;
    H I X S %Y=$E(X,1,3),%M=$E(X,4,5),%D=$E(X,6,7)
    S %T=$E(X_0,9,10)*60+$E(X_"000",11,12)*60+$E(X_"00000",13,14)
    TOH S
    %H=%M>2&'(%Y#4)+$P("^31^59^90^120^151^181^212^243^273^304^334","^",%M)+%D
    S %='%M!'%D,%Y=%Y-141,%H=%H+(%Y*365)+(%Y\4)-(%Y>59)+%,%Y=$S(%:-
    1,1:%H+4#7)
    K %M,%D,% Q
    ;
    DOW D H S Y=%Y K %H,%Y Q
    DW D H S Y=%Y,X=$P("SUN^MON^TUES^WEDNES^THURS^FRI^SATUR","^",Y+1)_"DAY"
    S:Y
    [...]

    1. Re:MUMPS by brausch · · Score: 1

      It's even worse than you think! :-) White space is significant (reminds of makefiles and tabs vs spaces). The above source isn't quite right. There need to be TWO spaces after the Q:'X in the line beginning with a C.

      Having said that, I love programming in this language (well, Intersystems Caché actually). The database and language are fully integrated with a very powerful standard library.

      --
      "Almost every wise saying has an opposite one, no less wise, to balance it." - George Santayana
  131. C# GoTo statement by BladeMelbourne · · Score: 1

    The C# GoTo statement is pretty uncommon to see in use:

    http://msdn.microsoft.com/en-u...

  132. + operator in JavaScript? by Anonymous Coward · · Score: 0

    I'm not familiar with JavaScript but I thought the plus sign is an arithmetic operator? var1 + var2 = output

    for i = i++;

    I forgot my C++. lol

  133. Total control by Horus1664 · · Score: 1

    Gotta love a BXLE or perhaps a CDS for those special occasions? Or what about a MVO? (You know who you are)

  134. end of line codes by John_Sauter · · Score: 1

    Probably the same way that most popular operating systems store text files as a list of lines separated by newline characters, encoded as 0x0A on UNIX or Windows but 0x0D on Apple II or classic Mac OS. VMS is an exception in that its "non-stream" text files have each line prefixed by its length.

    The conventions for line endings are based on history. DEC's operating systems and operating systems descended from them use CRLF because that is what you had to send to an ASR-33 teletype at the end of an output line. UNIX and its descendents use NL, which has the same code as LF, because they were targeted at later printers.

    By the way, the VMS record length field was 16 bits, avoiding the limitation of 255 characters in systems which used only 8 bits for the string length.

  135. loserville by Anonymous Coward · · Score: 0

    Wow - like how many times are we going to go rounds with the quirks of a language. I mean this is just getting sadder and sadder. We ARE in a tech bubble, and its goin to pop pop pop - and all these idiots who spend time writing about quirks and comparing languages who can justify their time on this stuff should be the first ones out the dooooor!!

  136. Matlab is full of strange features by drolli · · Score: 1

    -Possibility to access the "parent" scope
    -Distinction between "workspace scope" and "global variables"
    -Really weird stateful behaviour when using/declaring global variables
    -Impossibility to redirect the output of commands under special circumstances
    -Lazy copy in combination with slices (yeah, awfully practical, but run a profiler to see what happens)
    -At least two different ways of associating data with "handle objects"
    -"handle objects" (feels like the early 80s)
    -weird scopes for function declarations
    -absence of a decent "map" operator
    -half-assed "function handles"

  137. Object Vs Primitive by Greyfox · · Score: 1

    In assorted languages. Java and vbscript being particularly problematic, if you're a library programmer. "Oh, I'd like to write this generic container of things but I can't make it generic because some programmer might try to store an int in it :-/" Java's introduced some features to address that, and it's quite easy to solve in vbscript by never programming in vbscript.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  138. Perl, PHP, Lingo, Transcript, TypoScript, Lisp by Qbertino · · Score: 1

    Perl is pretty bizar in a hilarious sort of way - almost every aspect of it. PHP, being Perls former template engine, sheds most of that just to add in it's own featureset from wonderland. Both get the job done, PHP a little more so.

    Coulnd't say that for Lingo though. As far as regular usage PLs go, Lingo is about as shitty as it gets. 'Please' is an actual Lingo keyword - with no effect other than to make the sourcecode more polite. No joke. And seriously - that is not even its crappiest feature. If you want to kill braincells and a mixture of crystal meth and crack isn't fast enough, check out Lingo. Gladly it's basically gone extinct since the demise of Director, its platform.

    Transcript is simular to lingo, without the outlandish crappyness - but still pretty bizar.

    TypoScript is Typo3s configuration language. Think of a total programmer n00b learning just enough PHP4 to do turing complete stuff then inmediately trying to implement Basic for his CMS with it and failing one 3rd it but keeping the ruins as main means of configuration. Typoscript is what happens when a guy who can't programm takes psychoactive drugs and then takes a shot at it.... Luckyly there are some good oreillys on it, which makes it bearable. Sort of.

    Perhaps the language with the most bizar appearance is Lisp./eLisp. How anyone could come up with that syntax is totally beyond me. It must be realy powerfull if it is still around. ... Then again, emacs is a very strange programmin itself, so no supprise here.

    --
    We suffer more in our imagination than in reality. - Seneca
  139. wat by spyke252 · · Score: 1

    I'm surprised no one has posted wat yet. Even though it's a video, I really found it interesting and funny.

  140. C has bigger problems than that trivia by bzipitidoo · · Score: 1

    The "if (a = b)" syntax is among the first things newcomers to C are warned about. It's not a big problem.

    Null terminated strings are a bigger problem. What do you do if you want to embed nulls in a string? Not use the entire string.h library for starters, have to write your own routines. It really is better to store the length in a simple integer, as long as it's not stupidly small like in Turbo Pascal where they set aside one measly byte, thus making the maximum length a paltry 255 characters. There are simply too many use cases where length information is needed. Having the length makes a strlen function trivial and run in constant time, instead of a time dependent upon the data. We now have the String class in the Standard Template Library which addresses these problems.

    Bigger yet are the limitations of the function call syntax. This is not just C, but most programming languages that originated in those times. Most functions have a fixed number of parameters. If it's known how many parameters there are, it is not necessary to enclose the list. Basic math is done without that, eg. c = a +b instead of something gross like equal(&c,add(a,b)), Why can't functions be done the same way? Because they decided to allow variable numbers of parameters, with the printf function being the most prominent example of such a function. This was done in a very awkward manner. Consequently, most programmers avoid it. But we still have to include the parentheses even for functions with a fixed number of parameters. C enshrined parentheses as basically a sigil to distinguish function names from variable names. What does C gain from this? The ability to curry? No. Recursive functions? No, don't need variable length parameter lists for that, it does recursion anyway. The good in C's function syntax is that the programmer doesn't have to use a key word like "call" to call a function, and C has no unnecessary distinction between a function and a "procedure" as in Pascal. Can sort of do some functional style programming by passing pointers to functions. But they didn't get functions good enough. Operator overloading is an ugly hack that tries to address these inherent deficiencies. It doesn't succeed, can't go far enough. Same with polymorphism and name mangling. And C++'s addition of prefacing a parameter with an ampersand is nice, but merely a syntactic shortcut. The latest C/C++ standards also nibble at this problem with things like the introduction of "auto". But it still has the fundamental problem of excessive parentheses, like in LISP. C is all about brevity and economy, in both syntax and compiled code, but in this, they didn't do as well as they could have.

    Then there's parallel programming. C wasn't designed for it, and can't do it clearly and cleanly. To be fair, there isn't a general purpose language that really nails parallel programming. Does it make sense to have to clear an array by using a loop, as in "for (i=0; i<MAX; i++) a[i] =0;"? Not if you're trying to use the massive parallelism of current commodity graphics cards. To this day, parallel programming remains a sort of black art, to be attempted only by the most skilled and intrepid programmers. Similar to the reputation that assembler still has in some programming circles, or that network programming used to have (sockets, ooh, scary!) Just include the magic library and call the magic functions, let them handle the complexities.

    And that brings me to the next point, the libraries. The language designers didn't put enough consideration into libraries, or they would have realized how huge the entire set of libraries could get and made some provisions for that. Instead, years later namespaces were added. The next problem with the libraries is related to the problems with function calls. The library interface is too language specific. Those header files are a mess that makes it much harder for another language to use the related functions. A common solution is to resort to "wrappers", like m

    --
    Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
    1. Re:C has bigger problems than that trivia by skids · · Score: 1

      Null terminated strings are a bigger problem. What do you do if you want to embed nulls in a string? Not use the entire string.h library for starters, have to write your own routines.

      Yes. Because those are different constructs. Live with the fact that both are useful.

      Having the length makes a strlen function trivial and run in constant time

      And having a hash makes ==/=! run in constant time most of the time. And then you could also add an indicator for encoding. And some flags for the garbage collector or if not that at least a COW flag. And then suddenly you find you're using more than a cache line for just one variable in a critical code section even when you're pabsolutely sure the string can only contain "TRUE" or "FALSE". And that is part of why my applications seem to run slower and slower every year despite my hardware being upgraded.

      Personally I prefer functions to use parens. Like in math. It makes sense visually and keeps things organized. Are you allergic to the shift key or something, or do you just enjoy the mental challenge of parsing things in your head. You'd seriously prefer this:

      thingA thingB thingC,4,7,thingD thingE

      to this:

      thingA(thingB(thingC(4,7)),thingD(thingE))

      ?

      For which one do you have to consult the documentation, if even extant, to figure out the arity of things?

    2. Re:C has bigger problems than that trivia by bzipitidoo · · Score: 1

      Ever used a Reverse Polish calculator? Or postfix or prefix notation? It does work. Yeah, I seriously would prefer prefix notation to superfluous parentheses.

      Maybe you feel it's unclear? There's an answer to that too. Whitespace, as in Proper Indentation.

      thingA
      . thingB
      . . thingC 4 7
      . thingD thingE

      Before you ask, no, the whitespace is not required, This isn't Python. It is merely there to aid coders, same as any other indentation in C source code.

      --
      Intellectual Property is a monopolistic, selfish, and defective concept. It is "tyranny over the mind of man"
    3. Re:C has bigger problems than that trivia by skids · · Score: 1

      Well
      you
      can
      go buy
      a
      500x65000
      resolution
      monitor
      then.

    4. Re: C has bigger problems than that trivia by Anonymous Coward · · Score: 0

      Null is not a valid Unicode character. There should never be a null in a "string" of characters. If you have nulls in your data, use uint8_t instead of char. Yes, I know it's a typedef on most platforms to "unsigned char", but it makes it clear that it's not character data.

  141. Python False = True by Anonymous Coward · · Score: 0

    Py3 changed this.

    SyntaxError: can't assign to keyword

  142. And the correct answer is by Anonymous Coward · · Score: 0
  143. Article is clickbait wank... by Aardpig · · Score: 1

    ...none of its examples are in anyway WTF. I can't believe nobody has mentioned Fortran's arithmetic IF yet...

    --
    Tubal-Cain smokes the white owl.
  144. where are my perlmongers? by Anonymous Coward · · Score: 0

    I had a quick scan through and didn't see many real perl comments :/

    Im JAPH so generally notice when moving to other languages, here's some of the main ones that come to mind:

    - Default variables - perl adds a range of variables based on context, such as @_ for the array of args passed to a subroutine, or the default input $_ which doesn't even need to be specified in many cases. (i.e. "shift" is equivalent to "shift $_" )

    - the basic variable type prefixes: $scalar, @array, %hashmap - though you often work against $references when using arrays or hashes anyway.

    - context based return values - a sub can check if it was called expecting a scalar or array as a return value, and act accordingly.

    There are plenty more but those where what immediately came to mind, and are already more unique than most of the examples mentioned so far. (IMO)

  145. Re:php for sure. heck, java too. by Anonymous Coward · · Score: 0

    Yet another person who doesn't know enough about the language to know when he's reading bullshit.

  146. Re:SLIM in robots: a horrible clone of Darmouth Ba by Anonymous Coward · · Score: 0

    Dartmouth BASIC? Try HP in 1974
    HP 2000 C/F Time share BASIC
    Dual HP2100 with swap drum, user file and system disk, 9 track backup tape.
    256K Word, 32 users. 110 Baud dialup
    10KB program space (tokenized), Per user (seemed like a lot more)
    Vars A0-Z9, strings, 2d mats
    Computing environment supplied to Portland Or. public schools High school student body in 1970-1975?

  147. MUMPS by brausch · · Score: 1

    In MUMPS, now mostly used in Intersystems Caché, white space is significant in a strange way. There are places where one space is required and other places where two spaces are required.

    --
    "Almost every wise saying has an opposite one, no less wise, to balance it." - George Santayana
  148. no by fisted · · Score: 1

    > if (a = b) assigns the contents of b to a and executes the code following if b 0. Who the hell thought that would be a good idea?

    There are indeed times it is useful but I 100% agree, using the _same_ syntax as assignment was full retard.

    The same syntax as what exactly? = is just assignment, nothing else.

    They should of used:

    You should of used "have". And your proposal is utter crap.

  149. Verilog by Anonymous Coward · · Score: 0

    Verilog is unbelievably bad. For instance, a wire in Verilog can take on four possible values: 0 (false), 1 (true), X (unknown), or Z (undriven). This works great for a large subset of the language (including, e.g., gates, assignments, most expression operators).

    And then you get to the procedural language, where anything that's unknown gets arbitrarily treated as false! For instance, if a is X, then this will print False!:
          if (a == 0) $display("True!") else $display("False!")

    This almost sort of makes sense from a simulator-design perspective. If it was just for debugging code, it would be reasonably okay. But then... the procedural language is basically mandatory for any sequential logic like a latch or a flip-flop, so even the most basic way of writing an edge-triggered register:

            always @(posedge clk) q = d;

    Will completely incoherently treat a transition from 0 to X as a posedge. Anyway, the procedural language of Verilog is, I would contend, even worse than PHP.

  150. Re:C by jrumney · · Score: 1

    sizeof(string) (I may have got the name of the function wrong) returns the length of a single byte rather than the length of the entire string.

    Not quite, it should return the size of a memory pointer on the target machine, since that is what a "string" is in C.

  151. White space matters by xMonkey · · Score: 1

    FU makefile and the bastard who thought it was a good idea.

  152. Use Deslide! by antdude · · Score: 1

    http://deslide.clusterfake.net... d.com/slideshow/163234/head-scratchers-10-confounding-programming-language-features-434442 OR http://desli.de/11J3

    --
    Ant(Dude) @ Quality Foraged Links (AQFL.net) & The Ant Farm (antfarm.ma.cx / antfarm.home.dhs.org).
  153. Powershell by Anonymous Coward · · Score: 0

    I was actually in the room when the decision was made, so this is the god's honest truth: It's because DOS had already camped out on , |, and &. We could have used ==, but it just wouldn't have done to have -gt, -lt, -or, and -and, but stick with ==.

    Jim, if you're reading this, I want you to look upon your legacy and weep.

  154. Powershell by Anonymous Coward · · Score: 0

    Sorry, that's < >, |, etc. Can't post the alligator signs on web forums...

  155. JS by elbazo · · Score: 1

    Whole of javascript. absolute fucking mess.

  156. Objective-C Blocks by Anonymous Coward · · Score: 0

    A language feature which I find confusing, quirky, and elegant all at the same time.

  157. Maybe it is trying to preserve sig figs? by Marrow · · Score: 1

    Maybe it does not want to promote the number of significant figures that integer represents?

  158. Return value optimisation by Anonymous Coward · · Score: 0

    I found out about this the hard way. Apparently optimisations that optionally change the behaviour of code in unpredictable, unexpected ways are just fine.

    Net result: my rather elegant code had to be replaced with a long, ugly hack. Not happy.

  159. Re:C by smellotron · · Score: 1

    it should return the size of a memory pointer on the target machine, since that is what a "string" is in C.

    A string literal in C is of type char[N] (where N is the minimum value required to store the whole string, including the null terminator). String literals degrade to pointers quite easily, so yours is a common error. So...
    const char direct[] = "string";
    const char *const indirect = "string";
    sizeof(direct) == 7;
    sizeof(indirect) == sizeof(char*); // 4 or 8 on most 32- or 64-bit architectures, respectively

  160. JavaScript parseInt base for leading 0 changed by Paul+Fernhout · · Score: 1

    http://www.w3schools.com/jsref...
    "Note: Older browsers will result parseInt("010") as 8, because older versions of ECMAScript, (older than ECMAScript 5, uses the octal radix (8) as default when the string begins with "0". As of ECMAScript 5, the default is the decimal radix (10)."

    --
    A 21st century issue: the irony of technologies of abundance in the hands of those still thinking in terms of scarcity.
  161. Re:C by jrumney · · Score: 1

    If you think all strings can be defined as const char arrays, then your experience with C programming must be very limited. The vast majority of strings in use in real world programs are neither const, nor defined as arrays.

  162. Re:C by smellotron · · Score: 1

    If you think all strings can be defined as const char arrays

    Lucky for both of us, that's not what I think. I specifically said "string literal", which is a const array and not a pointer. This is relevant for the sizeof discussion because the operator is evaluating the size of the array (therefore the entire string) and not just evaluating the size of a pointer.

  163. A language with only one operator by descubes · · Score: 1

    XLR (http://xlr.sf.net) has essentially a single operator, -> which reads as "transforms into". The rest is defined in the library.

    (OK, to be honest, that's the theory. In practice, the current language implementations take many shortcuts).

    --
    -- Did you try Tao3D? http://tao3d.sourceforge.net
  164. Malbolge's useless encryption by grewil · · Score: 1

    I find Malbolge's encryption an interesting and nice feature. After an instruction is executed, the value of the current instruction (without anything added to it) will be replaced with itself mod 94. Then, the result is encrypted with one of two methods.

    http://en.wikipedia.org/wiki/M...

  165. Re:Best feature ever: Intercal (and others) COMEFR by cold+fjord · · Score: 2

    Elxsi Fortran had it long ago.

    Richard Maine in FORTRAN IV program illustrating assigned GO TO on web site

    The Elxsi compiler in the mid 80's actually implemented the comefrom
    statement (and several variants) as a continuation of this spoof. It
    wasn't documented, but I found out about it when Ralph Merkle (one of
    the developers) suggested that I might be amused by looking at a certain
    area in the compiler executable file. When I did so, I found a list of
    strings containing mostly familliar Fortran keywords. Amidst those, I
    spotted comefrom. A quick check verified that the statement actually
    compiled and worked as "expected".

    I later heard that the statement was pulled from the compiler after a
    customer submitted a bug report (I think it was a
    performance/optimization issue) related to the comefrom statement
    implementation. The joke wasn't worth actually investing scarce support
    resources on.

    --
    much of left-wing thought is a kind of playing with fire by people who don't even know that fire is hot - George Orwell
  166. Fourth by Anonymous Coward · · Score: 0

    In Forth all of the syntax is in Reverse Polish notation, like an HP calculator. Including the arguments for procedure calls.

  167. Haskell by rdnetto · · Score: 1

    The following is perfectly legal Haskell, and does exactly what it looks like:

    x = 2 + 2 where 2 + 2 = 5

    --
    Most human behaviour can be explained in terms of identity.
  168. The Daily WTF by Anonymous Coward · · Score: 0

    http://www.thedailywtf.com/ - Curious perversions in information technology

  169. Python's whitespace is a feature! by strombrg · · Score: 1
    I'm completely serious. Once you get over the initial "Ew, how FORTRAN77!", it's very nice.

    http://stromberg.dnsalias.org/...

  170. Self-modifying BASIC by PhilHibbs · · Score: 1

    My dad and I wrote a BASIC interpreter for the IBM PC in the '80s called BBasic, based on the Acorn BBC Micro dialect. BBC BASIC had an "EVAL" function, where it took a string and interpreted it as an expression. I persuaded dad that we should expand this functionality to an EXEC statement, that would take a string and interpret it as BASIC commands. If you put a line number at the start of the string, it would insert the code in the string into the program that was running - so you could have self-modifying BASIC code. There was one restriction, that if any of the points in the call stack were prior to the inserted statement, then it would fall over in a very untidy heap.

    It actually turned out to be pretty useful, the one used that I can remember was to store persistent data within the program itself, and you could save a program as an executable that included a runtime interpreter.