p2p programming languages
June 2, 2004 9:29 AM   Subscribe

If you were writing a new p2p application -- leaving ethical and legal issues aside for a moment -- which programming language would you use? I know Visual Basic and PHP, but neither is really any good for this purpose. I dislike things that require the user to install a big VM (.NET, Java) and find C++ a complete nightmare.

Forgot to mention: cross-platform and/or open source would be excellent, but not required.
posted by reklaw to Computers & Internet (36 answers total) 1 user marked this as a favorite
 
Combine the wxWidgets toolkit for the GUI, and use your favourite language.

I'd say perl, python or C++.
posted by cmonkey at 9:35 AM on June 2, 2004


Python. Open source. Free. Cross platform. Compiles to Windows exe.

But if you find installing .NET or Java too nasty, and C++ is too heavy for you, such a project is certainly over your head anyway IMHO. Seriously.
posted by y6y6y6 at 9:40 AM on June 2, 2004


Does .NET require anything for current XP users? I know that's not everyone, but it seems like most Windows users would already have the .NET runtime by the time your app is ready. I only ask because C# or VB.NET would probably be the easiest thing for you. Otherwise, what y6^3 said. Either part.
posted by yerfatma at 9:54 AM on June 2, 2004


Response by poster: wxWidgets is excellent. I was aware of it but didn't know it supported so many languages. Python looks best, as y6y6y6 says, although I am badly tempted by wxBasic.

I don't find installing .NET or Java too nasty (I have both installed), but I don't want to force all my end users to install them. People have outright boycotted p2p apps before over being forced to download the .NET runtime -- Overnet, for example, was forced to abandon it because of the user backlash. I'm pretty sure that XP doesn't come with .NET as default yet, unless they sneaked it into a service pack -- even then, not everyone would have it. Java is just slow and sucky (see: Limewire) as well as needing to be downloaded from Sun.

As for C/C++/C-anything: no. It's not that they're "too heavy" (please), it's just that they're bloody awful. They lack a coherent way of doing anything useful, and encourage bugs -- as much of the software written in them today shows. I accept that some people will never want to move away from C-based languages and all the screwy backwards-compatibility and outdated standards they entail, but I have no desire to actually learn one in this day and age.

