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
tractor fanatic
Sep 9, 2005

Pillbug

GrumpyDoctor posted:

Then you'll love Boost MPL

That's pretty cool but lacks the wonderful fun of compile time prime factorization

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Sorry, but Boost.Units is goddamn sweet.

Bozart
Oct 28, 2006

Give me the finger.
One of my proudest moments at work was talking a good programmer out of building unit conversion into our research platform. That is one of the most painful and unending things you can do. And you ain't gunna get paid for it later.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Seems like this should go here:
http://arstechnica.com/software/news/2010/04/developers-apparently-love-net-hate-mfc-ruby-on-rails.ars

quote:

the results themsevels are surprising—in particular, the poor showing by Ruby on Rails. ... The framework was criticised particularly in the area of community support.

Perhaps unsurprisingly, the creator of Ruby on Rails, David Heinemeier Hansson, has rejected the report's claims. Hansson tells InfoWorld that the kind of developers that are Ruby on Rails' core constituency wouldn't even partipate in such a survey, being far more likely to trash e-mails from organizations like Evans as spam.

'See, the rails community is so much better than you that we simply can't be bothered with your pathetic little survey.'

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Well, given that the report included MFC and Win32 in a list of web frameworks...

UberJumper
May 20, 2007
woop

Munkeymon posted:

Seems like this should go here:
http://arstechnica.com/software/news/2010/04/developers-apparently-love-net-hate-mfc-ruby-on-rails.ars


'See, the rails community is so much better than you that we simply can't be bothered with your pathetic little survey.'

I never quite understood why most rails developers acted like complete and utter douchebags. I went to a technology conference last year, aside from Microsoft / IBM / Sun, it was a big ruby on rails circle jerk.

:bahgawd: Ruby on Rails will be the death of .Net and Java!
:btroll: Python/C++ will die too why would anybody use that!
:bahgawd: Now everybody drink your koolaid.

Sadily i think everybody drank the ruby koolaid. As a result i got to have dinner and chat with some lonely microsoft / sun guys. Ironically i checked up on those companies promoting ruby and majority of them have yet to release anything.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Ryouga Inverse posted:

Well, given that the report included MFC and Win32 in a list of web frameworks...

No it didn't? It's "frameworks", period.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Avenging Dentist posted:

No it didn't? It's "frameworks", period.

The report posted:

The frameworks included in this user satisfaction survey are:

Apache Axis
Apache Struts
Google App Engine
Google Web Toolkit
Java Server Faces
Microsoft MFC
Microsoft .NET
Microsoft Win32
Oracle ADF
Spring
Rails
Zend
Three of these things aren't like the others.

"Frameworks, period" would include Cocoa/Carbon, Qt, GTK, etc. This thing has no idea what it wants to focus on.

crazyfish
Sep 19, 2002

Ryouga Inverse posted:

Three of these things aren't like the others.

"Frameworks, period" would include Cocoa/Carbon, Qt, GTK, etc. This thing has no idea what it wants to focus on.

Not to mention that the company that conducted the survey is charging $595 to view the results.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Ryouga Inverse posted:

Three of these things aren't like the others.

"Frameworks, period" would include Cocoa/Carbon, Qt, GTK, etc. This thing has no idea what it wants to focus on.

The selection of, uh, 'frameworks' was odd to be sure, but I loved how the parts about RoR community are just so loving perfect.

'The Rails community is full of assholes'

"Yeah, that's 'cuz we're better than you could ever hope to be. Now watch me ignore this guy's question and mock him for not using operator precedence to remove some of the grouping operators in the irrelevant part of his example code :smuggo:"

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Ryouga Inverse posted:

Three of these things aren't like the others.

"Frameworks, period" would include Cocoa/Carbon, Qt, GTK, etc. This thing has no idea what it wants to focus on.

Wow, a Windows-centric developer survey? Well I never.

Shumagorath
Jun 6, 2001

UberJumper posted:

I never quite understood why most rails developers acted like complete and utter douchebags. I went to a technology conference last year, aside from Microsoft / IBM / Sun, it was a big ruby on rails circle jerk.

