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
Hot Dog Day #55
May 22, 2003

The noblest of all dogs is the hot-dog; it feeds the hand that bites it.
code:
bool function(EnumValue p_enum)
{
   if (p_enum == EnumValue::valueOne)
   {
       return false;
   }
   else if (p_enum == EnumValue::valueTwo)
   {
       return true;
   }
   else switch (p_enum)
   {
       case EnumValue::valueThree:
       case EnumValue::valueFour:
            return false;
       default:
            return true;
   }
}
Obviously, rewritten from memory. I didn't even realize that last portion was possible (C++).

Adbot
ADBOT LOVES YOU

Contra Duck
Nov 4, 2004

#1 DAD

Hammerite posted:

http://falconpl.org/index.ftd?page_id=facts

Witness the power of facts! :yum:

Wow, check out that performance, it's three times faster than Perl at executing an empty loop!

tractor fanatic
Sep 9, 2005

Pillbug

Hot Dog Day #55 posted:

Obviously, rewritten from memory. I didn't even realize that last portion was possible (C++).

In C, else if works because an if/else block is treated as a single statement for the purpose of needing braces.

This program will output "yes" for example

code:
int main()
{
    if (1)
       if (0) printf("no");
       else printf("yes");
    else printf("maybe");
    return 0;
}

Hot Dog Day #55
May 22, 2003

The noblest of all dogs is the hot-dog; it feeds the hand that bites it.

tractor fanatic posted:

In C, else if works because an if/else block is treated as a single statement for the purpose of needing braces.

Huh, I did know that, but hadn't considered that was what was occurring on the else switch. I feel a bit sheepish posting that now.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Hammerite posted:

http://falconpl.org/index.ftd?page_id=facts

Witness the power of facts! :yum:
Apparently it's the only language that provides "direct binary data access"

quote:

Scripting languages are mainly designed to work with abstract data, as (floating point) numbers or strings.

What the physical machine knows is just memory and its binary numeric contents; and along with the physical machine, this is generally what is known by native code interfacing the physical machine and the scripting language.

Other than knowing abstract data, Falcon is also able to deal with low level representation of memory areas. This makes it much simpler and direct when dealing with binary content which is a common task in IT. For example, it is possible to see data streams from a local filesystem or from the network as both textual data and as binary sequences. You can access the bytes in files and memories directly, without wrapping libraries; and this is done safely, protected by the VM efficiently checking for correct usage of this power.
Witness the power of lies!

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


I'm working with a team who is writing a java app that has two very simple parts. The first piece polls a database at a regular interval and generates a report on various data. The second piece is a webservice that serves the report as well as exposing some methods that will update data based on the contents of the report. It's fairly simple.

Except that in order to accomplish this they split it into two distinct programs that each contain the same jars. The webservice lives in a tomcat container. The poller is a standalone java app. When I asked why they didn't just include the poller in the tomcat container as a timer class they replied "we couldn't figure out how".

Does this count as a horror?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Is there any reason for doing

var someString = ["qwe","rty"].join('');

instead of

var someString = "qwe"+"rty";

in Javascript?

e: actually, the code I'm looking at is more like

var someString = ["qwe","rty", "ui"+"op"].join('');

Wheany fucked around with this message at 12:57 on May 12, 2011

Zombywuf
Mar 29, 2008

Wheany posted:

Is there any reason for doing

var someString = ["qwe","rty"].join('');

instead of

var someString = "qwe"+"rty";

in Javascript?

e: actually, the code I'm looking at is more like

var someString = ["qwe","rty", "ui"+"op"].join('');

Or in fact doing var someString = "qwertyuiop"; :psyduck:

Let me guess, advert code?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Wheany posted:

Is there any reason for doing

var someString = ["qwe","rty"].join('');

instead of

var someString = "qwe"+"rty";

in Javascript?

e: actually, the code I'm looking at is more like

var someString = ["qwe","rty", "ui"+"op"].join('');

Not really.

It's not what you were asking about, but I could kind-of see doing

['hello', name + '.', 'how are you?'].join(' ')

