Link to home
Start Free TrialLog in
Avatar of PaulCaswell
PaulCaswellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Discussion: How can we avoid reinventing the wheel?

All,

The usual discussion rules apply ...

I recently had a discussion with Axter and it turned out we have both created something that seemed unique to our current situation. We could have saved much time!

https://www.experts-exchange.com/questions/21787694/declare-define-a-two-D-array-dynamically-and-destroy-it-afere-using.html#16290738

I think the problem is that there are so many different ways to write even the simplest things. If there were less, then tools could be made to search a pool of code in a sort of auto-complete system. Perhaps the language is at fault. Perhaps standards would help.

What are your views and experiences?

Paul
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PaulCaswell

ASKER

LOL!

Nice one Kent! :-)

Paul
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
FYI:
For anyone interested in how to call Doxygen from VC++ 6.0, 7.x, or 8.0 IDE, you can use the following method:
Go to External-Tools, and add the following tool.
Title:          Doxygen
Command: C:\Program Files\doxygen\bin\doxygen.exe
Arguments: $(ProjectDir)\Doxyfile
Initial Dir:    $(ProjectDir)

Check the following field:
"Use Output Window"


For VC++ 6.0 change $(ProjectDir) to $(WkspDir)
On VC++ 7.x and 8.0 use $(ProjectDir)

You would have to make sure that your project has a Doxyfile, which is created automatically if you run Doxygen for the first time using Doxygen IDE instead of VC++ IDE.
IMHO, the difficulty comes from the fact that the idea behind the code is not indexable, and once the idea is encoded its too late. If we could discover a way of describing the idea in some form that is at least structured if not concrete then we will be better able to leverage off that to get to a truly searchable library of code.

The internet is drastically improving matters. It is easy to extract keywords from your ideas and add 'download source C' and search. Unfortunately it will often still take as much time to tease out the nuggets or discover that there isnt one than it would to write the code in the first place.

Where are we going? How will we do this in 10 years time? Will Java be better once it grows up? Will there be another language that actually makes this possible, is is there already one?

Paul
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Friedrich,

Your points about market forces are valid. There isnt much to encourage us financially to avoid recoding the smaller things and, as C programmers nowadays working primarily on the smaller things, this is unlikely to change. I hadn't thought of patents and non-profit software being involved but you are right on both points.

I suspect/hope that the licensing system we have today will change. It is quite young right now.

I hope that an improved software design system will continue to eat away at the NIH issue. Maybe not but we can only hope.

Sparse markets, we have all seen, fix themselves in time. The web WILL become all-pervading but I believe it will go through a period of overload and unreliability before long. Perhaps deliberately caused but inevitable all-the-same. Once that phase is complete, with DOS, hacking, trojans, and spyware under control I believe it will become significantly more effective than it is now. How long this takes remains to be seen.

Ike,

Your vision of describing software with diagrams is inevitable IMHO. I have come to the same conclusion myself. We cannot continue to produce the effective, increasingly complex and integrated code we need while staying with text-based languages. What the programs will look like I have no idea and look forward to still being here when we find out. UML is a good start but it is still not sufficiently intuitive for the layman to code the business model while the programmer codes for the machine.

I love your idea that reinvention is also of benefit as a training and clarification exercise. I have never looked at it that way but I believe you are right. We must balance the time taken against the value of what we learn but it will never completely go away.

I suspect the software diagram will become both 3D and animated but that may be more of a hope than a wish. Modern games are already demonstrating that possibility with their fast and good rendering capabilities. Hardware assist is a must and is available right now. I sincerely hope that gesture-driven drawing packages like we've seen in movies recently will become common. We could use them for the design and modelling before any code is written and hopefully, the code generation will be automated to an increasing extent.

Any more thoughts? Once we no longer duplicate code but just connect up to a unit that has the capability we want, how would one global program running on millions of machines on the internet effect our lives? Sentience?

Paul
... Sentience?

And will we need to call in the Governor of California? ;-)

Paul
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want C you must be aware of the problems. java has it's own kind of problems.
And therfor it's not a fault of C or Java, it's how things are. And there are definitly not less ways of solving  a certain problem in Java then there are in C. And saying that Java is more portable as C is questionable also.

if you write ANSI C you can run it on more platform then you can run Java. and a lot of cross platform librarries exist which you can use for C programming, just a few example s a apr, the aolserver C stuff, libpcre, openssl and tons of others.

3) point three is a very loose understanding of Standards, and has nothing to do with what Standard stands for. the opposite is true you are talking about extensions to C which of course are not portable

4) is a FUD argument. C is much more stable then Java and C cod you one wrote has a good chance getting to compiled and run 10 years after it's initial version.

Friedrich
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DineshJolania
DineshJolania