:bahgawd: Ruby on Rails will be the death of .Net and Java!
:btroll: Python/C++ will die too why would anybody use that!
:bahgawd: Now everybody drink your koolaid.

Sadily i think everybody drank the ruby koolaid. As a result i got to have dinner and chat with some lonely microsoft / sun guys. Ironically i checked up on those companies promoting ruby and majority of them have yet to release anything.
Throw it right back at them and say Ruby will be rendered obsolete by Scheme on Skis.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Mac OS X supports "frameworks", which are just a directory/bundle that contains a dynamic library and associated resources (header files, images, and what have you). The iPhone doesn't support creating custom frameworks -- you can only build static libraries. But I wanted to be able to embed a resource (an HTML file) into my .a file and refer to it from within classes in the library.

That meant writing a build step in my project that would take the file, run hexdump on it, and dump the bytes into a .c file formatted as hex character literals:

code:
cat "${INPUT_FILE}" | hexdump -v -e '"    " 8/1 "'\''x%02x'\'', " "\n"'
    | sed -e "s/\'x  \',//g" | sed -e "s/\'x/\'\\\\x/g" >> "${OUTPUT_FILE}"
:psypop:

The first pipe to sed is to get rid of the extra columns in the last row if the file length isn't a multiple of 8. The second pipe to sed would be unnecessary if I could figure out how to get the hexdump format string to output "\x" correctly, so instead I had to make it output like 'x00' and then use sed to insert the backslash. Whenever I tried to put the backslash in the hexdump -e argument, black magic would cause it to always output two backslashes.

Whatever, it works this way and I'll never have to touch it again.

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"

Flobbster posted:

:psypop:

what the gently caress? Why not use a real language?

code:
import sys
with open(sys.argv[1], "rb") as infile:
    with open(sys.argv[2], "wb") as outfile:
        outfile.write("".join("\\x%d" % ord(c) for c in infile.read())
or, if your builds need to work on everything, write the equivalent in 30 lines of C. Is saving 28 lines really worth the cost of maintenance on that shell garbage?

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

Flobbster posted:

code:
cat "${INPUT_FILE}" | hexdump -v -e '"    " 8/1 "'\''x%02x'\'', " "\n"'
    | sed -e "s/\'x  \',//g" | sed -e "s/\'x/\'\\\\x/g" >> "${OUTPUT_FILE}"

This is exactly the sort of trash Perl and Ruby were made to replace

loving come on mang

Zhentar
Sep 28, 2003

Brilliant Master Genius

Flobbster posted:

Whatever, it works this way and I'll never have to touch it again.

If you managed to type that sentence without great big warning alarms going off in your head, you have no foresight at all.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Zhentar posted:

If you managed to type that sentence without great big warning alarms going off in your head, you have no foresight at all.

Oh, I don't actually believe that, I just don't care enough to change it right now. I've got bigger fish to fry, and this is a hobby project anyway.

pseudorandom name
May 6, 2007

code:
	.globl html
	.type html, @object
html:
	.incbin "blah.html"
	.size html, .-html
:colbert:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Flobbster posted:

Oh, I don't actually believe that, I just don't care enough to change it right now. I've got bigger fish to fry, and this is a hobby project anyway.

Just bookmark Janin's post for when you need to change it.

at0mic.c0w
Jun 3, 2004
I just found this in a project i'm maintaining:

php:
<?php

{...}

//TODO: wtf?
$action $this->getRequest()->getParam('ADD',null) == null $this->getRequest()->getParam('SEARCH',null) == null ?
        $this->getRequest()->getParam('DELETE',null) == "X" 'DELETE' null 'SEARCH' 'ADD';     

{...}
    
?>

Heavy_D
Feb 16, 2002

"rararararara" contains the meaning of everything, kept in simple rectangular structures
Arrgh, nm...

Ari
Jun 18, 2002

Ask me about who Jewish girls should not marry!

at0mic.c0w posted:

php:
<?php

{...}

//TODO: wtf?
$action $this->getRequest()->getParam('ADD',null) == null $this->getRequest()->getParam('SEARCH',null) == null ?
        $this->getRequest()->getParam('DELETE',null) == "X" 'DELETE' null 'SEARCH' 'ADD';     

{...}
    
?>


You know what the worst part is? $this.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

Ari posted:

You know what the worst part is? $this.

I don't think your posting is that bad. :shobon:

qntm
Jun 17, 2009

Ari posted:

You know what the worst part is? $this.

What's wrong with $this?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
// TODO: wtf? is my favorite.

Though that is the worst abuse of the ternary operator I have ever seen.

An Outland Dish
Jul 26, 2009

by Tiny Fistpump

Ryouga Inverse posted:

// TODO: wtf? is my favorite.

Though that is the worst abuse of the ternary operator I have ever seen.

For one of my online homework questions in my intro to programming course for c++, one of the questions was:

" Assume that day is an int variable whose value is 1 or 2 or ... or 7. Write an expression whose value is "sun" or "mon" or ... or "sat" based on the value of day. (So, if the value of day were 4 then the value of the expression would be "wed".)."

The only acceptable solutions?

TuringsCraft posted:

CORRECT SUBMISSION 1 (70%, 42 submissions):
day == 1 ? "sun" : day == 2 ? "mon" : day == 3 ? "tue" : day == 4 ? "wed" : day == 5 ? "thu" : day == 6 ? "fri" : "sat"

CORRECT SUBMISSION 2 (23%, 14 submissions):
( day == 1 ) ? "sun" : ( day == 2 ) ? "mon" : ( day == 3 ) ? "tue" : ( day == 4 ) ? "wed" : ( day == 5 ) ? "thu" : ( day == 6 ) ? "fri" : "sat"

CORRECT SUBMISSION 3 (3%, 2 submissions):
day == 1 ? "sun" : day == 2 ? "mon" : day == 3 ? "tue" : day == 4 ? "wed" : day == 5 ? "thu" : day == 6 ? "fri" : day == 7 ? "sat" : ""

CORRECT SUBMISSION 4 (1%, 1 submissions):
(day == 1)?"sun": (day == 2)?"mon": (day == 3)?"tue": (day == 4)?"wed": (day == 5)?"thu": (day == 6)?"fri": (day == 7)?"sat":""

CORRECT SUBMISSION 5 (1%, 1 submissions):
(day==1 ? "sun" : (day==2 ? "mon" : (day==3 ? "tue" : (day==4 ? "wed" : (day==5 ? "thu" : (day==6 ? "fri" : "sat"))))))

Now none of my classmates use the ternary operator anymore. What a terrible example.

Khorne
May 1, 2002

An Outland Dish posted:

For one of my online homework questions in my intro to programming course for c++, one of the questions was:

" Assume that day is an int variable whose value is 1 or 2 or ... or 7. Write an expression whose value is "sun" or "mon" or ... or "sat" based on the value of day. (So, if the value of day were 4 then the value of the expression would be "wed".)."

The only acceptable solutions?


Now none of my classmates use the ternary operator anymore. What a terrible example.
Clearly the superior solution is to set an array named day_lut as a global

char* day_lut[8];
day_lut[1]='sun';
day_lut[2]='mon';
...
day_lut[7]='sat';

and then day_lut[day]; with no checking to see if day is a valid number


Why yes, there was tons of code like this at the place I was contracted to code for.

On a better note, while that is a terrible example for the ternary operator just take comfort in the fact it could have been worse. Just look at the example you responded to.

Khorne fucked around with this message at 05:21 on May 13, 2010

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

An Outland Dish posted:

For one of my online homework questions in my intro to programming course for c++, one of the questions was:

" Assume that day is an int variable whose value is 1 or 2 or ... or 7. Write an expression whose value is "sun" or "mon" or ... or "sat" based on the value of day. (So, if the value of day were 4 then the value of the expression would be "wed".)."

The only acceptable solutions?


Now none of my classmates use the ternary operator anymore. What a terrible example.
With decent formatting it's really not that bad:
code:
day == 1 ? "sun" :
day == 2 ? "mon" :
day == 3 ? "tue" :
day == 4 ? "wed" :
day == 5 ? "thu" :
day == 6 ? "fri" :
           "sat"
I wouldn't actually willingly write such a thing in C, but if you're used to a language with pattern matching or something along the lines of Scheme's cond it looks pretty natural. However, no one in such a class would be and a class that teaches a language should never require writing things that are unidiomatic for that language.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Khorne posted:

Why yes, there was tons of code like this at the place I was contracted to code for. On a better note, while that is a terrible example for the ternary operator just take comfort in the fact it could have been worse.

Your example is a clamp/assertion away from being the "right way" in C. Perhaps it is you who is the horror, goon sir? :smug:

Khorne
May 1, 2002

Avenging Dentist posted:

Your example is a clamp/assertion away from being the "right way" in C. Perhaps it is you who is the horror, goon sir? :smug:
The real horror is my failure to express myself clearly. The last line in my post wasn't meant to reference my actual post because I didn't user the ternary operator at all. :(

I personally use "that way" when I do things in C. I've even done it in scripting languages because the difference is often non-existent. The horror is when there are multiple arrays defined for the same purpose, using commonly used variable names/names that make no sense, no checking if the value is within bounds (especially when invalid values can and will be passed from time to time), and using it for everything including avoiding a simple if->else construct for two numerical values that aren't referenced anywhere else.

The look up table array thing is great when you have numbers assigned to strings and it gets referenced often or used in multiple functions/places, but it's really not great when you are just using it as a lazy one-off else-if and don't implement it properly. You know all of this, but I have to defend my C coding honor.

Khorne fucked around with this message at 05:27 on May 13, 2010

TagUrIt
Jan 24, 2007
Freaking Awesome
code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}
:confused:

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock

TagUrIt posted:

code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}
:confused:

