Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
User Journal

Journal Journal: Memory leaks in Java

According to the more vocal and less informed people taking part in this discussion. How silly.

I swear I must have written out at least ten different replies but I could never bring myself to hit the "Submit" button. I just did not want to add to the insanity and get dragged into arguments where the other party is so blind that nothing productive can come from it.

Anyhow, I started to wonder why there are so many ignorant (Java) programmers out there. I decided the answer has to do with marketing. The simple explaination is that some peopole eager to promote Java and\or garbage collection started to make the statement that garbage collection meant the end of memory leaks. Yeah right.

Programming

Journal Journal: STL vs. Java's Collections

Lately I have been thinking about the C++'s STL vs. Java's Collections classes. I prefer the STL.

  1. The STL bends towards C++'s syntax while Collections does not bend towards Java's syntax. It makes sense to be able to access vectors with [] and move an iterator ahead by one with ++. If a language supports a syntax then it should be supported as far down as possible. I think it is easier to remember syntax than it is API's.
  2. Arrays do not play nice with Collections. Arrays in C++ and Java predate the STL and Collections. In C++, it is easy to use arrays along side and with the STL. In Java, it is not easy to use arrays with Collections.
  3. Iterators, iterators, iterators! Iterators in Java are sequential, meaning there is no random access. There are two iterator interfaces in Java-- the basic Iterator interface with its three methods hasNext, next, and remove and the fatter interface ListIterator with six additional methods add, hasPrevious, nextIndex, previous, previousIndex, and set. C++ has random access, bi-direction, forward, and backwards iterators; efficiency dictates which one is implemented. To be fair, C++ iterators usually do not allow for something like the add method found in Java's ListIterator but the job of an iterator is to traverse a container and not to add elements to the the container. C++ wins here because it allows a broader range of access when it is possible. The versatility of C++'s iterators make it rather natural to express algorithms strictly with iterators and because they are iterators subsequences can be passed.
  4. In the STL, the common way to traverse a container is to use iterators but that is not for all the containers in Collections. One has to use something like keySet if it is desired to traverse associative containers like HashMap. They are all containers, why burden the programmer with having different ways to traverse different containers?
  5. The STL uses C++'s template system to enforce an informal interface while Collections fall back to Java's type system and enforce a formal interface. Both types of interfaces are enforced at compile time, so safety is not so much an issue but it means the programmer has to type more in Java. Whenever I need to do a sort on a Java Vector I have to refer to the docs to see what interface to implement and pass along but in C++ I can pass the sort function just about anything.
  6. There is also the lame issue of Objects vs. primitive types in Java. Now we have the lame kludge known as auto-boxing to fix some of the problem. It is also lame that different methods are needed for int arrays, double arrays, and Object arrays-- generics and auto-boxing offer a kludgey inefficient fix. In C++, I can abstract the function into a template which allows me to just write the algorithm once and efficiency versions will be created on a per type need basis.
Slashdot.org

Journal Journal: How do you read Slashdot? part 2

I still think it is a good idea to have a slashdot browser but I also think that it is possible that our current web browsers might morph into that browser. Something like greasemonkey has potential, but I do not think it is there yet.

