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
fritz
Jul 26, 2003

Symbolic Butt posted:

code:
irb(main):001:0> 1/2+3
=> 3
irb(main):002:0> 1./2.+3
=> 0
:3:

what language is that i want to avoid it

Adbot
ADBOT LOVES YOU

double sulk
Jul 2, 2010

fritz posted:

what language is that i want to avoid it

scala

fritz
Jul 26, 2003

Brain Candy posted:

stack allocation, operator overloading and vectorization are a thing, but IDK, the winner for math isn't c++/c.

surprise, it's fortran and OpenCL/CUDA. most of the 'fast' c/c++ libraries are wrappers.

there was a slapfight in the scicomp stack exchange clone about a year ago re: this and i think the results ended up being inconclusive w/r/t/ c vs fortran and there were problems w/ people using free compilers or pay compilers and stuff like that

FamDav
Mar 29, 2008

JewKiller 3000 posted:

if you can't define the function swap so that the assert passes, your language does not have pass by reference

You can write a swap for non-primitives in java

EDIT: which jives totes mcgotes with your statement, but still

FamDav fucked around with this message at 07:18 on Sep 24, 2013

Notorious b.s.d.
Jan 25, 2003

by Reene

fritz posted:

what language is that i want to avoid it

it's ruby

Notorious b.s.d.
Jan 25, 2003

by Reene

FamDav posted:

You can write a swap for non-primitives in java

EDIT: which jives totes mcgotes with your statement, but still

nope you can't

the references you change will only be your local ones, because java is always pass by value at all times.

c# permits pass by name ("out" parameters), but java does not

FamDav
Mar 29, 2008

Notorious b.s.d. posted:

nope you can't

the references you change will only be your local ones, because java is always pass by value at all times.

c# permits pass by name ("out" parameters), but java does not

are you telling me that this mostly java

code:

class MyClass
{
	public int x;
}

void swap(MyClass a, MyClass b)
{
	int tmp = a.x;
	a.x = b.x;
	b.x = tmp;
}
doesn't swap the contents of a and b

BONGHITZ
Jan 1, 1970

java the hutt

Zlodo
Nov 25, 2006

Nomnom Cookie posted:

I dunno why you're using the term pass by reference then. It has a clear meaning and deals with language semantics, not calling conventions.

I should just have precised I was talking about low level representation
see the problem is that i prefer to avoid the word "pointer" as well because its a loaded term too and people would have said "there's no pointer in java you dumbass"

quote:

Taking your meaning, which is "everything is a pointer", it's not an actual issue. Dereferencing pointers from L1 is basically free.
I disagree. the biggest cost might very well be the GC but dereferencing a pointer is significant enough compared to having the right value in a register in the first place, especially as value types allow compilers to store the fields of small structs directly into registers

of course like everything it only becomes an issue for things that are executed on many objects or in the inner loops of some algorithms etc but its nice not to have to worry about this particular performance hazard and be able to focus your efforts elsewhere

quote:

