[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
/dpt/ daily programming thread
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: 255
Thread images: 21
File: YOU312t.gif (3 MB, 500x260) Image search: [Google]
YOU312t.gif
3 MB, 500x260
/dpt/ for non-degenerates among us

old thread >>52934914

what are you working on /g/?
>>
why is her heart black?
>>
File: dpt.png (550 KB, 1500x1800) Image search: [Google]
dpt.png
550 KB, 1500x1800
>>52939611
REMINDER to ignore TROLL posts that contain:
> gcc compiles this wrong code!!! (posts some retarded shit, compiles with g++)
> java can't compare these Integers with ==
> average of two ints in C
> fizzbuzz
> buzzwords
> go has no generics
> haskell is useless
> lisp brackets are unreadable
> GC is shit, use a real language
> programming literate
> anime ops
> non-anime ops
> posting new thread to early
> anime is gay
> trap ops
> non-trap ops
> osgtp retardation
> tripfags in general

Also, please don't forget to post this in the next thread. If you want to modify this list, POST IT YOURSELF.
thanks.
>>
>>52939663
Its a nigger
>>
how can I average 2 ints, gee?
>>
>>52939666
>python has warts but other languages also have warts so python isn't shit u guise!!
>>
is animu for homosexuals?
>>
>>52939611
she's not really my type but she's still beautiful af
>tfw no gf
>>
File: Capture.png (3 KB, 538x78) Image search: [Google]
Capture.png
3 KB, 538x78
Daily reminder to never run software as root.
>>
first for GC a shit
>>
>>52939737
Have fun hunting leaks.
>>
File: 1385533581520.gif (2 MB, 382x282) Image search: [Google]
1385533581520.gif
2 MB, 382x282
Probably a stupid question for anyone with decent understanding of maths, but..
I want to translate the the mouse cursor X coordinate to an angle between -45 and 45.

The coordinate is a fixed point number from 0.0 to 1.0 with 0.5 representing the middle of the screen, so I multiply it by 2.0 and subtract 1.0, then multiply it again by 45.0.

This makes the angle appear when the cursor is at the center or at either screen edge at 90 degree fov, but wrong in between. What should I do differently?
>>
why is gcc compiling code wrong so often?
>>
>>52939755
appear correctly*
>>
>>52939753
>I'm incompetent
we could have guessed that, pajeet
>>
>>52939753

It's not really that hard to write code with no memory leaks, in a language with no garbage collection.
>>
>>52939734
where did that come from?
>>
>>52939755
>translate to an angle
>the angle appear
>what do
you could try some coherence first, you fucking muppet
>>
>>52939784
Until you enter GUI-land, then it's leaks ahoy.
>>
"FP" languages make people ignorant of mathematics, even the parts of mathematics they allegedly emphasize.
>>
>>52939755
try posting code and/or expected vs observed outcome?
>>
>>52939784
>method_missing
opinion discarded
>>
>>52939759
because gcc is a gnushit. Even NASA recommends the intel compiler.
>>
>>52939753
no u

https://en.wikipedia.org/wiki/Lapsed_listener_problem
>>
>>52939666
>> osgtp retardation

nice work.
>>
I'd like to learn programming and become good enough to employ the skill professionally, at least at the basic or medium professional level. Actually, I want to major in information technology and organizations, so my future job will not primarily be programming oriented, but a knowledge of it will definitely be valuable.

Now, everyone online who knows programming appears to be an autistic retard who is 100% unwilling to share their knowledge without being arrogant and gloating. It's weird because there really isn't anything to gloat about. Programming monkey jobs may just as well be shitty as they may pay well.

Does anyone know of a guide to learn programming well (as in-depth as possible) written for non-autists?
>>
>>52939813
>even nasa
>such authority
>much jewing
>>
>>52939755
use radians instead?
>>
>>52939799

Eh, let RAII handle it all. Still no leaks.
>>
>>52939866
learn X in 24 hours should help you be a superpower by 2020
>>
How does one use the Intel compiler instead of gcc
>>
>>52939784
>It's not really that hard to write code with no memory leaks, in a language with no garbage collection.

It's EASIER now, thanks to tools like Valgrind. With big applications, it's still a common problem.
>>
>>52939901
>still a common problem
will always be a problem for the incompetents
>>
>>52939755
What are you trying to do this in? And are you sure its using degrees and not radians?
>>
>>52939875
>Eh, let RAII handle it all.

One of these days, C++ WILL have (optional) GC.
>>
>>52939801
which parts of math would those be? and which specific "FP" languages (people use that term for a wide variety of languages with varying degrees of math influence)?
>>
>>52939941
it can't
>>
File: 20160212_112743.jpg (2 MB, 3264x1836) Image search: [Google]
20160212_112743.jpg
2 MB, 3264x1836
Web browser that lets me browse without using my brain/body too much.

Scroll through bookmarks, one in box gets opened.

Hover based buttons too.
>>
>>52939891
>learn X in 24 hours
come think of it, shouldn't every book in this series ship with a bottle of amphetamine pills?
>>
>>52939954

It both can and will.
>>
>want to program something
>realize everything has already been done by people better than me
why even bother
>>
>>52939976
can't & won't
>>
>>52939976
You can't just slap a GC on top of any program. It'll break the std::*_ptr.
>>
>>52939977
why live?
>>
>>52939977
make a game or even any ordinary program it'll still be different with your unique take on it
>>
>>52940011
>>52939976

You dumb fucks. GC for C/C++ already exists.
Look up boehmgc.
>>
>>52940036
I got dubs so I'm right.
>>
>>52939755
>so I multiply it by 2.0 and subtract 1.0, then multiply it again by 45.0
Wait, why?

If you want 0...1.0 to go to -45...45, then you need to multiply the angle range by the [0,1] value, then subtract 45.

double map( double minRange1, double maxRange1, double minRange2, double maxRange2 )
{
return (maxRange2 - minRange2) / (maxRange1 - minRange1) + minRange2;
}

// OR, more specific to your case

int angleMap( fixed input )
{
static const int minAngle = -45;
static const int maxAngle = 45;
// don't use magic numbers, pls
return (maxAngle - minAngle) / input + minAngle;
}


I do not know what you are using, but the vast majority of language standard or typical libraries already have a mapping function, since mapping a value that falls in one range to another is a very common problem.
>>
>>52939713
>python is shit guis!! cus of this reason that doesn't make sense!
>>
>>52939941

One of these days a democratic congress will eliminate the 2nd amendment. I don't look forward to either of these days.
>>
>>52940036
look up how it doesn't actually work
>>
>>52940076
Link me, I'm not finding it.
>>
>>52939666
>anti OSGTP
>trips of satan
I just shed a Breivik tear.
>>
>>52939759
You're asking why it doesn't compile code with undefined behaviour how you'd like it to? That's because it's a C compiler, not a compiler for a language which only exists in your head.
>>
File: RMS.png (293 KB, 450x399) Image search: [Google]
RMS.png
293 KB, 450x399
Answering someone's question about learning programming @previous thread
>>52940110

>>>52939255
>Let me interject for a moment. You might want to look into Racket, or as I have recently taken to calling it: EMACS Lisp 2.0.
>Racket is, to me, the state of the art of metaprogramming, and deserves its nickname "the programmable programming language". Its guide is a quite accessible and powerful introduction to metaprogramming. To this end, it obviously introduces and explains all the fundamental design ideas of the language, which really gives the deep understanding you are seeking according to your post. The language itself has a fully developped facility for 'make your own' replacements for all language constructs: I'm busy myself rewriting and improving
quasiquote
right now. So go on, follow the guide and become a better programmer
>http://docs.racket-lang.org/guide/index.html

How did I do, /g/?
>>
>>52940126
i like osgtp because he replied to me once and it made me feel less autistic and lonely
>>
>>52940036

I meant as part of the standard.
>>
if i do
for(i= 0;i<strlen(k);i++){
}
in C, is stlen(k) evaluated once or every round?
>>
>>52940067

What's wrong with optional GC?
>>
>>52940182
Y E S
E
S
>>
>>52940187
>use GC
>pull in 3rd party library
>it's manual GC
And that's how you create a cluster fuck.
>>
>>52940076
>hey guise you should try my GC for C/C++
>doesn't actually do anything
>trollface.jpg
>>
>>52940182
Every round, but the compiler will actually hoist that one out of the loop (see http://ridiculousfish.com/blog/posts/will-it-optimize.html )
>>
Since /dpt/ is so elite, I have a question for you:
what is the alternative to becoming a "code monkey"? Aren't ALL programmers code monkeys?
>>
>Suddenly a system-wide, client-visible bug rears its ugly head in your ENTERPRISE application

Fuck.

Double fuck. I'm too drunk to deal with this right now.
>>
>>52939941
> One of these days, C++ WILL have (optional) GC.
Welcome to 5 years ago (GC was added in C++11).

Note that it's the implementation's option, not the user's. The implementation is required to tell you (via std::get_pointer_safety()) whether or not unused objects will be freed automatically. It isn't required to give the program any control over this.
>>
>>52940221

Write the library maintainer a rude e-mail.
>>
Are you kids still using Python and Ruby?
>>
>>52940245

That's true, actually. The problem is that it's optional for the implementation. Implementations should be required to have optional GC to be compliant.
>>
>>52940259
pretty much no one uses ruby but there are some shitkids that swear by python
>>
>>52939708
int avg = x ^ y;
>>
>>52940252
Seriously, forcing consistency in a language is good. I'm bold enough to say that dictating the tab width is a good thing.
>>
File: 1454527242413.gif (4 MB, 200x360) Image search: [Google]
1454527242413.gif
4 MB, 200x360
>>52940288
>int avg = x ^ y;
>>
>>52940282
I swear at Python whenever I have to use it, too.
>>
>>52940282
>pretty much no one uses ruby

Ruby uses ruby.
>>
>>52939708
http://aggregate.org/MAGIC/#Average%20of%20Integers
>>
>>52940309
so pretty much no one
>>
>>52940296
>I'm bold enough to say that dictating the tab width is a good thing.

And what IS the correct tab-width?
>>
>>52940309
BCC uses Ruby for some of its projects.
>>
Can somebody explain to me how to compile C files for windows so that they will work with my C++ project?

I'm looking at this library: https://github.com/google/gumbo-parser and can't for the love of me figure out how to include it within my project.
>>
>>52940324
OOH BURN
>>
>>52940336
Obviously hard tabs 8 width. Just how your mum likes it.
>>
>>52940299
int avg = (x >> 1) + (y >> 1);


Happy now?
>>
>>52940349
>8 width

get out
>>
>>52940342
extern "C" {
// legacy code here
}
>>
>>52940349
kill yourself
>>
>>52940336
3, as a compromise between 2 and 4, obviously.
>>
File: bitch cucks neckbeard.jpg (150 KB, 762x568) Image search: [Google]
bitch cucks neckbeard.jpg
150 KB, 762x568
>>
>>52940336
>>52940349
>>52940371
FRIENDLY REMINDER TO USE TAB CHARACTERS SO THAT ANY AUTIST CAN HAVE IT HOW THEY WANT IT
>>
While we're on the topic of editors, am I the only person who finds Emacs' default paren behavior absolutely vomitous?

The cursor should NEVER snap back & forth, even if it's only visual. By comparison, (show-paren-mode 1) is the goat.
>>
>>52940369
The library already includes those, yet no reference to functions can be found. Or am I suppose to include that?
>>
>>52940394

too bad being merely good at programming is useless if you have any ambitions
>>
Reposting, since I posted at first in dead thread.

Dear /dpt/.

Do you know any software for easy GUI making in Python, like Lazarus? I mean the "drag and drop elements" ones.

I tried looking for one, only found Monkey Studio (which is abandoned project) and some "wxglade" one, in beta state.

I just want to learn Pascal in order to easy create GUI for applications.
>>
>>52940433
Reposting, since I answered you in a dead thread.

Probably PyQt with the Qt designer.
>>
>>52940415
Than it should magically work. You're most likely screwing up another part.
>>
>>52940433
Why not ncurses?
>>
>>52939666
>avg of two ints
That's pleb tier.

Post average of int arrays itt, I'll go first:
int avg(int* arr, int size)
{
double sum = 0;
for (int i = 0; i < size; ++i)
{
sum += ((double)arr[i])/size;
}
return (int)sum;
}
>>
>>52940433
>>52940452
There's also this:
https://kivy.org/
>>
>>52940358
You appear to be confusing tab width with indentation step.

Tab stops *are* every 8 columns. That's a universal constant, even if some software likes to pretend otherwise. The kind of people who make such things configurable probably also let you configure the value of pi, just because they can.

The problem with making tab stops configurable is that your code stops being formatted correctly the moment it leaves your PC in your mom's basement (professional programmers don't do this shit).
>>
>>52940453
What am I supposed to do then?

I tried adding the main header file to the project and it still didn't work. Am I meant to literally include every file within the library?

Is there no way to install it/turn it into a dll/lib? The github page only explains the UNIX way of installation, but I have no clue how would that correspond to windows.
>>
>>52940497
The guide shows you how to dynamically link the library using GCC. When you dynamically link it, you can just include the header files you want.
Apart from installing gentoo, use something like MinGW to build it.
>>
It's for a mod in a strange game engine.
>>52939804
It wouldn't make much sense without explaining the intricacies and limitations of said engine, otherwise I would.
>>52939870
>>52939932
The engine doesn't use radians but degrees, fixed point angles and byte angles inconsistently. It's a headache, but I'm sure it's not the part I'm getting wrong.
>>52940063
>If you want 0...1.0 to go to -45...45, then you need to multiply the angle range by the [0,1] value, then subtract 45.
Thanks, my current way is only trial-and-error'd up and I fully intend to make it cleaner and more efficient once it works. I'll use your code as a template.

I think my main problem is trying to scale a vertical range to an angle linearly without using cos and sin.
>>
>>52940469
 P
NOT
R
T
A
B
L
E


THE POWER OF C COMPELS YOU
>>
>>52940452

Forgive me, but I must be too green, since I couldnt properly install this PyQt or how to use it. Also, I checked Qt official site and they onyl had "Qt Creator", no "Designer". Where can I get this Designer instead?

Tutorials on PyQt site assume that I would know already Qt or simply instruct me to write code in C++ in Qt then run convering scripts.

>>52940454

Because the applications I might need to make would cover control and monitoring measurement stations and should be easy usable by everyone at insitutute, I cant make it text based.

>>52940478

But Kivy is not IDE.
>>
>>52940541
I thought about using MinGW to build the library, but don't understand what I'm supposed to use in this case.

The many tutorials I found on web talk about including keywords such as __declspec, but would that mean I have to do it for every function within the library?
>>
>>52939866
Check out CS50: Introduction to Computer Science on edx, it really helped me to understand how to program in the first place, the rest is just lots of reading after this
>>
>>52940631
Many people struggle to use pointing devices, and find text-based interfaces much more user-friendly.
>>
>>52940575
wow that looks like a sword c:
>>
>>52940469
x87 is comparatively expensive to normal integer math and your code doesn't need it.
int avg(int *arr, int size)
{
int sum = 0;
for (int i = 0; i < size; ++i)
sum += arr[i];
return sum / size;
}
>>
>>52940681
>c:
Use GNU/Linux, please, and stop promoting non-free software.
>>
>>52940355

that doesn't work
for (1,3) it returns 1.
>>
>>52940702
Yours is susceptible to integer overflow.
>>
>>52940655
__declspec won't help you with compiling.
>>
some autist asked for tutorials in codecaves in last thread

my reply: git gud
google
and git gud
>>
>>52940679

But in this case it would really be much more comfortable to avoid text-based interface.

Graphs displayed in real-time, with mouse controls, multiple text fields and other controls that would be easier to use that way.
>>
>>52940726
Yours is susceptible to loss of precision
Be ashamed
>>
>>52939875
that's just defining memory leaks away
>>
>>52940469

daily reminder that (double)0.10000000000000000 == (double)0.10000000000000000+0.00000000000000001
>>
>>52940721
Okay, I'll stop playing around.
int avg = math.sqrt(a*a + b*b);
>>
File: Java.png (17 KB, 484x402) Image search: [Google]
Java.png
17 KB, 484x402
>>52940774
Daily reminder that (100 == 100) != (1000 == 1000)
>>
>>52940784

for (1,3) that returns sqrt(1+9) = sqrt(10) = sqrt(4*2.5) = 2*sqrt(2.5) != 2
>>
>>52940469
(defun avg (arr)
(/ (reduce #'+ arr)
(length arr)))
>>
>>52940702
for (int i = 0; i < size; ++i)    //fill array with 2^31 - 1
arr[i] = INT_MAX;
avg(arr, 10); //your code shits itself


>>52940774
>>52940764
Reminder that the function is designed to return the average as an integer. An integer average will BY DEFINITION not be as precise as a floating point average for most sets of data.
>>
let average = Seq.average
>>
>>52940824
> Using the lifpy language
>>
int avg(int *arr, int size)
{
__int64 sum = 0;
for (int i = 0; i < size; ++i)
sum += arr[i];
return (int)(sum / size);
}
>>
>>52940830
>I am a retard
>>
daily reminder that "integer averagers" should kill themselves
>>
>>52940818
sqrt(2.5) comes out as 1 when you cast it to an int, so you get 2*1 = 2

But regardless, 2 is not the correct answer
>>
>>52940728
Then how do I make this work? I don't understand what needs to be done.
>>
int average(int a, int b)
{
int result;
std::cout << "Please calculate the average of " << a << " and " << b << '\n';
std::cin >> result;
std::cout << "Thank you for your assistance.";
return result;
}
>>
int avg(int* arr, int size)
{
float sum=0;
for(int i=0;i<size;i++)
{
sum+=(float)(arr[i])/size;
}
return (int)(sum);
}


easy.
>>
>>52940879
You need Wall and pedantic
>>
>>52940879
Read up on MinGW.
>>
>>52940875
>sqrt(2.5) comes out as 1 when you cast it to an int, so you get 2*1 = 2

Only when you simplify it, sqrt(10) ~ 3. even when cast to int.
>>
>>52940908
Yep, which is much closer to the actual mean of 3.16ish.
>>
File: 1440217291148.jpg (56 KB, 461x523) Image search: [Google]
1440217291148.jpg
56 KB, 461x523
>>52940872
>"Your FizzBuzz was excellent, we just need you to complete one final test before we can hire you, ok?"
>"Please write a function that will find the integer average of these integers."
>yfw
>>
>>52940864
>I posted something completely irrelevant and have no argument
>>
val epsilon = 0.01
def average(xs: List[Int]): Double = {
def iterate(lower: Double, upper: Double): Double = {
val guess = (upper + lower) / 2;
if (upper - lower < epsilon) guess
else {
val distance = xs.foldLeft(0d)((result, next) => result + (guess - next))
if (distance.signum > 0) iterate(lower, guess)
else iterate(guess, upper)
}
}

iterate(xs.min, xs.max)
}
>>
>>52940815
Daily reminder that only morons compare objects with the "==" operator.
>>
File: java2.png (17 KB, 384x298) Image search: [Google]
java2.png
17 KB, 384x298
>>52941108

Still doesn't work
>>
>>52940907
I don't understand what exactly I'm supposed to read up on.
>>
>>52940830
>//your code shits itself
And so does the C standard.
>>
>>52941161
moron, now you're assigning value
>>
>>52940890

This is the only correct solution.
Account for everything. Won't ever overflow.
>>
>>52941196
should i use === instead
>>
>>52941172
http://lmgtfy.com/?q=ming
>>
>>52941185
my avg() function did not. It printed the correct average: 2^31 -1.
>>
How does this make you feel?

cube_t *create_cube(unsigned x, unsigned y, unsigned z)
{
cube_t *ptr = malloc(sizeof(cube_t));
ptr->size.x = x;
ptr->size.y = y;
ptr->size.z = z;
unsigned i, j; /* make 3D cube */
ptr->cube = malloc(sizeof(unsigned char **) * x);
for (i = 0; i < x; i++)
ptr->cube[i] = malloc(sizeof(unsigned char *) * y);
for (i = 0; i < x; i++)
for (j = 0; j < y; j++)
ptr->cube[i][j] = malloc(sizeof(unsigned char) * z);
return ptr;
}
>>
>>52941202
use .equals() you donut
>>
>>52941202
isequal or whatever
>>
>>52941161
http://www.tutorialspoint.com/java/number_equals.htm
>>
>>52940815
Holy shit, Java, what are you doing?
>>
>>52941213
Glad that I use a language that supports things like map and filter
>>
>>52941172
Are you smart enough to breathe?
>>
>>52941213
I feel fine, thanks.
Yes, I know you should be using one malloc() for the whole region, but why the fuck are you using C anyways?
>>
>>52941214
>>52941217
Then what is == for in Java?
>>
>>52941223
The == operator tests if the references are equivalent. I don't know why the first one was true but it shouldn't be.
In java you use the .equals method to test for equivalence of the data inside the object.
>>
File: fsharp code quotation.png (3 KB, 278x41) Image search: [Google]
fsharp code quotation.png
3 KB, 278x41
How do other languages even compete?
>>
>>52941251
>I don't know why the first one was true but it shouldn't be.
Yes, and this is a problem.

Why are you defending this undefined behavior?
>>
>>52941246
>>52941251
The real question is, why isn't "int" an object?
>>
I would like main() to print 12 35. How should I call the functions rainy, day and women?

void rainy ( int* x ) {
* x += 11;
}
void day ( int& x , int y ) {
x = x / y ;
y = y / x ;
}
void women ( int x , int * y ){
cout << * y << " " << x ;
}
int main () {
int bob = 1 , dylan = 420;
rainy ( );
day ( , );
women ( , );
}
>>
>>52940631
>>52940433

Anybody else?

Or I should just man up and learn Pascal?

I just hate programming, so I dont like the idea of learning yet another language.
>>
>>52941251
It's true because integers between -128 and 127 are cached and so have the same reference

read as: whether == in java does reference or value equality depends on the value
>>
File: 6jlrUMX.png (5 KB, 314x133) Image search: [Google]
6jlrUMX.png
5 KB, 314x133
>>52940815
C# in pic
>>
>>52941273
It's an object AND a built in

Because Java is a shitty fucking language
>>
>>52941290
r u avin a giggle
>>
>>52941281
Qt Designer is included with Qt Creator. I haven't used it much, but I know that Designer is a "mode" of Qt Creator. If you have Qt Creator, you have Qt Designer.
>>
>>52941301
nope it's true

there's a way around it

Integer a100 = new Integer(100);

it's very consise
>>
>>52941204
>>52941233
I really don't understand what I'm meant to extrapolate from this.

The first result on google links me to a tutorial explaining how to create an executable file, which I doubt I need in this situation.

The how-to instructions on making dlls require .def files which I don't have in this library.

What exactly should I be focusing on?
>>
What do you all think of Visual Basic?
I would argue that it's great for people trying to get into programming desu.
>>
>>52941273
Java has primitives for when you don't need the overhead of an object. "int"
Integers are objects with more capability.
>>
>>52941290
it's always value equality. in the case of objects it's the value of the reference. in java you are always dealing with values.

http://javadude.com/articles/passbyvalue.htm
>>
>>52941251
>I don't know why the first one was true but it shouldn't be.
>>52941270
It's called interning, look it up. That said it's stupid for == to suddenly change its behaviour for some numbers, but that's java for you.

>>52941273
Shitty language design.
>>
>>52941298
How can C# even compete when it can't even average two integers?

>>52941268
>>
>>52940815
>>52941298
int is not equal as integer
>>
>>52941317
>What exactly should I be focusing on?
Getting that shit to build. We already gave you the solution by using MinGW.
>>
>>52941299
Integer is an object, int is a special primitive piece of shit Java is trash (making it an int for performance reasons made sense maybe 50 years ago but it really doesn't make sense now. C# proves this, I can fairly easily make a language that allows unboxed ints to be treated as objects. Java is old and shitty.)
>>
>>52941199
>>i++
>>not implementing Kahan summation
heh, nice try kiddo. This is the only logical solution to the problem:
int avg(int* arr, int size)
{
double sum = 0;
double a, b, c;
c = 0;
for (int i = 0; i < size; ++i)
{
a = ((double)arr[i])/size - c;
b = sum + a;
c = (b - sum) - a;
sum = b;
}
return sum;
}
>>
hey faggots, stop replying to the troll

>>52939666

>>52939666

>>52939666
>>
>>52941273
"int" is a primitive but >>52941161 is using "Integer" which is an object
>>
>>52941328

>it always does value equality
>of the values of the references

JAVA FAGS STOP SAYING THIS YOU RETARDS
>>
>>52941279
rainy(bob);
day(dylan, bob);
women(bob, dylan);

You figure out where the * and & go.
>>
>>52940815
kill yourself and see >>52939666

>>52941223
>>52941270
see >>52941315

>>52941364
kill yourself retard

it's explained perfectly well in the link
>>
>>52941326
>>52941363
>Java has primitives for when you don't need the overhead of an object. "int"
>"int" is a primitive but >>52941161# is using "Integer" which is an object
Let me reiterate, C# and many other languages support unboxed integer type first class and treats it just like every other type instead of making stupid (and outdated) exceptions like Java does.
>>
>>52941273
why the fuck should it be an object? an int is an int, you don't need to sprinkle magic properties for it. typical fucktarded Cshart
>>
>>52941381
Fucking moron

1)

Integer a100 = new Integer(100);

is shitty language design

2) Equality of the references. REFERENCE EQUALITY.
>>
>>52941383
how does it achieve that without a performance hit?
I'm not arguing I'm just telling people what i learned from my java books.
>>
>>52941279
Sure:
rainy(&bob);
day(bob, dylan = 12);
women(35, &dylan);
>>
>>52941406
>is shitty language design
that's your opinion. and why are you arguing about this?

kill yourself retard
>>
>>52941411
C# has about the same performance as java, despite having "low level" features for the "performance conscious" developers.
>>
>>52941421
>that's your opinion
It's also true

>b-but why are you arguing about this anyway??
/dpt/ - daily programming thread
>>
>>52941443
/dpt/ - daily spergian nitpicking about subjective things that don't even matter
>>
>>52941461
import System.Java.JavaSystem.Java.Apologetics.Deflection;

class class X class { deflect(); }
>>
>>52941406
>2) Equality of the references. REFERENCE EQUALITY.
Except it it's checking the address and not the content.
>>
>>52941479
sorry