What I want is something that will allow me have a killfile, bayes filter out the most offensive comments, implement my own scoring system, create a local story database, and be able to search that database (slashdot's searching is bad).

I think I can pound out the start of such a browser in about two weeks with Python. I don't think that I can currently get everything I want with greasemonkey otherwise I would probably try it right now although I do not really know Javascript.

Any comments?

Slashdot.org

Journal Journal: How do you read slashdot?

The other day I realized how much it sucks to read slashdot. I use a web browser and it seems to be the only way to really read slashdot, I want to be able to read comments which does not seem possible with RSS. I don't like that web browser experience. I resent the fact that I have to do re-loads to see most child comments, change my threshold, and much more.

What do you people think of a slashdot browser? I think there is a lot of potential there. The user would have much greater control of the presentation! We can tack on our own rating system and much more. We can use spam-like filtering technology to filter out the worst trolls.

What do you think?

User Journal

Journal Journal: Some NFL thoughts

First off, for the first that I can ever remember a New England Patriot did something smart! What I am talking about is Tedy Bruschi deciding not to play this year. Now it is quite possible that it was not his decision, I have heard plenty of whispers that point out that he could not get medical clearance to resume playing. Whatever the reason, it is the smart thing to not play this year and to rule it out early. As I have said before, I don't care if football was what he has done for most of his life because it is about living to a point where you can no longer saying that (30+ years). I applaude you Tedy Bruschi, savior it.

Other Patriot thoughts, Monty Beisel is no savior. WTF, what is up with people saying that they Patriots draft well? Since when? They have drafted some good players, Belichick has definitely benefitted from this information age, but I would not say that they have had one truly solide draft class let alone the many required to make such a statement true. It is going to be fun to watch the Patriots crash and burn this year, only thing is that it might have to wait until the play-offs because the AFC-East is umm, soft.

Saw some ESPN thing that said Rothlisberger is on the bubble because New England exposed his flaws in the play-off game last year. ESPN also had a Rothlisberger interview in which he said that lost might be the best mistake he made last year because he saw that he needed to improve and blah, blah, blah. I think Rothlisberger will be fine.

I don't like T.O. and I certainly do not like his agent but I think it is unfair that a team can tear-up a players contract at anytime.

I hate how often race is brought up but it is rather interesting to see how former white players seem to side with Farve and African-Americans seem to side with Walker.

Sadly, I think Ricky Williams has been brought back into football for the wrong reasons. In a perfect world I think Ricky would be doing something else.

Nick Saban seems a little too slick to me, I don't trust him.

Programming

Journal Journal: C#-like Delegates in C++

Our beloved Slashdot recently had a posting about some article Bjarne Stroupstrup, the creator C++, wrote about the future standard of C++. The idea seems to be to sand off some of the rough edges from the language, where it is easy to do so, and avoid adding new language syntax/constructs by instead extending the standard library.

It seems your average Slashdotter does not like C++ and there were too many posts suggesting that C++ was broke and could not be fixed through new libraries and that Java and/or C# was better.

One comment that seemed to be repeated again and again was that C# had delegates and that both C++ and Java were weaker languages because they lacked delegates. Without really knowing what delegates were I figured that a delegate solution was able in C++. So this weekend, I googled delegates and found this useful link. Right away, I thought functors. Lo and behold, with some template hacking you can get something that acts and looks like a C# delegate. What is this, you do not want to template hacking? Okay, you really don't need to because it is described in Modern C++ Design: Generic Programming and Design Patterns Applied and available here.

So here is the code:

#include <iostream>
#include <string>
 
#include <Functor.h>
 
using namespace std;
using namespace Loki;
 
class Class1 {
public:
  void show(string s) { cout<<s<<"\n"; }
};
 
class Class2 {
public:
  void display(string s) { cout<<s<<"\n"; }
};
 
class Class3 {
public:
  static void staticDisplay(string s) { cout<<s<<"\n"; }
};
 
//define a functor taking a string returning void
typedef Loki::Functor<void, TYPELIST_1(string) > doShow;
 
int main(int argc, char **argv)
{
// make an array of these functors
  doShow *items[3];
 
  items[0] = new doShow(new Class1(), &Class1::show);
  items[1] = new doShow(new Class2(), &Class2::display);
  items[2] = new doShow(Class3::staticDisplay);
 
// call all items the same way
  string str="Hello World";
  for(int i = 0; i < 3; i++) {
    (*items[i])(str);
  }
 
  return 0;
}

Not that much different than the C# code, is it? Despite all those comments that talked about it being too difficult, or even impossible, to effectively un-"break" (yes, "fix" might be a better word here but C++ is not really broken so does "fix" fit?) through the approach that Stroupstrup outlined. Functor is nothing more than one of those fancy template libraries that you do not have to understand to use. Functor might not be as outwardly pretty as a C# delegate but that is just a matter of syntatic sugar and Functor is more general (which is good).

User Journal

Journal Journal: My Arc

Ugh, it seems every time I write about the programming language that I am designing I say that I am at least a year away. Well, I am still at least a year away! Progress is being made though. Paul Graham's On Lisp is proving to be an excellent book and would recommend it to anyone. I am only 70 pages in and yet there have been a plethora of language ideas. Wish I had a real copy instead of the (free) electronic version- I can only last so long reading at the computer. Mad props to Graham though for making it available for free and it seems he is going to get it re-published. Reading On Lisp I can't help but think that Graham's language Arc is going to be awesome, perhaps it will never gain the widespread acceptance that some anticipate but it will be a breath of fresh air in the programming language arena.

I still need to learn/survey Smalltalk and Dylan at the very least. The little bit of Smalltalk code that I have ever seen manages to thoroughly confuse me. There is a part of me that is excited to learn something that confuses. The little bit of Dylan code that I have ever seen I have understood, but I am afraid it was rather simple code. The reason to learn Dylan is that in a lot of ways it is the most modern Lisp out there.

There are other things to learn/survey of course. I am afraid that I really don't understand module systems. I might have a good idea of Python's module system but that just seems like fancy namespaces to me. Guess I am going to have to read some documentation about scheme48 and PLT Scheme to get a half decent idea of module systems. Still plan on reading up on some of the basic compiler material out there (right now that curtails Compilers: Principles, Techniques, and Tools by Aho, Sethi, and Ullman, Lisp in Small Pieces by Queinnec, and probably re-reading chapters 4 and 5 of Structure and Interpretation of Computer Programs). I think I want to brush up on my assembly skills so I am going to learn MIX and MMIX assembly and read, at least, the first two chapters of Knuth's The Art of Computer Programming.

Hopefully you see why it is at least a year away but it is a fun project. Before I start, I probably will hack together a quick Python or Arc interpreter with basic functionality to get comfortable with my tools and make sure I know what I am doing. I am going to try and stay away from the generating C code path. Maybe I will have a contest to name the damn thing.

As for the ideas that are floating around in my head at the moment, I am thinking there will definitely be a (good) macro system. As for the syntax or s-expression question, I don't really know-- maybe both! I hate to say it but I think the standard built in types will be fairly high-level-- arrays will be the equivalent of C++ vectors, strings will be more than simple character arrays, and so on. The language will be strongly typed and dynamic; there will probably be optional static typing also.

Programming

Journal Journal: stupid summing comparisons

Ever see some stupid code example that did a sum from 0 to N. It seems that such examples are used to compare different programming languages for some reason. The thing is that every such example I have seen stinks? Why, because such an example is concerned with showing off some loop construct rather than elegantly answering the question.

The following is one such bad example:

int sum0_n(int n)
    {
      int i, sum=0, sign=n>0?1:-1;
      n*=sign;
 
      for (i=0; i<=n; i++)
        sum+=i;
 
      return sum*sign;
    }

Now consider the following code:

int better_sum0_n(int n)
    {
      int sign=n>0?1:-1;
      n*=sign;
 
      return sign*((n*(n+1))/2);
    }

Only an idiot is going to learn something from that first example. That second example shows that one knows how to think and not just write some brain-dead loop.

User Journal

Journal Journal: Another reason to hate the New England Patriots

We will never really know what went down with Bob Kraft, Vladdy Putin, and the ring but the way I see it is that Bob Kraft is either a pinko-commie-red-bastard or some wimp that can't say , "hey that is mine give it back."

Football fans should not like wimps or pinko-commie-red-bastards or anything they own. Just another reason to dislike the Patriots.

User Journal

Journal Journal: Why computer architectures suck!

aPPLE'S DECISION TO SWTICH FROM A ppc ARCHITECTURE TO A X86 ARCHITECTURE IS/WAS DEFINITELY COMPLICTED. a LOT OF IT PROBABLY DOES HAVE TO DO WITH mOTOROLA'S AND ibm'S INABILITY TO MEET aPPLE'S DEMANDS FOR ppc CHIPS. oTHER FACTORS ARE PROBABLY THE BELIEF THAT x86'S ARE CHEAPER AND ARE FASTER BECAUSE OF THEIR HIGHER CLOCK SPEEDS. i'M SURE THERE ARE OTHER REASONS AS WELL AND i BELIEVE THAT THESE ARE GOOD BUSINESS REASONS FOR THE SWTICH BUT IT REALLY SUCKS THE ADVANCMENT OF COMPUTING. tHE X86 ARCHITECTURE IS LARGELY CONSIDERED SOMETHING OF A ARHITECTURAL DEADEND YET ALL IT IS BECOMING MORE POPULAR THAN EVER.

cONSIDER THE FOLLOWING FROM aLAN kAY:

Just as an aside, to give you an interesting benchmark--on roughly the same system, roughly optimized the same way, a benchmark from 1979 at Xerox PARC runs only 50 times faster today. Moore's law has given us somewhere between 40,000 and 60,000 times improvement in that time. So there's approximately a factor of 1,000 in efficiency that has been lost by bad CPU architectures.

The myth that it doesn't matter what your processor architecture is--that Moore's law will take care of you--is totally false.

iMAGINE WHAT COMPUTING COULD BE LIKE TODAY IF WE HAD TRULY FAST HIGH LEVEL LANGUAGES LIKE sMALLTALK, lISP, OR pYTHON. cONSIDER THIS QUOTE, " However, seeing how as technology hasn't really "advanced" in these 20 years
(moving from Lisp to C++ to Java), I suppose that it shouldn't really be a surprise that social consciousness hasn't advanced either
. yOU BETTER BELIEVE IT. wE ARE A BUNCH OF SADISTS ANDMASOCHISTS.

User Journal

Journal Journal: Peter King sucks a fatty

I am a big fan of Peter King's Monday Morning Quarterback but this week was probably his worst effort ever. See for yourself here.

Yes I realize it was very tongue in cheek but I just can't accept it. I can stand the New England flattery. Funny thing is that I know a lot of Patriot fans who insists that King hates the Patriots- guess that is all part of that nasty New England resolve about being the underdog and getting no respect and so on.

If, and that is a big if, Belichick does call the offensive plays then we will get an idea of what kind of coach he really is. As a Steeler fan, I loved him with the Browns :)

