« first day (304 days earlier)      last day (3711 days later) » 

9:00 PM
I'm wondering though, if there will ever be a Java AOT (system specific) compiler released... oh well
 
There is one
 
I especially like that Java doesn't have twenty different compilers (does that stop?)
 
@SimonAndréForsberg - technically it has more.
They are just more standards compliant
so it does not matter
 
Then that's what I love about Java, that there's not twenty different standards. I'd say Java only has one standard (I don't really count 1.5, 1.6, 1.7, etc. as different standards here, because they are all backwards compatible - although I'm not sure how backwards compatible C++ is)
 
@SimonAndréForsberg Was that recently? Any recent JVM should be using a tracing collector instead of reference counting, so circular references shouldn't affect them at all.
 
9:03 PM
@JerryCoffin it was about one year ago. I used a 1.7 JVM. I know that it shouldn't affect, but it did. And then I thought that even though I shouldn't need to, I see no harm in making life easier for the GC.
@JerryCoffin If the code is separated properly, there shouldn't be any need to debug everywhere.
 
it probably was not a leak, but rather a reference you did not know you had
 
@SimonAndréForsberg C++ has had three official standards (C++98, C++09 and C++11). A fourth has just been approved. C++11 could theoretically break old code (e.g., it has a completely new definition of the auto keyword) but in fact breakage is extremely rare (because auto existed previously, but nobody actually used it).
@SimonAndréForsberg Nice idea, and it's certainly not as bad as it used to be. Unfortunately, my experience indicates that if you push things hard you start to realize that the number of JVMs that actually comply with the JVM standard is zero.
 
0
Q: Interface class returning pointer to object with implementation-specific internal information

