Re: A few things I would like to see in a new programming language.
"digulla2000" <[email protected]> Sun, 03 Aug 2003 17:00:20 -0000
| Newsgroups | gmane.comp.programming.pragmatic |
|---|---|
| Message-ID | <[email protected]> |
--- In [email protected], "Avdi Grimm" <avdi@a...> wrote: > > > Therefore, it should be possible to understand the > > > program when > > > reading it in a natural way. Lines at the top should > > > not need > > > to reference things which are below. When you are > > > writing a book, > > > you are warned to reference material which is > > > explained further > > > on. Why do language developers insist that their > > > languages are > > > "more simple" when they break this golden rule? > > > Oddly enough, this was one of my favorite features when I learned > Haskell. Why? Because when I'm comprehending somone else's code, > that's how I think. I try to get a high level idea of what the > functions do, and then dig down deeper if I need to. The Haskell > syntax facilitates this process: the first line gives you an > overview, and then the lines following 'where' let you in on the > details, indexed by variable name. I don't think this style should > be mandatory, but I like having it available. I understand that but that's what a function is for :-) Functions, modules or packages should help you to organize your code and help others, to find their way around the code. But inside of a function (ie. a small block of program that does a simple operation), things should be sequential because that's easier to understand. Example: Right now, I have a rather large Python code which builds websites from descriptions. The code is nice and simple but every now and then, it does very strange things because I can no longer see what code is called when. This of course is based on the OO nature of Python and I would run into the same problems with any other OO language but there should be a simple to way to > > > In the end, even a fool should be able to write > > > working > > > programs. > > I heartily disagree with that statement. A programming language > should be as simple as possible, but no simpler. (Who said that? > Dijkstra?) When you try to make programming simpler than it really > is, you wind up with Java (hopelessly verbose and inexpressive) or > VB (baroque). We're in the business of solving problems, not of > making the problem-solving process look like child's play. I don't > think code should be needslessly obfuscated, but too many horrors > have been committed in the name of "simplicity" (COBOL, anyone?). *grin* After I wrote that, I realized that I was writing "I want COBOL" ;-) Of course, I agree to the statement (it was Albert Einstein, who said that btw. and was referring to mathematics). What I wanted to say was: One of the major flaws of many "modern" languages is that you can get yourself easily lost in their features. Example: I have a small Python code which can produce valid HTML. I do this by creating a base Element class and then I say "if you instantiate this class with key-value-pairs as arguments, then turn them into attributes when you write the element to a file". In Python, this is about six lines of code (formatting the elements for output is the hard part - four LOCs). Now I have a method render() which writes an element to a file. To do real-world HTML, I need to create lists of elements, turn them into a tree, etc. Just another few lines of code. Neato. But then, I found that the code looks bad in the web browser. The main point is that <P>...</P> renders very badly (most browsers will render that as *two* paragraphs). So I needed a way to get rid of the P elements. Oh dear. The problem is that I shouldn't say "Well, if a P class in the HTML modules is to be instantiated, use the P class from module MyHTML instead". Note I could do that (in Python, you can change the contents of a module during runtime) but then, I would be completely lost when which code is being called and if a problem happens, I simply couldn't track it down because the possible number of call stacks would be too great for me to grasp. A mandelbug: You know exactly what is broken but you have no idea how you could fix it. Also something which a language design should take into account: Even smart people have bad days. So maybe a better way to say the statement above would be: The programming language should allow to solve complex problems in a simple way. This might mean that the code can't be expressed in ASCII anymore. Maybe the compiler should already contain editors for more complex data structures and plug-in optimizers. ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/sO0ANB/LIdGAA/ySSFAA/W4wwlB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: pragmatic_lang-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/