[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
i've just learnd that c dose not know what a boolean is.
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 161
Thread images: 5
File: c++.jpg (20 KB, 360x193) Image search: [Google]
c++.jpg
20 KB, 360x193
i've just learnd that c dose not know what a boolean is.

So:
What does /g/ think bout C++ and why.

Also lets waste 32bit to store a one.
>>
>>53989057
Yes it does, it wouldn't have if-statements if it didn't. Anything that evaluates to integer zero is false, anything else is true.

And C++ is a big, overcomplicated, sloppy mess of a language that's in the neither-one-thing-nor-another zone.
>>
>>53989196
>its stores the value in an int
>also everything that is not 0 is true.
>try it
that's literally what I just said

>so open ears for everything bout c++
it was shit five minutes ago and its shit now.
>>
You use a char, dumbass
>>
>>53989196
uint_8 probably. Havnt touched standalone cpp in a long time
>>
>>53989132
It's not as though you have to use the parts you don't want to or as if they somehow burden you or your code.

C++ is amazing.
>>
This is how processors work. You can't ask for a bit of space. By allowing for single bits, you'd have to do all kinds of bit fiddling in the background. It would mess with C's awesome addressing system as well.
If you need to use high level concepts while ignoring all of this, use javascript or python or something.
>>
>>53989057
How about defining True as 1 and False as 0?
>>
>>53989358
today I learned all numbers in Javascript are stored in memory as 64bit floats.

Everything.
>>
>>53989057

How long would an experienced (2-3 years Java) programmer take to learn C++ enough to get a job using it? I'm thinking finance.

I keep hearing how difficult it is and how long it takes to learn.
>>
File: 1452558815705.jpg (232 KB, 538x785) Image search: [Google]
1452558815705.jpg
232 KB, 538x785
>>53989556
why do we use this abomination again?
>>
>>53989057
>i've just learnd that c dose not know what a boolean is
I've just learned that OP doesn't know what C is: https://en.wikipedia.org/wiki/C_data_types#stdbool.h .
>>
>>53989057
Working on a C++ project on Linux since last December, I could say, it's a really powerful language, but its standard is a big mess compared to C. And even with the latest standards, both the language itself and the STL make too many implicit assumptions. I actually have to go reading the standard because there could be multiple interpretations of a particular feature (for example, zero or null-initialization), that the previous guys on the project didn't care about and that caused bugs because behavior was undefined. Torvalds is right when he says C++ enable terrible programmers to make terrible code with it: unmaintainable, not generic, verbose. Exactly the contrary of what was expected when C++ was introduced.

Thank God, GCC has become stricter with poor C++ code, but C++ is still not to be left in anybody's hands.
>>
>>53989057
1) Ever heard of <stdbool.h> faggot?
2) sizeof(_Bool) == 1 on gcc under gahnoo+loonix
>>
>>53989587
because god is dead and JS has killed him?
>>
>>53989057
but C has had booleans for almost 20 years, faggot
>>
>>53989574
You just have to unlearn a lot of shit.
Pointers were difficult at first, but memory management isn't as hard as people make it out to be. I've really only been using C so I couldn't tell you much about the OOP aspects of C++.
>>
>>53990012

I already know C btw. I'm just curious why people said it takes a long time to learn.
>>
>>53990036
Because
1) if you think you know C you don't know C
and
2) people on /g/ don't know shit about anything
>>
>>53989057

c++ is a top tier language that doesn't baby you like java and python.

Strongly typed: check
Minimal overhead from unused features: check
Low level manual memory management: check
Pointers/pass by reference: check
Compiled / badass preprocessor: check
>>
>>53990036
It isn't that difficult, it will take a while to learn some of the more intricate aspects of the STL. But to get started if you already know c, and java it won't be that hard.
>>
>>53990160

