Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
Clearly this is a metaphor for something.

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


                     

algorithm library

Language independant algorithm library
 
(+1, -1)
  [vote for,
against]

Have you ever had a form on a web page or in a GUI application that asked for an email address? If so, you probably Googled for 'email address regex' and used the first complex looking match not posted by someone named L33tz_PHP_k|d. Or, possibly you lucked out and your programming language of choice provided a email address validation function, but you still had to scour the docs to find it. This happens all the time when programming: 'I need to validate input, or generate output that is defined in some RFC or standard somewhere, so I get to spend 15 minutes searching for prior implementations or reading the standard and figuring out the proper way to do it.'.

Now the idea: Define commonly used algorithms in a programming language independent XML format. Run a single command that converts the XML to each programming language, and puts the results both in a single large library file, and a small file for each algorithm's function(s).

For the email address validation example:

/usr/share/algos/email_address.xml:
<function name="check_email_address">
<arg name="email_address_to_check" type="string" />
<regex pattern="[...]@[...]" against="email_address_to_check">
</function>

root@host:~# update-algos
Generating email_address.php
Generating email_address.py
Generating email_address.rb
Generating email_address.pl
Generating email_address.h
Generating email_address.o
Generating algos.php
Generating algos.py
Generating algos.rb
Generating algos.pl
Generating algos.h
Generating algos.a

Then, if you just needed one function you could include/link against the smaller file, and if you needed many functions you'd use the large file with all functions.

The benefits of this idea are quicker and more reliable programming, and a distributed way of improving the algorithms.

There are a few low profile algorithm library sites, but they don't have many listings and they have no way of generating functions for different programming languages.

zone, Nov 07 2003

Dictionary of Algorithms and Data Structures http://www.nist.gov/dads/
[Extreme Tomato, Jul 30 2005]

[link]






       To answer your specific problem: why should I waste my time validating an email address with a regx? After all, that's still not going to tell me if it's valid (blah@wasted.pox is not exactly going to get you anywhere). Simply send an email to the entered address and see if you get a response. (And there are algorithms posted on the Internet for that, I've seen them.)   

       And more generally, if we follow your route, we end up no better than the script kiddies who understand nothing of what they're cobbling together from stolen code. It is not hard, and often a constructive exercise, to translate from one programming language to another.   

       Many have published algorithm libraries in book form. If you want a web site, go ahead and run it.
DrCurry, Nov 07 2003
  

       It is an interesting idea, but I think that XML-to-random-language bit is going to be a tough nut to crack. It might be easier to just recruit multilingual volunteers to translate each algorithm by hand.
krelnik, Nov 07 2003
  

       I sort of agree with [DrC] here; it will make learner programmers lazy, but then, aren't most programmers lazy anyhow?

The thing is I really do like this idea, it could be a godsend to people who need an algorithm right there and then. (+)
silverstormer, Nov 07 2003
  

       First Good Idea.   

       Generating Code from the algorithm is a good idea also.   

       Explore it little bit. How would you do it.. : For example Merge Sort.   

       We should have clearly defined components for this to work.
artist, Nov 07 2003
  

       Generic patterns are well understood and documented in "language agnositic" ways for more complex solutions.

There is also the concept of "native" methods in some languages - say you know how to write a string validation function in C but have been asked to provide the same result in Java; you could call a native C method from java without rewritting. I like to think this is the best approach for simple functions (such as the example) and is probably part of the driving design behind MS's Common Runtime Library.

Of course the fashinable way would eb to write service providing software all the time - and rely on one common data description language. Which pretty much describes web-services.
  

       I really like this idea. I like the idea of having a corpus of well-written algorithms out there that people can use in any language.   

       I guess you'd have to sort by language families (OO, functional, procedural) but that's OK.   

       Do formal methods specify algorithm description languages that could be used?
stevec2, Jan 26 2004
  

       I agree that this is an interesting idea, but many hurdles come to mind. Data typing and whatnot could get tricky.   

       It also wouldn't be too difficult in theory to write the algorithm in c++ or whatever and then convert to the XML language algorithmically.
pawebb, Feb 23 2004
  

       An algorithm is an effective procedure for enacting a mathematical function. By "mathematical function" I don't just mean sines and cosines and stuff but in its more formal sense of a relation that uniquely associates members of one set with members of another set.   

       So for any given function there may be many different algorithms. They all perform the same function of course, but they vary in their efficiency on different inputs. eg. Some sorting algorithms are more efficient at sorting partially sorted data whilst others are better at really unsorted data.   

       My suggestion is that the database could use the function as a search key and return all the algorithms that perform that function together with their time and space complexities so that the user can make an informed choice about the one to select.   

       How to specify a function? You could use search terms such as "sort" for well known functions. Another way would be to allow users to specify a function by writing a simple but inefficient algorithm that perfoms it.
k9island, Mar 11 2004
  

       The thing you're describing would be yet another programming language. Except a really ugly, hard to read one that nobody speaks.
(In other words, there's no such thing as a "language-independent language". There's just yet another language. This is true for human linguistics as well.)
  

       Wouldn't you be better off just using some of the existing languages? For example, if someone started writing really good algorithm examples in a subset of python, you could probably translate that to C or Java or Perl without too much trouble.
jutta, Jul 30 2005
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle