Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Everything Is References

Name: Anonymous 2010-08-20 16:29

Is there a language in which variables, function arguments, etc, are always references by default?

For example:

int x = 5;
int y = x;
y++;  // x and y are both 6


If you really did want a copy of something, you'd have to use a keyword:

int x = 5;
int y = copy(x);


And pass-by-value would also have to be done explicitly:

void func(int z)
{
   int w = copy(z); // now w is effectively "local"
}


It would force programmers to at least be aware of the fact that they're making a copy.

Name: Anonymous 2010-08-21 11:47

>>20
it's to make bad programmers aware that they're copying values instead of references — which is retarded
Sorry, but making bad programmers aware of bad programming is hardly "retarded" as a goal of a programming language.

it also makes literals and variable names have totally different semantics, when they should obviously be interchangeable
The fuck are you talking about?  So, what you want is this?

int x = 5;
int 6 = y;

I think you might be a good candidate for a language targeted at "bad programmers."

Name: Anonymous 2010-08-21 12:28

>>31
Holy fuck, I never thought someone could be this retarded. IHBT

Name: Anonymous 2010-08-21 12:33

>>40
Now you have two problems.

Name: Anonymous 2010-08-21 12:41

>>41
The fuck are you talking about? >>20 means that int x = 5; becomes int x = y;.

Name: Anonymous 2010-08-21 12:55

>>44
He said "literals and variable names ... should obviously be interchangeable."
That's simply impossible, and that's what my example shows.

Name: Touhou Master 1993 2010-08-21 13:49

>>38

Name            | Efficiency matters?
----------------+--------------------
Keyboard driver | No


Dad, I'm disappoint.

Name: Anonymous 2010-08-21 19:27

>>45
I'm simply speechless. It might be the case that you're the person who knows least about programming in /prague/

Name: Anonymous 2010-08-21 19:30

>>45
Also, read the fucking example given in >>20 and/or stop trolling

Name: Anonymous 2010-08-21 20:41

>>1
Why not just use pointers?
int *x;
*x = 5;
int y = *x;

Name: Anonymous 2010-08-21 21:00

>>1
Wouldn't doing it the other way around be more appropriate? That is, every assignment copies the value, and you need special syntax to assign a reference.

Name: Anonymous 2010-08-21 21:16

>>49
int *x;
*x = 5;

( ≖‿≖)

Name: Anonymous 2010-08-21 21:42

>>38
so easy for me to get unexpectedly high-paying jobs
0/10

Name: Anonymous 2010-08-23 1:40

>>47-48
I really don't know what to make of this...  It seems like a troll, but I think you're actually genuine, which just makes it depressing.

Here's the example from >>20:
y = 5;' means regular value assignment
but 'y = x;', means changing the reference

And his point was that the "semantics" of the two should be the same.  My point is that they obviously can't be the same.  Hell, it's not even "my" point, it's just common sense.  "5" is a literal and "x" is a variable.  You can't assign to "5" just like you can't assign to "hello world".  It resides int he code segment...  The variable "x" is a storage location on the stack or in the process's global space...  It's data, while "5" is a const that is part of the code segment.  When compiled, you're just going to get two very different things.  They're both going to end up as "MOV" instructions in x86, but one is going to be moving a literal and one is going to be reading a value out of the data segment, and these are completely different things in absolutely every language ever conceived.  A language where literals and variables had the same semantics would be a very fucked up (and probably useless) thing.  Is something about this difficult to understand?

I would guess that >>20 just misspoke.  He didn't really mean that literals and variables should have the same semantics.  He just didn't like the assumption that one copied by value and the other copied by reference.  You, on the other hand, just...  shit...  I don't have any idea.

I personally don't have a problem with that assumption and I don't think anyone who actually knows what they're talking about would have a problem with it, either, because they'd be aware that literals and variables aren't the same thing, so you shouldn't expect them to be handled the same, semantically.  Fuck.

Name: Anonymous 2010-08-23 1:44

>>50
That's the way it normally works.  I guess it depends on your definition of "more appropriate."  As I stated from the beginning, I just think that making the "copy()" operation explicit would at least make new or bad programmers think for a second before passing that 50MB bitmap object into a function by value.

Name: Anonymous 2010-08-23 1:45

>>52
I know it sounds like a troll, but it's true.  I'm in a position now where I hire new college grads, and the upshot of this thread is that I have some great new interview questions.

Name: Anonymous 2010-08-23 1:55

>>55
I have some great new interview questions.
Bullshit. All trolling aside, any programmer can answer correctly all the questions asked in this thread (except those that are undecidable). I refuse to believe any of today's programming juniors will be filtered by your interview.

Name: Anonymous 2010-08-23 2:02

>>53
There are in fact actual languages that real programmers use in which 6 := 2 is legal and will actually set the value of the symbol 6 to the number 2.

Name: Anonymous 2010-08-23 2:03

