[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: 24
old thread: >>51760395

What are you working on, /g/?
>>
r8 my hello world /dpt/
public class JTestbuild
{
public static void main(String[] args)
{
int i = 0;
while(i < 14)
{
switch(i)
{
case(0):
System.out.print("H");
break;
case(1):
System.out.print("e");
break;
case(2):
System.out.print("l");
break;
case(3):
System.out.print("l");
break;
case(4):
System.out.print("o");
break;
case(5):
System.out.print(",");
break;
case(6):
System.out.print(" ");
break;
case(7):
System.out.print("w");
break;
case(8):
System.out.print("o");
break;
case(9):
System.out.print("r");
break;
case(10):
System.out.print("l");
break;
case(11):
System.out.print("d");
break;
case(12):
System.out.print("!");
break;
case(13):
System.out.print("\n");
break;
}
++i;
}
}
}
>>
>>51764094
I'm reading C++ Primer after reading C Primer. I fell in love.
>>
>>51764094
PRE BUMP LIMIT
FAKE THREAD
>>
Homework :-)

>i suck
>>
Rate my strrev implementation!
void strrev(char *arr)
{
/* reverses char array in place */
unsigned len = strlen(arr);
unsigned i = len - 1;
unsigned j = 0;
char c;
while (i > j)
{
c = *(arr+i);
*(arr+i) = *(arr+j);
*(arr+j) = c;
j++;
i--;
}
}
>>
>>51764119
why ++i and not i++?

(just curious)
>>
Which of the following statements are true in Java?

A. Each event class has a corresponding listener interface.
B. The listener object's class must implement the corresponding event-listener interface.
C. A source may have exactly one listener.
D. The listener object must be registered by the source object.
E. A listener may listen for exactly one source.
>>
>>51764125
I tried C++ primer and wasn't a fan, but at the time I was pretty impatient. I'm reading Absolute C++ now. How do you like C++ Primer?
>>
Working on an OS. neetcode went down. Think I'll host a git instance on a hardened BSD. probably just use cgit or gogs on FreeBSD or OpenBSD. What advice do ya'll have as far as the hardening goes?
>>
>>51764147
ABD?
>>
>>51764135
Go to bed, it's soon 3AM in Norway
>>
>>51764160
just use github you dumb shit
>>
how do I keep more than one workspace in eclipse?

I don't want to have lots of projects in my explorer tab.
>>
>>51764189
No thanks. Not nearly as full of a learning experience or as exciting
>>
>>51764145
Consistency with extruded for loop common syntax.
>>
>>51764145
In this context, it makes no difference. It used to be potentially faster to ++i since it wouldn't require a temp var, but any modern (post '90) compiler should optimize it out.
>>
>>51764119
import java.util.ArrayList;
public class HelloWorldg {

public static void main(String[] args)
{

int i = 0;

ArrayList<String>faggotlist = new ArrayList<>();
while(i < 14)
{
switch(i)
{
case(0):
faggotlist.add("H");
break;
case(1):
faggotlist.add("e");
break;
case(2):
faggotlist.add("l");

break;
case(3):
faggotlist.add("l");
break;
case(4):
faggotlist.add("o");
break;
case(5):
faggotlist.add(",");
break;
case(6):
faggotlist.add(" ");
break;
case(7):
faggotlist.add("w");
break;
case(8):
faggotlist.add("o");
break;
case(9):
faggotlist.add("r");
break;
case(10):
faggotlist.add("l");
break;
case(11):
faggotlist.add("d");
break;
case(12):
faggotlist.add("!");
break;
case(13):
faggotlist.add("\n");
break;
}
i++;
}
System.out.println(faggotlist);
}
}
>>
>>51764269
10/10 absolutely enterprise

I especially liked the g you put at the end of the HelloWorldg class, indicating it's global
>>
>>51764143
mine is better
strrev = foldl (flip (:)) []
>>
>>51764295
that's not an implementation
>>
>>51764307
why not?
>>
>>51764295
Did you steal that from me? ;^)
>>
God, programming Java in Emacs is like playing Concentration.
public class JTestbuild
{
public static void main(String[] args)
{
int i = 0;
for(;;)
{
if(i==0){
System.out.print("H");
}
if(i==1){
System.out.print("e");
}
if(i==2){
System.out.print("l");
}
if(i==3){
System.out.print("l");
}
if(i==4){
System.out.print("o");
}
if(i==5){
System.out.print(",");
}
if(i==6){
System.out.print(" ");
}
if(i==7){
System.out.print("w");
}
if(i==8){
System.out.print("o");
}
if(i==9){
System.out.print("r");
}
if(i==10){
System.out.print("l");
}
if(i==11){
System.out.print("d");
}
if(i==12){
System.out.print("!");
}
if(i==13){
System.out.print("\n");
}
if(i==14){
break;
}
++i;
}
}
}
>>
>>51764316
you just used someone else's implementation of a string reversing function.
>>
>>51764325
Wait, but in Java does int 14 = int 14?
I know Integer 1000 != Integer 1000
>>
File: 1447640801229.jpg (86 KB, 1280x720) Image search: [Google]
1447640801229.jpg
86 KB, 1280x720
>>51764325
>>
>>51764340
>javafags literally do not understand why this is bad
>>
>>51764319
n-no
>>51764340
It is mine
and just to be pedantic, if I wasn't the author it would still be an implementation
>>
>>51764346
int is a type, Integer is a class. Unlike C#, in Java the two concepts are distinct.
In Java, classes do not have 'values', only properties and other associated data. Variables, on the other hand, do have values, that can be compared to other values.
>>
File: Winniethepooh.png (104 KB, 285x400) Image search: [Google]
Winniethepooh.png
104 KB, 285x400
Nothing because I spent all day programming at work. That's right /g/, I did it. I'm paid to program and I don't have a degree. I have never felt more fulfilled.
>>
>>51764370
Why is Java so shit?
Why does 1000 != 1000 when 100 = 100?
>>
>>51764340
No, 'flip' and 'foldl' do not reverse strings.

myfoldl f z [] = z
myfoldl f z (x:xs) = myfoldl f (f z x) xs
myflip f x y = f y x

strrev = myfoldl (myflip (:)) ""


>>51764351
Oh ok I was blowing some fa/g/s' minds with it a week ago and had to explain how it worked

>>51764370
This is why Java
1) is not actually OOP
2) is actaully shit
3) is designed badly
4) is way behind in terms of modern programming language design and implementation
>>
>half-baked primitive wrappers
enterprise quality design :^)
>>
Is /g/ literally filled with all these morons who can't do a simple print? KEK

class z
{
public static void main(String[] args) {
System.out.print("Hello World!"); }
}


>>>/out/
>>
>>51764351
>It is mine
import fizzbuzz
>>
>>51764383
i can't even read that
>>
To all of you neetco.de users who were complaining in the other thread about the site going down, just remember that gitgud.io still exists, and is more or less the exact same thing

>But Vivian James on the front page
Who cares? GG isn't the anti-christ, and a decent host for code is a decent host for code.
>>
>>51764094

good to see new thread has trap in op as well.
>>
>>51764383
>>51764395
fine
this is the cleanest, if not the most efficient
strrev (x:xs) = (rev xs) ++ x
>>
auto ref rev(T)(auto ref T x)
{
return x[$-1] ~ rev(x[0..$-2]);
}
>>
>>51764379
idk java's just a shit language
eg:
int i = 1;
if(i==1){
function():
} //this code block runs normally

