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.
 
  • Locked thread
AWWNAW
Dec 30, 2008

HoboMan posted:

ok so linq is still jank magic as far as i'm concerned so tell me if i'm wrong but it think the first select here is unnecessary
C# code:
return ds.Tables[0].Select("", "TaskCode").Select(row => row["TaskCode"].ToString()).ToArray();

don't think that first Select is even LINQ, think that's some data table thing https://msdn.microsoft.com/en-us/library/system.data.datatable.select(v=vs.110).aspx that appears to be sorting

Adbot
ADBOT LOVES YOU

AWWNAW
Dec 30, 2008

anyway yeah you could get rid of the first select but you'd have to replace it with a LINQ sort after the LINQ select

NihilCredo
Jun 6, 2011

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

if you're dealing with yuuuge DataTable poo poo, in my experience you should try to use their native methods as much as possible. feeding them to a LINQ expression requires casting which is shockingly slow. i once found myself eating a ~6 seconds lag on a table of a few thousand entries just because i had a type annotation in a foreach loop.

if the table is small though then gently caress it, LINQ all the way and forget their ugly-rear end mutation-happy API even exists. i even wrote myself extension methods for datatable/view/gridview just to avoid typing .Table.Rows.Cast<DataRow> every time

compuserved
Mar 20, 2006

Nap Ghost

Illusive gently caress Man posted:

i still get my own stuff done, but it's def a time waster.

lol if you don't waste as much time as you possibly can

HoboMan
Nov 4, 2010

compuserved posted:

lol if you don't waste as much time as you possibly can

why do you think i even post in this thread?

Bloody
Mar 3, 2013

HoboMan posted:

why do you think i even post

Bloody
Mar 3, 2013

hosed up part is that i do it around the clock tho

brap
Aug 23, 2004

Grimey Drawer
aren't SQL statement mappers hot poo poo these days?

akadajet
Sep 14, 2003

fleshweasel posted:

aren't SQL statement mappers hot poo poo these days?

yep.

and so is mongo.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Dylan16807 posted:

oh I know how the dumb feature works, but you can do very similar things in lots of statically-typed languages

should be able to get the syntax very close in C++

without taking advantage of implementation details and possibly your operating system, unless they've added Smalltalk/ObjC/Java-style reflection to C++11/14/17 without me knowing about it, you won't be able to implement something like this in a generic way because it requires looking up a variable given a string at runtime

Stroustrup claimed last decade they wouldn't add that kind of reflection because it bloats binary sizes by 50% for .NET, I had to point out the same kind of stuff for ObjC only adds about 10% and for the level of power it gives the framework designer, that cost is very well worth paying for

of course at that same meeting he said dynamic linking and stable ABIs were something best left to the market, so…

eschaton fucked around with this message at 02:40 on Apr 8, 2016

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

fleshweasel posted:

aren't SQL statement mappers hot poo poo these days?

Quite literally, in that they're rather popular and also giant turds.

Shaggar
Apr 26, 2006
statement mappers are good. orms are bad.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

gonadic io posted:

As much as I don't like programming in it that much, if you're making something that you plan to sell and have a free choice of language and infrastructure then C# is probably the best choice for stuff that isn't a website or a mobile app.

if you're building an application for professionals to use to get work done you'll use Objective-C or Swift because that's what you use to program the only computers worth using

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Bloody posted:

now if your using ammonia that's a whole nother ball of safety wax

best treated with chlorine bleach

homercles
Feb 14, 2010

everyone knows SQL, so lets throw all that away and learn this funky new orm api that has half the power, half the expressiveness and increases a huge amount of complexity. oh and none of the devs know how to really use it so we're back to doing thousands of single-row loads instead of anything vaguely intelligent

akadajet
Sep 14, 2003

homercles posted:

everyone knows SQL, so lets throw all that away and learn this funky new orm api that has half the power, half the expressiveness and increases a huge amount of complexity. oh and none of the devs know how to really use it so we're back to doing thousands of single-row loads instead of anything vaguely intelligent

