Nop, you havent made a point. Unless your point was that there are always crappy programmers misusing OOP and Java.
for(String s : new File(".").list() ) if(s.endsWith(".gz")) do_something(s);
now, we just did something that does not have immediate support in the language, demonstrating the flexibility of Java. How easy is it to do that in your-favorite-programming-language ?
dear mr coward: of course you are an amateur programmer. not only that, you are not a very nice person either so i cant even think of you as an "project manager" since you are not a team player.
I said the list is VALID. if you read the list from seperate places but write to it from a single thread you will be fine. This is the way, for example, the linux kernel worked before 2.3.
now, if you want your list to also allow parallell writes, yes you need to lock the list first. but this is like BASIC programming stuff, you shoulnt be so porud for pointing it out if you were not an amateur.
(from http://www.kernelnewbies.org/documents/kdoc/kernel -locking/lock-avoidance-rw.html) Avoiding Locks: Read And Write Ordering
Sometimes it is possible to avoid locking. Consider the following case from the 2.2 firewall code, which inserted an element into a single linked list in user context:
new->next = i->next;
i->next = new;
Here the author (Alan Cox, who knows what he's doing) assumes that the pointer assignments are atomic. This is important, because networking packets would traverse this list on bottom halves without a lock. Depending on their exact timing, they would either see the new element in the list with a valid next pointer, or it would not be in the list yet. A lock is still required against other CPUs inserting or deleting from the list, of course.
Of course, the writes must be in this order, otherwise the new element appears in the list with an invalid next pointer, and any other CPU iterating at the wrong time will jump through it into garbage. [...]
most of the stuff you mentioned had been planned to be included in the next releases of java long long time before C# was born.
I use both Java and C#. And to me it looks like Microsoft put every possible feature into C# without thinking so it could say "look, unlike Java, C# has xxx and yyy".
as a whole, the java implementations are much more usefull in practice (and less dangerous)
Integer ii = (Integer)e.next(); int i = ii.intValue();
probably few mintues per working day. I am not sure if this makes you code more clear because most of the time when you put something in a List/Array/whatever, you want to change its value and you cant do that with an automatically boxed type:
e.next() ++;
will simple not do what you intended so you will have to go back to casting Integers again. now THIS mixed use of two different methods will make you coding unreadable.
why is autoboxing so darn important to some people??
i will probably never use it because if i want a hash-table of integers or a binary-tree of doubles, i will write it myself with the native types. it is faster, and eats less memory.
the whole idea of hiding complexity by converting int to Integer and vice versa automatically is kinda scareing.
not to mention the waste of memory for creating those stupid wrapper objects...
Please dont use John Romero and feeling in the same line. Brings back bad bad memories...
He said at the bottom, and for what we know, that list could contain 6.2 billion names.
didnt you just made the same mistake by posting the mp3 file to slashdot?
this is slashdot, the land of truely geeks
ok wait...
"A decade ago, a self-taught computer genius from Finland [...] There's more on the Finish computer guy here."
(I think you get the point)
not to mention SCO
FUNCOM is Norwegian, not Swedish.
can someone explain to me what this list means?
and where the hell is Macedonia?? Macedonia is a part of Greece, as far as I know.
but, that was like just in the beginning...
dont know about first mainstream, but when it comes to a cross-platform threading model, i think ADA was first
check this one out:
http://cvs.sourceforge.net/viewcvs.py/buddy/bud
(there are zillions more, but this page was the one that i had in memory)
http://www.princeton.edu/~rvdb/JAVA/election200
dear mr coward:
l -locking/lock-avoidance-rw.html)
of course you are an amateur programmer. not only that, you are not a very nice person either so i cant even think of you as an "project manager" since you are not a team player.
I said the list is VALID. if you read the list from seperate places but write to it from a single thread you will be fine. This is the way, for example, the linux kernel worked before 2.3.
now, if you want your list to also allow parallell writes, yes you need to lock the list first. but this is like BASIC programming stuff, you shoulnt be so porud for pointing it out if you were not an amateur.
(from http://www.kernelnewbies.org/documents/kdoc/kerne
Avoiding Locks: Read And Write Ordering
Sometimes it is possible to avoid locking. Consider the following case from the 2.2 firewall code, which inserted an element into a single linked list in user context:
new->next = i->next;
i->next = new;
Here the author (Alan Cox, who knows what he's doing) assumes that the pointer assignments are atomic. This is important, because networking packets would traverse this list on bottom halves without a lock. Depending on their exact timing, they would either see the new element in the list with a valid next pointer, or it would not be in the list yet. A lock is still required against other CPUs inserting or deleting from the list, of course.
Of course, the writes must be in this order, otherwise the new element appears in the list with an invalid next pointer, and any other CPU iterating at the wrong time will jump through it into garbage.
[...]
thank you my friend for those nice and warm words :(
this shows how dumb these "expert programmers" really are.
The code is thread safe becuase if you interrupt it at ant location, the list is still VALID. and that without using any monitors or semaphores.
read Rusty's guide about locks in the linux kernel and you will understand what i am talking about.
of course, you didnt get a thing of what I just said, huh?
Oh my god, cant people even write a single list-insert without making a fool of themselves ?
... (first node in the list, could be null)
// NOTE: thread-safe code (can you see it?)
Item first =
Item item = new Item();
item->next = first;
first = item;
this is what i get:
Access Denied
You don't have permission to access "http://www.georgewbush.com/" on this server.
but that usually happens before the movies come out. so no, i dont wait. i stay home AND see the movie
just wondering,
how much better is that Bush dude?
(not that it does matter when it comes to politics)
damn lameness filter. i want to be lame, dont you get it??
// test2(input);
#include <gmp.h>
#include <stdio.h>
const int LEN = 10, PREC = 30000, LIMIT = 10000;
void approx(mpf_t out, int n) {
mpf_t tmp1;
mpf_init(tmp1);
mpf_set_d(out, 1.0);
mpf_set_d(tmp1, 1.0);
for(int i = 1; i < n; i++) {
mpf_div_ui(tmp1, tmp1, i);
mpf_add(out, out, tmp1);
}
mpf_clear(tmp1);
}
void test1(const char *num) {
int len = strlen(num);
char buffer[LEN + 1];
for(int i = 0; i < len - LEN; i++) {
strncpy(buffer, num + i, LEN);
buffer[LEN] = '\0';
mpz_t n;
mpz_init_set_str(n , buffer, 10);
if( mpz_probab_prime_p(n, 10)) {
gmp_printf("%Zd is a prime!\n", n);
return;
}}}
int sum(const char *str) {
int ret = 0;
while(*str) {
ret += (*str - '0');
str++;
}
return ret;}
void test3(const char *str) {
int x = sum("7182818284");
int len = strlen(str);
char buffer[10 + 1];
int j = 0;
for(int i = 0; i < len - LEN; i++) {
strncpy(buffer, str + i, LEN);
buffer[LEN] = 0;
if(sum(buffer)== x) {
printf("%d. %s\n", ++j, buffer);
if(j > 4) return;
}}}
int main() {
mpf_set_default_prec(PREC);
mpf_t a;
mpf_init(a);
approx(a, LIMIT);
char buffer[10240], *input = buffer;
gmp_sprintf(input, "%.10220Ff", a);
input[1] = input[0]; input++;
test1(input);
test3(input);
return 0;}
took me 15 minutes to break it. lets see if the lameness filter likes it...
NOTE: include gmp.h and stdio.h, link with gml
const int LEN = 10, PREC = 30000, LIMIT = 10000;
void approx(mpf_t out, int n) {
mpf_t tmp1;
mpf_init(tmp1);
mpf_set_d(out, 1.0);
mpf_set_d(tmp1, 1.0);
for(int i = 1; i 4) return;
}
}
}
int main() {
mpf_set_default_prec(PREC);
mpf_t a;
mpf_init(a);
approx(a, LIMIT);
char buffer[10240], *input = buffer;
gmp_sprintf(input, "%.10220Ff", a);
input[1] = input[0]; input++;
test1(input);
test3(input);
return 0;
}
spielberg will probably make yet another blockbuster.
and that other dude will do a great movie without the overused hollywood cliches...
most of the stuff you mentioned had been planned to be included in the next releases of java long long time before C# was born.
I use both Java and C#. And to me it looks like Microsoft put every possible feature into C# without thinking so it could say "look, unlike Java, C# has xxx and yyy".
as a whole, the java implementations are much more usefull in practice (and less dangerous)
ok, wait.
how much time do you save for writting
int i = e.next();
instead of
Integer ii = (Integer)e.next();
int i = ii.intValue();
probably few mintues per working day. I am not sure if this makes you code more clear because most of the time when you put something in a List/Array/whatever, you want to change its value and you cant do that with an automatically boxed type:
e.next() ++;
will simple not do what you intended so you will have to go back to casting Integers again. now THIS mixed use of two different methods will make you coding unreadable.
why is autoboxing so darn important to some people??
i will probably never use it because if i want a hash-table of integers or a binary-tree of doubles, i will write it myself with the native types. it is faster, and eats less memory.
the whole idea of hiding complexity by converting int to Integer and vice versa automatically is kinda scareing.
not to mention the waste of memory for creating those stupid wrapper objects...