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

File: 1480916491815.png (102KB, 1000x1071px) Image search: [Google]
1480916491815.png
102KB, 1000x1071px
What are you working on, /g/?

Old thread: >>58076261
>>
>>58079752
First for D
>>
File: doyouevenlambda.png (29KB, 811x805px) Image search: [Google]
doyouevenlambda.png
29KB, 811x805px
Friendly reminder that Lisp is the greatest programming language with the greatest programming community.
If you are not programming in Lisp, you honestly can not call yourself a programmer.

http://stevelosh.com/blog/2016/12/chip8-cpu/
>>
Should I add exception handling to my program only whenever Eclipse suggests it it?

Or more often?
>>
Fun(ctional) programming discussions:

>>58076404
>>
When I apply for a software dev job, should I link them to my github page? I only have a few Python and bash scripts there.
>>
>>58079835
Of course. Bonus points if you have 4chan projects listed.
>>
>>58079835
Yes, always link your github and your stackoverflow account.
>>
>>58079868
I'm not on PajeetOverflow.

>>58079854
Only this >>58079455

Are you guys actually serious or not?
>>
>>58079898
I would seriously link to the GitHub. I don't have a Stack Overflow, but that wouldn't hurt (assuming you don't ask retarded questions).

>>58079777
looks cool. What's the best Lisp interpreter for Linux?
>>
>>58079898
do you think any anon here has a job?
>>
>>58079898
>I'm not on PajeetOverflow.
Then forget being hired by any startup in the bay.
>>
>>58079835
you should link:

>your github
to see the code you wrote

>your twitter
to see if you're a racist bigot

>your facebook
to see if you aren't a sperg

>your reddit
to see your post history
>>
>>58079930
Steelbank common lisp (sbcl)
>>
File: 667.jpg (52KB, 500x500px) Image search: [Google]
667.jpg
52KB, 500x500px
>>58079794
REEEE why must we split /dpt/ even more ffs?

/dpt/ is slow as it is.
>>
>>58079956
This is our 3rd thread today already.

/dpt/ isn't too slow.

>>58079948
You jest, but someday this may actually be a thing.
>>
>>58079948
>GitHub
yes
>Twitter
no
>Facebook
no
>Reddit
no

They should be able to tell if you aren't a sperg in the interview.
>>
http://pastebin.com/MftqQ6i2

this takes 1sec to run if compiled with visual studio, and >70 sec to run if compiled with g++

any ideas why?
>>
>>58079933
A few of us do.

I love my job.
>>
>>58079956
The haskell autists got mad because you trolled them too much. What they didn't know is that now I know where they went and that they are clustered in one place at the same time.
>>
>>58079973
-O3 ?
>>
>>58079973
Any reason why you #define TEN_MILLION instead of just putting the actual number?
>>
>>58079973
enable an optimization flag in g++
also, do the threads even get started?
some languages you have to explicitly start them after constructing them
>>
WHAT LANGUAGE IS BEST FOR HEAVY COMPUTATIONS

PLEASE HELP
>>
>>58079996
i exagerated the number a bit

the original was
#define SIX_MILLION 6000000
>>
>>58079973
What are the optimization flags for g++? Also, have you thought

>>58080014
C/C++ with GNU Multiprecision
>>
File: luffy-worth-it-meme.jpg (39KB, 600x607px) Image search: [Google]
luffy-worth-it-meme.jpg
39KB, 600x607px
>>58079978
>be me
>dystopian future governed by women
>men chained in silicon mines
>go to the HR chick
>sup! the boss gave me a new job
>"what kind of job?"
>a blowjob
>le troldad_dance.jpg
>>
>>58080014
C++ and CUDA / GPU programming
>>
>>58080025
Easier to read
>>
>>58080044
Is Rust any good?
>>
>>58080025
oy vey
Still, why aren't you just putting the number in the program?
>>
File: 77358154.jpg (69KB, 1000x1000px) Image search: [Google]
77358154.jpg
69KB, 1000x1000px
I'm starting to get really autistic with design patterns and going overboard with simple projects.

What do?
>>
>>58080007
They way he constructed the threads they will launch automatically whenever possible. Read the std lib about threads of C++
>>
>>58080069
KISS
>>
>>58080056
>Rust
oh boy here we go again

https://github.com/rust-lang/rust-www/issues/268
>>
>>58080069
dumb frogposter
>>
>>58080058
What about when you need to redefine the number, such as for the metric system?
>>
>>58079992
yes
>>
>>58080075
>KYS
ftfy
>>
>>58080069
what are some examples? If it makes it easier to read and/or faster, then do it.
>>
>>58080070
word, i use java/python if i want anything with oop and c otherwise desu
>>
File: 1482175719207.jpg (65KB, 1000x1000px) Image search: [Google]
1482175719207.jpg
65KB, 1000x1000px
>>58080079
>>
File: 542140.jpg (13KB, 400x400px) Image search: [Google]
542140.jpg
13KB, 400x400px
>>58080077
The submitter looks exactly like I would imagine
>>
>>58080086
#define METRIC_MUL 420
#define MAX_VAL 10000000*METRIC_MUL

Also, if you need to redefine the number enough, it makes sense to store it as a variable instead of a macro.
>>
File: ?.png (17KB, 900x900px) Image search: [Google]
?.png
17KB, 900x900px
>>58080075
But design patterns make your code easier to maintain desu.
>>
>>58080086
Then the name you chose for it will be wrong which means you have to go over the program again.
I mean I guess it makes sense if you happen to use the same number for different purposes and then only want to change specific occurences. Like when you're calculating the amount of jews Hitler killed, and factor in the number of cocks OP sucks, but then OP goes and sucks another cock so now you have to change all the occurences of 6000000 that refer to cocks OP sucked to 6000001 while leaving the number of crispy jews the same.
But then why would you call that "constant" TEN_MILLION? If you change the value, the name becomes meaningless and indeed confusing.
>>
>>58080147
Until they don't. Like all things, they are good only in moderation.
>>
guys i'm genuinely spooked. i sovled the first 11 problesm (except problem 10) on euler and now i'm realizing i'm only good at brute forcing them. you can't bruteforce the next ones what should i look into for optimization?
>>
>>58080194
just leave the problem running a couple days
>>
>>58080194
A book on programming.
>>
>>58080194
learn lots of theory
problems solved without brute force typically apply some theoretical math and computer science
>>
>>58080210
ya sounds good. actually what i'll do is hack they shit and turn it into a botnet and use millions of parallel computations to do teh massive number crunching!

>>58080211
well most books say syntax.
>>
>>58080194
http://jeffe.cs.illinois.edu/teaching/algorithms/everything.pdf

you can skip the language theory parts
>>
File: cs_grad.png (89KB, 683x433px) Image search: [Google]
cs_grad.png
89KB, 683x433px
>>58080210
>>
>>58080271
it's the KISS solution
>>
Anyone knows how can i install g++ on windows?
>>
>>58080114
But what if you want something that works fast? C++ is compiled and I much more prefer it over C.
>>
>>58080300
MinGW
>>
>>58080290
No it's not. You misunderstand what KISS means. It is not an excuse to be lazy. Far from it.
>>
>>58080271
>13:39:00

in my post it says 19:39:00
>>
>>58080318
It has to run to only once.
Running it for a while is completely adequate and leaves the solution clear and simple.
>>
So i'm trying to open as many TCP sockets as possible in my program, and something is breaking.

When I get to around 537, the program crashes in SDL_net because of "stack smashing". Here's some relevant data from Valgrind
*** stack smashing detected ***: ./a.out terminated
==13234==
==13234== Process terminating with default action of signal 6 (SIGABRT)
==13234== at 0x612D428: raise (raise.c:54)
==13234== by 0x612F029: abort (abort.c:89)
==13234== by 0x616F7E9: __libc_message (libc_fatal.c:175)
==13234== by 0x621056B: __fortify_fail (fortify_fail.c:37)
==13234== by 0x621050F: __stack_chk_fail (stack_chk_fail.c:28)
==13234== by 0x542C675: SDLNet_CheckSockets (SDLnetselect.c:153)


Any ideas?
>>
>>58080317
i already install gcc on my windows, and i can compile c programs just fine, but when i do g++ it says "not an internal command" or something
>>
>>58080271
actually lolled
>>
>>58080334
Why would you even do the Euler problems if you're not trying to improve yourself? Might as well just google the answers. That's truly the simple solution, no?
>>
>>58080335
Either you have a stack overflow or you are writing past the end of a stack-allocated array.
>>
>>58080338
You mean:
is not recognized as an internal or external command, operable program or batch file.
, yes?

You need to add it to your PATH variables.

Locate the .EXE used for compilation, and Google how to add PATH variables for command-line access.

Otherwise, you'd need to type out the fully qualified path to your executable.
>>
>>58080351
i am trying to improve myself and my algos anon.

i'm a homeless programmer self admittedly my shit got stolen and i'm happy because through that i started doing euler at library computer.
>>
>>58080326
>What the fuck is a timezone? Sounds like some communist shit.
>>
>>58080351
I'm not the one doing the problems.

But if someone paid me to do it, I'd just let it run and call it a day.
>>
>>58080378
Did you know that the entire country of China has just one time zone, although it geographically crosses five?
>>
>>58080390
well if they were paying per problem solved then this would not be very efficient because of the time it'd take to get solutions. you'd be better optimizing it == more problems solved, more money.
>>
>>58080396
Yes.

What does that have to do with anything?
>>
>>58080399
I can do other shit while the program runs.
>>
>>58080413
you realize that on euler bruteforcing some of the solutions could take upwards of days? where an optimized algorithm can get the answer in less > 60 seconds...
>>
>>58080390
>https://en.wikipedia.org/wiki/Generic_you

Learn to read, fuckwit, or better yet just immolate yourself already.
>>
>>58080315
i prefer c desu
structs work just as well as classes :^)

also i legit have never used c++ because java and others satisfy my ``legitimate'' oop needs sufficiently well
this is a bit trivial but i fucking hate operator overloading, too
>>
File: IMG_20161219_155931[1].jpg (4MB, 2448x3264px) Image search: [Google]
IMG_20161219_155931[1].jpg
4MB, 2448x3264px
C++ noob here, is this okay code?
Task: Czeck if two short integers have exactly matching digits (repetitions allowed). Print Yes/No accordingly.
Basically put each digit in the corresponding index of a flag variable, then XOR.
>>
File: 12.png (25KB, 970x297px) Image search: [Google]
12.png
25KB, 970x297px
>>58080374
this is my bin folder

there is no g++ exe in this folder
>>
>>58080411
>timezones sound communist
>largest communist country doesn't have timezones
>>
>>58080432
no u

His argument was dependent on someone doing the Euler problems. So it was necessary to point out that I'm not.
>>
>>58080451
nice screenshot
>>
File: d53.jpg (29KB, 600x600px) Image search: [Google]
d53.jpg
29KB, 600x600px
>>58080451
>taking a picture of a computer screen with a camera
>>
>>58080476
>>58080478
I forgot to bring my cable pls no bully
>>
>>58079948
i hate this, everything is too connected, i want to keep real life separate from fracebook, facebook separate from 4chan, 4chan separate from everything else
why does everything gotta run into each other now. people 15 years ago didn't act irl how they acted in chat rooms, nothing has changed
>>
>>58080484
is your computer just not internet-connected?
>>
>>58080476
thanks
>>58080478
yeah, that's literally what "screenshot" means
>>
>>58080500
They shut it off, too many noisy freshmen. Yes, university we're talking about.
>>
>>58080500
no, he forgot the wifi cable
>>
>>58080500
Yes, university shut it off. too many noisy freshmen.
>>
>>58080508
lmao what...who the fuck shuts off the internet
>>
File: ebin.gif (2MB, 320x240px) Image search: [Google]
ebin.gif
2MB, 320x240px
>>58080525
>>58080508
>>
Whats the outlook/expectations for entry level no-college people in more normal programming jobs? (as opposed to web-dev where you can get a job easily with a pretty basic portfolio and maybe studying for a couple months if even that)
>>
>>58080457
it's easy to setup g++, follow my steps:
1) put this code in g++.c
#include <stdio.h>

