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
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
We have a ton of these littered around our codebase:

code:
if (name == "texture.d3dtx") {
    int a = 1;
}
I might have added a few to the pile.

Adbot
ADBOT LOVES YOU

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I just sincerely wrote (in Go) the type map[string][]map[string]interface{}.

Eela6
May 25, 2007
Shredded Hen

TooMuchAbstraction posted:

I just sincerely wrote (in Go) the type map[string][]map[string]interface{}.

I've done it, too. Using the reflect package?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Eela6 posted:

I've done it, too. Using the reflect package?

No, this was converting a JSON blob into something usable. That said, it's kind of shocking how your options for Go are either to tediously enumerate everything by hand, use a code generator, or leap off the deep end into reflection.

canis minor
May 4, 2011

I find this impressive, but also terrifying

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


ChickenWing posted:

in before "what tests?"

It compiles, isn't that enough of a test?

Dirty Frank
Jul 8, 2004

Suspicious Dish posted:

We have a ton of these littered around our codebase:

code:
if (name == "texture.d3dtx") {
    int a = 1;
}
I might have added a few to the pile.

Seeing as you're admitting to it, there's going to be a good reason, so, you know, go on...

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Dirty Frank posted:

Seeing as you're admitting to it, there's going to be a good reason, so, you know, go on...

the conditional breakpoint gui in visual studio has been broken for like three releases now

Dirty Frank
Jul 8, 2004

Suspicious Dish posted:

the conditional breakpoint gui in visual studio has been broken for like three releases now

ha! ok, don't check them in though, that is naughty!

also for anyone using c# it works fine, this poor bastard is using c++ I'm guessing?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
uh yes our game engine is c++ like every other one in existence

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Suspicious Dish posted:

uh yes our game engine is c++ like every other one in existence

Have you heard of Unity, by any chance?

iospace
Jan 19, 2038


duz posted:

It compiles, isn't that enough of a test?

The Fool
Oct 16, 2003


TooMuchAbstraction posted:

Have you heard of Unity, by any chance?

The actual engine is written C++.

Unity Website posted:

Native C++ performance across platforms with Unity-developed back-end IL2CPP scripting

That being said, there are game engines in every major language.

And some that don't make sense.

The Fool fucked around with this message at 00:05 on Dec 7, 2017

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

The Fool posted:

The actual engine is written C++.

Ah, my mistake. Thanks for the correction.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

TooMuchAbstraction posted:

No, this was converting a JSON blob into something usable. That said, it's kind of shocking how your options for Go are either to tediously enumerate everything by hand, use a code generator, or leap off the deep end into reflection.

TooLittleAbstraction

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

The Phlegmatist posted:

These get posted every once in a while in this thread and I'm like 95% sure it's people who learned to program using Perl, since ca. Perl 5 and Perl Best Practices that was a common idiom to guarantee you returned a boolean value and not something else.

e: along with return (var? || false)

Did you learn to program with Perl? There is no 'true', no 'false', and very explicit rules in the basic documentation. Likewise in perlintro, and the common idiom is to make use of undef==false in subroutine returns.

Looks more like Python (and Ruby in the edit).

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

TooMuchAbstraction posted:

Have you heard of Unity, by any chance?

yes. the core engine is in C++ but they added mono bindings and that's where they want you to program, but there is a large chunk of actual C++ engine. they sometimes compile your mono C# to C++ for platforms where they can't ship a JIT engine.

Jeb Bush 2012
Apr 4, 2007

A mathematician, like a painter or poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas.

PhantomOfTheCopier posted:

Did you learn to program with Perl? There is no 'true', no 'false'

sure there is!

code:
bash$ perl -e 'if (false) { print(":D\n") }'
:D

boo_radley
Dec 30, 2005

Politeness costs nothing

canis minor posted:

I find this impressive, but also terrifying

Hey, gently caress you, buddy.

quote:

Alice is a two-dimensional, stack-based, recreational programming language. It was designed as a feature-rich Fungeoid with many useful (and some not so useful) commands which make it comparably usable for a 2D language. To this end, depending on whether the instruction pointer moves orthogonally or diagonally, Alice operates either in an integer mode or in a string mode, which allows every operator to be overloaded with two different commands.

Loezi
Dec 18, 2012

Never buy the cheap stuff

canis minor posted:

I find this impressive, but also terrifying

This is so far beyond the realm of my understanding and comfort zone, that I'm only getting a somewhat eldritch vibe. Pretty much i_know_some_of_these_words.png

Dylan16807
May 12, 2010

Loezi posted:

This is so far beyond the realm of my understanding and comfort zone, that I'm only getting a somewhat eldritch vibe. Pretty much i_know_some_of_these_words.png

It's something where visual aids would go a long way, especially an animation of a program running.

While it's pretty difficult to follow the description, the actual language is not very complex.

Your program looks like a word search; a big grid of characters that's loaded into RAM. A cursor bounces around and every character it touches is an instruction to execute. It has math instructions, text instructions, goto instructions, everything you need to compute. Plus there's a couple stacks for temporary data storage.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

ratbert90 posted:


- A SUPERCLASS DEPENDED ON A SUBCLASS OF ITSELF. When I saw that I drat near had an aneurysm.


Athas posted:

How does this work in C++? Is this some shenanigans with forward-declared classes that just end up not causing a linker/compiler error by chance (because of no data members?)?

Was it CRTP? We had a bunch of code that used to use that because the devs on that team were scared of vtable lookup latency so all of their polymorphism was at compile time. Also they had their code set up as a chain of different stages, each stage templated with its input and output destinations, which if you think about it for a moment means that each stage had all of the others as a template argument.

They would frequently have problems with hitting MSVC's template recursion depth limit and if they ever got a compile error... well, we don't talk about that in public.