Really, it'd be nice if there was a network-focused language for this sort of thing with a nice way of handling connection states, client-server communication and such, but I don't think such a thing exists (unless Python does the job, of course -- I'm yet to look at it in depth).
posted by reklaw at 10:22 AM on June 2, 2004


People who would be interested in a P2P file-sharing app would not find it onerous to install .Net or Java since they surely have already done so. And it's a useful filter for weeding out stupid users. If they boycott your app, you don't have to support their asses, which is a huge win for you, because supporting the clueless will consume time that would be better spent developing.

Java is not slow and sucky -- Limewire is slow and sucky. Check out Eclipse, a Java IDE that is written in Java -- it is neither slow nor sucky. The company I work for does all its development in Eclipse. Our product (which is written in Java) is also neither slow nor sucky. Other Java applications that are neither slow nor sucky include Xnap, Jedit, and Acquisition (a Mac Gnutella client).

I would suggest Java if only because it makes it trivial to port the application to more than one platform (just some UI tweaks, if that) and if your app is any good, people will want to do that. Also, its networking support is quite good -- it's the closest thing you're going to find to a "network-focused language," I think.
posted by kindall at 10:48 AM on June 2, 2004


Response by poster: Hmm... interesting. I'm not sure refusing to support a whole section of the userbase that doesn't want to download ~15MB of Java (Java being even less used than .NET, generally -- I can think of few programs that require it) is such a good idea, but still. Eclipse sounds nice, and so does wx4j (wxWidgets with Java) from cmonkey's link, come to that.

If I'm going to go down that road (the making-people-install-VMs road), though, I might as well be using VB.NET, I suppose. Tough decisions.
posted by reklaw at 11:11 AM on June 2, 2004


windows doesn't have java or .net pre-installed? i would see maybe not having java if they had .net, but neither one seems weird.
posted by rhyax at 11:52 AM on June 2, 2004


If you go with .net you cut out a section of your potential users. Maybe you care, maybe you don't. I'm not talking about ideological reasons, I'm talking about operating systems other than Windows.
posted by substrate at 12:16 PM on June 2, 2004


Response by poster: Well, I know my copy of Windows XP didn't come with .NET -- it was an option in Windows Update's 'Windows XP' section (ie. not 'Critical Updates and Service Packs', which are installed automatically). It was in the same place as things like Windows Media Player 9, Windows Movie Maker 2 and whatever the latest version of DirectX was.

That said, maybe it comes with new computers and newer copies of Windows XP now -- like I said, maybe they even sneaked it into a Service Pack at some point. Even so, given the way Windows users tend to upgrade things, I think the people with .NET installed are very much in the minority.
posted by reklaw at 12:17 PM on June 2, 2004


Response by poster: Slightly-too-late-for-on-preview: Isn't there a free software implementation of .NET anyway? I can see why Java might be preferable, though.
posted by reklaw at 12:19 PM on June 2, 2004


Isn't there a free software implementation of .NET anyway?

Are you thinking of mono? I haven't heard much about it in production environments yet, but it has a strong pedigree.

I second y6y6y6's python suggestion, it seems ideal for what you're looking for.
posted by cCranium at 12:29 PM on June 2, 2004


Why are you creating a whole new P2P app, anyway? It seems to me that all the heavy lifting in that area has been done, and that the work that's currently being developed is in the trickier areas like anonymous, encrypted transfers and highly segmented downloading. If C++ scares you, P2P networking is going to give you cold sweats and nightmares.

Unless you have some very specific niche you're going after (or want to use it exclusively on a closed network), or are just doing this on a lark to "see if you can do it", you're just going to wind up re-inventing Gnutella.
posted by mkultra at 1:09 PM on June 2, 2004


Java less used than .Net? Are you kidding?
posted by five fresh fish at 1:29 PM on June 2, 2004


If I were designing a new P2P file-sharing system, the language to implement it in would be pretty low on my list of major design choices to think about.
posted by Mars Saxman at 1:37 PM on June 2, 2004


+1 for Java.
posted by trillion at 1:44 PM on June 2, 2004


Microsoft Windows comes with the MS Java VM installed. The .NET Framework is an option you can select at Microsoft's Windows update site.

Both Java and .NET implemenations are free. Do not confuse the retail product Visual Studio .NET, which is a development IDE like Eclipse.

Eclipse is nice, and it is fast.. but Java apps always look sort of twitchy.

I would say, based on your requirements, to use Java. However, if you are more familiar with writing in VB and you decide to limit the app to Windows-based systems, then you may just want to stick to a VB/COM+ sort of app, which can run on any default Windows system.
posted by linux at 1:59 PM on June 2, 2004


I'd also vote for Java. There's a freely available P2P API developed by Sun called JXTA that could really help with some of the difficult parts of what you're doing. Having a relatively mature API to work from will make it quite a bit easier, especially if you're working in a new language.
posted by freshgroundpepper at 2:01 PM on June 2, 2004


Response by poster: Wow, lots of replies that I can't help but respond to.

It seems to be between people recommending Java and people recommending Python at this point. I can't say I'm exactly mad keen on Java's syntax, but I'm sure I'd get used to it. Python just appeals to me more for some reason, though. Python is, after all, free of all the framework bloat, and it's open source, too.

Oh, and again: C++ doesn't scare me. C++ zealots are second only to GPL ones, it seems. I just think that the way C++ does this is terrible for no good reason, and other languages do things much better.

For all the code-reuse people: What I'm planning to do here isn't something that's been done before. I'm quite familiar with how Gnutella works (heck, I can tell you in protocol-level detail how bloody Napster worked, and more besides). I have no desire to recreate an existing system. The newness of this whole thing is the reason I asked about languages in the first place -- I could have just done it in VB, but it wouldn't have done the concept justice.

I have the network itself mapped out in quite a lot of detail. Its core is something like fasttrack, only with social-group type stuff added, including persistent user recognition (something sorely lacking from nearly all decentralised networks). There's more than that, but I don't really want to give it all away.

Am I going to come unstuck in a big way at some point? Probably. But it's worth trying.
posted by reklaw at 2:31 PM on June 2, 2004


It's been done with Python. The Bittorrent reference implementation was written this way. You can get source here.

I've used it. Works just fine.
posted by bonehead at 2:52 PM on June 2, 2004


if I'm not mistaken, Napster was initially written in VB... I wouldn't use it, but hey... do an initial version in VB and port to a real language once you've got the P2P crap sorted out.
posted by krunk at 6:14 PM on June 2, 2004


Python is, after all, free of all the framework bloat

The framework bloat is what makes writing a p2p app in .Net or Java extremely easy. With less (relevant) framework, you get to write more code.
posted by Kwantsar at 6:31 PM on June 2, 2004


No one forces you to use libraries when you use Java. and you don't have to run java code on a VM. It can be compiled and if you don't use APIs that aren't already in libgcj, then you'll have less of a problem getting an executable. I'm not a fan of java but it's got good development tools, a large set of existing libraries, a large community of people who understand it, and you get (somewhat) cross platform for free while you're doing the development on the VM.
posted by rdr at 7:18 PM on June 2, 2004


PHP/GTK is an option but I don't know anything about its' performance.

Mono for Linux/Windows/Everything is an open source implementation of .Net, along with many libraries such as GTK# for your UI. It might be interesting to try MyXAML later on too.

MS.Net programs can be turned into a standalone executable but I don't know whether thinstall supports mono. It does mean you don't have to give a huge runtime to your users though as it strips the libraries unused and statically compiles the app.
posted by holloway at 7:34 PM on June 2, 2004


Response by poster: krunk: I've been tempted to do that, but have you ever tried to write stuff using VB's winsock-controls model? It's damn near impossible to make it work right.

Given rdr's comment, I think I'm about ready to give in to Java -- it didn't even occur to me that a free-software Java compiler (that is, GCJ) might exist, for some reason. It's nice to know that there's an open .NET around, too.

So, follow up question: what's the best way to start learning Java?
posted by reklaw at 7:54 PM on June 2, 2004


The same way you learn any new language: Go to the source (in this case java.sun.com, check out the tutorial to get the basic datatype and language structure, or follow one of the charts on the differences between C++. Do a couple small tests to see how the module, package, class and interface structures work, then read other peoples code that does simple things along the base level of the protocols you are using, for example, simple test scripts using the socket libraries. If you know other languages (particularly C++), you should pick it up pretty quick. It is not as elegant as python, but doesnt have the nightmare of datatypes and potential memory leaks that are so rife with C++.

(im just starting to learn python, myself, I do like Java, but my current job I am constrained to scripts and legacy PERL has given me too many headaches this year)
posted by lkc at 8:04 PM on June 2, 2004


Another vote for Python. Cross platform. Good libraries. Sufficiently high level for easy prototyping. Numerous app frameworks - Twisted might be good for this space. Lovely clean, compact syntax.

If you are really going to commit to Java, understand that much of mastering Java is actually mastering the huge API. The language itself won't present much of a challenge to anyone familiar with a C-like syntax and OO basics, but it takes a long time to get your head around all the facilities available, which ones to use, and which to avoid.

I would also use a decent IDE that saves as much typing as possible. You can write java with a text editor but it's pretty laborious, and I find myself fat-fingering bigLongInterCappedNames all the time. (OTOH, if you're a VB guy, you're probably used to this ;-) ) Eclipse is good and free.

Java does have the advantage that it is probably a more saleabe skill than Python, thus you personally might benefit more by learning it. I'm right now supported by Java (and a little Tcl). I would love to deploy my Python-fu for money, but it hasn't come up yet.

You realise that you can distribute standalone Python executables, don't you?

It sounds to me as though your major challenges are in the design of the system, not the implementation language. Therefore, I would advise that you choose the language that appeals to you most. Once you like your design, and more, other people like it, you can always port it. Better yet, publish your protocols, and let other people implement it on their own platform of choice. Your system will be far more attractive if other people can write compliant clients themselves anyway.
posted by i_am_joe's_spleen at 9:00 PM on June 2, 2004


Response by poster: I am a bit torn between Java and Python. I'm told both are good, and I can see the appeal of each.

I reckon Eclipse might end up being the clincher in this deal. I was tinkering with wxPython and Boa Constructor earlier, and it was just dire -- I had to fight the IDE to make it do what I wanted (after spending about half an hour to make the thing even run). Eclipse, on the other hand, is nice, and Java in general seems to have a lot more support thrown behind it by people who can make my life easier -- at least from what I've seen. I'm not even slightly used to typing out long names -- VB does that for you, with a little dropdown that appears where you're typing, making sure you get the name right. For all the sneering VB gets, it certainly has a good IDE -- one of the few I've seen where placing controls on a form doesn't turn into some Borland-like nightmare.

Oh, and I am intrigued by your mention of Twisted -- will investigate further.

It looks like I can distribute standalone executables of Python, Java and even .NET -- it's just a matter of difficulty. Python would definitely be easiest in this regard, with Java requiring me to play around with one of those too-snooty-to-work-on-Windows-properly free software compilers, and standalone .NET (with something like thinstall) requiring me to pay quite a lot of money, by the looks.

I've already more-or-less written the protocol/network-design/etc., but I have to get it working myself first -- mainly because there might be something I've overlooked, or assumed will be unrealistically easy. If it took off, I'd be delighted to publish the protocols and let someone redo the whole thing (in C++, more than likely, for some strange reason I don't seem to be privy to). Oh, and the idea of acquiring saleable Java skills made me smile -- I'm actually going to university quite soon to study english literature or journalism. Barring something very strange indeed happening, I probably won't be getting a job that involves programming...
posted by reklaw at 9:23 PM on June 2, 2004


Another vote for Python; I've written a very extensive app/website in Python, (~30kLOC) and these days I spent most of my time in C++. Python will a) get you up and running in no time (e.g. you can subclass a Web or plain TCP/IP server and start responding to basic socket/ftp/http/telnet/pop/imap/whatever requests within a few minutes of coding, b) it will have very acceptable speed for almost everything, c) Python lets you refactor more easily than anything I've seen ever: your prototype will end up being your production app, d) Python has enough hooks to everything else to not lock you in (easy C++ extensions, native JVM implementations, JNI and .NET bridges).

