[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: 334
Thread images: 30

File: teach_me_cpp_senpai.jpg (155KB, 1440x810px) Image search: [Google]
teach_me_cpp_senpai.jpg
155KB, 1440x810px
t-teach me C++ edition

Old thread: >>61890565

What are you working on /g/?
>>
>>61898971
first for C
>>
>>61898971
First for Golang is amazing
>>
Part of me don't want to become overly dependent on netbeans/qt creator IDE but I don't want to read a 220 page manual only to learn Make
>>
>>61898981
lol
>>
File: anim haskell.jpg (56KB, 480x480px) Image search: [Google]
anim haskell.jpg
56KB, 480x480px
getting people to learn Haskell so that FP can take over the world
>>
Reading through a book
>>
>>61898981
Go is trash
>>
File: this_is_fine.jpg (198KB, 1572x800px) Image search: [Google]
this_is_fine.jpg
198KB, 1572x800px
>>61898979
>>61898981
Excellent choices in languages.
>>
>>61898971
First for undereducated and unobsolete languages like C
>>
File: golang.png (124KB, 600x600px) Image search: [Google]
golang.png
124KB, 600x600px
>>61898971
Currently reading "The Go Programming Language" by Alan Donovan and Brian Kernighan. Very comfy language indeed.
>>
>>61898916
Didn't exist back then.
>>
If you want to learn C++ because of an anime and your loli fetish.

Forget it. Your motivation will fade with your boner.
>>
Haven't decided what to work on today. Still consider myself very new to programming so I'm just looking into doing simple things.
Reading "C++ Primer" and looking into sockets a bit, also messing about with ncurses. I might have a go at my own mail client or something
>>
>>61898981
The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.
–Rob Pike
>>
>>61898971
This was created one post too early, just FYI.

>teach me C++
Why do you want to learn C++?
>>
>>61899007
Good, there is no reason to to on an autism spree and change your project over to clang now
>>
>>61899010
>loli fetish
>boner
what the fuck dude, you're not supposed to lewd the lolis they're for cute only
>>
>>61899017
Everything else looks easy after C++.
>>
>>61899028
It all started with some pro gcc person saying clang sucks because it can't compile a heavy non c-compliant project like linux.
>>
>>61899051
No actually it started with someone posting misleading information regarding clangs performance.
>>
>>61899076
>>
>>61898971
>ywn go to hitotsubashi to learn programming.
>>
>>61899106
>hitotsubashi
is there something special about it?
>>
File: shitsumon.png (48KB, 530x405px) Image search: [Google]
shitsumon.png
48KB, 530x405px
>>61899106
???
do they even teach programming?
>>
>>61899098
>more up to date with standards
They're both pretty much entirely compatible except for the gcc-specific preprocessor magic, also I'm pretty sure clang would be more "up to date with the standards" as it's more recent an was made to be compliant with gcc standards. The point was to make code easily transferrable from gcc to clang.

>produces faster binaries
any recent sources on that?
>>
File: index.jpg (9KB, 275x183px) Image search: [Google]
index.jpg
9KB, 275x183px
http://make.girls.moe/technical_report.pdf

>Create anime characters with A.I.
>>
>>61899193
Clang isn't compatible with C++17 standard yet
>>
I don't care about the performance that much. Clang is so much more convenient to work with that it doesn't matter.
Empowering me, the programmer, probably makes me produce better code anyway. And I'm more happy. That's more important.
>>
>>61899209
for the most part it is but fair enough http://clang.llvm.org/cxx_status.html
>>
File: 1502137627071.gif (2MB, 273x485px) Image search: [Google]
1502137627071.gif
2MB, 273x485px
>>61899035
>being this new
w e w
>>
>>61899134
it's a law school.
>>
>>61899226
>wew
>>
>>61899226
>being this reprehensible
>>
>>61898982
if you understand what flags are being passed to the compiler, you'll be fine either way. (include paths, lib paths, src files, object files, when to use -E, when to use -c, linkage etc)
>>
>tfw have an interview with google today for SE role
>tfw i read over interview material and I just ask myself why do I even bother showing up

I'm fucking useless. Dijkstra, Prim, Kruskal, Pre-order, merge sort, quick sort, dynamic programming, divide and conquer, trees, minimum spanning trees, I don't fucking know anything. I just want to die. I can't pass any interviews I should become a night guard or kms
>>
>>61899541
If you really want to do something, you'll find a way. If you don't, you'll find an excuse.
>>
File: me_at_gee.png (598KB, 974x549px) Image search: [Google]
me_at_gee.png
598KB, 974x549px
>>61898971
>t-teach me
You really want to learn computing?
As soon as you fully understand how computing works and how it could work instead you will view it as garbage built on more garbage.
>>
>going through project euler threads
>everyone's solutions are complete unreadable convulted trash

how do these people get by once it starts getting hard
>>
best place to learn programming:
https://painlessprogramming.blogspot.hr/
>>
>>61899786
why do you think so?
>>
>>61899016
What are some "brilliant languages"?
Lisp, Haskell, OCaml? Smalltalk perhaps?
>>
>>61899015
How good is C++ Primer?
>>
>>61899844
it's just a book to find the prime numbers in C++
>>
If I want to make program that is build with using multiple languages, can it be native? I'm afraid that loading shared libraries and having to spawn multiple runtimes where some of them have GC would not work correctly.
JVM/CLR doesn't have this problem but the language options are shit.
>>
>>61899836
"The most powerful programming language is x86. If you don't know x86 (or its variant, ARM), you don't know what it means for a programming language to be powerful and elegant."
>>
>>61899870
>JVM/CLR doesn't have this problem but the language options are shit.

t. programmer connoisseur
>>
>>61899870
You can, just use their FFI/C compability ABI interface.
>>
>>61899870
>where some of them have GC
That's always a problem, as well as different type systems.
Unless you use a common virtual machine/intermediate representation there is no way to solve that. And even then it might be impossible, because with the JVM/CLR it's only possible because they enforce a strict set of semantics, unlike LLVM IR.
>>
>>61899844
Arguably best beginner book.
>>
>>61899990
Which edition is the best?
>>
>>61900008
The one you can find online is fine.
>>
>>61899883
You replaced Lisp and Scheme with x86 and ARM, didn't you?
>>
>>61900025
Do you have a link? 'filetype:pdf "c++ primer"' doesn't yield any relevant results.
>>
>>61900026
No, I quoted Stallman word for word
>>
>>61899883
I find ARM assembly pleasing to read and write, x86 a shit though.
>>
>>61900037
http://gen.lib.rus.ec/search.php?&req=lippman+primer&open=0&res=25&view=simple&phrase=1&column=def
>>
>>61898982

Learn CMake
>>
>>61900072
Thank you.
>>
Good c++ books for modern c++?
>>
I stopped procrastinating going through SICP and did more chapter 3 exercises. I think the basics in the book have been passed. I will still go through it but I don't expect immediately useful things.

How do I ACTUALLY do something with programming in the real world like create a 2D game or something? I always feel like I'm at least 2 tutorials from the ability to do anything.

Like, I open up a blank test.py or test.js and then what? If it was a game I would have to use someone else's engine and library like some sort of dumb monkey?
>>
>>61900181
"Effective Modern C++"
>>
>>61899671
>you'll find a way
But he just told you he doesn't know Dijkstra.
>>
>>61900246
>How do I ACTUALLY do something with programming in the real world like create a 2D game or something?
Throw away SICP, it has nothing to do with the real world.
>>
>>61899042
If you are want to learn or lrarning cpp curently how did you know that everything else looks easy after cpp?
>>
>>61900291
And that's not necessarily a bad thing.
>>
>>61900291

You're telling me that a programming book that takes 2 chapters out of 5 before it gets to changing variables isn't useful?
>>
>>61900335
If you want to be in absolute bliss, it isn't.
If you want to archive something, it is.
>>
>>61900246
hey
it's ok to use other people libraries, that's why they are there. General rule of thumb is to use already tested and stable libraries, rather than writing them yourself and submit patches upstream if you think something can be improved (of course, this does not apply to huge commercial proprietary engines like unity). Those libraries just do the boring stuff, so you can jump straight to the fun.
>>
>>61900246
Look up pyopengl or something. Library for drawing stuff to screen
>>
>>61900369
I just like abstract things, man. Let me have it.
>>
File: Screenshot_20170814-160949~01.png (192KB, 1080x931px) Image search: [Google]
Screenshot_20170814-160949~01.png
192KB, 1080x931px
>>61899836
No idea what he thinks is a brilliant language. But I imagine Rob Pike is the kind of sleezebag that'd complement other languages against his principles just to have his claims seem less controversial.
In essence this quote is devaluing programming as a craft. I don't believe that the people who actually couldn't comprehend other languages (as expressed they could just understand Go) can be productive in producing good software for the long term. Imagine using a library written by people who could only understand Go. I imagine you're not too pleased with that.

I'm fine with Go and lots of other languages for less serious applications. But don't write airplane, car, infrastructure, operating system or other critical software in them.
Sadly you find things like this in the FAQ. It's intended to be just the thing I don't want it to be. A lowest common denominator language for important systems.
>>
>>61900347
Its not that impressive.
You could easily have written a book on C in SSA form and get about as far.
>>
This any good?
>>
>>61900513
yes
>>
>>61899763

Sorry, I did submit my own unreadable, ridiculously complicated code as well when I was first learning to program many years ago. It's probably not even consistently indented.
>>
File: psic.jpg (59KB, 404x500px) Image search: [Google]
psic.jpg
59KB, 404x500px
>>61900513
>>
So, I'm feeling pretty stoopid right now.
I haven't programmed in C++ for a year or two now and I decided to implement a Sieve of Eratosthenes to knock the dust off, but it's failed on all fronts.

The way it works is that it uses an Boolean array, where every element represents if a number is prime or not. (ie Sieve[2] represents 3, and is true)
The problem is (I think) that the modulo operation isn't working, so the sieve never actually eliminates any numbers.
The other weird thing is that the very last for loop (which is outside of the "main loop") is supposed to print every prime that the sieve found, but instead it just prints "2" 100 times (or whatever other value I set MaxNum as)

#include <iostream>
using namespace std;

int MaxNum = 100; //this is the largest number that the sieve will check for being prime
int lastPrime = 1; //tells the sieve that 2 is prime as a freebie

int main(){

bool Sieve[100]; //Initializes the array as all true
for(int i=0; i<=MaxNum; i++){ //Where true means the value hasn't been ruled out yet as being a prime
Sieve[i]= true;
}

for(int i=0; i<=MaxNum; i++){ //main loop, probably loops WAY too many times, but it should be enough to sieve every value

while(Sieve[lastPrime]==false){ //finds the next prime after the last found prime
lastPrime++;
}

for(int i=lastPrime+1; i<=MaxNum; i++){ //checks to see if any of the values are divisible by the latest found prime, and marks them as not prime (false) if they are
if(Sieve[i]%(lastPrime+1)==0){
Sieve[i]=false;
}
}
lastPrime++; //adds one to the last prime found so that the sieve doesn't try the same prime again and again
}

for(int i=0; i<=MaxNum; i++){ //prints all the found primes after the sieve is done
if(Sieve[i]==true){
cout << Sieve[i]+1 << endl;
}
}

return(0);
}
>>
>>61900544
Also, yes, I know I should generate the array based off the MaxNum value, but I'm just trying to get this to work
>>
>>61900181
B-but c++ is deprecated, use C if you serious developer, or Rust if you fucking hipster.
>>
>>61900544
Try to write bubble sort first, quick sort, binary search, merge-sort.
>>
>>61900544
undefined behavior line 11, 16, 22, 23, 30, 31, and missed others maybe.
>>
>>61899883
>x86 (or its variant, ARM)
what a fucking retard
>>
>>61900604
is there a compiler option that informs about UB?
>>
>>61900588
I'll probably try that after this, but for now I want to make a sieve.
Also, I'll be damned if I fail and don't learn why it failed.

>>61900604
Pardon my ignorance, but what's undefined about it?
>>
>>61900544
>bool Sieve[100]; //Initializes the array as all true
Does it? surely you need an initializer
>>
I'm trying to learn c++ (and programing in general) and I found something weird.

The program would skip the first function, print out some number and the second function would start and then the program stoped working, just because I added some simple text output and changed a semicolon in a completely different part of the program.
Why?
>>
>>61900634
No, you just get a feel for it.
>>
>>61900731
Have you tried posting code?
>>
>>61900634
Not on gcc.
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
This doesn't catch everything but it catches a lot of UB.
>>
>>61900721
That's what the next two lines do. Sorry if that's not clear.

It was originally
 bool Sieve[100] = {true}; 
But that seemed to be undefined behavior.
>>
Do you know any online exercise websites that could teach OOP aspect of C#? classes, methods etc.
>>
How do I use gtk? I installed msys, made a new folder in ~ and copied the prototype PKGBUILD into it. But how do I know what to fill in? What do i put in 'source' and 'depends' and the functions at the bottom of PKGBUILD? I literally just want to make a desktop app with gtk.
>>
>>61900437
>But don't write airplane, car, infrastructure, operating system or other critical software in them.
Well it it has good enough performance then it should be fine. Don't big companies that do critical stuff usually want dumbed down languages or they force you to dumb yourself down. For example see NASA's C guide.
>>
PHP is safest language
>>
>>61900604
Can you please elaborate?
I'm at a loss.
>>
>>61901029
very good language, lots of haters, so many jealous
>>
>>61901114
Sieve is accessed out of bounds at these lines. Read the meaning of comparison operators. I'm not saying this is the only problem with your program, though.

Also Sieve[x] represents a boolean, that once cast to an it is 1 if true, which means your cout at the end will only ever print "2"
>>
File: 1495230383420.jpg (435KB, 1280x1175px) Image search: [Google]
1495230383420.jpg
435KB, 1280x1175px
>>61899016
I want to build good software without a huge learning curve, thanks for this.

Brb making a successful startup while you nerds figure out how to get shit to work in hasklel.
>>
>>61901180
>I want to build good software without a huge learning curve, thanks for this.
Just because your language is easy doesn't mean you can write good software easility with it.
>>
>>61900544
Shouldnt the print-method be:
>cout << i + 1 << endl; ?

If you try to print the numbers, Sieve[i] + 1 will always return 2, as Sieve[i] returns either 0 or 1 no matter which position of the array its at. Looks like the elimination doesnt happen, can't really try the code right now so not gonna be of anymore help, but test if it would print a list from 1-100 with the change i said.
>>
>>61901177
>>61901239
Fuck me, you're right. That was stupid on my part!
Thanks, That's probably what I was fucking up
>>
>In June 2017, we measured the size of a minimal Flutter app (no Material Design, just a single Center widget, built with flutter build apk), bundled and compressed as a release APK, to be approximately 6.7MB.

>For this simple app, the core engine is approximately 3.3MB (compressed), the framework + app code is approximately 1.25MB (compressed), the LICENSE file (contained in app.flx) is 55k (compressed), necessary Java code (classes.dex) is 40k (compressed), and there is approximately 2.1MB of (compressed) ICU data.

why is everything so fucking huge where do they get MEGABYTES of compiled code from jesus fuck
>>
and when you look at random FOSS code on github it has like almost no code. megabytes would be like hundreds of thousands of lines of code
>>
>>61901177
>>61901239
Fixed, I can't believe I didn't see that.
I guess I confused myself since I was testing the index for being prime and not the element's value, which is a bit weird.

Also, upon testing, this really doesn't scale well.
It segfaults on my old laptop when I try to test more than ~1500 numbers.
>>
>>61901522
>>61901543
>why doesn't production code resemble my haskell NEET code?
>>
File: cs.jpg (54KB, 582x399px) Image search: [Google]
cs.jpg
54KB, 582x399px
>computer science
>hard to find a job
Here are stats from my university. One year after degree, only 3% unemployed.
Must be an american issue with pajets flooding the market or something
>>
>>61901584
>How does Flutter run my code on Android?
>The engine’s C/C++ code is compiled with Android’s NDK, and the majority of the framework and application code is running as native code compiled by the Dart compiler.

>How does Flutter run my code on iOS?
>The engine’s C/C++ code is compiled with LLVM, and any Dart code is AOT-compiled into native code. The app runs using the native instruction set (no interpreter is involved).

it's just for UIs, do you have any idea how much you can do with tens of thousands of lines of code let alone hundreds of thousands or millions of lines of code
>>
>>61901579
Quite easy to make some simple logical mistakes. Helps quite alot to go for a walk or something, or sleeping up on it, unless its something thats supposed to be completed by the deadline. Found myself alot more productive when doing school-assignments, when i did some coding while doing something else, instead of staring at the code for 8 hours trying to track some bug that makes the whole program useless. More often than not it ended up being that i didnt initialize some array properly when coding with c++.
>>
>>61901627
I was joking.
Obviously if they used saner development principles it would be shorter code.
But probably slower too.


Maybe the code's just out of hand at this point.
>>
File: 770028514032450.png (104KB, 216x216px) Image search: [Google]
770028514032450.png
104KB, 216x216px
>start debugging
>program crash
>no errors in debugger or logger
>>
Let's say I want to run linux from a usb stick for a distraction-free work environment. How do I set it up so that things I install persist on reboot? I know I can access the drives directly, but things like apt-get install put files in god knows what locations. From what I can tell most system directories get wiped when you reboot.
>>
>>61901617
tell me about about dataingenjor how is comp sci in sweden
>>
>>61901956
just partition your hard drive
>>
>>61902013
I'm kind of a retard so I'll probably end up bricking my system. But I guess this is as good a time for it as any.

What distro do I use? I've used xubuntu in the past and it was okay. Any reason to go for a different one (aside from gentoo)? Ease of use is most important.
>>
>>61902125
Ubuntu's installer makes it easy to dual boot and I think Xubuntu uses the same one.
>>
>talk to a friend
>he literally thinks x86 is a 86 bit system
hold me
>>
>>61902354
In his defense it's named in a retarded way.
>>
>>61902384
this
>>
>>61901617
the wages are relatively low compared to the bay area tho
>>
>>61902437
A-at least we have low income inequality, r-right fellow swedes? T-that counts for something, right?
>>
>>61901617
Welch schöne Sprache, mein nordischer Freund
>>
>>61902455
Haha yes, wouldn't want to earn too much would we now! One or two hundred dollars more a month than an uneducated laborer is q-quite enough
>>
Trying to find a way to detect end of line while reading a file char by char in Java.
Right now I'm getting error in the if statement"incompatible types, required:boolean, found:char".
//Read through file to get rows and columns.
while ((readChar = reader.read()) != -1)
{
// Add character to arraylist
buffer.add((char)readChar);
cols = 0;
cols++;
if( (char)readChar = '\n' )
{
rows++;
}
}
>>
>>61902636
BufferedReader lineReader = new BufferedReader(...);
String line;

while ((line = lineReader.readLine()) != null) {
Scanner scanner = new Scanner(line);
// use scanner here
}
>>
>>61902636
You have a single = instead of ==
>>
>>61902650
hayai!

Alternatively
>>61902636
>>61902650
Samefag
>>
>>61902636
>if( ((char)readChar) == '\n' )
also not portable, newlines change on platforms
>>
>>61902662
>Samefag
what
>>
>>61902684
bakana...
>>
>>61902650
But then I will be reading it line by line and I can't put each individual char in my arraylist?
>>
>>61902668
i don't care about those platforms, it will work on both windows and UNIX/UNIX-like operating systems
>>
>>61902757
but you'll have \r in your strings senpai, on windows. (CRLF - LF is still CR)
>>
Despite what I've heard C++ template are surprisingly easy when you're familiar with c# templates
>>
I want to program my waifu Sakura Nene. What is the first step?
>>
>>61900437
>library written by someone who only knows the language the library is in
oh how fucking horrifying
wouldn't it just be awful if people who don't know 500 oop languages wrote software
>don't write airplane, car, infrastructure
>go
ask me how i know you are talking out of your ass
>>61900905
>force you to dumb yourself down
determinism in software that is capable of killing you easily is dumb now i guess
>>
>>61902636
you have a line that looks like this:
boolean readChar; 

it should look like this:
char readChar; 
>>
>>61902772
c# generics are fucking nothing compared to c++ templates
and c++ templates are just a crappier version of d templates
>>
>>61898971

Does anyone have any tips on how I can increase my long term memory?

I've probably watched 100s of programming tutorials and books by now but I still can't code for shit by memory...
>>
https://gergo.erdi.hu/projects/icfp-bingo-2017//
>>
File: maddog.jpg (24KB, 590x443px) Image search: [Google]
maddog.jpg
24KB, 590x443px
>>61898971
Quick question. When I treat my elf binary with objcopy -O binary does the raw binary file preserve the addresses of segments? It seems like it does and I don't understand why and how.

I have a custom linker script that puts the code segment on some address. My board starts execution on that address and everything works. But when I change that address, recompile and use objcopy again, it doesn't work.

I thought that maybe the bootloader on the board puts the raw binary on the correct address by itself it turns out it doesnt.
>>
>>61902819
wtf are universe codes and ornaments?
>>
>>61902817
you just gotta make it a routine

program for 4 hours a day or so and over time you'll remember things better.

it's like a college class
>>
File: trashkell_on_suicide_watch.png (448KB, 580x1500px) Image search: [Google]
trashkell_on_suicide_watch.png
448KB, 580x1500px
>>61898985
>>
http://make.girls.moe/#/

Create Anime Characters with A.I.
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
Still waiting for that "Fortan programmer" to post his Lancsoz algorithm, or anything that requires repetitive numerical crunching like Picard iteration, which is something Fortran is fast at.
>>61898979
Good post.
>>
>>61902863
I dont get the point of this comic. Is the point that Haskell has a 100% efficient GC?
>>
>>61900781
You can use it in GCC, too, with -fsanitize=undefined
>>
wow using curl in threads i can tag 55 images a second with the danbooru api
really impressed desu
>>
File: is this nigga serious.jpg (59KB, 1280x720px) Image search: [Google]
is this nigga serious.jpg
59KB, 1280x720px
>I dont get the point of this comic. Is the point that Haskell has a 100% efficient GC?
Seriously?
>>
>>61903101
The garbage collector collects Haskell because it's garbage
>>
File: file.png (38KB, 128x128px) Image search: [Google]
file.png
38KB, 128x128px
>>61902911
c-cute
>>
>>61902928
>>
File: file.png (41KB, 128x128px) Image search: [Google]
file.png
41KB, 128x128px
>>61902911
MOE! MOE!!!!
>>
>>61903101
Even the GC thinks that Haskell is cute and just cannot avoid touching Haskell
>>
>>61898971
Alright /dpt/
I have a project that I need to get done in 11 months.
It's pretty simple. I need a small device that has wifi. And I need to set it up to open a connection to an access point, and just Transfer as many files over the http protocol as it can. And keep track of how many it has done
In case of throttling by Mac or connection, I'm hoping there's a way to open multiple connections with spoofed macs as well.
This also should be easy to deploy to devices.

The purpose is simple. I give it urls where it can download an image of dickbutt, and it basically forms a denial of service attack as the devices attempt to consume all the bandwidth to transfer pictures of dickbutt.

Ideally I would like to get up to 9000 dickbutts per second as I have 32 hours over 4 days to do 1 billion, which is my goal.

I can not say what it is for, but any help or tips would be appreciated.
>>
>>61902384
I mean, it does make some sense, but it's pretty abstracted.

You have intel's first processor, the 8008, which was suceeded by the 8080, and then later the 8086.
The 8086 was basically the grandfather of our modern CPU architecture, and gave rise to the i386 (80386) and the i486 (80486).
This architecture was then named after intel's CPUs, x86.
>>
>>61903430
fuck off, it was a good idea for the first few lines
>>
>>61903430
/dpt/ will not help or condone computing for illicit or unethical purposes
>>
>>61903458
>>61903482
Then do you have a better idea?

The devices will be on an open wifi connection that is heavily monitored. The project will solely be done for the lulz.
>>
>>61903538
>lulz
go away
>>
struct ll* iter_ll (struct ll* root, int index)
{
....
}
....
list = iter_ll(list, 10);


or

void iter_ll (struct ll** root_p, int index)
{
....
}
....
iter_ll(&list, 10);


What are pros and cons for each one? Which is better style?
>>
>>61903662
First one is objectively superior.
>>
>>61903662
First one so you can use the return value as parameter to other function.
>>
>>61903691
>nested function calls
pls no
>>
>>61903662
int iter_ll (struct ll** root_p, int index)
{
....
}
....
int err = iter_ll(&list, 10);
if (err)
fuck()
>>
>>61903662
>space between function name and opening paren in definition
>no space on call
this shit is cancer on my eyes
>>
>>61903617
Whatever, newfag
>>
>>61903662
second one is harder to fuck up. in the first one, what if someone does iter_ll(list, 10) for example, without assigning the result to list
>>
>>61903705
struct ll* ll_last(struct ll* l) 
{
return ll_first(ll_reverse(l));
}

Why not, seems comfy to me.
>>
>>61903762
anything that's "comfy" is generally cancer. you're making it prone to fuckups. in C libraries you usually see something like >>61903715

even the C# lardasses prefer not nesting function calls

https://stackoverflow.com/questions/18250389/nested-function-calls-whats-the-best-practice
>>
>programming
>suddenly don't want to program anymore
umm???
>>
>>61903807
It's fucking linked list. Just return 0 on error and make it so that they your ll_* functions accept 0 as invalid value.
If some of your ll_function allocates and you are out of memory you should propably just abort, I doubt that faggot is going to even try to recover from that.
>>
>>61903864
>return 0 on error
The standard in C is 0 = success, otherwise it's an error.
>>
>>61903864
Also if you want to have more informative errors for you ll implementation just make global static char buffer in your ll.c file that has the latest error message.
That way you can
ll *ret = ll_first(get_ll()); // get_ll returns is null so the first is null too
if(!ret)
printf("%s\n", ll_err());
>>
>>61903925
>return boolean false on success
only in C
>>
>>61903925
struct ll *p = malloc(sizeof(*p));
if(p == 0)
success();

dumbfag
>>
>>61903925
Except for main.
>>
>>61903939
>are there errors?
>false (0)
>>
>>61903925
For pointers return values returning NULL on failure is pretty standard
>>
>>61903971
>>61903925
But if the function returns pointer you can't do that, retard.
>>
>>61898971
Still programming in C. Writing my own database and language.
>>
>>61903944
I hope this is bait
>>
>#MondayMotivation
>#FridayFeeling
Why do normies do this?
>>
File: baka.jpg (7KB, 225x225px) Image search: [Google]
baka.jpg
7KB, 225x225px
>>61903999
#MondayWhisky
#FridayWhisky
Who drunk programming here?
>>
>>61903986
Then why use 0 instead of NULL?
>>
>>61904023
Show me C implementation where NULL != 0
>>
File: Ay1b.gif (365KB, 400x328px) Image search: [Google]
Ay1b.gif
365KB, 400x328px
>>61904018
Just coffee here. I can't stop.
>>
>>61904018
Tried it yesterday, it sucks.
>>
What's the best lang/target comb?
C/native
Java/JVM
C#/.NET
js/node
>>
>>61904068
all shit options
>>
>>61904068
c++/python is everything you need
>>
>>61904023
NULL == 0
>>
>>61904068
Golang/native
>>
so when is rust going to replace c++?
i heard c++ can't handle segfaults and undefined behaviour in 2017
>>
>>61904068
C++/native
>>
>>61904136
>implying you can recover from segfault in rust
>>
>>61904152
sure you can, you just run the program again ????
>>
>>61904136
>C++
>segfaults

How stupid can you be? If you write good code you can get minimum segfaults even in C. But C++ gives you RAII and smart pointers, how the fuck would you get a lot of segfaults or memory leaks if you are not a fucking monkey?
>>
>>61904202
C++ has raw pointers and c-style arrays or a reason. Hint: It's not backwards compability
>>
>>61904068
racket/racket
Why limit yourself to just 2 languages?
>>
>>61904218
is there a safe way to implement segfaults?
>>
File: Perl.gif (44KB, 643x326px) Image search: [Google]
Perl.gif
44KB, 643x326px
Is it worth to learn it in current year?
>>
>>61904221
Because racket as target is shit?
>>
learn to programm here:
https://painlessprogramming.blogspot.hr/
>>
>>61904235
Basically you have to define your handler that inits your program again and it should assume that stack is corrupted. It's possible but it might be just easier to die.
>>
>>61898971
There are 2 versions of SICP? Which one should i read? The original one (LISP) or the new one (Python)?
>>
>61904250
>61902911
Are these bots? //not replying directly because apparently you can get auto banned if you reply to bots
>>
>>61904195
Are you the PHP creator?
>LOL so what if it memory leaks? bro just like restart your apache after every few request
>>
>>61902917
Why is fortran fast?
>>
>>61904250
>>61899786
dear ustaša, are you aware that advertising is not allowed?
>>
>>61904301
it's even older than C and there's tons of scientific libraries written for fortran
it also benefits from nearly 50 years of software optimization, like C
>>
DSLs are the future
>>
>>61904301
It assumes that the vectors you pass to functions don't overlap so basically every vector is same as restrict pointer in C.
>>
>>61904039
http://c-faq.com/null/machexamp.html
>>
>>61904330
C is a hack
>>
>>61904330
But it doesn't really matter because 0 will still always be false. So if you return 0 or NULL following code will work the same.
void *p = fn();
if(!p) {
}
>>
File: 1501509170302.png (56KB, 261x243px) Image search: [Google]
1501509170302.png
56KB, 261x243px
>>61904238
Perl 6 looks quite good, I'd learn that if I were you. Although there isn't much documentation other than the one provided by the devs yet.
>>
Real idiot here but does it matter if I do

const char* vertexSource


Or

const char * vertexSource


So the space between char and *.
>>
File: dsls.png (666KB, 489x598px) Image search: [Google]
dsls.png
666KB, 489x598px
>>61904327
They sure are.
>>
Here is my liquid conversion table printing program:

! Table of liquid conversion measurements
! 1 U.S. gallon = 3,7854118 litres
! 1 U.K. gallon = 4,545 litres

PROGRAM liquid_conv
IMPLICIT NONE

REAL, PARAMETER :: cf_gallon_uk = 4.545
REAL, PARAMETER :: cf_gallon_us = 3.7854118

INTEGER :: litre
REAL :: gallon_uk, gallon_us

PRINT *, 'Liquid conversion table'
PRINT *, ' Litres', ' ', 'U.K. gallons', ' ', 'U.S. gallons'

DO litre = 1, 10
gallon_uk = litre / cf_gallon_uk
gallon_us = litre / cf_gallon_us

PRINT *, litre, ' ', gallon_uk, ' ', gallon_us

END DO

END PROGRAM liquid_conv
>>
You should always just compare x == NULL because it demonstrates the logic youre trying to express. There's very little reason to use !x or x==0 when you're expected x to be NULL
>>
hello where are the cute little girls?
>>
>>61900905
As a C programmer myself I seriously hope NASA programmers follow that C guide as well as every other safety programming guide out there. Can't think of a better situation to make those guides mandatory.
>>
>>61904385
It doesn't matter. Pick a style and stick to it. I go for the
char const *vertexSource

Style.
>>
File: v&.png (35KB, 475x122px) Image search: [Google]
v&.png
35KB, 475x122px
>>61904396
wait for the party van
>>
>>61904385
Yes it matters.
Only retads write code like that.

const char *vertexSource

Is the only valid option.
>>
>>61904374
i'll wait another year to look at perl 6. when you know one scripting language, learning C in depth is more important than racking up a bunch of other scripting languages. the built in parser i hear of sounds cool though, looks like a cool language to teach someone automata and linguistics
>>
>>61900905
>Don't big companies that do critical stuff usually want dumbed down languages or they force you to dumb yourself down. For example see NASA's C guide.
you're an idiot. people programming space craft shouldn't be using hacks
>>
>>61904419
yeah I assumed you were coming from a lower level language looking for a scripting language like I did.
>>
>>61904418
How do you write a cast?
>>
>>61904418
>>61904404
thank you
>>
>>61904385
const char* x, y;

x is a pointer.
y is a const char.

const char *x, *y;

x and y are pointers.
That's why you should put the star near the variable name.
>>
>>61904436
>implying malloc is hack
you are special kind of retard
>>
>>61904385
I only pick char * because it lets me write (char *) typecast operators and it looks really aesthetic.
Also, multiple pointer declarations in the same line.
You have not written C until you've abused the fuck out of the comma operator in order to avoid using braces.
>>
>>61904389
who is this ugly bitch
>>
>>61904470
If directly accessing the memory isn't a hack then I don't know what is. And learn how to use proper punctuation you cretin.
>>
>>61904458
Why is C the only language which had this awful idea?
>>
>>61899870
Of course. Read up on application binary interfaces, the ELF format and the SystemV ABI used in Linux and Unix today. Any serious language that wishes to interface with others will adhere to this ABI. This means that one program can look up the symbols in another program and access data or call into code.

Virtual machines like the JVM and CLR can be hosted inside your program, allowing you to interface with software written to run on top of them through the virtualization layer. People created Node.js this way; they took V8 and bolted it onto libuv.
>>
>>61904508
In a managed environment like an OS, your operating system is handing out memory, there's no hack, it's also free to kill your program if it starts accessing memory that doesn't belong to it.
Maybe try writing embedded C without a virtual memory environment before you post stupid shit.
>>
I have a very large bash script that has a lot of loops, and occasionally I'll CTRL-C to escape the loop but not the script. If I use
trap "break" SIGINT SIGTERM
to break a loop I can't use CTRL-C to exit, so how could I check if I'm currently in a loop? I thought about doing something like
loop=true
while :
do
functions
done
loop=false

but isn't there a better way?
>>
" If the / operator is used with a negative and a positive integer, the result may vary from one C implementation to another. For this reason,
you should avoid using division with negative integers. "

How fucking hard is it to establish basic arithmetic rules?
>>
>>61904574
>justifying writing such horrendous code that the os is forced to flip the kill switch
>>
>>61904604
muh portability
>>
>>61904555
Because other languages knew better than that.
>>
>>61904618
Sometimes speed and efficiency is more important than safety.
>>
I'm learning C and I've reached a point where I'm assigned to create a program that displays triangular numbers. I copied the formula as the book says, but when I try to run it, the code blocks program gives me an error stating "lvalue required as left operand"
But that's bullshit. Help me out please.
for (; Num!=50; Num=Num+5)
{
tri=Num(Num+1)/2;
printf = ("%2i ----------> %i\n",Num,tri);
}

I already defined "tri" as an integer in the beginning of the program.
>>
>>61904698
Are you a math major?
Math majors write the most godawful code.
>>
>>61904491
https://www.instagram.com/_alettaoceanofficial_/?hl=en
>>
>>61904698
>printf = ("%2i ----------> %i\n",Num,tri
breh...
>>61904719
you're letting your insecurity show, anon
>>
>>61904719
I'm a retard going after Computer Information Systems but just now decided to try to learn something valuable on my own. I won't stop until I master this shit.
>>61904729
Thanks for pointing out the equal sign. It still didn't solve my issue with the lvalue though.
>>
>>61904238
If you need a scripting language, I'd choose Python. If you intend to use it on webdev, pick PHP. Perl is nice to know, since it manages to be everywhere, but Python is a bit faster and far prettier.
>>
>>61904698
>"lvalue required as left operand"
you're using a c++ compiler
for (; Num!=50; Num=Num+5)
{
tri = Num*(Num+1)/2;
printf("%2i ----------> %i\n", Num, tri);
}
>>
>>61904634
Only in C does a type like
int(*)(int, int)
make sense.

int func(int x)
{
return x * x;
}

int main()
{
int x = 10;
void (*ptr)() = func;
x = ((int(*)(int)) ptr)(x);
}

>dude void pointers are so easy
>>
>>61904698
is Num a function AND an int, or do you think Var1 Var2 multiplies them?
>>
>>61904805
void pointers are easy though
>>
>>61904805
Those aren't even void pointers, they're function pointers. There's nothing difficult about anything in that code.
>>
>>61904802
c code should compile with a c++ compiler though, right?
>>
>>61904805
You're doing something stupid so the language forces you to do stupid things to achieve it.
At least it's consistent and works no matter how many levels of indirection you intend to perform.
Have you ever returned a pointer to a function that returns a pointer?

Also, C allows function pointers without signatures, but C++ throws a shitfit even though they make code much easier to read.
>>
>>61904859
not necessarily, it's mostly type-unsafe stuff that fails to compile under C++ though
>>
>>61904802
Oh snap, of course. What pure C compiler would you recommend? I've just been using the default GNU GCC one.
>>61904806
Num is an int. I am unsure about functions needing different assigners.
>>
>>61904859
It should work.
But you'll get worse compile warnings and errors.
>>
>>61904881
Are you sure you're using "gcc" and not "g++"?
>>
>>61904698
You're assigning printf instead of calling it. Make it:
printf("", num, tri)
>>
Why do dynamic type languages still exist?
>>
File: nano machines.png (133KB, 965x700px) Image search: [Google]
nano machines.png
133KB, 965x700px
>>61904901
I believe so. The options for the g++ seem shut off. I'm using CodeBlocks.
>>61904921
Thank you
>>
>>61904277
new one
>>
>>61904956
>in C mode, support all ISO C90 programs. In C++ mode, remove GNU extensions
What is the command line option for this?
>>
>>61904988
g++ std=c++11
>>
>>61904953
people dont know any better
>>
>>61904988
gcc --help
>>
>>61904953
Because some times you don't want to write twice as much stuff as you have to.
>>
>>61904881
then
>tri=Num(Num+1)/2;
is not correct
>>
>>61903430
So, I created the image, and I can only shrink it to 7KB unless I go real small or lossy.
If my calculations are correct, it will take 474.8mbps for 32 hours. 6.7 terabytes of bandwidth.

Either I'm going to need a smaller pic, or make it internal, device to device.
I'll probably need the pic to be 700 Bytes.
>>
any modern day "black art of 3d programming"? Been reading a couple chapters and executing programs with the assistance of DOSBox + FreeDOS tools.
>>
File: dickbutt2-1-2-1.png (7KB, 205x220px) Image search: [Google]
dickbutt2-1-2-1.png
7KB, 205x220px
>>61905046
Forgot pic.
>>
I was taught c++ in visual studio but i really dont like the fact it doesn't respect my freedoms.
Is code::blocks a decent alternative if i want to use an IDE?
>>
>>61905042
Kek, I see why that anon wondered if he was a math major now.
>>
>>61903538
>do you have a better idea
there is so much better even useful applications for this kind of thing, and you want to do an epik troll with the reddit dick butt picture
>>
>>61903538
Why not use what we always use, low orbit ion cannon?
>>
>>61905057
Hello brainwashed GPL cuck
>>
>>61903430
how is this not a standard DOS attack?
>>
>>61905112
There are better applications for transferring 1 billion images in 32 hours over http?
Because that is literally my goal.
I'm not set on dickbutt, and I'm open to suggestions, I was also considering the troll face, but it's copyright infringement or something
>>
>>61905168
I'm pretty sure cyber attacks are a much more severe type of crime than copyright infringement.
>>
>>61905129
>>61905156
It's not for DoS, and won't be, as long as I can shrink the pic enough. But whatever it comes to...
>>
>>61905168
>1 billion images in 32 hours over http

wow dude my project is to copy a jpeg image 1 billion times onto a hard drive; simply epic
>>
>making an app that resembles MAL list but with additional features that I personally want
>spend some many hours on the thing but will never be able to put something so cringy in portfolio
>>
>>61903939
you can do
if (error) do_something(); 

you inbred tard
>>
>>61905168
I did your job for you. You can pay me in bitcoins. I have super efficient code right here:
#/usr/bin/sh
for i in $(seq 10);
do
curl -F "[email protected]; filename=dickbutt" example.com
done

Go be a leet hacker now. You're welcome.
>>
https://filippo.io/linux-syscall-table/

how can cpu registers have both signed and unsigned longs passed through them? Even pointers and structures are passed, how come this isn't undefined behavior in C
>>
>>61905290
I didn't even consider curl desu.
I was more thinking about just forming the raw packets. I don't care if it receives the picture.
As long as it sends the request to the server, and the server sends back the packet containing the image, it's good.
I mostly think this is the way due to speed and efficiency. If the image is 700 Bytes, in theory, it can send two per packet.

This traffic will be sniffed, logged, and generally known about, so the traffic going out and in must look like a genuine file transfer. Being caught is part of the plan.
>>
>>61905424
can you use a tripcode so i can identify your posts in the future please
>>
>>61902798
>ask me how I know you're talking out your ass
Are you mentally handicapped? They're aiming to be a systems programming language. It's not me saying they should do that.
I wish hiroshimoot could be more discriminatory and have 4chan posters pass reading comprehension tests. Nothing comprehensive. Just basic shit. Should filter out morons like you.
>>
>>61905443
I'm not sure if I want to
>>
Anyone running a aspnet MVC site with mono? Ive been having a bit of trouble getting it to work on my server. Does mono need any special configuration for MVC web applications?
>>
>>61902437
>the wages are relatively low compared to the bay area tho
bay area prices are crazy
>>
Currently working on learning C

How do you guys structure your general programming directory? I'm not talking specifically to C, but the over arching directory for projects, stand alone code files, etc
>>
>>61905624
ad-hoc
>>
>>61905489
>systems programming language
>MOTHERFUCKING PLANES
dude you are way too vocal on things you don't know about
>>
>>61905624

.git/
build/
include/
src/
.gitignore
CMakeLists.txt
LICENSE
README
>>
>>61905624
My files go to src/, other peoples' files go to lib/. Non-code files go to resources/, and documents go to doc/. Root will have readme.md and git-files. Something like that.
>>
>>61905624
>Open Visual Studio
>Create Project
:^)
>>
>>61905624
.git/
obj/
src/
include/
makefile
>>
>>61898984
>>61898988
>>61898990

>implying that go is trash just because its logo is a squirrel
>>
>>61904458
And yet, you have
int* fun()
{
...
}

and
(char*) otherptr;


Just make it so the * applies to type desu.
>>
>>61905836
That's not the main reason why it's trash but that logo just makes it so much more retarded
>>
>>61905844
It's common for people to write
int *fun()
{

}

I've never seen anyone do that with this style though
int*
fun()
{

}


The cast thing is where it starts to become inescapably inconsistent though.
>>
I need most fucking basic C compiler that can run the program just so I can see if I made any mistakes. I tried to google but most of the stuff I get are online compilers
>>
>>61905904
I don't know why you wouldn't write it like (int *)
>>
>>61905907
gcc or clang
>>
>>61905907
Clang
GCC
MSVC (comes with Visual Studio)
>>
>>61905907
gcc -std=c89 -pedantic-errors should keep you from writing non-standards compliant C
>>
New thread:

>>61905927
>>61905927

>>61905927
>>61905927

>>61905927
>>61905927
>>
>>61905929
>c89
>portable
>>
guys how do you deal with cross platform application?

do you write two entry functions? or do you code them separately?
>>
>>61905939
What language? What kind of project?
>>
>>61905946

cpp, simple 2d platformer game.
>>
>>61905907
tcc
>>
>>61905957
If you use a cross platform library for your game then it should compile on all supported platforms.
>>
File: 1501193265852.png (183KB, 697x713px) Image search: [Google]
1501193265852.png
183KB, 697x713px
>>61905921
>>61905924
>>61905929
>>61905963
>>
>>61905929

Honestly, -std=c11 should be preferred.
>>
>>61905912
(int *)otherptr;

or
(int *) otherptr;
>>
>>61905907
if you're the code blocks guy, your setup uses gcc.
my gcc compiler also complains about lvalues when trying to assign something to the printf function.
>>
>>61904399
NASA's styleguide seems pretty solid to me, with the exception of the fact that they recommend 4 spaces for indentation, rather than a 4 space tab.
>>
>>61905912
I'd write it as (int*) personally. Now int* is the complete type.
>>
>>61905673
C is used in planes and in many other critical real time systems
>>
Trying to read a maze from a text file and save it a char array in Java.
I'm currently getting NullPointerException and I have no idea what's wrong.
public Maze(java.io.Reader fileInput) throws IOException
{
boolean colCounter = false;
ArrayList<Character> buffer = new ArrayList();
BufferedReader reader = new BufferedReader(fileInput);
int readChar;
//Row starts as one to count for EOL.
rows=1;

//Read through file to get rows and columns.
while ((readChar = reader.read()) != -1)
{
if(!colCounter)
{
cols++;
}

if( (char)readChar == '\n')
{
colCounter=true;
rows++;
}

else
buffer.add((char)readChar);
}

Iterator<Character> mazeIterator = buffer.iterator();

for(int r = 0; r < rows; r++)
{
//loop through the columns of each row
for(int c = 0; c < cols; c++)
{
mazeData[r][c]=mazeIterator.next();//NullPointer here
}
}
}
>>
>>61907197
why the fuck are you accessing iterators manually, just use a foreach loop

also
ArrayList<Character>
lmao
>>
>>61907197
what line do you get the null pointer on?
>>
>>61907492
>mazeData[r][c]=mazeIterator.next();
>>
>>61907492
Also get NoSuchElementException sometimes
>>
>>61905673
https://en.m.wikipedia.org/wiki/System_programming_language
Read.
>>
>>61905345
Signed and unsigned are both represented in the same number of bits, its just a matter of how you interpret it when the msb is set.
I believe that integer overflow (often happens when you misinterpret the number) is undefined behavior in C. And this isnt purely theoretical, I have had a situation where constant-folding optimization produced a different expression than the unoptimized version.
>>
>>61905624
/home/anon/Projects <- personal projects, not very much structure here since if I have too many project folders that means I have too many projects and need to drop some
/home/anon/Scratch <- small files in various languages for just testing stuff out and experimenting
/home/anon/School <- schoolwork, school projects
/home/anon/Git <- git repos that arent personal projects. but if im forking and want to make changes then i work in here
Thread posts: 334
Thread images: 30


[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.