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
Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

qntm posted:

code:
function modify(input) {
	input = "red"
}

var x = "blue"
modify(x)
print(x) // "blue" indicates variable was passed by value
         // "red" indicates variable was passed by reference

I guess I didn't have the right definitions because I thought the name binding inside the block was more of a scoping thing. let me change the example a bit


code:
function modify(input) {
	input.setName("red")
}

var x = new X
x.setName("blue")
modify(x)
print(x.getName()) // "blue" is pass by value according to wrong poster Symbolic Butt
                   // "red" is pass by reference according to wrong poster Symbolic Butt
it makes a lot more sense in my mind but I guess the right definitions are useless in this context so you enter clowntown because java is "pass by value" but it's "pass reference by value" and not "pass value by value" :gary:

Symbolic Butt fucked around with this message at 01:29 on Dec 10, 2015

Adbot
ADBOT LOVES YOU

pseudorandom name
May 6, 2007

Elder Postsman posted:

hey what do y'all think of Go

there are people here talking about it and one person using it, i don't know anything about it except it's from google.

I hear that someday it will support multiple threads

Soricidus
Oct 21, 2010
freedom-hating statist shill

qntm posted:

code:
function modify(input) {
	input = "red"
}

var x = "blue"
modify(x)
print(x) // "blue" indicates variable was passed by value
         // "red" indicates variable was passed by reference

now consider a c++ class with a shallow copy constructor and an overloaded operator=

e: oh wait yeah that'll teach me to read properly i'm dumb ignore me

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

Symbolic Butt posted:

today I just said in passing "java is pass by reference I think.... right?"

lol at the discussion that followed

are you familiar with the "single-element array output argument" pattern

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

hackbunny posted:

are you familiar with the "single-element array output argument" pattern

as someone not particularly familiar with Java, what's the joke/horrors about Java's pass by reference?

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

Maluco Marinero posted:

as someone not particularly familiar with Java, what's the joke/horrors about Java's pass by reference?

Java is pass by value for all primitives. for objects, Java passes the object reference by value...meaning you can modify the original object through the reference.

not much of a horror but leads to a few gotchas.

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

Symbolic Butt posted:

I guess I didn't have the right definitions because I thought the name binding inside the block was more of a scoping thing. let me change the example a bit


code:
function modify(input) {
	input.setName("red")
}

var x = new X
modify(x)
print(x.getName()) // "blue" is pass by value according to wrong poster Symbolic Butt
         // "red" is pass by reference according to wrong poster Symbolic Butt
it makes a lot more sense in my mind but I guess the right definitions are useless in this context so you enter clowntown because java is "pass by value" but it''s "pass reference by value" and not "pass value by value" :gary:


now consider in java
code:


function modify(final myAss input) {
	input.setName("red"); //OK
	input = new rear end(); //not OK
}

var x = new rear end();
modify(x);

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
java is pass by reference, but some objects are immutable/read-only (notably primitive types)
java is pass by value, and references are a kind of value (and so you can't have a reference to a reference)

but really, there are objects and primitive types. primitive types are copied so they are immutable, objects are passed around by pointer and may or may not be mutable/writable through their methods or (barf) exposed fields. .net formalizes them as value types vs reference types. yes, a lot of built-in .net value types are just type system drag for intrinsic VM types, but at least they are in the type system, unlike java primitives which are pure magic. boxed java primitives don't have to be read-only either, but they are to mirror the immutability of the underlying type. java arrays are pure magic too, hence the Arrays static class. it's not a bad system (I actually personally enjoy clunky verbose code) but I hate the hole it leaves in the type system

Maluco Marinero posted:

as someone not particularly familiar with Java, what's the joke/horrors about Java's pass by reference?

since references are values, and values are immutable, you can't pass a reference by reference. what you can do is pass a reference to a mutable object that holds a reference to the object you want to return ("out" parameters in C#) or replace ("ref"). generics are pretty new to the language and type-erasing, so forget about a generic container object, but java has always had a non-type-erasing generic type, that also happens to contain fully mutable fields: arrays of course

Java code:
class TurdFactory {
	// example of "out" argument
	public void createInstance(Turd[] turd) { // non-idiomatic, sue me
		turd[0] = new Turd();
	}
}

class TurdStealer { // execution in the kingdom of nouns lol
	// example of "ref" argument
	public boolean steal(Turd[] turd) {
		if (turd[0] == null)
			return false;
		else {
			turd[0] = null;
			return true;
		}
	}
}

class ByrefTurdTest {
	public static void main(String[] args) {
		TurdFactory turdFactory = new TurdFactory();
		TurdStealer turdStealer = new TurdStealer();

		Turd[] turd = new Turd[1];

		turdFactory.createInstance(turd);
		assert turd[0] != null;

		boolean stolen = turdStealer.steal(turd);
		assert stolen;
		assert turd[0] == null;
	}
}

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
A lot of langs do that though? or is there subtle difference in the phrase 'passes the object reference by value' that I'm missing?

e: this was a response to the shorter explanation, I don't think I fully get it yet but that helps hackbunny.

Maluco Marinero fucked around with this message at 01:30 on Dec 10, 2015

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
it's absolutely not a coincidence that all java primitives fit in a machine register. yes, it's a VM implementation detail floated up to the language surface. it's not that bad, the migration path for a C++ or even C programmer is pretty straightforward, you'll say references and they'll just nod and think "special integers, like pointers"

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
it's just that java is a surprisingly low-level language, it's the C of the GC world. you can't return multiple values with a tuple not because it's impossible but (I guarantee it) because the syntax would be too convenient, just symbols and formatting and no class names, not explicit enough. java is not agile, everything that exists needs to be named (ok, exaggeration) and to some degree planned in advance. this philosophy is why it took 8 major revisions to have lambdas, and why despite the VM growing a new opcode (!!!) specifically for lambda invocation, lambdas are still so rigid

it's a very conservative language and I think it's one of its strengths

Soricidus
Oct 21, 2010
freedom-hating statist shill

hackbunny posted:

it's absolutely not a coincidence that all java primitives fit in a machine register. yes, it's a VM implementation detail floated up to the language surface. it's not that bad, the migration path for a C++ or even C programmer is pretty straightforward, you'll say references and they'll just nod and think "special integers, like pointers"

apart from long, I think, on the 32-bit machines that were overwhelmingly popular when java was created

fritz
Jul 26, 2003

pseudorandom name posted:

I hear that someday it will support multiple threads

not generics tho

Soricidus
Oct 21, 2010
freedom-hating statist shill
also i'm not sure why you describe special cases as "holes" in the java type system. the object/primitive distinciton is not as elegant as if everything was an object, but that doesn't stop primitives and arrays being part of the type system? like there are Class objects that represent their types etc.

JawnV6
Jul 4, 2004

So hot ...
what's worse: "elegant" or "robust"

Brain Candy
May 18, 2006

Soricidus posted:

also i'm not sure why you describe special cases as "holes" in the java type system. the object/primitive distinciton is not as elegant as if everything was an object, but that doesn't stop primitives and arrays being part of the type system? like there are Class objects that represent their types etc.

that i can't use Map<int, Butts> means some types are more equals than others

sarehu
Apr 20, 2007

(call/cc call/cc)

JawnV6 posted:

what's worse: "elegant" or "robust"

I looked one of my old resumes that fortunately I never sent out and it had "elegant" on it, I had to slap myself.

Wouldn't have had that feeling with "robust."

VikingofRock
Aug 24, 2008




Brain Candy posted:

that i can't use Map<int, Butts> means some types are more equals than others

Wait, you can't use ints as a map key in java?

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

VikingofRock posted:

Wait, you can't use ints as a map key in java?

no but you can use Integers ;)

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
and no it will not "autobox" thsi for you

N.Z.'s Champion
Jun 8, 2003

Yam Slacker

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Have some probably wrong observations about 3D Graphics APIs and Vulkan: http://blog.mecheye.net/2015/12/why-im-excited-for-vulkan/

suffix
Jul 27, 2013

Wheeee!

Elder Postsman posted:

hey what do y'all think of Go

there are people here talking about it and one person using it, i don't know anything about it except it's from google.

there's some ranting about it earlier in the thread but rather than repeat it i'll link to some posts by go supporters explaining how not having dependency management is actually a good thing, and how checking error values for every call is not annoying because you can subvert it so the compiler can't check that you're handling errors

https://blog.gopheracademy.com/advent-2014/case-against-3pl/

https://blog.golang.org/errors-are-values

leftist heap
Feb 28, 2013

Fun Shoe
those posts are some hilarious stockholm syndrome

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

suffix posted:

there's some ranting about it earlier in the thread but rather than repeat it i'll link to some posts by go supporters explaining how not having dependency management is actually a good thing, and how checking error values for every call is not annoying because you can subvert it so the compiler can't check that you're handling errors

https://blog.gopheracademy.com/advent-2014/case-against-3pl/