Georgios BitzesI was wondering whether this design is a good idea or whether there might be a better way to do things. As it stands, I have these classes in C++: class State { private: int value; } class Base { public: virtual State* getState(int value) = 0; virtual void advan...

 
@SimonAndréForsberg In practice, C++ has more in the way of backward compatibility problems, simply because it was in use for quite a while before it was standardized, and there's a fair amount of code going back to the '80s, so of which was written pretty poorly--often simply because compilers and hardware at the time more or less demanded cutting corners wherever possible.
 
@JerryCoffin - reading things like this make me realize that the learning-curve required to become effective (not great, just 'competent') in C++ is much steeper than it is in Java:
39
A: My C++ code involving an fstream failed review

Loki AstariI would argue the exact opposite. Explicitly closing a stream is probably not what you want to do. This is because when you close() the stream there is the potential for exceptions to be thrown. Thus when you explicitly close a file stream it is an indication you both want to close the stream an...

Should you close the stream? no, becayse then you have to handle the exceptions, and if you don't handle the exceptions, the destructor swallows them silently.
What's the right solution? Frankly, the amount you need to know to do simple tasks makes the learning curve effectively insurmountable in a few months.
I typically have to learn a new process in about 2 months.
 
9:11 PM
As a Java person, swallowing exceptions and not closing streams just feels wrong...
 
I work with a lot of really, really smart people (the sorts of people who write the C++ standards), and it takes them years working with cherry-picked interns/employees to get them close to their skill levels.
 
@rolfl The learning curve is definitely steeper, not reasonable question about that.
 
@JerryCoffin My experience is that so far, sure there is some platforms that haven't implemented some features yet (Android not supporting Java 1.7 and the GWT compiler not having implemented String.format), but in those cases my experience is that I get a clear exception that I can understand and solve the problem with. I don't know what your idea of "comply with the JVM standard" is or not, but I'd say that everything I've encountered does comply.
 
That is my 'beef' with C++, is that it is an optimistic language... it is easy to program something that consists of the right inputs and environments... but programming defensively requires a huge amount of experience to know what to defend against.
 
time to read up
 
9:16 PM
@SimonAndréForsberg One really fundamental way in which C++ is nearly unique is that it places a heavy emphasis on RAII (aka SBRM). That means most resource cleanup is done in destructors. Just about any time you'd have a try/finally in Java, you'll probably just have straight-line code to use the resource, and the cleanup you'd have in the finally block will be in a dtor instead.
 
@rolfl Which AOT one do you mean then?
 
gcj for one.
 
@JerryCoffin Say hello to Java 1.7's try-with-resources statement that takes care of that finally block that simply close the resource!
 
Isn't GCJ quite dated? @rolfl
Last I've seen was Excelsior JET
however it's expensive as hell
or hmm
if it can compile bytecode to native
does it matter that it's old then?
 
@rolfl Can I order a SEDE query to find "Primarily opinion-based" posts?
 
9:20 PM
@SimonAndréForsberg Yes--they've done a decent job of copying C#'s syntax, but (just like the C# it copied) it still leaves it to all client code to use the right syntax to clean up the resource, whereas in C++ the resource automatically cleans up after itself.
 
@skiwi it seems gcj is in maintenance mode.
 
@rolfl Hold that order, working on it myself :) Shouldn't be too hard.
 
You mean this site? gcc.gnu.org/java o rmaybe a different one
 
@JerryCoffin Does all C++ code call destructors?
 
as sept 22 2009 seems pretty old
 
9:23 PM
@JerryCoffin The corollary to that statement is that in C++ you have to write your own destructor, whereas Java will do the destruction for you
 
@SimonAndréForsberg I suppose you could write code in C++ that didn't use destructors, but it'd barely be recognizable as C++ if you did. Normally, you create objects on the stack, and their destructors get invoked when they go out of scope.
 
and you still have to 'bracket' new xxx with delete xxx
 
@rolfl Not really true.
@rolfl If you're writing new xxx chances that you're doing something horribly wrong approach 100%. It does happen, but in well written code it's so rare it's hardly worth mentioning.
 
@rolfl One query order coming up: data.stackexchange.com/codereview/query/172622/… (not that you asked for it, but still)
 
@JerryCoffin posted my answer, it's crap. Nevermind. :P
 
9:28 PM
@JerryCoffin So technically, the resource doesn't clean up after itself in C++ if you don't call the object's destructor, just like the object doesn't clean up after itself if you don't call it's .close()-method (or use the right try-with syntax) in Java?
 
meh, I have nothing against C++.... but it is not the right langiuage for me.
@SimonAndréForsberg - C++ destructor and Java close() are different things.
can't compare them
 
@SimonAndréForsberg Sort of true, except that normally you don't call the destructor at all--it's called automatically when the variable goes out of scope.
 
except 'scope' in C++ is a fuzzy thing
you can change it.
 
the C++ destructor is functionally equivalent to Javas finalize() method, however
there is no guarantee that the finalizer ever gets called on an object in Java, so it's pretty useless
but it might get called
 
@rolfl I have to compare them to know their differences, don't I?
 
9:31 PM
@rolfl "scope" is very tightly defined in C++ (has to be, since so much behavior depends on things like dtors being invoked when things go out of scope).
 
0
Q: jQuery XML Parse Needs to Be More Efficient

MxmastaMillsI will preface by saying that this data set is much larger than what I have here. I'm having to loop through an XML file to get data and display it on a site with jQuery. I have to use jQuery because I'm working within a framework that I can't edit so I'm having to manipulate the data after the f...

 
I wasn't aware that the destructor can be automatically called in C++.
 
It is not 'automatically' called.
The compiler adds a bunch of instruction code to the end of the method that goes back and cleans up the mess.
Think of it as each method having it's own mini GC.
 
Wow I love
 
But, there are ways to make objects last outside the scope of the method/
 
9:34 PM
isn't that a leak?
 
and there are ways to control whether references to an instance add to it's reference count, or not.
 
@Mat'sMug Not as long as you remember to clean it up when you want it to be deallocated.
But yes, it can become a memory leak if it's not taken care of
Though smart pointers make it pretty hard to have a memory leak these days if you're using C++11
 
good to know I guess
 
That's the term, smart pointers.
 
@rolfl You seem to have a rather unusual definition of "not automatically" that doesn't include what the compiler does...automatically. If you're saying "C++ doesn't endow the CPU with new capabilities to clean up resources without executing any code", then you're right, but at that point you're defining "not automatic" in a way I'd have though was pretty obvious.
 
9:35 PM
allright, I'm AFK/driving
ciao!
 
@JerryCoffin in exception cases, you can jump out of the instruction call, and things do not get cleaned up.
(AFAIK, anyway).
Whereas, in Java, they will.
 
You mean when an exception is thrown? The stack is unwound when an exception is thrown.
 
@rolfl Not to be insulting, but clearly you don't know (in fact, one of the primary reasons decently written code does resource cleanup in dtors is to ensure exception safety).
 
I told you earlier that I don't know... so, it's not insulting ;-)
 