Maybe it was the context which made it difficult. Like using C++ for frequency trading or something similar. I don't remember the context honestly.
>>
I would say C++ is everything that C is plus the classes with the advantage of the object oriented design.
Since C++ is backwards compatible with C, there is literally no reason to not use C++.
>>
>>53989556
>>53989556
What happens on a 32bit system?
>>
>>53990071
>Strongly typed: check
made me kek
>Minimal overhead from unused features: check
true
>Low level manual memory management: check
implying that's a good thing
>Pointers/pass by reference: check
every single language passes by reference
>Compiled / badass preprocessor: check
whoa
>>
>>53990436
Still 64bit. Javascript is an interpreted language.
>>
>>53990062
C isn't C++ and your post is actually a great example of your second point.
>>
>>53991017
I'm not that anon but

>made me kek
C++ is more strongly typed than not

>implying that's a good thing
It is a good thing, unless you're incompetent.

>every single language passes by reference
C++ offers pass by value (default) and pass by reference

>whoa
Yes
>>
>>53991154
>C++ is more strongly typed than not
How can anything be "more" or "less" strongly typed. It's binary, it's either or.

>C++ offers pass by value (default) and pass by reference
And so does every fucking language, so what?

>>53991132
Butthurt much?
>>
>>53991185
stop posting about shit you don't understand.
>>
>>53991185
>How can anything be "more" or "less" strongly typed. It's binary, it's either or.
you're making an absolute fool of yourself. Please learn how different languages compare to one another and how the terms "strong typing" and "weak typing" describe a gradient across typing systems and are not black and white.

>And so does every fucking language, so what?
I was clarifying, not really to you, but. C++ is mostly pass by value.
>>
>>53989358
Minimum memory block is 8 bits, right? So would an object (struct or class) with a member variable of 8 bools (or a bool array of size 8) and no other members take up 8 bits? That would achieve the same ratio as storing a bool as a single bit.

>>53989589
>>53989618
Not having a bool as a primitive data type seems like a major omission. And as for
>sizeof(_Bool) == 1
Doesn't sizeof() return the size in BYTES? So that's still 8 bits to store 1 bit of data.

>>53990036
If you know C, it probably won't be too hard to learn C++, especially if you have OOP experience in other languages. The hardest part about C++ is the pointers and memory management, which really don't exist in most high level languages.
>>
>>53991264
>Minimum memory block is 8 bits, right? So would an object (struct or class) with a member variable of 8 bools (or a bool array of size 8) and no other members take up 8 bits? That would achieve the same ratio as storing a bool as a single bit.

No. Languages do not compact data that way. You can achieve something similar though using bitwise operations. bit masks.
>>
>>53991264
>The hardest part about C++ is the pointers and memory management, which really don't exist in most high level languages.
Except they sort of do. These things are possible because of RAII. Both C# and Python (and a bunch of other languages) support RAII.

You have constructors, copy constructors, assignment constructors and destructors in Python too.
>>
>>53991203
Anon claimed he knows C. I pointed out he most likely doesn't know C. You got butthurt about it, deal with it. I said nothing of the sort that somehow equated C with C++, that only exists in your mentally challenged mind.
>>
>>53991264
>Not having a bool as a primitive data type seems like a major omission.
REEEE I HAVE TO INCLUDE A LIBRARY AT THE TOP OF MY CODE
>>
>>53991101
no it isnt, its jitted everywhere.
>>
>>53991437
JIT compilation is still interpreting. What in the fuck am I reading? JavaScript is an interpreted language, as opposed to compiled language.

Every time I post something here someone has to "correct" me.
>>
>>53991821
>compilation is interpreted as opposed to being compiled
Are you high?
>>
>>53991821
no it is not, it is read once through and directly turned into unoptimized x86 assembly. hot functions are optmized and recompiled. this is not interpretting in any sense.

http://jayconrod.com/posts/51/a-tour-of-v8-full-compiler
>>
File: 1447867832311.jpg (65 KB, 500x500) Image search: [Google]
1447867832311.jpg
65 KB, 500x500
>>53991821
>>53991853
pic related, its (you)
>>
>>53991852
I said JIT compilation is still interpretation. Read what I said fuckhead.