Bro you need to learn more about JVM internals if you want to poo poo on them. For starters, Hotspot allocates out of a thread-local buffer (imaginatively acronym'ed as TLAB). In the vast majority of cases Java allocations are pointer bumps.

OK, fine. that's a good, efficient way to allocate things. a nice thing when allocating things on the stack though is that freeing it is equally cheap. its just wasteful to reach for the heap for temporary objects

Zlodo fucked around with this message at 08:41 on Sep 24, 2013

qntm
Jun 17, 2009
The difference between call-by-value and call-by-reference (also known as "pass-by-value" and "pass-by-reference" respectively) is most easily explained using the following pseudocode.

code:
x = "blue"

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

modify(x)
print(x) // "blue" indicates language calls by value
         // "red" indicates language calls by reference
Hint: almost all popular programming languages call by value. This includes C, Java, Python and PHP. The most notable exception is Perl.

(Some programming languages allow you to call by reference if you use special syntax. This includes PHP and C#.)

Look out!

Confusingly, many call-by-value programming languages pass an object reference as their value.

Use this pseudocode to test this behaviour.

code:
x = new Object
x.colour = "blue"

function modify(input) {
	input.colour = "red"
}

modify(x)
print(x.colour) // "blue" if call-by-value and value is whole object
                // "red" if call-by-value and value is reference to object
                // "red" if call-by-reference
Hint: almost all popular call-by-value programming languages use a reference to the object as their value. This includes Java and Python.

BONGHITZ
Jan 1, 1970

c pus pus

Brain Candy
May 18, 2006

Zlodo posted:

of course like everything it only becomes an issue for things that are executed on many objects or in the inner loops of some algorithms etc but its nice not to have to worry about this particular performance hazard and be able to focus your efforts elsewhere


OK, fine. that's a good, efficient way to allocate things. a nice thing when allocating things on the stack though is that freeing it is equally cheap. its just wasteful to reach for the heap for temporary objects

quote:

Escape analysis is a technique by which the Java Hotspot Server Compiler can analyze the scope of a new object's uses and decide whether to allocate it on the Java heap.

Escape analysis is supported and enabled by default in Java SE 6u23 and later.

:allears:

Nomnom Cookie
Aug 30, 2009



Zlodo posted:

I disagree. the biggest cost might very well be the GC but dereferencing a pointer is significant enough compared to having the right value in a register in the first place, especially as value types allow compilers to store the fields of small structs directly into registers

of course like everything it only becomes an issue for things that are executed on many objects or in the inner loops of some algorithms etc but its nice not to have to worry about this particular performance hazard and be able to focus your efforts elsewhere


OK, fine. that's a good, efficient way to allocate things. a nice thing when allocating things on the stack though is that freeing it is equally cheap. its just wasteful to reach for the heap for temporary objects

Your intuition about the heap doesn't apply to the JVM, especially when talking about the young generation. Marking the live objects and blowing away the rest of the young gen is frequently a cheap operation, on the order of a millisecond. Do this 10 times a second and it costs 1% throughput. Yes, that's a cost, but the benefits make it a worthwhile tradeoff. Java programmers don't have to reason about object lifetime or screw around with smart pointers, for one thing.

zokie
Feb 13, 2006

Out of many, Sweden

Dessert Rose posted:

lol if you can't think of a way you'd actually use this

like obviously a list of keyvaluepairs isn't useful but i didnt feel like coming up with a real example

i sort of assumed that the use would be obvious to anyone that wasn't an idiot but i guess i am in the terrible programmer thread so here are a couple of better ones

code:
using System.Threading;
using System.Timers;
ok so now if i want a Timer what namespace does it come from? there's System.Threading.Timer and System.Timers.Timer

obviously i want a System.Timers.Timer or i wouldnt have used the namespace but the compiler will barf on it so
code:
using Timer = System.Timers.Timer;
omg now i can just write Timer in my code and it goes to the right one instead of me having to use System.Timers.Timer timer; everywhere

disambiguation is most of how it gets used but again, generics can get kind of verbose. i mean do you really want a

code:
ConcurrentDictionary<Tuple<string, int>, IEnumerable<List<Butt>>> cd = new ImNotEvenTypingThisShit();
when you could just do
code:
using ButtCollection = ConcurrentDictionary<Tuple<string, int>, IEnumerable<Task<Butt>>>;
ButtCollection cd = new ButtCollection();
maybe you dont use generics enough in your own code for it to matter but with stuff like IEnumerable<> and Task<> floating around now your code is going to look messy as gently caress without these

This was pretty neat but couldn't you just get your job to buy you ReSharper? Or just start exploiting that Intellisense knows about camel- and pascal-casing?

Brain Candy
May 18, 2006

fritz posted:

there was a slapfight in the scicomp stack exchange clone about a year ago re: this and i think the results ended up being inconclusive w/r/t/ c vs fortran and there were problems w/ people using free compilers or pay compilers and stuff like that

woaw slow down hoss with your 'measurements'. fortran is the fastest because i saw a benchmark five years ago saying that. now I believe it for all time and any of your stinky evidence is just you trying to trick me into using an inferior solution.

Zlodo
Nov 25, 2006
auto completion is very helpful to write code but the advantage of making things more concise is that it also helps readability

Zlodo
Nov 25, 2006

did you do any profiling demonstrating that this closes the gap with c++ performance?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

zokie posted:

This was pretty neat but couldn't you just get your job to buy you ReSharper? Or just start exploiting that Intellisense knows about camel- and pascal-casing?

yeah this totally solves the problem

also lol if you don't have a personal r# license and you write more than ten lines of c# a year

Workaday Wizard
Oct 23, 2009

by Pragmatica

Dessert Rose posted:

yeah this totally solves the problem

also lol if you don't have a personal r# license and you write more than ten lines of c# a year

what does resharper add that vs doesnt already have? legit question

i never found vs lacking in quality of life features like refactoring etc. so i never bothered with f#

Nomnom Cookie
Aug 30, 2009



Dessert Rose posted:

yeah this totally solves the problem

also lol if you don't have a personal r# license and you write more than ten lines of c# a year

Did you know that you can get resharper except its an ENTIRE IDE?

Morkai
May 2, 2004

aaag babbys

Shinku ABOOKEN posted:

what does resharper add that vs doesnt already have? legit question

i never found vs lacking in quality of life features like refactoring etc. so i never bothered with f#

it will helpfully import references, suggest refactoring to improve readability and maintainability, keep your styling more consistent, recommend best practices, auto-insert/complete some common blocks, warn you about misuse of closures...

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

qntm posted:

...
Hint: almost all popular programming languages call by value. This includes C, Java, Python and PHP. The most notable exception is Perl.

(Some programming languages allow you to call by reference if you use special syntax. This includes PHP and C#.)

Look out!

Confusingly, many call-by-value programming languages pass an object reference as their value.
...
Hint: almost all popular call-by-value programming languages use a reference to the object as their value. This includes Java and Python.

this was an educational post :tipshat:

Posting Principle
Dec 10, 2011

by Ralp
jax-rs trip report: continues to kinda own and is flask levels of easy. all the ancilliary java stuff is weird though, containers and resources and aag. i used cxf and now i don't if i've screwed myself and my code isnt portable because apparently jersey is the way to go??? java is weird

Shaggar
Apr 26, 2006
jax-rs is a java standard api for REST and cxf and jersey both have implementations of that api, so theoretically if you're using only jax-rs related stuff and not cxf specific its portable between either implementation.

I've never used jersey but cxf is great for soap and worked fined for rest the one time I did it.

Shaggar
Apr 26, 2006
So in the world of java theres this magic thing called the Java Community Process. Basically whenever anyone thinks they have an idea for an api or a language feature that they think would be great to become officially part of java, they can create a detailed spec called a Java Specification Request (JSR) and submit it to the JCP. The JCP council of elders then decides the worthiness of the JSR. If a JSR becomes official then the described API is written and maybe also a reference implementation of that API. For example, Servlet Spec 3.0 is JSR-315. JAX-RS 2.0 is JSR-339. JSRs are like the java version of IEEE RFCs

Some APIs, like jaxb (the java xml binding api) are so popular that they become part of the official standard distribution libraries(Java Standard Edition or JSE). Others that are still popular but don't make sense in a client distribution like JSE can be distributed separately or together as a larger standards pack. Java EE is kind of an example of a larger package of JSRs. Depending on the version of Java EE you're talking about it refers to a collection of JSR APIs. For example Java EE 7 includes the servlet-api, jax-rs, and jpa amongst others. If you have a container that is a JEE 7 server, its basically saying "I support all the APIs specified by the Java EE 7 spec!" So anything you write can rely on those apis being available on that platform. Jboss and websphere are examples of such server.

If you're writing code against the JSR apis only and no specific implementations, you can then deploy that code to servers like jboss or websphere and they have their own implementations that will connect to those JSR APIs. However, lots of people hate what they think is Java EE when really what they hate is jboss and websphere which are both kind of lovely (websphere is awful).

Most people generally do not need all of Java EE though. They're gonna do like you're doing and include the jax-rs api as a dependency on the project and write code against that API. Then you deploy it to tomcat or jetty which are both servlet containers. Since they only provide an implementation of the servlet-api, you would need to provide your own implementation of the jax-ws API. In your case you're using cxf.

You should be developing against jax-rs-api and never do anything cxf specific in code. That is, if you remove cxf libraries from your project it should still compile (cause it compiles against jax-rs-api). jax-rs-api is a compile time dependency since its required for compilation and cxf would be a runtime dependency because it is only required when you go to run the code. This way you can either include cxf as a runtime dependency in maven for your project OR add it as a global library to your servlet container (tomcat or jetty). Either way since it is a runtime dependency you can swap it with any other jax-rs implementation (like jersey).

tl;dr: java owns and the JCP is pretty good and creates APIs that everyone writes their code against that are separate from implementation code. This allows you to make portable code as long as you only write against the API and not specific implementations.

Shaggar fucked around with this message at 17:46 on Sep 24, 2013

fritz
Jul 26, 2003

Brain Candy posted:

woaw slow down hoss with your 'measurements'. fortran is the fastest because i saw a benchmark five years ago saying that. now I believe it for all time and any of your stinky evidence is just you trying to trick me into using an inferior solution.

modern fortrans look like they might be ok to program in, but i dont think ill ever get a job at a place where 'fortran' isnt just a word to make twentysomething javascript programmers snicker

Posting Principle
Dec 10, 2011

by Ralp
i think shaggar has been right all along

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
shaggar is right he just has bad opinions

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Shinku ABOOKEN posted:

what does resharper add that vs doesnt already have? legit question

i never found vs lacking in quality of life features like refactoring etc. so i never bothered with f#

all the things morkai mentioned plus it also does neat things like suggesting transforms of loops into LINQ expressions

it also greatly enhances syntax coloring so interfaces can be colored differently from classes, variables that mutate over the course of a method can be a different style than variables that don't...

tbf vs gets more of its features every release but it's still fantastic

Bloody
Mar 3, 2013

when is vs2013 coming out? i see the RC is already up and i want to make sure to nab it before my dreamspark account goes away forever

Workaday Wizard
Oct 23, 2009

by Pragmatica

Bloody posted:

when is vs2013 coming out? i see the RC is already up and i want to make sure to nab it before my dreamspark account goes away forever

best feature of 2013 is the return of colored icons (they are still lcd flat though :( )

i hope the chucklefuck that made the black flat icons got fired into the sun

Nomnom Cookie
Aug 30, 2009



is everything still ALL CAPS

DESIGN LANGUAGE. METRO. MODERN. MINIMALIST. BUILD PROJECT

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

my stepdads beer posted:

{'default': {'ENGINE': 'django.db.backends.mysql',

word

PENETRATION TESTS
Dec 26, 2011

built upon dope and vice
what is the best fortran ide?

double sulk
Jul 2, 2010

sublime text

Brain Candy
May 18, 2006

matlab

Brain Candy
May 18, 2006

please don't fortran

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

FamDav posted:

are you telling me that this mostly java

code:

class MyClass
{
	public int x;
}

void swap(MyClass a, MyClass b)
{
	int tmp = a.x;
	a.x = b.x;
	b.x = tmp;
}
doesn't swap the contents of a and b

that's correct. the contents of variables a are b are not swapped by that code.

going back to jewkiller's post:

code:
a = x
b = y
swap(a, b)
assert(a == y && b == x)
and modifying it to fit your example

code:
MyClass x = new MyClass(1);
MyClass y = new MyClass(2);
MyClass a = x;
MyClass b = y;
MyClass.swap(a, b);
assert(a == y && b == x)
the assert will fail. after the 'swap', a.x will be set to 2, and b.x will be set to 1, but which objects are held in which variables doesn't change. ("assert(a == x && b == y)" will be true on either side of the swap() call.)

this is something that fucks beginners up pretty often.

Salynne
Oct 25, 2007

Nomnom Cookie posted:

is everything still ALL CAPS

DESIGN LANGUAGE. METRO. MODERN. MINIMALIST. BUILD PROJECT

this bothers me so god drat much

Adbot
ADBOT LOVES YOU

cowboy beepboop
Feb 24, 2001


johny use postgres

  • Locked thread