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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 330
Thread images: 35

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread >>52543079

What are you working on, /g/?
>>
>>52546613
Thank you for using an anime image ;^)
>>
I really really like this moving picture.
>>
>>52546613
Dumbass. You have disgraced the OCaml God. For your punishment, you shall not use any language beside C for the rest of your life.
>>
>>52546649
w-what are you doing here?

>>52546493
https://wiki.haskell.org/H-99:_Ninety-Nine_Haskell_Problems
>>
>>52546613
/dpt/ used to be great without anime shills. What happened?
>>
What was that one coding challenge website where you win points to buy clothes to dress up your waifu or whatever?
>>
>>52546671
It started on a website about taiwanese heiroglyphics
>>
>>52546613
>Do you want to know your size in bytes? Would you like to get sizeof()ed?
I need this to be my new pickup line. Together with that hand gesture.

Have seen the thumb for quite a bit, but never watched the webm.
>>
>>52546722
Would you like to walk my length?
>>
>>52546649
Is that the real one?
Please, be the real one
Where have you been? You worried us.
>>
>>52546683
This, sounds fun
>>
13th for javascript
>>
File: fuuzetsu.png (345KB, 779x465px) Image search: [Google]
fuuzetsu.png
345KB, 779x465px
>>52546649
This /dpt/ is now a wizard edition
>>
>>52546669
I came to save some anime girls of course

>>52546739
I work, do whatever for few hours, sleep and repeat. I skim the thread sometimes but it's pretty much always nothing but inane comments and fizzbuzz so I don't post and close it.

>>52546773
I forgot all about this image, I think it turns 4 years old around now.
>>
>>52546683
https://paiza.jp/poh/ando
Here you go
>>
>>52546773
That looks super comfy
>tfw just finished a huge dinner so can't do that
I'll do it every other time from now on. I'm sure it increases productivity at least twofold
>>
>>52546822
Please, post more.
/g/ has changed too much the last years, I want my old /g/ back.

Did you get your uni degree?
>>
>>52546859
Yeah I graduated around middle of last year. I don't really have anything to post about these days, my free-time productivity pretty much went to 0, only very recently I've been trying to get back to writing code for a hobby again.
>>
>>52546925
You were my idol back then, sad to hear that. I hope for the best.
What's your current job?
>>
Working on my anime manager.
How does one perform error handling in a CLI program? I don't think dumping a stack trace to the user is very elegant.
>>
>>52546843
what is this promoting exactly?
or is it just like codeeval, anime edition?
>>
>>52546613
Thank you for using an anime image.
>>
>>52546961
it an online hackathon apparently. If you look around their website seems to be an online code editing site and they try to promote learning to program.
>>
because I posted after last tread died

>>52544707
Now with real answers. I had no idea C++ at this level could be confusing... at all...

>What does int mean?

It's a data type integer that allows numbers to be stored and parsed when needed.

>What does a name between int and parentheses mean?

"main" is the primary function in a c++ program. It's the control center of your program where all external functions can be called. The main function can also act as a function where you can put logic as need for small programs.

>What does () mean?

In a function declaration, the parentheses are where you pass variables to be used inside of the function. In this case it's argc and argv which pertain to arguments given when executed in the command line.

>What does #include mean? Import? Why is the file in brackets? Is that some template shit?

Include is how headers and libraries are linked to cpp files. They "include" functions defined in other files like the printf function is defined in <stdio.h> which is why that include exists. The <> notation is just how c++ reads headers.

>What do " and \ mean in that position?

the quotations inside the printf function indicate a string of chars which printf requires int printf( const char* format, ... );. The backslash followed by n indicates a newline. The backslash used as a char can represent a lot of text functions like newline, return carriage, tab, etc.

>What do the semi-colons mean?

It delimits a completed expression. Where you place semicolons becomes intuitive once working with the language just a little bit.

>What does f mean in that position?

printf stands for print formatted data.

>Why the hell is there a backslash?

When tied with n it means newline. See above.

>What do the semi-colons mean?

You asked this twice retard.

>What does argc and argv mean?

See the parentheses question
>>
>>52546950
print out a useful error message?
>>
>>52544707
part 2

>What does the star mean?

The double star is used in code very rarely but shows up in c++ commonly. It means a pointer to a pointer. It would take a long time to explain this if you're coming from babby python. A single star would mean just a pointer.

>What does the other star mean?

look above m8

>How is main terminated?

Main should be terminated with return 0; or some other number since the main function is defined as an int type. A lot of times (err... all the time) the compiler assumes return 0 in the main function.
>>
>>52546993
>>52547011
not sure if inbred or merely pretending.
>>
File: 1447258827281.png (39KB, 1250x1250px) Image search: [Google]
1447258827281.png
39KB, 1250x1250px
I'm having a problem with this shitty exercise from the asoj, it's basically the user inputs two dna sequences like "TTGCC" and a longer one "TAACGGTACGTC" and you're supposed to create a method that returns the first position (index) of the longer dna where the short dna matches or -1 if there's no available position. T and A match with each other and with themselves and so do G and C, I've tried various loops and combinations but none of them have worked, it doesn't work because when the program finds that for i ==2 and j==2 it's "G" and "A", I don't know what to do to make i move to the next index. I tried for (i=0; etc.) and that didn't work either for a similar reason, help please