Technology (Apple)

Journal Journal: Some Apple thoughts

As exciting and possibly senseless as Apple's decision to switch to the x86 architecture is; be warned it will be bumpy regardless of what the Apple people say. Software is complex with a lot of parts and it is unclear how such those new parts will behave in this dual architecture environment that Apple is creating. A lot of things that the Python people are saying does not sound exciting. The little bit I was able to find from the Mono people does not sound super either. This development kit that Apple is offering is a really bad deal for open source developers. Also hearing some people saying that they plan on delaying buying a new Mac until after the switch. All and all, Apple is daring to be different again- I admire their braveness.

User Journal

Journal Journal: Random Thoughts

  1. I don't know really what to make of Apple switching to Intel. It probably won't be easy to run OS X on a regular PC and there is always that question of Apple being able to deliver competitive prices. Having a hard time believing that code is going to be so easy to port between PowerPC and x86 Intels- should be interesting.
  2. I think the story of Ricky Williams is a rather sad one. The guy is obviously a complicated personality that too many people want to dismiss as a pot-headed free spirit. If Ricky comes back I think it will be for the wrong reason, money. Ricky gets that football is not always going to be part of his life; what is so the matter with that?
  3. On the other side of the coin, you have Tedy Bruschi seemingly unwilling to admit that he can be anything but a football player. Without being familiar with his case, I must say I can't really think of a good reason for him to return. I don't hear anybody criticizing him; come on people he just suffered a minor circulatory problem of the head, or something similar according to New England, maybe he is not thinking straight and is crazy.
  4. I just read some criticism of Ricky Williams from some idiot New England Patriots fan that felt it was important to point out that with Ricky being only 195 lbs that he is lighter than Kevin Faulk. I don't know what the guy was getting at but I Williams is still better than Faulk at that size.
  5. In the history of baseball has there ever been a bigger standard for anybody other than Pete Rose? Pete Rose took uppers, okay so what? Pete Rose goes all out into the catcher during the All-Star exihibition, okay so what? Pete owes back taxes, okay so what? Pete Rose gambles on baseball, a big no-no within baseball, okay so what? Wake up people.
  6. Anyone else suspicious of the New England Patriots' offense this year? They have little depth behind Brady and Dillon; one has to think that one will miss sometime. I still don't trust Brady, he forces things at times and it cost them one game last year and kept them from having any chance to come back in another. Worse of all, Belichick seems resigned to handling the offensive play call responsibilities!?! Just remember everybody, Buddy Ryan once said that he knew more about quarterbacks than Bill Walsh.
  7. It is sort of annoying how the New York Yankees expect to win all the time. Perhaps the only time I will cheer for a New England team is when it comes to baseball.
  8. It is pretty frustrating to see my Pirates draft a high schooler in the first round. There might be a bigger upside with drafting a high school kid but they also have a bigger downside. There is a reason why the Pirates are always drafting in the so high.
  9. Peter Gammons said that every team in baseball would of drafted Justin Upton first overall, I am not so sure. Sign-ability is always an issue for some clubs. Get salary cap and please set up a rookie rookie salary cap.
  10. I was very sad to see Peter King pick the Patriots as AFC Champs again. How can one pick against the Eagles in the NFC and yet still pick the Patriots in the AFC? The Eagles have been doing it longer, been more consistent, and face less team termoil (even with all this T.O. noise!). I must also disagree with his pick of San Diego out West along with Jacksonville winning the South. Don't sleep on the Colts and Bengals. The West is wide open.
  11. There is something about Nick Saban that I just do not trust.
  12. I would love to see nothing more than to have the Jets come out of East. I just don't see how. I just don't see the Bills having a chance, something about Mularky and Donahoe that I just don't trust.
