Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Otto Skorzeny posted:

For C or Obj-C, clang. For C++, nothing yet.

Is icc not any good now? I haven't written C++ in years so I'm dated but it used to be pretty good.

Adbot
ADBOT LOVES YOU

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
ICC will compile fine, but it disables some optimizations unless it's running on an Intel processor.

TenDRA is a really good, really fast C compiler, but it's not seen much development in a while and its C++ support isn't much better than clang. I only compile with it to verify that my code doesn't accidentally use any GCC extensions.

tef
May 30, 2004

-> some l-system crap ->

Otto Skorzeny posted:

For C or Obj-C, clang. For C++, nothing yet.

clang is worth keeping an eye on for c++ support

ZorbaTHut
May 5, 2005

wake me when the world is saved

HFX posted:

I've just got in a habit of treating all warnings as errors.

I tried this for a while, but it made certain kinds of debug code annoyingly difficult, especially with warnings turned way up. Yes, I know that variable isn't used, I commented out all the code that used it, I don't feel like commenting out every individual necessary variable definition as well :argh:

As well as stuff like if(somevector.size() < 10) {}, or for(int i = 0; i < somevector.size(); i++) {}, and the warnings that spews out annoy me and 99% of the time (100% of the time, with what I've been doing lately) are absolutely worthless.


Worth noting that Clang (which is written in C++) now builds itself, and that series of boxes has gotten substantially greener since I first inspected it. It wouldn't surprise me at all if it built the vast majority of non-template-magic programs totally fine by the end of the year, if not building the majority of Boost.

I am so totally excited for Clang.

ZorbaTHut fucked around with this message at 23:02 on Mar 14, 2010

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

ZorbaTHut posted:

Worth noting that Clang (which is written in C++) now builds itself, and that series of boxes has gotten substantially greener since I first inspected it. It wouldn't surprise me at all if it built the vast majority of non-template-magic programs totally fine by the end of the year, if not building the majority of Boost.

Actually, we should be fine on template-magic programs; metaprograms that don't compile are pretty firmly in the "individual bug" category rather than "serious architectural work required". Our major holes are all around virtual inheritance (lots of code-generation problems), access control (lots of implementation gaps), and exceptions (lots of rigorous testing needed).

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
code:
void CheckState(State state1) {
  if ((state != state1)) {
    throw Exception("Invalid state");
  }
}

void CheckState(State state1, State state2) {
  if ((state != state1) && (state != state2)) {
    throw Exception("Invalid state");
  }
}

// ...

void CheckState(State state1, State state2, State state3, State state4, State state5, State state6, State state7, State state8) {
  if ((state != state1) && (state != state2) && (state != state3) && (state != state4) && (state != state5) && (state != state6) && (state != state7) && (state != state8)) {
    throw Exception("Invalid state");
  }
}
e: from the same code

code:
for(int i=0;i<workingDir.size();i++){
  if((workingDir[i] < 'a')||(workingDir[i] > 'z'))
    throw Exception("special characters in working dir !!")
}

system("find " + workingDir + "/ -exec rm -rf '{}' ';'" + " >& /dev/null");

TOO SCSI FOR MY CAT fucked around with this message at 19:07 on Mar 16, 2010

wigga please
Nov 1, 2006

by mons all madden

Janin posted:

code:
void CheckState(State state1) {
  if ((state != state1)) {
    throw Exception("Invalid state");
  }
}

void CheckState(State state1, State state2) {
  if ((state != state1) && (state != state2)) {
    throw Exception("Invalid state");
  }
}

// ...

void CheckState(State state1, State state2, State state3, State state4, State state5, State state6, State state7, State state8) {
  if ((state != state1) && (state != state2) && (state != state3) && (state != state4) && (state != state5) && (state != state6) && (state != state7) && (state != state8)) {
    throw Exception("Invalid state");
  }
}
Tell this guy he needs to implement support for up to 300 States.

Lexical Unit
Sep 16, 2003

Janin posted:

code:
for(int i=0;i<workingDir.size();i++){
  if((workingDir[i] < 'a')||(workingDir[i] > 'z'))
    throw Exception("special characters in working dir !!")
}

system("find " + workingDir + "/ -exec rm -rf '{}' ';'" + " >& /dev/null");
:raise: I want to meet the person who wrote this and ask them what they were thinking.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Janin posted:

code:
void CheckState(State state1) {
  if ((state != state1)) {
    throw Exception("Invalid state");
  }
}

void CheckState(State state1, State state2) {
  if ((state != state1) && (state != state2)) {
    throw Exception("Invalid state");
  }
}

// ...

void CheckState(State state1, State state2, State state3, State state4, State state5, State state6, State state7, State state8) {
  if ((state != state1) && (state != state2) && (state != state3) && (state != state4) && (state != state5) && (state != state6) && (state != state7) && (state != state8)) {
    throw Exception("Invalid state");
  }
}

I thought that 'what would you have to do without arrays?' question in my CS tutorial was stupid. Apparently not!

HFX
Nov 29, 2004

Jonnty posted:

I thought that 'what would you have to do without arrays?' question in my CS tutorial was stupid. Apparently not!

The right answer to your question would be I'd use a list.

I've come to the conclusion that most programmers have never progressed beyond the intro classes in their skill set. Once you do that, a lot of the code you deal with starts to make a lot of sense.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

HFX posted:

The right answer to your question would be I'd use a list.

Oh, don't be pedantic, you know what they meant.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Jonnty posted:

Oh, don't be pedantic, you know what they meant.

well, what DID they mean? because you can get along just fine without arrays as long as you have pointers:

code:
typedef struct {
data_obj *next;
int data;
} data_obj;
i mean "what would you do without arrays?" is an open-ended question that can have tons of valid answers, and "make functions with 300 parameter overloads" isn't one of them

n.ed: I'm actually being serious, what do you think that that question means? They didn't ask "what would you do without any language construct that allows you to create a data type containing more than one value", they asked what you would do without arrays.

Crazy RRRussian
Mar 5, 2010

by Fistgrrl
What is an array? A contiguous buffer in memory that you can treat as a vector of values?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

LockeNess Monster posted:

What is an array? A contiguous buffer in memory that you can treat as a vector of values?

What is an array? A miserable pile of values! But enough talk...

Crazy RRRussian
Mar 5, 2010

by Fistgrrl

Ryouga Inverse posted:

What is an array? A miserable pile of values! But enough talk...

I mean, depending on the definition of the array the assignment statement "don't use arrays" would have very different implications.

Array could mean associative array, and/or linked list could count as an array as well.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

LockeNess Monster posted:

I mean, depending on the definition of the array the assignment statement "don't use arrays" would have very different implications.

Array could mean associative array, and/or linked list could count as an array as well.

Well, yeah, that's why this discussion is anything but pedantic. "What if you didn't have arrays" is an incredibly vague question.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

LockeNess Monster posted:

I mean, depending on the definition of the array the assignment statement "don't use arrays" would have very different implications.

Array could mean associative array, and/or linked list could count as an array as well.

You could say that procedures are arrays of instructions, but trying to super-extend definitions like that isn't helpful. An array is a fixed-size, homogenous sequence of values, stored consecutively in memory.

I think it's fair to give the tutorial a break, though, considering that arrays are usually taught before lists. Obviously, it's asking "what would you have to do without data structures?"

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I guess I just hate the question because the answer they're expecting is predicated on you not knowing anything but what they've taught you. I hate questions like that because I always try to read more about what I'm doing, etc. and so I always know the "pedantic" answer to the question.

It's a legitimate question as written - "What would you do [in this function] if you couldn't/didn't want to use arrays?" because then you can give any of the valid answers that still accomplish the task but don't use arrays. But when you write the question specifically expecting the answer "gently caress WE'RE SCREWED UNLESS THERE'S SOMETHING ELSE YOU HAVEN'T TOLD ME YET" and use vague terminology to boot, well...

Nomnom Cookie
Aug 30, 2009



Ryouga Inverse posted:

I guess I just hate the question because the answer they're expecting is predicated on you not knowing anything but what they've taught you. I hate questions like that because I always try to read more about what I'm doing, etc. and so I always know the "pedantic" answer to the question.

It's a legitimate question as written - "What would you do [in this function] if you couldn't/didn't want to use arrays?" because then you can give any of the valid answers that still accomplish the task but don't use arrays. But when you write the question specifically expecting the answer "gently caress WE'RE SCREWED UNLESS THERE'S SOMETHING ELSE YOU HAVEN'T TOLD ME YET" and use vague terminology to boot, well...

"Array" is not vague terminology in C, C++, Java, Pascal, or C#. If it's a class in PHP, yeah, you might have a point, but I don't think that was the case.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Nomnom Cookie posted:

"Array" is not vague terminology in C, C++, Java, Pascal, or C#. If it's a class in PHP, yeah, you might have a point, but I don't think that was the case.

okay, so "use a linked list" is a perfectly valid response to the question, because they didn't specifically disallow that solution

Vinterstum
Jul 30, 2003

....and the thread reaches another low point.

To get bach on track, I present you with an excerpt from the Blob class. It hasn't seen use in a long, long time (or very possibly ever), but still lurks around in our Perforce history somewhere and is occasionally brought out to scare fresh coders.

code:
Blob_c::Blob_c(uint nSize)
{
    m_pData = reinterpret_cast<uint*>( new uchar[2*sizeof(uint) + nSize] );
    m_pData[0] = HostToLittleEndian_v( e_Norm + 1 );
    m_pData[1] = HostToLittleEndian_v( nSize );
}
Blob_c::Blob_c()
{
    m_pData = m_aNull;
    atomic_inc((int*)m_pData);
}
Blob_c::Blob_c(const void*p, uint nSize)
{
    new (this) Blob_c(nSize);
    memcpy( &m_pData[2], p, nSize );
}
Edit: For completeness, m_aNull is defined as:
code:
uint Blob_c::m_aNull[] = { e_Null+1, 0 };

Vinterstum fucked around with this message at 02:58 on Mar 18, 2010

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!
I dunno, most of that doesn't look that terrible (except for the new(this) part).

HFX
Nov 29, 2004
I'll raise this.

So I've been putting in a lot of hours on a project that is 90% of javascript. For the most part it is one unified application and not a javascript just for a webpage at a time.

I decided to see how large the project has grown:

find . -name "*.*" -exec cat {} \; | wc -l
cat: .: Is a directory
194914


That's right a 200K lines of code Javascript application. This explains why I've been working 60+ hours for the last 2 months since I joined the project. Imagine the pain from debugging with most of the people being of the intro class programming variety.

Jonnty posted:

Oh, don't be pedantic, you know what they meant.

To be fair, there is a whole class of languages built upon the concept of the list being your basic data structure. Some of them don't even have arrays, although most do for performance reasons.

evensevenone
May 12, 2001
Glass is a solid.
Linked list is like answering "Drive my Hummer!" when someone asks you what you would do if you didn't have a car.

shrughes
Oct 11, 2008

(call/cc call/cc)

evensevenone posted:

Linked list is like answering "Drive my Hummer!" when someone asks you what you would do if you didn't have a car.

No, your analogy is inapt. Using a linked list is like answering, "I never drive my car" when someone asks me what I would do if I didn't have a car.

Vanadium
Jan 8, 2005

Nomnom Cookie posted:

"Array" is not vague terminology in C, C++,

So I guess I will be okay if I dynamically allocate enough memory for N objects of type T and just have a pointer to them instead of declaring a T[N]?

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!
This is worst derail, occurring on ugliest track

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Vanadium posted:

So I guess I will be okay if I dynamically allocate enough memory for N objects of type T and just have a pointer to them instead of declaring a T[N]?

Yes, those are both arrays.

Vanadium
Jan 8, 2005

How is the former an array?


vvv that just means you access the elements of actual arrays through a pointer, it does not make everything you can point to an array

Vanadium fucked around with this message at 16:56 on Mar 18, 2010

HFX
Nov 29, 2004

Vanadium posted:

How is the former an array?

You do realize that the former is fundamentally what an array is right? You can very well do *(pointer + sizeof(object) * index). In fact [] is syntactic sugar for the pointer math.

Crazy RRRussian
Mar 5, 2010

by Fistgrrl
This is a retarded derail. Can we just all accept that an array is something contiguous in virtual memory that can be accessed via some sort of get_element_at_index() function? Unless you are a php programmer or something.

Vanadium. Those are both arrays. Just one is on heap and another one is on stack or in Data section.

HFX
Nov 29, 2004

LockeNess Monster posted:

This is a retarded derail. Can we just all accept that an array is something contiguous in virtual memory that can be accessed via some sort of get_element_at_index() function? Unless you are a php programmer or something.

Vanadium. Those are both arrays. Just one is on heap and another one is on stack or in Data section.

I can agree to that, and I'm sorry I joked about the list earlier since that lead to the derail.

HFX fucked around with this message at 16:38 on Mar 18, 2010

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

(found via irc)

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
haha, that's incredible

"Do you mean <question that probably gets asked approx. 20 times a day on that forum>? I can't answer anything more complicated than that."

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
If you want a laugh, I strongly recommend searching phpfreaks.com's forums for all of Q695's posts:

http://www.phpfreaks.com/forums/index.php?action=profile;area=showposts;u=70191

haku posted:

You have programming training?!?! :eek:

Q695 posted:

Yes, I have a degree in IT (my BS), focusing in Web Development (my AAS), and looking for work more along the lines of QA and eventually becoming an architect. Why is that so shocking?
(emphasis mine)

edit:

aaah hahahaha
http://www.phpfreaks.com/forums/index.php/topic,240167.0.html is pure gold. Q695 believed that using an HTML <input> type of 'password' automatically encrypted the data (with SSL) before sending it to the server.

Q695 posted:

Why did a college professor lie to me about it then? Why wouldn't password automatically encrypt the data when sending it?

I can appreciate not being knowledgeable; you have to learn somehow. He's just so arrogant in his stupidity, when his suggestions are almost all bad ideas and he's proven wrong by smarter people in almost every post. He's a jackass to people that try to help him, too: http://www.phpfreaks.com/forums/index.php/topic,240090.0.html

Lysidas fucked around with this message at 03:13 on Mar 19, 2010

nullfox
Aug 19, 2008
Jesus. H. Christ.

It's poo poo like ^^^^ that make me incredibly sad to be associated to PHP. I'll hazard a guess that poo poo like that and the general "php c0d3rz" creating awful, terrible code is the primary factor behind so much PHP hate these days.

We're not all like that, I promise! - Please don't lump us competent folks in with this lot.

</plea>

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
His lovely attitude has nothing to do with PHP, or any other language. He's just a bad programmer.

Crazy RRRussian
Mar 5, 2010

by Fistgrrl
I like how he is boasting with the fact that he went to college and had an OMG real life college professor tell him that!

wheezy360
Mar 8, 2006
I just ran into this comment while coming through client's jsp files.

code:
      <div class='left' id='sidebar'>
		<%-- 
			Please do not modify the indentation, modifying it causes 
			the html to break...
		--%>	
			<%@ include file="/include/inc_left_nav_search.jsp" %>				
      </div>

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer

LockeNess Monster posted:

I like how he is boasting with the fact that he went to college and had an OMG real life college professor tell him that!

Professors: fine for theory, always wrong on code.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply