Slashdot Mirror


Favorite Programming Language Features?

johnnyb asks: "I'm curious what everyone's favorite programming language features are. I'm looking for both the general and the specific. I'm especially looking for features that few people know about or use, but are really useful for those who do know about them. What are your favorite programming language features?" "A couple of examples to kick off the conversation:
  • Continuations

    Continuations are very interesting, because they can be used to implement a number of flow-control features such as exceptions, coroutines, cooperative multithreading, and are better at modelling web interactions. This is a more general feature, but most people use these in conjunction with either scheme or ML.

  • Tuple-returning

    It is a huuuuge time-saver when languages like Perl allow functions to return tuples. Instructions like '($a, $b, $c) = $sth->fetchrow_array()' is a wonderful thing.

  • The flip-flop operator [Perl's '..' operator]

    Another perlism that I just think is cool. Read more about it here.

Okay, on to yours!"

312 comments

  1. Simple, OOP by agent+dero · · Score: 2, Insightful

    Object-oriented programming.

    For me it's just easier. ;)

    (Especially with XCode displaying it as a little blue box, it makes the concept easier to grasp for beginners)

    --
    Error 407 - No creative sig found
    1. Re:Simple, OOP by rasjani · · Score: 1

      Well, its not oop i was after or i didnt get your point =)

      But this would rule in the oop context too.

      The "with" operator here means that it sets the scope of the namespace..

      In oop context you would allways have to use some identifier if the variable you are using is part of the object or no identifier if its defined in local scope.

      With "with" operator and oop, you could do something like

      class shito {
      var $dimwit;
      var $moreon;
      function shito () {
      with this {
      $dimwit = 0;
      $moreon = 0;
      }
      }
      }

      --
      yush
  2. That's obvious by krel · · Score: 2, Insightful

    Beautiful syntactical simplicity.
    *cough*C*cough*

    --
    karma: ouch!
    1. Re:That's obvious by Jeremiah+Cornelius · · Score: 1

      I **LOVE** Curly braces! Gotta have 'em!

      --
      "Flyin' in just a sweet place,
      Never been known to fail..."
    2. Re:That's obvious by Tr0mBoNe- · · Score: 1

      I perfer the simpler languages for pure number crunching and for OO, Smalltalk, Java, or QT... they manage to be easy enough to use in most setups.

      but my fav has gotta be Lisp. pure unadultrated Lisp. and when I feel sadistic, ProLog helps.

      a little lisp for ya.

      (defun firstElement (list)
      (car list)
      )

      great eh?

      and recursion is great too... wanna get the last of the list? SURE!!!

      (defun last (list)
      (cond
      ((= (length list) 1) list)
      (T (last (cdr list)))
      )
      )

      but hey.... lisp is grrrrrreat... car cdr... defun.... length.... what a language.

      --
      while(1) { fork(); };
    3. Re:That's obvious by drgnvale · · Score: 1

      I'm sure you think your sarcasm is funny there, but your a sucky lisp programmer. Common lisp already defines a first function and a last function. Also, no one puts close parens on their own line. You program in notepad or something?

    4. Re:That's obvious by jonadab · · Score: 1

      If you want simple syntax, it's not C that you want. The lisp-based languages
      all have much simpler syntax.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    5. Re:That's obvious by Anonymous Coward · · Score: 0

      your a sucky lisp programmer.

      "you're", "LISP".

    6. Re:That's obvious by drgnvale · · Score: 1

      "you're" is correct, however LISP is not.

    7. Re:That's obvious by Tukla · · Score: 1

      Yeah, it should be "LisP"!

  3. Easy. T-Shirt (C): by torpor · · Score: 2, Funny
    (void *)(void *);
    --
    ; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
  4. ON ERROR RESUME NEXT by Anonymous Coward · · Score: 2, Funny

    j/k

    1. Re:ON ERROR RESUME NEXT by cuerty · · Score: 1

      Private Sub Test On Error Go To Hell 'Do Stuff Exit Sub Hell: 'Here the fun End Sub

      --
      >Linux is not user-friendly.
      It _is_ user-friendly. It is not ignorant-friendly and idiot-friendly.
  5. Lists by Midnight+Warrior · · Score: 1

    Tcl and Postscript both offer lists and lists within lists, without having to do anything fancy. Perl does have this, to an extent, but only on static lists. Anything dynamic adds a few lines of code and confuses things pretty easily. Of course, all of this came from Lisp, but I learned car and cdr and that was more than enough for me.

    In short, lists only work when recursion is right at the tip of your fingertips in your language. If XSLT-2.0 works on tree fragments, we will have lists there as well.

    1. Re:Lists by bill_mcgonigle · · Score: 2, Informative
      Perl does have this, to an extent, but only on static lists.

      What do you mean by 'static lists'? Do you mean they're immutable?

      You can do
      push(@{$outer[$inner]},$value)
      to add to a list in a list. The syntax is tough, but I think it does what you mean. @{} is like a cast-to-list.
      man perlref
      should be helpful.
      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    2. Re:Lists by Feztaa · · Score: 1
      What do you mean by 'static lists'?

      I would guess he means "lists that are hardcoded into the program", I forget the proper term for this.

      He was saying that perl creates nested arrays nicely:

      my @array = (["foo", "bar"], ["baz", "qux"]);


      But when it comes to actually creating a structure like that dynamically using push or unshift, the code gets really ugly. And I think you proved his point ;)
    3. Re:Lists by Feztaa · · Score: 1
      Just to clarify, the above code snippet creates a two-dimensional array, it could also be created thusly:

      my @array;
      $array[0][0] = "foo";
      $array[0][1] = "bar";
      $array[1][0] = "baz";
      $array[1][1] = "qux";
  6. anonymous inner classes by notyou2 · · Score: 3, Insightful

    I think's java's concept of anonymous inner classes is simply superb... it enables runtime aggregation of small objects while preventing you from having to create hundreds of named external helper classes to implement the behavior.

    It's certainly not an unknown feature, but I couldn't live without it.

    1. Re:anonymous inner classes by at2000 · · Score: 1

      I would say it is Java's (ugly) solution to no function pointer support.

    2. Re:anonymous inner classes by Nasarius · · Score: 1

      I absolutely hate anonymous classes. They make for some really ugly code. Private classes seem much simpler to me.

      --
      LOAD "SIG",8,1
    3. Re:anonymous inner classes by bigsteve@dstc · · Score: 2, Insightful
      Other programming languages do this so much better with different constructs. For example, "blocks" in Smalltalk, Ruby, or "currying" in ML, etc.

      Java's inner classes (anonymous or named) are not even first class! (Try coding an inner class that refers to a non-final attribute in its enclosing scope.)

      They are better than nothing though ...

    4. Re:anonymous inner classes by Tool+Man · · Score: 1

      Anonymous inner classes are helpful, but only by comparison to the usual class-crazy nonsense that Java flings at you. Check out what you can do with closures (i.e. in Common Lisp), where you can create a nice little nugget of behavior, without having to create yet another nuisance class and its associated file.

      Lisp macros are pretty wild too, since the language itself is available to do the magic. Compare to simple text substitution, and only the name is really similar.

    5. Re:anonymous inner classes by Bazzargh · · Score: 3, Informative
      Java's inner classes (anonymous or named) are not even first class! (Try coding an inner class that refers to a non-final attribute in its enclosing scope.)

      This isn't quite right. First off, they are first class, and you can refer to a non-final attribute from a named or anonymous inner class. What you can't do is refer to a non-final local variable from an anonymous inner class.

      The intended effect is similar to closures - variables referenced from the enclosing scope have the value when the closure was instantiated (see, e.g. Scheme) - except that unlike scheme, you can't modify the now-private copy. If you want a modifiable copy, you just make one, like so:

      final finalFoo = foo; Object bar = new Object() { private myFoo = finalFoo; // myFoo now acts as 'foo' would if this was // *really* a closure. }

      I'd agree that the construct sucks. I'd rather be in a language with closures myself.

    6. Re:anonymous inner classes by bigsteve@dstc · · Score: 1
      First off, they are first class,

      I guess it depends on your construction of "first class". The definition you cite is for first class data types. I was using it in the sense that the class declaration is not a first class construct in Java. In particular, there is this awkward issue about non-local variables.

      ... and you can refer to a non-final attribute from a named or anonymous inner class. What you can't do is refer to a non-final local variable from an anonymous inner class.

      Correct. My mistake.

      final finalFoo = foo;
      Object bar = new Object() {
      private myFoo = finalFoo;
      // myFoo now acts as 'foo' would if this was
      // *really* a closure.
      }

      The comment is incorrect. If there was a real closure, then foo could be non-final, and the result of assignments to foo would be apparent in any code in which foo is still in scope. In slightly different code, a single foo might be visible in multiple instances of the anonymous inner class.

      But clearly each instance of myFoo is only in scope for a single instance of the inner class. instance. Hence this is not a simulation of a closure. To do that, you'd need another object to carry the shared 'foo' variable.

      But you probably really knew that ... just like I really knew that an inner class can refer to a non-final attribute. :-)

    7. Re:anonymous inner classes by cheezit · · Score: 1

      Inner classes break the Java security model...go ahead, check out the .class files that get created and then load them at runtime. You'll get full access.

      This was true at one point anyway, I haven't tried it recently.

      --
      Premature optimization is the root of all evil
    8. Re:anonymous inner classes by tambo · · Score: 1
      As a general rule, I agree. But there is one instance where anonymous inner classes are awesome: attaching some code to an event handler. Usually you have to do this:

      class HandlerFunction implements EventHandler { blah blah blah }

      and

      HandlerFunction h = new HandlerFunction();
      sourceObject.addEventListener(h);

      This is syntactically unclear - it puts space between the event handler attachment and the event handler code. It's also wasteful: if you just use this event handler once, why design a whole class for it?

      An anonymous inner class makes this really clear, though:

      sourceObject.addEventListener(new EventListener { void eventRaised(Event e) { ... } } ) ; In short, you patch the event-handler code right after the spot where you attach a listener object.

      - David Stein

      --
      Computer over. Virus = very yes.
    9. Re:anonymous inner classes by Omega1045 · · Score: 1

      You are right. They even mention this right in the Sun Press Java 2 books. I don't have a link to back that up, but I remember reading it in there somewhere.

      --

      Great ideas often receive violent opposition from mediocre minds. - Albert Einstein

  7. Re:Speed and RAM by sfjoe · · Score: 3, Insightful

    I feel the one of the strongest features of Java (or any language) is a standardized documentation feature (i.e. javadoc) and "readability". Being able to easily understand what another developer's intentions and "gotchas" are is invaluable. Perl, for example, can be obtuse without even trying very hard.

    .. and now, 50 rebuttals from the Perl crowd.

    --
    It's simple: I demand prosecution for torture.
  8. Many by Apreche · · Score: 4, Interesting
    First off I like nothing more than automatic memory management. Being able to forget about pointers and malloc and all that garbage makes programming infinitely easier and faster. I only write in C or assembly when I really really need the speed or when I'm at such a low level that nothing else is possible.

    Next I love ruby's block system, especially for stuff like this.
    myarray.each { |e| puts e }
    It comes in super handy for a ton of stuff. Especially when I'm doing XML.

    Also, there is another thing that I first discovered in python
    x, y = y, x
    Save me a temporary variable, w00t.

    Lastly, its not really a language feature, but in any object oriented language I love being able to serialize the objects. It's so simple to use pickle or any other serialization library and just write objects out to file or network. I never have to design a binary file format ever again. It's even better when you use Ruby and you can marshall objects into XML or YAML with a single method. Then you've got a human readable and editable file format that you can magically transform into objects again later. Super useful.
    --
    The GeekNights podcast is going strong. Listen!
    1. Re:Many by Anonymous Coward · · Score: 0


      x, y = y, x
      Save me a temporary variable, w00t.


      For numerics, you could always go with
      x += y
      y += x
      x -= y

      Works in many languages and you don't need a temporary variable.

    2. Re:Many by PSUdaemon · · Score: 3, Informative

      x ^= y
      y ^= x
      x ^= y

      bitwise, no overflow worries...

    3. Re:Many by Anonymous Coward · · Score: 0

      x, y = y, x Save me a temporary variable, w00t.

      You think it saves you another variable. In reality, a temporary variable gets used underneath that, because that's how computers work.

      All programming languages are syntactic sugar for machine code. When a programming language trades away representation of the machine for cleaner syntax, don't think that the machine works a different way underneath.

    4. Re:Many by Anonymous Coward · · Score: 1, Insightful

      You think it saves you another variable. In reality, a temporary variable gets used underneath that, because that's how computers work.

      Well, yes, but since we're talking about favorite language features, I don't see your point. This is something that saves the programmer from having to create extra temporary variables himself since the language does it for you. Try to keep up.

    5. Re:Many by Anonymous Coward · · Score: 0
      This is something that saves the programmer from having to create extra temporary variables himself since the language does it for you. Try to keep up.

      So then the perfect language is one where all the real programmers have done all the work for you, and you're just a little script monkey.

      import java.StuffImTooStupidToDo.*;

      public class MyWebServer
      {
      public MyWebServer(int port) {
      WebServer x = new WebServer(port);
      }

      public static void main(String[] args) {
      MyWebServer y = new MyWebserver(80);
      }
      }
      There aren't that many real languages. They are Forth, C, Ada, Fortran, and assembly language. If you aren't proficient in one of these, you aren't a real programmer (of course, even real programmers use little scripts from time to time, which is why everything not of the above list exists).
    6. Re:Many by belg4mit · · Score: 1

      Not to feed a troll, but if you're going to play the Crotchety old Real Programmer than you damn well better add Lisp to that list.

      --
      Were that I say, pancakes?
    7. Re:Many by Albert+Y.C.+Lai · · Score: 5, Insightful

      So then the perfect language is one where all the real programmers have done all the work for you, and you're just a little script monkey.

      To that I answer by quoting Dijkstra: "if we wish to count lines of code, we should not regard them as 'lines produced' but as 'lines spent': the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger." (EWD1036, page 11)

      And so for example even your 10-line, 40-token launcher is too long; its information content can be expressed succintly as "new Webserver(80)" or even "Webserver 80" in any properly designed language.

      When electronic calculators came out, accountants did not say "the calculators do all the arithmetic for you, and you are not a real accountant" (or did they?) Similarly for spreadsheet. The reality is, each time they are relieved of a chore, they find a more worthwhile thing to spend their time on, such as analysing various what-if scenerios, which had been intractible until the advent of spreadsheets --- a fine programming language in its own right. I now quote Asimov on the general idea: "The Machines are only a tool after all, which can help humanity progress faster by taking some of the burdens of calculations and interpretations off its back. The task of the human brain remains what it has always been; that of discovering new data to be analyzed, and of devising new concepts to be tested. ... I notice that capable men are still at a premium in our society; we still need the man who is intelligent enough to think of the proper question to ask." (The Evitable Conflict, can be found in I, Robot or other collections)

    8. Re:Many by Anonymous Coward · · Score: 0
      its information content can be expressed succintly as "new Webserver(80)" or even "Webserver 80" in any properly designed language.

      Why stop there? We'll just design a new language (call it Webserver) that runs programs that are at at most one unsigned short in length. Then, if you want to program a webserver, you just write:
      80
      Before this can work, though, a real programmer will have had to implement a Webserver compiler to run on an actual microprocessor, and that programmer will probably have used C.

      And so for example even your 10-line, 40-token launcher is too long

      Knuth would probably disagree. He'd likely look at your little one liner and wonder about the machine it's supposed to run on.

      Whichever expert you want to agree with, it won't change the fact that your code eventually boils down to machine language. You've got no place to optimize code, as well as no place to fix bugs, if something underneath your code is broken.
    9. Re:Many by allanj · · Score: 1

      Cool - I knew that one. It's fast, efficient and non-intuitive. Now try doing that with any non-integer type (like, say, a string), and the grandparent posters x,y = y,x really shines. Besides, the semantics of x,y = y,x is readily understandable.

      --
      Black holes are where God divided by zero
    10. Re:Many by Albert+Y.C.+Lai · · Score: 1
      a real programmer will have had to implement a Webserver compiler to run on an actual microprocessor, and that programmer will probably have used C.

      ... your code eventually boils down to machine language

      A person who can agree with both statements has clearly accepted one intermediate language (in this case C) as a firewall between the programmer and the machine language. The same person may also be aware that the machine language is yet another proxy, this time hiding the circuitry within the microprocessor. At any rate the person has rightfully dismissed the direct, exclusive use of the machine language --- or even electronics --- as realistic for providing web services.

      If you can accept being one or two layers removed from the bare hardware, the next step is inevitable. Pending on a demand from the complexity of the system to be built, there are no problems and only benefits adding a third layer. (Of course if the system is trivial, like Hello World, anyone can write it in the machine language and have it correct, optimal, and maintainable.)

      Indeed a web server has been written in Haskell [link]. Haskell, in turn, has compile-to-C compilers. This example happens to use the machine-C-Haskell layering; the idea is the same with other languages and numbers of layers.

      To debug the system, the C compiler team debugs the C compiler, the Haskell compiler team debugs the Haskell-to-C compiler, and finally the webserver author debugs the 2000 lines of Haskell code he writes. If the system is large enough, this partitioning of labour is the only way (the monolithic, one-man alternative is out of the question).

      To optimize the system, there is the theoretically optimal way of optimizing a web server written entirely and directly in the machine language, or the practical, sub-optimal way of asking the C compiler team, the Haskell compiler team, and the webserver author to do their respective parts in writing good-enough code or generating good-enough translations. It is clear which one is realistic when the system is extremely large.

      The hard work put into the compilers benefits many projects, and the cost is amortized.

    11. Re:Many by Anonymous Coward · · Score: 0

      At any rate the person has rightfully dismissed the direct, exclusive use of the machine language --- or even electronics --- as realistic for providing web services.

      No. The ideal case is a hardware webserver. The flaws of such a thing are that there's far too long a turn-around time on updates or changes to the webserver. Since there are all ready so many computers in existance (now) with general purpose microprocessors that can handle a webserver, it makes sense to use those (provided that the performance hit is acceptable). This approach has worked so well for so many things that it's been extended to all sorts of applications.

      If you're going to use a general purpose processor on a computer to run your application, the best thing is to use assembly language, because there's no performance hit over machine language while there's a huge gain in ease of coding.

      If you can accept being one or two layers removed from the bare hardware, the next step is inevitable.

      The jump from assembly language to C (on an abstraction scale) is actually quite large. It could really be filled with another language that would introduce no performance hits but has good abstraction. People settle for C because portability is an issue and no other language is feasible for use.

      To optimize the system, there is the theoretically optimal way of optimizing a web server written entirely and directly in the machine language, or the practical, sub-optimal way of asking the C compiler team, the Haskell compiler team, and the webserver author to do their respective parts in writing good-enough code or generating good-enough translations. It is clear which one is realistic when the system is extremely large.

      Those are business decisions. If you want something done right, you do it on as low a level as possible. Once you've moved away to writing code that is interpretted, you're not really doing computer programming anymore. It doesn't mean that you can't write well written programs, but it's definitely not the same thing.

    12. Re:Many by mc6809e · · Score: 1

      "x, y = y, x Save me a temporary variable, w00t. "

      You think it saves you another variable. In reality, a temporary variable gets used underneath that, because that's how computers work.


      Depends on what you mean by a variable.

      Suppose the compiler does something like

      ld R1, $x
      ld R2, $y
      st $x, R2
      st $y, R1

      Are you claiming the registers are temporary variables?

      There are also instructions on some microprocessors that will permute groups of objects. I think SSE supports that.

    13. Re:Many by Bush+Pig · · Score: 1

      You also forgot COBOL. Now - I personally _hate_ programming in COBOL, so much so that I put my COBOL book up for sale 3 seconds after I found out I'd passed the subject that required it, but it's still superb for what it was designed to do.

      --
      What a long, strange trip it's been.
    14. Re:Many by Osty · · Score: 1


      provided that the performance hit is acceptable)

      If you're going to use a general purpose processor on a computer to run your application, the best thing is to use assembly language, because there's no performance hit over machine language while there's a huge gain in ease of coding.

      The jump from assembly language to C (on an abstraction scale) is actually quite large. It could really be filled with another language that would introduce no performance hits but has good abstraction. People settle for C because portability is an issue and no other language is feasible for use.

      If you want something done right, you do it on as low a level as possible. Once you've moved away to writing code that is interpretted, you're not really doing computer programming anymore. It doesn't mean that you can't write well written programs, but it's definitely not the same thing.


      Wow. What's it like living in the 80s? Big hair and Camaros, baby!


      It must be nice to simply ignore two decades of hardware advancement. I'm sure your employer loves the fact that you write all of your code in assembly language. Who cares if it takes you years to write a system that could be done in months with C or weeks with a scripting language. It's fast as all get out!

    15. Re:Many by Anonymous Coward · · Score: 0

      Next I love ruby's block system, especially for stuff like this.

      myarray.each { |e| puts e }


      Very nice, but rather verbose - partial application (like in real functional languages like ML and Haskell) would let you write just myarray.each puts.

  9. Dreamed-of feature by Dr.+Weird · · Score: 5, Interesting

    This is less of a favorite feature, and more of a feature I wish we had. What about having the representation of the language independent of the code itself? I think this will eventually happen and could really revolutionize things. I believe the inklings of separating 'physical' representation from the code were there in some languages like Algol 60 and CS work in the 1960's, but it never caught on (perhaps hindered by other features of those works?).

    In a little more detail, suppose I write a C program. It will have lots of functions and conditionals with their "blocks" surrounded by braces.

    But what if I prefer my "blocks" to be started and ended by brackets instead of braces. Better yet, what if I am tired of typing these and would like indentation to control this. Or whatever -- start end commands, if you like. The point is that these are minor sytactic idiosyncracies, and we all have preferences. Why not store the code in an underlying format (XML would be okay, were it not for the bulk of it)? As long as there is a one-to-one correspondence between all possible representations, you could view it however you want.

    And so on for all syntactic features. Prefer "if-fi" construction to "if () {}"? Or "if ... then ..."? Better yet, really like Perl's "$_"? If you want it to be displayed like this, turn it on. Otherwise, say you don't like this feature, and it will automatically replace the "$_"'s (either implicit or explicit) with the variable to which it refers. Again, no problem.

    At this point, I feel like I am repeating myself, but let me continue for a little bit. It would let each user have his/her personal favorite representation. We already let them control the colors of their syntax highlighting, lets take it a step further.

    Hell, if you want to use a graphical viewer for those C programs, akin to LabView, go for it! Or (in my opinion) a much better graphical programming environment with a graph structure. The point is: you write it how you want and save it. It appears to another coder how he/she wants it to appear, but the content is exactly the same.

    In short: why isn't this done? It seems like a spectacular step in unifying programming languages a bit, and letting each user tailor his preferences while maintaining compatibility. As long as there was simple one-to-one correspondence, the translation from physical representation to underlying code and back would be quick and fairly easy to handle. Are there any modern projects which attempt this? Or *any* which attempt it with some success?

    On a somewhat related note, is it possible to put a "hook" to a comment in the code, and with the proper viewer have that comment displayed along with the code (say when you click the "hook", move your mouse over it, or drag the "hook" to a "comment box")? If this last paragraph doesn't make sense, please ignore it.

    1. Re:Dreamed-of feature by Retribution · · Score: 1

      Agreed. The actual content and presentation of a programming languages is, in my opinion, an important and useful distinction to make, especially after you've learned enough different languages. I always think of languages in terms of a) what they can easily express and b) how they express it. There have been a number of languages that I loved content wise, but couldn't stand presentation wise. Just as tabulation style, commenting style, naming conventions, and so on are usually up the to programmer, why not leave the *rest* up to them as well, assuming there was some underlying, unifying way of making it all cohesive?

      I've been thinking about this for a while. What makes the most sense to me is some XML representation of the content, and then an editor would be required to interpret as { and }, for example. If the representation is chosen carefully, I imagine that many small code blocks could, potentially, be mostly language independent, or at least compatible with many different languages without changing a single "line" (of the XML representation).

      I've considered on occasion putting in some work to get a small proof-of-concept project off of the ground, but don't really have the time. If anyone is actually interested in this, I'd be happy to help contribute to such a project.

      --
      -- That tickles!
    2. Re:Dreamed-of feature by EvlG · · Score: 1

      This is a terrible idea for maintenance. Imagine trying to read the code for a given app that had all sorts of bizarre preferences chosen. You would have to spend a lot of time just understanding what the hell you were looking at.

      The whole idea is to make things as uniform and regular as possible because then there is less for everyone else to learn when they look at the code. This suggestion adds a whole layer of confusion, and only buys a modicum of user preference in return. That is a poor tradeoff.

    3. Re:Dreamed-of feature by xTMFWahoo · · Score: 1

      why not just write your own compiler?

      this is what it sounds like you want???

      --
      "Patriotism is supporting your country all the time, and your government when it deserves it." Mark Twain.
    4. Re:Dreamed-of feature by Dr.+Weird · · Score: 2, Interesting
      Imagine trying to read the code for a given app that had all sorts of bizarre preferences chosen. You would have to spend a lot of time just understanding what the hell you were looking at.

      No. In some sense, this is precisely the problem I try to avoid. The bizarre preferences were chosen because that programmer/company/standards bureau liked them and/or found them useful (hopefully). By storing the content of the program, and not their silly display preferences, it would load and present to me however I had it set up to display it, not according to their preferences.

      In other words, they have some silly COBOL-like syntax mixed up with graphical elements. But the presentation is not in the code . When I load the file, it would display according to my preferences, perhaps looking very C-like.

      I am not suggesting that the options/commands be different for each user, but rather that the presentation be different. In other words, this is the way to make there be least to learn on behalf of programmers. They don't need to know the other programmers' formatting rules, syntax, blocking options, etc. By having a 1-1 correspondence between representations, a representation suitable for you would be generated automatically.

    5. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      Not really. I am not asking for new language functionality (though there is plenty of that I wouldn't mind). In a sense, I want the compiler to work in a certain language. Lets pretend that the language was stored and looked just like C. (Probably not the best way to go, but bear with me.)

      Now, I want to be able to set up my IDE to let me edit that C file and display that C file how I want. Curly braces? Maybe, maybe not... just use indentation. Still, when I use indentation in my editor, it might put the braces in the C file automatically. I could pick it how I want, someone else could pick what they want, but each of our source files would be the same. You might imagine how XML fits into this. I would use indentation or a curly brace or a bracket or "start" or some other command to indicate the start of a block and it would be put in the actual code as: . Much more interesting examples can be made.

      So, as a first step, no new compiler would be needed: just pick an existing language. The point is to have the representation customizable, e.g. modify vi. Or a graphical editor, so that drawing a box or rectangle or something puts in the source. Still, when you viewed it, it would look like a curly brace or say "start" or whatever display preference you had set.

      In order of ease to implement and maintainability, a new language/compiler would probably be best for this, or at least a preprocessor to take the meta-language (xml) to something like C. But not necessary and not really the point.

    6. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      I am glad to know that other people are thinking of this -- it means that some day, something might actually be done! ;) Language-independence or something close might not be possible within our current set of languages, without lots of pain. Maybe within a certain paradigm -- such as procedural programming -- with only some pain.

      But effectively, one would create a large (infinite?) set of "programming languages," each of which was equally expressive, but differed in how shortcuts were displayed and coded, and how long it took to perform specific programming tasks. But there would be no confusion, because each user could use his own "language" and have complete interdependence with others.

      I actually think perl could serve as an interesting jump-off, but it might be too messy to be practical. I too would love to offer advice and extensive testing for anyone who makes a serious effort at this. I would even report bugs and write code here and there. But I certainly don't have the time nor the expertise to spearhead this. I would also like to know the history of some other attempts like this, and why they failed (Algol 60 and a few other rants were found as "physical representation independent" after extensive searching.)

      I speculate part of the problem of these historically is that everyone had to learn a standard representation anyway; since the "reference representation" was printed in a book, you had to know that standard. So, if you wanted to customize your display of code you could do that, but you had to also know the "reference representation" to learn things. Now, this problem is gone since we have the internet and code is easily distributed software with books, etc. So you aren't tied to a "reference representation," but rather can view the example code in your preferred representation (unlike when code was printed in books, instead of electronically). Perhaps this, along with the advent of XML, will remove the historical impetus that hindered previous projects (plus the oodles of goodies people have invented that can be turned on and off in the past few decades).

    7. Re:Dreamed-of feature by CTachyon · · Score: 1

      By storing the content of the program, and not their silly display preferences, it would load and present to me however I had it set up to display it, not according to their preferences.

      One of the obvious benefits is the end of the holy wars over brace and indentation style. Think code should be tabbed out 2 spaces instead of 4? Constantly resisting the urge to reformat everyone else's Java code to 1TBS? Want to program in C using Python-style meaningful whitespace? Not a problem. Just clicky-click on your editor preferences (or :set codingstyle=foo), and you're done.

      --
      Range Voting: preference intensity matters
    8. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      Great! Someone's on the bandwagon. :-D

      So, have you ever seen anything like this? For the brace/indentation conventions, it would be easy to implement. But there are so many more things that a real bottom-up design could do.

      Btw, is there a better place for us to have these discussions, which are slightly wandering off-topic?

    9. Re:Dreamed-of feature by bigsteve@dstc · · Score: 1
      What you are describing is a IDE feature, not a programming language feature. Or alternatively, it is a programming language feature that forces everyone to use a whizzo (read memory hungry, buggy, etc) IDE. No thanks.

      One of the obvious benefits is the end of the holy wars over brace and indentation style.

      Good project managers don't allow coding style holy wars to break out. They mandate a house coding style, and (if necessary) use code reviews to enforce it.

    10. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      Indeed, this is largely an IDE feature. But certain file formats are conducive to reading by the IDE, so in a sense it is also a language issue. (at least language format)

      Also, you don't need to use a memory hungry IDE. I use vi mainly, and this would still be possible. Syntax highlighting is the first step -- the representation depends on how you have things set up. This is just the next step. So a purely text representation with no information besides what is directly coded would be possible (layed out, textually, to your specifications).

    11. Re:Dreamed-of feature by Somegeek · · Score: 2, Insightful
      This is a terrible idea for maintenance. Imagine trying to read the code for a given app that had all sorts of bizarre preferences chosen. You would have to spend a lot of time just understanding what the hell you were looking at.

      I don't believe that you understand the concept becuase it seems that your argument doesn't apply.

      The whole point would be that you wouldn't see the idiosyncrasies of the way that he likes his code laid out, he would in essence give you compiled code and your development environment would display it for you however you liked to see it.

      For example, take the way people develop HTML code; some code it in notepad, writing the raw code, others use graphical interfaces with WYSIWYG software that just lets them edit the finished product, and others may use something in between, but its all the same code; displayed for you the way you like it; in text or graphically, or in windows with your toolbars and your highlighting preferences and tab spacing. What if you could only view it in the program that it was originally writen in?

      --
      And as you tread the halls of sanity, You feel so glad to be, Unable to go beyond. I have a message, From another time..
    12. Re:Dreamed-of feature by Cuthalion · · Score: 1

      Maybe you should look at Eidola. I think it's been a while since it's been actively developed, but still seems to be roughly what you're talking about.

      --
      Trees can't go dancing
      So do them a big favor
      Pretend dancing stinks!
    13. Re:Dreamed-of feature by StiLTs · · Score: 1

      I don't think the parent was suggesting that the syntax preferences should be attached to the code: they are attached to the user. Then all code looks like your code to you since it all looks like python (or perl, or c, or scheme, or prolog, or whatever you like) and it also all looks the same to the compiler/interpreter/vm/whatever.

      --
      open minded enough to see things for what they really are
    14. Re:Dreamed-of feature by wayne606 · · Score: 4, Insightful

      Why in the world would any programmer care about whether they write "if { }" or "if ... fi", etc? I don't see the big advantage in indulging one's personal preferences about syntax. It's not like every person's brain has a completely different way of reading a program that makes it significantly easier to understand a unique brand of syntactic sugar...

      Sure, you can develop in your own special IDE that gives you your unique syntax. But don't you ever look at code together with other programmers who might have different preferences? Don't you ever view code published in magazines and on web sites that can't pretty-print to your specification? Training yourself to strongly prefer some kind of private language is not a very good idea.

    15. Re:Dreamed-of feature by Anonymous Coward · · Score: 1, Insightful
      This is a very interesting concept. You can essentially do the same thing now with a java decompiler or with Perl's B::Deparse (although you lose the comments).

      Though having used things like B::Deparse I can tell you that you'll lose some syntatic sugar, e.g. things like "$a++" or "$a+=1" might come back out as "$a=$a+1" (or vice versa), or special cases where a programmer chooses to format a single if() statement:

      if($bar) qux()
      or
      qux() if($bar)
      becomes
      if($bar) {
      qux()
      }


      Even though it might have been cleaner and easier to read before it was broken out into a block.

      You'll lose things like whether or not it had brackets, whether or not there was a line break, etc. Basically, you lose the special cases. Maybe that's a good thing in that it enforces uniformity, but there are cases (like in long lines wrapping) it's handy to drop some syntax and use some ugly shorthand. You'd have to pack around a lot of metadata to save that information (that might not be relavant to other "views"), or make blanket staments that all if() statements will look a certain way, all increment operations will look a certain way, etc.
    16. Re:Dreamed-of feature by sICE · · Score: 1

      I frequently endup using reformatting tools for bad code that i get handed to. I mostly use: indent (probably already installed on your machine), AStyle (far better than indent), and perlTidy, there's more xxxTidy programs like html/php, etc have a look on google... there's probably dozen of flavors around.

    17. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      This is a valid point. Nonetheless, refer to the recent article on Code Complete on Slashdot. Many references are made to the section on indenting. 2-4 spaces is best. Ideally, we would be infinitely flexible, but there is something about our brains/culture that fixes us towards that. The first thing that one should consider when one learns there is an average behavior in such phenomena is to consider that this is always accompanied by fluctuations. So, each user will have an optimal indentation readability.

      And some people prefer perl's $_ (and other shortcuts) as a useful shortcut; some prefer to write things more explicitly. Neither is better or worse, and coping with a way you do not prefer takes effort. Not terribly, but when you have 100,000 lines of someone else's code to understand and modify very quickly, you should take all the minor speed improvements you can get. I am not exactly a software developer, but my colleagues and I often develop applications. We generally collaborate and look at each others code. It is readable and not particularly difficult. But if other designer's preferences matched mine, it would be easier to read, and over time this speed improvement would amount to something substantial.

      As long as representation-independent code is what people were using, I don't see this "training yourself to strongly prefer some kind of private language" as being a bad idea. Additionally, the potentials for graphical programming and alternative paradigms could be really interesting; exploring these would not be overly detrimental/risky. If things started to go sour with one set of trial display/programming options, you could switch to a more comfortable/conventional style with no problem, instead of having to start the project from scratch.

      Besides, at the very least, it gives you automatic alternative ways of viewing code -- could having the same bit of code (well) translated between perl, c, python, and java be detrimental? It can only open you to new ways of looking at the same problem. (ignore the fact that these languages are probably too disparate for this to be feasible.)

    18. Re:Dreamed-of feature by craigmarshall · · Score: 1

      I hate Microsoft as much as the next guy, but the .Net CLR does exactly this for you. C# and VB.Net (and J# and Nemerle and all those other .Net languages), all compile to the same byte code, so in theory, couldn't they all be translated into each other? If not 100%, then very nearly...

      I have a feeling Java and Jython could be too. It would be a heck of a lot of work for the translator, but it might be possible.

      Craig

    19. Re:Dreamed-of feature by wayne606 · · Score: 2, Insightful

      As long as the different representations are not too far off then it's probably not a big deal. But I work a lot together with other developers looking at the same code at the same time and if our dialects were mutually incomprehensible that would not be a good thing.

      Multiple representations can be very powerful - editing html code in parallel with the rendered version makes a lot of sense. But even in this case there is not a one to one mapping - it's not just syntax but semantics that vary (i.e. the rendered version has no semantics whereas the html or xml code may). I wonder if you could find two real programming languages that you could usefully and bidirectionally translate between and not lose a lot in the process.

    20. Re:Dreamed-of feature by Singletoned · · Score: 1

      I have to say, I've been thinking of this myself, but always assumed there was a good reason not to do it and that I was being stupid for thinking it.

      This has given more confidence now that obviously intelligent people are also thinking it.

      The only real problem I can see with it is that if you didn't have an IDE available (you needed to hack a piece of code in notepad or something) you probably wouldn't understand the code, or at least, wouldn't be used to it.

      With the size of code these days, though, it's getting harder and harder to do anything outside of an IDE.

      A corrollory to this is that I've seen some programs display code as a flow chart which can be really useful sometimes. This would mean you could view it that way if you preferred.

    21. Re:Dreamed-of feature by k98sven · · Score: 1

      Why in the world would any programmer care about whether they write "if { }" or "if ... fi", etc?

      Because we're geeks, and as such we want to be able to write palindromic code!

      (And I'm saying that as someone who actually has..)

    22. Re:Dreamed-of feature by k98sven · · Score: 1

      Not that it's not possible to write palindromic code with curly-braces! (the one I did was in C)

      It's just more of a challenge.

    23. Re:Dreamed-of feature by Dr.+Weird · · Score: 1
      I wonder if you could find two real programming languages that you could usefully and bidirectionally translate between and not lose a lot in the process.

      You have boiled things down to the essence of the problem. This is the real question. This is why I primarily stuck with simple examples like indenting -- easy bidirectional correspondence. As we shift between more elaborate language features, and/or allow programs to include any layout for which there isn't a 1-1 correspondence, things will go apeshit and impossible to maintain, I suspect.

      So, within that constraint, can anything really useful be done? At least some, I think. Maybe some really useful things... but this is the question that needs to be answered.

    24. Re:Dreamed-of feature by gurps_npc · · Score: 2, Interesting
      I agree. But more so.

      We use graphical interfaces for a lot of things, we should use them for programming.

      SCREW the text editor based programming.

      What is this bracket crap to seperate codes?

      You want to seperate code? draw a circle around it. Variables that are in the circle can be accesed by code in the circle. Want to reference a variable outside the circle? Draw a line from it into the circle. And guess what - you can tell from the color of the variable name that it is not from that same object.

      I am trying to design such a language, but realize it is a big project. In fact it is two projects: 1) Designing the language (mostly done) and 2) Writing an open source graphical editor/compiler program that will allow you to write/code the program, save it, edit it, debug, and compile.

      reply to this post if you want more information

      --
      excitingthingstodo.blogspot.com
    25. Re:Dreamed-of feature by johnnyb · · Score: 1

      This is kind of possible in Scheme/Lisp languages. They are essentially syntax-less, in that what you are actually doing when you code them is building a parse tree. Some people have come up with alternative syntaxes for Scheme that is more "normal", which I think can covert code from/to this syntax. It's not the full thing you want, but Scheme is a good start.

    26. Re:Dreamed-of feature by wayne606 · · Score: 1

      I think rather than preserving all the data when you convert from one representation to another, you need to think of it as multiple views onto a single internal format that you may not ever look at.

      Programming languages are hard - just consider html/xml. You have two types of views - structural and presentation. That would correspond to semantics-based XML tags like <definition>, <example_code lang=C>, etc, one one hand, and large italic green text on the other. It doesn't make sense to pollute either of these representations with tags belonging to the other, I don't think, but you can keep everything in a comprehensive internal format and have multiple editors that modify the things they like without messing up the other tags. Various people have done research on this topic - 15 years ago there was something called Lilac that worked like this for LaTeX.

      How does this apply to programming languages? What are the useful "other views" of a program? Maybe an encoding of the breakpoints and debugging hooks you have applied with the debugger? You wouldn't necessarily want to see those when you are editing the code. Profiling information? Nicely formatted documentation?

      If you think there is stuff to be done in this area, give it a try ... See what DevStudio.Net and Mono are moving towards and what would be good to have, from your point of view, which they are not addressing, and have at it ... We won't know if something will be useful unless we try it out.

    27. Re:Dreamed-of feature by Da+VinMan · · Score: 1

      I think you could take this idea in at least two different directions:

      1. Language style/internationalization mapping - Allow programmers to be productive using familiar symbols, keywords and in their native language. This could allow you to use an internationalized keyword as part of the language instead of a fixed English word ('si' instead of 'if' in Spanish for instance). This could also allow stylistic mappings like 'End If' or 'fi' instead of '}'. Essentially this would automate the same sorts of transformations that one could accomplish with C style macro expansion, and it wouldn't require you to use a language that had a macro processing feature; it would require it of the IDE though.

      2. Language semantic mapping - This one is harder. So, OK, it's easy to say that if I used 'if' in one language it will be 'if' in the next language. Comment characters/blocks wouldn't be too bad either, for the most part. But what about operator precedence? What about incongruent semantic mappings in general? (For example, the tuple return feature in Python mapped onto Java.) Granted, all those transformations will be possible, but the generated code would, in many cases, be awkward and not really in line with how an experienced practitioner in the target language would do things. One thing you have to keep in mind is that programming languages are separate languages for a reason. Each language brings a different way of seeing information systems to the table. The C view of systems bears some similarity to the Java view of systems but it really is vastly different in how it solves problems.

      I really see the former case as being the most useful. In particular, I see the internationalization case as being the noblest use of this idea. But, ultimately, I think your idea could really benefit one language at a time. So, one could do something like this for C. Just use C's standard syntax as the baseline tokens and then do the stylistic/internationalization transformations right in memory in the editor. That way, everyone else can still use the source code, and only the developer with the custom IDE has the transformed code. Likewise, having accomplished that, it would be pretty easy to do for Python, etc. One thing it probably would not be able to do though, would be name transformations for the relevant library APIs. Those translations could be pre-mapped to the list of known APIs, but some of those translations would have to be done on the fly. I guarantee that would confuse a lot of programmers as the selected term may not accurately reflect a translation of a word in the API name. Actually, it's a fairly funny thought.

      Make it so! ;+)

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    28. Re:Dreamed-of feature by ameoba · · Score: 1

      I'm pretty sure you could do this with Lisp and some macros...

      --
      my sig's at the bottom of the page.
    29. Re:Dreamed-of feature by L1TH10N · · Score: 1

      This will also have great benefit for foreign language programmers. Imagine Indian programmers writing code in Hindi or Chinese programmers writing code in Chinese. The coding engine needs to have something that automatically translates the comments though.

      --
      Yet another ironic recursive statement.
    30. Re:Dreamed-of feature by tomhudson · · Score: 1
      A lot of language customazation and i18n stuff can be done with an include header file:

      for example:

      #define si if
      or
      #define fi }
      or (for pascal-like syntax
      #define begin {
      #define end }
      or even
      #int EXIT_CODE = 0;
      #define prog int main(int argc, char* argv[], char* env[]) {
      #define endprog return(EXIT_CODE); }
      #define printstr(x) printf("%s", x);
      #define foreach(x) for(int i=0; i<x; i++) {
      #define endfor }
      #include <stdio.h>
      so you end up with:

      #include "simple.h"
      prog foreach(argc) printstr(argv[i]) endfor endprog

      a 2-liner :-)

    31. Re:Dreamed-of feature by tomhudson · · Score: 1

      oops, shouldn't have a # in front of the int EXIT_CODE = 0;

    32. Re:Dreamed-of feature by Da+VinMan · · Score: 1

      Yeah, I thought of that too, but I shied away from it because it affects the maintainability of the code for other developers. The method I suggested would be harder to implement, but it wouldn't affect the source code for everyone else. Also, I think once you put together something that could work in the IDE for a given language, it would be fairly easy to tweak it for every language that IDE supports. That's a powerful idea in the case of Visual Studio.NET or another IDE that supports many languages.

      Part of what you demonstrated above are macros that provide some syntactic sugar to increase productivity. I'm all for those in the right situation, but I think that's another subject entirely. Those macros would definitely work in the context of a multi-language IDE of the sort described above, but only for the language keywords and not the macro contents.

      So, in your example:
      #define si if

      If I the IDE was just using English, both of the following fragments would be valid:

      if (cond) {blah;}; // uses normal C keyword at compile time without macro
      si (cond) {blah;}; // uses macro translated C keyword

      Now, if I mix it up a bit by changing the IDE over to Portuguese mode, the first line of code becomes:

      se (cond) {blah;}; // uses normal C keyword at compile time without macro

      And the second line stays the same. So you would then have a source code file on the screen that would appear in Portuguese and Spanish and would be saved as English and Spanish.

      If you didn't use macros at all for language translation, it would just all be saved in compilable English and appear on the screen as whatever language the developer had selected in the IDE. Of course, you'll also note that implementing the idea as presented also means that the comments would all stay in their original language. The code would be usable in any language, but the comments would still be unintelligible to the uninitiated without help from the likes of BabelFish or another translation product, which would inevitably slaughter the translation (which may or may not be good enough). Also, the maintainer will probably want to add to or change the comments along the way, and the changes at least would probably need to be saved as their vernacular in order to be fair. And then you'll have a hodge podge of languages in one source file, which isn't good.

      And that is the death of that idea. *sigh*

      So, I suppose what we'll have to do instead is all use some subset of English within a project so that EVERYONE on the project can understand the comments, etc.

      Err... yeah, never mind. We already do that.

      *twitch*

      At least it's Friday.

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    33. Re:Dreamed-of feature by Anonymous Coward · · Score: 0

      Shellgol. The permanent cure for this idea.

    34. Re:Dreamed-of feature by Anonymous Coward · · Score: 0

      ...there are at least two environments already to do what you want.

      Either write a your-new-language-to-JVM compiler, or do the same thing with .Net.

      The underlying language for Java is Java Byte Code, and the underlying language for all .Net languages is MSIL.

    35. Re:Dreamed-of feature by Dr.+Weird · · Score: 1

      The problem is that you can't have different representations! You are still stuck with one. As soon as you compile to the underlying language, you cannot uncompile. Names are scrambled, etc.

    36. Re:Dreamed-of feature by femto · · Score: 1
      You've just described LISP , invented in the second half of the 1950's.

      As the inventor of LISP writes:

      If customary notations are to be used externally, translation programs must be written.
      also:
      Another reason for the initial acceptance of awkwardnesses in the internal form of LISP is that we still expected to switch to writing programs as M-expressions. The project of defining M-expressions precisely and compiling them or at least translating them into S-expressions was neither finalized nor explicitly abandoned. It just receded into the indefinite future, and a new generation of programmers appeared who preferred internal notation to any FORTRAN-like or ALGOL-like notation that could be devised.

      So basically, LISP is the generic format you are talking about. LISP is just bunch of list structures in memory.

      To allow humans to interact with it, the lists are often mapped to text. We can arbitrarily choose parenthesis as the list separators, resulting in the familiar lists enclosed by parenthesis.

      The intention was to write the front ends you describe, but the authors of LISP found it was just as convenient to write in the generic form so didn't bother.

    37. Re:Dreamed-of feature by titusjan · · Score: 1

      You might want to read Extensible Programming for the 21st Century. It was discussed on slashdot here.

  10. Perl by psyconaut · · Score: 1, Flamebait

    Write once, read never ;-)

    -psy

  11. Re:Speed and RAM by MooseGuy529 · · Score: 2, Insightful
    .. and now, 50 rebuttals from the Perl crowd.

    Yeah, Perl can be obtuse. Personally, I find that less-experienced programmers write clearer Perl code. Basically, there are many idioms and shortcuts that, used sparingly, can create extremely readable and intuitive code. However, just as using the same pronoun to mean several different things in the same sentence, using too many of these features makes code hard to read.

    Take $_, for example. I am relatively inexperienced at Perl (I have used it a lot, but I don't know a ton about it), and I usually don't use $_ unless I'm absolutely sure it will be what I think it is. Often, I prefer to use a specific variable name in constructs like foreach where the variable will be used several times in the loop, just because it makes things a little clearer.

    Personally, what I like about Perl is that, in the same way that PHP has functions for everything on earth, Perl has every data structure on earth built in. It's nice not to have to worry about how to organize data. Perl also just seems very intuitive to me. In my opinion, and inevitably opinions on this will differ, Perl makes concepts like pointers/references, hash tables/associative arrays, and arrays/lists simple enough that you can use them without extra effort, but versatile enough that you aren't stuck reinventing the wheel when you want a slightly different structure. That's basically one of the things that makes me prefer Perl to C--in C, I have to do so much stuff by hand: conversions, array insertions and such, but in Perl, everything does what it should without extra effort. Of course, Perl isn't for everyone or everything, since these built-in features come at a performance cost, but, for what I use it for (little scripts and such), it doesn't matter.

    Maybe the ease of working with data is what makes the rest of Perl programs so sloppy or cryptic sometimes... I guess when you have to create and manipulate data structures by hand, you can (and must) put more thought into what the data structures should look like.

    --

    Tired of free iPod sigs? Subscribe to my blacklist

  12. Magic by belg4mit · · Score: 1

    I like some of Perl's magic, some borrowed from predecssors, Particularly (read from all files given on the command line), and various switches such as -n, -p and -i that simplify away common code.

    --
    Were that I say, pancakes?
  13. OOh, I love! by Creepy+Crawler · · Score: 1

    MS C++ when it auto-fucks inline assembler!

    Wow, I coded a JMP there, somehow its now a JNE. Hmmmmmmmm... How'd I figure that out? Deadlist on a compiled executible. Never NEVER told me it'd do that. Just did it. Almost as bad as MASM...

    Sucks having to compensate for compiler errors!

    --
  14. closures by gstover · · Score: 1
    lexical closures, of course, & automatic memory management.

    gene

  15. Stupid Lexical Scoping Tricks by Breakerofthings · · Score: 2, Interesting

    Closures and Currying are two of my personal favorites.

    Overloaded Functions are sweet.

    I am also quite fond of operator overloading.

  16. Favourites by E_elven · · Score: 3, Insightful

    Ruby blocks, lambda functions, lazy evaluation.

    And C++ :)

    --
    Marxist evolution is just N generations away!
    1. Re:Favourites by Anonymous+Brave+Guy · · Score: 1

      I'll go with the lambda function bit, but I'm not entirely convinced by the rest. :-)

      I rather unsubtly advocate C++ around these parts from time to time, but that's because I think it's incredibly well-engineered for a real-world tool. It has a lot of "powerful enough" features, and you can get work done with it. However, if we're talking about favourite features for a language, presumably we're going for ideals, in which case frankly C++ sucks on most counts: its OO features can be cumbersome to use; its generics are child's toys compared to those in other languages; its syntax generally is terrible; and it's missing any serious support for functional idioms.

      Ruby blocks are, as far as I can tell, just a rather unusual syntax for fairly routine concepts. Quite a few people seem to like them, so I assume they do their job well in the context of Ruby as a whole, but what's special about them that a dozen other languages can't do in their own way?

      Lazy evaluation is an intriguing concept, but suffers from the classic flaw of many purely functional languages: in realistic problems, things don't run on abstract machines in isolated worlds, and a certain level of determinism is required to get things done. I've yet to see a really compelling example of code that is particularly elegant or efficient using lazy evaluation, but can't be written similarly elegantly and efficiently using some sort of generator/iterator idiom and perhaps a basic optimiser.

      Lambda functions, and in fact the whole family of related concepts -- higher-order functions, currying, anonymous functions, closures -- just make life so much easier. Working in languages that provide at least modest support for these ideas (in the sense of, say, Perl rather than ML or Haskell) always seems less like hard work than using something like C++, where the closest you get is some template wizardry which, looked at objectively, is pretty much off the scale at the wrong end. Functional idioms rock, and why no-one has yet produced a solid imperative language that integrates these features cleanly and comprehensively I do not know...

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Favourites by E_elven · · Score: 1
      >[C++] generics are child's toys compared to those in other languages;

      I'm not sure what you mean -could you give an example? C++ templates do the functional-style polymorphism quite well, i.e. an operation can be applied to an arbitrary type (or sequence thereof usually). Additionally you have the immense metaprogramming power right there for you to tap into including compile-time polymorphism (the OO kind) and other nifty stuff.

      Speaking of toy implementations, have you taken a look at Java Generics?

      >Ruby blocks are, as far as I can tell, just a rather unusual syntax for fairly routine concepts. Quite a few people seem to like them, so I assume they do their job well in the context of Ruby as a whole, but what's special about them that a dozen other languages can't do in their own way?

      It's just that 'unusual syntax' and ease of use. Observe:
      array_of_elements.each do | element |
      do_something_with element
      end
      Lovely, looooovely!

      >Functional idioms rock, and why no-one has yet produced a solid imperative language that integrates these features cleanly and comprehensively I do not know...

      Well, in the case of higher-order & anonymous functions: any language that has higher-order functions is by (one) definition functional so the question should be unasked :) I think OCaml is an excellent mix of idioms but unfortunately I've this inner drive -a daemon, Goethe would say- to go all-out on a given idiom so I sort of prefer Haskell over it.

      --
      Marxist evolution is just N generations away!
    3. Re:Favourites by Anonymous+Brave+Guy · · Score: 1
      [C++] generics are child's toys compared to those in other languages;
      I'm not sure what you mean -could you give an example? C++ templates do the functional-style polymorphism quite well, i.e. an operation can be applied to an arbitrary type (or sequence thereof usually).

      That's true, of course, up to a point. They're certainly very useful things. The problem is they're so awkward, both to write and to use. Compare something like this fairly typical C++ style:

      template &lt;<typename Cont, typename T&gt;
      bool contains(Cont c, T x)
      {
      for (Cont::iterator it = c.begin(); it != c.end(); ++it)
      {
      if (*it == x) return true;
      }
      return false;
      }

      with this fairly typical ML style (neglecting the fact that you'd probably do this with a higher-order function in such a language anyway):

      fun contains (x, []) = false
      | (x, h::t) = h = t orelse contains (x, t);

      The combination of type inference, implicit genericity, and pattern matching in the functional version makes for much more concise code.

      Additionally you have the immense metaprogramming power right there for you to tap into including compile-time polymorphism (the OO kind) and other nifty stuff.

      That's true, if inadvertent. However, at the risk of using an old cliche, look at LISP if you want to see what metaprogramming can really do.

      Finally, regarding Ruby blocks, what does that approach offer over a fairly common idiom (in random pseudo-code):

      foreach element in array_of_elements:
      do_something_with element

      or the obvious functional version:

      apply do_something_with array_of_elements

      The technique is useful, but I don't see why Ruby's blocks offer anything new or different. Am I missing something here?

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  17. dream here.... by josepha48 · · Score: 1
    I like lots of things from different languages..

    regexp functions -> functions that do what the regexp do. eg result = regexp.removeSpace(word);

    Easy to understand syntax.. instead of && use AND, instead of OR use OR, etc. kinda BASICish syntax.

    Garbage collection that works, unlike java where sometimes it losses things, because of programmer error. IE: if I can do it the garbage collector should clean up after me, if it can't then it should not let me do it.

    Definatly object oriented, Java / C# / C and Perl are all cool for their ability to do objects, so its python. There is more....

    --

    Only 'flamers' flame!
    Does slashdot hate my posts?

    1. Re:dream here.... by tchuladdiass · · Score: 1

      Which would you prefer:

      twenty three plus fifty two divided by 7
      or
      23+52/7 ?

      To me, symbols are easier to read when there is a lot of code to go through, because they take up less short term memory space than more wordy syntax. Which brings up my favorite feature, C's inline conditional (I only which there was a "looping" inline conditional).

    2. Re:dream here.... by josepha48 · · Score: 1
      Hmm Id say..

      result = add(23, div(52,7));

      a little more typing but not that much.

      I've looked at some pretty ugly C and I've even seen some really obfuscated(sp) shell code and perl.

      regexp can be a real pain in some cases when people do things that more advanced.

      Also it would be good to see the result have two parts to it. result.int (gives integer value) and then result.dec (gives decimal value), then result just gives both. No double, or longs or shorts or etc, etc.

      C is good for many things, but sometimes I find that I end up putting in more comments in my code so people can follow what is going on in the code. In some programs that get really large what ends up happening is that people just keep adding to the code and then you look at a function and spend half a day trying to figure out why someone added 1 line. If the code was easy to read and the coder spent less time trying to figure out do I need a long or double or did I free this, or ... and more time on just what the task he wanted to get done was, ie I need to do business logic, it could be better. I like Java alot, but it has problems with its garbage collection, IE I've coded errors in the code that prevent stuff from getting collected. Simple put I should not be able to code like that.

      --

      Only 'flamers' flame!
      Does slashdot hate my posts?

  18. C++ friend by gRa · · Score: 1

    I really really love the keyword "friend" in C++. It invites objects of other classes to touch one's private parts.

    I like methaphors of pleasant real live experiences in a programming language. (That is why I hate the functions "kill" and "die".)

  19. C pointers and arrays by Quill_28 · · Score: 3, Interesting

    Just to confuse people do this:

    main() {

    int x;
    int y[2];

    x=1;
    y[1]=10;

    printf("%d\n", y[x]);
    printf("%d\n", x[y]);
    }

    What will happen?

    1. Re:C pointers and arrays by Anonymous Coward · · Score: 0

      10
      10
      utterly perverse.

    2. Re:C pointers and arrays by Anonymous Coward · · Score: 0

      It won't compile.

    3. Re:C pointers and arrays by ComputerSlicer23 · · Score: 3, Informative
      As I recall, in C x[y] and y[x] are defined to be identical. I believe you can do 1[y] and have it work. That's because a[b] is must be identical to *((a) + (b)). I'm over using paranthesis intentional. Because addition of a pointer and a constant is communitive, either one works. Because (1 + y) is a legal, and returns a pointer it works.

      Personally, I think it's a completely crappy thing. You should get an error telling you: "Attempting to use a constant like a pointer".

      So it should print out "10\n10\n";

      If that's an ANSI C complier: you should get a warning about no return in main, an illegal declaration of main, and an unknown function printf. You might get away with main, because I believe all functions implicitly return an int.

      Kirby

    4. Re:C pointers and arrays by Quill_28 · · Score: 3, Interesting

      You are correct. Thee compiler just sees memory.
      The x could also be a double.

      double x; won't change a thing

      One another interesting thing:

      the x[y] line compiled into assembly(using gcc non-optimized) will use less lines of code than y[x]

      Optimized they use the same.

      Learning this stuff actually gave me a much better understanding of pointers and arrays and their relationship in c.

    5. Re:C pointers and arrays by JohnFluxx · · Score: 1

      hmm, that would only work if both sides are the same size.
      This works because an int * is the same size as an int. If you used char's, I'm sure it wouldn't work.

      Correct me if i'm wrong.

    6. Re:C pointers and arrays by Quill_28 · · Score: 1

      Are you refering to the assembly part or using a double as the array?

    7. Re:C pointers and arrays by JohnFluxx · · Score: 1

      I mean:

      char x;
      char y[2];
      x = 1;
      y[1] = 99;

      In this case I don't think that y[x] is the same as x[y]

    8. Re:C pointers and arrays by Quill_28 · · Score: 1

      I believe you are correct, it won't compile.

      But you could do something like

      int x;
      chat y[2];
      x=1;
      y[1]=99

      Then they would be the same.

    9. Re:C pointers and arrays by JohnFluxx · · Score: 1

      yes because sizeof(int) == size(char*)

    10. Re:C pointers and arrays by squiggleslash · · Score: 1
      It will. anything[somethingelse] in C is syntactically identical to *(anything+(somethingelse)), so you can, quite legitimately, have an integer outside the brackets and a pointer on the inside.

      Of course, you're more likely to want to turn the integer (offset) part of the dereference into an non-trivial calculation than the pointer part.

      --
      You are not alone. This is not normal. None of this is normal.
    11. Re:C pointers and arrays by squiggleslash · · Score: 1
      No, it's still right. You're misunderstanding what's going on.

      x is not being mysteriously changed to a pointer in x[y], it's still being read as an integer. So, if x is 1, and y is 4e00, in x[y] it's still being evaluated by the compiler as 1[(int *)4e00]

      However, in C (I just wrote this, damn it!) a[b] is exactly the same as *(a+(b)). A pointer plus an integer is always a pointer to the same type as the original, offset by the integer multiplied by the object size. And it doesn't matter what order you do it in, *(a+b) == *(b+a).

      So in the above case, x[y] == *(x+(y)) == *(x+y)
      ; y[x] == *(y+(x)) == *(y+x) == *(x+y).

      That's how it works, honestly. Internally, the C compiler is doing something like:

      Write out code to evaluate x into register A
      Write out code to evaluate y into register B
      # We're adding an integer to a pointer, so multiply integer portion by object size
      Multiple A by four
      Add A to B
      Get byte from memory location B

      That's why they're the same. And you can set x to be any type you like as long as it can be automatically cast to an integer.

      --
      You are not alone. This is not normal. None of this is normal.
    12. Re:C pointers and arrays by JohnFluxx · · Score: 1

      I'm going to have to check this now, because I'm sure I'm right, but I'm going to look a fool if I write the code and I'm wrong :)

      It's not doing exactly *(x+(y)) it's doing more like I said: *(x + sizeof(*x)*y )

      And it's that added sizeof that's makes x[y] != y[x] when it's char x and char *y;

    13. Re:C pointers and arrays by squiggleslash · · Score: 1
      May I suggest you try doing *(x+y) because you'll see I'm right and you missed a critical comment from me.

      When you add an integer to a pointer, the integer is multipled by the object size before the addition takes place. Eg, for a 32 bit machine with a flat memory space:

      char *x = (char *)NULL; printf("%d\n", x+1);

      will print "1".

      Wheras:

      int *x = (char *)NULL; printf("%d\n", x+1);

      will print "4".

      So your sizeof is actually inappropriate. Instead of, for (32 bit) int *y, "*(x + sizeof(*x)*y )" adding 4x, it'll add 16x!

      That's why x[y] == *(x+y) == y[x]. It's the same operation in all cases. x[y] is always equivalent to *(x+y), it's actually defined by ANSI.

      This is also why x++ and x+=1 are always equivalent. Because if x (on a 32 bit machine) is an integer pointer, both will add four to x, not one. This is because:

      x+=1 == x=x+(1). If x is a pointer, then pointer arithmetic is used, so the integer portion is multipled by the object size before the addition takes place. Four gets added to x.

      --
      You are not alone. This is not normal. None of this is normal.
    14. Re:C pointers and arrays by squiggleslash · · Score: 0
      "*(x + sizeof(*x)*y )" adding 4x, it'll add 16x!
      Erm, 4y and 16y respectively. Must. Learn. To. Hit. Preview. Button.

      And now that damned stupid two minute thing has kicked in. Time to find a joke to cut 'n' paste:

      Seems there was a young soldier, who, just before battle, told his sergeant that he didn't have a rifle.

      "That's no problem, son," said the sergeant. "Here, take this broom. Just point it at the Germans, and go 'Bangety Bang Bang'."

      "But what about a bayonet, Sarge?" asked the young (and gullible) recruit.

      The sergeant pulls a piece of straw from the end of the broom, and attaches it to the handle end. "Here, use this... just go, 'Stabity Stab Stab'."

      The recruit ends up alone on the battlefield, holding just his broom. Suddenly, a German soldier charges at him.

      The recruit points the broom. "Bangety Bang Bang!" The German falls dead. More Germans appear. The recruit, amazed at his good luck, goes "Bangety Bang Bang! Stabity Stab Stab!" He mows down the enemy by the dozens.

      Finally, the battlefield is clear, except for one German soldier walking slowly toward him. "Bangety Bang Bang! shouts the recruit.

      The German keeps coming.

      "Bangety Bang Bang!" repeats the recruit, to no avail. He gets desperate. "Bangety Bang Bang! Stabity Stab Stab!"

      It's no use. The German keeps coming. He stomps the recruit into the ground, and says...

      "Tankety Tank Tank."

      Yeah, I thought it sucked too.
      --
      You are not alone. This is not normal. None of this is normal.
    15. Re:C pointers and arrays by JohnFluxx · · Score: 1

      Ah. It seems I missed the crucial part that the + operator does more than first meets the eye.
      Got it - thanks.

      btw, the joke sucked. :P

    16. Re:C pointers and arrays by booch · · Score: 1

      Don't forget:

      for ( int i = 0; i < 13; i++ )
      putchar(i["Hello, World!"]);

      --
      Software sucks. Open Source sucks less.
    17. Re:C pointers and arrays by Anonymous Coward · · Score: 0

      I want a refund for the forty seconds I spent reading that joke (notwithstanding the time I'm spending on this post).

  20. Self-execution by BollocksToThis · · Score: 4, Informative

    My favourite thing is languages that can execute strings of their own code.

    For example, clipper can do this via blocks:

    cVar := &("{ || nVar += 43")

    Python has the same thing via "exec":

    >>> b
    NameError: name 'b' is not defined
    >>> exec "b=2"
    >>> b
    2

    This means you can build up strings of code at runtime and execute them, or store field-specific database logic in another database table, and fetch it when needed.

    C# is not quite so convenient - you have to build up a complete class and compile it, but it can all be done in memory at runtime so it's just a little more work. Clipper and python can both affect the current scope directly (which can be both bad or good, I suppose).

    I believe ruby has blocks similar to clipper (probably better), but I don't use it, so I'm not sure. I also don't use perl, so I have no idea if it supports this...

    --
    This sig is part of your complete breakfast.
    1. Re:Self-execution by BollocksToThis · · Score: 1

      Err, oops, cVar wouldn't really have any value after that block executes - that'll teach me to change my example halfway through...

      --
      This sig is part of your complete breakfast.
    2. Re:Self-execution by Randolpho · · Score: 1

      Hmm... I have yet to see a valid reason why runtime code generation might be valid. Would you care to supply one? I'm honestly interested; I see no real point, but I'd like to.

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    3. Re:Self-execution by BollocksToThis · · Score: 2, Informative

      I'm not sure what you mean by 'valid', but I'm going to go with 'useful'.

      Say you have a database with multiple tables that all require user data entry. You can write code for each and every data entry screen (apparently the "visual basic" school of thought), or you can write a generic data-entry screen and include pieces of code for specific field validation in the database itself - so in effect, based on structural tables, the program builds the correct code for each screen. This also saves having to distribute a new version of your app every time you update or add a new table.

      Another good reason might be embedding pieces of code in an XML document or some such, but that seems a little less useful than the database idea.

      --
      This sig is part of your complete breakfast.
    4. Re:Self-execution by multriha · · Score: 1

      Runtime code generation is very fun, arguable useful, and unquestionable too big a security issue to consider ever using.

    5. Re:Self-execution by Anonymous Coward · · Score: 0

      too big a security issue to consider ever using

      Now that's just not true at all. It depends, like all things security-related, on where it's used, how it's used, and what it's used for.

    6. Re:Self-execution by turgid · · Score: 2, Interesting

      In the days of 8-bit micros, as games became more advanced, allegedly self-modifying code was used to get enough stuff in the sparse RAM available and for performance reasons when a dynamically-modified unrolled loop was required IIRC.

    7. Re:Self-execution by Randolpho · · Score: 1

      Ok.... so tell me how this differs from, say, writing a re-usable function?

      Honestly, I don't see how storing the code in the database is somehow better than storing the code in the system, other than that it reduces the code size of the actual system (at the expense of storing it elsewhere); you still have to write the code.

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    8. Re:Self-execution by Etyenne · · Score: 1
      Runtime code generation is very fun, arguable useful, and unquestionable too big a security issue to consider ever using.

      I don't see the point. If you don't execute outside input to your program, how could it be a security issue ?

      --
      :wq
    9. Re:Self-execution by Etyenne · · Score: 1
      also don't use perl, so I have no idea if it supports this...

      It does. It's called eval. It is also use for exception handling.

      --
      :wq
    10. Re:Self-execution by funbobby · · Score: 1

      One simple reason is that it's a hell of a lot harder to figure out what the code does, which means it's far more likely to ship with bugs, and those bugs could be security holes. A more specific security risk is that if you have other bugs that cause your program to produce garbage data, executing the garbage will probably be far more destructive than just outputting garbage.

      Self generating code is playing with fire. It's of dubious value, and it has a non-trivial chance of going wrong spectacularly. Even if it works, the next person who looks at the code will be cursing your name because of the extra hours they had to spend unravelling it.

    11. Re:Self-execution by Anonymous Coward · · Score: 0

      Of course you still have to write the code, but:

      a) you don't need to deploy the new code, so you don't need to update hundreds or thousands of clients who may be distributed throughout the country or the world. You just need to update the database.
      b) you don't have to duplicate the common code for every new dialog.

      Perhaps it would be better if you explained how your reusable function easily handles multiple tables with different validation requirements?

    12. Re:Self-execution by blancolioni · · Score: 1

      Allegedly? The main loop of the C64 Basic interpreter was self-modifying, and it was put into zero page for an extra speed boost.

    13. Re:Self-execution by turgid · · Score: 1

      The 6502 was so primitive, and the instruction set so poor, that I'm surprised anyone managed to write anything at all that wasn't self-modifying on that architecture.

    14. Re:Self-execution by mc6809e · · Score: 1

      In the days of 8-bit micros, as games became more advanced, allegedly self-modifying code was used to get enough stuff in the sparse RAM available and for performance reasons when a dynamically-modified unrolled loop was required IIRC.

      In my experience, it was mostly used to save a level of indirection. Loading an immediate value was faster than loading a value through an address.

      Suppose you had to loop x times, where x periodically changes. You could do

      LDA #0
      loop: CMPA $x
      BEQ exit
      INCA
      BRA loop
      exit:

      Each CMPA with contents of address x might cost you 5 cycles. Instead, you might do

      LDA $x
      STA $loop+1 // immediate field of CMPA instruction
      LDA #0
      loop: CMPA #0 // 0 is dummy value to be over-written
      BEQ exit
      INCA
      BRA loop
      exit:

      Now the CMPA #whatever takes only 2 cycles and you get some more speed.

    15. Re:Self-execution by Osty · · Score: 1

      I don't see the point. If you don't execute outside input to your program, how could it be a security issue ?

      From a T-SQL (Microsoft SQL Server) standpoint, dynamic code execution is a security risk for several reasons. SQL injection is the obvious reason, but even if you don't think you're at risk for SQL injection doesn't mean you're not. Why is that? Simply, because you have to allow more permissions on database objects when using dynamic code.


      For example, I may want to limit permissions to insert into table Foo to a well-written, security-reviewed stored procedure sp_InsertFoo. I can give EXECUTE permissions to sp_InsertFoo and not have to give INSERT permissions on the table Foo.


      Now imagine I have a procedure sp_DynamicInsertFoo that inserts into Foo but does so with with dynamic code generated inside the procedure. Now I not only have to give EXECUTE permission to whoever's calling sp_DynamicInsertFoo, but I also have to give INSERT permission on Foo. If my application ever does run into a SQL injection vulnerability, Foo can now be written into by arbitrarily. This would be even worse if Foo is a table where I store SQL instructions I want to execute.


      Permission problems aside, there's also performance issues. A stored procedure using dynamic code needs to be recompiled more often (perhaps even every time it's run), compared to a static procedure that can be compiled once and cached. As well, from experience I've found that 90% of the time someone is trying to write dynamic code in such a scenario, there's some design flaw in their logic. This is similar to folks that can't think in set-based operations and so try to do everything using cursors (cursors have their uses, but in general they're a poor choice).


      That said, with proper design and planning, there are some situations where the benefit of dynamic code generation may outweight the deficits. It's a rare scenario (not as rare as it should be, but still rare), but dynamic SQL execution does have its place.

    16. Re:Self-execution by Anonymous Coward · · Score: 0

      It seems to me you're using a sproc to work around a brain-damaged security model. If your schema could express which INSERT and UPDATE transactions are permitted, it wouldn't make any difference how they were generated.

  21. Re:Speed and RAM by Anonymous Coward · · Score: 0

    I would like to inquire as to what illicit substances have been utilized by you prior to the creation of that comment.

  22. Several: by twem2 · · Score: 3, Interesting

    Functions as first class citizens, that is functions can be returned from functions and provided as arguments as functions. The basis of the functional paradigm and it makes life much much simpler.
    Pattern matching (some ML:)

    fun has_a [] = false
    | has_a 'a'::_ = true
    | has_a _::xs = has_a xs;

    Simple elegent functions requireing much less if_then_else's.

    Automatic garbage collection and bounds checking: enables me to write the code to do the job, not the memory management.

    Polymorphic typing: I can write general functions:

    fun contains x [] = false
    | contains x x::_ = true
    | contains x _::xs = contains xs;

    That will work with any type for which equality is defined.

    These are the reasons I hate C for general programming. The most important thing is efficient algorithms, without them no amount of low level optimization will help. With good algorithms, functional languages are now normally at least as fast... (and much much easier to debug and even verifiable).

    From non-functional languages, the object model is wonderful when used properly.
    Smalltalk & co's complete environment is a nice feature.

    I also have a soft spot for BBC BASIC with its speed, interactivity and simplicity. These are combined to allow windowed applications including at least one web browser and anyone can start programming simple programs (which is missing from most modern computers)

    Then there's the specialist languages. They have all sorts of nifty features (Mathematica is a good example) but I wouldn't expect them in an everyday language.

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

      <blockquote>
      These are the reasons I hate C for general programming. The most important thing is efficient algorithms, without them no amount of low level optimization will help. With good algorithms, functional languages are now normally at least as fast... (and much much easier to debug and even verifiable).
      </blockquote>
      C allows you to return functions if you so desire.<P>
      <P>

      void (*returnfunc(void))(void);

      int main(int argc, const char *argv[])
      {
      (*returnfunc())();

      return 0;
      }

      void *returnme(void)
      {
      printf("I tawt I taw a puddy cat\n");
      }

      void (*returnfunc(void))(void)
      {
      return returnme;
      }

    2. Re:Several: by ameoba · · Score: 1

      I'm suprised that nobody has mentioned anything about Prolog (and been modded up). It takes your pattern matching and then adds on a depth-first-search with backtracking and can execute all matching versions of a fuction.

      It's kinda like have a non-deterministic computer.

      --
      my sig's at the bottom of the page.
    3. Re:Several: by Anonymous+Brave+Guy · · Score: 1
      C allows you to return functions if you so desire.

      Well, it allows you to return function pointers, which certainly have their uses. However, your program has eight non-trivial lines of code, but would be written in around three lines in just about any language supporting serious functional idioms, something like this (in random functional pseudo-code):

      fun main = returnfunc
      fun returnfunc = returnme
      fun returnme = print "I tawt I taw a puddy cat\n"

      Such features, having much simpler syntax, would also be immune to the error involving pointer notation that you made. Moreover, a compiler that understands functions to this level would almost certainly reduce this to main being the print expression, which no C optimiser is likely to do in your case.

      Your simple example is a perfect demonstration of exactly why C sucks in this particular respect.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  23. Two words: string handling by Fished · · Score: 4, Interesting

    This is not the issue it was ten years ago, but one feature I absolutely want tightly integrated into my language is robust string handling. I still like perl's best (although perhaps only because I know it best). It simply seems to be more tightly integrated into the language as a whole.

    --
    "He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
    1. Re:Two words: string handling by Randolpho · · Score: 1

      I'd like to second this. In fact, I'd have firsted it if you hadn't posted.

      Strings are one of the most important aspects of programming; the number of complete, useful programs that have been written that didn't process or use a string in some way is close to zero.

      A good programming language uses and processes strings in a speedy, efficient manner, and has a robust, easy to program means of doing so.

      --
      "Times have not become more violent. They have just become more televised."
      -Marilyn Manson
    2. Re:Two words: string handling by jonadab · · Score: 1

      Yes, good string-handling is essential. I used to like BASIC for that, but
      then I discovered elisp. The buffers in elisp are exceedingly handy for this.
      They're like strings on steroids, only that really doesn't do them justice.
      The ability to place markers is particularly nifty: you can mark a spot in
      the buffer, and then you can modify the contents of the buffer, and the
      marker still marks the "right" place, even though it may be a different number
      of characters into the buffer. There are other cool things about buffers too.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    3. Re:Two words: string handling by hackstraw · · Score: 1

      First. Wow! An interesting ask.slashdot.org question.

      OK, my language of choice is Perl. Some things I like about it:

      - while (<>) { ... } 99% of my scripts have this. Thise little thingy does _a lot_. It means that I am reading one line from a file or STDIN and stuffing the contents into an anonymous variable $_. Its cool because you can use it on a pipe or with a filename, you don't have to test for which is which, and it automatically does the opening of the file for you

      - foreach (@ARRAY) { ... } I do this a bunch

      - I like that there are basically only 3 data types in perl. A thingy ($var), a bunch of thingys (@STUFF), and a key value pair of thingys (%HASH = ( key => var })

      - no allocation or deallocation of memory

      - HERE documents really simplify large text field

      - the __DATA__ handle

      - the __END__ thing so I can use the space below that for scratch space

      - regular expressions that kick ass

      - I wish there were a cleaner way to do block quotes in C I cheat by doing #if 0 #endif

      - I think the dangling if and unless things are nice, but I almost always rewrite them because there is more than one line of stuff ...

      Oh well, the power just went out, I gotta shut down my computers.....

    4. Re:Two words: string handling by Anonymous+Brave+Guy · · Score: 2, Insightful

      This is certainly true to a point. There are three basic kinds of data used throughout the programming world: text, numbers and logic (true/false). Pretty much any mainstream general-purpose language provides basic arithmetic and logical operators, and then an extensive library of more advanced mathematics functions. With strings, you often get basic operators, but beyond those there's a world of difference between providing a couple of upper-/lower-case conversions and having things like regular expressions supplied as standard.

      I think part of this problem is that what constitutes good support for strings isn't nearly as clear-cut as it is with numbers. Should we provide mutable and non-mutable types? How much should the regexes support? How do we deal with international issues?

      The latter is a biggie that I think will become more significant as time goes on and markets expand worldwide. Frankly, most languages suck when it comes to dealing with translating text and working with foreign languages. Consider how many provide a function mapping a character onto its upper-case equivalent; what it's supposed to do with a German double-s? Some languages get text support spectacularly wrong: C++'s much heralded IOStreams system codifies structure that should be data, and thus makes itself almost completely useless for any sort of internationalised development; all the locales in the world won't change the fact that different languages use different word order conventions.

      I think the underlying problem here is that text is fundamentally a complicated thing. Numbers, whether integers, fixed- or floating-point, have fairly well-defined rules (though as any numerical analyst will tell you, they don't necessarily match those of mathematics). Text, however, is on a different level. Even dealing with simple concepts like a case-insensitive comparison (assuming your input language even has cases in this sense) can be hugely complicated in practice, and complications like multiple word-forms multiply up to make it many times more difficult than typical mathematical code. It's more like expecting calculus to be built into a simple programming language, except that relatively few apps need that level of maths, while just about anything with a UI potentially needs that level of text support.

      Even if you're only dealing with manipulations of well-structured text in a single language, not all processing fits neatly into the idioms offered by regular expressions. Regexes are powerful tools, to be sure, but I think we're still waiting for the not-quite-silver bullet in text processing to arrive. I expect this to be something based on higher level concepts than a simple list of characters, possibly to be very demanding of processing power (though viable with tomorrow's technology), and probably to revolutionise the international development community like nothing we've ever seen before.

      So yes, I agree completely, good text processing is a very important feature for a programming language. If only any of them had it... ;-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  24. This "ask Slashdot" is a concurrent "cross-post" by Paul+Bain · · Score: 4, Informative
    The poster, johnnyb, also asked this question on Advogato just a short time ago. It will be interesting to see the differences in the comments made there and the ones made here at Slashdot.

    Hey, johnnyb, where else have you posted this question? When you get answers, will you analyze them and post your conclusions? It could be interesting.

    --

    A lawyer & digital forensics examiner. Also an expert on open source software (OSS).
  25. Re:Speed and RAM by Gilk180 · · Score: 1

    in C, I have to do so much stuff by hand: conversions, array insertions and such, but in Perl, everything does what it should

    I am all for scripting languages such as perl and my favorite python, but this isn't the way I would describe it.

    In C, some stuff needs to be done by hand, but it does what you want it to do.

    In many scripting languages, it does what the interpreter thinks it should do and getting things to act the way you want is much harder if this differs from what the interpreter thinks it should do.

    Both approaches have their uses. Some things are just easier in Perl/Python/whatever. Some are easier in C.

  26. Python's indentation syntax by mkcmkc · · Score: 3, Insightful
    Like probably most people, I hated Python's blocking-by-indentation syntax for the first few weeks. The column restrictions kind of reminded me of FORTRAN.

    But after the adjustment, I've truly grown to love its spartan clarity and simplicity. I can hardly stand to look at the redundant brace-littered syntax of Java, C or Perl now.

    Mike

    --
    "Not an actor, but he plays one on TV."
    1. Re:Python's indentation syntax by thaWhat · · Score: 1

      yeah, but try a little cut and paste form someone else's code were they use spaces instead of tabs, or hack some code where you move code in and out of blocks... I moved to perl, then to php ps: somehow I am glad that cold fusion does not even rate a mention here

      --
      If all you have is a hammer, everything looks like a thumb.
    2. Re:Python's indentation syntax by L1TH10N · · Score: 2, Insightful

      I was a bit sceptical of the Python method of blocking. Then I tried Python and really lost my tempo because I was so used to having closed braces. But after getting used to the Python way, I found it was so QUICK!

      --
      Yet another ironic recursive statement.
    3. Re:Python's indentation syntax by texwtf · · Score: 1

      What really grates on me about the python indentation thing is not that it exists, rather that the python users are so dogmatic about it.

      Would it really kill them to provide a pragma to use curly blocks like the rest of the sane universe? Why not be a little less inflexible and let people code how they want?

      The feature I want in a language is a little less specific: Let me program how I want as opposed to enforcing some arbitrary pet style of your own.

    4. Re:Python's indentation syntax by mkcmkc · · Score: 1
      Let me program how I want as opposed to enforcing some arbitrary pet style of your own.

      The wisdom of a converged, aesthetic style is probably more obvious after one has (a) tried it for a few months, and (b) maintained code written "how I want" for a few years.

      Mike

      --
      "Not an actor, but he plays one on TV."
  27. Generic programming by LoveMe2Times · · Score: 4, Insightful
    The ability to do generic programming ala Boost is a great feature. Higher level languages are all about better abstractions, and generic programming is the best abstraction mechanism we've seen in general use since OOP. While OOP lets you encapsulate behavior and abstract over interfaces, generic programming lets you abstract over *form*. The significance is in the coupling. Generic programming allows much looser coupling between the writer of the generic library and the user of the library. A nice example is a generic "find" function:
    template <typename I, typename V>
    I find(I begin, I end, V val)
    {
    for (I it = begin; it != end; ++it)
    if (*it == val)
    return it;

    return end;
    }
    And here, you have captured the essence of a linear search. To understand what's going on, first know that I and V are arbitrary types that are inferred (at compile time) from the values you pass when you actually call the find function. For the generic find function to work, there are only a couple of restrictions on these types:

    1) I must be incrementable.
    2) I must be dereferenceable.
    3) You must get from begin to end in a finite number of steps.
    4) The type you get when dereferencing I (I's value type) must be comparable to V.

    Because of this, you can use the same find function to search through arrays, lists, vectors, maps, sets, strings, streams, and more, even though none of them inherit from each other or implement a common interface in the OOP sense.

    Additionally, there's no complicated syntax for the user of the library:
    int myarray[10] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55};
    int* p = find(myarray, myarray + 10, 8);
    if (p == myarray + 10)
    cout << "8 was not found." << endl;
    else
    cout << "The value of p is " << *p &lt&lt "." << endl;
    The great thing about abstraction is that it avoids duplication. Avoiding duplication lets you test/debug/prove correct once for greater reliability. Once you wrap your head around this simple example, you'll be surprised how deep the rabbit hole goes.
    1. Re:Generic programming by tchuladdiass · · Score: 2, Interesting

      One thing I've always wondered (since I mostly do C and not much into C++), how is this different than something like pointers to void in C? For example, the way qsort() works -- it can operate on any data type also.

    2. Re:Generic programming by CableModemSniper · · Score: 1

      try qsort with argv and see how well it sorts it.

      --
      Why not fork?
    3. Re:Generic programming by X · · Score: 1

      Generic programming is in many ways kind of the opposite of using void*. Using void* your world is typeless. With generics, you have the full type information available to you. Generic programming is very much about Type Theory.

      This plays itself out in many ways. For starters, with generics you can do specialization (like for your sort example, you might want to handle things differently depending on whether your void* points into an array vs. a linked list vs. a b-tree). You also have no problem doing things like "++i" if i is a generic iterator, but there isn't a way to do that if i is a void*.

      Really, what I'm talking about is just the tip of the iceberg though. If you want to really blow your mind, try using a language like ML, or read "Modern C++ Design".

      --
      sigs are a waste of space
    4. Re:Generic programming by Anonymous Coward · · Score: 0

      template <typename I, typename V>
      I find(I begin, I end, V val)
      {
      for (I it = begin; it != end; ++it)
      if (*it == val)
      return it;

      return end;
      }

      ...you can use the same find function to search through arrays, lists, vectors, maps, sets, strings, streams, and more...



      Sorry to be pedantic, but your function wouldn't work as expected on std::map since the iterators point to pair<key, value>. Besides which, it's silly doing a linear search on trees like std::map and std::set, so they have member find functions.
    5. Re:Generic programming by Vadim+Grinshpun · · Score: 1

      well, the difference here is type safety.
      e.g., the compiler ensures that the "begin" and "end" are of the same type (I), and that when something of type I ("it", in the example in the post) is dereferenced, you get something of type V.

      with void*, you are on your own, and if you pass incorrect pointers to your function, you won't find out until the program crashes or produces very strange data.

      e.g., let's say you have an array of doubles called a, and an array of chars called z. and you'd like to find the value 3.14 in the former.
      In your code you make a typo that looks something like this:
      int index = find( a, z+length_of_a, 3.14)

      with the generic find function, the compiler will catch the error (the find might have to be written out as find).
      if find were written using void *'s instead, you'd not know anything was wrong at runtime.

      HTH :)

  28. the . operatior (PHP) ownz by opweirdisntit · · Score: 0

    man... on almost every language by default you cant combine as easily as you can with PHP. With a simple . you can save yourself wonders of time. Maybe even go out with girls now :P for example....

  29. wow.... by opweirdisntit · · Score: 0

    wow it cut off my example:():P

  30. VB could use a little of that by pingveno · · Score: 2, Insightful

    Complete agreement! It's much easier and readable. It would be great if MS used that for Visual Basic, instead of the ugly End If construct. Much more comfortable for people who have to work with VB every once and a while. Some people get too attached to the English language.

    --
    "it's not about aptitude, it's the way you're viewed" - Galinda
    1. Re:VB could use a little of that by vadim_t · · Score: 1

      "End If" contains useful information though. In C you sometimes see things like:

      } /* if (foo == bar) */

      because lots of {s and }s get confusing pretty fast

  31. Simplicity, macros, conditions, multiple dispatch by Wolfkin · · Score: 2, Interesting

    I use Common Lisp.

    Lisp has almost no syntax, so it's extremely regular (barring exceptions like LOOP). Because it's so regular, it's easy to build macros that do powerful things.

    Macros can completely transform the source, at compile time, but with the full power of the language. Having that ability, together with simplicity, means that it's easy to build a complete mini-language for one's manager or web designer to use on the site, and easy for them to learn it, since you can explain the syntax in 5 minutes or less, and they don't have to learn 50 built-ins to use it.

    Common Lisp's conditions system not only allows exception-handling, like Python, but can also have an entire protocol for controlling execution flow built on it. More about that in the conditions chapter of Peter Seibel's forthcoming book.

    Lastly, having a generic-function-based object system means that a method can "belong" simultaneously to more than one class, at the same time. So, instead of having a method inside a class, you call a method with any number of objects of various classes, and it figures out from the type of the object what method to run, of all the similarly named methods. You can even specialize a method on a particular object or objects, instead of a particular class or classes! Multiple dispatch rocks.

    --
    Property law should use #'EQ, not #'EQUAL.
  32. Re:Speed and RAM by daviddennis · · Score: 2, Insightful

    What makes Perl sloppy or cryptic was that it was designed to make it easy to create quick hacks. Remember Larry Wall's Great Programmer Virtues: Lazyness, Impatience and Hubris. Perl was designed to make laziness easy; once Perl was written, you could be very lazy in your programming and things would still work.

    I'm an experienced programmer who's done relatively little Perl, although its use is increasing significantly in my work. Like you, I deliberately avoid use of $_ because I find it a very confusing concept, and I think it encourages the creation of confusing code. And even though you and I avoid it, the beginning Perl books are full of it and that makes it almost inevitable that most will use it.

    For some reason, I always, always hated that $ you have to put in front of variable names. I know it makes all sorts of interesting things possible, but for some reason I've always found it hard to read.

    Still, it's tough not to love associative arrays built into the language. It really makes a lot of normally tough things a snap, and I'm sure their coding of it is a lot faster than anything I would have done.

    D

  33. Branches by Anonymous Coward · · Score: 0
    The branch has been around since assembly

    They are used behind the scenes higher languages to create loops. They are still visible in most programming languages usually through the 'if' keyword.

    Without the branch, the simple manipulation of the Program Counter, there would be nothing more than calculators.

  34. my favorite by scrytch · · Score: 2, Insightful

    Clean syntax. Not one that forces me to lean on my shift key and decorate my code with punctuation characters. The "noise" gets in my way so much that I can't even stand to program in perl anymore. I just can't take syntax like sub foo { dostuff @{$blah->{woof}}; etc... } anymore. Semicolons drive me bats.

    Python's ok. Tcl is closer to the ideal syntax, but oy what a feature poor language. Lisp's really nice. Forth would be about perfect, but it makes you work at such a low level most of the time (fact is, most people just don't build it up that much) that your code looks noisier than perl, more like APL even.

    Of course I like modern features, like automatic memory management, structured exceptions, first class functions, pattern matching, currying, asynchronous execution, concurrency, and so on. But I just can't express concepts well in a language that makes me clad every expression in so much syntactic scaffolding.

    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
    1. Re:my favorite by scrytch · · Score: 1

      Incidentally, Haskell is probably my favorite in terms of clean syntax and language power. It just requires a PhD to manage to write anything more complex than "Hello World". The compiler's speed is also best described as "geological".

      Ocaml is much more "real world" (you can even have variables (*gasp*)!) , but ocaml is full of syntax warts, unhelpful compiler feedback, a module system that's *supposed* to be the bees knees but looks suspiciously instead like plain old namespaces of static methods, and weird restrictions like overzealous monomorphism restrictions and lack of ad hoc polymorphism. It's that last one that just keeps frustrating me every time I want to pick up Ocaml.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    2. Re:my favorite by lukesky · · Score: 1

      Haskell code can look absolutely beatifull. Just look at this short qsort algorithm. I don't know of any other language where you can write an algorithm this simple.

      qsort [] = []
      qsort (x:xs) = qsort [y | y = x]

      --
      -- look sir droids...
    3. Re:my favorite by lukesky · · Score: 1

      Sorry, I should have used the preview button. The code got screwed up. Here is the real code:

      qsort [] = []
      qsort (x:xs) = qsort [y | y <- xs, y < x] ++ [x] ++
      qsort [y | y <- xs, y >= x]

      --
      -- look sir droids...
    4. Re:my favorite by tigersha · · Score: 1

      And inefficient. That code sorts a list, not an array and QS is not very good at that.

      --
      The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
    5. Re:my favorite by Fahrenheit+450 · · Score: 1
      I don't know... the OCaml code isn't much less elegant
      let rec qsort l =
      match l with
      [] -> []
      | h::t -> let lt,ge = List.partition ((>) h) t in
      (qsort lt) @ (h::(qsort ge));;
      Disclaimer: Yes, we all know it's innefficient, and subject to pathalogical behavior, etc... Still, it's pretty and it gets the job done. Of course, in the real world, we'd use List.sort to sort our lists, or Array.sort (or Array.fast_sort) to sort our arrays.
      --
      -30-
    6. Re:my favorite by scrytch · · Score: 1

      > Of course, in the real world, we'd use List.sort to sort our lists, or Array.sort (or Array.fast_sort) to sort our arrays.

      Or MyArray.sort to sort MyArrays. Or MyOtherContainer.sort to sort MyOthercontainer ...

      This is a functional language? Where is the polymorphism? This is precisely what my complaint about ocaml's module system is about -- it looks like nothing but namespaces. I don't ask for Haskell type families and abstractions of lists all the way down to MonadPlus; I do ask that I can define a bloody "sort" function that can take anything that implements the collection with items that support comparison! Even C++ manages to do this.

      Oh I also ask that I can have C types like unsigned 32 bit ints without having to use a separate module and my own different set of operators. So maybe I do want type families...

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    7. Re:my favorite by Fahrenheit+450 · · Score: 1
      I don't ask for Haskell type families and abstractions of lists all the way down to MonadPlus; I do ask that I can define a bloody "sort" function that can take anything that implements the collection with items that support comparison! Even C++ manages to do this.

      While at first blush, that sounds like a good idea, from my viewpoint I don't really see how useful or wise that really is. First of all, you could do such a thing with a little bit of work by first wrapping at least the List and Array modules up as objects (something I believe has already been done and is available at the OCaml humps) -- I suppose you might want to do the String and Buffer modules as well, but none of the other standard modules make any sense in terms of sorting. Then you can just define

      let sort o = o#sort
      and be done with it. Now you can sort anything, so long as it's an object of type
      < sort : 'a; .. > as 'a
      Or perhaps it's even better to do something like
      let sort (a : 'a) : 'a =
      let l = a#to_list in
      let l' = List.sort compare l in
      a#of_list l';;
      Which would work on any object of type
      < of_list : 'b list -> 'a; to_list : 'b list; .. > as 'a
      It's not really what you're asking for, and of course you have to make all of your new data structures objects of the same type, but it's got the same flavor (you can also do a similar thing with type constructors and pattern matching, but it's just as much of a pain in the ass).

      The biggest problem I see with a fully generic sort is that it really just doesn't make sense. Arrays and lists are not the same things. For one thing, lists are immutable structures, arrays are not -- therefore, if you define a fully generic sort that works on both arrays and lists, you are now kept from using methods that sort arrays in place (unless you're willing to do the horribly inefficient task of tearing down and rebuilding the list every time you want to modify a value to emulate sorting in place). So now you need to define two functions: one for sorting in place (which can only be used with certain classes of types) and one for sorting externally. And of course certain data structures are more efficient to sort using "method A" than others, blah, blah, blah... (DISCLAIMER: I am not Joe Type-theory, so there is likely a better line of reasoning behind this behavior of OCaml -- go ask someone like Xavier Leroy or Benjamin Pierce if you really care.)

      All of this may still be possible to graft onto OCaml (see the work that was being done on GCaml, but I only see a small portion of that really being useful to me. Apparently YMDV, and that's cool...

      --
      -30-
    8. Re:my favorite by scrytch · · Score: 1

      > While at first blush, that sounds like a good idea, from my viewpoint I don't really see how useful or wise that really is

      I think there's mountains enough of literature, on generic programming, to say nothing of implementations, without me having to justify why I want it.

      > For one thing, lists are immutable structures, arrays are not -- therefore, if you define a fully generic sort that works on both arrays and lists, you are now kept from using methods that sort arrays in place

      In C++, one would merely specialize a template or simply overload a function to a more specific type, as you would also do in Dylan or CLOS. In Haskell, you could subclass the type family.

      Presumably in Ocaml, you'd override the sort method on a subclass. Seems I have to use objects to get pervasive polymorphism in Ocaml ... something I wouldn't mind, but for the fact that objects come with their own strange set of type restrictions. It's like two languages fighting each other inside Ocaml -- I'd just like one of them to win at long last.

      Module functors are also supposed to address the issue, but I'm still searching for any documentation of how.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    9. Re:my favorite by mburns · · Score: 1

      What the heck is missing from Tcl/Tk? I do not miss explicit memory allocation, object encapsulation, checking of type declarations, or structs. A standard single-inheritance object extension is available.

      I did sit down for two days to write an extension to concatenate namespaces as freely as concatenating strings (and that capability had already been written elsewhere). And, I would write computational physics in Fortran, anyway.

      Let me praise the uniquely clever shimmering variable types, communications access to hierarchies of processes, and the uplevel command to allow safe run-time macros.

      --
      Michael J. Burns
    10. Re:my favorite by Fahrenheit+450 · · Score: 1
      I think there's mountains enough of literature, on generic programming, to say nothing of implementations, without me having to justify why I want it.

      Like I said above, that's fine. I find generics tend to lead to sloppier and more confusing code at the expense of saving a couple of keystrokes -- you like 'em for whatever reasons you like 'em for. As a wise man once sang, it takes diff'rent strokes to move the world...

      Presumably in Ocaml, you'd override the sort method on a subclass. Seems I have to use objects to get pervasive polymorphism in Ocaml ... something I wouldn't mind, but for the fact that objects come with their own strange set of type restrictions. It's like two languages fighting each other inside Ocaml -- I'd just like one of them to win at long last.

      Well yes and no. You're still not getting ad hoc polymorphism. The sort function outlined in my earlier post is still parametric polymorphic with type

      (< of_list : 'b list -> 'a; to_list : 'b list; .. > as 'a) -> 'a
      But it feels more like the ad hoc polymorphism you're looking for... And like I said above, you can also do it with type constructors. For example:
      type 'a sortable_container =
      Array of 'a array
      | List of 'a list
      | String of string;;

      let sort cmp (c : 'a sortable_container) =
      match c with
      Array a -> Array.sort cmp a; Array a
      | List l -> List (List.sort cmp l)
      | String s -> failwith "Haven't implemented string sort yet...";;

      let a = Array [| 10; 3; 5; 1; 4; 7|];;
      let l = List [ 10; 3; 5; 1; 4; 7];;
      let b = sort compare a;;
      let m = sort compare l;;

      val a : int sortable_container = Array [|10; 3; 5; 1; 4; 7|]
      # val l : int sortable_container = List [10; 3; 5; 1; 4; 7]
      # val b : int sortable_container = Array [|1; 3; 4; 5; 7; 10|]
      # val m : int sortable_container = List [1; 3; 4; 5; 7; 10]
      The big difference here is that you need to rewrite both the type sortable_container and the sort function every time you add a new sortable structure, whereas with the object approach you just need to be sure your structure has the appropriate methods.

      Module functors are also supposed to address the issue, but I'm still searching for any documentation of how.

      I'm not sure how functors would help you out here either (have you tried asking on the OCaml mailing list there are some serious OCaml gurus there). Functors are just modules parameterized over module types, so you could use one to build, say, a sortable data structure out of one that has no sort function yet, but is a subtype of some other module, but then you would have to do something like:

      module SortableDS = Sorting(UnsortableDS);;

      let sds = SortableDS.some_initialization_function;;
      let ssds = SortableDS.sort sds;;
      So you're back to where you started with the Lists and Arrays (though this would allow you to standardize the interrface to the sort function). But again, if you really want to know the answer, ask on the OCaml mailing list.
      --
      -30-
  35. Perl's taint mode by babbage · · Score: 4, Interesting
    In the current issue of ACM Queue, Marcus Ranum makes an interesting case for Perl's taint mode in his article Security: The root of the problem -- Why is it we can't seem to produce secure, high-quality code?:
    Right now, the state of the art in software security is to pass your code through some kind of static source-code analyzer such as ITS4 or Fortify that looks for dangerous practices and known bugs. That's a great start, and, according to my friend Gary McGraw--chief technology officer of Cigital and author of several books on software security--who works with the stuff, it catches a significant number of potential security problems. But, as you can see, the compiler already knows a lot of what it needs to in order to make a good stab at determining what is being done wrong.

    One really neat concept is embodied in the Perl programming language--tainting. The idea of tainting is that the interpreter tracks the source of data and turns off dangerous operations if they are called directly as a result of user input. For example, when you're running a Perl script in taint mode, it turns on a lot of error checking before passing user-provided data to certain system calls. When you try to open a file for write using a filename that is tainted data, it checks to make sure the directory tree ownerships for the target directory are correct and that the filename doesn't contain "../" path expansions. In other words, the runtime environment tracks not just the type and value of the data but also its origin. You can imagine how nice this capability can be for writing server-side code or captive applications.

    Unfortunately, few programmers use tainting because it imposes an extra burden on the programmer, and it's sometimes difficult to figure out a secure way to get the job done. But what if we built tainting-type capabilities right into our runtime environments for C/C++? A simple high-value approach might be to modify I/O routines (read/write) to determine if they are connected to a socket from a remote system, and to do some basic checks on data coming across it, such as checking to see if the stack is altered across calls to certain functions following I/O.

    Ranum is citing this as an example of a way that existing tools -- such as GCC -- could be enhanced in such a way that programmers using currently popular languages (C/C++) would have a better security safety net without having to be retrained in practices (like checking for buffer overflows) that while obvious are still under-utilized in most software. The whole article is interesting reading, but this remark about Perl's taint mode seems like one of the best concrete examples of a modern protective language feature.

    1. Re:Perl's taint mode by Anonymous Coward · · Score: 0
      Why don't you use splint to do statical analysis whether tainting is handled correctly?

      splint allows you to define attribute for taintedness and describe how functions behave in respect to that attribute - a bit like in C you can use 'const' attribute.

  36. To the Forth degree. by Anonymous Coward · · Score: 0

    Forth is also powerful if low level. Basically build a language from the ground up.

    For the high-end Smalltalk and Scheme.

  37. True 64-bit Environment w/ Strong Primitive Typing by mosel-saar-ruwer · · Score: 2, Interesting

    This is what I want:
    1) An honest-to-goodness, floor-to-ceiling, cradle-to-grave, first-to-last, night-n-day 64-bit environment, with

    2) Strongly-typed data primitives.

    For the first criteria, if, at any point, you are forced to make contact with a 32-bit environment, then the platform fails the test.

    For instance, if the platform requires you to use either Java or SQL, then it fails.

    SQL fails because it is essentially an ASCII-based language that has almost no sense of primitive data types whatsoever, and its only undefined binary type, the binary BLOB, maxes out at 2^32 = 4 Billion bytes [so much for high-quality MPEGs of, e.g., Gone With The Wind].

    Java fails because, as recently as the Java 1.5.x Beta, it cannot take long ints as array indices. For instance, the following will not even "compile" [i.e. "javac," whatever that is] under the Java 1.5.x Beta:

    public class SixtyFourBit
    {
    public static void main (String args[])
    {
    long theLong = 1;
    theLong theLong += 1;
    System.out.println("theLong = " + theLong);

    double [] theDoubleArray = new double[theLong];
    }
    }

    So your "middleware" for this hypothetical 64-bit platform is forbidden to touch either SQL or Java.

    As for the strong data typing, I want the environment to be natively aware of

    A) IEEE 96-bit Extended Doubles
    B) IEEE 128-bit Extended Doubles
    C) [Bonus for Extra Credit] LabVIEW 128-bit TIMESTAMPs
    According to Professor Kahan, Matlab has [or has had] some serious problems here:
    http://www.cs.berkeley.edu/~wkahan/MxMulEps.pdf
    PDF DOCUMENT
    So: Any takers?
  38. Lameness Filter - Java Correction by mosel-saar-ruwer · · Score: 2, Informative

    The java code should have read as follows [I didn't notice that the shift operator had been caught by the /. HTML filter]:
    public class SixtyFourBit
    {
    public static void main (String args[])
    {
    long theLong = 1;
    theLong <<= 32;
    theLong += 1;
    System.out.println("theLong = " + theLong);

    double [] theDoubleArray = new double[theLong];
    }
    }

  39. unification as in prolog by egott · · Score: 2, Interesting

    Languages without "real" unification feel unexpressive or too low level. Whenever I program in something other than prolog (which is most of the time) I miss it.

    Example: [foo(A,x)|B] = [foo([p,q],x),C,d,e].
    which implies that A = [p,q], B = [C,d,e], and C remains unconstrained.

    --
    There are 10 kinds of people: Those that understand ternary; those that don't; and those that don't care.
    1. Re:unification as in prolog by nado · · Score: 1

      Hey man, just curious... Do you write prolog for your job? I like Prolog, but erm... it isn't used much.

  40. lambdas! by Hubert_Shrump · · Score: 1

    for zope-related crap (when i'm in the slave pit, not doing cool stuff) lambdas whip ass.

    you can stuff functions into session variables - how's that for obtuse!

    --
    Keep your packets off my GNU/Girlfriend!
  41. enumerated set based operations by omibus · · Score: 1

    And no, C based languages dont have them. But Delphi/Pascal does.

    Then you can do things like
    if (var in set) then
    begin

    end;

    Then you can use + and - to add and remove items from the set.

    --
    Bad User. No biscuit!
    1. Re:enumerated set based operations by polveroj · · Score: 1

      You can do that in C++ with operator overloading if you're willing to give up the "in" keyword.

    2. Re:enumerated set based operations by sir99 · · Score: 1

      If you really wanted, you could #define in <= for example, where <= would be your inclusion operator.

      --
      The ocean parts and the meteors come down
      Laid out in amber, baby.
  42. Multiple [& Possibly Overlapping] Instances? by mosel-saar-ruwer · · Score: 1

    A nice example is a generic "find" function

    Remember the Swedish rock group ABBA? How many instances of the substring ABBA occur in the following string [and what should your generic "find" function have as a return value]?

    ABBABBA
    Extra Credit: Tell me what a generic "replace" function should do when told to replace "ABBA" with "The Bee Gees".

    PS: I learned just the other night that ABBA soloist Anni-Frid Lyngstad was the product of Nazi Aryan eugenics experiment [dubbed "the Lebensborn"].

    I excrement you not:

    http://www.wordiq.com/definition/Nazi_children


  43. emacs solves that problem by mkcmkc · · Score: 2, Informative
    I use emacs, so moving blocks around with proper indentation is quite trivial. Even if I had to edit with Notepad, though, it'd be a small price to pay for the readability.

    Mike

    --
    "Not an actor, but he plays one on TV."
  44. Re:Speed and RAM by chromatic · · Score: 2, Insightful
    I deliberately avoid use of $_ because I find it a very confusing concept

    How ironic that you used the English cognate a mere four words later!

  45. Re:True 64-bit Environment w/ Strong Primitive Typ by Jordy · · Score: 1

    Huh. How odd. C/C++ can do this just fine. (Well, C++ with C99 support makes it easier).

    #include <stdint.h>

    int main() {
    int64_t theLong = 1;
    theLong = 32;
    theLong += 1;

    double *theDoubleArray = new double[theLong]; ...
    delete[] theDoubleArray;
    return 0;
    }

    The ABI guys are still trying to figure out how to map all the double sizes. Right now, sizeof(long double) on my x86 machine gives me 12 bytes 96 bit. There is also talk of making a "long long double" of 16 bytes. Sooner or later they'll figure it out.

    In C++ you could always create a class and overload all the operators to create a custom 128-bit type that acts just like a native type and is strong typed.

    Then C99 gives you native complex types, but that's another story.

    --
    The world is neither black nor white nor good nor evil, only many shades of CowboyNeal.
  46. You can simulate it in perl by bill_mcgonigle · · Score: 2, Interesting

    You could do this in perl if you wanted to. For instance, you can code perl in Latin. It's done using the Filter::Util::Call module, which lets you preprocess your perl code. Read Damian Conway's discussion about it. He gives a simple example using Klingon keywords and talks about implementing a Switch function in perl.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    1. Re:You can simulate it in perl by Dr.+Weird · · Score: 1
      Thanks. This is very interesting.

      Do you think this would be easily extensible to graphical programs? What about automatically "expanding" perl's special variables?

    2. Re:You can simulate it in perl by bill_mcgonigle · · Score: 1

      Do you think this would be easily extensible to graphical programs?

      Not sure where you're going with that, but if you can get the "language" into a perl data structure you should be good to go.

      What about automatically "expanding" perl's special variables?

      I think you want use English;.

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    3. Re:You can simulate it in perl by belg4mit · · Score: 1

      Yes, and in Perl 6 you will be able to do it.
      Perl 6 lets you write your own grammar.

      --
      Were that I say, pancakes?
    4. Re:You can simulate it in perl by Anonymous Coward · · Score: 0

      Yes, and in Perl 6 you will be able to do it.
      Perl 6 lets you write your own grammar.


      How revolutionary. It's not like other languages have had this feature for years now.

      Consider OCaml, for example, which comes with two syntax styles out of the box (and can translate between them at will), and also permits its entire grammar to be modified or transformed almost arbitrarily.

  47. .NET CLR by L3WKW4RM · · Score: 1
    But what if I prefer my "blocks" to be started and ended by brackets instead of braces. Better yet, what if I am tired of typing these and would like indentation to control this. Or whatever -- start end commands, if you like. The point is that these are minor sytactic idiosyncracies, and we all have preferences. Why not store the code in an underlying format (XML would be okay, were it not for the bulk of it)? As long as there is a one-to-one correspondence between all possible representations, you could view it however you want.
    snip...
    In short: why isn't this done? It seems like a spectacular step in unifying programming languages a bit, and letting each user tailor his preferences while maintaining compatibility. As long as there was simple one-to-one correspondence, the translation from physical representation to underlying code and back would be quick and fairly easy to handle. Are there any modern projects which attempt this? Or *any* which attempt it with some success?

    You just described the .NET Common Language Runtime. Lots of different languages that compile to the same bytecode representation.

    1. Re:.NET CLR by Dr.+Weird · · Score: 1
      I apologize for not knowing more about .NET. From what I had understood, .NET had a few, hard-coded languages compiled to the same bytecode (e.g., J#, C#, C++, VisualBasic).

      I am interested in having fully flexible syntax, instead of just a few hard-coded options. My favorite example for somewhat extreme flexibility (aside from graphical programs) is being able to use perl's special variables, but basically as macros. They might be hardcoded in the underlying language in "expanded form." (Or conversely, they might be stored as macros in the underlying language, but abbreviated in the representation if the user desired.) How flexible is .NET? Seemingly, though, this is a step in the right direction. Just curious: how open is .NET and how much is included in Mono? (Also, as I mentioned, I wouldn't mind snookering a few language features in with this idea, as well.)

    2. Re:.NET CLR by johnnyb · · Score: 1

      Not quite. What they were wanting is code that could be displayed in whatever fashion the user wanted. If they liked braces and you liked indentation, YOU could code in indentation, and when I viewed YOUR code, it would have braces instead.

      The CLR allows multiple languages on the same runtime, but I can't view your VB code as C#.

    3. Re:.NET CLR by Frizzle+Fry · · Score: 1
      The CLR allows multiple languages on the same runtime, but I can't view your VB code as C#.

      This might be possible though, even though it doesn't exist now. I know that there are reverse compilers that can turn java bytecode into reasonable java, so I wouldn't be surprised if someone could write one that would turn .net bytecode into vb or c#.
      --
      I'd rather be lucky than good.
    4. Re:.NET CLR by johnnyb · · Score: 1

      Except that when compiling, all of your labels are gone (like local variable names, for example), making this not as useful as it might seem.

    5. Re:.NET CLR by the+quick+brown+fox · · Score: 1
      Reflector does an amazing job and lets you decompile into VB.NET, C#, or Delphi (I believe). No serious .NET programmer should be without this tool, as unlike Java, the .NET framework class libraries do not come with source code.

      You do lose local variable names, but method parameter names and field names stay intact.

    6. Re:.NET CLR by Lagamorph · · Score: 1

      He didn't really. He's not talking about multiple (well defined) languages compiling to a common intermediate language, he's talking about a "language" that would drive a parser-writer insane. .NET is nice because you can choose the language you prefer to write in and still use the same framework class library, but the languages have to be well-defined in order for the code to parse properly. This open-ended approach would be a parsing nightmare.

      -Lagamorph

    7. Re:.NET CLR by Frizzle+Fry · · Score: 1

      I assumed that for .net bytecode, there was some equivalent of the .pdb symbol files we use for native dll's, which contain all of the local variable names, etc. (or at least for whatever wasn't optimized away by the compiler). If you had these for your .net class, you would be all set. Do they exist? Obviously, if someone didn't want you figuring out how their code works they wouldn't givey you this (and would probably use Dotfuscator from VS, or somesuch), but if the assumption is that you are translating code of someone you know from vb to c# or whatever, then you would presumably have the symbols.

      --
      I'd rather be lucky than good.
  48. Re:True 64-bit Environment w/ Strong Primitive Typ by mosel-saar-ruwer · · Score: 1

    Huh. How odd. C/C++ can do this just fine...

    Does "C++" have a tape backup package? [As in Seagate-Veritas Backup Exec? Or CA-Cheyenne ARCserve?]

    Does "C++" have seamless background mirroring to a failsafe mirror server? [Preferably in a peer-to-peer relationship, but Master-Slave will do in a pinch.]

    Does "C++" distribute loads across multiple redundant servers?

    Does "C++" have a querying capability? [I.e. can C++ "query" itself the way a relation database can "query" itself?]

    Does "C++" have data transfer protocols? With encryption?

    Can "C++" authenticate against something like Novell Directory Services, or Microsoft Active Directory?

    Or do I have to write all this stuff by hand?

    Dude, I want the whole nine yards, but, to get it, I practically have to re-invent a multibillion dollar company like Oracle, or Informix.

    Surely there's somebody out there with prepackaged database product that's truly 64-bit and that has native support for strongly typed primitives!?!

  49. Dreamed-of feature-Flower power. by Anonymous Coward · · Score: 0

    Or a "genetic" high-level[1] language were you build a basic skeleton of the problem (constraints as it were), and have it evolve to the optimum design.

    [1] Borrowing from AI, Neural, GA, and Fuzzy to make this happen.

  50. gcc is more fun by r00t · · Score: 1

    The computed goto is great.

    void *vp;
    some_label:
    vp = & // the unary && operator
    goto *(vp);

    Oh yeah... fill a jump table with pointers and
    you can do some pretty cool stuff.

    Let's not forget __asm__ with automatic register
    assignment, the ability to place a variable into
    a specific section of the executable, the ability
    to associate a variable with a specific register,
    the __builtin_expect and __builtin_constant_p
    builtins... gcc kicks ass.

    1. Re:gcc is more fun by Smallpond · · Score: 1
      The real computed goto is:
      GOTO (10, 20, 30, 40), J
      Just check any Fortran reference manual. My other favorite is the PowerPC EIEIO instruction.
    2. Re:gcc is more fun by bdhall1313 · · Score: 1

      Can't forget about COBOL's version:

      GOTO PROC1, PROC2, PROC3 DEPENDING ON VAL1.

      Or writing statements like:

      INSPECT LINEIN REPLACING GARBAGE BY VALID-DATA.

      (I hate COBOL)

    3. Re:gcc is more fun by Nutria · · Score: 1
      GOTO PROC1, PROC2, PROC3 DEPENDING ON VAL1.

      There's also
      PERFORM .... DEPENDING ON
      (I like COBOL. I hate clever C programming.)
      --
      "I don't know, therefore Aliens" Wafflebox1
    4. Re:gcc is more fun by tambo · · Score: 1
      Oh yeah... fill a jump table with pointers and you can do some pretty cool stuff.

      Sure... like crash your box, over and over again.

      This code is incredibly useful - but it's also incredibly fragile. Setting your program counter to random addresses is like closing your eyes while driving and making a blind left turn. A small miscalculation means the difference between Fourth Avenue and the tree next to Fourth Avenue.

      This is the single greatest reason why previous generations of software sucked: pointers are unusably fragile. This is why they're damn near nonexistent in modern programming. Of course, you're still using them a lot (with things like "ref" and "in" parameters), but it's all heavily supervised.

      But, you can still get this functionality, though - even with managed code - through reflection. That is, just build an array (or other container) out of Method objects based on the same delegate/signature/parameter list, and invoke whichever method you want. The only real difference is that the interpreter running your code (Java's VM or Microsoft's CLR) doesn't just make a leap of faith based on the contents of an integer; it understands that you're accessing a method pointer and asking to invoke it. This understanding makes safety checking possible, so that if you're wrong, the interpreter can just throw an exception rather than executing garbage memory.

      And this raises me to my point: Reflection rocks. I nominate this as one of the most extraordinary features of modern programming. Your code can peer at a generic object, and poke and prod it at will. Microsoft's "Reflection Emit" stuff is even better: you have methods writing other methods. This was possible before, of course, but it was always hacky/fragile; reflection makes this explicit, legal, safe, and understandable.

      - David Stein

      --
      Computer over. Virus = very yes.
  51. easy by Pierre · · Score: 1

    4.321**2 instead of pow(4.321,2)

    1. Re:easy by Pierre · · Score: 1

      this is the real reason that everybody secretly yearns to program in FORTRAN

    2. Re:easy by Anonymous Coward · · Score: 0

      Too bad the C compiler reads this as 4.321 * (*2) and says wtf! You can't dereference 2!!!! :)

  52. Slashdot mangles stuff, WTF? by r00t · · Score: 1

    I didn't ask for HTML. I chose plain text and I
    damn well expect Slashdot to accept full ASCII.
    I'll try "Code" now. Grrr.

    void *vp;
    some_label:
    vp = &&some_label; // the unary && operator
    goto *(vp);

  53. Cross-platform. by Anonymous Coward · · Score: 0

    The very best features of languages are those that allow me to effortlessly write code that runs on as many different platforms as possible. In today's world, there should be absolutely no reason to be tied down to a single platform.

    Python absolutely excels at cross-platform stuff.. and while C/C++ is fairly good, there are still compatibility problems between different implementations of the language that follow different standards.

    And if you want to do anything GUI, you need a good cross-platform windowing library like wxWidgets.

  54. automatic arrays = hashes = 'objects' by Kz · · Score: 1

    I like C-like syntax, but for easy prototyping, automatic arrays and hashes are sooo neat! much nicer than garbage collection IMHO. perl makes them easy, once you get over the $,%,@ line noise

    my main problem with that is (besides perl's ugly syntax) that arrays and hashes are different things. that alone makes me use PHP more often than perl.

    but in PHP I have choose all the time between the array/hash thing and the 'object' thing. I'm sure that internally the objects are managed with hashes, but the syntax make them diferent objects (in extreme cases i have to convert one to the other and back again).

    that's what's turning me towards Pike... arrays are hashes, and object-like syntax is just syntactic sugar over the hash! (and 'splices' are nice too)

    so, for me now is Pike first, then PHP, and if i have to recurse to Perl... then i might try C++ (with STL), just because i find it far more readable!

    --
    -Kz-
  55. reflection by agwis · · Score: 2, Interesting

    I'm surprised I haven't seen this listed yet. In java I use reflection often and at the cost of a little processing overhead, it allows me to add remove fields from a database with very little code change.

    I generally like to use struts in web applications and find I often have to tranfer values from an action form to a java bean and vice versa. Using the org.apache.commons.beanutils package it is incredibly easy to do this, and beanutils uses reflection to do this with.

    My second choice would be good regexp support. IMO, Perl is the best at this and I also like the Java regexp package in 1.4 as well.

  56. Re:True 64-bit Environment w/ Strong Primitive Typ by Anonymous Coward · · Score: 0

    Umm... you're not going to find a database with all of these features. You might be able to find a combination of programs from different vendors (Oracle, Veritas, Novell) and some libraries that will let you interface with the database in a reasonable manner (Rogue Wave, OCI, whatever).

    If I'm going to get a database, I want one that focuses on being a database... not something that is a "backup-enabled mirroring RAID-based load sharing encrypted connection AD-integrated solution". That's not a product, that's 10 pounds of overblown marketing drivel stuffed into a 5-pound bag.

  57. But why do I have to re-invent the wheel??? by mosel-saar-ruwer · · Score: 1

    If I'm going to get a database, I want one that focuses on being a database... not something that is a "backup-enabled mirroring RAID-based load sharing encrypted connection AD-integrated solution". That's not a product, that's 10 pounds of overblown marketing drivel stuffed into a 5-pound bag.

    But that's why Oracle [or DB2, or Informix, or SQL Server, or whatever] costs, oh, $50,000, and a C++ compiler costs, oh, $500.

    You can be a cheapskate, buy your own C++ compiler, and write all that stuff from scratch, or you can ante up, purchase the pre-packaged product from Oracle, and save the twenty years of your life that you would have spent writing it from scratch.

    I just want something like "Oracle" [or "DB2" or "SQLServer" or whatever] that's truly 64-bit, i.e. that's got at least ONE interface that's truly 64-bit, not a bunch of 32-bit bullshit [like SQL-92, or Java 1.5.x] masquerading as 64-bit.

    And strong typing of primitives would be really swell, too. [Yes, we do scientific computing out here in flyover country!!!]

  58. ksh by mirabilos · · Score: 1

    http://www.oreilly.com/catalog/korn2/index.html

    Everything I learnt from it, and all these useful
    features like

    if [[ $foo != @(From\ )* ]]; then ...

    set -A arrayname -- $(head -1 file)
    let i=0
    while (( i "
    let i+=1
    done

    and more stuff like that.

    If you want to update your system to have this
    kind of powerful shell too, read
    http://wiki.mirbsd.de/MirbsdKsh
    and, for prompt lovers who don't like the
    simplistic '$ ' PS1,
    https://mirbsd.bsdadvocacy.org:8890/cvs.cgi/ src/et c/profile

    gl hf

    --
    My Karma isn't excellent, damn it! (And /. still does not get UTF-8 right in 2012. Wow.)
    1. Re:ksh by mirabilos · · Score: 1

      Oups, mangled.

      Should have been

      while (( i < ${#arrayname[*]} )); do
      print "$i = <${arrayname[i]}>"
      let i+=1

      I've just seen GNU bash has "shopt -s extglob",
      but not the (supposedly more portable than
      echo) print builtin... gah.

      Also, check out coroutines in the ksh book
      or manpage, they're REALLY powerful.

      --
      My Karma isn't excellent, damn it! (And /. still does not get UTF-8 right in 2012. Wow.)
  59. Minimalism. by Pogue+Mahone · · Score: 1
    My personal favourite is the while-loop. With the while loop I can construct for-loops, do-while-loops and even if and if-else constructs.

    Only slightly ;-)

    --
    Every bloody emperor has his hand up history's skirt [Peter Hammill/VdGG]
  60. Re:Easy. T-Shirt (C): by mirabilos · · Score: 1

    Yea, C rocks - after all, it's portable assembly
    language with some syntactic sugar (for, while).

    I miss a goto in ksh, though.

    --
    My Karma isn't excellent, damn it! (And /. still does not get UTF-8 right in 2012. Wow.)
  61. #1 Garbage collection by Simon · · Score: 2, Interesting

    #1 Garbage collection. a.k.a. automatic memory management. Not very sexy, but by far the single biggest productivity boosting feature of any language. I hate housework. It is just a waste of time.

    #2 No pointers, no buffer overruns, no memory corruption. Related to the first point. Memory corruption is just so hard track down. You can keep your pointers, I've already got an OS, I don't need to write my own. :)

    After spending years programing asm and C on a platform with no memory protection (Amiga), and then later C++, I think I've paid my dues here.

    #3 Stack traces. Not a language feature per se, but it takes a lot of the drudge work out of debugging.

    #4 Python's 'for' loop for iterating over the contents of a list or array:

    for thing in myarray:
    mutate(thing)

    It is easy to remember, easy to type, much easier to read, and you use it _all_ the time. Compared to the same code in C, C++ or Java, it is a godsend.

    #5 Dictionaries, a.k.a. associative arrays. It just makes a lot of problems much much simplier and faster to solve. Sure, most other languages have dictionaries available as a class, but when they are seamlessly built into the language you use them as easily as any other primitive datatype.

    --
    Simon

  62. You must be very smart. by TheLink · · Score: 1

    If I did that, no one would be able to help me if I get something wrong - e.g. I screwed up in my custom syntax or metadata or my code, and I'm not sure where.

    And it would be harder for me to learn from other programmers programs and integrate their code.

    Ultrageniuses and Uber Programmers are free to write their whole entire universe of code, but I bet crappy programmers like me will still stick to using what tons of people are using, and reusing other people's work (e.g. CPAN) and learning from _their_mistakes_.

    Life is too short to only learn from your own mistakes.

    --
    1. Re:You must be very smart. by Dr.+Weird · · Score: 1
      You're hitting at a really deep point. Learning from others' mistakes will be impossible if the mistakes in one representation translate to mistakes in a different representation in a way such that mistakes made in one representation would not typically be made in another.

      Of course, this could be support for this idea, as a programmer learns a few representations of the same code and can switch between them, he/she can see the mistakes obvious in some representations.

      Now, you can still give your code to a buddy and they may fix your problem in their own representation and hand it back to you in your own representation, but if the mistakes are so un-obvious in the representation they have set up, no luck. So probably, programmer's using drastic changes in syntax representation would have to learn a couple very different representations to collaborate effectively. But these are the programmer's who would probably find no problem in this. And many would use it just for syntactic sugar, and that would be fine. I think there would be little/no problem with sharing and learning from mistakes across representations as long as indentation/braces/etc. were the only things being changed.

      But if obvious mistakes in one representation translate to obscure ones in another, things could be difficult in collaborations if people are using very drastic changes . Thanks for pointing this out -- I had considered static code, and code in development, but not necessarily the value of mistakes in code and the necessity to share them for development. One point may be to not allow drastic enough changes for this to become an issue (though in fact it may be a virtue to allow that diversity of representations). Again, thanks.

    2. Re:You must be very smart. by TheLink · · Score: 1

      I regularly deal with things that go wrong, so it's not such a deep point :). It's not just the code that could go wrong- there are so many things that could go wrong and I'm sure they will.

      For example, say I create a "syntax configuration file" or whatever that sets up my representation. But I screw up, and though in my fallible _mind_ I think the syntax should be ABC, the syntax configuration file does BAC in some cases. Whoopee - is it a bug in my syntax conf file or a bug in my program, or a bug in the open source program parsing the syntax conf file and generating the representation, or they're all buggy, it's a bug in somewhere else!

      Now who's going to be the kind person who _can_ and _will_ help me? Maybe my chosen representation is really crappy according to everyone else! Next thing you know, I post to a discussion group for representation recommendations and start something worse than a vi vs emacs war... ;)

      In the end, I'd probably resort to using and learning some programming genius's representation. Which brings us back to conventional programming languages and their conventional representations. Being conventional ain't so bad in the end...

      OK I'm being a bit negative, but like I said, everyday I deal with things that go wrong - (I'm in the IT security line). Often 95% of the people out there don't even notice that stuff is going wrong, or they just click OK and go on with their rose tinted lives (and they won't even REMEMBER clicking OK). Whereas I go - "whoa remote attacker can execute arbitrary code of the attacker's choice!", or whoops "SQL injection".

      There are plenty of things that go right too, despite all the imperfections. So feel free to ignore me - it might actually work well. But you may wish to give it some more thought - no matter what there are bound to be limits in the multi representation thingy - even if they're not hard limits - you'll always end up with making some things easier to do than others. The genius is in picking the right things to make easier and the right things to make harder.

      Having infinite possibilities is nice, but often to really get anywhere you need rules and restrictions, especially if it's not just you and there are other entities involved.

      Limits are a necessary part of what makes games fun :).

      --
    3. Re:You must be very smart. by sonamchauhan · · Score: 1

      > If I did that, no one would be able to help me
      > if I get something wrong - e.g. I screwed up in my custom syntax
      > or metadata or my code, and I'm not sure where.

      Describing the same idea (eg: an algorithm) using different words (eg: a different programming language) often better exposes subtle problems with it.

      And if source can be auto-translated to different languages on the fly (NOTE: source including comments... I am not talking about de-compilation here), person A could use his knowledge of the language he is skilled in, to help person B, without the overhead of learning person B's language.

      Another advantage of this idea: not all the world's programmers speak English as their first language, yet most are _forced_ to learn it to code. This would help people code in their native language.

    4. Re:You must be very smart. by TheLink · · Score: 1

      "Describing the same idea (eg: an algorithm) using different words (eg: a different programming language) often better exposes subtle problems with it."

      What if you also make mistakes while describing? Describing something in different ways works if you're explaining an idea to someone, but does it help when you need to be precise? Scenario: in one person's representation, something is a syntax error because the chosen representation/syntax is more strict and rigid (for error detection purposes), whereas in another person's representation there may not be an analogous way to generate such an error.

      See my other post

      In order to share code and learn/fix code from others, people would also have to share their representation/translation files. People would also have to debug representation/translation files. And they may have to debug those nearly alone if they are the only ones using those representations.

      "not all the world's programmers speak English as their first language, yet most are _forced_ to learn it to code. This would help people code in their native language."

      Even though a programming language's tokens are in English does not make it English. For example: the concept of an "OR" in most programming languages means something quite different from what it does in English.

      An analogy: people could build their own network standard instead of TCP/IP and run their own networks with translations in between the two, but most people seem to have preferred to standardize (don't see many new DECNET, Banyan, IPX installations). If you use your own standard if you have problems, people can help you with the big picture problems, but you're often on your own with the details.

      --
    5. Re:You must be very smart. by sonamchauhan · · Score: 1

      > > "Describing the same idea (eg: an algorithm) using different words
      > > (eg: a different programming language) often better exposes subtle
      > > problems with it."
      > What if you also make mistakes while describing?
      That is precisely what my point is... the mistake will be auto-translated to the other language and exposed.

      Consider this Perl snippet source-translated to Java:
      :

      #the third element of the array must seed the transform
      %hash = transform(@array1[3]);


      //the third element of the array must seed the transform
      java.util.Hashtable h = transform(array1[3]);


      Since both languages start arrays from subscript zero, the Java coder tracking down a bug will knows that the third element should be really array1[2], not array1[3] - without needing to learn Perl.

    6. Re:You must be very smart. by TheLink · · Score: 1

      What you're pointing out is more a bug in the end description, not a bug in the describing.

      Bug in describing: you make a mistake so that your chosen custom representation is not quite "perl" but "almost perl. End up with a representation/syntax that's not quite what you think it is. Worse if there are bugs in the description compiler/generator and it's not what the "computer" should think it is either.

      Who is going to help you debug that? Everyone else says THEIR representation is fine (da best), and maybe you should switch to theirs instead... Back to square one.

      --
    7. Re:You must be very smart. by sonamchauhan · · Score: 1

      What you're pointing out is more a bug in the end description, not a bug in the describing.

      Its at least a bug that gets caught.

      [ I'll correct something I said: "since both languages start arrays from zero...[the bug could be corrected]". This is really not necessary - a translator could translate common elements (like arrays) even if in one language, the index started from 0, and in another, it started from 1.]

      Bug in describing: you make a mistake so that your chosen custom representation is not quite "perl" but "almost perl.

      I assume you mean a customized version of Perl. The same automated mechanisms (say, in the current Perl, or the upcoming Perl 6/Parrot architecture) that translate "almost perl" to parrot bytecode, would be used in one of the steps of translate Java source to "almost Perl" source and vice-versa.

      I am tired of the Babel-basket of languages, with existing software in one language inaccessible in another. For eg: I remember once semi-learning python because of it's excellent support for email header RFC822 parsers.

      Mono/.NET/Parrot let a class in one language access classes in other supported languages (eg: a Perl class can inherit from a C# base class). Providing source-to-source transforms would be going one step further.

  63. Very useful by TheLink · · Score: 1

    So that a remote attacker can cause a system to run arbitrary code of the attacker's choice.

    Very useful when you need to do things that the system was never designed to do.

    Whole industries and many thousands of jobs depend on such useful ideas. :).

    --
  64. how about hardly any features? by ChipMonk · · Score: 1

    For stack-based hardware, FORTH is very powerful. A tiny interpreter (even on chip-level) and screamingly fast. PostScript is similarly stack-based, but its huge base vocabulary is less than ideal for beginning programming.

    In a similar vein, I've been pondering the feasibility of a no-GP-register CPU. Low addresses (say, the first 31 words) are stored on-chip, the rest in slower memory. Data is accessed via two memory-address registers (a la the M reg in the old 8080, which turned into (HL) in the Z80) to lend itself to load-store internal implementation. 30-bit (or 62-bit) addressing, a RISC architecture, predicates all around, everything vector-able (including predication).

    Bah, I'm up too late. Brain is fuzzy.

  65. TCL's slave interpreter by macemoneta · · Score: 1

    I've found TCL's slave interpreter very useful. It allows you to execute "uncontrolled" TCL code securely, trapping/substituting/exposing whatever you want. Variables can be exposed, hidden, readonly, etc.

    In particular, I find it useful when allowing an application written in TCL to be scripted. The TCL application can remain robust and reliable, even when the user code isn't.

    --

    Can You Say Linux? I Knew That You Could.

  66. Re:Speed and RAM by TheLink · · Score: 1

    I like the $ coz I use the <<"EOT"; stuff a lot.
    e.g.
    print <<"ENDHTML";
    <html>
    <head><title>$title</title>
    </head>
    <body>
    Unquoted:<b>$blah</b><br>
    Quote d: ${\( htmlquotearray($blah) )}
    </body>
    </html>
    ENDHTML

    Witho ut the $ or other special character this would be very difficult. Not sure how you'd do that sort of thing in other languages.

    In addition to the associative arrays, I like CPAN - as you mentioned, there are plenty of experts around who produce better code, and with CPAN I get to reuse their work, thus raising the average code quality of my programs AND reducing the amount of work I do ;).

    --
  67. Re:Speed and RAM by krakrjak · · Score: 2, Informative

    Perl has a standardized documentation feature: PODs. You can embed all manner of documentation alongside your code and then see the output (much like a man page) by running 'perldoc [perl module]'. If you use classgen you get a POD skeleton in your perl modules.

    I do agree that standardized documentation built into a language is quite powerful.

  68. A neat trick that I love doing with perl by Feztaa · · Score: 1
    Forgive me if this is already mentioned, but it's a neat little perl trick that I dreamed up on my own (though I'm probably not the first).

    It's an easy way of developing a command-driven interface (which is useful if you're developing a web-app or even for limited-functionality command shells).

    So for example, the user's command is stored in the variable $cmd. We then have hash %cmds which stores all the possible commands like this:

    $cmds{foobar} = sub { print "this is the foobar command"; };
    $cmds{bazqux} = sub { print "this is the bazqux command"; };

    (defined $cmds{$cmd}) && &$cmds{$cmd};


    What that means is that we use %cmds as a look-up table of commands, looking for the command given by the user in $cmd, and if it exists in the table, it's executed, if not, nothing happens. It's secure in the sense that garbage data entered by the user is just ignored, they can only do things that we specifically allow them to do (similar to having a default-drop firewall ruleset, I suppose).

    Using the above example in the context of a website in CGI, lets say the user called the CGI as "index.cgi?cmd=foobar", well, then the anonymous subrouting $cmds{foobar} is executed, giving the user access to that page, and then if they go to "index.cgi?cmd=bazqux", then $cmds{bazqux} is executed. It's immune to buffer overflows or any trickery like that, because any command that isn't specifically defined in the hash fails the "defined" test, and nothing is executed. Even if it was executed, you'd just get a runtime error saying you can't use an undefined value as a reference to a subroutine to execute, which would translate to an HTTP500 error to the user, keeping security intact. The 'defined' test just allows you to catch the exception and print a nice page to the user explaining the command was not recognized instead of throwing the 500 error at them.
  69. Regexp operator by davegaramond · · Score: 1

    Come on, over 100 comments and nobody said regexp operator?

    I can't stand re.replace('...'), re.match('...'), etc. That's why I like Perl and Ruby, which provides with re operators such as //, m(), qr()/%r(), etc.

    Python's raw string still sucks for regex.

  70. foreach by Anonymous Coward · · Score: 0

    i typed /foreac in firefox... to no avail.

    hmmm... shirly someone would have mentioned foreach by now. and stop calling me shirly.

    then i searched for foreach. not a single (at least modded) post has mentioned it.

    any language that has a foreach or at least while () or equivalent lets you get things done quicker than you can say lickety-split.

    raw assembly also lets you get it done lickety-split. learn vector programming.

    there's a spectrum for ya.

  71. So many! by notany · · Score: 1


    Special variables, multimethods. meta-object-protocol, lisp-syntax, lisp-macros, ....

    --
    Dyslexics have more fnu.
  72. Re:Speed and RAM by jonadab · · Score: 1

    > a standardized documentation feature

    Oh, like POD (in Perl) or docstrings (in elisp)?

    --
    Cut that out, or I will ship you to Norilsk in a box.
  73. Does the CPAN count as a language feature? by jonadab · · Score: 1

    I'm in love with the CPAN. I especially like search.cpan.org -- I have a
    bookmark keyword set up in Mozilla for it, and it's the one I use most often,
    more often than the keyword for dictionary.com, probably even more often than
    the one for Google. I don't just use it to find new modules, either; I use
    it to quickly check the docs for modules I already use. Every language should
    have a mirrored public repository like the CPAN, complete with an automatic
    installer like CPAN.pm that comes standard with the language tools.

    --
    Cut that out, or I will ship you to Norilsk in a box.
    1. Re:Does the CPAN count as a language feature? by Anonymous Coward · · Score: 0

      The problem I've found with CPAN is that instead of finding one well documented, full featured robust implementation of something, there are ten versions, each with their own bugs, features and ideosyncracies.

      The idea's great, but I think something got lost in the translation ...

  74. Pascal and With operator. by rasjani · · Score: 2, Interesting

    I dont remember what the syntax actually was but when you defined a structure, you could point into its members with with.

    like if the structure had members x and y and structure was named coords you could do something like this

    var own_x;
    with coords
    begin
    x=own_x
    y=123.13
    end

    --
    yush
  75. OOP (I use Delphi) by hsoft · · Score: 1
    The magic of abstraction
    TComparable = class
    protected
    function DoCompare(aRef:TComparable):Integer;virtual;
    end;

    TStrComparable = class(TComparable)
    private
    FStr:string;
    protect ed
    function DoCompare(aRef:TComparable):Integer;override;
    pub lic
    property Str:string read FStr write FStr;
    end;

    function TStrComparable.DoCompare(aRef:TComparable):Integer ;
    begin
    if assigned(aRef) and (aRef is TStrComparable) then
    Result := CompareStr(Str,(aRef as TStrComparable).Str)
    else
    Result := 0;
    end;
    Of course, there are a lot of other cool stuff to do with Delphi and oop, but I don't have all day to write this...
    --
    perception is reality
    1. Re:OOP (I use Delphi) by 00lmz · · Score: 1

      shouldn't Comparable be an Interface instead? I think Delphi has them...

    2. Re:OOP (I use Delphi) by hsoft · · Score: 1

      Hum, yeah. However, I based myself on my own library, which has a kind of multi-virtual-fields comparison system. Thus, the virtual DoCompare of the TComparable *is* implemented in my library. Yeah, I shoulda use an interface for the example...

      --
      perception is reality
  76. To go with this... by Anonymous Coward · · Score: 0

    ... a good API and toolkit.
    I especially like Cocoa.

  77. Don't bash C++ by Chemisor · · Score: 4, Informative

    > #1 Garbage collection. a.k.a. automatic memory
    > management. Not very sexy, but by far the single
    > biggest productivity boosting feature of any
    > language. I hate housework. It is just a waste of time.

    Garbage collection does not free you from memory management. It simply converts one kind of problem into another: namely it eliminates accesses of unallocated memory, but it creates memory leaks instead. The thing is, it is not always easy to figure out when you no longer need a block of memory. That's with garbage collection it is supposed to be good practice to "free" your pointers anyway, by assigning NULL to them. Why they can't just use STL containers instead, I don't know.

    > #2 No pointers, no buffer overruns, no memory
    > corruption. Related to the first point. Memory
    > corruption is just so hard track down. You can
    > keep your pointers

    You won't have any memory corruption if you don't use arbitrary indexes to access your arrays. For example, when iterating over a container, you run your iterator from ctr.begin() to ctr.end(); no corruption possible. The other cause of memory corruption is using unverified data to directly access your arrays. That happens when you ask the user for a number and then use it to index; this is wrong in so many ways, I can't even begin to list them all. Verify your data, and you will not have any data corruption.

    > #3 Stack traces. Not a language feature per se,
    > but it takes a lot of the drudge work out of
    > debugging.

    #include
    backtrace_symbols()

    > #4 Python's 'for' loop for iterating over the
    > contents of a list or array:
    >
    > for thing in myarray:
    > mutate(thing)

    #define foreach(t,i,c) for(t i = c.begin(); i #5 Dictionaries, a.k.a. associative arrays. It
    > just makes a lot of problems much much simplier
    > and faster to solve.

    map m;

    > Sure, most other languages
    > have dictionaries available as a class, but when
    > they are seamlessly built into the language you
    > use them as easily as any other primitive '
    > datatype.

    You can use map as easily as any other primitive data type of the same category: as an array.
    m["january"] = 31;
    cout "january has " m["january"] " days" endl;

    1. Re:Don't bash C++ by Bklyn · · Score: 1

      Lots of your post was garbled due to the < being eaten as an HTML tag. This seems to be happening even in "Plain Old Text" mode.

      My interest was piqued on backtrace_symbols() however; never knew about its existence. Very nice!

      #include <execinfo.h>

      void* stack[64];
      int stacksize = backtrace (stack, sizeof (stack) / sizeof (void*));
      char** stacktrace = backtrace_symbols (stack, stacksize); /* do something with stacktrace */

      free (stacktrace);

      Very handy.

    2. Re:Don't bash C++ by Chemisor · · Score: 1

      The only part that appears to have been eaten by HTML is the foreach macro, since you have already found the execinfo header. So I'll reprint it:

      #define foreach(t,i,c) for(t i = c.begin(); i != c.end(); ++ i)
      foreach (array::iterator, i, container)
      modify (*i);

      It prevents infinite loops and buffer overruns, because the range is obtained from the container, and the increment is autogenerated. I use it all the time; it is included in the uSTL library.

  78. Don't confuse people by Chemisor · · Score: 4, Funny

    Just because you can write it that way, does not mean you should. Should you blame makers of underware for letting you put it on over your clothes? Just because Superman can do it, does not mean you should.

  79. favorite programming language feature? by confused+one · · Score: 1

    Compilers. Because coding in hex blows.

  80. Dynamic functions and object knowledge by (trb001) · · Score: 1

    One of my favorite features of PHP is the ability to define a function, then call it by dynamically constructing a string and using call_user_func. It's great, allows for reduction of code by creating functions/objects that have names that can be easily instantiated.

    Along the same lines, the fact that PHP allows you to retrieve and use object variables dynamically is wonderful ($var = "name", $obj->$var is the equivalent of $this->name). It allows for incredibly fast and robust code development. Loose type checking is always an issue in these cases, but the benefits well outweigh the downfalls.

    --trb

  81. Loads... by Tom7 · · Score: 1

    Most important features that I constantly miss in mainstream languages:

    * products (tuples)
    * sums (distinguished unions with pattern matching)
    * no 'null' pointer (use sums instead)
    * higher order functions!
    * type inference
    * parametric polymorphism
    * parametrized modules
    * static typing with type safety guarantees!

    It's worth trying a modern typed functional language like ML if you don't know what these are; there's more to the world of programming than C-like scripting languages.

  82. Perl Poetry by wbav · · Score: 1

    I mean come on, how many languages in which you can do this?

    --

    =================
    Unix is very user friendly, it's just picky about who its friends are.
  83. Syntactic simplicity? C?? by alienmole · · Score: 1

    Simple by what metric? Ever written a parser for C?

    If you want simple syntax, try Scheme or Lisp. Opinions differ on its beauty (it grows on you, though).

  84. Laugh all you want by Zork+the+Almighty · · Score: 1

    Laugh all you want, but I program mostly in the computer algebra system Maple. My favorite feature of its language is that identical objects are stored only once by the system - you effectively use pointers for everything, and it is completely transparent. There are a lot of crazy hacks you can do with this functionality, keeping in mind that it incurs no extra overhead.

    --

    In Soviet America the banks rob you!
  85. not really a "language feature" but... by dark404 · · Score: 1

    I really love javadoc, it makes life so much simpler when generating documentation.

  86. This is the best stuff to have.... by Anonymous Coward · · Score: 0

    make the language that can be inputted by voice commands and has the smarts to do what you tell it, e.g. "Give me a program that manges a database of 1 million people in c++". You'll probly have to run it on a coustom bulit computer that has as "parts" a dozen trained programers;)

  87. CLOS by arethuza · · Score: 1
    Various features of Common Lisp: CLOS (particularly multimethods and :before, :after and :around methods), the loop macro and the whole 'language that is its nown macro language thing'.

    Almost all of PostScript, which actually makes a pretty find command line language.

    'using' in c#

  88. Re:This "ask Slashdot" is a concurrent "cross-post by johnnyb · · Score: 4, Interesting

    Actually what I'm wanting to do, eventually, is write a book about great programming constructs people have probably never heard of, or don't understand well.

    My last book took me 3 years to find the spare time to finish, so I don't suspect I'll have this done anytime soon.

    I was originally going to just analyze scheme's features, but then I realized that many languages have features that need to be recognized, too. my original outline was going to be:

    * Memory Management
    * Symbolic programming - an intro to Scheme
    * Functional Programming & Functional Programming Patterns
    * Closures and higher-order functions
    * Advanced Flow Control w/ Continuations
    * Compile-Time programming 1: Macros
    * Compile-Time programming 2: Partial Evaluation
    * Compile-Time programming 3: C++ templates
    * Lazy evaluation
    * Lazy data structures

    However, if I decide to open it up to other languages, I have no idea how I'm going to organize it or even how I will decide what to include.

    Anyway, it was originally posted just to Advogato, but then I remembered that the only threads on Advogato that get any real response are flame-wars, which is sad because Advogato could be a real cool place. Then I thought "you know, this would make a good 'Ask Slashdot' as well. However, I don't expect the quality of responses on Ask Slashdot to be as good, although I expect there to be a LOT more of them.

  89. everything as an object by hal9000 · · Score: 1

    Everything-as-an-object in, for example, Ruby and Smalltalk.

    --
    Look out honey, 'cause I'm using technology; Ain't got time to make no apology
  90. My must haves... by Fahrenheit+450 · · Score: 2, Informative
    Things I've found to be invaluable to the way I program:
    • Strong typing: Much like pig and elephant DNA just don't splice, one should not be allowed to add characters to integers then divide by floats and expect a sensible result.
    • Type inference: I want a language that can figure out what I'm doing without having to specify every last detail. And I want it to be able to tell me when I'm trying to splice said pig and elephant DNA.
    • Higer order/first class/anonymous functions: makes life and coding so much nicer.
    • Pattern matching: pretty and powerful.
    • An interactive environment: why should I have to compile my whole freaking program to test one little function?
    • Paradigm neutrality: if a problem is best solved with object, let me use objects. If an algorithm is most naturally expressed functionally, gimme that. If imperative code is what I need, let me use it. If I want to mix'n'match hand me the blender
    • Native and byte-code compilation: choose between speed and portability depending on your needs
    Thank goodness there's OCaml there to provide all this for me in one happy little package...
    --
    -30-
  91. Re:Simplicity, macros, conditions, multiple dispat by Da+VinMan · · Score: 1

    Macros can completely transform the source, at compile time, but with the full power of the language. Having that ability, together with simplicity, means that it's easy to build a complete mini-language for one's manager or web designer to use on the site, and easy for them to learn it, since you can explain the syntax in 5 minutes or less, and they don't have to learn 50 built-ins to use it.

    Could you give an example of this? Every person who's ever made a living doing LISP raves about LISP in this way. I've never seen the magic here or had the necessary ah-ha moment. I've seen some really really ugly code in LISP that looks like it took about 4x longer to write than it would in VB or Java though; so it is off-putting that way.

    Thanks!

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
  92. Think about it a little more... by Da+VinMan · · Score: 1

    .NET byte code does NOT typically contain the source code within it. So, what you have is the raw IL which resembles so much assembler. On top of that, IL can be obfuscated to remove any meaningful identifiers. IF the IL does contain the source code, it's only because the IL was compiled for usage in a debug environment. And then, the IL will be the source language of the developer of the program, not the source language of your choice.

    Granted, a reverse engineering from IL to language source is possible, but it's never perfect and almost always messy.

    So, in short, IL != source code.

    Same thing applies to Java byte code, BTW.

    Feel free to prove me wrong. I'd be happy to use your product. ;+)

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
  93. Re:Speed and RAM by daviddennis · · Score: 1

    Nice point. But if it's the only word you use it's not that easy to grasp. And much of the time you don't say it at all, you imply it instead. I think you get the idea about it; if used sparingly it's fine, but if it's all you talk about it gets pretty confusing.

    Hope it helps :-).

    D

  94. Unification and Backtracking by Maljin+Jolt · · Score: 1
    Not so many coders are able to grasp mentally a declarative paradigm of logic programming.
    member(X,[X|_]).
    member(X,[_|R]):-member(X,R).
    This is 'is a member of list' predicate in prolog.

    Or another example:
    qsort[]=[]
    qsort(x:xs)=(qsort[y|y<-xs,y<x]) ++ [x] ++ (qsort[y|y<-xs,y>=x])
    This is complete quicksort algorithm written in haskell. Please compare the code above to an average implementation of quicksort in your favourite C or java library.

    --
    There you are, staring at me again.
    1. Re:Unification and Backtracking by BenjyD · · Score: 2, Insightful

      Yes, but does anyone do anything serious in standard Prolog? I found even using Eclipse's (www.icparc.ic.ac.uk/eclipse) extended Prolog, with all the extra functional features just too damn fiddly, even for something well suited to solution by Prolog-like techniques (optimal scheduling).

    2. Re:Unification and Backtracking by Maljin+Jolt · · Score: 1

      Yes, but does anyone do anything serious in standard Prolog?

      Yes, in past I did some commercial app for large data classification/consistency analysis, for cleanup before migrating between incompatible sql backends. Necessary before putting huge data into datawarehouse.

      Classifier part was worth to be a tiny expert system. Much cleaner code and more effective using prolog then SQL. Actually, my prolog solution was a winner because an SQL based project failed fatally under the weight of it's one unmanagable complexity.

      I think logic programming will make a comeback in near future, because with today's hardware it is fairly sufficient even for non-trivial logic problems ;-).

      Probably, the haskell will be the favourite before prolog

      --
      There you are, staring at me again.
  95. best language feature by divbyzero · · Score: 1

    Syntactic minimalism without sacrificing semantic richness.
    Examples would include the Lisp and Forth families.
    Anyone know of any others in the same spirit?

    --
    But my grandest creation, as history will tell,
    Was Firefrorefiddle, the Fiend of the Fell.
  96. A few favorites by scruffy · · Score: 2, Interesting
    Garbage collection

    Unrestricted integer size (e.g., Lisp bignums)

    Have persistent objects between program invocations. It's so tedious and buggy to have to write to a file when a program ends and then read it again when you start it up again.

  97. Regex as operator, and foreach by Etyenne · · Score: 1

    Regex as operator, IMHO, is God-send in Perl. Regex-as-object in Python is clunky (too many step to apply a regex), and PHP implementation as function is confusing.

    foreach() is a close second. I think Java and C# now have this operator too (unsure about Java). If I where stuck using the repetitive and redundant "for (assignation; stop condition; incrementation) { block }" construct for simple list iteration, it would make me scream.

    If you are familiar with Perl, I suggest you read "Advanced Perl Programming" by Sriram Srinivasan from O'Reilly. Reading this baffle me with the flexibility and ingenuity of this language. While I don't advocate using all these techniques (tie, closure, typeglob, etc) in production code for maintainability purpose, knowing your options is certainly a good thing.

    --
    :wq
  98. Common Lisp Macros by Anonymous Coward · · Score: 0

    With Common Lisp Macros, you get the ability to add most any feature you may want. Obviously, they work better in a CL environment with all of its other functions and capabilities. But with Macros, you can even add many of those if they weren't already present.

    Simple example is something like an OOP paradigm. Perhaps you don't like CLOS. Perhaps you like Smalltalks better. You can readily add that style of classes, methods, and objects using macros.

    High level languages are about abstraction, CL Macros let you create your own abstractions, not just the ones the language gives you.

    So, macros let me make my own language features.

  99. features by jefu · · Score: 1
    I'd like to see design by contract built in to languages. In particular I'd like to be able to write something like :
    double sqrt(double x)
    pre x > 0
    post abs(result - x * x)/result < epsilon
    {
    ...
    }
    If the language has classes, it would be nice to also have class invariants checked before the entry to a public function and after the result, so :
    invariant instance-var > 7 ;
    public int bar(int x)
    pre x > 0
    post result < 0
    {
    ...
    }
    would (essentially) translate to :
    public int bar (int x)
    pre x > 0 && instance-var > 7
    post result < 0 && instance-var > 7
    {
    ...
    }

    Ideally this would be something that could be turned on and off either at compile or run time on a class by class basis.

    Functions as first class objects, including currying would also be very nice (like this in haskell)

    times3 = 3 *

    An unnamed "tuple" type (like in haskell or python) is great for handling multiple return values from functions. For example to get both the quotient and remainder from integer division :

    (div,rem) = divrem(7,5) ;

    Iterators are really nice - including the ability to define new iterators on classes (and it would be best if primitives were somehow included in classes). It should be possible to wrap iterators in functions. For example, instead of :

    for (i = 0 ; i < N ; i++)
    for (j = 0 ; j < N ; j++)
    do_foo(i,j) ;

    It would be nice to be able to define an iterator that produces all the (i,j) pairs :
    for (i,j) in all-i-j-pairs
    do_foo(i,j)

    Or even, given a mapping function :
    map(do_foo, all-i-j-pairs)
    1. Re:features by Bullet-Dodger · · Score: 1
      Excuse me if I'm missing something, but the design by contract of which you speak sounds like it could just be done by assertions. Or is there something fancier that design by contract does? I'm unfamiliar with the subject.

      i.e.

      double sqrt(double x)
      {
      assert(x > 0);
      ...
      assert(abs(result - x * x)/result < epsilon);
      }

    2. Re:features by jefu · · Score: 1
      It can be done with assertions, yup, but less cleanly. The syntax I gave would handle multiple returns from the function and ideally the syntax would provide a way to check the result value regardless of the name. Futher, though it can be rather more expensive, it could be possible to save the value of any needed arguments passed in.

      Finally, combined with class invariants, what might take four statements with assertions (assert class invariant on entry, assert preconditions, assert postconditions, assert class invariant on exit) is done with one invariant for the class and the pre/post conditions.

      It doesn't remove the need for assertions, but does provide cleaner syntax. For instance, in the code you gave there's no return result.

  100. RAII - Resource Aquisition is Initialization by rsclient · · Score: 1

    The stupidest name for the best concept. My code constantly grabs some sort of resource -- files, mutexs, com objects, whatever -- that need to be "freed" somehow (Release, delete, free, etc).

    Old style: "free" it at the end of the method

    Problem: doesn't work with exceptions. Easy to forget with early returns. You have to add an ugly try/catch/finally block in each method, meaning that variables have to be declared in ugly and inconvienient spots.

    Solution: "free"Me classes:

    class ReleaseMe
    {
    private:
    IUnknown* m_ptr;
    public:
    ReleaseMe (IUnknown* ptr):m_ptr(ptr) { }
    ~ReleaseMe() { if (m_ptr) m_ptr->Release(); }
    };

    ...

    ISomething* ptr = ....
    ReleaseMe RM(ptr);

    Result: No matter what happens (almost), the object will be "free"d. I can return early; I can have exceptions; I can do whatever, and the object is "free"d.

    The same concept can be used for classic C files (fcloseMe), for all the myriad ways of allocating memory (there must be a half-dozen in C++ on Windows), etc.

    Smart pointers are the same idea, but IMHO drag in too much baggage -- you have to spend too much time figuring out the thousand-line smart pointer template, you have to do a lot of work to know if one smart pointer type can be converted into another, the boxing/unboxing thing looks awful...the list goes on. And the only work with one type of memory resource, when in reality in C++ on Windows there are lots of types of memory that have to be managed.

    --
    Want a sig like mine? Join ACM's SigSig today!
  101. Re:Speed and RAM by chromatic · · Score: 1

    Agreed. As an editor and a programmer, I've seen terrible abuses of English and code. I've learned to appreciate simplicity and locality in both.

    Woe to the language developer who invents some sort of passive voice programming, though.

  102. Pascal - all of it by gatkinso · · Score: 1

    I love(d) Pascal. It was simply the coolest bestest language going.

    Sure Kernighan likes to bash Pascal... says it isn't suitable for serious system level programming.... but then again how does he explain MacOS?

    Ah well I am a C++ java type like everyone else these days.... but I love Pascal still.

    --
    I am very small, utmostly microscopic.
  103. I miss READ/DATA by Anonymous Coward · · Score: 0

    Back in ye ol' days of line numbered BASIC, you could use a READ/DATA pair to stuff arrays with initial values, something like this:

    dim ar$(3)
    for x = 1 to 3
    read ar$(x)
    next x

    data "Monty", "Python", "Rules!"

    Great way to load fixed value lookup tables with a minimum number of lines. Of course you wouldn't use it except for large enough arrays (including multidimensional, just nest the loops).

  104. Best Code Snippet by nlindstrom · · Score: 1

    /*
    TOP SECRET Microsoft(c) Code
    Project: Chicago(tm)
    Projected release-date: Summer 1998
    */
    #include "win31.h"
    #include "win95.h"
    #include "evenmore.h"
    #include "oldstuff.h"
    #include "billrulz.h"
    #define INSTALL = HARD
    char make_prog_look_big[1600000];
    void main()
    {
    while(!CRASHED)
    {
    display_copyright_message();
    display_bill_rules_message();
    do_nothing_loop();
    if (first_time_installation)
    {
    make_50_megabyte_swapfile();
    do_nothing_loop();
    totally_screw_up_HPFS_file_system();
    search_and_destroy_the_rest_of_OS/2();
    hang_system();
    }
    write_something(anything);
    display_copyright_message();
    do_nothing_loop();
    do_some_stuff();
    if (still_not_crashed)
    {
    display_copyright_message();
    do_nothing_loop();
    basically_run_windows_3.1();
    do_nothing_loop();
    do_nothing_loop();
    }
    }
    if (detect_cache())
    disable_cache();
    if (fast_cpu())
    {
    set_wait_states(lots);
    set_mouse(speed, very_slow);
    set_mouse(action, jumpy);
    set_mouse(reaction, sometimes);
    }
    /* printf("Welcome to Windows 3.11"); */
    /* printf("Welcome to Windows 95"); */
    printf("Welcome to Windows 98");
    if (system_ok())
    crash(to_dos_prompt);
    else
    system_memory = open("a:\swp0001.swp", O_CREATE);
    while(something)
    {
    sleep(5);
    get_user_input();
    sleep(5);
    act_on_user_input();
    sleep(5);
    }
    create_general_protection_fault();

  105. Re:Syntactic simplicity? C?? by Carnildo · · Score: 1

    If you want simple syntax, try Brainfuck or Befunge.

    --
    "They redundantly repeated themselves over and over again incessantly without end ad infinitum" -- ibid.
  106. Re: macros by Wolfkin · · Score: 1
    Okay. Here's an attempt at why macros are so useful:

    It's very common for a developer to want to open a file, read from (or write to) it, and close it. No matter what happens (in this idiom) we always want to close our file. Errors or exceptions should not prevent the file from being closed, so, in most languages, we'd have to remember to close that file in every branch of our code.

    Now, one solution to this would be to have open files be objects that know to close themselves when being garbage collected (Python does this, I think), but this means that if we have an error, and fail to remember to close the file, we're guaranteed to have an error if we try to open that file again later in the same run of the program. For long-running processes this is, of course, fatal.

    Macros to the rescue! :)

    In Lisp, if we wanted to read from a file without worrying about all that, we'd say:
    (with-open-file (file-variable "/path/to/file")
    (do-something (read-line file-variable)))
    or if we wanted to write to it:
    (with-open-file (file-variable "/path/to/file" :direction :output)
    (write-string "just a test string" file-variable))
    In this example, WITH-OPEN-FILE is a macro that adds code to the beginning and end of whatever code it contains, so that a file is opened, a stream is attached to the file, the variable name we give it is connected to the stream, our code runs, and then, *even if we had an error or just jumped out of our code into some other area of the program*, the file is properly closed.

    Of course, we could do all this bookkeeping ourselves, but now we don't have to, and this is not something we could easily do concisely with functions alone. Further, now we just don't have to ever worry again about whether a file gets closed properly. It just works.

    Multiply the conceptual savings from this macro across a whole slew of similar macros, and the effect is very much like defining a new, higher-level language that frees the developer from messing with the low level details, but preserves those details so that they're available when the developer actually wants to use them directly.

    Now, my original assertion was about using macros to aid in building manager-friendly or web-designer-friendly mini-languages, and I haven't talked about that. Part of this is because I'm most familiar with one implementation of that in particular (PSILISP, my web application framework), and it's not done yet. Nevertheless:

    In PSILISP, assuming you've already defined a page called PAGEONE, you can say
    (in-page pageone
    (write-to-page
    (dotable (author (get-authors))
    (td (first-name author))
    (td (last-name author))
    (td (do-something-like-an-edit-or-delete-form author)))))

    (in-page pageone
    (write-to-page
    (p :class "my-html-p-class"
    "This is a paragraph in the same page,
    but maybe in a different file or package, Lisp-wise.")))
    and it's easy for the web designer to understand what's going on, even if said designer doesn't know Lisp in the first place.
    --
    Property law should use #'EQ, not #'EQUAL.
  107. Re: macros by Da+VinMan · · Score: 1

    Ok, I think I understand your post. BUT, what I don't get is how macros get LISPers all excited about macros when macros look so much like regular function calls.

    For example, if PSILISP were just a bunch of functions in Java, we could write code that would do essentially the same thing with the same number of lines of code. Furthermore it COULD (though it often isn't I admit) be just as readable as the LISP version. No?

    Really, I'm not trying to be difficult. I'm just missing the magic here. I'm sure that part of what I'm missing is context. If this were the 1970's and I were faced with decision to choose the most productive environment and I got to decide between something like BAL, COBOL, FORTRAN, or LISP; I'm sure I would choose LISP. In the context of that day and age, LISP and macros WOULD be magic. And, I'm not saying LISP is no longer useful, it just has a much more mature heritage and I'm sure that its younger cousins probably stole much from it.

    BTW - If you would like to see a web development framework that provides a full object oriented treatment of web development semantics, give Tapestry a look. Granted, it's a Java framework, but you may find some inspiration for features there. In particular, you might like to see the components that Tapestry provides a developer. It is, by far, the best UI layer framework for web development I have found in the Java world. I compare its productivity to the ASP.NET framework, which I have also used for work (say what you like about .NET; it's productive as all hell).

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
  108. Multimethods by Anonymous Coward · · Score: 0

    I love them, plain and simple. Dynamic polymorphism over more than one parameter makes things so much nicer.

    I recently wrote a small blog entry on what my favorite features would be.

  109. Re: macros by Wolfkin · · Score: 1
    From what I just read about Tapestry, it does seem very similar to what I intend PSILISP to be when it grows up. The most immediate difference, to me, is that I expect PSILISP to be less than 5,000 lines of code, where Tapestry is well over 50,000.

    I started PSILISP mostly because I was frustrated with the prevalence of web frameworks that treated pages as having only the most tenous connection to other pages. That is, the decision of which code to run for this URL/form/session state combination was made too early in the response process, and usually depended almost entirely on the URL.

    In any case, this is far off topic.

    It's true that anything you can do with macros can be done with non-macrified languages (as far as I know). It's just that with macros, you can have the additions appear to be built into the language, and you don't force users to build object oriented code even where that's overkill. In PSILISP, I'm using macros to do the same sorts of things that I used to use mix-ins for, in Python, but now, I worry less about the details of how it's implemented (after I write it), since it's just like any other built-in.

    Here's an example of a macro that doesn't something you can't do, as far as I know, in Python:

    Suppose you're writing some larger app, and you'd like to have something happen whenever your app prints something (work with me, here; you can come up with a less contrived example of this, I'm sure).

    So, everyplace you now have
    (print (do-something variable-name))
    ; in python this would be
    ; print do_something(variable)
    you'd like it to save the variable name and value.

    So, you can write an (untested) macro:
    (defmacro print ((func var))
    (let ((f (gensym))
    (v (gensym)))
    `(let ((,f ,func)
    (,v ,var))
    (save-value (format nil
    "Called ~A with variable: ~A having value: ~A" ,f ',var ,v))
    (CL:print (,f ,v)))))
    to shadow the built-in print statement. Of course, this is a fairly fragile implementation of PRINT, and would break in lots of cases as written. However, you haven't had to change any of your original code, with the possibly hundreds of print statements like this, and now you're getting the formatted string in your logfile or database or whatever SAVE-VALUE does with it, and in that string is not only the variable value, but the source *name* of the variable as well!

    How would I do this in Java? Could it even be done without choosing from the outset to use a non-builtin to do my low level printing? I'm quite sure you couldn't do this in Python without resorting to changing the builtin print function in C (for CPython).

    The important thing is that you can build new language features for Common Lisp that are written in Common Lisp, and can be used exactly like any other language features. In fact, most of the "built in" functionality of Common Lisp can be implemented in terms of macros, though there are a few built-ins that are only possible as "special operators".
    --
    Property law should use #'EQ, not #'EQUAL.
  110. Formatting! by JoeCommodore · · Score: 1

    Indention, syntax coloring, loop/conditional indicator lines (not to forget ability to collapse loops/conditionals for readability). Playing with KWrite with some PHP sure makes me look at my other code editors with a heavy sigh. Of course all those GUI featurees as copy paste, etc. too.

    --
    "Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
  111. Jobs by Anonymous Coward · · Score: 0

    My absolute favorite feature is a job market which favors practitioners of the language.

  112. Interesting that you posted this. by WindBourne · · Score: 1

    It is one of my interview questions to allow me to figure out where coders stand. What amazes me is the number of arguments it will cause until somebody compiles it and figures out what is happening.

    The other big ones these days is trying to determine if somebody has *nix. I have been asking applicants how to create new processes, and ppl professing to have years of *nix experience will tell to spawn a new process by fork. When I ask what it returns, it is then "a handle to the process". When I ask how to switch the executable, they have no idea. Finally ask what exec is, and the answer is, no idea. Amazing. Total MS coders (or possibly VMS), that are too lazy to even look over standard *nix code or books.

    --
    I prefer the "u" in honour as it seems to be missing these days.
    1. Re:Interesting that you posted this. by eggoeater · · Score: 1

      I printed out your post and filed it under "things to learn before my next job interview."
      I have experience coding C in Unix, but I haven't done a fork() since college. Thanks.

    2. Re:Interesting that you posted this. by WindBourne · · Score: 1

      Good to study before any interview. I assume that you are not trying to represent yourself as *nix expert, no? One good way to get ready for a *nix is be up on running linux(in this job environment, you would do well to run some *nix and windows at home), read a small but important program. One would be xinetd.

      One of the people who failed a *nix expert interview claimed to do embedded linux, for which he would have gotten the job had he even had a clue. But that response was his. He had no clue on how *nix starts or how to start a daemon program upon boot-up. Yet, he was a *nix expert.

      But I give him credit for schuzpa.

      --
      I prefer the "u" in honour as it seems to be missing these days.
    3. Re:Interesting that you posted this. by eggoeater · · Score: 1

      Luckily I do have a job so I don't have to prepare for an interview any time soon. I have a lot of experience with a lot of things but I know not to call myself an expert at anything. (As soon as you do, you inevitably meet someone who knows a whole lot more than you do.) I have a good background in *nix which makes me the "expert" in my department. Most of the MS heads around here have little patience for shells or using vi. I've had a spare computer in my home office for a couple months waiting for me to install linux so I can get some REAL experience. This is impossible at work as only SAs have root access to any of our Solaris servers. Most of the work I do is SQL (MS & Oracle), some .NET component work, and telephony. Thanks for all the advice.
      Steve

  113. Not a feature -- I want it to work. by oneiros27 · · Score: 1

    For whatever I'm trying to accomplish, I want a language that can do what I need it to do to accomplish the task. Preferably, that lets me get the task done in a time under the amount of time that I have been given to complete it.

    [and when run, will complete the task within the accepted specifications, such as run time, memory utilization, etc]

    There are times when the right language for the job is assembly, and there are others where it'd be a shell script.

    There are times when it's appropriate for me to spend my time with memory management ,and other times when it's irrelevent to the environment that the program's going to run it.

    A language might work well for a particular situation, but I think it's unrealistic to think that any one feature is going to make me always want to use a particular language.

    --
    Build it, and they will come^Hplain.
  114. Re:Speed and RAM by Nurgled · · Score: 1

    Think of $_ like "it". You can use it in everyday speech to get your point across in the minimum amount of words, or you can be verbose and spell everything out.

    foreach (@page) {
    split(/\s/, $_);
    }

    ...should be read as "for each page, split it on the spaces." In this situation, in fact, the "it" is optional, but leaving it out makes things even more confusing unless you're writing something quick-and-dirty, which has no place in a full application:

    y/abc/xyz/ foreach @name;

    If you're writing something which is going to be used in the long term, it's wise to avoid the use of $_, not least because (by default) it's a global symbol and so you can get some weird bugs by one bit of code clobbering another's "it", like this:

    Pick up the sword. Pick up the sheild. Give it to me.

  115. purposes are more important by bloody_geek · · Score: 2, Interesting

    I don't look at the features alone in a language. Usually, I look at what its primarly used for. I use C because it's a general-purpose language, that has a strong issued standard, with ANSI compiler compliance. I find that beginner programmers who like languages with lots of features(i.e C++), they get carried away and don't learn the language like they should. C++ is an extremely complex language, that is hard to use correctly.

  116. Re:True 64-bit Environment w/ Strong Primitive Typ by Anonymous Coward · · Score: 1, Insightful

    What are you going to do when you need a true 128-bit environment? It used to be that 32-bits seemed like more than anyone could ever use. Now that's starting to no longer be the case for certain applications, and 64-bit is becoming more important.

    I don't think it's reasonable to expect certain bit lengths for primitive types (unless your application is very specialized, i.e. nobody else is ever going to want to run it). Primitive integer types are never going to be able to do all the computations necessary (wake me up when they sell cheap 4096-bit computers to compute RSA keys); the primitive types should be seen as tools for performing a fairly limited range of computing tasks (ditto with floating point; IEEE 754 is not a magic cure-all for numerical robustness). The rest is up to the programmer, language designer, or library designer.

    Also, I'm not sure what you're talking about with regards to SQL, but none of that stuff is really closely defined in the SQL standard itself. Many high-quality databases are more than capable of storing more than 4 GB of data in a single field. Storage size limitations reflect the underlying database backend more than the programming language used. The native protocols for databases are more than capable of transferring data in pure binary as well.

  117. A simple Perlistic addition, but a beautiful thing by SadPenguin · · Score: 1

    I have been a C++ -er since about 14, and i have begun coding Perlwise. Something so simple as being able to say
    'foreach(@array){ print $_;}'
    is a world of difference. Kicking one's self over fence post errors is now a thing of the past, and i love it.

    IMOH it is the simple conveniences like this that are done 100000000000 in a program that really make life better simply by volume of use. Oh, and this is lang. independent, but loosely typed, memory managed-ness is a great thing too. Not having to think to hard about where things are going (just knowing how to get them back) allows for much more thought to be applied to problems of form, rather than semantics and specifics.

    --
    sigSEGV - doy!
  118. Textual vs. graphical representations by Anonymous+Brave+Guy · · Score: 4, Insightful
    We use graphical interfaces for a lot of things, we should use them for programming.

    SCREW the text editor based programming.

    I think this is one of those rites of passage all experienced programmers probably go through. At some stage, your experience of different languages gets to the point where you understand that the underlying concepts transcend the syntax of any specific language. A natural next step, particularly if you've seen the sort of parsing graphs used by compilers, is to assume that throwing out the "awkward" text syntax in favour of some whizzy graphical scheme will make things much easier. Some people have even done PhDs on this subject.

    Unfortunately, when you try it in practice, you find it's not nearly as clear-cut as you thought. Like all that nasty, unnecessary punctuation found in many programming languages, it turns out that using a concise, precise text format is often far easier both to read and write than any graphical alternative. What can be done in one line of regex in Perl takes a whole screen of graphical representation via flow charts and state machines.

    I wish you luck in your exploration of graphical alternatives, but I'm afraid the odds are pretty heavily that after a while, you'll come full circle, and understand that all that nasty "bracket crap" is there for a reason, and has survived for decades because that reason is sound.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Textual vs. graphical representations by Dr.+Weird · · Score: 1
      Here's one of my favorite ideas for graphical programming (besides higher level design, like UML, etc.), which barely uses graphical elements:

      Say you have a if statement, or alot of nested if's. If the blocks have any substantial size, it is impossible to see the flow and connection of the state prior to the conditional and after the conditional precisely because you have to jump back and forth. It requires enough time to look at the code to basically memorize the input state or the output state. Watch experienced programmers sift through unfamiliar code with such blocks. They jump back and forth, precisely like this.

      By blocking each separate conditional in a rectangle (nested if necessary, can scroll through the text in each rectangle) the hierarchical structure (parse tree) becomes apparent much more easily. The textual commands are still there, but this shows the layout of the individual commands simultaneously with retaining the speed and expressiveness of text.

      I imagine that text will continue to be the primary mechanism by which programming is done (I would take C++, Java, or even VisualBasic over LabView for ordinary programming tasks, for example), but I imagine graphical elements for ORGANIZING those textual statements will be important. And some levels of viewing the code may suppress the code altogether (for example, UML-like modeling).

      So the idea of wiring icons together and programming like this is probably doomed to failure, graphical organization of textual programming, I believe, has great potential. At least, it is worth having a go.

    2. Re:Textual vs. graphical representations by gurps_npc · · Score: 1
      Perhaps you are right, but I think you are severly mistaken about the background as well as the facts.

      High end Graphical Interface, has not been around for decades, so what I am talking about is only possible recently.

      I love perl, and agree that a lot of what we do is best done in text, but not ALL of it There are a ton of key words related to keeping scope. Ideas such as reference, derferencing are all better displayed graphically.

      I am not trying to remove text, just not use it for stupid awkward kludges. I am going to continue to use text for the areas appropriate for it.

      Example, say we had a Perl Reg Ex. Instead of a command that looks like this:

      ( $doc = $dos_location ) =~ s%\\00\d\\?%%;

      I could have something that had

      $doc-(double box with text in it )-$dos_location The left box would have nothing in it [as the reg-ex is deleting stuff] and the right box would have a \00(one character symbol obtained by control d meaning any digit)\(one chacter symbol obtained by control ? meaning 0 or 1).

      That would be FAR easier to read and understand. You have end result variable, connected by line to the reg ex, then the change made then the thing changed using symbols that are NOT confusable with normal letters/punctuation, then the connection to the starting variable.

      --
      excitingthingstodo.blogspot.com
  119. Re:Multiple [& Possibly Overlapping] Instances by Anonymous+Brave+Guy · · Score: 1
    Extra Credit: Tell me what a generic "replace" function should do when told to replace "ABBA" with "The Bee Gees".

    Question your musical taste? ;-)

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  120. Re:Speed and RAM by Anonymous+Brave+Guy · · Score: 1
    Woe to the language developer who invents some sort of passive voice programming, though.

    You mean like the whole concept of declarative programming, as seen ubiquitously in the functional and logical language worlds?

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  121. One from C, One from Pascal by rfc1394 · · Score: 1
    1. I like the idea C came up with of the ++ operator (and --, and to a lesser extent some of the equal codes such as *=, /= etc.), e.g. instead of
      A = A+1; You have
      A++; or ++A; depending on whether you want A to be increased before using it or after you use it.

    2. I like the idea Pascal came up with to distinguish an assignment from a comparison. The equal symbol = is only used for comparison. To assign a value to a variable you must use the "becomes" symbol :=. This eliminates the possibility of nasty errors in C such as
      if B=C { being used where they should have used if B==C { N.B. Yes, I know there are checks in certain cases that require you to put certain of these type of expressions in () to allow them without getting compiler warnings, and I also know that there have been attempted system hacks where this type of exploit has been attempted to grant priveleges by doing a comparison using = instead of ==.

      If assignment used a special sequence that can't be used in any other case (or did not allow assignment inside of a statement), check code that implemented root access hacks (A test for privelege against the user's privelege code which grants the user root privelege) would be impossible in the first place.

    Paul Robinson <Postmaster@paul.washington.dc.us>
    --
    The lessons of history teach us - if they teach us anything - that nobody learns the lessons that history teaches us.
  122. Re:Favourites and a tangent by E_elven · · Score: 1
    Functional languages certainly are nice -but there's always a tradeoff. The C++ code will likely run faster on reasonable loads though that's something that's becoming increasingly irrelevant for certain types of programming.

    My main problem with functional languages is with I/O: all the literature claims that monads are the 'natural solution' to that kind of processing, but I always thought it was just a lazy cop-out and it certainly doesn't feel right among the rest of the syntax.

    For the uninitiated, a normal (functional) function must always produce the same output with the same parameters so something like
    ReadFromScreen screen_one
    wouldn't work because any given name is bound to a certain value and is therefore immutable.

    I personally feel that the mathematically oriented people are making this too difficult, and would prefer that the RealWorld were abstracted into a few 'magic' functions; for example, the 'function' GetScreenContents would take as a hidden parameter the actual current contents of the screen -thus the functionality (hehe) would stay intact:
    GetScreenContents <em>Please enter your name:</em> and
    GetScreenContents <em>Please enter your name:</em>
    would produce the same output (namely the string "Please enter your name:" whereas
    GetScreenContents <em>Please enter your password:</em>
    would produce a different output. Sure, it's a sort of a hackish way of doing it but I think it'd fit better :)

    I must admit -and I'm ashamed of this- that I don't know LISP or any variants thereof. I started with imperative languages and am only slowly unlearning those patterns so that I can actually use functional languages (and I've done a bit in Prolog). It seemed easier to start with Haskell than, oh, CLOS or something. So I'm getting there!

    Regarding Ruby: yeah, it is a simple abstraction of a common idiom -well, a few idioms. Blocks can be used as closures, high-level functions, lambda functions and iterators. There's just something intangibly cool in how Ruby does it. I could bridge it to your earlier argument about C++ generics vs. functional polymorphism: the same thing can be achieved many ways but this is just the best one :)

    --
    Marxist evolution is just N generations away!
  123. Re:Favourites and a tangent by Anonymous+Brave+Guy · · Score: 1

    I totally agree about functional languages and monads. They're theoretically elegant solution to a major practical problem, but always seem far too awkward in actual use (though I'm no expert on this subject).

    What I'd like to see is the reverse approach: an imperative language that supports higher-order functions, currying, etc. properly. I don't see any problem with this approach, yet the most (only?) serious attempt to bridge the imperative/functional gap so far seems to be OCaml, which starts from a functional approach and adds imperative-like features (and, IMHO, not particularly cleanly). One need only look at the flexibility evident in scripting languages that provide basic support for functional programming concepts to see the potential.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  124. After learning Haskell for the past 6 or so months by Anonymous Coward · · Score: 0

    I must say I like lists and 'infinite' lists, recursion, lazy evaluation and currying.

  125. Operator overloading et al by Da+Penguin · · Score: 1
    Probably the biggest thing I miss from Java (compared with C++) is operator overloading. How the heck is this:
    BigInteger a=new BigInteger(), b=new BigInteger();
    a.Multiply(new BigInteger(3)).Add(b);
    Easier than:
    bigInt a,b;
    3*a+b;
    Plus Mathematica has some truly amazing features that few people seem to be fluent in. Even things like instead of just defining what the function f[x] equals, you can define what an arbitrary pattern equals, like redefine Sin[x]+y/z. Too much to say here, but I have always been amazed.
  126. Perl's understandable documentation ... by Anonymous Coward · · Score: 0

    Is what got me hooked on it. The language behavior and features (perl 4 man pages) were described in a conversational and friendly manner, as if the manual page were trying to explain to you why the features were added, where they appear in other languages, and how they're different or the same in Perl.

    I don't need to tell you that most technical documentation is usually written as if it were an oversight. When I saw the quality of Perl 4's included documentation, I had a high degree of confidence that the perl interpreter itself was of high quality, and that the author understood *language*, both computer and human.

    Try to point me to another language's documentation that's as friendly as Perl's.

  127. Javascript by kanarie · · Score: 1
    I love the 'eval' function in Javascript and the short 'if, then, else' statements.
    doc = (document.all)?document.all:document;
    eval(doc+". myForm.myName='John';");
  128. Too many assumptions by TheLink · · Score: 1

    The problem is when you _think_ your custom reprentation is perl+, but actually it's NOT, it's closer to php++ than perl+.

    Translating the program to Java may[1] better indicate there's a problem, but who knows what perl+ is? Maybe even you don't.

    Also translating php++ to Java may generate source that has 10x the number of lines and is harder to understand compared to something that's natively written in Java that does the same thing.

    For the scenario you cite to be practical, too many things would have to be perfect or near perfect, or even possible.

    In such a world we'd all be speaking languages that could be losslessly translated to esperanto or parrot-bytecode and vice versa, with zero misunderstanding.

    --
    1. Re:Too many assumptions by sonamchauhan · · Score: 1

      > The problem is when you _think_ your custom
      > reprentation is perl+, but actually it's NOT,
      > it's closer to php++ than perl+.
      >
      > Translating the program to Java may[1] better indicate there's a problem,
      > but who knows what perl+ is? Maybe even you don't.

      Your thinking is muddled.

      First, can you translate Perl-Php+++ to a virtual machine's bytecodes (.NET CLR/Parrot bytecodes/JVM)?

      Well, unless you write your own bytecode scheme, compiler, and virtual machine etc, you probably can.

      Now since Perl-Php+++ translates to bytecodes, you can reverse translate these bytecodes to Java/C# sources. And lift the comments from the original source.

      It may be shorter code, it may be longer. But it can be done.

      And that's not even considering the majority case: the majority of people who have no interest in Perl-Php+++ but just want to program in plain Perl or plain VB.Net or plain Java.

    2. Re:Too many assumptions by sonamchauhan · · Score: 1

      Sorry for some harshness at the beginning of my post back there.

      Thanks and have a great day!