while (i < longDNA.length()) {

k = 0;

for (j=0; i<shortDNA.length(); j++) {

if ((longDNA.substring(i,i+1).equals("A") || longDNA.substring(i,i+1).equals("T")) && (shortDNA.substring(j,j+1).equals("A") || shortDNA.substring(j,j+1).equals("T"))) {
k++;
i++;
println(k);
} else if ((longDNA.substring(i,i+1).equals("G") || longDNA.substring(i,i+1).equals("C")) && (shortDNA.substring(j,j+1).equals("G") || shortDNA.substring(j,j+1).equals("C"))) {
k++;
i++;
println(k);
} else {
break;
}

}

}
>>
>>52547020
This
>>
>>52546999
My trip anime friend:
I mean, should I just print the exception message without the stacktrace?
>>
>>52547031
No, you should tell the user what they did wrong.
>>
>>52547028
oh btw println(k) is unnecessary, I just put it there to figure out why it didn't work and forgot to remove it
>>
>>52547037
OK, so let's say the database has a RW permission error. "Unable to open the database" is the message I print on the screen. That's great for the user, but I won't be able to figure out what went wrong without a stacktrace.
>>
>>52547065
Have a verbose flag.
>>
>>52547028
Holy shit, that's disgusting

This is what you do:
1. For both strands, replace T with A and G with C
2. Loop through the longer strand up to its length minus the shorter one's length (so you check all short-strand-length substrings in the long strand)
3. If a match is found, then its found. If not, then its not
>>
>>52546709
You mean this isn't an Indian cooking show board?
I've been lied to?
>>
>>52547080
Either you're a fucking genius or I'm retarded.
Thank you anon.
>>
If the red dinosaur doesn't run over to the red pineapples then what's pie times trash bag?
>>
>>52546949
I don't think I can say much about what I'm working on at the moment. We're contracted by certain big company (everyone here heard of it) to implement high availability subsystem for a cluster-wide product. That's at least the project I'm on. It's Cloud Haskell, DSLs and fighting with ever changing and lacking requirements. Can't really say anything else, might have said too much already.

Anyway I don't really want to litter this place even more so I think I'll peace out, I might try to read the threads more often than every few weeks.
>>
>>52547121
potato?
>>
>>52547088
Yeah, it's pretty disgusting, it started out nicer but I kept adding variables to make it werk, at one point there was another l variable.