>>53991853
The V8 engine doesn't use interpretation, but that doesn't make Javascript a compiled language. I can write a C++ interpreter, but that doesn't make C++ an interpreted language. Even if V8 was used in all browsers and JavaScript applications, your point is still invalid.
>>
>>53991963
lol, you're done kid. go home. be here bright and early on the boards to get your next dose
>>
>>53991910
Actually it's not. But this is what I'm talking about. It's like people on this board know just enough about these things to make subtle errors in their assertions and they're not capable of understanding the way things actually are.
>>
>>53991314
Here's what you said:
> if you think you know C you don't know C

I'll reiterate and expand: C isn't C++ which has some unruly standard spanning 700+ pages. C is C and it can truly be internalized.

Stop talking about what you don't understand, as was made clear from your other comments.
>>
>>53991990
>better start trolling now that I learned something
>>
>>53991301
No, but you can use bitwise operators to simulate that. Don't do it if you don't need it.
>>
>>53989589
Thank you for posting this 10 Internets for you!
>>
>>53992034
>I'll reiterate and expand: C isn't C++ which has some unruly standard spanning 700+ pages. C is C and it can truly be internalized.
Anon was claiming to know C, I don't know why you are bringing C++ into it.
>>
>>53991963
>I said JIT compilation is still interpretation. Read what I said fuckhead.
>compilation is still interpretation which is not compilation
Again, are you high?
>>
>>53991017
>every single language passes by reference

try pass a primitive in java by reference
>>
>>53992195
You responded to the wrong person and then posted exactly what they already said. Good joob.

>>53992271
How do you think the JIT compiler determines how to compile the code on the fly? I'll give you a hint, it involves interpretation. God damn you're fucking dense. What are they teaching you kids these days?

JIT compilation is a combination of interpretation and compilation. Otherwise it wouldn't be JIT compilation... it would just be compilation.

Javascript is an interpreted language. End of story.

Dumbfuck shitbrain cancer scum piece of shit. Fuck. Read a book.
>>
>>53992297
you can't really pass an object by reference in java either
>>
>>53992357
>How do you think the JIT compiler determines how to compile the code on the fly?
The same way a compiler does it.

>I'll give you a hint, it involves interpretation.
So now you're saying all compilers interpret, but you just said that JIT compilation is interpretation and not compilation.

>JIT compilation is a combination of interpretation and compilation. Otherwise it wouldn't be JIT compilation... it would just be compilation.
Here's a hint. JIT compilation _is_ just compilation.
>>
>>53992297
Wrap it in an object or pass it as an array.

>>53992360
All objects and arrays are passed by reference in Java.
>>
File: 1431308605551.jpg (12 KB, 200x200) Image search: [Google]
1431308605551.jpg
12 KB, 200x200
>>53992381
this
>>
>>53992381
>The same way a compiler does it.
Care to explain why the code would not just be compiled initially, if not the need for interpretation?

>So now you're saying all compilers interpret, but you just said that JIT compilation is interpretation and not compilation.
No, although JIT compilers user interpretation

>Here's a hint. JIT compilation _is_ just compilation.
Well fuck me, right? Why compile the entire program before running, when you can just use JIT compilation somehow without interpretation to compile discrete sections at a time over and over again!
>>
>>53992360
In java, objects are passed by reference, primitives aren't. java.util.collections sort() method returns void, if it was pass by value it would need a return type.
>>
>>53992438
to answer your first question, its not because the language is interpreted. its because its dynamically typed.
>>
>>53992438
>Care to explain why the code would not just be compiled initially, if not the need for interpretation?
It's called JUST IN TIME compilation. The reason it isn't compiled at start is because it's lazy compilation. Lrn2 code path.

>No, although JIT compilers user interpretation
By your own definition all compilers do interpret somewhat. Interpretation is not synonymous with executing.

>Why compile the entire program before running, when you can just use JIT compilation somehow without interpretation to compile discrete sections at a time over and over again!
Static compilation for maximum speed, speed+memory optimization and minimal memory footprint, JIT compilation when the tradeoff is acceptable.