int main(int argc, char** argv){
printf("Hello world\n");
return 0;
}
[code/]
2) then run this command:
gcc -o g++ g++.c
3) optional, add the directory containing g++ in the path (refer to your OS manual)
>>
>>58080525
who the fuck shuts off the internet... lmao what
>>
>>58080457
What in Satan's holy name do you think cpp.exe is? Communist Pool Party?
>>
>>58080451
There's no reason to use &Num over Num, is there?
>>
>>58080544
1. that's C code. not C++ code
2. i think don't have g++ installed on my computer
>>
>>58080194
I got to about 60 a couple of years ago with no CS, math or algorithm knowledge.

Just brute force it, and if it's not fast enough, profile.
>>
>>58080565
>that's C code. not C++ code
it is both you fucko
>>
>>58080562
lol

that might be
>>
Can someone explain REST to me?
I don't get it.
>>
>>58080565
you need to compile g++ optimized for your machine
>>
>>58080460
China is not a communist country.

Their ruling party is called "Communist", but oddly enough does not represent communism.

>>58080508
>They shut it off, too many noisy freshmen.
What the fuck
>>
>>58080593
OK, but I need you to lay down first.
>>
>>58080601
Columbia bro?
>>
what would be a good way to name generic objects in java?

i have a loop, where every loop creates a new object.
>>
>>58080597
Yeah, I too agree that it hasn't even been tried yet.
>>
>>58080562
>cpp.exe sdf.cc
> cpp.exe: error: CreateProcess: no such file or directory
>>
>>58080526
>>58080545
>>58080597
What's surprirsing about shutting the internet off
>>
>>58080621
>i have a loop, where every loop creates a new object.
why
>>
>>58080621
just name it paash
that's loop in your language
>>
>>58080636
In Soviet Russia, internet shuts YOU off.
>>
>>58080457
install g++entoo
>>
>>58080622

he is right when he says that the chinese communist party is communist in name only.

china had the largest explosion in private wealth of any nation and actually less state intervention into the economy than the US.
>>
>>58080636
>What's surprirsing about shutting the internet off
the internet is a basic human right, bro
what fucking country are you from lmao
>>
>>58080643
>>
>>58080624
cpp is "C preprocessor"
>>
>>58080636
Why in the world would you ever shut off the internet in a library, office, or living space?

Some people might actually be doing schoolwork, or even freelance programming, or skyping with their father who's stationed in Afghanistan.
>>
>>58080639

each line of my file contains information about a chemical product.

each time a line is read, the information is stored into a new "chemical" object.
>>
>>58080650
>less state intervention into the economy than the US.
That's not really anything surpsing
>>
>>58080653
>>58080664

Bulgaria lol its like 5mbps for the whole building so. They tried teamviewer once and everyone ketp spamming the Quran.
Get me out of here
>>
>>58080622
Yeah, yeah, I get the meme, but China's government is not and cannot be described as "communist".
>>
>>58080674
What meme? Are you implying it has been tried? What a retard.
>China's government is not and cannot be described as "communist".
Obviously, that would imply that it has been tried.
>>
File: pepe dabs.png (66KB, 554x400px) Image search: [Google]
pepe dabs.png
66KB, 554x400px
>>58080673
>Bulgaria
understood
>>
>>58080670
It certainly is surprising, and should challenge your worldview, if you're under the impression that China is "communist".

>>58080665
So what's the problem?
>>
>>58080450
I must admit. I really like C++ and I spent a lot of time learning it. But until now I have never actually used it for anything.

Don't see anything wrong with operator overloading. After discovering that I wish Java has it.
>>
>>58080714
java is c++ for retards, don't even have pointers
>>
>>58080450
>but i fucking hate operator overloading, too
You must hate fun
>>
>>58080764
what is that javascript?
>>
>>58080764
what is that python?
>>
>>58080806
C#
>>
>>58080694
What would you describe it as?
>>
>>58080806
>>58080814
>>58080815
It's Haskell, idiots.
>>
>>58080815
As a career backup plan, should I learn C# or Javascript? Is there anything to be done other than webdev?
>>
>>58079835
link your github here
>>
>>58080830
Either would give you a fuckton of jobs, but if you do Javascript, you're stuck in webdev world.