https://blog.golang.org/errors-are-values

lol that error one is great. the number of hoops he has to jump through to get even slightly away from how ugly that code is

and jfc every time I read go code I'm taken aback by how ugly it is in general

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
just write a wrapper class! then you could do so many things besides forget to check errors.

like it may be ugly but at least the compiler is making sure you check for errors

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
swift did it right though. make possibly-failing calls look different, do exception handling the way everyone already knows how.

don't loving just look at c and go "hey, errno was a great idea, let's just make the compiler enforce it"

triple sulk
Sep 17, 2014



just use c# for everything

Ericadia
Oct 31, 2007

Not A Unicorn
where all my ALGOL 60 and or PL/I programmers at?!

suffix
Jul 27, 2013

Wheeee!

Suspicious Dish posted:

Have some probably wrong observations about 3D Graphics APIs and Vulkan: http://blog.mecheye.net/2015/12/why-im-excited-for-vulkan/

that's cool

i have a hard time being excited about vulkan as a technology just because it's so low level that you'd never use it directly unless you were making a low level game engine
but i suppose you could say something similar about X

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Elder Postsman posted:

hey what do y'all think of Go

there are people here talking about it and one person using it, i don't know anything about it except it's from google.

do you like garbage languages that fail at basically everything they claim to achieve?

the type system is next to useless. the lack of support for generics and iterator like operators means anything that requires a complex data structure that is not built in will almost certainly be cast to interface{} and then, at some point, downcast to some other type. hopefully it's original type but who really can tell?

channels are a worthless abstraction. they block on send and receive so unless you use some sort of queue they provide only very limited concurrency and they are not preemptible so they are of limited use for parallelism. virtually every modern language has a better solution available as a library

there is next to no type safety. almost any operation can return `nil` despite it's type signature. there is no pattern matching, no option/maybe type and no exceptions so every single operation must be checked for errors manually

this one is pretty minor compared to the above but it's 2015 and go still has statements. there's zero excuse for statements in modern programming languages. there is absolutely no reason `isEven = if x % 2 { true } else { false }` shouldn't work

this one is major. it's 2015 and go has zero support for immutable values. immutable values are the best reason to use erlang, clojure, scala and rust. they are a huge win for productivity and program correctness and go just doesn't have them presumably to simplify compilation


i will concede go is alright if you need to ship something of limited ambition or complexity to customers/users. it's nice they can just download a binary without worrying about dependencies

the talent deficit fucked around with this message at 06:41 on Dec 10, 2015

cowboy beepboop
Feb 24, 2001

suffix posted:

there's some ranting about it earlier in the thread but rather than repeat it i'll link to some posts by go supporters explaining how not having dependency management is actually a good thing, and how checking error values for every call is not annoying because you can subvert it so the compiler can't check that you're handling errors

https://blog.gopheracademy.com/advent-2014/case-against-3pl/

https://blog.golang.org/errors-are-values

why doesnt the official go site have syntax highlighting this is awful

triple sulk
Sep 17, 2014



my stepdads beer posted:

why doesnt the official go site have syntax highlighting this is awful

rob pike unironically posted:

Syntax highlighting is juvenile. When I was a child, I was taught
arithmetic using colored rods
(http://en.wikipedia.org/wiki/Cuisenaire_rods). I grew up and today I
use monochromatic numerals.

-rob

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
what the gently caress

Ericadia
Oct 31, 2007

Not A Unicorn

lmao

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
what the gently caress

Suspicious Dish
Sep 24, 2011

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

suffix posted:

that's cool

i have a hard time being excited about vulkan as a technology just because it's so low level that you'd never use it directly unless you were making a low level game engine
but i suppose you could say something similar about X

I was hoping the parts about politics and the stories of the battles between game developers and GPU manufacturers would be intriguing and interesting.

I didn't actually write that much about Vulkan in comparison, other than as framing for that, and to help say "well, I'm happy this isn't happening anymore"

sarehu
Apr 20, 2007

(call/cc call/cc)
Edit: Deleting this in honor of Cuisenaire rods.

sarehu fucked around with this message at 07:17 on Dec 10, 2015

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Adbot
ADBOT LOVES YOU

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Suspicious Dish posted:

Have some probably wrong observations about 3D Graphics APIs and Vulkan: http://blog.mecheye.net/2015/12/why-im-excited-for-vulkan/
This was pretty interesting! I had wondered what the incentives around the development of Mantle were. Any chance you can cite sources for your claim that nvidia was responsible for the OpenGL 3 failure?

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