Also, no one said anything about no interpretation at all, those are your words not mine. I'm just pointing out the irony in saying that "hurr durr JIT compilation is not compilation", because it obviously is compilation and micro optimization.
>>
>>53992438
>Care to explain why the code would not just be compiled initially,
Because it's dynamically typed. Also, what >>53992498 said about lazy evaluation.
>>
>>53992487
I don't know how to make you understand. JIT compilation is both interpretation and compilation. Even if it wasn't, that doesn't detract from the fact that Javascript itself is designated as an interpreted language.

Interpret relevant portion of program
Translate to bytecode
Execute
Repeat
>>
>>53992392
>>53992481
>All objects and arrays are passed by reference in Java.
not true. everything in java is passed by value. there aren't any variables to hold an actual object like in C++, just a reference/pointer to it, and those are passed by value;
private static void byValue(String s) {
s = "zcx";
}
public static void main(String... args) {
String a = "asd";
test(a);
assert a.equals("asd");
}
.
>>
>>53992392
>Wrap it in an object or pass it as an array.

Why would I want all that overhead of constructing objects if I just want to write a swap function for two primitives? That's a shitty solution.

JAVA = BLOAT
c++ = elegance
>>
>>53992560
>passing a reference is not passing a reference
u w0t m8

>>53992562
Class wrappers for primitives are lightweight objects though.
>>
>>53992559
x86 is not bytecode. and no js engine in the last 5 years has turned it into bytecode. no amount of screaming and kicking will make it so. did you even read the link posted? stop humiliating yourself
>>
>>53992042
fucking faggot
>>
>>53992498
>Also, no one said anything about no interpretation at all, those are your words not mine. I'm just pointing out the irony in saying that "hurr durr JIT compilation is not compilation", because it obviously is compilation and micro optimization.

>Here's a hint. JIT compilation _is_ just compilation.

>no it isnt, its jitted everywhere.

>It's called JUST IN TIME compilation. The reason it isn't compiled at start is because it's lazy compilation. Lrn2 code path.
I know what it's called. The methodology about how code is compiled JUST IN TIME is where interpretation comes into play. This isn't fucking hard.

What you just said is "the reason it isn't compiled at start is because it's compiled later on." What are you even getting at?

>By your own definition all compilers do interpret somewhat. Interpretation is not synonymous with executing.
This isn't MY definition, it's widely accepted. Please educate yourself. I never claimed interpretation was the actual point of execution.
>>
>>53992559
In your deluded head, what do you actually think goes on in the "interpret relevant portion of program" stage?

Because interpret and translate to byte code is the same fucking step: It's called compilation.
>>
File: 1444181138762.jpg (18 KB, 707x370) Image search: [Google]
1444181138762.jpg
18 KB, 707x370
>>53992023
>unironically literally describing yourself
>>
>>53992634
>What you just said is "the reason it isn't compiled at start is because it's compiled later on." What are you even getting at?
JavaScript is dynamically typed you moron, hence why it is compiled "later on". How thick are you?
>>
>>53992619
A "js engine" is not Javascript. The language is an interpreted language. I'm kicking and screaming because kiddies seem to think the way a particular piece of software executes Javascript has a bearing on the language itself. Perhaps you didn't read the link posted?

Again, if I write a c++ interpreter (which do exist), that does not make c++ an interpreted language.

I'm beginning to think this thread is full of JS "coders" who can't into anything less abstract than the language itself.
>>
>>53992672
parsing and building an AST is not interpreting.
>>
>>53992672
>I'm kicking and screaming because kiddies seem to think the way a particular piece of software executes Javascript has a bearing on the language itself.
Now you are just making stuff up on the go. Nobody ITT said anything about this. You're just moving the goal post to cover up the fact that you have no fucking idea what you're talking about.

>I'm beginning to think this thread is full of JS "coders" who can't into anything less abstract than the language itself.
Anon, you're the fucking retard who didn't even know JS was JIT'd in the first place (by virtually every single modern JS engine there is), and when you found out it was you had no idea why it must be JIT'd and can't be statically compiled....

