Hm, and total_count should be incremented with count* not out on its own. There’s a chance we don’t find a spot or an item.
A) Why bother using (fixed-length) arrays if you don’t do anything with random access and just iterate through all the time? Might as well use linked-lists. Alternatively, go for a more sophisticated hash-table implementation.
B) Surely what the OP is looking for is more than just an implementation of multisets (that is, more than just keeping track of how many occurrences there are of particular product ids within the last MAX_LINK_COUNT many)?
Yeah, you really have to tell us more of what you want to do. Maybe you want to hook up a PDA to a barcode scanner and walk around a store using it. In that position you’d have to ask what runs on the PDA (probably c++, but maybe something higher-level). In any case you have to tell us whether you want a GUI and what kind. (If you don’t want a GUI, then it’s much easier to go with a lower-level language like C++. If you do want a GUI, then that leads to the big question. A Windows gui? A Web gui? A PDA gui?).
Because it’s demonstration code, not release code.
You’re looking for a way to limit to the top X number of products that were bought by the same people. What items constitute the top X is going to vary with time, with some entering it only briefly, while others remain for a long time. So you could track same purchases per time for each month, but then you have to store a whole bunch of data and track every single product that was ever linked to this one. This class lets items make a stab at entering. If they’re popular enough they’ll wear down less popular items and enter the list. If items that are on the list aren’t popular, they’ll wear down fastest, while as ones which continue to be popular will keep popping their count back up as other clash to get in. Think of it as a mini-evolution system where the strongest at any given moment are the ones who make it into the running. But you don’t have to track a whole lot of data to accomplish that task.
Maybe this is a complete misread of the OP, but perhaps what is really needed here is an excuse to relearn programming.
I vote for C# because it is nicely tidy and consistent in its syntax, and it is well supported for the Windows platform, and Microsoft makes it so easy to get (VisualStudio with several languages is cheap, and (at least a little while ago) you can get a version of VisualStudio with C# for free from Microsoft.com. It uses the .NET framework, which provides all the Windows forms for GUIs and offers “managed code” that automates the checking of certain things like out-of-bounds array indices that often lead to bugs (in doing so it prevents certain kinds of security problems). I got an introductory book by Jesse Liberty that explained it quite clearly and pleasantly.
C# and C++ and Java are so similar in their syntax that many things look the same between them, or differ only in some minor way like a semicolon at the end of a line.
In any case, object orientation will be the big new element of programming, if you’ve been out of it long enough.
I vote for Eiffel!
Actually the only time we used Eiffel is when a customer wanted us to move a program out of Eiffel into Java in a week. I don’t know whether we ported the code or just rewrote the code, but it got done.
I’d look at Haskell or O’Caml for this (or if you need access to the .NET libraries, take a look at F#).
Here’s an implementation of a weighted slope one collaborative filtering algorithm in 29 lines of Haskell.
For instance, here’s a series of blog articles on functional programming and collective intelligence. They use F#, Microsoft’s version of O’Caml/SML. The languages are close enough to probably do a direct translation, if you don’t want to be tied to Windows/Mono.
Just for reference, this is how Amazon’s system works.
(IMHO) Java and Perl.
With one you can write many disparate types of programs and deploy them on a great multitude of architectures. With the other you can glue together anything you want.
I wouldn’t dream of deploying Java applets, which were supposed to become what Flash is.
However, Java is very well suited to back-end processing, there are loads and loads of web sites out there running on a Java server, such as Tomcat or JBoss.
I guess if you are doing heavy duty particle physics modeling then Java might not be the tool :).
In my world, we are typically database and network bound, so the total round-trip experience might break down to ~1ms due to Java, ~500ms due to the database, ~200ms due to the network.
I suspect the OP picked a language a half decade ago.
This ZOMBIE seems to have been revived by a spammer. Reported.
I vote for ** Zombie ** :eek:
Everything written in all the above posts 5 years ago is obsolete today.
But the determined real programmer can still write FORTRAN programs in any language!
I am currently learning Go, only a few years old. Developed by Google, it seems to be getting a bit of traction as a systems development language for the Internet age. Has concurrency built in for multi-threading, which I need.
However, it is ‘horses for courses’, choose the language which has the emphasis and features you require for the job in hand and also has a style that makes it easy for you to be productive. Languages used in large enterprises are rather different beasts to those used for the Web.
There is nothing that can be all things to all programmers, they all have strong and weak points. A zero sum game, I think.
Go is the first mainstream language I’ve seen that really does concurrency well. (Except for Erlang, but everybody seems to hate Erlang except me.)
I’ve been really into Scala lately. Java-ish syntax, but much more compact, and with functional extensions. The Akka package provides large-scale concurrency in a way that I am told is Erlang-like (I don’t know enough about Erlang to compare).
On what kind of platform were you planning on running this software?
I mostly use C# nowadays, but then I do a lot of web-based work and it is one of the standard languages for web applications. C# is also good for standalone Windows applications and console applications, but is very difficult (but not impossible) to use in a Unix or Unixlike environment, such as the Mac or Linux. Almost nobody does C# development on the Mac anyway so you’d be struggling alone with a lot of minor technical issues (why is it still throwing a file access permission error? !@#$) rather than spending time actually building your application.
C# is actually pretty close to Java in terms of its paradigms. They are both object reference-based languages with garbage collectors that have a C-derived syntax.
Javascript, on the other hand, is an entirely different beast even though it looks very much like Java, C#, and C++. Javascript is a duck typed language, very loose.
I disagree. Python is my favorite scripting language (and I routinely use a half-dozen of them and have used many others over the years). But it’s not particularly good for a beginner due to the way it’s documented.