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
JewKiller 3000
Nov 28, 2006

by Lowtax

nrook posted:

also, basic list operations appear to be a pain in the rear end in java, or at least they were before java 8. can't use java 8 at work yet so I don't have opinions about it, but it probably fixes some of this

like, I had an object foo in a list today, and I wanted to take all the objects such that foo.bar == "hi", and get their indices in the list

you know, like

code:
[i for i, j in enumerate(the_list) if j.bar == "hi"]
or

code:
IEnumerable<int> IndicesWhereBarIsHi(IList<Foo> foos) {
  for (int i in Enumerable.Range(0, foos.Count) {
    if (foos[i].bar == "hi") {
      yield return i;
    }
  }
}
which is better than it looks, because I included the function declaration. unless you're doing it mid-logic, then it is just what it looks like cuz you gotta declare a closure. you can and should probably define your own IEnumerable<T>.Enumerate extension method like the python one above though, which makes this cleaner, and lets you use fake sql syntax if you're an idiot

how do you do that in java? you do

code:
List<Integer> indices = new ArrayList<Integer>()
for (old-style for loop like a caveman) {
  if (Foos.get(i).bar == "hi") {
    indices.append(i);
  }
}
which sucks! especially since it tempts people to add logic into the for loop, and has mutable state and stuff like that

i think you mean

code:
filter_map the_list (fun i, j -> if j.bar = "hi" then Some i else None)

Adbot
ADBOT LOVES YOU

Damiya
Jul 3, 2012

coffeetable posted:

as to scala, i haven't used it but i know many of its headline features are now in java 8, so you might wanna try that first.

not even.

pattern matching, case classes, implicits, partial functions, etc.

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

to be fair I wouldn't call list comprehension or filter a basic list operation, you're just used to the sweet syntactic sugar

but that's not the point, can't you write an iterator in java 7?

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

nrook posted:

also, basic list operations appear to be a pain in the rear end in java, or at least they were before java 8. can't use java 8 at work yet so I don't have opinions about it, but it probably fixes some of this

like, I had an object foo in a list today, and I wanted to take all the objects such that foo.bar == "hi", and get their indices in the list

you know, like

code:
[i for i, j in enumerate(the_list) if j.bar == "hi"]
or

code:
IEnumerable<int> IndicesWhereBarIsHi(IList<Foo> foos) {
  for (int i in Enumerable.Range(0, foos.Count) {
    if (foos[i].bar == "hi") {
      yield return i;
    }
  }
}
which is better than it looks, because I included the function declaration. unless you're doing it mid-logic, then it is just what it looks like cuz you gotta declare a closure. you can and should probably define your own IEnumerable<T>.Enumerate extension method like the python one above though, which makes this cleaner, and lets you use fake sql syntax if you're an idiot

how do you do that in java? you do

code:
List<Integer> indices = new ArrayList<Integer>()
for (old-style for loop like a caveman) {
  if (Foos.get(i).bar == "hi") {
    indices.append(i);
  }
}
which sucks! especially since it tempts people to add logic into the for loop, and has mutable state and stuff like that

code:
grep { $_->bar == 'hi' } @array;
(i can't help it; i still miss perl sometimes)

gonadic io
Feb 16, 2011

>>=

prefect posted:

code:
grep { $_->bar == 'hi' } @array;
(i can't help it; i still miss perl sometimes)

code:
indices = map fst . filter (\(_,x) -> x == "hi") . zip [0..]

~Coxy
Dec 9, 2003

R.I.P. Inter-OS Sass - b.2000AD d.2003AD

guy at my work uses comic sans 14 pt bold as his ide typeface

Flaming June
Oct 21, 2004

~Coxy posted:

guy at my work uses comic sans 14 pt bold as his ide typeface

recently former coworker did the same

hmm

Shaggar
Apr 26, 2006

nrook posted:

also, basic list operations appear to be a pain in the rear end in java, or at least they were before java 8. can't use java 8 at work yet so I don't have opinions about it, but it probably fixes some of this

like, I had an object foo in a list today, and I wanted to take all the objects such that foo.bar == "hi", and get their indices in the list

you know, like

code:
[i for i, j in enumerate(the_list) if j.bar == "hi"]
or

code:
IEnumerable<int> IndicesWhereBarIsHi(IList<Foo> foos) {
  for (int i in Enumerable.Range(0, foos.Count) {
    if (foos[i].bar == "hi") {
      yield return i;
    }
  }
}
which is better than it looks, because I included the function declaration. unless you're doing it mid-logic, then it is just what it looks like cuz you gotta declare a closure. you can and should probably define your own IEnumerable<T>.Enumerate extension method like the python one above though, which makes this cleaner, and lets you use fake sql syntax if you're an idiot

how do you do that in java? you do

code:
List<Integer> indices = new ArrayList<Integer>()
for (old-style for loop like a caveman) {
  if (Foos.get(i).bar == "hi") {
    indices.append(i);
  }
}
which sucks! especially since it tempts people to add logic into the for loop, and has mutable state and stuff like that

lol. not using linq for that is the most retarded thing.

Bloody
Mar 3, 2013

yeah couldn't you just do foos.where

Shaggar
Apr 26, 2006
yes. but he thinks putting retarded garbage you will never reuse into reusable functions is a thing that people should do

Shaggar
Apr 26, 2006
not that you couldn't make a reusable function w/ linq

Bloody
Mar 3, 2013

k gonna keep laughsing

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Shaggar posted:

yes. but he thinks putting retarded garbage you will never reuse into reusable functions is a thing that people should do

uh idk shaggar, breaking poo poo into functions (even if you'll never reuse them) sounds like a good thing compared to just writing a big sequence of convoluted garbage

at least your garbage is all isolated into tiny digestible chunks

Bloody
Mar 3, 2013

why would it be better to have that awful function call than a single call to a std function

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
idk about that because I don't even know what are java's std functions, I was just thinking in a general case

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Symbolic Butt posted:

idk about that because I don't even know what are java's std functions, I was just thinking in a general case

the java code is correct afaik but the c# code is functionally equivalent to

code:
foos.Where(f => f == "hi")

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
regardless of your opinions on reusability i don't see much way that you could improve that from a readability standpoint, since all the information is right there

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Dessert Rose posted:

the java code is correct afaik but the c# code is functionally equivalent to

code:
foos.Where(f => f == "hi")

neat

Shaggar
Apr 26, 2006

Dessert Rose posted:

the java code is correct afaik but the c# code is functionally equivalent to

code:
foos.Where(f => f == "hi")

actually hes trying to get the indexes of the foos where their bar value is "hi" instead of selecting the foos (which is stupid). the linq would be something like

C# code:
var hibarIndexes = foos.Select((foo,index) => new {foo,index}).Where(x=>x.foo.bar=="hi").Select(x=>x.index);

gonadic io
Feb 16, 2011

>>=

Dessert Rose posted:

code:
foos.Where(f => f == "hi")

does this return the indices or all the "hi"s?

Bloody
Mar 3, 2013

im the code in a high level language where indices in a list are being janitored

nrook
Jun 25, 2009

Just let yourself become a worthless person!

Shaggar posted:

actually hes trying to get the indexes of the foos where their bar value is "hi" instead of selecting the foos (which is stupid). the linq would be something like

C# code:
var hibarIndexes = foos.Select((foo,index) => new {foo,index}).Where(x=>x.foo.bar=="hi").Select(x=>x.index);

poo poo I forgot c# had nice anonclasses like that, it's been too long. also I'm not sure I ever knew there was a select that gave you the indices. in that case yeah the linq way is better

and yeah good code would not require a list of indices ever. But I was passing them into bad code, which wanted the list of indices. doing dumb things with sequences to pass them into various functions is a really, really common thing to have to do, so good languages make it easy

ah well, I (think?) java 8 should make this better anyway

Asshole Masonanie
Oct 27, 2009

by vyelkin
just found my new favorite phrase


code:
el.IsActive = !el.IsInactive;

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Bloody posted:

im the code in a high level language where indices in a list are being janitored

this is why i missed what the hell was going on the first time around

also why you don't wrap tiny linq queries in their own method

Bloody
Mar 3, 2013

ctps: making monstrous nested struct/union beasts

like, a union of a struct and an array and the struct is full of unions of bits and bytes and also loose bytes and aughughguh its like russian nesting dolls made of poo poo

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Bloody posted:

ctps: making monstrous nested struct/union beasts

like, a union of a struct and an array and the struct is full of unions of bits and bytes and also loose bytes and aughughguh its like russian nesting dolls made of poo poo

why

Morkai
May 2, 2004

aaag babbys
my chickens, they have come home to roost. currently tasked with "performance optimization" of our EF use. lol

Morkai
May 2, 2004

aaag babbys
expression trees rule everything around me.

Bloody
Mar 3, 2013


because im a horrible monster relying on compiler behavior to slightly-more-sanely address bitfields in a large pile of poo poo

Brain Candy
May 18, 2006

Morkai posted:

my chickens, they have come home to roost. currently tasked with "performance optimization" of our EF use. lol

just reduce the length of the busy loop, ez

Valeyard
Mar 30, 2012


Grimey Drawer
doing software engineering at my university is literally just CS except you get less choice of classes in your final year, and in the third year there is a mandatory summer work placement with accompanying essay/presentation

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
thanks -o

code:
unix1% time p t1

real    0m0.021s
user    0m0.002s
sys     0m0.006s

unix1% time pa t1

real    0m0.030s
user    0m0.002s
sys     0m0.013s

Plastic Snake
Mar 2, 2005
For Halloween or scaring people.

Morkai posted:

my chickens, they have come home to roost. currently tasked with "performance optimization" of our EF use. lol

rewrite those methods to not use EF. done!

weird
Jun 4, 2012

by zen death robot

Valeyard posted:

doing software engineering at my university is literally just CS except you get less choice of classes in your final year, and in the third year there is a mandatory summer work placement with accompanying essay/presentation

you're lying

Valeyard
Mar 30, 2012


Grimey Drawer

apt gangbang posted:

you're lying

mobile software engineering is the only one that is different, becaause you get to drop the database class and take an embedded systems class in its place

weird
Jun 4, 2012

by zen death robot
oh

zeekner
Jul 14, 2007

Valeyard posted:

mobile software engineering is the only one that is different, becaause you get to drop the database class and take an embedded systems class in its place

what? that's dumb, database design is really important in mobile. embedded systems class is cool though, they should be required to take both

Valeyard
Mar 30, 2012


Grimey Drawer

Uncomfortable Gaze posted:

what? that's dumb, database design is really important in mobile. embedded systems class is cool though, they should be required to take both

yup, there are definetely other classes that could be removed instead of database, the one about programming language syntax parsing/scope checking/code generation is interesting but would make more sense to lose

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
at my uni software engineering was pretty good, the mandatory courses were often shared with CS but i think there was a good focus on applying the science which would be my definition of engineering. there was a pretty good choice of cs/eng courses you could take too as elective slots and we had to do at least 400 hours of real work experience with reports over the degree, and a large project in 3rd and fourth year

though heaps of people didn't do the work exp, never graduated, got a job anyway

Adbot
ADBOT LOVES YOU

Star War Sex Parrot
Oct 2, 2003

is "software engineering" an actual ABET degree?

  • Locked thread