My advice: prototype in python, validate your design, and if you notice slowdowns, recode the slow bits only in C++ and wrap them in Python to interface with the rest of your code.
posted by costas at 9:36 PM on June 2, 2004


On the other hand....

GCJ isn't going to get you all the nice (ok, not really nice) java UI stuff and windows support is probably going to involve installing cygw in. Just a warning.
posted by rdr at 9:46 PM on June 2, 2004


Yet another vote for Python; costas is spot on. If platform agnosticism is a major design goal, I'd say forget Windows/.NET/VB/C#/whatever - it ain't worth the grief. It can be done in Java, but there's fewer headaches in Python.
posted by normy at 9:51 PM on June 2, 2004


Response by poster: But is there a Python IDE that comes anywhere near Eclipse's standard? Or, hell, even works properly? I like Python, but the quality of the tools surrounding it (on Windows at least) leaves a lot to be desired. Maybe using VB has turned me into some kind of IDE sticker, but I'm not especially fond of doing things in notepad/textpad/whatever. That said, I do it for PHP, so maybe it wouldn't be all that bad once I got used to it.

I'm flip-flopping on my decision here. The further I look into Java, the more it looks like overkill -- and it's not as cross-platform friendly as Python, if you're going for native code. wxPython seems excellent.

My kingdom for a decent Python IDE that lets me design forms properly, then. I'm not just being insanely GUI-centric here: the GUI part of the app is a big part of what I'm trying to do. Without a decent interface to go with the network stuff, the thing won't fly -- I'm sure of it.
posted by reklaw at 10:22 PM on June 2, 2004