@rolfl Fair enough!
 
9:39 PM
FEI: (For Everyone's Information) I added an answer to the meta post about best-practices rule. Sorry if it sounds too much like a simple comment, but I figured it was worth adding as an answer. I might expand on it tomorrow. Too tired for now.
0
A: Revising or removing the "Best practices" topicality rule

Simon André ForsbergI'm not sure if this should be an answer or a comment, but I think that one of the things that this rule was meant to avoid is questions that are primarily opinion-based. Many of these primarily opinion-based are asking something like "What is the best (practice) and why?". Considering that there...

 
But, that's another point for Java that you don't have to know the internals of destructors in order to be an effective Java programmer.
 
oh well, a CR answer is never too trivial!
Thanks! These are the practices I lack while trying to teach myself. Along with @JerryCoffin's suggestions, I think I may need to re-write the bulk of the program with these better practices in mind. The "sorter" logic is a sloppy attempt to graph only the sites with the longest outages. The "sorter" list contains only the average outage times, separated from their sites. I then graph every site with a larger average downtime than the 10th-longest time in the "sorter" list. It's awful, but I think a solution will become evident once I rework the code with your and Jerry's suggestions in mind. — Liesmith 1 min ago
 
@Mat'sMug Never thought I would star that, but I did. :)
 
@SimonAndréForsberg I'll blame the fact that you're tired :)
 
Me too. Better go to sleep now.
 
9:42 PM
ok I'm really gone now - bye!
 
Night folks!
 
@rolfl There are certainly differences between the things you need to learn in order to use C++ effectively vs. using Java effectively. At least IME, using C++ effectively largely consists of understanding a lot of how things work. Using Java effectively seems to be much more a matter of learning every trick your IDE provides to deal with things like refactoring and such, since doing it by hand is generally unbearable.
 
0
Q: Fallout style homework game (beginner)

CalypsysI've been going through LPHW (learn python the hard way) lessons and i am now at exercise No36 where i got to create a similar game. Could you please review it and point out beginner mistakes? Thank you in advance. I hope you like the game. from sys import exit inventory = [] ground = ['Bone...

 
0
A: Is this the right way to inject AutoMapper profiles

Jeff VanzellaWhat is the purpose of the IMapper interface and Mapper class? It looks to me that they are just wrapping the IMappingEngine interface and MappingEngine class. While this is a good method when you have a third party class that doesn't have an interface, I think it is overkill here. Why don't y...

Zombie killa
didn't know what else to do with that question
 
0
Q: PHP Multidimentional array initialization

user2884319I am initializing a php array as follows $newArray = array(); $newArray['2014-13-03']['SMD']['ID'] = 5; $newArray['2014-13-03']['SMD']['ID'] = 10; Just wanted to check if you guys think this is a wrong way to insert data into an array. It is working just fine, but still wanted to check from op...

 
9:51 PM
@JeffVanzella Works for me.
 
@Mat'sMug Thanks :) I got home again, now I have time to check the other answers
 
@JerryCoffin - it seems we both have preconceieved notions of the weaknesses in the alternative langauges.... let's pick on C# for a bit, shall we?
2
 
wasn't an easy question to answer :) Had to do some research on AutoMapper
 