You just fucking wrote that it was JIT'd because it "had to be interpreted" first which makes no sense at all.
>>
>>53992617
you may want to check what passing by reference actually means
void by_reference(int& x, int& y) {
x = 3;
y = 4;
}
int main() {
int x = 1;
int y = 2;
by_reference(x, y);
assert(x == 3);
assert(y == 4);
}
>>
>>53992671
I understand that. What I was trying to get him to see is that... if JIT is JUST compilation... then the language would be fully compiled to begin with.

>>53992652
The language is parsed and types are resolved.

>>53992652
>interpret and translate [is] called compilation
You can't have it both ways. I now have two people arguing not only against me but among themselves. Retards.
>>
>>53992706
>hurr durr i'm not passing by reference because i'm passing a reference type herp der
void by_hurrdurr_value_according_to_you(int& x, int& y)
{
int t = x;
x = y;
y = t;
}

void foo(int& x, int& y)
{
by_hurrdurr_value_according_to_you(x, y); // <--- where is your god now?
}
>>
>>53992706
Uhh did you just change the address values passed instead of the values at them?
Was that intentional?
>>
>>53992724
>The language is parsed and types are resolved.
Parsing is not interpreting. Building the AST is not interpreting.

Every fucking compiler does this. So tell me, how is JavaScript "not compiled" when it goes through the exact same steps as compiled code?
>>
>>53992706
what the fuck is that language?
>>
>>53992706
>you may want to check what passing by reference actually means
Passing by reference is literally passing a reference. Just because sepples does syntactic sugar and implicitly converts variable addresses into references, doesn't mean that passing a reference type isn't pass by reference.
>>
I like C++ and I accept that I will never master it. String operations are a bitch though.
>>
>>53992705
>Now you are just making stuff up on the go. Nobody ITT said anything about this. You're just moving the goal post to cover up the fact that you have no fucking idea what you're talking about.
But they did.
>Still 64bit. Javascript is an interpreted language.
>no it isnt, its jitted everywhere.

You're wrong and you keep making it worse. What in the fuck.

>Anon, you're the fucking retard who didn't even know JS was JIT'd in the first place (by virtually every single modern JS engine there is), and when you found out it was you had no idea why it must be JIT'd and can't be statically compiled....
No no and no.

>You just fucking wrote that it was JIT'd because it "had to be interpreted" first which makes no sense at all.
Show me where. What I was doing was exposing how illogical it is to claim JIT is just compilation. If that were true, JIT would not be differentiated between itself and compilation. There wouldn't be a need for it. I asked for the the reason why it is necessary. It's a dynamic language. If it's dynamic, how can it be JIT compiled without dynamic interpretation? It can't.

Fuck you people are literally beneath me. This is why you program in js.
>>
>>53992774
Dont bother even trying to master it
It has very few realistic uses
>>
>>53992745
english with hebrew number system and ASCII compliant special charaters
>>
>>53992786
>doesn't even know how JIT works
>claims he is "above" other people
The Dunning-Kreuger is strong with you.
>>
>>53992798
Holy fuck this board is literally cancer. You must be one of the compiled only JS users.
>>
>>53992803
good, i thought it was someone's attempt to write c
>>
>>53992809
>Holy fuck this board is literally cancer
Then leave, nobody will miss you.
>>
>>53992745
that's c or c++ syntax.
>>
>>53992826
suck my fat dick bitch you dont tell me what to do

go back to your trap porn faggot this is my thread
>>
>>53989057
Assembly doesn't "know" what a boolean is. Why would C? A boolean is whatever you as the developer want to define it as.
>>
>>53992839
well it sure as hell isn't valid c for passing by reference
>>
>>53992809
Please enlighten me on all those cases where c++ is more suitable than either C or C#
Theyre pretty much just game engines and some weird nitch things
>>
>>53992845
this
#define bool char
if you really really have to
>>
>>53992861
Actually I want you to show me what cases where C# is more suitable than C or C++.
>>
>>53992855
didn't say it was valid ;^)
>>
>>53992840
You must be 18 to be here.