Well, I don't do much GUI work, but I love PythonWin (which comes with the win32all extensions for python, linked from the python.org download page): Windows only, but it also shows you what can be done in Python (PythonWin itself is in python, wrapping MFC through win32all). If you want wx, Boa Constructor sounds like your best (free) bet; but as I said, I am not a GUI guy. This recent /. thread should cover the IDE question.
posted by costas at 10:50 PM on June 2, 2004


I believe that Komodo might be what you're looking for.

In Linux land, Glade and the relevant Python bindings will let you design GUIs in a graphical way.

BTW, Tcl/Tk might be worthy of your consideration.

Personally, I find IDLE is OK, but my GUI needs are simple. It pops up method signatures and has a class browser - that's enough for me.
posted by i_am_joe's_spleen at 11:14 PM on June 2, 2004


Ah, here we are.
posted by i_am_joe's_spleen at 11:16 PM on June 2, 2004


If you're fond of Eclipse, but Python sounds tempting, why not use Eclipse to write Python code?
posted by majick at 6:58 AM on June 3, 2004


Response by poster: Wow, Komodo and Eclipse-with-Python both work very well for writing straight python, and for its sheer simplicity PythonCard (from the /. thread) is excellent, too. Doing the GUI entirely seperately in wxGlade seems to be the best way of doing it, instead of using a complete code-and-GUI IDE like Boa Constructor tries to be.

Thanks to everyone who helped me in this thread.
posted by reklaw at 3:50 PM on June 3, 2004


« Older Quiet bar in NYC   |   prepaid cell phone advice Newer »
This thread is closed to new comments.