this too has been my experience with orms

homercles
Feb 14, 2010

and lets do all this in a plang language that has no code completion so devs wont even bother experimentally trying to code complete to see what functions they might be missing out on

akadajet
Sep 14, 2003

homercles posted:

and lets do all this in a plang language that has no code completion so devs wont even bother experimentally trying to code complete to see what functions they might be missing out on

i miss c# code complete :(

akadajet
Sep 14, 2003

js devs don't like to document poo poo, so i'm always trudging through source code to figure out what api's are available

brap
Aug 23, 2004

Grimey Drawer

eschaton posted:

if you're building an application for professionals to use to get work done you'll use Objective-C or Swift because that's what you use to program the only computers worth using

im a mac user and i just have to lol at this

JewKiller 3000
Nov 28, 2006

by Lowtax
integer division should have a separate operator imo, call it "div" or something, just not "/". if x = 1 and y = 2 then i want x / y = 0.5, i don't care if x and y are both ints. in fact i cannot think of a single instance in my programming career where i wanted the integer division behavior

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
personally, I can't think of a single instance where I wanted dividing two integers to suddenly drop a dozen bits of precision because they're now floats. to each their own I guess.

JewKiller 3000
Nov 28, 2006

by Lowtax
floating point is not the only possible representation of decimal numbers

Jerry Bindle
May 16, 2003
there is a part in a knuth book that talks about computing with rational numbers but i'm too fuckin stupid to understand it. something about chinese remainder theorems?

brap
Aug 23, 2004

Grimey Drawer
chances are if you're integer dividing you're going on to use it as an index in an array or some poo poo

Dylan16807
May 12, 2010

eschaton posted:

without taking advantage of implementation details and possibly your operating system, unless they've added Smalltalk/ObjC/Java-style reflection to C++11/14/17 without me knowing about it, you won't be able to implement something like this in a generic way because it requires looking up a variable given a string at runtime

Stroustrup claimed last decade they wouldn't add that kind of reflection because it bloats binary sizes by 50% for .NET, I had to point out the same kind of stuff for ObjC only adds about 10% and for the level of power it gives the framework designer, that cost is very well worth paying for

of course at that same meeting he said dynamic linking and stable ABIs were something best left to the market, so…

they're all accessed through the $, so you don't actually have to make them local variables.

but if you really want an abomination it wouldn't be all that hard. make a declaration macro that creates the variable and then inserts the name and a pointer into the data structure. you don't need runtime reflection.

it might not look exactly the same as php, but you can get pretty close. for extra fun replace $ with *, everyone loves overloaded dereferencing

Plorkyeran
Mar 22, 2007

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

fleshweasel posted:

im a mac user and i just have to lol at this

the various mail apps for ios are probably all mostly written in obj-c or swift and are used a lot by professions for getting work done.

and xcode, but counting that is kinda circlejerky

and then, uh... keynote? i've never seen any evidence that anyone uses any of the other iwork programs, but i guess there must be at least a few users

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

akadajet posted:

js devs don't like to document poo poo, so i'm always trudging through source code to figure out what api's are available

or they document poo poo only superficially, so it looks like good documentation at first

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
hey speaking of Car extends Vehicle, i remember people talking about nethack's creature types and how one creature can polymorph into another type with different weaknesses and strenghts and such, and because of that, CaveTroll extends Troll extends Creature doesn't really work.