C# is not primarily webdev, and is mostly used in app backends and automation/data movement/CRUD things.
>>
anything wrong with this?
it should work, amirite?

String dataArray[] = line.split("\t");
>>
>>58080830
Yes C# can be used to develop desktop applications on Windows and mobile apps on Windows Phone.

And they are working on a Linux implemention. Read up about Mono if you are interested.
>>
>>58080867
Shouldn't that be
String[] dataArray
?
>>
>>58080867
specify the language
>>
>>58080884
Both are possible in Java but the one you wrote is prefered.
>>
>>58080860
>>58080875
Any beginners book you can recommend that's not just pages of academic fine print?
>>
>>58080888

java

>>58080884

no clue, but that looks better
>>
>>58080905

>>58080884
is correct

the brackets go with the type in java, not the identifier as some other languages do
>>
Studying for my exam.

Ask me this:
How important is it to know what a "complete" tree is?
>>
>>58080875
>And they are working on a Linux implemention.
.NET Core literally comes installed out-of-the-box on Red Hat Enterprise Linux now.

.NET Core is a lightweight (open-source and cross platform) version of the .NET Framework. Right now the APIs aren't as wide as the .NET Framework, but .NET Standard is going to bring it more in-line, with really just platform-specific things being left out.

>>58080900
http://www.robmiles.com/c-yellow-book/

Free PDF on page, plus code samples, great book for any newer programmer.

It's much more practical-focused than the masturbatory SICP.
>>
>>58079752
Writing a Python script to write a C++ header file.
>>
>>58080926
>http://www.robmiles.com/c-yellow-book/
Ok thanks man
>>
>>58080924
...it takes two seconds to look definition up.
>>
>>58080194
Try harder.
>>
>>58080924
First year discrete math?
Nigger learn that shit, it's all basic.
>>
>>58080977
Data structures.
>>58080949
>>58080977
I know what a complete tree is, I'm just wondering how often the term comes up in the field. IMO the only definition in my mind worth knowing is if it is balanced.
>>
>"AssertionError: Expected {} got {}."
fucking javascript
>>
>>58081000
Heaps are complete binary trees.
>>
>>58081013
{} != {}

they are different objects

what was the context?
>>
>>58080822
Let's see:
>production quantities are not primarily state-controlled
>you literally have to pay for basic schooling, like elementary school
>people have private property
>you work for a wage that you can spend on things
>things such as insurance are not forced
>companies that are state-owned are operated as sovereign entities and do not distribute their wealth

China is capitalist as fuck, with some authoritarian sprinkled in.

It's really a market-economy with socialism mixed in.

>>58081013
You must provide the correctly-gendered {}, anon.
>>
>>58080900
I'm sorry can't help. I havent studied C# myself.
>>
>>58081000
That's not your problem. Your problem is you're being a little whiny cunt and clearly not interested enough to invest 30 minutes a day towards your profession.
It's expected of you to learn everything in your books, and then some, so do it.
>>
>>58080926
Didn't know there was already a working version on a linux distribution.
>>
>>58081033
yeah i know, just looked weird as shit is all
>>
>>58081027
Heaps are balanced trees. It does not matter if it is complete or not, it is just resultant from the heap rule.

>>58081046
I do study the materials, I am just asking why such a definition is important.
>>
>>58081076
Because it's a fundamental term. Everything on the level I assume you are at is.
>>
>>58081038
>people have private property
If you think a land grant saying you can have some property for 70 or so years is the same as private property then sure.
>It's really a market-economy with socialism mixed in.
Wouldn't really call it "mixed in" but I guess.
>>
>tfw i always talk shit about vim on /g/ but i actually enjoy using it
>>
File: dotnet-tomorrow.png (98KB, 1581x853px) Image search: [Google]
dotnet-tomorrow.png
98KB, 1581x853px
>>58081057
Mono has been working on Linux for years now, and meets virtually all of the functionality of the .NET Framework as they add features to .NET.

I believe it was over two years ago that Microsoft started paying their devs to contribute to open-source projects like Mono.

Mono is actually what Xamarin runs off of, and when Microsoft bought Xamarin they made it free and open-source. It used to cost $1,000 for one year of a dev license.

.NET Core actually had its 1.0 release earlier this year, but has been in a working state for quite some time. I personally am waiting to use .NET Core for when they drop .NET Standard 2.0 (pic related), because this means PCLs will be MUCH easier to develop (libraries that will work with any flavor of .NET on any platform).
>>
>>58081076
Knowing that a heap is a complete binary tree simplifies its array representation.
>>
>>58081110
how is performance compared to java?
>>
>>58081111
Thank you, a reason.
>>
>>58081110
Mono is a lot slower than .NET core IIRC.
>>
>>58081119
>>58081123
I'm pretty sure Java is faster for raw number-crunching than either.

I'm not sure though; I haven't seen any recent benchmarks, and .NET Core is very new, so I suspect there's massive improvements to be made.

Although, if you need speed in a particular situation, I'm not sure why you wouldn't just use a C/C++ library to do the heavy-lifting.

Different tools for different jobs.
>>
>>58081119
bad. very bad.
https://benchmarksgame.alioth.debian.org/u64q/csharp.html
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=csharpllvm&lang2=java
>>
File: assbuttz.png (127KB, 751x1731px) Image search: [Google]
assbuttz.png
127KB, 751x1731px
>>58081119
>>58081123
>>58081167
Looks like they're pretty on-par, depending on the test.

Not pictured is one that Java wins out by a longshot for
regex-dna
, so I'd imagine that's a very specific optimization that works better in the JVM.
>>
>>58081167
>C/C++ library to do the heavy lifting
see
>>58080037
>>
>>58080929
I want to do this, but it just seems a bit too difficult to make. There's just too many catches to add in.
>>
>>58081192
.NET core has comparable performance to Java but suffers from a lack of libraries on Linux, while Mono has those libraries but is much slower.

I think it'll be a few years before C# development catches up to Java on Linux.
>>
File: wtf-girl.jpg (23KB, 599x327px) Image search: [Google]
wtf-girl.jpg
23KB, 599x327px
> dot net
> on unix
> not Vala
>>
>>58081192
>>58081192
Why are the CPU loads so uneven?
>>
File: 1452073157348.png (769KB, 1052x1342px) Image search: [Google]
1452073157348.png
769KB, 1052x1342px
>>58079752
GUYS, my mind is boiling inside from this dilemma.

char in c is stored on only one byte
but we have 4 byte word each time on a 32 bit machine.

technically we can't have the adress of every character, so four successive characters must have the same adress, then we need other offset info to access the right one.

am i wrong here ?
for example

0x40028000 :| char1 | char2 | char3 | char4 |

0x40028001 :| integer |


how can i refer to char2 here ?

with integer it's easy since it takes 4 bytes so the adress of this integer is 0x40028001
but with the others i'm clueless.
>>
>I have a phone interview in 3 minutes.

What should I study to prepare?
>>
>>58081227
>technically we can't have the address of every character
a pointer points to one byte, not the standard word size. This is why memory is capped at 4GB for 32-bit systems
>>
>>58081239
rub one off instead
>>
>>58081246
beat me to it
>>
>>58081227
Address size is still a byte.
>>
>>58081246
ok so how i declare a pointer ptr to a shared memory adress of sizeof(char[10])
and how do i increment it to access each char (byte) at a time

| char | char | char | char | char | char | char | char | char | char | <---- shared memory of size 10 bytes
>>
What is faster than
-Ofast -march=native
>>
>>58081239
>Do you know how to fizzbuzz?
>Is the interview for Haskell? If not, it's not worth your time.
>Be sure to be formal and if it's a woman, address her as M'lady
>Have a solid handshake
>Talk about that one time you and your buddy caught a fish that was *this* big and extend your arms forgetting that this was a phone interview
>>
>>58081227
Addresses are still byte-by-byte.
With integers, you just (usually) have to store them in addresses divisible by four, so you get:

0x40028000 : chars
0x40028004 : integer

It can be crucial when compounding data in structs, like, you can't make such a struct
struct a{
char b;
int a;
}
Because if the struct is stored at 0x40028000, corresponding address of int would be 0x40028001, and that's not permissible, because you can't divide 0x40028001 by four.
>>
>>58081285
char *ptr = &(array[0]); // or just array
for(int i = 0;i < 10;i++){
printf("%d\n", (int)*ptr);
ptr += sizeof(char); // char is defined as 1, so this is redundant
}
>>
>>58081288
Using PGO.
>>
>>58081288
> -ffloat-store
> -fexcess-precision=style
> -ffast-math
> -fno-rounding-math
> -fno-signaling-nans
> -fcx-limited-range
> -fno-math-errno
> -funsafe-math-optimizations
> -fassociative-math
> -freciprocal-math
> -ffinite-math-only
> -fno-signed-zeros
> -fno-trapping-math
> -frounding-math
> -fsingle-precision-constant
> -fcx-fortran-rules
>>
>>58081307
Just do ++ptr it will increment it with the correct amount.
>>
>>58081288
Branch prediction and data prefetching
#define likely(x)      __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

This tells GCC to organize the code so more of the likely branch is stored on the cache than the unlikely branch. This can be a lifesaver for tight loops (used this in tight loops, 50% speed increase).

I haven't had much success with branch prediction, since GCC seems to know what is going on, but if you know for sure that data is going to be needed before it is accessed, then consider looking into it

Of course, inline assembly with special instructions is probably a lot faster than compiler optimizations, but that takes a lot of background knowledge.

On a slightly unrelated topic, look into Valgrind's cachegrind and kcachegrind for profiling.
>>
>>58081307
i'm stupid
i thaught
0x40028000 + 4 bytes = 0x40028001
>>
>>58081399
>!!x
>>
>>58081402
how to hell would you otherwise address byte sized primitives
>>
>>58081410
It doesn't matter
>>
>>58081307
Hold up, if it was array of integers, would ++ptr increment by 1 or 4 bytes?
>>
>>58081419
that why i was confused.
>>
>>58081422
++ptr always increments by one byte
>>
>>58081399
>>58081353
>>58081343
Ok thanks, I'll look futher into that.
>>
>>58081433
So how does ptr[<constant integer>] work then? Why does ptr[1], ptr[2] and so on give me the correct respective cells in said array?
>>
>>58081433
no, if it's an int* ptr it will increment by 4 bytes

char* ptr will increment by one byte
>>
>>58081433
No
++ptr increments by sizeof(type_the_pointer_points_to) bytes.