Dear Friedrich,
And saying that Java is more portable as C is questionable also .>>Portability is one the best features  of Java.
Lets  take a ground to earth example " Say I create  a window with title  hello world". In Java you will have to write the
code once  and it will work on all flavours of OS. If you wrote in  C , for every OS you need to add /modify code.


3) point three is a very loose understanding of Standards, and has nothing to do with what Standard stands for. the opposite is true you are talking about extensions to C which of course are not portable >> Yes quite correct, what I intended to say was extensions to C and not Standards, thanks a lot  for correcting my mistake.

4) is a FUD argument. C is much more stable then Java and C cod you one wrote has a good chance getting to compiled and run 10 years after it's initial version.>>  Initially we used to follow  K&R style. Then came ANSI  style.
Then lot  of  code was changed to  support ANSI.  We felt that there are lot of flaws with C and later  C++ was  evolved (Which  repaired lot of things  from C ).
Then came  C++. Initially very poor version. We used to access private members through  member pointers. Then this was disallowed. Then came lot of rules.
We had  special style of casting  like const_cast etc.
We had mutable keyword,exceptional handling, templates.
We had inlining, etc.
We had local classes,nested classes  etc.


So my point is this evolution was not all of sudden. Years  after year , I saw this is supported and that is not supported. After  15 years of my attention  to C and C++ language, I am  not in  postion to say that  "Whether I know good C and C++".  This "good" and "more good" are relative.
You get 100 books on C and C++ which mentions about  "How to improve performance,How not to program,
What is bad and what is good, Effective C++".  More information creates more complexity rather then helping  here.
C allows every silly way to  "Solve any damn kind of problem" and this becomes the root  cause of the problem too.
But you get  very less books on Java on such topics. Why ?. why programmer has to bother about  what is  efficient what is not. Why he should take care of his allocations/deallocations.?( In C++ there are lot of jargons like
auto_ptr,vector, smart pointers).There are lot of rules when one uses Multiple inheritance.


Year after year macro's  were added  to allow more functionality.  For eg .

#ifdef __STRICT_ANSI__
#ifdef VAR_ANSI
#ifdef BSD_COMP
#ifdef  __cplusplus
Well I suggest you take apart C and C++. I'm talking about C. And C software has a astoning way of just "stay". And even if there are changes backward compatiblity is always very high on the priority list and in fact you can even nowadays compile K&R C.

Now you picked exaclty on example where Java is better than C. But how about command line utitlites? They are legion and they are practical, and the whole power you get on Unices is based on simple command line programs. Most of this things are written in C. So in fact my C toolchain is much better filled than anything else out there. Want a grep with Java? Good luck.

Now even for the GUI stuff there do exist portable solutoins. You can use
GTK+ e.g for C
or wxwindows or QT for C++

So with the proper libraries I'd argue C is not worse or better then Java.

I agree fully that having GC is a very very large plus for Java, and I wished C has something like this also. This whole manual memory managment is just stupid and should be done by  a machine. Now I'm using the Boehm-Weiser GC and I'm qutie happy with it.

I do not try to squeeze out the extremst mini optimization. the C code I write is hopefully boring. So boring that you even dare to put your hands on it to correct things ;-)

Now my opinion to C++ is the complete opposite, For me C++ is a not needed language. To many black magic behind everything. I do not use C++, and If I had to I'd write Eiffel in C++. I wiched Objective-C would have get the attention C++ has catched...

I suggest you check out Ocaml,Smalltalk, Ruby, Eiffel, Oberon, D or Objective C for a much better way on doing OOP.

Regards
Friedrich
Hi Paul,
IMHO, the difficulty comes from the fact that the idea behind the code is not indexable, and once the idea is encoded its too late. If we could discover a way of describing the idea in some form that is at least structured if not concrete then we will be better able to leverage off that to get to a truly searchable library of code. >> >
No doubt  idea behind  the code is not indexable. But at least   function name , symbols, macros, file name,include files ,global variables can be indexed  using a tool called  cscope. I have been using it  to search 1Gb  of source code.
The best feature which I felt was search using regular experssions.  I can mantain conflicting functions, duplicate functions. The most powefull of all  is "Find this egrep pattern" .
If we had names like   binary_tree1(),bin_tree2(),Binary_Tree3(),Bin_Tree4(),binarytreecreate()
then an intelligent egrep serach will be  [B]*[b]*in.*[t]*[T]*ree.
My point is you can capture "function names,symbols etc" using " Intelligent  egrep patterns.".
We can maintain a Synoname list  for  example  
"delete node" could  correspond to "delete item","delete stack","pop item".
We can use certain heuristic function to evaluate the search order  , for eg. "delete node"   most commonly corresponds to  "deleting an node from link list". We should give higher priorities to such cases.
The idea is to  "develop the  heuristic function which captures most of logical  ineference".
We can  very well use AI's "semantic N/W".

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It feels to me like we are moving towards Aspect Oriented Programming.