so how would you check for a monster's weakness for petrification when the player hits it with a cockatrice corpse without going all
code:
switch(attack_type) {
	case ATTACK_TYPE_COCKATRICE_CORPSE:
		switch(target_creature_type):
			case CREATURE_TYPE_CAVE_TROLL:
in the year 2016?

homercles
Feb 14, 2010

I like the android javadoc search feature in the top-right for http://developer.android.com/reference/packages.html where you type in a package name substring and it highlights matches. Is there a nice way to take Java8 source code and source code for whatever libraries I'm using, and build a combined nicely styled javadoc with the package substring search to store locally?

FamDav
Mar 29, 2008

Wheany posted:

hey speaking of Car extends Vehicle, i remember people talking about nethack's creature types and how one creature can polymorph into another type with different weaknesses and strenghts and such, and because of that, CaveTroll extends Troll extends Creature doesn't really work.

so how would you check for a monster's weakness for petrification when the player hits it with a cockatrice corpse without going all
code:
switch(attack_type) {
	case ATTACK_TYPE_COCKATRICE_CORPSE:
		switch(target_creature_type):
			case CREATURE_TYPE_CAVE_TROLL:
in the year 2016?

you have weakness and type be components all things

code:
if (attackee.weakness == attacker.type) {
  damage *= attacker.weaknessMultiplier
}
one possible solution is to go with an entity component system, which at a super high level looks like a roughly schema'd database that various components (rendering, collision detection, health management, death, etc.) iterate over and update.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Wheany posted:

hey speaking of Car extends Vehicle, i remember people talking about nethack's creature types and how one creature can polymorph into another type with different weaknesses and strenghts and such, and because of that, CaveTroll extends Troll extends Creature doesn't really work.

so how would you check for a monster's weakness for petrification when the player hits it with a cockatrice corpse without going all
code:

switch(attack_type) {
	case ATTACK_TYPE_COCKATRICE_CORPSE:
		switch(target_creature_type):
			case CREATURE_TYPE_CAVE_TROLL:
in the year 2016?

multiple inheritance and multimethod dispatch in CLOS, so all that is done for you by the language

Lisp code:
(defgeneric attack (attack target-creature))

(defmethod attack ((attack <attack>) (target-creature <creature>))
  "general attack behavior"
  …)

(defmethod attack ((attack <cockatrice-corpse-attack>) (target-creature <cave-troll>))
  "specialized behavior when a cave troll is attacked with a cockatrice corpse"
  …)

(defclass <cockatrice-corpse-attack> (<attack> <creature>)
  "a kind of attack that uses a cockatrice corpse"
  …)

(I'm using the Dylan convention of putting angle brackets around class names above)

multiple inheritance lets you create a cockatrice corpse attack by combining the classes, and multimethod dispatch lets you specialize the attack method on both parameters, so you only need to implement the meaningful combinations; the standard method combination system will take care of the rest

you would probably really make <cockatrice-corpse-attack> not descend from <creature>, and instead take the instrument of an attack as a parameter when creating it. then you could specialize make-instance so that when it's asked for an attack using a cockatrice corpse, it returns an instance of the right <attack> subclass

listening to the Software Engineering Daily interview with the Dwarf Fortress dude, I seriously thought he'd be better off with a system like CLOS than either single or multiple inheritance in C++

raminasi
Jan 25, 2005

a last drink with no ice

Wheany posted:

hey speaking of Car extends Vehicle, i remember people talking about nethack's creature types and how one creature can polymorph into another type with different weaknesses and strenghts and such, and because of that, CaveTroll extends Troll extends Creature doesn't really work.

so how would you check for a monster's weakness for petrification when the player hits it with a cockatrice corpse without going all
code:
switch(attack_type) {
	case ATTACK_TYPE_COCKATRICE_CORPSE:
		switch(target_creature_type):
			case CREATURE_TYPE_CAVE_TROLL:
in the year 2016?

if you've got n attacks and m attackables you need to encode n*m cases, there's no way around it. the basic decision is whether you model the logic as a two-level tree, like your example (and if so, which order the levels are in) or a big matrix. the tree isn't a fundamentally bad way to do it, as long as you're not doing a big nested switch. e.g. you could create IAttackable, which could either simply declare a single Attack(AttackInfo) or a method for each type of attack (SwingCockatriceAt, WriteMeanTweetAbout, etc). then each monster would implement IAttackable and define how it's affected by each attack type. for the big matrix approach your language will need something more powerful than a basic c-style switch, like real pattern matching or multimethods.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
oh, and i meant to say that you are allowed to use any language you want.

the discussion back in prehistoric days was about reimplenemting it in c++ using oop because that was a relatively new and hot thing.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
whoops, too slow

raminasi
Jan 25, 2005

a last drink with no ice
"how do i do multiple dispatch in <language without multiple dispatch>" is one of the best ways to get a plethora of confidently wrong answers on stackoverflow, as dozens of people fresh out of undergrad will fall all over themselves to explain the visitor pattern to you

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

JewKiller 3000 posted:

integer division should have a separate operator imo, call it "div" or something, just not "/". if x = 1 and y = 2 then i want x / y = 0.5, i don't care if x and y are both ints. in fact i cannot think of a single instance in my programming career where i wanted the integer division behavior

Visual Basic had \ for integer division

Wheany posted:

hey speaking of Car extends Vehicle, i remember people talking about nethack's creature types and how one creature can polymorph into another type with different weaknesses and strenghts and such, and because of that, CaveTroll extends Troll extends Creature doesn't really work.

so how would you check for a monster's weakness for petrification when the player hits it with a cockatrice corpse without going all
code:
switch(attack_type) {
	case ATTACK_TYPE_COCKATRICE_CORPSE:
		switch(target_creature_type):
			case CREATURE_TYPE_CAVE_TROLL:
in the year 2016?

in the year 2016 you program games with the entity-component-system model, and create game objects by aggregating components. I find entity-component-system hard to wrap my mind around, it's radically different from model-view-controller. like, in ecs you're hardly expected to write any code, and when you do it's to create new components, but you totally can make a game out of pre-made components and only a very thin layer of glue. like you could make a billiards game that's 99% assets and other metadata for the physics and rendering engines and only the smallest amount of code to keep score, handle input, etc. in fact the Unity engine/development environment calls your code "scripts" like it was unimportant (and it is, the engine does the heavy lifting)

I'm probably not explaining myself very well, but it's such a different kind of programming from what I/we usually do. there is no single place you can look at and say "there's the game logic", because the logic is spread among several components × objects. it's also a kind of programming where artists are absolutely vital, to the point that an artist can singlehandedly make a successful game with the vaguest and shittiest programming skills, and programmers who get into game development tend naturally to write engines instead of games

hackbunny fucked around with this message at 09:42 on Apr 8, 2016

Soricidus
Oct 21, 2010
freedom-hating statist shill

JewKiller 3000 posted:

integer division should have a separate operator imo, call it "div" or something, just not "/". if x = 1 and y = 2 then i want x / y = 0.5, i don't care if x and y are both ints. in fact i cannot think of a single instance in my programming career where i wanted the integer division behavior

really? i rely on integer division a lot and can't think of any occasions where it's annoyed me that i had to use a non-integer type to get non-integer behavior. if anything, the thing that annoys me about dividing integers is that you have to do div and mod separately in most languages. i want to do like "n, r = x /% y" and get both at once.

Bloody
Mar 3, 2013

GrumpyDoctor posted:

if you've got n attacks and m attackables you need to encode n*m cases, there's no way around it. the basic decision is whether you model the logic as a two-level tree, like your example (and if so, which order the levels are in) or a big matrix. the tree isn't a fundamentally bad way to do it, as long as you're not doing a big nested switch. e.g. you could create IAttackable, which could either simply declare a single Attack(AttackInfo) or a method for each type of attack (SwingCockatriceAt, WriteMeanTweetAbout, etc). then each monster would implement IAttackable and define how it's affected by each attack type. for the big matrix approach your language will need something more powerful than a basic c-style switch, like real pattern matching or multimethods.

or a lookup table and int enums!

Adbot
ADBOT LOVES YOU

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

JewKiller 3000 posted:

integer division should have a separate operator imo, call it "div" or something, just not "/". if x = 1 and y = 2 then i want x / y = 0.5, i don't care if x and y are both ints. in fact i cannot think of a single instance in my programming career where i wanted the integer division behavior

integer div is really useful sorry

  • Locked thread