11 years ago I first encountered Java. Before then I mostly used C. I immediately loved how Java kept familiar C constructs but protected me from the most common, most difficult, and most time-consuming bugs. No more string buffer overflows? Awesome! Out-of-bounds array indices caught at runtime? Awesome! No need to allocate and (forget to) release memory? Awesome! No more core dumps? More than awesome! This is what I imagined programmer heaven to be like.
Even expert C programmers often wrote code that had buffer overflows and memory leaks. Making sure code didn't have such problems took a lot of hard-to-test mental reasoning. Introducing such problems in maintenance code was a continual danger.
I doubted that Java could offer these features while giving reasonable performance. And in fact, in early versions it couldn't. But over the years all sorts of optimisations have made Java performance adequate for most computing tasks.
Jump forward to today. My most troublesome bugs in Poker Copilot lie in a different area: concurrency mostly in the form of thread-safety. It's possible to have two or more pieces of code running more-or-less in parallel, accessing the same resources, sharing information, and needing to co-ordinate their activities.
Even expert Java programmers have trouble writing thread-safe code. Making sure multi-threaded code doesn't have synchronisation problems takes a lot of hard-to-test mental reasoning. Introducing such problems in maintenance code is a continual danger.
I use the Java concurrency API. It's good. It helps me a lot. I've read, re-read, and tried to grok Java Concurrency in Practice. It's also good and helps me a lot. But these are not enough.
What I long for is a language that's similar to Java but designed at every level to help write multi-threaded code. Something that offers me familiar constructs and concepts. Yet something that offers me better help for writing thread-safe code. Perhaps a language where objects are immutable by default, unless I specifically mark them as not immutable (Immutable objects make concurrency easier). Perhaps a language where I can mark a class as synchronized, which automatically makes all methods in the class synchronized (therefore ensuring that only one method in the class can run at once). Perhaps a language where parameters are passed as deep copies by default, or as copy-on-write objects, unless I mark them otherwise.
Many Java projects are riddled with obscure concurrency bugs. It's hard to get even the most basic code right, as I demonstrate with code to format a date as a String.
The Poker Copilot Blog
Tracking the development of Poker Copilot, Mac OS X software for poker analysis and statistics.
Saturday, 6 June 2009
C is to Java as Java is to what?
Subscribe to:
Post Comments (Atom)
Poker Copilot Translation Project
Want to use Poker Copilot in your language? Then help with the Poker Copilot Translation Project.
Blog Archive
-
▼
2009
(337)
-
▼
June
(29)
- Poker Copilot: One Year Old
- Poker Copilot 2 Early Access Program Update
- Poker Copilot 1.76 Released
- A Lousy Poker Copilot Week - And a New Feature
- Stuff from Aidan + Posterous = Instant New Blog
- Food, Inc
- Poker Copilot HUD always on?
- Sub-Millisecond Query Optimisation
- Poker Copilot 2 Early Access Program Update
- Multi-table HUD demo
- What's Poker Copilot Missing that Hold'em Manager ...
- Finding Memory Leaks in Cocoa + Objective-C
- FastSpring and Credit Card Fraud
- Does Poker Copilot have Ongame Network Support?
- Poker Copilot 2 Early Access Program Update
- Poker Copilot Tutorial in French
- Mac-ify your Full Tilt Poker
- Why does Poker Copilot talk to the Internet?
- Poker Copilot's Crash Reporter
- Sentence of the Day
- What I've Been Reading
- Obscure Sentence of the Day
- Cha-ching!
- Statistic of the Day
- Hero Stats for Current Table Only
- Poker Copilot 1.74 Released
- C is to Java as Java is to what?
- Competitors for Google?
- Poker Copilot goes Cyrillic?
-
▼
June
(29)


4 comments:
I have no idea what Im talking about but cant you just develop with Xcode?
List of concurrent programming languages: http://en.wikipedia.org/wiki/Concurrent_computing#Concurrent_programming_languages
I don't think any satisfy the familiarity requirement (Join Java only exists in thesis form). Scala supposedly (no first hand experience) inter operates well with Java and would seem to be a good bridge to functional programming.
It's conceivable you could write Java methods in the FP style (methods don't change data, only return new data) but that seems a pain as well as wasteful.
I can't say much because of the NDA, but I was at the WWDC a couple weeks ago, and just wait til the new version of Leopard/XCode comes out. You will have to use Objective-C, but there may be a very elegant solution to the multi-threaded issues you're talking about.
Then again, maybe there won't be... I can't say for sure :)
Check out Objective Caml. It's not especially tailored to writing multi-threaded applications, but it satisfies many of your other requirements (e.g. immutability by default, familiar OO idioms). It's mature and has a large user community (many academic, but quite a few industry folks).
Post a Comment