>>53992861
Not him, but C++ is a lot nicer to work with than C when you don't want to give up on the speeds you get with C. For embedded and systems programming, there is no reason to use C over C++ unless you're contributing to a project that's already written in C or you need to bootstrap the C++ object model manually.
>>
>>53992861
embedded systems that need a level of abstraction beyond C
>>
>>53992725
you must really be retarded, if you still think passing objects in java is the same as an actual pass by reference in c++
>>53992735
>>53992745
c++
>>53992771
>Passing by reference is literally passing a reference
no, it's not
>>
>>53992877
C++ is an unmanaged memory oop shit
C# is better for normal oop shit because memory management
And c is better for performance applications because of the control you have
C++ is literally the bloat of c# with the added complexity of managing memory
As it it has the negatives of both and no positives
I dont think you need an example
>>
>>53992861
So far we have game engines, embedded systems, niche cases, and commercial desktop software that isn't from a shit company is a good one too.

I mean that covers pretty much everything
>>
>>53991326
Yet some other guy, good and unqualified here.
I have written in Fortran and Pascal and it seems to me that C has some prerequisites before you can go using numeric data; is that so, that you have to "include a library" at the top of the code to get integers?

What excellent civil dialogue throughout this thread, I am confident I can ask a question and not be called names. Much.
>>
>>53992939
>you must really be retarded, if you still think passing objects in java is the same as an actual pass by reference in c++
Tell me the difference between holding a reference type (in foo) and passing it along and passing a reference type in Java/Python/JavaScript/whatever then.
>>
>>53992952
Exposed for what you really are.

I understand not everyone wants or needs to manage their own memory. But c'mon now.
>>
>>53992913
C# is nicer to work with than c++ thu
Like you said with not needing maximum performance for some things

>>53992924
>nitch
>>
ITT:
>java doesn't do pass by reference
>JIT compilation isn't compilation
>C = C++
>strongly typed just means it's more strongly typed than weakly typed

Welcome to /g/ everyone
>>
>>53992955
>commercial desktop software
How are those memory leaks :^)
>>
>>53992979
>C# is nicer to work with than c++ thu
Yes, but you need to boostrap the CLR (and most probably .NET if you're into that sort of thing too).

>Like you said with not needing maximum performance for some things
My point was that with C++ you _do_ get maximum performance.
>>
>>53992990
>strongly typed just means it's more strongly typed than weakly typed

Tell the class what you think strong typed and weak typed refer to and give some examples of languages.
>>
>>53992977
Like I said, when you need to manage memory youre going for performance, hence what c is for
Ofc c++ still has small uses in those weird cases
>>
>>53992994
How are those logical errors :^)

It's like the difference between driving stick and manual... if you have memory leaks, it's the drivers fault.
>>
>>53993013
>My point was that with C++ you _do_ get maximum performance.
Nope
You get shit on by memory overhead and vtable calls and whatnot
>>
>>53993022
Very strongly typed: the lisps and Haskell
Not so strongly typed: C++
Barely strongly typed: Python, Java
Weakly typed: C
Even weaker typed: JavaScript, PHP, ...
>>
>>53993024
C++ can be just as fast C. It's not as though non-OOP code is magically weighed down by OOP and abstract language features.
>>
>>53993053
>You get shit on by memory overhead
What memory overhead?

>and vtable calls and whatnot
Only if you write shitty code, inheriting from everywhere, would this be a performance issue. vtable is literally a memory lookup, and the compiler is very good at caching those btw.

I mean, wtf do you even know about C++? You don't even know how references work: >>53992735
>>
>>53992952
This reply truly shows us your level of understanding of c++. Whatever shitty c code you write is not likely going to be anywhere near as efficient as the same code written in c++ after it's been optimized by the preprocessor.