if(i){
function();
} //compile error
[/code[
>>
>>51764414
i'd rather just use github desu
>>
>>51764424
forgot
srrev x = x
>>
>>51764307
Yours isn't an implementation, you're clearly using strlen() which you DID NOT in fact write yourself. You might as well import the entire procedure.

>>51764411
Then get the fuck out and come back when you've learned a single FP language?

>>51764424
>not eliminating variables
ISHYGDDT

You still didn't write (++) yourself.
>>
>>51764431
not specific to strings
0/10
>>
>>51764449
neither did you in >>51764143
>>
>>51764414
wtf does neetco.de download to your PC?
>>
>>51764483
virus.exe
>>
>>51764433
How is this a bad thing?
Java literally has dozens of other reasons that it's bad and this isn't even close to one of them. In fact, I'd prefer languages that check types and don't perform weak implicit casts.
>>
>>51764487
fuck you serious? i deleted it right away, running a mbytes scan now.
>>
>>51764449
>Yours isn't an implementation, you're clearly using strlen() which you DID NOT in fact write yourself. You might as well import the entire procedure.

What if I wrote my own strlen?
It's stupidly easy to write.
size_t strlen(const char *s)
{
char c;
size_t i = 0;
while (c != '\0')
c = *(s + i++);
return i;
}
>>
Working w/ .sql. So right now, I have a table w/ a name, username, and password. The file I'm importing is a .csv file w/ the name, username, and password.

Is there a way to take a file and hash it BEFORE I import it? Basically, I want my password to be stored as
$2y$10$ZTNlZjZmMWVkMjMxOWE3MOsaMyvDRUPJSR5VWJ.QwG0zd4rkdLaMu
instead of
 secret 


Can I do this? Is there a program that takes a .csv file, and applies blowfish of a specified hash of say, $2y$10$, and a specified length, of say 22?
>>
>>51764394

I'm pretty sure it's not so much that they can't do it, so much as they want to make the process as complicated as possible.

>>51764435

Then go do just that. There's nothing wrong with Github or Bitbucket for the majority of projects. The reason people wanted to use Neetco.de was because they were against Github in general, likely due to the code of conduct, and the fact that they took down C+=. People who want an alternative git repository aren't limited to just one Gitlab running in a guy's basement.

>>51764483

Wasn't aware Needco.de was putting crap on peoples' PCs. Gitgud doesn't do that though.
>>
>>51764489
It isn't an implicit cast, it's basic computational logic. 1 is on, 0 is off - but not in Java, where 1 is a compiler error.
>>
>>51764501
You didn't implement i++, or *(const char*)
>>
>>51764094
IGNORE TRANNY THREADS

REPORT TRANNY POSTERS
>>
>>51764520
fuck off
>>
>>51764510
https://github.com/ErisBlastar/cplusequality
>>
>>51764433
java is literally retarded:

"The next time you come across a situation where two Integers defined with equal values fail an equivalency (==) test, remember this tip. Suppose you have two integers defined as follows:

Integer i1 = 128
Integer i2 = 128
If you then execute the test (i1 == i2), the returned result is false. The reason is that the JVM maintains a pool of Integer values (similar to the one it maintains for Strings). But the pool contains only integers from -128 to 127. Creating any Integer in that range results in Java assigning those Integers from the pool, so the equivalency test works. However, for values greater than 127 and less than -128), the pool does not come into play, so the two assignments create different objects, which then fail the equivalency test and return false."
>>
REAL THREAD

>>51764566
>>
>>51764580
kill yourself
>>
File: 1441740255078.gif (1 MB, 392x400) Image search: [Google]
1441740255078.gif
1 MB, 392x400
>>51764540
get fucking rekt nigger
>>
>>51764516
No, Java distinguishes types and requires the condition in an 'if' to be of type 'bool'. Type checks are actually useful. For instance, is '2' on or off? We don't really know and end up with behavior that has to be defined by a very lengthy standardization and has weird side effects like in "falseyness" in JavaScript. Only accepting bools ensures that you it behaves how you expect because true/false are obviously true/false.
In C++, 1 has to be converted implicitly to type bool but this doesn't introduce any overhead.
In C, there literally isn't a concept of bool and that's just because C is so fucking old.

Look into static typing a little bit maybe.
>>
>>51764501
size_t strlen(const char* string)
{
size_t result = 0;
while ( string[++result] );

return result;
}

meh.
>>
>>51764543
https://github.com/ErisBlastar/cplusequality/blob/master/src/fixCPP.Xe
>>
>>51764508
Also, I have a function written
function password_encrypt($password) {
$hash_format = "$2y$10$"; // Use Blowfish with a "cost" of 10
$salt_length = 22; // Blowfish salts should be 22-characters or more
$salt = generate_salt($salt_length);
$format_and_salt = $hash_format . $salt;
$hash = crypt($password, $format_and_salt);
return $hash;
}


I just don't know how to apply it to a column in a table
>>
>>51764580
Was it autism?
>>
>>51764543
>Instead of "running" a program, which implies thin privilege and pressure to "work out", programs are "given birth". After birth, a program rolls for a 40% chance of executing literally as the code is written, 40% of being "psychoanalytically incompatible", and 40% of executing by a metaphorical epistemology the order of the functions found in main().

im in tears
>>
Good morning
>>
>>51764094
Name of Anime?
>>
>>51764600
>>51764593
some of the other files are good too
>>
>>51764589
size_t strlen (const char* s) {
const char* s2 = s;
while (*s++) ;
return s2 - s;
}
>>
>>51764501
first of all your code is broken... what happens when 'c' is initialized to '\0'?

size_t strlen(const char* c)
{
size_t sz = 0;
while(*c++)
sz++;
return sz;
}


this is how an autist (aka anyone who is going to actually implement cstdlib) would write it.
>>
>>51764528
>tranny
>implying cross dressing doesn't improve your programming skills
>>
>>51764617
thanks mate! I love it!
>>
>>51764622
Doping is illegal, so is cross dressing
>>
>>51764433
a) it's a way of forcing people to idiot-proof their code
b) it's less liberal with typecasts than C and its offspings are
>>
>>51764573
Or you could just properly compare reference types using .equals() or .compareTo().
>>
>>51764617
wait shouldn't it be s - s2?
>>
>>51764617
this is autism
>>
>>51764143
Eww postfix.
>>
>>51764640
That's not idiot proofing your code, that's trying to idiot proof your programming language.
>>
>>51764644
Yes. I fucked up. It should be s2++ really.