SystemDeflection deflect = new SystemDeflection(SystemDeflection.Deflect);


>>52941490
that's called
REFERENCE
EQUALITY
>>
>>52941479
why do you think >>52939666 was made? you're a fucking sad retard if you get your panties in a bunch over this complete non-issue.
>>
>>52941479
>class class X class { deflect(); }
"class" is a keyword nigga. You can't name your class "class"
>>
>>52941435

That most people don't use them is not an argument for not having them.
>>
>>52941512
class ((100==100)==(1000==1000)) { deflect() }
>>
>>52941500
>that's called
>REFERENCE
>EQUALITY

Which, as we've discussed before, is boneheaded default behavior in a language where memory management is handled automagically.

A superior option would be to have == call .equals() and have .referenceEquals() to check ref equality.
>>
>>52941411
Why is overhead necessary for objects?
Let's say you have a class A with a method foo()
class A {
public void foo () { this.... }
}


Then you have an object 'a' of type A and you want to call its foo() method.
A a = ...;
a.foo();


Because we know that 'a' is of type A, we know exactly where the foo() method is located and to make the 'a.foo()' call. It would be equivalent to it being implemented like
class A {
public static void foo (A this) {
this....
}
}
A a = ...;
A.foo(a);


Now we know that methods (which are what make objects, objects) have no real overhead in determining where their methods are. Then, stuff like '+' could be implemented as a "method" and inlined without any difference in performance.
I'm not great at explaining this but the only reason for there to be overhead is in generic programming, In this case either
> do what C++ does; re-generate code for each instance of a generic method. No time overhead, but potential bloat
> do what Java currently does; box it. But a sufficiently not-retarded type system should be able to know hide boxing from you instead of introducing "Integer objects"
>>
>>52941518
having them doesn't support the argument that C# is cleaner, simpler, more elegant and easier to learn than java
>>
>>52941314