@rolfl I'll leave that to others. I'm pretty sure I've used up (at least) my quota of language bashing for the month. :-)
2
Of course there's no limit on bashing PHP (but it's not really a language).
5
 
Finally got 25 upvotes on this answer:
25
A: Speech processing on the Raspberry Pi

syb0rgThis is the main project my Raspberry Pi is dedicated to right now, so I figure I can add my two cents. Keep in mind this project is still very much a work in progress. I chose to use the C programming language for this project exclusively on the Raspbian OS, and that may have affected some of ...

Woah, it looks like I missed a lot of conversation today.
 
10:00 PM
0
A: Writing a function to add or modify an existing object inside an array

BenVlodgiPerhaps instead, use a hashmap of [id, quantity]. If id exists in hashmap, then increment up the value at hashmap[id].

^ Someone is saying that this is "not an answer"; why isn't it?
 
Three people are saying that ;-)
 
it looks more like a comment to me
 
I agree ^
 
How about now?
1
A: Writing a function to add or modify an existing object inside an array

BenVlodgiWhy are you using an array to do the job of a map? Use the right data structures.... ... instead, use a hashmap of [id, quantity]. If id exists in hashmap, then increment up the value at hashmap[id].

 
now it looks like an answer
 
10:27 PM
0
Q: Square root approximation with newton's method in C++

matheussilvapbI designed a program that calculates the square root of a number using newthon's method of approximation that consists in taking a guess (g) and improving it (improved_guess = (x/g + g)/2) until you can't improve it anymore: #include <iostream> #include <iomanip> using namespace std; template <...

 
@Malachi there, you have an answer ;-)
0
A: Do I have any SQL Leaks?

rolflYour code is asymmetrical.... You open your SQLConnection inside the using block, but you close it outside in the final block.... anyway, the Close is completely redundant: If the SqlConnection goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by call...

 
Finally, my UTTT game is ready for posting.
I think.
Hmm, just over 200 lines of refined code...
 
10:54 PM
@Malachi - you also suggested someone look at the other SQL question... here:
0
A: SQL PreparedStatement; Am I doing it right?

rolflThere are a couple of issues I think you should be aware of. In JDBC, the default state of a connection is getAutoCommit() == true. you keep changing this to be false, then running some selects, and then setting it back to true. if it was true when you came in, then you set it to false. No pr...

Asker was last seen: Jan 29 '13 at 7:41 .... not sure it was worth much.
 
0
Q: Table data is not occupied in Loop PHP

RbexMy problem is how to occupy the table data which is blank. I know it won't happened because everytime it goes to particular day(1,2,3,4,5,6,7) I used tr and closed it /tr but how to do it? I don't have idea and I've been trying this for 3 days. Don't worry about the code I'll just refactor it lat...

0
Q: Reducing number of operations