User Journal

Journal Journal: Some NFL thoughts

  1. It would be very unwise to bet on the New England Patriots to win another Super Bowl.
  2. I would much rather see the Patriots play the Colts in the RCA Dome than the Colts go to New England again. Guess we just have to wait until the playoffs. Think the Patriots will make it?
  3. If I were the Colts I would exclusively draft defensive players this year
  4. Terrel Owens might be selfish but let me throw out the name of a lesser known wide receiver Hines Ward. Ward puts his heart into every play (even when he shouldn't) and is anything but selfish. With all that said, Hines Ward wants his deal restructured and yet I don't hear people calling Ward selfish.
  5. The Ravens had two very interesting signings, Mason and Rolle. I don't understand the Mason signing and just think that contract will end up hurting the Ravens in the future. The Rolle signing is a different matter, it could give the Ravens the best defensive backfield in football but I think they are lacking a lot up front now and it is certainly interesting that they are going back to the 4-3.
  6. I think Corey Dillon's agent really felt like he was stealing money from the New England Patriots when he got Dillon's deal extended. I thought the quote the agent had about Dillon being on the wrong side of 30 was rather telling. I guess the agent does not remember the Patriots releasing Troy Brown because of his contract even though he was still being productive.
  7. Speaking of Troy Brown, I have to think that situation should scare players away from signing with the Patriots. There is no loyalty there.
  8. Jamal Lewis will not return to "form"
  9. If Chad Pennington's shoulder is healthy then I really like the Jets this year. I just don't see his how his shoulder can be though.
  10. What the hell are the Broncos thinking bringing in all those Brown D-line castoffs?
  11. I think that Denver Clevend trade did not help either team. Very odd.
  12. I thought the Tom Brady deal was almost done like forever ago.
  13. What did Nolan do to deserve being named coach of the 49ers? I don't care if his dad was head coach there.
  14. If I were the 49ers I would trade away any good players for draft picks and just start over.
  15. Tedy Bruschi is a fool if he ever plays again. It does not matter what caused his stroke. Anyone who knew of Mike Webster towards the end should understand.
  16. It is a mistake for Steve McNair to comeback. That man has probably never been 100% healthy since he started playing in the NFL. The popular example to site here would be Earl Campbell. There are plenty of other lesser known examples though.

Slashdot Top Deals

"Everyone is entitled to an *informed* opinion." -- Harlan Ellison

Working...