>>56
I'm not really talking about right/wrong questions...  I'm just suddenly more aware of the trend toward esoteric bullshit.  Like the guy who says "lol performance doesn't matter anymore."

I'm going to make sure that A) the candidate understands why performance does matter, and B) how to go about achieving it.

Name: Anonymous 2010-08-23 3:30

>Is there a language in which variables, function arguments, etc, are always references by default?
This is a bad idea and you should feel bad.

Name: Anonymous 2010-08-23 3:51

>>57
Fortran, wasn't it?

>>54
Then you're just going to have the bad programmers accidentally modifying data that should have been copied. If you were going to do this and expect it to make things clearer, you'd have to make every argument take an explicit copy/refer marker. And you'd have to require them in both the function definition and at the call site.

Name: Anonymous 2010-08-23 5:27

>>1,1-1
SPAWHBTC

Name: Anonymous 2010-08-23 9:02

>>60
Fortran is one of many.

Name: Anonymous 2010-08-23 18:25

>>40
Does your company tells publicly they use ocaml?

Name: Anonymous 2010-08-23 20:19

>>53
In a single sentence: I don't think you understand what "semantics" means in a sense more abstract than the underlying assembly constructs. Get out and have good luck in your learning.

Name: Anonymous 2010-08-24 7:41

>>38,39
I just want to point out how misleading your programs list is. All you pointed out were a list of drivers and the OS. Of course that stuff needs to be written low-level.

For an app like Winamp, efficiency definitely does not matter. The only parts that need to be efficient are MP3 decoding and database management, both of which should be handled by separate dedicated low-level libraries (something like SQLite or BerkeleyDB). In some cases these facilities are provided by the OS (for instance an iPhone provides CoreAudio decoders and SQLite as built-in libraries.)

Winamp got horribly slow around version 3, and the language had nothing to do with it. It was still written in C++.

Name: Anonymous 2010-08-24 7:45

>>65
You know C++ is basically C with some useless syntactic sugar, right?

Name: Anonymous 2010-08-24 8:06

>>66
I consider C++'s "syntactic sugar" quite harmful.

Name: Anonymous 2010-08-24 9:25

>>66
Uhh yes, what's your point?

Name: Anonymous 2010-08-24 9:31

>>68
My point is that obviously the language has nothing to do with this slow-down around version 3. What you're saying happened has no reason at all to be blamed on the implementation language.

Name: Anonymous 2010-08-24 9:36

It's never C++, which is a perfect language. It must be the programmers, or the compiler writers, or the library authors, or the platform, or...

Name: Anonymous 2010-08-24 10:29

>>69
Uhh, that was my point too genius. Version 2 and version 3 were both written in C++. One was fast, the other was slow. Ergo, the implementation language had nothing to do with it.

http://en.wikipedia.org/wiki/Reading_comprehension

Name: Anonymous 2010-08-24 10:43

>>71
COMPREHEND MY ANUS

Name: Anonymous 2010-08-24 10:52

Name: Anonymous 2010-08-24 10:54

>>71
So why mention it? I thought you were being sarcastic about C++ being slow. You had no need to say anything about Sepples at all.

Name: Anonymous 2010-08-24 10:55

>>73
Implying I have aspregers

Name: Anonymous 2010-08-24 12:32

>>75
You have asspreger's

Name: Anonymous 2010-08-24 13:22

>>65
For an app like Winamp, efficiency definitely does not matter. The only parts that need to be efficient are MP3 decoding

The only part of an MP3 player that needs to be efficient is the MP3 decoding?  Not even you know what point you're trying to make any more.

You should whip up an MP3 player (a.k.a. "MP3 decoder") in BASIC or whatever the hell it is that you use and keep it running in the background.  Make it so that it consumes 100% of your CPU(s) at all times, even when paused.  Hopefully the pain of using your PC at that point is too much to bear and you can no longer visit /prog.

Name: Anonymous 2010-08-24 13:51

>>77
Surely you're trolling. Winamp does a hell of a lot more than decode MP3s.

Name: Anonymous 2010-08-24 13:52

Name: Anonymous 2010-08-24 14:03

>>77
The only part of an MP3 player that needs to be efficient is the MP3 decoding?  Not even you know what point you're trying to make any more.
Winamp provides a fully skinnable UI, a rich plugin architecture, an archive management system, etc.

The reason you think everything should be built in C++ is because you're unable to conceptually separate the computationally intense subsystems of the application from the whole application itself. Think about all of the features in Winamp; what percentage of Winamp code do you think is specifically for MP3 decoding? 2%? 1%? So why should you write the entire program in a comparatively low-level language just for that small percentage?

While the main function of Winamp is playing music, there is no reason this needs to even be part of the application code. Any modern OS provides decoding MP3s as a system service; for those formats it doesn't, you can use (foss or licensed) third-party libraries. If you do need to write something like this yourself, you can write it in a low-level language and link it in, and keep the other 99% of the program in a better language.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List