Pollyanna
Mar 5, 2005

Milk's on them.


code:
if(!bowser.firefox){

iospace
Jan 19, 2038


Pollyanna posted:

code:
if(!bowser.firefox){

Go on...

repiv
Aug 13, 2009

https://www.npmjs.com/package/bowser

The code looks valid, but browser detection in general is its own horror...

Pollyanna
Mar 5, 2005

Milk's on them.


repiv posted:

https://www.npmjs.com/package/bowser

The code looks valid, but browser detection in general is its own horror...

Haha gently caress, teaches me to assume something is a typo. I can imagine unaware devs “fixing” a codebase full of errors...

Munkeymon
Aug 14, 2003

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



repiv posted:

https://www.npmjs.com/package/bowser

The code looks valid, but browser detection in general is its own horror...

And sometimes unavoidable when you're using newer APIs that don't behave consistently.

Reformed Pissboy
Nov 6, 2003

One of our QA guys taught himself Python and made a whole Tk app with multithreading and serial communication and stuff, but he never learned about the "and" keyword :nyoron:

Python code:
if response != '':  # if the power is off the serial input is just blank so detect and notify
   if response[10] == ' ':
      if response[0] == ' ' or response[0] == '+' or response[0] == '-':
         if '.' in response:
            if response[14:16] == '\r\n':
               stilltrying = False
               style1 = ttk.Style()
               style1.configure('connected.TButton', background='green')
               self.connect_button.configure(style='connected.TButton')
               self.button_tare_scale.configure(state='enabled')
            else:
               self.ser.close()
         else:
            self.ser.close()
      else:
         self.ser.close()
   else:
      self.ser.close()
else:
   self.ser.close()

nielsm
Jun 1, 2009



Suggest that he pack the validation logic into a separate function with early return:

Python code:
def response_is_valid(response):
  if response == '':  # if the power is off the serial input is just blank so detect and notify
    return false
  if response[10] != ' ':
    return false
  if response[0] not in "+ -":
    return false
  if '.' not in response:
    return false
  if response[14:16] != '\r\n':
    return false
  return true

if response_is_valid(response):
  stilltrying = False
  style1 = ttk.Style()
  style1.configure('connected.TButton', background='green')
  self.connect_button.configure(style='connected.TButton')
  self.button_tare_scale.configure(state='enabled')
else:
  self.ser.close()
Really, commend the guy, he may be able to grow and become really valuable.

nielsm fucked around with this message at 19:47 on Dec 7, 2017

canis minor
May 4, 2011

boo_radley posted:

Hey, gently caress you, buddy.

I aim to please :) On the other hand Bob is more what I'm accustomed to.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Reformed Pissboy posted:

One of our QA guys taught himself Python and made a whole Tk app with multithreading and serial communication and stuff, but he never learned about the "and" keyword :nyoron:

That’s super cool. Enjoy the look on QA guy's face when you show them and!

The Phlegmatist
Nov 24, 2003

PhantomOfTheCopier posted:

Did you learn to program with Perl? There is no 'true', no 'false', and very explicit rules in the basic documentation. Likewise in perlintro, and the common idiom is to make use of undef==false in subroutine returns.

Looks more like Python (and Ruby in the edit).

Yeah, that was the way I was taught (I tried to generalize the examples a little bit since I don't maintain Perl anymore, just maintain code from ex-Perl programmers.)

But we were taught that all functions need to have a single point of return and that if the function was meant to return a boolean, we needed to specifically return the result in a boolean context by returning a conditional. That's probably a paranoid level of defensive programming, but it was in vogue at the time.

FlapYoJacks
Feb 12, 2009
I am the coding horror.

I made a function yesterday that takes a vector pair and can hack up a string several times based off of what was passed via the vector. :v:

std::string testString = "1:2:3 4:5:6,7,8";
std::vector<std::pair<std::string, int> > delimiters = {{" ", 1}, {":", -1}, {",", 1}};
std::vector<std::string> returnVector = multiSplit(testString, delimiters);

This would return a vector of strings containing 4, 5, and 7.

It's me, I am the coding horror. I could have used boost, but I didn't want to actually do any real work yesterday. :v:

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
code:

class MemAnal

Never abbreviate that word!

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Yeah, it's dumb. And "meme" is only four letters anyway.

CPColin
Sep 9, 2003

Big ol' smile.

Doc Hawkins posted:

"meme" is only four letters anyway.

Mean Al: *gets confused about the "Me Mean Al" class, files HR complaint with lots of bad grammar*

CPColin fucked around with this message at 20:48 on Dec 8, 2017

joebuddah
Jan 30, 2005
I just got handed a project that got the author a promotion. Of course after I get it, it starts to bog down the system.

I find he was using 6 stored functions for each insert statement.

Each function did aggregate functions that could have done with computed columns or subqueries.

Each insert using the functions took 3 seconds. Given that I have over 50 iot devices polling ever minute. That leads to a big slow down.

Coffee Mugshot
Jun 26, 2010

by Lowtax
Turns out promoting people based on launching projects rather than sustaining a project's growth is the real coding horror.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

joebuddah posted:

I just got handed a project that got the author a promotion. Of course after I get it, it starts to bog down the system.

I find he was using 6 stored functions for each insert statement.

Each function did aggregate functions that could have done with computed columns or subqueries.

Each insert using the functions took 3 seconds. Given that I have over 50 iot devices polling ever minute. That leads to a big slow down.

50 iot devices per minute??? Better switch to Kafka/Spark because you have a case of the Big Data™

Adbot
ADBOT LOVES YOU

Carbon dioxide
Oct 9, 2012

Suspicious Dish posted:

50 iot devices per minute??? Better switch to Kafka/Spark because you have a case of the Big Data™

You misspelled MongoDB.

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