For solving complex problems: Haskell ** This is really a GREAT language (solve the eight queens problem in 20 lines of code, producing 90 results in less than 1.5 second).
Could you give an example of what Haskell code looks like? I''m just interested.
As for debugging, C++ has this built in: exceptions.
There was quite an interesting thread here earlier this month about exceptions, and it was determined that exceptions cause a VERY negligible speed drop. I, for one, love the idea that the debugging info can be built into a final release at almost no speed cost. The potential for this is pretty cool: You don''t have to worry about crashing someone''s system.
Preprocessor? I''ve used it before. Im not too fond of it though. The only reason I''d use the pre-processor would be to get code to work on multiple compilers; something that wouldn''t be needed if the same code would compile on ALL compilers.
Macro''s? Just use inlining.
My perfect language would be somewhat like C++, but not so "hacked" together. Especially the templates.
I once used a language called EIFEL, and I liked it. Everyone bitched because it was so damn slow, but as for the model of the language, it was pretty clean, and lots of functionality. On a side note: the language first compiled into C code, which then was compiled into machine code, which is probably why it was slow: too many steps to optimize.
=============================================== If there is a witness to my little life, To my tiny throes and struggles, He sees a fool; And it is not fine for gods to menace fools.
This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
I just looked into Objective-C, which seems to address a lot of the gripes I have with C++. And it has a reflection mechanism. Nobody else has mentioned this so far, so I wonder if I''m the only one that misses this?
I''m talking about things like being able to determine an object''s classname, instantiating a class of a given name, getting a pointer to a method based on the method''s name, invoking methods on objects whose class was unknown at compile-time...
At the very least, I would really have liked to have metaclasses in C++. Run-time polymorphism just isn''t the same without them, and not everything can be solved with templates.
Tom Nuydens delphi3d@gamedeveloper.org www.gamedeveloper.org/delphi3d
The thing I really like about haskell, is that it requires so litle code to do anything (yes it is slow, I know). The program below is all that is needed to solve a pretty complex problem, the "eight queens" problem. And it is, "How to place 8 queens on a chessboard so that none of them captures eachother?" Just run "queens" function with 8 as argument and you will be presented with 92 correct solutions within a few seconds.
I really would like to know how much code that had to be written in a language like C, or C++ in order to do the same thing as this short haskell program.
type Square = (Int,Int)
queens::Int->[[Square]] queens 0 = [[]] queens n | n>0 = [(n,q):qs|qs<-queens(n-1), q<-[1..8], not (capturesAny (n,q) qs)]
Thinking about how to get rid of preprocessor commands: debug-only output can be done through setting a single variable somewhere, that constructs a different kind of exception in debug than it does in release, or something to those lines.
It requires code modification, but then, so does removing the #define DEBUG..
Your missing the point of the preprocessor.
The pre-processor runs through the code BEFORE (pre) compilation. The point is, that doing your variable and if() statements will take a few clock cycles no matter what build your in (just to do the if()). And one of them around every piece of debug code? I''d rather stick with the pre-processor.
The other argument for keeping the preprocessor in a language such as C++ is portability. You can have the same source having all the code for Win32, Linux, BeOS, whatever.
#ifdef __WIN32__ #include #endif
etc.
Without the preprocessor your force the source into a different group for each OS. I''d rather keep the pre-processor.
I have to agree with you on one point though. Macros are pure evil .
I''ll use a inline function over a macro everytime, but the pre-processor still has it''s uses).
(Point of interest: I''m guessing one reason Java has no pre-processor is because of it''s platform independentness (is that a word ).
Looking at functional languages like Haskell, it seems quite important to have high-level data structures. Do you think this is also useful in more "traditional" OOP/procedural languages? Python, for example, has built-in support for tuples, dictionaries and the likes. Would you use this stuff if it were available, or would you prefer to roll your own and have full control over how it''s implemented? (And perhaps get better performance...)
Anonymous Poster: Using metaclasses, MadKeithV''s idea could be implemented without the overhead of an if() for every exception. During startup, you could check if you''re in debug mode, and determine the class types of the exceptions you want to throw. Later, you instantiate exception objects using these metaclasses. This way you''d only need to check for debug mode once.
Tom Nuydens delphi3d@gamedeveloper.org www.gamedeveloper.org/delphi3d
Hmm, in the future, there will be two kinds of programers: Assembly programmers (Math dudes), and HLL programmers (theory dudes). Since the ASM dudes will only use the assembly, I guess a perfect language would only have to appeal to the theory dudes. So, if you can find one language that does everything very well, then you have made the perfect language. Until then: Perl for file i/o and string parsing, C and C++ for games, operating systems, generally big projects, and Assembly for low levelness, etc.
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt