Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Are you blurring the difference between a "crappy" algorithm and a poorly written program that uses that algorithm? If the quicksort algorithm is "crappy," why does your program at least seem to use it when it tells your computer how to partition the list it the list the machine sorts?

Crappy algorithm because of the pivot selection algorithm used. Crappy style because: it doesn't use the language libraries to increase the readability, it allocates new arrays on each call, it uses arrays and the function takes the length of the list as an argument (C guy who just learned C++?).

Why use arrays instead of iterators? I don't know. Maybe iterators need more overhead than arrays do. Even if you do use an iterator instead of an array, what kind of data structure represents the list while your computer partitions it? That list just might be in an array.
The iterators for arrays are just pointers, and arrays decay into pointers at function boundaries anyway so, there is no overhead.
By using iterators you make sure your algorithm can work with any linear sequence that provides random access. The whole point is to not care about what kind of data structure you are sorting. You see, now the C++ version is even more generic than the Haskell solution!!

.. to a guy who earned a philosophy degree.
That explains a lot.
 
Just download the source code and compile it yourself from http://www.erlang.org. It works a treat.

I NEVER use Macports or Fink. Its always much better in my opinion to compile it yourself so you can enable or disable features as you need them.

Just issue the following commands to get it installed and working:

Code:
./configure --enable-threads --enable-smp-support --enable-kernel-poll --enable-sctp --enable-hipe --enable-native-libs --enable-shared-zlib --enable-darwin-64bit --with-ssl --with-javac --with-termcap --enable-dynamic-ssl-lib

Code:
make

Code:
sudo make install
When I did what Cromulent suggested, a program still ended abnormally when the computer said, "Permission denied." Maybe I made a mistake?
 
Crappy algorithm because of the pivot selection algorithm used. Crappy style because: it doesn't use the language libraries to increase the readability, it allocates new arrays on each call, it uses arrays and the function takes the length of the list as an argument (C guy who just learned C++?).
That is a bad way to choose a pivot. Unfortunately, the Haskell quicksort tells the machine to choose it that way. But the quicksort algorithm doesn't force anyone to pick the first element as the pivot. Your earlier post suggested that the quicksort algorithm was crappy, not that the Haskell program was crappy because it told the machine to use a lousy way to pick a pivot.

The iterators for arrays are just pointers, and arrays decay into pointers at function boundaries anyway so, there is no overhead.
In C, an array name stands for a pointer that points to the array's first element. If an array consists of a collection of data that live in consecutive storage locations, you might need a pointer even when you're sorting an array.

By using iterators you make sure your algorithm can work with any linear sequence that provides random access. The whole point is to not care about what kind of data structure you are sorting. You see, now the C++ version is even more generic than the Haskell solution!!
That's a good point. But Haskell is not, and has never been, object-oriented. It's a purely functional language where you don't mix programming paradigms. If I want to write an objected-oriented program, I'll write in an object-oriented programming language. I'd rather not mix paradigms.


That explains a lot.
For example? By the way, I have two degrees. The first was in Data Processing, and I programmed professionally before I earned the Philosophy degree with a minor in Computer Science.

You might be surprised to know how much philosophy can help a programmer. Philosophy is largely about abstraction. So is programming. A few courses in logic help a programmer, too. I specialized in logic when I earned my philosophy degree. If you compare logic the discipline the first-order predicate logic and sentential logic, you'll know that mathematicians and computer scientists ignore many of logic's subfields. In some of those subfields, abstraction seems more important than it does in OOP.
 
Last edited:
Which folder did you download the source code to then? Sounds like you tried to do it in a place you don't have permissions.
I downloaded it to my homdirectory's "Downloads" subdirectory, moved it to /usr/local/src, untarred it there, ran the configure script, and ran make with sudo. Building progressed much farther than it did before it ended abnormally. Now the computer seems to loop infinitely when it's running erlc. With the "top" command, the machine says that erlc is occupying about 127% of processor time.
 
I downloaded it to my homdirectory's "Downloads" subdirectory, moved it to /usr/local/src, untarred it there, ran the configure script, and ran make with sudo.

Don't do that. Just keep it in your home directory and run the commands exactly as I posted. In that order. It will then install in /usr/local.

Which version of Mac OS X are you running? Do you have the latest version of Xcode installed (not that it really matters but if it is ancient it might make a difference)?
 
Don't do that. Just keep it in your home directory and run the commands exactly as I posted. In that order. It will then install in /usr/local.
All right, I'll do that. I need to stop acting as though I'm still running my Sun machine. Ooh, I miss the poor old guy. :)

Which version of Mac OS X are you running? Do you have the latest version of Xcode installed (not that it really matters but if it is ancient it might make a difference)?
I'm running Snow Leopard, but I don't know its version number. I got the iMac about five months ago.
 
If you want to be a good professional programmer, you should learn more than one language.

If you want to be a good programmer, get a couple of books on algorithm analysis and data structures and consider a university degree.
 
Don't do that. Just keep it in your home directory and run the commands exactly as I posted. In that order. It will then install in /usr/local.

Which version of Mac OS X are you running? Do you have the latest version of Xcode installed (not that it really matters but if it is ancient it might make a difference)?
Thanks, Cromulent. Erlang works.

Bill
 
Please could someone advise me on what programming language to learn first, I have no programming experience. I would like to learn something that will be beneficial and recognised to help me start a career in programming?
Also what tools would I need to learn the suggested language?

Thanks

I've just noticed this new book in my Safari library. I can't vouch for it, I have got time right now to look at it, I consumed with studying Mandarin. I just thought I'd put it up here because there's been a few posts asking how to start with Mac programming, it might be useful.

Wang, Wallace (2011) Mac Programming for Absolute Beginners, Apress.

More info at: apress.com/book/view/1430233362
 
I remember learning Basic as a kid from books obtained from my local library. These books were illustrated with robots that had words on them like "print" and "let". The illustrations shows the robots doing things with data represented as cubes with 2 or "hello" in them. For example, I'd see a "let" robot put a data cube into a box labelled "A".

I'm forever thankful for starting as a kid with these kind of books. I think they were responsible for giving me a really solid foundation. And my transition from procedural to OOP was also relatively easy. I just when back to thinking about the robots again. But now the robots had boxes inside them, and they started talking to each other.

large.cgi


I had those too!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.