>>51764631
>>51764646
<3
>>
>>51764656
Yeah I figured it out. Please tell me this isn't GNU.
>>
>>51764589
your code is fucking broken too. jesus christ you guys suck asshole at writing c...

pre-increment will return the incremented value, so your code never ends up checking string[0]
>>
File: Screenshot_2015-12-08_20-22-19.png (99 KB, 1602x907) Image search: [Google]
Screenshot_2015-12-08_20-22-19.png
99 KB, 1602x907
https://www.codeeval.com/open_challenges/8/
Completed this challenge using the wonderful thing we call the stack
>tfw CodeEval completely disregarded the ternary operator on line 41 and just printed spaces where there should have been newlines

Buncha faggots
>>
>>51764649
Well, yeah, that too.
>>
File: 1449611751881.png (1 MB, 1702x2471) Image search: [Google]
1449611751881.png
1 MB, 1702x2471
>>51764635
It's a natural enhancement, sort of like training at higher altitudes.
>>
>>51764245
Some compilers(whatever fucking offbrand c++ compiler my uni made us use I'm looking at you) deliberately do not optimise this out. Who knows why, maybe legacy support or something.
>>
File: 1449036901033.jpg (28 KB, 418x396) Image search: [Google]
1449036901033.jpg
28 KB, 418x396
>>51764528

>what is a trap

newfag detected you fucking idiot
>>
>>51764672
http://www.stdlib.net/~colmmacc/strlen.c.html

If you ignore the last 100 or so lines of code, yes, it GNU essentially does it this way.
>>
>>51764681
I didn't think of that. thank you for your insight!
>>
So is the CS scene filled with weebs or is /g/ an exception?
>>
>>51764686
Are you using makefiles or how do you compile from Sublime?
>>
can you freelance coding?

as in working on your leisure time with no having a contract?
>>
>>51764743
Can an Indian be a weeb?
>>
>>51764772
yes
i know a ton
>>
>>51764772
Do they crossdress while they code?
>>
Making pong with Lua and Love2D. Hope to be able to have multiple players at the same time, i.e 3 paddles, 4, 5, all the way to eight. Has only 2 player "functionality". Call er n-pong.
>>
File: this thread.jpg (350 KB, 1280x639) Image search: [Google]
this thread.jpg
350 KB, 1280x639
>>
>>51764788

If they don't they arent qts and are shit at it.

post pics
>>
>>51764828
i dont care how gay u are, indian traps are the most disgusting thing in the world and you know it
>>
>>51764846
>not wanting the feminine monobrow
>>
>>51764806
who is this cum plum
>>
>>51764743
Go look at the number of anime avatars working on video oriented projects like mpv.
There's plenty of weebs here.
>>
>>51764806
because he signed a contract with the student council that they'll pay off his debt in exchange for being their crossdressing dog
>>
File: 1439691356396.jpg (12 KB, 225x225) Image search: [Google]
1439691356396.jpg
12 KB, 225x225
>>51764888
>>
/dpt/ working on my game, need inspiration for a simple checkpoint system,
should I just make an enum and serialize it to be loaded in next program start?
this might be stupid but is there a way to save variables without creating a file to store them?
c++
>>
>>51764772
>Indians
>CS
Microsoft & Java certification =/= CS
>>
>>51764325
More like playing concentration camp.
>>
>>51764846

never actually seen one
>>
>>51764746
I just open terminal and use clang
>>
File: agdg in a nuttshell.png (64 KB, 914x800) Image search: [Google]
agdg in a nuttshell.png
64 KB, 914x800
>>
>>51764806
>he downloaded himegoto
>he knows enough about the mkv format to add his own subs
stop pretending you're not a degenerate
>>
>>51764932
> enum and serialize it
> save variables without creating a file

Do you have any idea what you are doing?
>>
>>51765019
the guy with his dick out should be wearing a skirt
>>
>>51765034
What is a degenerate and how are you not one?
>>
File: 1449382093117.jpg (21 KB, 400x654) Image search: [Google]
1449382093117.jpg
21 KB, 400x654
>>51765034
>>51764609 here

Thanks for indirectly answering my question.
>>
>>51765075
Make sure to read the manga when you're done.
the anime was too short and cheap.
>>
>>51765048
all i know is i want to save a single variable which will probably be of type struct/enum that simply states what checkpoint the player is at, in something that isn't a plainly readable/alterable text file
>>
>>51764686
nice massive leaks toolbag

guess it was worth looking like an elite C hacker
>>
>>51765114
just encrypt the file
or just encode it
>>
>>51765114
>in something that isn't a plainly readable/alterable text file
Why care?
>>
File: 1446452437308.gif (81 KB, 182x249) Image search: [Google]
1446452437308.gif
81 KB, 182x249
>>51764647
This. Ew to be honest family.
>>
>>51765117
Donde?
>>
>>51765124
because it seems lazy to save progress in an alterable text file people can just edit to get to the end
>>51765120
could you offer some std library class/function examples i could use to achieve this
(don't need to write the whole thing just some names of what to use)
>>
>>51765131
>using the keions to shitpost
End yourself.
>>
>>51765133
nevermind, didn't see the free at 42.

you're still an idiot.
>>
>>51765152
to encode, just literally write any function that maps the data one to one

to encrypt, just use any standard encryption algorithm like MD5 or SHA1, have a hardcoded key
>>
>>51765168
y-you too
>>
File: 1448361698562.png (669 KB, 674x614) Image search: [Google]
1448361698562.png
669 KB, 674x614
>>51765172
>standard encryption algorithm like MD5
>>
>>51765152
Is there any benefit to completing the game? A cash reward, perhaps? No? Then why would it matter if someone can skip straight to the end?
>>
>>51765172
> encryption algorithm like MD5 or SHA1

7/10
>>
>>51765183
>>51765189
It's for a fucking game that he doesn't want people cheating in

He's not storing fucking launch codes
>>
>>51765178
just as a note though you really don't want to have an api that randomly mallocs shit everywhere and expects the client to call free themselves
>>
>>51765197
I can't tell if you're trolling or not, you've earned your reply. 9/10
>>
>>51764706
Most compilers only optimise if you request optimisation.

For classes which override operator++, the compiler has to invoke the correct one. The construction of a temporary may get optimised out if it isn't actually used, but only if it doesn't have other side effects (and if the compiler can actually determine that this is the case).
>>
>>51765197
>He's not storing fucking launch codes

oh man this tickled me pretty good, and thanks for the advice,
shit if they go through the effort of 'cracking' the encryption they can just have the ending i suppose
>>
File: lamb-clipart-lamb2.gif (4 KB, 202x179) Image search: [Google]
lamb-clipart-lamb2.gif
4 KB, 202x179
Thank Christ Java supports lambda expressions now.

i love my lambies.
>>
>>51765206
I'll keep that in mind
>>
>>51765114
you could use the registry, as Gates intended.
>>
>>51765210
He just has to hash every possible checkpoint value to check, it's not that bad
>>
>>51765228
Everyone is crystal clear that MD5 and SHA1 aren't encryption algorithms right?
>>
I have a month to do any project I want. It's going to be in C++ regardless.

Anyone have any ideas they wouldn't mind throwing out? I'm at a loss.
I can do graphics and interaction, or something CLI but that is less impressive to the non-autist. I would rather not learn Qt.

Any ideas?
>>
>>51765233
Honestly, getting by with interfaces and anonymous classes was pretty clever.
>>
>>51765259
Calculator
LMC
>>
>>51765178

on your knees
>>
>>51765257
No, has hyou got the answer?
>>
>>51765233
hi gtp
i am programming noob
what is every the point of using a lambda expression?
thanks,
>>
>>51765247
is this a joke or a viable solution
>>
>>51765271
I have a whole month. Maybe I should add that I've been programming for almost two years. Something related to a virtual machine could be cool, though.
>>
>>51765290
You => Dead
>>
>>51765282
That doesn't even make sense.

>>51765291
Viable solution
>>
>>51765291
sadly, both
>>
>>51765315
He hasn't got any clue what you're talking about
Why're you so salty?
>>
>>51765290
>what is every the point of using a lambda expression?

You can replace 110 lines of garbage with ->
>>
>>51765259
man QT is a goddamn pleasure to use and you should be grateful that you have the option of using it.
>>
>>51765291
Yes.
>>
>agdg is making fun of us again
>>
>>51765341
so that will allow you to replace the usual 110 lines of checking if two Integers are equal in java with just one?!?!? but how...
>>
>>51765342
I've heard language from both sides, but my reason for not wanting to use it in this project is because I've just refreshed myself on C++ and the only point of this project is to have something in C++ on my github. Learning Qt would take more time that I would rather spend building a more impressive project. Also, I haven't any idea for some desktop application with a traditional GUI.
>>
File: solution.png (14 KB, 851x330) Image search: [Google]
solution.png
14 KB, 851x330
>>51765377
>>
>>51765364
You deserve it.
>>
>>51765377
private static Image SelectBestAvailableWaifuImage(IEnumerable<IWaifu> availableWaifus)
{
var waifu = availableWaifus.SingleOrDefault(w => w.Name.Equals("Kobeni", StringComparison.VariantIgnoreCase).Select(w => w.Image);

if(waifu == null)
{
throw new BestWaifuNotAvailableException();
}

return waifu;
}
>>
>>51765446
Forgot the null prop operator on line 3. Shame upon my family.
>>
>>51765463
seppuku();
>>
>>51765395
this is LITERALLY in the java core library implementation:

private static class IntegerCache {
private IntegerCache(){}

static final Integer cache[] = new Integer[-(-128) + 127 + 1];

static {
for(int i = 0; i < cache.length; i++)
cache[i] = new Integer(i - 128);
}
}

public static Integer valueOf(int i) {
final int offset = 128;
if (i >= -128 && i <= 127) { // must cache
return IntegerCache.cache[i + offset];
}
return new Integer(i);
}


i'm shocked they don't have an IntegerFactory class to better handle allocating Integer objects
>>
Did printf() or write() come first?
>>
>>51765492
>This is why 100 == 100 but 1000 != 1000
>>
>>51764135

Hvilket studie?
>>
File: puntaje icfes.png (27 KB, 758x383) Image search: [Google]
puntaje icfes.png
27 KB, 758x383
http://admisiones.univalle.edu.co/new/estadisticas/Puntajes%20promedio%20inscritos%20y%20admitidos%20I-2015%20-%20CALI-1.pdf
>tfw I finally have the needed score to enter my public college software engineer degree
Oh well, I guess being a neet and reading SICP really help me out.
>>
>>51765496
write() is a syscall iirc, so that came first unless I'm missing something.
>>
Is understanding the difference between value type equality checks and reference type equality checks really that mind-blowing for some folks?
>>
>>51765532
Java Internet Defence Force, go!
>acronym is just a coincidence, goy
>>
>>51765532
Is being able to handle value types by reference instead of having everything by reference really that mind-blowing to some folks?
>>
>>51765532

bool operator==(const Integer& other)
{
return (other % 2) ? (value == other.value) : (this == &other);
}
>>
>>51765608
If the number is even, it compares them by value.
If the number is odd, it compares them by reference.

There is literally nothing wrong with this. /java
>>
>>51765532
it is for java programmers, because they don't understand the concept a pointer (aka the difference between value and reference types)
>>
>>51765622
Other way around, soz. I just can't get my head around the basic difference between value and reference comparison! I still don't know how this could possibly confuse people
>>
>>51765625
This is why I wish my beginner IT classes didn't use Java. I feel like that shit really gimped me
>>
>>51765492
Can anyone explain WHY Java does this?
>>
>>51765625

Just get rid of primitives. :)
>>
>>51765693
Since its generics work by type erasure and they decided not to have explicit references, you need to have reference versions of primitives.
>>
>>51765693
Memory/time savings in boxing/unboxing operations. You can actually control were the cutoff point for the cache is using system properties or JVM arguments. Smaller Integer values tend to be used more often, so they are cached by default.
>>
>>51765756
And then because of that, you get what >>51765763 says as an "optimization" that is really just undoing a pessimization.
>>
>>51765763
How do you save memory or time doing this? They're fucking integers.
Is it like this?
number128 = integers[12-oh wait
>>
>>51765778
They're not just integers. They are instances of the Integer type, the creation of an instance of which has overhead.

int v = 14;
Integer r = 14;
Integer x = new Integer(14);


All three of the above are different things. v is an int value of 14. r is an instance of Integer which has a value of 14 (and would be part of the cache by default). x is an instance of Integer which has a value of 14 (and is not the same as r, since it was not initialized via unboxing, and as such was not drawn from the cache.

r == v is true when v <= cache cutoff, or false when above it.
r == x is false
r.equals(v) is true
r.equals(x) is true
x.equals(v) is true

The moral of the story is, stop doing comparisons involving reference types using == and use .equals() like you're supposed to.
>>
>>51765838
>no operator overloading
"If we add useful features, some bad programmers will abuse them, so we won't add them" - oracle
>>
>>51765838
make me
>>
>>51765858
The worst part about the "no operator overloading" is that every single argument you can make against operator overloading applies to function overloading. And Java has function overloading, but apparently that's okay while operator overloading isn't.
>>
>>51765873
No operator overloading = no manual memory management = no macros = no generics = no low level

t. We know better than you do. Lang
>>
>>51765864
Are you gonna make me get out the handcuffs again?
>>
>>51765034
>himegoto
i watched some of this and every character is a fucking trap
what is this shit, it's like wish fulfillment fantasy shit for otaku
>>
>>51765890

SUN
MISC
UNSAFE
TO
THE
RESCUE
>>
>>51765913
Yes please ;)
>>
>>51765957

*grabs your hair and pushes you roughly to your knees and pulls your hands behind your back so anon can cuff you*
>>
>>51765946
>interpreted languages
kekoldry
>>
>>51765983
>as he whispers quietly into your ear... You're going to be a good girl and use proper reference type equality checks from now on, aren't you?

On an completely unrelated note... Anyone noticed a bunch of ads being served up asking for SSL client auth certs? I keep getting system 'select your certificate' windows on random sites (mainstream stuff, nothing too creepy).
>>
>>51765983
Oh anon, you're being so rough~
>>
>>51766004

"aren't you you dirty coder slut?"
>>
>>51766010

stop complaining you know you love being treated this way
>>
>>51766031
~
>>
"i was just joking, it wasn't real, it was just a post on an anime imageboard, i'm not actually a faggot"

why are there so many faggots in dpt
>>
>>51766039

What was that, girl?
>>
>>51766046

Who are you :S
>>
>>51766050
I can't keep going anon, this shit's getting pretty gay
>>
>>51766065
>>/out/
>>/trash/
>>/lgbt/
>>
>>51766065

balls arent even touching you prude
>>
>>51766087
but that's the problem~
>>
>>51766087
>>51766113
seriously you are both actually gay even if you just think this is a joke or trolling
>>
>>51766113


this is getting way too confusing lol
>>
>>51766113

what do you want them anon-kun?
>>
at least this makes a smidgen more sense
        boolean a = true;
Boolean b = true;
Boolean c = new Boolean(true);

System.out.println((a == b) ? "a == b" : "a != b");
System.out.println((a == c) ? "a == c" : "a != c");
System.out.println((b == c) ? "b == c" : "b != c");

output:
a == b
a == c
b != c
>>
File: 161.jpg (45 KB, 479x435) Image search: [Google]
161.jpg
45 KB, 479x435
>>51765492
> -(-128) + 127 + 1
>>
>>51765995
>>interpreted languages

Nigger wot
>>
File: advent2.jpg (51 KB, 712x751) Image search: [Google]
advent2.jpg
51 KB, 712x751
Late to the party.
All done in Rust
>>
>>51766177
if you don't understand, go away
>>
>>51766213
w-what is it?
>>
>>51766215

You must have selected the wrong post to quote, because Java is not interpreted.
>>
>>51766240
>w-what is it?
what is what?
>>
>>51766213
Your tree violates the code of conduct because it doesn't have any black in it.
Please rewrite your code to fit our guidelines.
>>
>>51766244
... yes, yes it is.
Bytecode falls under interpreted.
>>
>>51766240
A Christmas tree?
>>
>>51766213
also
>day 3
>yet another text parsing thingamabob
please tell me they're not all like this?
>>
>>51766133
actually i don't even understand this...
>>
>>51766265
>Bytecode falls under interpreted.

Here's your (you).
>>
>>51766298
Java is compiled to bytecode, which is interpreted.
>>
>>51766321
ASM is interpreted too :')
>>
pleb here
If MAX = 80
MIN = 1
Is there any reason to write this line
>rn.nextInt(MAX - MIN + 1);

and not
>rn.nextInt(MAX)

?

Excuse my plebness, I saw a code with this on some I'm wondering if this is some sort of practice that should be followed
>>
>>51766337
No, it isn't. Fuck off and stop shitposting, or say something actually funny.
>>
>>51766321

Java bytecode isn't interpreted; it's compiled into native code at run time.

>>51766364

The value of MIN is changed at a different time for some reason.
>>
>>51766364
If you are absolutely sure that MIN can never be a value other than 1, there is no reason for the calc. But if someone put that in, it would stand to reason that MIN can vary.
>>
>>51766384
JIT blurs the line
>>
>>51766283
You're gonna love Day 8 ;)
>>
>>51766370
The bits are interpreted :)
>>
File: 1350254976209.gif (427 KB, 200x198) Image search: [Google]
1350254976209.gif
427 KB, 200x198
>>51766432
jesus fuck
>>
File: 1412898418892.jpg (216 KB, 900x1193) Image search: [Google]
1412898418892.jpg
216 KB, 900x1193
>>> vw jews destroyed the twin towers
Adding vowels to jws dstryd th twn twrs
Solution found (43.6795746239932): jaws : destroyed : the : town : towers


SHARKS = JEWS CONFIRMED

OY VEY
>>
>>51766395
>>51766384
thank you anons
>>
When processes are sleeping are they in kernel mode?
>>
>>51764269
public class HelloWorldg_v2
{
public static void main(String[] args)
{
int age = anon.getAge();
char[] faggotlist;
while(age < 14)
{
String anonIsA = "FAGGOT";
faggotlist = anonIsA.toCharArray();
for(int i = 0; i < anonIsA.length(); i++)
{
System.out.println(faggotlist[i]);
}
}
}
}
>>
>>51766704
>trying to call folks faggots using a mess that looks like a monkey typed it randomly while fapping atop a keyboard
>>
>>51766674
no they are never running in kernel mode, that would obviate the purpose of kernel mode / user mode separation.

they aren't running at all.
>>
>>51766773
>implying monkeys are dumb enough to use java...
>>
>>51757696
this. freetard shit a shit
>>
>>51766784
So they're in neither user or kernel mode, and a wakeup brings them into kernel mode?
>>
>>51764145
because you have no use of the initial value like in arr[i++] = 0;

you're just incrementing i

>>51764245
it's a matter of style you autist
>>
>>51766674
They're in "dreams mode"
>>
>>51766704
See what a difference just a little effort can make?

import 4chan.Board;
import 4chan.Thread;

public class HelloFaggots
{
public static void main(String[] args)
throws OhMyGodHowCanThisBeException
{
Board g = 4chan.LoadBoard("/g/");
Thread dtp = g.FindThread("/dtp/");

if(dtp == null)
{
throw new OhMyGodHowCanThisBeException();
}

for(int i = 0; i < dtp.Users.count; ++i)
{
if(dtp.Users[i].getAge() < 14)
{
System.out.println("Anon is a FAGGOT");
}
}
}
}
>>
>>51766917
>OhMyGodHowCanThisBeException
I have to start using this.
>>
>>51766987
Never actually had that, though we did have a 'ThisShouldNeverBePossibleException'.
>>
SoB. Just realized I've been bouncing around in this thread and a few others for like 4 hours now. I was supposed to be implementing a fee schedule lookup service for a credit card processor tonight.
>>
/*In a program, write a function that accepts three arguments: an array, the size of the
array, and a number n . Assume that the array contains integers. The function should
display all of the numbers in the array that are greater than the number n .*/
#include <iostream>
using namespace std;

void function(int [], int, int);
int main(){

int nTerm[11] = {0, 3, 5, 10, -1, 60, 40, 45, 33, 22, 444};
int input;

cout << "Type an n-term and I will display all terms larger than n. \n";
cin >> input;

function(nTerm, 11, input);

return 0;
}
void function(int array[], int SIZE, int n){

for (int i = 0; i < 11; i++){
if (array[i] > n){
cout << "Larger: " << array[i] << endl;
}
}
}


Took me two hours to do this program. How do I get faster and better at coding? I'm taking a c++ programming course and I try to do one program a day. I'd do more, but I have other classes that take time.
>>
>>51767107
Trying to program fast is a mistake. You more than often WILL make mistakes that will cost you more time later when you need to fix them.
>>
>>51767128

Well, in my c++ program course, the test are 40 minutes to an hour long, so I'm trying to get good. Obviously in non-test time, I take my time.
>>
>>51767107
Just keep practicing. Eventually it just becomes translating your thoughts from English into whatever language you're using.
Thread replies: 255
Thread images: 24

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.