I've been having problems with my earbuds coming out when I'm working out, so I'd like to switch to some more conventional headphones, and I'm looking for some suggestions.
Ian wrote a comment about being about to return references to value types.
Basically, he's asking for a way to build a collection of value types so that they can easily be modified, and to do this, he'd like the indexer to be able to return a reference rather than a value.
This restriction shows up from time to time, usually when somebody wants to write code like (example from Ian):
gets a copy of the value stored at vec and puts it in a temporary local, being able to modify the X property on that temporary copy is a useless thing to do, so the language prohibits it.
So why won't C# let you get the reference to a value? Well, it's all because of the presence of the garbage collector. If you had a reference (aka internal pointer) somewhere into the middle of an array, any movement of the array as part of a GC would mean that the reference would be invalid.
It might be possible to add a construct to a system that would say "this is an internal pointer, and if you move the outer object, you need to update the inner pointer as well, but that would mean that the reference to the value would not be a simple pointer, but a reference to another object which encapsulated the inner pointer (so the GC could find it), which pretty much defeats the purpose of being able to do this.
In C++, the programmer owns the memory, and gets to choose how things get created, deleted, and moved around. In C#, the GC owns the memory, and the programmer just gets to borrow it for a short period of time. Working in the C# world requires a different mindset, and until you internalize it, things are likely to seem a bit weird.
The meta message is around using structs in C#. In a word, don't use structs unless you're forced to use them - and by forced I mean that you need to do interop, or you've looked at your profiling data and realized that you really need to reduce the number of objects that you have around. In other words, they shouldn't be the default choice - there are a lot of disadvantages and gotchas with structs, though a few of those will go away when Whidbey shows up.
And if you do use structs, see if you can make them immutable. That hides most of the ugly cases.
Hope that makes sense
Last week, I was talking with one of my friends at the club, and he said that he had written something that was somewhat personal on his blog, and that it bothered him that his manager was bringing it up at meetings as an example of how blogs can show personality (or something like that).
I also have things on my blog that I'd prefer people don't mention in a large group, and I started thinking about why that was the case. I have two reasons:
First, when I'm writing my blog I'm writing it for people who already know something about me from what I've already written, so the effect that a single post that I write on - I don't know, the fact that I like to read Jane Austen novels from time to time - is going to have much less overall effect on what people think of me than if that's one of the only things the know about me.
Second, there's a considerable difference between me relating something, and somebody else providing a quick summary of what I said. If they're doing it online, they can easily provide a link to my original words, and then people can decided for themselves what I really mean, but if it's done in person, I don't get that opportunity.
So what do you think?
From an internal question on tools for generating code metrics...
If you know of any others, please add them to the comments. If you have experience with any of these and want to share, please feel free to do that as well.
About 15 years ago, I was skiing at Snoqualmie. Coming fast downhill, I caught an edge, popped both skis, and slammed face first into the ground. I couldn't breathe for about two minutes, and came away with a cracked rib.
Sunday, I was skiing at Stevens Pass, and repeated the maneuver, with the exception of the "unable to breathe" part, but including the cracked rib part. It's not as bad as last time, but it does mean that I can't do much bike riding or lifting for a month or so. Luckily, it's pretty early in the bike season, so I'm not going to miss much.
Last time I did this, I went on a 4-day ski vacation after the injury, so I'm pretty sure I can still ski.
Given a type named:
The following works:
But this is an error:
Well, the rule is that C# only imports the types in the namespace mentioned in the "using" statement.
Back in the early days of C#, we had a slightly different rule, which I *think* also imported namespaces as well as types, but with that behavior, users were getting into situations where they had name collisions and were having difficulty figuring out what was going on (and, perhaps, coming up with workarounds - we obviously didn't have the global namespace operator coming in Whidbey), so we decided to limit the number of things that go into the global namespace.
In search of new headphones and armed with the suggestions that I got in comments to my last post, I spent some time on the exercise page at Headphones.com. After reading that page, and doing a bit more research, I decided to learn more about what Koss and Sennheiser had to offer.
I spent a little time on the Koss site first. Or, to be more precise, I tried to spend time on the Koss site, but they decided that their main page should just launch a popup. Which my software blocked. I worked around that, and finally got their non-resizable popup with all-white scroll bars to come up, drawing from their painfully-slow web server. After a little browsing and reading, I moved over to the Sennheiser site.
What a relief. It's reasonably fast, and they display their headphones in product lines, so you can see (for example) that the PX line has the PX100, PX200, and PX250. If you go to the detail page, you get all the information you want.
So, I ended up buying the Sennheiser PX100 merely because they had a website that was better than their competitor. And I don't think I'm alone in making that sort of choice - online experience matters.
Anyway, I got the PX100's through the always-excellent NewEgg for $43.99 including shipping. They come with an interesting hard-shell case that I will likely never use because it takes at least a minute to get the headphones in it, and I'm a bit too lazy for that. The sound is really nice - the response is flat, and extends a bunch farther into the bass range than my earbuds did. They also pass my quality test for audio equipment, which is whether, after listening for a few minutes, I find myself wanting to turn up the volume.
Nice phones, and they certainly stayed in place better than the earbuds...
Last night, I finally beat my Twilight Zone, and got into "Lost in the Zone" multiball. I made good progress the first couple of weeks, but recently I'd been hampered by the current location of the machine (due to remodelling), which leaves it slightly off-level and with a light reflection right above the flippers. But, I'm lazy, so I didn't try to fix it.
To get to "Lost in the Zone", you have to collect a whole bunch of door panels. You are rewarded with a 6-ball timed multiball in which all the high-score jackpots are enabled. The hard part is actually making any shots (you really can't aim) without hitting the other balls on the table. So, you get about a minute of this frenzy (which is plenty), then the machine goes dead, all the balls get reset, and you start trying to do it again. My score ended up being about 1.4B points.
Next up are some mods for the machine. There are enough enthusiasts that there are lots of options. Here's what I'm thinking of:
I've considered getting a "topper", which is something that goes on the top of the machine and is hooked into the lights, but that seems hard to justify right now.
(Washington, DC) The USDA today announced the completion of a research program targetted at raising crop yields for lettuce growers, with the identification of a new technique. Paradoxically, it involves trimming off the growth of juvenile plants, in the hopes that the plant will respond to this injury by growing faster. For reasons that are not yet clearly understood, the technique isn't always successful, but when it does work, it's a tremendous re-leaf.
I took advantage of the nice April weather that we're having in Seattle to go on a lunchtime ride. There's a traditional Wednesday ride at Microsoft that the faster riders go on, where "faster riders" == "riders who also race", which means they're anywhere from pretty fast to really fast. But, with rain expected tommorrow, I decided to bring my bike in today and have a go.
The first 4 or 5 miles was fairly calm as we wound through Marymoor park and east on highway 202, and it was easy to stay on the back of the pack (drafting can save up to around 30% of your effort, though I don't generally ride close enough to see that much benefit). But as we turned south and started climbing, the pack broke apart a bit more. I blew up a bit (ie exceeded my aerobic threshold) on the climb up 244th Avenue, but rode with another rider who was waiting for me. Turns out, however, that I was faster up the hill than he was, so after a weave through some repaving, I crested the hill and joined the rest of the group. We rode down to NE 8th, turned right, rode a bit more, and then descended down the 12% grade of Inglewood hill, ending up back on East Lake Sammamish going north. At that point, I latched on the rear wheel of another rider and held on for 7 or 8 minutes until I got dropped off the back. A regroup at the end of Eastlake, back through Marymoor, and then up 40th to the campus.
Overall, a pretty good ride. I did have to draft to stay with the group, but could do so with a little trouble. It helped a bunch that this is early season and these guys aren't close to how fast they'll be in 3 months or so, but my aerobic fitness is better than I expected, though I'm down quite a bit on strength.
The new bike worked pretty well, and I've gotten the seat adjusted to where I like it. My back and right wrist hurt a bit, which either means that I'll need to raise the bars (or perhaps shorten the stem), or merely that my overuse injuries are showing up. The difference between the new bike and the old bike is pretty drastic - I did 28 miles on Sunday morning on the old bike, and averaged about 13.5 MPH. Today, with a bit of drafting help, I did 19 miles in around 68 minutes, which is pretty darn fast for considering there were a couple of steep hills, and I didn't quite spin out on the downhills. So, the verdict on the bike is "great" so far. Oh, and I may have finally found a seat that my butt can tolerate well.
Two of the guys on the ride showed up of fixies - bikes that are fixed-gear. Not only do they only have a single speed, they have no freewheel, so you can't coast - you pedal all the time, both up and down the hills. That they can ride both up and down the hills in a single gear is pretty impressive, and on the steep downhills they'll be spinning their cranks at something like 150RPM, or even a bit faster.
I should also mention that all the other riders are really nice guys and quite tolerant at having less experienced guys along for the ride.
From our Northwest rocketry mailing list:
Apollo 11 Panorama
This interview came to my attention because of his comments about C++ and .NET, but that's really a pretty small part of what he says.
I had the opportunity to listen to Gosling talk at Java One last year, and I was struck by how close his perspective is to a certain C# designer's perspective.
I've been asked countless times about the differences in speed between managed and unmanaged code, and here's another good resource in that area.
From Rico, Qualitative Code Differences in Managed Code
Suzanne Cook, a great blogger (and developer) on the CLR team, spends some time talking with the Channel 9 folks.