because it would mean you wouldn't have to remember to put spaces in all the right places.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Zombywuf posted:

Or in fact doing var someString = "qwertyuiop"; :psyduck:

Let me guess, advert code?

It uses variables, so it cannot be just "qwertyuiop".

And it's not advert code, just poo poo. If I had to guess, it's either an :airquote:optimization:airquote: or the coder didn't know you could just use a + to concatenate strings.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Okay, for some reason the layout of an element is different in IE 8 than in other browsers, let's invesigate... Hmm, that is quite a DOM tree. I'll try the console:
code:
> asd = document.getElementById("id19")
> asd
<input type="checkbox" id="id19">
> asd.parentElement.parentElement.(30 more).parentElement.parentElement
<body>...</body>
:froggonk:

e: Here is the CSS path with ids and classes removed:
html body div div table tbody tr td div div div div div table tbody tr td div div div div div div div div div div div div div table tbody tr td a input

Wheany fucked around with this message at 15:32 on May 12, 2011

All Hat
Jul 11, 2008

He that is without int among you, let him first cast a long

Wheany posted:

Is there any reason for doing

var someString = ["qwe","rty"].join('');

instead of

var someString = "qwe"+"rty";

in Javascript?

e: actually, the code I'm looking at is more like

var someString = ["qwe","rty", "ui"+"op"].join('');

join used to be more efficient, not sure if it is anymore.

http://www.google.com/search?hl=no&client=opera&hs=zKY&rls=nb&channel=suggest&q=javascript+concatenate+string+vs+join&aq=f&aqi=&aql=&oq=

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Surely this statement is meaningless without an indication of whose javascript engine you are talking about? I mean, I'm assuming this is something that might vary between browsers.

McGlockenshire
Dec 16, 2005

GOLLOCKS!
It might be based on this 2008 article. Older IEs seem to perform better using join().

Given the radical changes to how modern Javascript engines work, it's likely that the results might be different now.

Munkeymon
Aug 14, 2003

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



IE6 has a better worst case run time when using .join than concatenating with the + operator, but, at least in my testing, you had to be working with 500+ parts to really notice. I'm assuming there was also some horrific memory leak where every intermediate string in the concatenation chain had to be created and didn't go away.

Sometimes I prefer joining on an array just because I think it ends up looking a bit cleaner when you have enough variables going around. Also, it's easier to type a comma than a plus if you're feeling lazy.

Melted_Igloo
Nov 26, 2007

Wheany posted:

Okay, for some reason the layout of an element is different in IE 8 than in other browsers, let's invesigate... Hmm, that is quite a DOM tree. I'll try the console:
code:
> asd = document.getElementById("id19")
> asd
<input type="checkbox" id="id19">
> asd.parentElement.parentElement.(30 more).parentElement.parentElement
<body>...</body>
:froggonk:

e: Here is the CSS path with ids and classes removed:
html body div div table tbody tr td div div div div div table tbody tr td div div div div div div div div div div div div div table tbody tr td a input

Dunno seems like the browser should scream some warning if the node path gets past like 20 levels, or at least there should be some plugin that does that

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Melted_Igloo posted:

Dunno seems like the browser should scream some warning if the node path gets past like 20 levels, or at least there should be some plugin that does that

Rule #1 of web development: Browsers don't scream about *anything*.

zeekner
Jul 14, 2007

Monkeyseesaw posted:

Rule #1 of web development: Browsers don't scream about *anything*.

They cry themselves to sleep instead.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

Geekner posted:

They cry themselves to sleep instead.

Browsers aren't smart enough to cry about the atrocities they commit, they just do whatever they can to make something out of what they're given. If that happens to be, for example, the full path to one of the backend databases, well, they're just happy that they could display something for you. :downs:

All Hat
Jul 11, 2008

He that is without int among you, let him first cast a long

Hammerite posted:

Surely this statement is meaningless without an indication of whose javascript engine you are talking about? I mean, I'm assuming this is something that might vary between browsers.

ya, sure. but that article McGlockenshire links to is probably where array joins instead of straight concat comes from in most cases.