>>58081456
Don't listen to him.
>>
>>58081458
>>58081467
Thanks for this
>>
>>58081288
If you don't care about precision too much and you know that the data won't go beyond a point, don't use larger types. You can use uintX_t and intX_t to do this. The less wasted space you have, the more data can fit on the cache at one time.
>>
>>58081410
?
>>
File: sad yui.jpg (28KB, 467x700px) Image search: [Google]
sad yui.jpg
28KB, 467x700px
>spend all night working on project
>go to bed
>dream about me sitting at my computer working on project
>oh shit i'm so productive i improved so many things
>wake up
>dream version of project was just different enough to prevent any progress from being copied over to your IRL one

Why can't I just dream about being an anime girl like everyone else?
>>
>>58081576
>he doesn't lucid dream
I'm sorry for you.
>>
>>58081489
today caches have a word size of 64 bytes. tard.
>>
>>58081592
Lucid dreaming is a fucking myth
>>
>>58081605
You're a dumbass.
>>
>>58081612
It isn't though, why the fuck would you think it is?
>>
>>58081612
No, it objectively isn't, and I'm someone who does remember many dreams from his life.
I can personally know when I've taken control of a dream.
>>
Hey I was the guy to ask about pointers in C++ a couple threads ago
thanks to the people who responded.
>>
>>58081778
No problem, we accept blowjobs as payment
>>
I need to define an interface for image filters, but I can't find one that adequately meets the needs of all filters.

Some filters take in multiple images, some take in options that aren't simple values (they may be arrays).

Not sure what to do, exactly.
>>
>>58081990
>filters are objects
why
>>
>>58082004

poopject oriented poopgramming.
>>
>>58081990
Use Factory pattern
>>
>>58082031
Filters should be functions.
>>
>>58082059

They are, right now, but the file is closing in on 1 billion LoC.

>>58082045

Go on.
>>
>>58082004
>>58082031
>>58082045
>>58082059
filters should be matrices
>>
>>58082073
If they are, then why do you need to make an interface?
Just have a bunch of functions and that's it.
>>
>>58082082
filters should be runtime ASM
>>
>>58082073
>but the file is closing in on 1 billion LoC.
Hyperbolic?
Regardless the count isn't an issue.
What's your real issue?
>>
File: 1480390918873.jpg (108KB, 677x529px) Image search: [Google]
1480390918873.jpg
108KB, 677x529px
>>58082082
>>58082089
>>58082095

Why did I even bother?
>>
>>58082116

Well, it sort-of is, because C# doesn't have free functions, so the definitions either have to occur in partial classes, which are hacky, or together, which is shit.

So I'm just going to kms, senpai.
>>
File: martin-shkreli.png (251KB, 500x375px) Image search: [Google]
martin-shkreli.png
251KB, 500x375px
>>58082136
>because C# doesn't have free functions
What a fucking meme
>>
>>58082145
Is this the guy everyone is calling as moot?
>>
>>58082119
>wahh i dont know what to do
>Here's what you should do
>wahh
>>
I wrote a PKGBUILD patch for FVWM+ since the AUR package was just not working at all. Can anyone check if it's correctly done? I learnt about 10 minutes ago how diff works, so I don't know if I did it correctly.
http://pastebin.com/Bh2bYNd0
>>
whats the best sublime color scheme
>>
>>58082400
Install gentoo and then vim
>>
>>58081886
Wow try to be nice
Thought dpt might be different
>>
>>58082411
no
>>
>>58080300
MSYS2 lets you easily install and use both 32 and 64-bit Mingw compilers.
That would probably be the best way.
>>
>>58082356

All of the suggestions were shit.
>>
is it possible to make it so that Python doesn't check global variables inside a function's namespace?
>>
>>58082429
I don't understand. Why would you do something stupid when you could reach perfection?
>>
>>58082427
what
>>>/reddit/
>>
>>58082473
Really? You can't just make your filters each a functoin? I was pretty serious about that.
>>
File: output.webm (2MB, 526x310px) Image search: [Google]
output.webm
2MB, 526x310px
Working on my terminal emulator, still dicking around with sixel support to improve performance where I can.

In the meantime, have some OpenGL basic example running inside my terminal using sixels as renderer target.
>>
>>58082504
i have work to do
>>
>>58082534

If this were C or C++, I'd do that.
>>
>>58082540

Disgusting. [spoiler]actually neat[/spoiler]
>>
>>58079752
This is a god damned curse.
>Be programming for 2 years on and off in small projects, really really enjoy doing it, genuinely want to work this the rest of my life
>Get my GED with honors, but in order to go to college I have to take an entry exam without a calculator, which the calculator was the sole reason I even passed the math portion at all
>Already forgot alot of algebra and I'm scared as shit to take the exam and bomb out
>Too inconfident in my abilities to start freelancing, afraid I'd just bite off more than I can chew.
>Completely out of projects to do - can't think of anything interesting or fun to write.
>Out of all the careers, I had to be stuck with one that required me to combat my shitty math skills head on
It's either this or nothing though. I'm not able to see myself doing anything else. Please help. How do I do this shit?
>>
>>58082540
meh
>>
>>58082575
Can't you literally just put static functions inside of a class? Christ.
>>
>>58082645

Yes, that's how I'm currently doing it. That ends up having to be in one file.
>>
>>58082641
Like, surely there has to be people here who made a break into programming careers without fucking college right? I don't want this fucking math. I want to fucking study PROGRAMMING god damn it. I have been studying math every fucking day for the past week. I don't want this.
>>
>>58082717
you don't need college to be a programmer
but honestly, if you struggle with basic mathematics it's not a good sign
>>
>>58082641

I got your back anon. You need to start at the most basic level and work your way up. I would recommend this GRE algebra material (It's basically highschool algebra).

https://www.ets.org/s/gre/accessible/GRE_Math_Review_2_Algebra.doc

Sparknotes' algebra guide is pretty decent as well.

http://www.sparknotes.com/testprep/books/gre/chapter2section2.rhtml

>>58082717

You need math, it's important to at least know up to calculus. Funny thing is that I'm at the precalc level. Just take it slow. Make a promise to do at least 3 practice problems a day.
>>
>>58082683
OOP was a mistake
>>
>>58082683
...Oh.
Could you make a class that loads all of the static functions defined in other classes into itself with reflection? I don't know much about reflection (or C#) but it seems like you're in a pickle
>>
>>58082683
In your build file (Make or whatever), cat all of the functions together into one class, and THEN compile it
This way they can be written in different files but compiled as one (-;
>>
>>58082082
In a linear space yes, in general they are maps from an space to another
>>
>>58082739
I've heard that math is not necessary for EVERY programming position. Math skill is very valuable for game engine developers because of the complex rendering and shit. But to me, some faggot who writes Python shit and Flask web development stuff, is it all that necessary? I've never needed more than just basic shit in any of the things I've made. Not even when doing memory manipulation.

>>58082736
It's not the basic mathematics though, it's this fucking bullshit with Algebra, fucking Geometry, all this shit. I did Algebraic equations fine for the most part during my GED, and I was OK on Geometry, but that was two months ago and I've already forgotten a bit of it from misuse. I've studied up again and I've reclaimed what bit of skill I have, but I just lack the fucking mindset to do inner calculations on the fly. It makes me stress the fuck out over the test because I'd have to actually sit and do the calculations by hand.

https://secure-media.collegeboard.org/digitalServices/pdf/accuplacer/accuplacer-texas-success-initiative-assessment-sample-questions.pdf
Most of the fucking algebra ones I was fine on in this, but the Geometry is really fucking with me. Also I couldn't do ANY of it witthout my calculator. Otherwise I'd be sitting here artistically counting fingers.

I just fucking hate this shit. I want to do programming and not sit here all day doing math problems.
>>
What is the fastest multi threaded Makefile (GNU Make)?
>>
>>58082799
It really depends on what you want to do. I you for example want to program image processing you will need matrix and vector mathematics.
>>
>>58082799
>I just fucking hate this shit. I want to do programming and not sit here all day doing math problems.
then what's the point of going to college for a comp sci or comp eng degree, then?
you'll never get through it because it's a fuckton of math
I took just as many math classes as computer science classes
>>
What's the best way to keep a data structured sorted when only one value is changed at a time?

I'm thinking about using bubble sort on an array but isn't anything better?
>>
>>58082799
Sorry guys, I'm late.

What you're looking for is called web development. ¨.>
>>
>>58081990
>Some filters take in multiple images, some take in options that aren't simple values (they may be arrays)

So have them take a vector of void pointers. Problem solved.
>>
>>58082834
I would take the value out of the list, change it, and re-insert it with quicksort. An initial sort has to happen to get everything in order, and this only works on one item at a time, but this seems to be the best way for small numbers of data.
>>
>>58082746
>>58082763

Pls no bully

>>58082751

There are some tricks I could do for 'plugins' without requiring a unified interface.
>>
>>58082834
How do you need to access this array?
>>
>>58082829
See, that's why I don't want to go at all. I don't want to sit in college for four years racking up debt with a big chance of falling into major depression and dropping out.

But I feel like I have to because I don't see any other way to get a job doing programming. I'm too paranoid to do freelancing and I'm not sure where to look for jobs that don't require degrees. Plus, I can't think of any projects to put on a repo somewhere.

The longer I sit here doing nothing, the more I feel like a failure too, because my brother already is a dropout that does nothing all day. I feel like I have to step up and succeed where he failed.
>>
>>58082855

C# actually has facilities for that, so I could. Do not tempt me.
>>
>>58082882
first of all go to a free college
because the college you go to doesn't matter at all for a comp sci degree (unless it's MIT or other top school)
the reason is because almost all employers ask for "bachelors degree or equivalent experience", and they don't care
>>
>>58082809
A unity build will be faster anyways.
>>
>>58082954
Directories have their own unity builds (input, net, video, etc.), but I have a five other cores that aren't being used, and I want to speed it up if I can.

I will try one unity build to see what happens
>>
>>58082862
>for small numbers of data
I need this to be able to scale properly with higher numbers of data.

What I'm playing to do right now is everytime an item is changed, compare it with adjacent items and swap if necessary. It's O(1) no matter the size of the array but the sorting isn't guaranteed to always be in the right order (which I'm fine with it)

>>58082873
I need to sequentially read the first n entries, others are ignored. I'm not using a buffer since entries can go back and forth from the top position.
>>
>>58082997
>I need this to be able to scale properly with higher numbers of data
As long as you aren't adding large chunks of the array at a time (above 20%, but I have no math proof), then you should be fine. Inserting them one at a time is insanely fast, and you can iterate over all of the data you want to insert into the array.
>>
>>58083064
Well, I might have been overthinking it I guess
>>
>>58082921
by free do you mean a community one? That's what I'm trying to do, but I have to take this stupid fucking entry.

And I'm not sure if this one is free because I'm applying for some aid.
>>
>>58083241
depends on your state and family income level and such, so not necessarily only community colleges are free
for example, TAP + Pell grants paid for my tuition and all my books and also paid me extra money every semester
>>
>>58082884
Have them take their parameters in their constructor. Problem solved.
>>
File: 1482085176868.jpg (370KB, 496x700px) Image search: [Google]
1482085176868.jpg
370KB, 496x700px
So if I were to try to get into Computer Science WITHOUT college, how would I do it?
>>
>>58083400
wikipedia, /dpt/, library genesis (libgen), project euler has been nice, basic language references/library documentation (standard java api has extremely good documentation)
>>
>>58083400
learn php, python, and sql
learn mysql, mongodb
learn javascript, node, django
learn wordpress, magento, woocommerce, volusion
and then make and add features to websites for people
>>
>>58083432
No what I meant was: How would I get a JOB without college? Although I appreciate the references. I'll be sure to go look up libgen. Never heard of that one.
>>
>>58083456
haha fuck sorry m8; yeah libgen is pretty sweet it's an publicly accessible illegal library of a shitton of books & articles
>>
>>58083453
Well let's see:
I know Python, SQL, MySQL, Javascript(I hate this language), Django(although I prefer Flask), and I know some Wordpress.

Now back to the freelancing thing: I'm just paranoid of not being able to do something and wasting everyones time.

How do you decide if you're ready for freelancing?
>>
>>58083456
Build a portfolio. Write libraries, make video games, master fizz buzz, etc. At the end of the day, employers care more about skill than education, but you have to prove it and without a degree you have to prove it twice as hard.
>>
File: present.png (51KB, 289x291px) Image search: [Google]
present.png
51KB, 289x291px
what's in the box?
>>
>>58083498
they post the job and you get to read the description before you bid on it
so just pick easy ones at first if you're unsure
>>
>>58083520
2500 BP
Eh, at least it's not useless upload credit
>>
>>58083520
fuck wrong thread im so sorry guys
>>
File: 1443574971582.gif (3MB, 320x180px) Image search: [Google]
1443574971582.gif
3MB, 320x180px
>>58079752
>What are you working on, /g/?
pirating and installing Ubuntu B-)
>>
>>58083513
That's the easy part then. Specifically, are there places to look for jobs though? Like sites? Should I just seek out specific companies and throw my application at them on their site rather than going to places like say, Indeed or whatever meme job site there is these days?
>>
What's the difference between :

eval(input())
and
int(input())
?

Google doesn't really tell much except that eval is a security risk, but both do the same thing I guess.
>>
>>58083453
>mongodb

Don't tell him to learn this disgusting abomination made by people who don't understand data, for people who don't understand data. Mongo needs to die already.
>>
>>58083676
eval() takes whatever it's given an executes it as straight code.
So I could pass
os.system("rm -rf /")
and it would execute it.
>>
>>58083676
what?
eval will treat the thing like a piece of code and execute it
int will cast to integer
>>
>>58083709
>>58083712
Makes sense, thanks.
>>
Is it possible to program in Australia?
>>
>>58083878
No. Their internet is too shitty.
>>
Any easier way to check a file extension than looking at the last 4 chars? (.pdf is what I'm doing that's why only 4)
>>
>>58083946
many language have a standard string feature like
filename.endswith(extension)

if you really want to be sure of the filetype, read the contents
>>
>>58079752
>What are you working on, /g/?
A manga organizer akin to HappyPanda in [spoiler]rust[/spoiler]
>>
Does learning C prevents from being a code monkey?
>>
>>58084029
Sure. But you need to learn a bit of assembly as well.
>>
>>58083676
which version of Python?

if it is 2, input does an eval() too
>>
>>58079777
Learning LISP has changed the way I look at all other languages, it's so clean to think and work with

>>58079948
>twitter
>facebook
>reddit
tfw security oriented thus not having these makes sense
>>
>>58084073
How much is enough?
>>
>>58083498
just do it anyway
>>
>>58083946
If you're using a real operating system you can just check that magic number in the files header. no need for any of that.
>>
>>58084213
this works fine but it incurs a pretty huge overhead compared to just checking the basename
>>
>can't every think of things to code
>mfw never going to improve
>>
I downloaded a pack of 2800 files and for whatever reason the owner titled them in the format "XXXX - " and I need a basic script to rename all of them, I don't know much code, I tried this

@echo off 
setlocal enableextensions enabledelayedexpansion
for %%i in (*)
do (set name=%%i && ren "!name!" "!name:~7!")
endlocal


but it didn't work out. Can you guys help me out?
>>
New thread:

>>58084335
>>58084335
>>58084335
>>
File: sorting algorithms.png (494KB, 1366x751px) Image search: [Google]
sorting algorithms.png
494KB, 1366x751px
https://youtu.be/M0cNsmjK33E?t=307

>std::sort(gcc) = 16821 comparisons, 28348 array accesses
>Radix Sort (LSD) = 0 comparisons, 6300 array accesses

>A Radix Sort implementation is incredibly more efficient than a standard library sorting method


How can a standard library sorting algorithm be so bad? Aren't they supposed to be the best choice in almost any situation?
>>
>>58084368
Radix sort works well if the range of allowed values in the array to be sorted is small, as is the case in these examples.
>>
>>58084174
Enough to be able to read some hand-written assembly and sort of figure out what the hell is going on.
>>
File: barb.png (750KB, 1096x607px) Image search: [Google]
barb.png
750KB, 1096x607px
Decided to refactor my 3x3 convolution into arbitrary NxN convolution. Works well, but still slow. This is a 5x5 smoothing kernel with a divisor of 83 on noisy barb.

Interesting artifacts on the edges since there's no wrap or extending, pixels are just excluded.
Thread posts: 316
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.