fmod() is deep magic, it can't be trusted.

I actually did something almost exactly like that a few days ago:
code:
        while (positions.last()->pitch - pitch > 180.0) {
            pitch += 360.0;
        }

        while (positions.last()->pitch - pitch < -180.0) {
            pitch -= 360.0;
        }
I am not proud.

ymgve fucked around with this message at 15:31 on May 13, 2010

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe
An entire class where the only comment is

code:
//?
Thanks guys. That comment is TOTALLY useful.

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

clockwork automaton posted:

An entire class where the only comment is

code:
//?
Thanks guys. That comment is TOTALLY useful.
Sometimes comments are useful for what they tell you about the commenter.

manero
Jan 30, 2006

I just reverted a developer's ASCII art figlet comments from an 800+ line HTML/JS mishmash. I assume he put them in because it was too hard for him to find the code he needed to modify.

Is it too late in the evening to start drinking?

Edit: I don't think he even used figlet. He could at least have chosen a decent font.

manero fucked around with this message at 05:07 on May 14, 2010

tripwire
Nov 19, 2004

        ghost flow

manero posted:

I just reverted a developer's ASCII art figlet comments from an 800+ line HTML/JS mishmash. I assume he put them in because it was too hard for him to find the code he needed to modify.

Is it too late in the evening to start drinking?

Edit: I don't think he even used figlet. He could at least have chosen a decent font.

Spoilsport :(

Lexical Unit
Sep 16, 2003

TagUrIt posted:

code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}

ymgve posted:

code:
        while (positions.last()->pitch - pitch > 180.0) {
            pitch += 360.0;
        }

        while (positions.last()->pitch - pitch < -180.0) {
            pitch -= 360.0;
        }
Y'all must be my coworkers. I work with code like that every day of my life.

POKEMAN SAM
Jul 8, 2004

TagUrIt posted:

code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}
:confused:

Wait wtf, after seeing the loops I missed the real horror of the return line...

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Ugg boots posted:

Wait wtf, after seeing the loops I missed the real horror of the return line...

Hahahaha I just saw that right now.

Adbot
ADBOT LOVES YOU

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Ugg boots posted:

Wait wtf, after seeing the loops I missed the real horror of the return line...

Is there any conceivable reason why you might think that was in any way sensible? Some standard return format or something?

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