Also unused c++ features don't add any bloat to your program.
>>
>>53993051
Yeah
But why deal with the manual when the automatic works juat as well
>>
>>53993056
So you agree that strong typing and weak typing is a relative gradation between languages?

I'm confused by your previous post.
>>
>>53993090
the compiler caches vtable calls? what universe are you in. the compiler isnt used at runtime. and every call to a vtable is almost certainly gonna be a cache miss. devirtualizing is something compilers do though
>>
>>53993097
Because laptimes and fun, that's why
>>
>>53992972
when you pass by value, the variable is copied and if you assign some other value to the function argument, you assign it to the copy and the passed variable stays unchanged. changing the value when passing by reference will affect the arguments after the function call.
>>
>>53993116
>So you agree that strong typing and weak typing is a relative gradation
Yes

>between languages?
Wouldn't make the distinction on language level. Type theory is well-defined after all.

>I'm confused by your previous post.
I'm laughing at people ITT calling C strongly typed.
>>
>>53993090
>I mean, wtf do you even know about C++? You don't even know how references work
>literally quotes me commenting on tard code

>>53993091
Yes anon, me compiling the same with the c++ compiler will magically make it faster
>>
>>53993149
>Yes anon, me compiling the same with the c++ compiler will magically make it faster

It will. You'd be surprised by how complex and powerful the c++ compiler is.
>>
>>53993131
>the compiler caches vtable calls?
Yes. A vtable lookup is just a memory lookup.

>the compiler isnt used at runtime
Not everything needs to happen at runtime. How the hell do you think compiler optimizations work?

Protip: Compilers also optimize memory lookups.

>and every call to a vtable is almost certainly gonna be a cache miss.
That's just plain ignorant. Do you have a habit of making insanely large objects with many methods, and/or do you have a habit of allocating objects extremely sparsely apart?

>devirtualizing is something compilers do though
Well, duh.

>>53993137
>when you pass by value, the variable is copied and if you assign some other value to the function argument, you assign it to the copy and the passed variable stays unchanged. changing the value when passing by reference will affect the arguments after the function call.
So how is pass by reference in Java not pass by reference?
>>
>>53993207
>>53992725
>So how is pass by reference in Java not pass by reference?
private static void byHurrdurrReferenceAccordingToYou(Integer x, Integer y)
{
Integer t = x;
x = y;
y = t;
}

Go ahead and see what happens
>>
>>53989057
>what is typedef
>>
>>53993296
you're passing by value in that function goober
>>
>>53993296
You're changing the reference, whereas references in C++ are immutable and thus implicitly dereferenced.

You're not explaining why passing a reference isn't pass by reference, you're only pointing out that one language implicitly dereferences while the other changes the reference....
>>
>>53993320
that's the joke. you can only pass object variables by value in java
>>
>>53993347
oh. I haven't used Java in a long time. Since Android dropped.
>>
>>53993347
See >>53993335

It's a reference, you're not doing any deep copies and then passing by value. You're passing the reference.
>>
>not just passing UML to the pajeet
>>
>>53989057
>Also lets waste 32bit to store a one.
OMG OP, you must be really smart to think of this. You should email Intel and let them know of this great, memory-saving optimization tip!
>>
>>53993335
Passing by reference literally means that the
function can reassign the actual argument and passing the reference by value isn't the same thing and what you wrote has nothing to do with anything
>>53993359
I'm copying the passed variable, which is a reference. deep copy has nothing to do with it
>>
>>53992481
>>53992392
>>53992617
>>53992725
>>53992771
>>53993335
holy shit, /g/ is literally much worse than pajeets and has completely no idea about even the most basic stuff
https://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html
>Reference data type parameters, such as objects, are also passed into methods by value. This means that when the method returns, the passed-in reference still references the same object as before. However, the values of the object's fields can be changed in the method, if they have the proper access level.
>>
>>53992961
OK not name-called!