NotShadowStar
Sep 20, 2000

Wheany posted:

Is there any reason for doing

var someString = ["qwe","rty"].join('');

instead of

var someString = "qwe"+"rty";

in Javascript?

e: actually, the code I'm looking at is more like

var someString = ["qwe","rty", "ui"+"op"].join('');

If ui, op are variables and are numbers or potentially are integers, it would add them first and coerce it into a string. Which may or may not be what you wanted.

Impotence
Nov 8, 2010
Lipstick Apathy

Monkeyseesaw posted:

Rule #1 of web development: Browsers don't scream about *anything*.

code:
try {
	// Everything
}

catch (e) {}

nielsm
Jun 1, 2009



Biowarfare posted:

code:
try {
	// Everything
}

catch (e) {}

More concisely:

ON ERROR RESUME NEXT

Fiend
Dec 2, 2001

nielsm posted:

More concisely:

ON ERROR RESUME NEXT

Hey this is what I used to do to get my vbscripts to work!

Opinion Haver
Apr 9, 2007

Biowarfare posted:

code:
try {
	// Everything
}

catch (e) {}

If I ever write a language this will be a compile-time error.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

All Hat posted:

ya, sure. but that article McGlockenshire links to is probably where array joins instead of straight concat comes from in most cases.

But has this really been an issue anywhere ever? I mean has the performance of string concatenation ever mattered except for benchmarks?

pseudorandom name
May 6, 2007

yaoi prophet posted:

If I ever write a language this will be a compile-time error.

code:
try {
	// Everything
}

catch (e) { DoNothing(e); }
Your move.

Munkeymon
Aug 14, 2003

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



Wheany posted:

But has this really been an issue anywhere ever? I mean has the performance of string concatenation ever mattered except for benchmarks?

Yep, it is where I work, and it's a pretty hosed up scenario.

All Hat
Jul 11, 2008

He that is without int among you, let him first cast a long

I truly have no idea. I can't really think of a situation where concatenating >500 strings would seem like a genuinely good idea, so I suppose not.

Opinion Haver
Apr 9, 2007

pseudorandom name posted:

code:
try {
	// Everything
}

catch (e) { DoNothing(e); }
Your move.

Yeah but at least there's something.

Hughlander
May 11, 2005

pseudorandom name posted:

code:
try {
	// Everything
}

catch (e) { DoNothing(e); }
Your move.

Make it a compile time error after the optimizing compiler gets done with it.

NotShadowStar
Sep 20, 2000
pre:
public static int Main()
try {
 App.Init()
} catch(ex) {
 //nothing
} finally {
 return 0
}
Totally safe. More uptime!

PalmTreeFun
Apr 25, 2010

*toot*

yaoi prophet posted:

If I ever write a language this will be a compile-time error.

Error: Failed to understand purpose of exceptions. Initiating auto-pilot.

pseudorandom name
May 6, 2007

Hughlander posted:

Make it a compile time error after the optimizing compiler gets done with it.

That would require whole program optimization, and even then I could probably come up with a control flow that your compiler couldn't follow.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

All Hat posted:

I truly have no idea. I can't really think of a situation where concatenating >500 strings would seem like a genuinely good idea, so I suppose not.

Probably just about every corporate intranet that should be using a dedicated database/CMS setup but isn't.

TasteMyHouse
Dec 21, 2006

pseudorandom name posted:

That would require whole program optimization, and even then I could probably come up with a control flow that your compiler couldn't follow.

yeah but if you can outthink the compiler to that degree you'd probably realize that catch all do nothing is a terrible idea.

pseudorandom name
May 6, 2007

You'd be surprised by how ingenious incompetents can be.

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

"Wheany" posted:

But has this really been an issue anywhere ever? I mean has the performance of string concatenation ever mattered except for benchmarks?

Can help when you're heap-spraying, though I suppose that's technically a bad thing.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Best way to separate content and presentation using CSS?

<td class="bold">

e: Not a horror, but pretty dumb anyway.

Adbot
ADBOT LOVES YOU

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
.bold {font-style:italic;}

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