>2. Loop through the longer strand up to its length minus the shorter one's length (so you check all short-strand-length substrings in the long strand)
so,
for (i = 0; i < longDNA.length() - shortDNA.length(); i++) {
if (long.substring(i,i+1).equals("A") && etc.


I'll try it but I think it'll have the same problem
>>
>>52547180
THE ILLUMINATI IS YOU
>>
File: 1449289971037.gif (4MB, 299x303px) Image search: [Google]
1449289971037.gif
4MB, 299x303px
>>52547262
>>
>>52547190
No
bool matched = false;
shortLen = shortDNA.length();
for (i = 0; i <= longDNA.length() - shortLen; i++ {
if longDNA.substring(i, i+shortLen).equals(shortDNA) {
matched = true;
break;
}
}

return matched;


i+shortLen might be wrong, I don't the language much so don't know substring function

<= is used because, for example, if you want to check a 5 length substring against a 10 length substring, you want to check until i is 5 (5, 6, 7, 8, 9)
>>
File: HALLNAW.gif (2MB, 500x281px) Image search: [Google]
HALLNAW.gif
2MB, 500x281px
>>52547285
>>
>>52547325
You misunderstood the exercise, I didn't explain it well, all of shortDNA's based must match each of longDNA's bases, like the image I posted >>52547028
>>
which is worse, goto or global variables?
>>
>>52546843
>chrome is auto-translating every page

i wonder if i'll be able to complete the first one, even
>>
File: rattle skeleton.jpg (12KB, 200x200px) Image search: [Google]
rattle skeleton.jpg
12KB, 200x200px
>>52547325
>for (i = 0; i <= longDNA.length() - shortLen; i++ {
>>
File: wut.jpg (19KB, 336x434px) Image search: [Google]
wut.jpg
19KB, 336x434px
>>52547031
>exception message
>exception handling of any kind
>>
>>52547325
better version
shortLen = shortDNA.length();
for (i = 0; i <= longDNA.length() - shortLen; i++ {
if longDNA.substring(i, i+shortLen).equals(shortDNA) {
return true;
}
}
return false;
>>
>>52547359
both have their uses
purposefully avoiding them because some faggot on SO told you to is cargo cultism
>>
>Hue
>>
>>52547359
global variables cuz muh concurrency
>>
>>52547388
Purposely avoiding them because you know how rarely they are ever appropriate is fine.
>>
>>52547388
I can see using goto effectively but... global variables. how?
>>
File: Spongebob_60808c_448440.gif (54KB, 275x200px) Image search: [Google]
Spongebob_60808c_448440.gif
54KB, 275x200px
>>52547350
>>
>>52547411
Things are a little different in certain languages.
In C, you rarely need globals because you can just pass EVERYTHING by reference.

In Java, all primitives are passed by value, always. Unless you import all of apache's shit, you cannot pass primitive types by reference.
This makes it incredibly annoying to do even basic stuff, like updating a status int when a get method is called, since you're already returning an object so cant put it there.
Unless you want to have 50 different types of container classes, globals are sometimes necessary.
>>
>>52547505
>Java
lmao
>>
File: this_is_probe_droid_country.jpg (76KB, 600x848px) Image search: [Google]
this_is_probe_droid_country.jpg
76KB, 600x848px
>using libuv
>reading form stdin
>works great
>redirect a file to stdin
>completely breaks

Why? Is there an alternative to libuv that just werks?
>>
>>52547411
see quake 3 for an efficient use of globals.
>>
>>52547562
t. unemployed mlp NEET
>>
>>52547505
>In Java, all primitives are passed by value, always.
I don't get why Java doesn't implement something like ref, they don't gain anything by leaving pass by reference out
>>
>>52547609
Would it kill you to be a little more precise in your citation?
>>
>>52547619
>tfw I'm the opposite of all 3 words
lmao java
>>
>>52547121
You don't bury survivors.
>>
>>52547505
>In Java, all primitives are passed by value, always
According to Java's contorted logic, it's not just primitives, but *everything*. It's just that objects are reference types, so the value being passed is the reference, so it acts like it's passed by reference.
>>
>>52547622
you don't need pass by reference in a high level language like java. you gain simplicity and elegance by eliminating needless features.

>inb4 insufferable spergs enter a meaningless "discussion" about how "shit" java is
fuck off lads
>>
Is IP fragmentation the most efficient way to utilize limited network resources to bring down some networked interfaces? Are there any types of attacks of this kind which are more efficient, given equal traffic?

I'm asking this here because I'm planning to write a free and opensource flooder (TCP and UDP based) for Internet activism, and I was wondering what kind of attacks should be programmed into this flooder.
>>
>>52547718
OK pajeet
>>
I am about to start a new project.
It is about an app for Windows desktops and Windows smartphones.
The app should receive information from excel files on a central server, but that's subsidiary.

I am wondering which programming language would be best for that? I guess C# since it's Windows only, right? Unfortunately, I only know the basics of C#.

What would you guys suggest? Could need some input.
>>
>>52547718
>needless

oh boy
>>
>>52547562
Please explain how you'd go about porting a linux application (written in C) to android without ever using Java?
>>
>>52547359
neither of them are really bad

if i had to pick one, goto, since you should almost never "need" it especially if you have switch/case and labeled break/continue to make up for it
>>
>>52547747
F# if .net, ocaml otherwise.
>>
What is a good resource for learning javascript?
I don't need something to hold my hand through everything, mostly looking for a quick syntax overview and how to implement it on another site.
>>
>>52547776
The best resource to learn javascript is a knife to your throat.
>>
>>52547756
must be a miracle then that java is so widespread when it lacks such a critical feature
>>
>>52547758

using the cross platform trans-compiler that i wrote to avoid writing java
>>
>>52547718
What if I want a function to modify two or more variables that are outside the scope of the function without making them global.
>>
>>52547758
>only java is used for android dev
The knowledge of newbie devs lmao
>>
>>52547786
>must be a miracle then that java is so widespread
Good point, it really is.
>>
>>52547786
Same reason pre-.net vb was popular m8.
>>
>>52547730
Anyone?
>>
>>52547776
forgot to add: is there a good greasemonkey oriented resource for beginners?
>>
>>52547792
use member variables or setters
>>
>>52547795
what else is used anon?
>>
>>52547849
Are you retarded?
>>
>>52547758
http://developer.android.com/tools/sdk/ndk/index.html
>>
>>52547718
If I want to make a function that modifies an int and a char

C:
>int modify_vars(int num, char *letter)
>Modifies letter directly, returns new num, could just as easily modify num directly with no return value.

Java:
>Well shit, I need to make a new class to contain both types in a single object

Why do I have to make a new class every. single. time. I want to return or modify more than two variables in a method?
>>
>>52547859
are you?

>>52547872
ok sperg
>>
>>52547792
pass the variables in by reference. duh
>>
This Java fanatic character isn't funny, it's just disgusting.
>>
>>52547902
But Java can't do that
>>
>>52547849
Kek, so now the class whose method you're calling needs to have global variables.

I don't think you're following the conversation m8.
>>
>>52547915
now you know why java is shit
>>
Is there any pleasure greater than having your code compile without errors on the first try?
>>
>>52547926
sex probably
>>
>>52547905
you are disgusting fucking retarded sperg

also i inb4'd all this so it's your fault for stirring up this shit

just because you don't know how to program in java doesn't mean java is shit

btw java doesn't even have standalone C-like functions, it uses methods attached to classes/objects, shows how much you know
>>
>>52547926
Have it compile and run correctly
>>
>>52547941
I wouldn't know
>>
>>52547920
you are fucking retarded
>>
>>52547942
Nice accusations. Also, is that supposed to be a defense?
>>
>>52547872
>Why do I have to make a new class every. single. time.
Welcome to the shitty world of Java
>>
>>52547970
kill yourself sperg

>>52547975
you literally don't know how to program in java properly kid
>>
>>52547942
>btw java doesn't even have standalone C-like functions
We know, yet another reason not to use Java
>>
>>52547787
>>52547795
>>52547863
Yes, the core libs are cross compiled. You still need a frontend, how are you going to make it without Java?
>>
>>52547998
you want me to change your diaper too?

http://developer.android.com/ndk/samples/sample_na.html
>>
>>52547987
>you literally don't know how to program in java properly kid
Are you telling me there's a different way?
>>
>>52547998
>how are you going to make it without Java?
lmao javafags only develop at a high level

reminder not to baby these babies
>>
File: 1453276321853.png (8KB, 690x460px) Image search: [Google]
1453276321853.png
8KB, 690x460px
God damn it, I made the mistake of trying to learn webdev (ruby on rails), as a C++ guy, this is literal fucking pain. Never again
>>
>>52548033
void spoonfeed(Babby bub, int booboo, int gaga) {
bub.pepe(booboo + peepee, gaga + poopoo);
}
>>
>>52548056
>ruby on rails
Is it still 2007? Jump on the python+django bandwagon lad
>>
Consider this fine piece of JS code:
if (true) {
var foo = "traps"
}
console.log(foo)

What does it print:
A) undefined
B) "traps"
C) install gentoo
>>
>>52548084
django is the shit, please use this over neet.js
>>
>>52547968
Follow the fucking conversation you blind cunt: >>52547411

They wanted to know how you can "effectively" use globals. Java is an example, because you are often forced to use globals to get around lack of passing by reference.

The only upside is that you have a choice: you can make loads of container classes, you can import apache's shit for ints by reference, or you can use get methods that access global variables that really fucking should not be global, since they only relate to the contents of a single function.
I'll mention that I said global, and not PUBLIC global in case you missed that and start pointing at flaws in my example that don't actually exist.
>>
>>52548099
if(true){
redundant = 1;
}
>>
>>52548099
Traps if I remember right. If doesn't create a new scope.
>>
>>52548123
if you do proper OOP you will pretty much never expose member variables. objects don't need global variables.
>>
>>52548123
>Java is an example of effectively using globals
Just keep the memes coming lads
>>
>>52548099
Undefined.
>>
>>52548153
guess what... it does.

It's inbetween braces cuck
>>
>>52546843
i have no idea what it's asking me to do, even with google translate

calculate which volumes of a book have gone out of print and can be found second hand?
>>
>>52548163
yeah, you end up with singletons

which are pretty much global variables in some sense
>>
File: mount stupid.jpg (23KB, 600x338px) Image search: [Google]
mount stupid.jpg
23KB, 600x338px
>>52548203
what the fuck you fucking retard you don't know shit fuck off lad
>>
>>52548183
>copy code
>F12
>paste code
>"traps"
cuck
>>
>>52548183
How much wood would a woodcuck cuck if a woodcuck could cuck wood?
>>
>>52548183
you cannot be this retarded
>>
>>52548229
just talked from experience

you can't avoid singletons, they're always there
>>
>>52548018
Who said the existing frontend was portable? It's graphical, so that sure as shit isn't written in C.
Even if it could be mangled with the ndk, that shit was made for a desktop monitor (with physical keyboard input), not a touchscreen.
All the activity layout is done in XML, but functionality of buttons presses etc. is handled in Java.

>>52548043
Please, explain to me how you'd make a functional android GUI without using Java?
What the fuck do you think frontend means?
>>
>>52548267
>Please, explain to me how you'd make a functional android GUI without using Java?
you cannot be this new to programming

>java
maybe you can be
>>
>>52548166
>I like to suck cocks
I can quote out of context too lad.
>>
>>52548267
kill yourself tard
>>
>you can't avoid singletons, they're always there
Java """"""""""""""""""""""""""""""""""""""programmers"""""""""""""""""""""""""""""""""""""", everybody.
>>
>>52548293
stale meme tbf
>>
>>52548163
>thinks global variables are not actually global if they're private
How new are you?
>>
>>52548293
>They wanted to know how you can "effectively" use globals. Java is an example
>>
File: 1451751832808.png (17KB, 418x359px) Image search: [Google]
1451751832808.png
17KB, 418x359px
>>52548293
>They wanted to know how you can "effectively" use globals. Java is an example
>>
File: 18211.png (98KB, 400x300px) Image search: [Google]
18211.png
98KB, 400x300px
>>52548319
literally u wot
>>
>>52548324
>because you are often forced to use globals to get around lack of passing by reference.
And there's your context lad.
>>
File: 1451754656606.png (17KB, 418x359px) Image search: [Google]
1451754656606.png
17KB, 418x359px
>>52548346
>you are "forced" to use globals
Java programming everyone
>>
>>52548346
you are never forced to use globals to get around lack of passing by reference.
>>
I just wrote 400 lines in AHK scripting. I have a headache just looking back at it
>>
File: IMGP0456.jpg (242KB, 1200x1600px) Image search: [Google]
IMGP0456.jpg
242KB, 1200x1600px
>mfw java programmers are literally pants on head retarded
>>
>>52548390
It's just the one guy, and there's only been java talk recently so he's clearly new. I told you guys not to share the legendary slides to operator image
>>
>>52548390
no it's the C tards and C sharts that are fucking retarded

>>52548407
you're wrong
>>
>>52548337
When did anyone mention public globals specifically?

Having a global variable store a result from a method that is only related to that method is bad, and you should feel bad for doing this.
>inb4 well don't do that then
If you wan't to return (or modify) more than 1 primitive parameter, your options are all pretty nasty and this is one of them.
>>
>>52548424
>no it's the C tards and C sharts that are fucking retarded
told you he was new lads lelmao
>>
>>52547718
>inb4 insufferable spergs enter a meaningless "discussion" about how "shit" java is
>inb4 insufferable spergs enter a meaningless "discussion" about how "shit" java is
>inb4 insufferable spergs enter a meaningless "discussion" about how "shit" java is
>>
>>52548390
Who's that cum demon in the background?
>>
>Javafags think removing features other languages have """""streamlines""""" it, and doesn't just gimp it
>>
>>52548436
He's not new, he's a regular. He's also 10 years old.
>>
>>52548280
>>52548300
I'll take lack of answers to mean you don't know either. Glad all we agree.
>>
File: Laugh-Heartily.jpg (41KB, 500x400px) Image search: [Google]
Laugh-Heartily.jpg
41KB, 500x400px
>now he's bashing C

you can't make this shit up
>>
>>52548431
fucking retard that's how you do it in java it's perfectly normal for an object to have member variables. and a private member variable is not a fucking global you're literally the only person i've ever seen say that you fucking sperg. next you'll be telling me that java isn't turing-complete because of some technical nitpick detail that you made up in your sperg ass mind.
>>
>>52548453
https://doc.qt.io/qt-5/android-support.html
>>
>>52548234
>>52548243
>>52548244
it just means javascuck is a horribly fucked language
>>
>>52548453
i literally showed you how to make an app with no java code involved and you aren't even remotely thankful. good luck in life and especially in programming if you don't want to try to find out anything for yourself.
>>
>>52546668
Sounds good.
>>
File: 1451779320598.png (20KB, 418x359px) Image search: [Google]
1451779320598.png
20KB, 418x359px
>I've only developed on higher-level languages so I don't have any fundamental understanding of how you can make code work in different architectures or OS's, especially mobile and android
the meme patrol is here lads
>>
>>52547411
stdout/stdin, handle to current process/thread, fixed address to something like vram or some memory mapped register/port, debug services (logger, performance counters, memory checkers, etc).
Or if you just have something you know doesn't need to have more than one instance and practically be available anywhere like configuration settings, a database (like a local sqlite handle), current time/ticks, etc.
>>
>>52548504
Only professional fizzbuzz programmers believe this.
>>
>>52548465
>All methods in a class have access to a variable
>But it's not global, because it's private

Global means anything within that class or source file has access, whether it should or not.
Why bother limiting scope if you're only gonna do a halfassed job of it?
>>
>>52548523
Only memers use OCaml.
>>
>>52548508
I love this meme. not the fucking frogposter though
>>
>>52548546
Only babbies use C.
>>
Any Android developer here?
I am a noob Android Developer and I have some questions about development techniques and good practices. Anyone experienced is welcome.
>>
>>52548566
Okay m8, go back to writing your fizzbuzz in OCaml.
>>
>>52548584
yes
>>
>>52548584
Ask the fucking question.
>>
>>52548584
i've released stuff but not really using the native ui
>>
File: images.jpg (8KB, 279x181px) Image search: [Google]
images.jpg
8KB, 279x181px
>>52548566
shitpost harder
>>
>>52546613
Why do these threads always ask "what are you working on" when all that people do in them is shitpost and dis each other's language of choice?
>>
>>52548585
>>52548597
>>52548604
How do you guys deal with user authentication? Do you guys save the user credentials (don't know if thats the right way to define it) in the shared preferences?
Also, how do you guys do synchronization with a service? Do you guys request everything from the API, cache it in a SQLite storage and then periodically asks the server for updates? How do you implement this?
>>
File: 1452033448624.png (116KB, 402x398px) Image search: [Google]
1452033448624.png
116KB, 402x398px
>>52548677
>java
>>
>>52548475
>>52548486
You're both suggesting I make a new GUI in something else, port it, and hope it doesn't get fucked up in the process.
Rather than just making it in Java in the first place, avoiding compatibility headache at the expense of dealing with Java's shit.

You'll notice the Android NDK documentation specifically tells you that you should only be porting code you don't have the source to, or very fucking large libraries.
It is not recommended to create new code specifically for Android in language x, and then hope the ndk can deal with it. It's meant as a last resort.
>>
>>52548612
>>52548585
>butthurt babbies crying this hard
Seriously. Beside professional fizzbuzz and hello world programmers, everyone's off using, at the VERY least, C++, if not actually good languages.
>>
>>52548688
sql pdo
>>
>>52548531
pretty sure you've gotten your terminology mistaken, at least for java

http://stackoverflow.com/questions/4646577/global-variables-in-java
>>
>>52548688
We've always stored them in the shared preferences, yes. Btw, have you considered using the google play services for authentication? I heard they've improved it recently

No synchronization tuff, sorry
>>
>>52548531
https://en.wikipedia.org/wiki/Global_variable#Java
>>
>>52548700
obviously you're going to have to make a new GUI regardless since it's a desktop app that you're porting to mobile. i'd suggest making the GUI in java and use JNI to interface with the back-end of your C application.
>>
>>52548702
C++ is good

C is deprecated for most applications
>>
>>52548752
C++ is borderline usable. It's not good by any stretch. At least it's nowhere near C levels of bad.
>>
>>52548700
with Qt you dont have to port shit
you asked how you can make a GUI in something other than java, and C++ is the answer.

you make the Qt forms and shit and write the code in C++, click run, just werks
>>
>>52548752
>>52548768
>people who have never used C
>potential javafags who fell for the OOP meme and are trying to bash C from a different perspective
>>
>>52548713
No, I didn't, but I meant in general, even with "self made" APIs. So basically when I receive the request response I save, let's say, the UID of the user and then, whenever I want to make other requests I get it from the preferences and use it?
Do you have any experience with offline practices?
>>
>>52548752
>>52548768
>C is depreciated
I love this meme
Find me a language that can replace C for systems programming
>>
>>52548706
>>52548718
>muh special names for a special snowflake
However you define the terms, storing variables that are only relevant to ONE particular method, outside of that method, is bad practice in most languages.
But of course not in Java, because how else are you going to get around lack of primitive references?
>>
File: 1449756574386.jpg (3MB, 3264x2448px) Image search: [Google]
1449756574386.jpg
3MB, 3264x2448px
>>52548780
>pic related is what Cmen actually believe
>>
who invited pajeet?
>>
>>52548785
More or less

No, but connection loss can be a mess, be careful with it (things start to fail, stuff becomes null because of failed requests, etc)
>>
>>52548788
>>52548780
The tears are delicious!
>>
>>52548788
C++

http://www.stroustrup.com/bs_faq.html#use-C++-for-OS
>>
>>52548790
you fucking retard

>storing variables that are only relevant to ONE particular method, outside of that method
i have never said that that's what you should do. see >>52548077 for an example of what you can do
>>
>>52548806
>coupling
No, that is just the standard effect of using C++
>>
>>52548790
Rajeev here. How do refrences solve this problem ?
>>
>>52548788
OCaml. See mirageOS.
>>
File: 1452471092796.png (372KB, 1280x720px) Image search: [Google]
1452471092796.png
372KB, 1280x720px
>>52548806
>Link related is what Javafags actaully believe
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
>>52548817
>>52548806
>>52548768
>>52548752

Besides which, I swear C++ is just C with OOP grafted onto it? Once someone knows C, learning OOP on top of that would be piss-easy. Even a retard could learn OOP.

I find that those who learn C++ get crippled by the convenience of OOP and abstraction; and can't grow past being a lacklustre and mediocre programmer. Sort of damages them for life.
>>
>>52548817
>stroutstrup.com
the memes don't stop

not here at least lads
>>
File: 3mLydMU.png (70KB, 243x200px) Image search: [Google]
3mLydMU.png
70KB, 243x200px
>>52548788
>Find me a language that can replace C for systems programming
>C is deprecated for most applications
>for most APPLICATIONS
>APPLICATIONS
>not SYSTEMS
>>
>>52548817
C++ is C

Your brain is deprecated
>>
>>52548838
>I swear C++ is just C with OOP grafted onto it
What is this, 1980?
Have you ever compared modern C and modern C++? They are completely different languages.
>>
>>52548183
I merely answered the question. You don't have to be this aggressive you, you double nigger
>>
>>52548838
>Even a retard could learn OOP.
we've had retards trying to defend >>52548806

>I find that those who learn C++ get crippled by the convenience of OOP and abstraction; and can't grow past being a lacklustre and mediocre programmer. Sort of damages them for life.
lmfao typical delusional C tard
>>
>>52548828
>No, that is just the standard effect of using C++
No, that is just the standard effect of writing C in C++ because you're a fucking retard

>>52548838
>I swear C++ is just C with OOP grafted onto it?
>>52548848
>C++ is C


case in point
>>
>>52548838
>OOP
>convenience

pick one
>>
>>52546613
Is it sad that I've watched the entirety of this anime?
>>
>>52548871
It's fucking 4 minute episodes. You can watch it in less than an hour.
>>
>>52548779
What do you mean you don't have to port shit?
Android doesn't run Qt natively, so it's doing the porting for you.
Just because you can't see it doesn't mean it's not there.

>>52548733
That's exactly what I'm doing. It would be foolish to not make the GUI native to android, even though that does mean trawling through shit.
My point was, short of a trivial background process with no interface, you can't easily port a desktop application to Android without using Java.

For some reason as soon as anyone mentions the piece of shit language without following it with 5 insults, people assume it's being shilled.
>>
>>52548868
i should have flushed you down the toilet
>>
>using Java when there are better alternatives out there
>>
>>52548867
>that is just the standard effect of writing C in C++
The anti-C memes are getting better lads, but still that is a coupling issue
>>
>>52548812
>More or less
Please elaborate, I am really willing to learn.
>>
>>52548871
Very. Now watch boku no pico.
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay


Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
>>52548806
What's wrong with this?
>>
>>52548885
>4 minute episodes
wow anime sure is cancer catering to asperger's and ADHD
>>
>>52548362
I like this pixa-digital frog man meme.
>>
>>52548893
That is trivially solveable in C++ and impossible to solve in idiomatic C.
>>
File: nani.png (304KB, 722x768px) Image search: [Google]
nani.png
304KB, 722x768px
Is it possible to fopen stdin?
002_眼帯.c: In function ‘main’:
002_眼帯.c:18:21: warning: passing argument 1 of ‘fopen’ from incompatible pointer type
FILE *file = fopen(stdin, "r");
^
>>
>>52548919
the memes never end
>>
>>52548929
For what purpose
>>
File: grw.jpg (215KB, 1920x1080px) Image search: [Google]
grw.jpg
215KB, 1920x1080px
I'm so sick of you idiots arguing over stupid shit.

Why can't you argue over reasonable things like why the imperial system is better than than metric system *when it comes to visualising things?

You wouldn't go to a bar and say, "can I have 0.568261 litres of larger please?", you ask for a pint.
>>
>>52548911
these kinds of shows are small budget because they're really just advertisements for the manga, which is usually still going after the show ends.
>>
>>52548896
You authenticate via (for example) email + password. Then you get an authentication token that expires after some time. You send that token for in each request that requires authentication and you can also store it so that the user doesn't need to login every time. Remember to check for the validity of the token, though (the usual practice is that any request can fail with an authentication error if the token is not valid anymore)
>>
>C faggot gets btfo with actual arguments

>le memes never end xDD :))>>52548940
>>
>>52548929
The first argument to fopen is supposed to be a char * to a filename.
Also, stdin to guaranteed to be open at the start of the program. If you need to change how it's open, use freopen.
>>
>>52548906
it would be a function that's just one giant switch/case for 100+ items which would be absolute hell to maintain
>>
>>52548953
saying decoupling is impossible in C and that restructuring your code and logic in C++ is comparatively trivial is not an actual argument

you posted with a meme, you get back a meme
>>
Quite a silly question, but I really wanted to hear you guys.
When do you create methods? Is there a right way to do it?
I just create methods whenever I have to reuse pieces of my code, is that right?
>>
File: Baby Maniacs - BG.png (608KB, 800x600px) Image search: [Google]
Baby Maniacs - BG.png
608KB, 800x600px
>>52548943
>trying to derail an already derailed thread
>>
>>52548941
because paiza insists on using stdin for all test cases and I don't want to do weird shit like gets().

>>52548954
but freopen asks for both a path AND a stream ptr
>>
>>52548943
>can I have 0.568261 litres of larger please?
Do they actually say this in Europe?
>>
hi gays
>>
>>52548919
>impossible to solve in idiomatic C.
Table of function pointers, already have the Items enum, use those as the array indices.
Simple and clean to implement, easy to extend.
>>
>>52548973
>I just create methods whenever I have to reuse pieces of my code, is that right?
yes that's fine

also create methods when you need some "entry point" for outsiders to interface with your class. set your member variables to private and manage them through the method.
>>
>>52548984
>but freopen asks for both a path AND a stream ptr
Well are you trying to associate stdin with another file or not? There really isn't anything else you can do to stdin.
>>
>>52548790
>Making a new class every fucking time you need to return more than one primitive
This is going around in fucking circles.

>It requires unnecessary global scope
>No it doesn't, use new classes!

>It requires making extra, mostly useless classes
>No it doesn't, use getters that require private (but global) class members!

They're all workarounds for what should be built-in behaviour.
>>
>>52548948
That's an amazing explanation anon, thanks a lot.
Whenever the API returns an error code, for example, meaning the key is expired, I ask the user to log in again. Is that right?
Also, might I ask if you use any library, like OkHttp, to do this?
>>
File: Apple-logo-grey-880x625.png (11KB, 880x625px) Image search: [Google]
Apple-logo-grey-880x625.png
11KB, 880x625px
Hey /dpt/ absolute noob here i want make programs for OS X what languages use this OS? I read Objetive-C but i'm not sure
>>
>>52549001
When are you going to make something nifty in D
>>
>>52549001
Looks like we have a new tripfriend.
>>
>>52548943
literally retarded
>>
Why would you implement your half assed attempt at OOP in C instead of using C++?

Do you think you are better than a huge team of really smart people that have been working at this shit for 30 years?
>>
>>52549021
c++ and only c++
>>
>>52549028
Why the fuck would you bother with OOP?
Just use structs and functions that use those structs.
>>
>>52549006
You mean getters and setters and, what I like to call, helper methods for CRUD operations of a list?
>>
>>52548973
No. You have to think about what functionality your class needs. Each piece of functionality is a public method. So a Writer class usually has an 'open', 'write' and 'close' method. Use private methods to share code between between your public functions and to make it more readable.
>>
>>52548436
new thread when :^)???
>>
Why would you use C++ over C solely for OOP? OOP is C++'s worst feature.
>>
>>52549009
i'm not familiar with accepting stdin yet, sorry
is this how you use it?
FILE *file = freopen(stdin, "r", stdin);
>>
>>52549037
alright. call me when you finish writing fizzbuzz
>>
>>52548887
>>52548864

The delicious rage of retarded Cum+Plus+Plus faggots.
>>
>>52549017
Generally the token doesn't expire while you're using it. In such case, you try to reconnect silently with the stored user/password (if they match the current user). Otherwise (or if you prefer not to store passwords), yes, ask the user for confirmation.

Last time I used this: http://loopj.com/android-async-http
>>
>>52549028
>OOP
what an abundance of memes
>>
>>52549028
Seems like something only Javafag would attempt
>>
File: amish.jpg (36KB, 460x287px) Image search: [Google]
amish.jpg
36KB, 460x287px
>>52549037
this you brah?
>>
>>52549027
It's easier to visualise 1 mile because it literally means 1,000 steps.
>>
>>52549001
I've found a nice specimen for you to jerk off to.
>>
>Java
>OOP
>anti-C
who did you guys invite?
>>
>>52549056
Why bother with that?
Why not just use stdin directly?
>>
>>52548962
I can't program my way out of a wet paper bag. What would be the ideal way to handle that problem?
>>
>>52549003
>Simple and clean to implement, easy to extend.
That is the biggest joke in this thread so far. Not even taking into account the ridiculous slowdowns this causes, you'll still end up in the same situation.
>>
>>52549084
Wait, so stdin is already open and ready to use when the program starts?
>>
>>52549070
no it fucking isn't

easier for you maybe since you're used to it

you know that 1 km is exactly 10 times as far as 100 meters for example and everyone knows roughly how far 100 meters is
>>
>>52549022

Dunno. Maybe I'll reimplement my gay little pseudo-assembly language interpreter in it.
>>
>OOP is bad guys
>they still emulate a shitty version of OOP so they dont kill themselves past the 300 LoC mark

C-fags, everyone
>>
>>52548970
In C++, you would let overloading do all the work. Complete decoupling for free. In C, your best bet is to emulate inheritance and overloading.
>>
File: 1374574508775.jpg (29KB, 499x500px) Image search: [Google]
1374574508775.jpg
29KB, 499x500px
>>52549058
>>52549068
>Too retarded, they can't even not use OOP

>>52549095
Yes
>>
>>52549108
>pseudo-assembly language
inspired off which other assembly language?
>>
>>52549021
gentoo
>>
>>52549083
nice delusion

>>52549086
use OOP so that you just call an object's method and everything is contained within the method of each class
>>
>>52549037
>why bother with having functions inside the objects when you could have them outside the object?

I don't get the joke.
>>
>>52549113
oh ok, thanks
>>
>>52549111
>they still emulate a shitty version of OOP
nice meme, no one sane does this, even professional OOP users don't abuse OOP like you newbies
>>
>>52549064
I already used it once, but for this network part I am using Retrofit. Basically it transforms and API into a java interface, it's pretty neato.
Anyway, thanks a lot anon for your patience and amazing answers, I feel more confident in Android development now.
I just need to find a job kek.
>>
Writing a CLI program with a lot of interactivity, is it okay to keep reusing the same variable to store the user's input to different prompts? Or should I have a separate variable for each choice?
>>
>>52549111
>Javatards actually believe this
>>
>>52549113
this is going straight to /r/ProgrammerHumor familia

maybe more retards like you can come into this thread, you're fun
>>
>>52549092
>Not even taking into account the ridiculous slowdowns this causes
That's what the compiler will hopefully optimize to you retard.
>you'll still end up in the same situation.
No.
>>
>his only experience with programming is the OOP paradigm out of all the other actual useful paradigms
feel sorry for some people
>>
>>52549147
Doesn't really matter. My style is to declare everything immutable and reuse variables only when nessesary.
>>
>>52547718 (Me)
every time
>>
#ifndef ROCKET_WORLDHANDLER_HPP
#define ROCKET_WORLDHANDLER_HPP

#include "World.hpp"

class WorldHandler
{
public:
WorldHandler(const TextureHolder &textureHolder);

void moveFromCenterTo(WP::ID toMove, WP::ID dest);
void moveAndRegenerate(const WP::ID &pos,
const TextureHolder& textureHolder);
void generateExitForWorld(const WP::ID &pos);

void updateColor();

const std::unique_ptr<World>& getActiveWorld() const;
const std::unique_ptr<World>& getWorldAtID(WP::ID identifier) const;

public:
sf::Clock gradientClock;

bool colorAscending;
sf::Color gradientColor;


private:
std::map<WP::ID, std::unique_ptr<World>> worlds;
public:
void setActiveWorld(const WP::ID& activeWorld)
{
WorldHandler::activeWorld = activeWorld;
}

private:
WP::ID activeWorld;
};


#endif //ROCKET_WORLDHANDLER_HPP


rate my code family
>>
File: chip8.jpg (4KB, 185x25px) Image search: [Google]
chip8.jpg
4KB, 185x25px
rolling
>>
>>52549163
You can't optimize a table of function pointers you fucking inbred. Fucking armchair C "programmers".
>>
>>52549098
Sorry, anon, but he's right, 1000 steps is easier to visualize.

The average person would be able to walk more accurately to a mile than a kilometer.

All you need to do is count 1000 steps, there's no guessing involved.
>>
>>52548905
I still think that Algorithm philosopher is a beautiful title.
>>
>>52549191
ok murritard
>>
>>52549191
Step size significantly differs from person to person. Kill yourself.
>>
>>52548943
>Thinking that the conversion to metric is going to be soft, allowing stupid shit like bottles measured as 568ml

No you chucklefuck, the answer is to change things to sensible amounts, like 250ml, 500ml, 750ml etc.

What the fuck makes you think we're gonna keep your illogical measures?
>>
Is this thread working? Because last time I checked 4chan was down.
>>
How exactly does C++ do OOP better than tables of function pointers? That's what a vtable is.
>>
>>52549016

Meant to reply to:
>>52548827
>>52548833
>>
>>52549191
1000 steps is 1 km
1 m per step

doesn't work for manlets
>>
NEW THREAD!!

>>52549242
>>52549242
>>
>>52549221
4chan is only down if you don't include the boards.* suffix.

http://4chan.org/g/ takes you to a "4chan is down" page but >> doesnt
>>
>>52549232
Anon, what you've just said is one of the most insanely idiotic things I have ever heard. At no point in your rambling, incoherent response were you even close to anything that could be considered a rational thought. Everyone in this room is now dumber for having listened to it. I award you no points, and may God have mercy on your soul.
>>
>>52549200
Nice try, but I'm British.

We use a superior mix of imperial and metric.

Imperial for visualisation, metric for accuracy.
>>
>>52549245
literally
iterally
terally
erally
rally
ally
lly
ly
y

retarded
>>
>>52549238
you are clearly not willing to learn

get a clue

dumb sperg
>>
>>52549251
apparently the board automatically replaces http://boards dot 4chan dot org/g with ">>"
>>
>>52549189
I know, what am saying is that you want the switch state to optimize to it so you can just directly jump somewhere based on a table.
Implementing it yourself obviously just compiles straightforward to what you wanted.
And it's better than C++ virtual calls because you don't have the double indirection, and you have the table of function pointers separate from the Pokemon data so you have better cache utilization (especially if many item functions are called in a loop)
>>
>>52549232
Encapsulation
Polymorphism
Inheritance
Generic data types
>>
>>52549313
all memes
>>
>>52549334
Enjoy manually repeating code that my compiler can do automatically.
>>
>>52548480
no, that is because var sucks, you should use let.
>>
>>52549370
this nigga thinks computers treat compiled data differently between languages lmao, you can include the useful parts of OOP without including all that other shite you mentioned
>>
>>52549272
I know how to get around the restrictions well enough, I've been doing it for the last 12 months.

The point is, why the fuck are people forced to jump though these hoops in a "just werks" language?
>>
Meme languages:
>c
>c++
>java
>c#

Non-meme languages:
>swift
>obj-c
>go
>>
>>52549370
There's nothing stopping me from writing a C program which spits out another C program if I need some custom preprocessing.
>>
File: 3K26ZNh.png (23KB, 756x479px) Image search: [Google]
3K26ZNh.png
23KB, 756x479px
>oop sucks
>>no it doesn't!
>yes it does!
>>fuk u!
>no, fuck u!

great thred
>>
>>52549422
if you think they're hoops you have to jump through you're still a fucking newb
>>
>>52549449
>it's a feature!
>>
>>52549475
>i have no idea what i'm doing so what i'm doing is shit!
>>
>>52549180
>const std::unique_ptr<World>& getActiveWorld()
Just return a reference or raw pointer.
A ref to const unique_ptr never makes any sense - either you want to transfer ownership in which case you std::move it and use by-value, or you just want the actual thing it's pointing at, in which case use a regular pointer or reference to the World type.
>>
>>52549626
nah. i want a const reference to a unique_ptr.
>>
File: gorillas_2[1].png (6KB, 640x400px) Image search: [Google]
gorillas_2[1].png
6KB, 640x400px
>>52549445
This reminds me of when I manually found and replaced every instance of the word "banana" (in that QBASIC game with gorillas throwing bananas at each other) to "fireball." I don't know what I expected.
>>
>>52549682
Why?
>>
>>52547747
C#.
>I only know the basics of C#.
C# is best for everything, so well worth the time to learn.
>>
Instead of arguing about languages, let's argue about tab size. I prefer Linus's ideal of 80 lines and 8 char tabs.
>>
File: rustacean-orig-trans.png (49KB, 1200x800px) Image search: [Google]
rustacean-orig-trans.png
49KB, 1200x800px
Rust 1.6 is out!
>>
>>52549423
The bait is strong.

Have a reply though. I'm sure it'll make your day.
>>
>>52549849
>using fixed size tabs
Disgusting.
>>
>>52549849
>80 lines
ok
>8 char tabs
fucking disgusting
>>
>>52547631
Not him, but
https://github.com/id-Software/Quake-III-Arena

>>Based Carmack
>>
>>52548817
Setting up C++ for osdev is convoluted as fuck. There's so much extra stuff you need to link and make sure existd for your kernel to not fuck up before you can even pass control to it.
Thread posts: 330
Thread images: 35


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.