No reply. Well my background can be unworthy.
>>
>>53993149
there was nothing wrong with that code. you're too dumb to understand some basic language constructs
>>
>>53991264
_Bool is a primitive
>>
>>53993196
which c/c++ compilers are considered the best?
>>
>>53991326
Yes, because libraries are supposed to be for specializations, not common stuff that can be used in any program. I mean, it's entirely possible to have a language that has bools (i.e. bits) as its ONLY primitive data type, and have every other data type in libraries built off of that. But I'd hardly call that a complete general purpose language.

>>53991821
Isn't JIT still compilation rather than interpretation? As I understand it, the difference is that compilation converts the entire code into machine instructions (either stored on disk as an executable file, or loaded into memory with JIT) and then executes it, while interpreters go one line at a time.

>>53991963
>. I can write a C++ interpreter, but that doesn't make C++ an interpreted language.
Your implementation of it would be an interpreted language. Just like BASIC can be either compiled or interpreted. But if I recall, someone HAS actually created an interpreted version of C++, and it required substantial changes to the language since it's not designed to be interpreted.

>>53992357
If by interpretation you mean parsing, than yeah - but by that definition EVERY compiled language is interpreted. It's only an "interpreted language" if each line is executed before the next one is parsed.

>>53992559
The only way "JIT compilation is both interpretation and compilation" can be true is if your program is composed of multiple JIT-compiled executable units, which aren't compiled until called from the main function. If you have a single unitary executable, it's JIT compiled once at the beginning and no more compiling or interpreting happens while it's running.

>>53992798
Are you the same metric that made a fool of himself on /r9k/?
>>
>>53993024
So you can't imagine a situation where you'd want both OOP and memory management? I mean people usually think of C++ as an OOP language but it's main advantage is that it's multi-paradigm, you can choose which features to use without having to use anything specific. That's why it includes all of C.
>>
Does anybody in this thread know what pass by reference and by value fucking means?

Jesus christ my head is going to explode
>>
>>53994679
>Yes, because libraries are supposed to be for specializations, not common stuff that can be used in any program

Then why do you have to include stdlib.h and shit everywhere?

Fuck off
>>
>>53989057
>never heard of <bool.h>
>>
Java is pass by value, universally. Holy fuck you guys are stupid.
>>
>no stdbool

gee, op really sucks badly...

#include <stdbool.h>
>>
>>53990436
... you still (kinda, it depends) have 64b floats on 32b systems
>>
>>53994826
Well yeah, that's what I'm saying is the problem with C. There isn't enough built-in functionality to build a useful program without libraries. They tried so hard to avoid making assumptions about the environment a program would be running in that they ended up with a language that can't do ANYTHING without libraries.
>>
>>53992634
So if nobody reads my programming language it wouldn't be interpreted correct?
>>
>>53995059
So what?
>>
>>53994812
Passing by value basically means you're sending the function or whatever a copy of the object in question. All its data fields or whatever are the same, but any changes to it won't affect the original (and under normal scope rules, it will cease to exist when leaving the function, unless it's declared static or returned from the function).

Pass by reference means you give the function the address of the object, so they can manipulate the original. Thus the original object can be altered by the function, even if the function's return type is void.
>>
>>53989132
Maybe he means the bool type (which is in c99 or some shit)

>>53989057
Lets piss on a 32 bit architecture and force it to move one byte so the autistic dev can eat a couple clock cycles to save 3 bytes
>>
>>53994954
>>53994954
>>53994954
>>
>>53995120
The Java documentation itself says it is strictly pass by value.
>>
>>53995109
So I guess I should go look up libraries in C before I can start to be short on any knowledge about it.
>>
>>53992252
>I don't know why you are bringing C++ into it.
because it's the fucking thread's subject
>>
>>53996434
OK people so how good is the BOOST library set of over 80 libraries?
>>
>>53995059
>>Every lego brick
C is a fucking system's language, you're supposed to write system code with it i.e an operating system. The libraries exist so you can write applications with it, which is amazing considering the original scope of the language.
>>
a header file is not a library you morons
the standard library IS linked by default
but you need to know the declaration of functions to use them
fucking scripting language programmers
Thread replies: 161
Thread images: 5

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.