user1234I have a function to find the max of three numbers, but it uses 24 ops I want to reduce it to 20 ops. Only using the following bitwise operations ! ~ & ^ | + << >> int maxOfThree(int x, int y, int z) { int a1 = (x+(~y+1))>>31; int a2 = (x+(~z+1))>>31; int a3 = (y+(~z+1))>>31; return ((~a1&((a2&z...

 
Off Topic
0
Q: Table data is not occupied in Loop PHP

RbexMy problem is how to occupy the table data which is blank. I know it won't happened because everytime it goes to particular day(1,2,3,4,5,6,7) I used tr and closed it /tr but how to do it? I don't have idea and I've been trying this for 3 days. Don't worry about the code I'll just refactor it lat...

 
Two midterms in a row. It's finally over.
Time to handle flags...
 
11:09 PM
Successful, do you think?
 
0
Q: Simple example of N-Tier, entity framework, unit of work, repository, business logic layer

David GoodI've been studying c# for about 6 months and am trying to make a simple example for an n-tier application. I want to learn to do things in the most proper and professional way. This example uses a table in the database called "Settings" where various application settings can be persisted to the d...

 
@rolfl: I don't think I did too badly, but I have no high hopes.
 
So, @Jamal - you just processed a flag, and it came through as 'disputed', but I had 'voted' as invalid flags and you agreed.... right?
> disputed - I think this is now enough of an answer.
 
Yes, I agreed that it was okay to keep, hence why I didn't remove the answer. Mods are now able to provide feedback for helpful flags.
 
But my flag was helpful.... :(
It was flagged 'not an answer', I said 'invalid flags', and you disputed that... and agreed at the same time ;-)
 
11:14 PM
As long as there's an invalid flag raised, all flags will be disputed. I cannot control that.
 
Ahh
That probably explains the pointless auto-close-without-comment thing I have been doing.
 
And I have heard some SO users say that they have lots of disputed flags, which means they've been invalid flagging a lot.
 
add a comment, then flag invalid.
 
1
Q: How would you have had solved this problem?

bazangHere is my solution to this problem; please be brutally honest/strict, if I would have written this code, in a 45 minute interview, what would you think? (I am aiming for Google,Facebook). Here is the problem I solved: *Given a linked list, reverse the nodes of a linked list k at a time and ret...

 
11:32 PM
Hello @PlattStudent101
I see that you are a new user here. Welcome to the 2nd Monitor!
Hello @Yuushi
 
heya @syb0rg
 
@Yuushi Have you ever seen this before?
	switch (row)
	{
		case 0 ... 2:
			return 0;
		case 3 ... 5:
			return 1;
		case 6 ... 8:
			return 2;
		default:
			return -1;
	}
 
?
 
Compilable code, it's used in my UTTT program.
 
nope, can't say I have
 
11:36 PM
Hmm, interesting. @JerryCoffin Have you seen that used before ^^^
 
Weird. I would've just expected cast 0: case 1: case 2:
 
Shorthand code for that. :P
 
I know, and it looks more readable. I just haven't seen that before.
 
I saw it in an SO question somewhere, I'm trying to find the post now.
44
Q: What is "..." in switch-case in C code

jasonzHere is a piece of code in /usr/src/linux-3.10.10-1-ARCH/include/linux/printk.h: static inline int printk_get_level(const char *buffer) { if (buffer[0] == KERN_SOH_ASCII && buffer[1]) { switch (buffer[1]) { case '0' ... '7': case 'd': /* KERN_DEFAULT */ return buffer[1]; ...

I'm going to see the responses to in when I post my UTTT question. If it gets a good response, I might start using that in my reviews.
 
Is there a SE site for asking about hardware recommendations?
 
11:48 PM
Does anyone with ammo want to give this old post its last upvote for Good Question?
24
Q: My C++ code involving an fstream failed review

dreamlaxI have a small 10-liner function that writes some data to a file using an std::ofstream. I did not explicitly call .close() at the end of my function, but it failed code review with the reason that it is better to explicitly call it for style and verbosity reasons. I understand there is no harm i...

 
@Jamal done
 
Hey @davidkennedy85
 
@davidkennedy85: I'm not sure. I also can't find anything on MSO.
 
Becuase Tom's Hardware sucks
And that's the only site I know of
 
11:51 PM
Anandtech
 
What do you chaps think: $300 for a Dell i3 or $400 for a Lenovo i5?
@yuushi thx
 
no problem
 
Does the reload happen in 4 minutes?
 
@syb0rg Not valid in C or C++. Can't remember for sure, but almost seems like it might have been allowed in Pascal.
 
@JerryCoffin It isn't valid?
 
11:58 PM
@syb0rg Not in C or C++, no.
 
Reload in 1 minute... silly
 
@JerryCoffin Define "valid". It does compile with my C compiler.
In this code here:
0
Q: Ultimate Tic-Tac-Toe in C

syb0rgHere is my attempt at the UTTT code-challenge (in response to the the Weekend-Challenge Reboot). Here is what I would like critiqued: I tested the code a few times for bugs, but I may have missed some. I feel like I have duplicated code in some places (with only minor changes being the differe...

 

« first day (304 days earlier)      last day (3711 days later) »