The concept here, if my understanding is correct, is that you write the code and then add 'Aspects' to it, say error handling or GUI. I am currently looking for an XML/HTML parser that I can not only use to pull data out of the file but then modify it and put it back in. If it was written in some form of AOP language I could probably bind the parts together in a far easier fashion.

Don't bother to look for one for me, there's far more I need from it than I can describe, and I think that is the core of the problem. I can describe several parts of what I want but not the whole of it. It would probably take me as long to unambiguously describe it as write it and even then, the description would only be of use as a reference, not as a search definition. In AOP you can obtain parts, put them together and, instead of the whole becoming the sum of its parts, like the bricks of a house, the whole becomes a true blend of its parts, like a gourmet meal.

Paul
Well maybe, but if you want something more flexible you should try a dynamically-typed language like Smalltalk or Common Lisp. Another question still open for discussion, do you understand what will happen with aspects? How will you be able to find out what aspects are implemented....

Regards
Friedrich
Hi fridom,

I am not deeply knowledgeable about AOP but I understand the intent is to separate different aspects of the code into separate, replaceable parts. For example, error detection and handling or file I/O can be completely removed from the code.

I could then find my XML parser and add aspects that conform to my requirements because the parser itself is EXACTLY an xml parser, no more. There is always so much hassle when you finally find the code you seek, only to discover that it requires another library, which needs yet another one etc. With AOP there are no side effects to inclusion, it just folds in and takes over its task and nothing else.

Paul
AOP is in first a new buzzword with a serious background. The static "programming" people have found that they need more flexibility. Their first tries (especially in the OO-Section) were the Design Patterns, a lot of them are a direct expression on the shortcoming of the popular C++ object model.

Now this "patterns" are much less needed in language which do offer more flexibility.
http://www.norvig.com/design-patterns/ 

Now they found out that they need something like specializin on more then one parameter. Now they found another thing. The objects are not extensible. If you have implemented a class you hardly can reopen it you can not simply add new things because that would break old things. For that the started working on AOP.

So the road is IMHO quite clear (and interesting), they postulate "static type safety", but they really are looking for weakin it in their "world view", because the used langauge does not permit easy extensions the must start working on giant frameworks to overcome the self imposed limit.

I bet most of this find they are working on "real advanced" stuff, and they are right. That is really advanced stuff for their view on the world of programming, but others simply do not have this problems because their tools allow for easy extensibility.

So what they really do they reinvent a wheel which other have solved since ages. So if you think AOP is the future then they simply have got you. It sounds impressing and "revolutionary" but it's in the end a work-around for limits put on them by their tools.

I suggest you check out the work done by the Haskell community, you'll be suprised....

I suggest also to check
http://common-lisp.net/project/aspectl/

Another good reading is "Essential COM" especially the first chapter.  

Regards
Friedrich
Hi Friedrich,

I had a look at haskell a while ago. You are right! They are doing some astonishing things!

I came across Corn a few months ago! http://corn.telefonia.pl/tutorial/index.html Again, a bit young for commercial use, and probably will never emerge! Imagine an oop language where classes can inherit cycliclically! They define a boolean class where an object of type 'false' is merely an inverted object of type 'true' and vice-versa. Take a peek at the tutorials. It'll mess with your head in a good way! :-)

I'm going back to look at Haskell again. I hope one-day it comes out of the purely academic environment into the 'real' world.

Paul
Haskell is quite "real" Just check out darcs
http://abridgegame.org/darcs/

and pugs:
http://pugs.kwiki.org/

A few other things worth checking:
Ocaml http://caml.inria.fr/
Mozart/Oz: http://www.mozart-oz.org/
Common Lisp
Scheme
Self

Regards
Friedrich
Excellent!

We've covered the main topic tidily. We've had some side-discussions about porttability and linguistics and several other interesting topics. Lets have one more look into the future.

Assume we do, finally, discover a way of properly taking what is in our minds and building it out of pre-fabricated parts such as sticks or bricks rather than the houses of sand we build today, where will the world of computers go?

I have to admit a little trepidation. It worries me somewhat that in a decade's time, the program I run to analyse the attobytes and femtobytes of data I will be working with may consists of millions of processes running on millions of processors around the world. The data transfer rate would have to be astronomical! Who will hold the purse-strings? How will terrorists 'use' this system? Will the system get near-sentient? Will we be negotiating with the Vodaphones or the Googles, the communicators or the databases?

And who will the huffers and the puffers be?

Paul