Thats god to know, but I still dont understand how to properly install PyQt. When I downloaded it via repository, I just got folder with various scripts.
>>
>>52941549

No, the reasons that C# is simpler, more elegant, and easier to learn are not intrinsically related to performance.
>>
>>52941544
I agree

or some kind of =&= operator
>>
>>52941569
>>52941544
k tards
>>
>>52941544
>>52941569
Universal equality is a terrible idea and should never have been done.
>>
>>52941346
I don't understand what you guys mean by build.
When I try mingw on other files, it literally creates the executable. How is that going to help me?
>>
>>52941582

You're as bad as a python user.
>>
== checks for the specific object, not just an object that happens to have the same state

it's perfectly fine
>>
>>52941545
Your explanation only works when you don't have to worry about overridden methods.
>>
File: cc0.jpg (5 KB, 200x200) Image search: [Google]
cc0.jpg
5 KB, 200x200
>>52941533
Here's your reply
>>
Triggering Java programmers:

What do you use more, == or .equals( _ ) ?
>>
>>52941559
https://www.riverbankcomputing.com/software/pyqt/download
http://zetcode.com/gui/pyqt4/
>>
>>52941601
>it's perfectly fine

Thanks for your input, Gosling.
>>
>>52941616
i use neither because i'm not a faggot
>>
>>52941590
If only operators were actually methods, then not only would this be a solved problem (some types couldn't be compared for equality), but we'd actually be able to overload the operators.
Too bad Java is shit.

I like the Integer == Integer problem because it shows three of my biggest language-design qualms of Java: primitives, no-operator-overloading, magic syntax and conversions (Integer + Integer, Integer x = 123)
>>
only fucking Cshart codemonkeys use things like == or .equals( _ ). most algorithms don't need it
>>
>>52941606
If you had to explicitly specify which methods can be overloaded (don't people already do this using docstrings in Java?) then it wouldn't be a problem.
>>
File: mount stupid.jpg (23 KB, 600x338) Image search: [Google]
mount stupid.jpg
23 KB, 600x338
>>52941650
kill yourself you fucking retard you don't even know what you're talking about. why don't you make your own language if you think you know better than the designers of the #1 programming language in the world
>>
>>52941631
>>52941652

>fucking people checking if two things are equal, fucking retards
>why don't you fucking use the standard java tm enterprise edition idiomatic patterned design pattern decorator
> (a > b-1) && (a < b + 1)
>>
>>52941652
>Cshart codemonkeys

Oh look, it's you again. Are you going to poopoo in your pants about properties again?
>>
>>52941213
>cube_t *ptr = malloc(sizeof(cube_t));
>ptr->cube = malloc(sizeof(unsigned char **) * x);
>ptr->cube[i] = malloc(sizeof(unsigned char *) * y);
>ptr->cube[i][j] = malloc(sizeof(unsigned char) * z);
4 levels of indirection, you're killing your poor cpu's caches, prediction and pipeline.
I would make the structure like this:
typedef struct {
unsigned int sizex, sizey, sizez;
unsigned char cube[];
} cube_t;

cube_t *c = malloc(sizeof *c + x*y*z);

making use of C99 flexible array member and just a single allocation.
>>
>>52941672
>why don't you make your own language
That's exactly what I'm doing
>>
>>52941616
>What do you use more, == or .equals( _ ) ?
It's not either or, you use them in completely different situations.
>>
>>52941683
how about you give an example of an interesting situation where you check if two objects are equal.
>>
>>52941665
You can declare methods 'final', which prevents them from being overridden.

Modern Java VMs are probably quite good at detecting and optimizing methods that could be overridden but aren't.
>>
>>52941627

That tutorial tells me to code GUI out of elements from provided libraries, instead of using that QT Designer for that, but thanks for help.
>>
>keep feeding trolls after being warned
>keep talking the same retarded topics
>half of the thread wasted
you guys are truly obsessive...
>>
>>52941699
I know. I asked which you used more.
>>
>>52941650
How about you go research on why instead of talk shit about things you clearly know nothing of.
>>
>>52941733
it's the 'tism
>>
>>52939666
why is SICP on there?

also, wicked trips, satan :^)
>>
>>52941740
You are more likely to compare primitives than objects in you're code tbqh senpai
>>
>>52941775
Which do you use more for objects
>>
>>52941699
i forgot what the difference was fugg
>>
>>52941807
you'd use != null or == null or maybe object1 == object2

string1.equals(string2) maybe but only for fizzbuzz tier newb programs or for some sort of codemonkey CRUDshit
>>
File: 5bc.png (45 KB, 200x200) Image search: [Google]
5bc.png
45 KB, 200x200
>>52941807
Well considering "==" only checks if both objects point to the same address in memory, I'd have to go with equals()
>>
>>52941812
see >>52941601
>>
I suppose there's no way to set the sharing mode for a file with C's file api like with winapi's file api, is it? I want to open a file(config file) at startup, keep the handle during runtime and disallow editing/deleting it without the handle(outside the application)
>>
>>52941863
>>52941844

thx that's what I kind of thought
>>
>>52941601
also, objects contain and manage their own state. you should normally never have to "inspect" the entire state of an object by using .equals()
>>
>>52941345
int is an alias for System.Int32, faggot
>>
>>52941812
see>>52941857
>>
>>52941857
So wouldn't it be better if their behaviour were switched?
>>
>>52941751
>"I left out operator overloading as a fairly personal choice because I had seen too many people abuse it in C++."
>James Gosling.
>>
>>52941941
see >>52941918

>this breaks the encapsulation
>>
>>52941672
holy kuk
do you really think the fact that a language is the most popular means the creators had good taste or even knew what they were doing?

java is a shitpile, and the time it takes to write a better language than it can be measured in hours.
>>
>>52941953
>"there is no benefit in never having to worry about what any operator in any code base is doing"
>retarded namefag
>>
>>52941889
http://stackoverflow.com/questions/7573282/how-to-lock-files-using-fopen
>>
>>52941970
>le java is bad meme
epic
>>
>>52941975
You could name your function something retarded and have no clue what it does.
If your developers are operator overloading all over the place, it's their fucking fault. Equivalent to naming variables/methods 1-3 character abbreviations. Basic operators should be overloaded for basic things.
>>
>>52941989
> le calling something a meme cause you don't have anything to say meme
>>
>>52941975

I like to make it so my operator overloads have ridiculous and non-obvious side effects.
>>
>>52939734
uranus
Thread replies: 255
Thread images: 21

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.