[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: 320
Thread images: 34

File: 1480590811928.png (389KB, 934x1000px) Image search: [Google]
1480590811928.png
389KB, 934x1000px
What are you working on, /g/?

Old thread: >>59423393
>>
>>59430383
Thank you for posting an anime image.
>>
Why FP is so popular here?
>>
C is the best programming language.
>>
Is it better to learn Java or JavaScript?
>>
>>59431083
Both.

Java is a wonderful beginners language while C is a step up.

It's how I learned at UW-M.
>>
>>59431083
Java, certainly, it's not a scripting language unlike JavaScript.
>>
>>59431083
Javascript is good for frontend on that part as well.
>>
>>59431114
What's UW-M?
>>
>>59430928
It's mostly memes. No one actually does shit with FP no matter how much they shill it. Compare the amount of posts referring FP in dpt to the amount of posts with actual FP sources in it.
>>
File: 1442770342893.jpg (91KB, 636x410px) Image search: [Google]
1442770342893.jpg
91KB, 636x410px
Does there exist some JVM assembler or C?
>>
>>59431245
https://github.com/Sable/jasmin

It's in the Debian repositories as "jasmin-sable".
>>
>>59430383
>What are you working on, /g/?
Managed to read to and write from GPU memory now. It's a bit hacky, because I needed to rush things in order to meet the deadline for a bet I had with a friend.

https://github.com/enfiskutensykkel/ssd-gpu-dma
>>
I want to make easter egg mini game for my website. Should I go with pure JS?
>>
>>59431612
What's the pure JS?
>>
>>59431083
JavaScript if you want a job without a college degree. Java if you're going to go to school for computer science.

Java is a fine language, but unless you have a college degree, you'll have to compete with college grads for jobs (since that's what universities teach.)

JavaScript isn't taught (well or at all) in most universities, but is high in demand, so the competition isn't as bad.
>>
File: 1450826579222.jpg (146KB, 589x900px) Image search: [Google]
1450826579222.jpg
146KB, 589x900px
What's the meme around C last days?
>>
>>59432516
>pic
I'm hard
>>
>>59432536
Welcome to /g/
>>
Haskell
>>
Just named my websocket server project "rainbowsocks"
did I do good /g/
>>
>>59430383

Nothing

Nothing at all

Everytime I open my editor I can't bring myself to do anything. I used to go 12 hours a day at this shit.

Is this burnout?

I am literally good at nothing else in my life, what to do now I don't enjoy programming anymore?
>>
File: trap programmer.jpg (2MB, 1700x2470px) Image search: [Google]
trap programmer.jpg
2MB, 1700x2470px
>>59432672
Yes
>>
>>59432677
look for what you ACTUALLY enjoy doing
>>
>>59432707
<3
>>
>>59432677
>he doesn't take citalopram
>>
>>59431863
JavaScript. No jQuery, site itself is on Angular.
>>
File: $001.png (653KB, 564x394px) Image search: [Google]
$001.png
653KB, 564x394px
help
>>
What's the best PL and why is it OCaml?
>>
dist += board[i][j] == 0;

Java didn't like this, and casting the boolean to an int didn't work either. How do I add 1 to dist if board[i][j] == 0 without using an if-statement?
>>
>>59432960
man stdlib.h
>>
>>59433003

Switch to C you fucking plebrainlet.
>>
>>59433003
ternary operator
>>
>>59433003
If you really want to write shit code u can do:
dist += (board[i][j] == 0 ? 1 : 0);


Dont know if u need parenthesis.
>>
>>59433095
>>59433089
Thanks.
>shit code
Because of readability?
>>
>>59432970
>no dependent types
>no HKTs even
It's fucking garbage. Wouldn't even call it a language.
>>
>>59433145
t. brainlet
>>
>>59433141
Magic numbers. No one knows what that "1" or "0" really means.

You should write it like:
int One = 1;
int Zero = 0;

dist += (board[i][j] == Zero ? One : Zero);


Because the values for One or Zero might change later to fit your business needs.
>>
>>59433177
I'm not the one using a deficient language.
>>
>>59433198
>Magic numbers. No one knows what that "1" or "0" really means.
Are you trolling or retarded on purpose?
>>
>>59433288
Yeah, good luck to you when you need to assign 40 instead of 1 later; you can just change the value now and it will update your formulas.
>>
>>59433250
You're the one who's mentally deficient though.
>>
>>59433345
Are you sure you aren't mistaken? Only someone mentally deficient would use a deficient """""language""""" such as OCaml.
>>
>>59430928
FP is really good, which is why for the past 10 years most languages have moved towards it
>>
>>59433411
Sure thing my brainlet """"programmer"""" friend.
>>
File: 540.png (118KB, 657x527px) Image search: [Google]
540.png
118KB, 657x527px
TUMBLING DOWN
TUMBLING DOWN
>>
>>59433653
What does this post have to do with programming, you fucking retarded stupid fucking frogposter who should fucking kill himself?
>>
File: 1486396299203.jpg (124KB, 882x731px) Image search: [Google]
1486396299203.jpg
124KB, 882x731px
>>59433724
I'm making a game
>>
File: 827.png (250KB, 680x638px) Image search: [Google]
827.png
250KB, 680x638px
Those peaceful people devoted their time to the brewing of ale, the smoking of herbs and the posting of pepe
>>
>>59433603
What kind of stupid question is that?
>>
File: probability plot.png (25KB, 480x480px) Image search: [Google]
probability plot.png
25KB, 480x480px
I used R to plot probability distributions of characters of a German ASCII text and its compressed/encrypted versions.
While ordinary ASCII (UTF-8, blue) has high variance, compressed (BZIP2, red) and encrypted (GPG, green) versions show almost uniform distributions. Apparently, GPG uses zip-compression by default.
>>
File: Text Compression.png (35KB, 589x602px) Image search: [Google]
Text Compression.png
35KB, 589x602px
Then I tried Huffman-Coding on the probabilities.
Result is not too bad.
>>
>>59433923
Why blues pop up in the 100 region?
>>
hey guys im working though some challenges someone here recommended and one of them asks to implement a program as a GUI

how do i do this with python? do i need to use another program or something?
>>
>59434277
It is the letter 'e'.
The earlier peak is space ' '.
>>
>>59434280
PyQt, PyTk
>>
>>59434280
PyGTK
>>
File: $004.png (653KB, 564x394px) Image search: [Google]
$004.png
653KB, 564x394px
>>59432960
>>59433037
pls
>>
Anyone knows a good gcode parser/generator lib for python?
I dont want to write my own.
>>
>>59434969
Switch to OCaml.
>>
>>59435014
no
>>
>>59435014
Why would anyone switch from garbage to garbage?
>>
>>59435100
Let me guess... Haskell fan?
>>
it seems it is that time of the day when /dpt/ is useless and full of cunts
>>
>>59435158
>>59430216
>>
>>59434969
use a different language
>>
>>59432707
is that a boy or girl?
>>
>>59435279
Yes.
>>
>>59435181

>>>59435464
>(((impure)))
nice try, rothschild

>>>59435426
>even
>Apply yourself Pajeet before arguing on things you don't understand.

Just as shit.
>>
>>59435149
Nope, Haskell is trash too. But it's still better than the garbage mentioned in earlier posts.
>>
>>59435463
Even better!
>>
>>59433763
keep posting anime and frogs
>>
>C tards have to define string types before using them
>C tards have to define chart types before using them

Can't make this shit up
>>
>>59433145
You forgot the worst part: NO SMT DUE TO GLOBAL LOCK IN THE RUNTIME.
It's a toy language.
>>
>>59435697
>uses languages and system written in C
Go write your system in javascript, faggot.
>>
Is Java viable for web development?
>>
>>59435721
>toy language with actual industry usage
>in the meantime Hasklel is only used to compute Fib(16)
>>
>>59430383
What's the best programming language, and why is it Lisp?
>>
>>59435721
It's an insult to human intelligence.
>>
>>59435514
What is a non garbage language for you?
>>
>>59435743
Because you can make it look like OCaml.
>>
>>59435733
Why do I have to make my own system? Did you make yours, autismo?
>>
>>59435741
so it's a pajeet.
>>
File: polymorphism.png (590KB, 680x954px) Image search: [Google]
polymorphism.png
590KB, 680x954px
>>
>>59435749
That title is preserved for C
>>
>>59435775
Ah, yes. The Pajeet insult. Typical of Haskell fags who ran out of other ad hominem to throw around.
>>
>>59435780
saved
>>
Mixins
>>
>>59435750
>a non garbage language
Excuse me, what?
>>
>>59435788
Actual Haskellfags like both C and Haskell
>>
>>59435750
There doesn't exist one right now.
>>59435788
I'm not a "Haskell fag". I despise it actually. But that doesn't somehow mean it isn't better than your joke of a """"language"""".
>>
File: parametric.png (776KB, 680x954px) Image search: [Google]
parametric.png
776KB, 680x954px
>>
>>59435809
>everything is garbage xD
>>>/global/rules/2
>>
>>59435826
whoops made a mistake
swap the first two
>>
>It's another weebshit thread
>>
>>59435817
I like C, C++, Haskell, OCaml and Lisp.
OCaml is still the best.
>>
>>59435830
Everything is garbage.

At least C# allows me to get things done.
>>
>>59435780
>>59435826
is this some new plebbit meme? fuck off.
>>
>>59435826
>>59435843
where is
forall a.
from
>>
File: 1389567984959.png (123KB, 600x811px) Image search: [Google]
1389567984959.png
123KB, 600x811px
>>59435847
>>
>>59435826
Template is static, doesn't quality as runtime polymorphism. Should use virtual functions instead.
>>
>>59435861
why does it have to be from a language?
>>
>>59435847
Anime website.
>>
>>59435861
Trashkell.
>>
>>59435874
that's why I said swap the first two
>>
>>59435735
absolutely
https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html
>>
>>59435850
>I like [...] C++[...].
Opinion discarded.

>>59435861
Coq.
>>
>>59435879
ah yes
>>
>>59435879
trashlel
>>
File: 1381180758595.gif (154KB, 120x120px) Image search: [Google]
1381180758595.gif
154KB, 120x120px
I've just finished writing Conway's Game of Life in JavaScript for a uni exercise. Feels pretty good man, I've only just gotten into programming, mainly because of the course, and this is by far the most complex thing I've made yet.
>>
>>59435884
>Opinion discarded.
Opinion discarded.
>>
>>59435905
try changing the rules, its a lot of fun.
>>
>>59435915
not an argument
>>
>>59435750
None is perfect, but I can think of a few nice enough ones:
>C#
>Ruby
>Rust
>Crystal (maybe, in the future)
>Perl (because string handling, it would otherwise be utter crap)
Some others, like Haskell, F# and Clojure are supposedly nice too, but I'm not experienced enough with either.
>>
>>59435972
Not him but I like Nim too, don't judge
>>
File: SubredditGrowthOverTime-all-time.png (619KB, 1953x1262px) Image search: [Google]
SubredditGrowthOverTime-all-time.png
619KB, 1953x1262px
>>59435878
That's like saying reddit is a porn or programming website
>>
>>59435999
>trees
autistic af
>>
>>59435997
Heard good things about it, but the compiles-to-C thing is a bit of a turnoff and a limitation imo.
>>
>>59435999
No it isn't
>>
>>59435999
wtf reddit was exclusively porn in 2006?
>>
>>59436016
Trees as in "weed, 420 blaze it!"
>>
>>59435999
Not even close to true, but stay delusional you faggot.
>>
>>59435999
reddit must have been good before 2008
>>
File: 1450648121055.gif (2MB, 187x186px) Image search: [Google]
1450648121055.gif
2MB, 187x186px
What makes Lisp macros so special so they are used instead of functions?
>>
>>59436057
Compile time code.
>>
>>59436054
Well it's not like the original subreddits shrunk, the other ones simply grew even more.
>>
if c is so fast why don't we just compile it to jvm bytecode
>>
>>59436057
Syntax sugar and metaprogramming. Scopes, evaluation, variable names etc. are not a limitation with macros. Other languages have macros too these days though.
>>
in c++
delete thing;
thing = nullptr;

should I set the pointer to nullptr or does delete do that already?
>>
>>59436106
You should just not reference thing at any point after the delete.

And you shouldn't use delete at all.
>>
delete this;
>>
>>59436106
>should I set the pointer to nullptr
Only if you'll keep thing for a later use. Otherwise don't set a pointer to NULL after free, it's absolutely stupoid.
>>
>>59436050
Yes, that's autistic.

>>59436044
No, I think the graph is misleading. Reddit was originally basically a programming/tech site, with no distinct "subreddits". NSFW was the first "subreddit", but it was really just a containment board for porn, everything else was just "on reddit" without being put in a particular subreddit. Only later on did they start to require everything be put on a specific subreddit, the "original" reddit later became /r/programming.

>>59436081
Because that would make it slower?
>>
>>59436106
Only if it's going to remain accessible, eg. a class member, otherwise it's POINTless.
>>
>>59430383
If your language is not homoiconic, it's trash.
>>
>>59436120
>>59436167
it's a static class member, so yes.
I guess delete doesn't set it to nullptr then?
>>
>>59436106
>>59436118
>>59436119
>>59436120
Really the only time you SHOULDN'T set it to nullptr is if you call delete on the pointer just before it goes out of scope. If there's any chance that you're going to re-use the pointer again before the pointer goes out of scope, you should set it to nullptr, otherwise you're just asking for trouble. Basically, you shouldn't have any non-null pointers that can't be safely dereferenced. Anything that doesn't point to the null reference is assumed to point to something valid, and inevitably, somebody's going to come along and try to dereference it, unless it's set to null. Because there isn't any way to effectively test whether a pointer is valid, so basically any pointer that doesn't point to valid data should be set to null, so people know not to dereference it.
>>
>>59436192
that's some solid advice. thanks.
>>
>>59436192
Typical of code monkeys. Advocating for useless assignation.
>>
>>59436187
>I guess delete doesn't set it to nullptr then?
No it doesn't. Try
#define DEL(ptr) do { delete (ptr); ptr = 0; } while (0) 
for that. Consider an array version too. Also, see:
http://en.cppreference.com/w/cpp/language/delete
>>
If your language is not homosexual, it's trash.
>>
>>59436187
No it doesn't. Same reason why C/C++ doesn't automatically check for null when dereferencing - there are some cases when these safety checks are unneccessary, and would just slow things down. So when they are needed, the programmer has to be explicit about it. For example,

int meme() {
Widget *widget = new Widget();
Widget.frobnicate();
delete Widget;
return 5;
}


in this code there's no point in nulling the pointer, since it's cleared off the stack immediately after delete(). But if you're doing something like a linked list, you want to immediately set a pointer to a deleted node to nullptr, so that nobody tries dereferencing it later.
>>
>>59436259
>Widget *widget = new Widget();
...
Widget *widget (new Widget());
>>
>>59436231
1/10, I replied.
>>
>>59436282
That's fucking stupid.
Why the fuck does Meme++ have like 5 different ways to initialise things?
>>
>>59436255
https://web.archive.org/web/20161021144343/http://gay-lisp.org/
>>
>>59436231
I'm not a code monkey, but I recognize that any professional code is going to be handled by them. Unless it's IMMEDIATELY clear from context that the pointer doesn't point to anything valid (i.e. the pointer's lifetime ends shortly after you use delete()), it's very likely that someone is going to add code that tries to access it, and the only safety feature they are likely to use is a null check. Don't assume that other people reading your code are going to have a complete knowledge of program structure, where they can accurately tell if when it's reasonable to assume the pointer points to something valid.
>>
>>59436295
Because for the entirety of it's existence it's been a "Yeah but what if it had THIS feature too!"
>>
>>59436282
What even is the point of that?
>>
>>59436295
because they all do something different
>>
How do I do this in C++?
task type Encapsulated_Variable_Task_Type is
entry Store (An_Item : in Item);
entry Fetch (An_Item : out Item);
end Encapsulated_Variable_Task_Type;
task body Encapsulated_Variable_Task_Type is
Datum : Item;
begin
accept Store (An_Item : in Item) do
Datum := An_Item;
end Store;
loop
select
accept Store (An_Item : in Item) do
Datum := An_Item;
end Store;
or
accept Fetch (An_Item : out Item) do
An_Item := Datum;
end Fetch;
end select;
end loop;
end Encapsulated_Variable_Task_Type;
>>
>>59436325
What does it do?
>>
>>59436320
So why doesn't sepples have eval(), prototype-based OOP, modules, bignums, or a standard GUI library?
>>
>>59436306
If someone do such stupid thing with my code I will kick that person. I don't work with idiots who can't code.
>>
>>59436340
> or a standard GUI library?
Because standard GUI libraries are always sciet.
>>
>>59436325
I have no idea what that is doing, but I'm sure something can be hacked together via boost and some templates.
>>
>>59436337
A thread that requires the first command to give it a value to store, then loops infinity either giving or taking in a new value for Datum.
>>
>compile my C++ program
>no libraries
>no bullshit
>tfw 16mb exe
>strip -s program.exe
>15mb
>>
>>59436340
He didn't say "all" features. Habla Ingles motherfucker?
>>
>>59436422
And that's why C++ templates are shit.
>>
>>59436422
Post full source and makefile.
>>
>>59436470
It trades memory for speed. You save some performance on reduced type casts, you lose out on memory.
>>
>>59436510
Enjoy your icache misses.
>>
File: download.jpg (20KB, 300x300px) Image search: [Google]
download.jpg
20KB, 300x300px
>>59436341
>I will kick that person
>>
Elite opinion: static linking is better than dynamic linking
>>
>>59436510
It's not so much reduced type casts as it is unboxing. Without templates, generics are implemented as void pointers (or pointers to interfaces, if you bound the generic parameter), and you have to pay the price of indirection.

>>59436524
With templates you can choose whether you want to use a pointer, and a sufficiently smart compiler will reuse the same instantiation for all pointer types since the compiled code is the same.
>>
>>59436422
What compiler and platform are you using? How big is your program? GCC on Windows at least produces really bloated binaries, especially if you use iostreams, but that doesn't even get it up to 1MB binaries.
>>
>>59436542
Not that elite, I'm sure many agree. Unless you really need the memory savings and/or the separate distribution/updating flexibility, what's the point?
>>
>>59436560
gcc on msdos, static linking
>>
>>59436542
Only if you're writing software for toasters.
>>
>>59436570
>gcc on msdos
You mean DJGPP?
>>
>>59436569
t. ulrich drepper
>>59436573
t. retard
>>
>>59436569
>the separate distribution/updating flexibility
That's a very useful thing for a lot of programs, as long as they're not using shit libraries that break their ABIs all of the time.
But really, only proprietary fags are worried about the whole static vs dynamic shit.
>>
>>59436552
>a sufficiently smart compiler
Last I checked, gcc couldn't even compile a unique_ptr down to a raw one. Since then, I expect concrete citations of existing "sufficiently smart compilers", including version and limiting factors.
>>
>>59436588
are there any other ports?
>>
>>59436607
I dunno if C++ does it, but in principle that's what should happen. There's no sense at all in duplicating the generated code if the only difference is the pointer type. In fact you could go further and say that the same instantiation could be reused for values of the same size and alignment.
>>
>>59436615
Not that I'm aware of. Though I thought maybe you meant running it under Windows/Linux to make DOS programs.
>>
>>59436650
that's what I'm doing, yes.
>>
File: halp.png (146KB, 1440x900px) Image search: [Google]
halp.png
146KB, 1440x900px
I need some halp.
>>
>>59436637
Hearing of "sufficiently smart compilers" makes me roll my eyes. When someone uses that phrase, I know they're not aware of any real compiler that is truly "sufficiently smart" otherwise one would say "gcc/clang/etc. does X". My code is meant to run today, not when mythical software is going to finally get written.
>>
File: rebbit.png (20KB, 987x286px) Image search: [Google]
rebbit.png
20KB, 987x286px
is /dpt/ dead?
>>
>>59436718
I'm not defending C++ here - it's pretty embarrassing that it can't do basic things like that.
>>
>>59436689
Is there an option to do dynamic linking, just to see what effect it has on binary size?
>>
>>59436718
>>59436771
By "it" I mean any compiler for it.
>>
>>59436714
ENGLISH ONLY
>>
>>59436714
I don't see p1-ano defined
>>
I went through an entire 4 year program without making an exe file. What the shit?
>>
>>59436809
You were programming in Linux
>>
File: 1452403462016.png (79KB, 307x400px) Image search: [Google]
1452403462016.png
79KB, 307x400px
>>59436809
>an exe
>>
>>59436825
Sorry a exe
>>
>>59436778
g++.exe: error: unrecognized command line option '-shared'; did you mean '-shared'?

apparently not.
>>
>>59436809
I suppose you made .jar files?
>>
>>59436830
I think you missed the point of my smug anime face.
>>
>>59436833
No just ran everything with ./
>>
>>59436832
I don't think that's a hyphen. Try typing it out yourself instead of copy-pasting.
>>
File: halp.png (146KB, 1440x900px) Image search: [Google]
halp.png
146KB, 1440x900px
>>59436787
>>59436798
the IRC guys halped me.
>>
>>59436832
That's a really useless error message.
>>
>>59436798
It is implicitly defined.
>>59436714
(mayor (p1-ano p1) (p2-ano p2))
>>
Is this the babby thread before you graduate to /wdg/?
>>
>>59436863
>>59436866
Disregard. Mine is mixed up!
>>
>>59436863
>mIRC
>>>/trash/
>>
>>59436879
Too obvious.
>>
>>59434445
go to google dot com and search C documentation

stop trying to be dumb cli weeb
>>
>>59436893
It must be all the rage in Paraguay.
>>
>>59436857
that's a hypen and I did type it myself
>>
>>59435972
>ruby
>rust
>crystal

t. fizzbuzzer
>>
>>59436325
By making a huge fucking mess, I'm sure.
>>
>>59435999
Jesus christ.. this is a perfect visual of normies invading the internet
>>
>>59436932
Says the elitist prick who has no clue about either of them.
Here's a nice website for you, now please fuck off: http://screamintothevoid.com/
>>
>>59436832
>>59436857
>>59436865
Does DOS even support dynamic linking?
GCC probably has the option disabled for that target, but it wasn't removed from their "did you mean" system.
>>
>>59436932
What's wrong with Ruby?
>>
>>59436978
>lists two unfinished immature languages as "good" languages
seems legit
>>
>>59436832
c++ fans will defend this
>>
>>59436832 (You)
>.exe
>>
>>59436981
It's too productive. You know the whole "don't appropriate my culture" bullshit? Same thing here: retards with a well-developed Stockholm syndrome while using C feel threatened by people who actually get useful shit done in less painful ways.
>>
>>59437050
>people who actually get useful shit done in less painful ways
In the meantime the only actual codes that are frequently posted here are C, C++, D, Haskell (!) or Lisp. Makes you think.

>>59436981
I think it's alright. Up until recently it did the most retarded thing by interpreting source code straight up but now it does at least a few operations on the AST.
>>
>>59436999
Learn to count and to read, only Crystal is unfinished and I readily admitted to only having high hopes for it for now.
>>
File: 1450635395685.jpg (23KB, 500x342px) Image search: [Google]
1450635395685.jpg
23KB, 500x342px
>>59437050
>You know the whole "don't appropriate my culture" bullshit?
No
>retards with a well-developed Stockholm syndrome while using C feel threatened by people who actually get useful shit done in less painful ways.
Are you high? What's all this gibber? I barely understand it.
>>
In C if I have an of type def structs how can I move all of them down with memmove?
>>
>>59437050
C is productive.
It barely takes any longer to write something in C than it does to write it in python or ruby.
python is basically C without braces tbqh
>>
File: 1488321839821.png (136KB, 320x371px) Image search: [Google]
1488321839821.png
136KB, 320x371px
>>59437125
>I have an of type def structs how can I move all of them down with memmove
>>
>>59437125
*if I have an array of typedef structs
>>
>>59437114
>I barely understand it.
I'm not high, you're just out of the loop. That first part you answered "no" to is kind of a prerequisite.
>>
>>59437141
The same way you would do it with an array of anything else. Point to the beginning or your array for the source, use number_of_elements * (sizeof your_struct) as the size and enjoy the move.
>>
>>59437126
>C is productive.
No. A language can't be "productive". It's retarded to claim that it can be.
>>
>>59437092
>C, C++, D, Haskell (!) or Lisp. Makes you think.
I have nothing against any of those languages, only some of their fanbases for being idiotic.
>>
>>59437171
do I not need a loop?
>>
>>59437180
You must really hate Go and Rust's "fanbases" then.
>>
>>59437193
No, don't use loops. They're pretty inefficient
>>
>>59437193
If it is an array, why would you? It's supposed to be contiguous. Hence you can move the whole array by moving data of the size of the whole array.
>>
>>59437210
>>59437215
So what should the destination be?
>>
>>59437198
Did any of them make hostile or passive-aggressive remarks towards people who use languages other than their own? If not, you totally missed my point.
>>
>>59437193
A loop assignment gets optimized to a call to memcpy
>>
>>59437259
>>59437272
>>
>>59437272
Nope, this is wrong.
>>
>>59437262
The hypocrisy is strong.
>>
>>59437314
As long as the source and destination are contiguous, it is on every compiler worth mentioning.
>>
>>59437126
>python is basically C without braces tbqh
Poe's law is strong today.
>>
>>59437344
Substantiate.
>>
>>59437272
>>59437215
>>59437210
I've got this can you tell me what's wrong?
 memmove(&factory->cars[idx + 1], &facory->cars[idx],
factory->num_of_cars
* sizeof factory->cars[idx]);

I get stack smashing detected.
>>
>>59437356
>>59437377
Can you help me out?
>>
Doing project euler again

Quick question on C++ doubles.

If a number is printed as :
     2.14335e-05 

and I multiply it by another number, there's is there going to be a significant loss in precision?
>>
>>59437092
>frequently posted here
>here
And JS is most frequently posted on github, what's your point?
>>
>>59437374
Where have you been the last few weeks? We've been raided by anti-C/C++/pro-Mozilla shills for weeks now. Threads even got nuked due to how shitty dpt gets some nights.
>>
>>59437356
Are you literally retarded?
>>59437377
Yes.
>>
You guys must not be arguing about C, D, Rust, Go, and such because you share the same Algol ancestry. It doesn't make sense to argue about, you are still the same Algol descendants.
Better learn Haskell.
>>
>>59437418
The point is this is not Github.
>>
>>59437423
>Yes.
I don't understand if you're calling me retarded I'm not the guy in the first post you linked.
>>
>>59437400
>Quick question on doubles
checked
>>
>>59437400
I wouldn't say significant but never expect results to be exact. For example in medical simulation software I usually see 10^-6 as the threshold for a null value. If you actually want exact computation, use multiprecision arithmetic like GMP or a language which natively supports big nums.
>>
>>59437423
Why wouldn't it? Also, why are you resorting to name-calling? Are you butthurt that you don't know what you're talking about?
>>
>>59437425
Better learn Idris.
>>
>>59437475
It doesn't matter much, just escape Algol.
>>
>>59437421
I visit here only once in a while. Either way, I did my best emphasizing that I don't lump everyone who uses the same language together:
>some of their fanbases
>some
>>
>>59437435
I brought up Github, not you, now please focus.
>>
>>59437474
Can you help me out? Is this >>59437377
correct?
>>
In C, is *foo->bar the same as *(foo->bar)?
>>
File: 1478093820966.jpg (104KB, 1000x1430px) Image search: [Google]
1478093820966.jpg
104KB, 1000x1430px
What's the best site for retards like me to learn programming. I guess I'll try Java Script. I ultimately want to find a programming job here in my shitty country (Bulgaria).
>>
>>59437425
Algol is natural, as it reflects the structure of real life activities, as described by most people (and shampoo manufacturers). D seems kinda pointless though. At least Go has concurrency, if nothing else.
>>
>>59437561
Yes. -> has a higher precedence than unary *.
>>
>>59437561
Yes, -> is a top-priority operator.
>>
>>59437566
>JavaScript
check /wdg/, they have resources
>>
>>59437552
Post your "factory" structure. I'm quite sure you are not moving a contiguous array.
>>
>>59437552
Depends on how they're declared
>>
>>59437566
A bit of motivation goes a long way, just FYI.
>>
If you have other questions grammar-related you can check http://www.quut.com/c/ANSI-C-grammar-y-2011.html. As you will see -> is in postfix expression, which is parsed at a lower depth in the tree than unary & hence has precedence over it.
>>
>>59437464
Alright... I was thinking of using GMP as well, but it turned out doubles were more than precise enough to get the job done.

Similar question.
If I have the file "printing.cpp" in the same folder as my main.cpp, what would I need to type to #include it? This file is mostly so I don't need to re-type templetized ostream& << operators
>>
>>59437602
>>59437608
typedef struct {
char name[80];
int num_of_cars;
Car cars[possible_num_of_cars];
} factory;
>>
nothing
I can program
I get satisfaction from programming
but I can't bring myself to actually do something
>>
>>59437602
>>59437608
This >>59437691
is the real one sorry for the other two posts I fudged them up and deleted them.
>>
>>59437651
>#including a source file
Please no.
>>
>>59437703
Post full relevant code.
>>
>>59437729
Well, what would I do as an alternative?
>>
>>59437766
Source files symbols are supposed to be resolved by the linker. Inclusion is only here to declare used symbols in the current translation unit. Your IDE probably thinks it is building from another repository than where the main is located or something. I don't know how your setup works.
>>
>>59437126
This is so incredibly not true.
>>
>>59437363
>being pedantic
the conversation is about write-ability and productivity.

>>59437178
?? scripting languages are productive. high abstraction, easy to write and read to quickly automate things. that's productivity.
>>
Can someone help me convert this MIPS code to C
     

add


$t0, $zero, $zero

loop:


beq


$a1, $zero, finish


add


$t0, $t0, $a0


sub


$a1, $a1, 1


j


loop

finish:


addi


$t0, $t0, 100


add


$v0, $t0, $zero


and this code to MIPS
/ $s0 -> int *p = intArrary;

// $s1 -> a

P[0] = 0;

int a = 2;

p[1] = a;

p[a] = a;
>>
>>59437805
Why the fuck did you put so many blank lines? I don't want to have to scroll to read that shit.
Is this the reddit spacing of code tags?
>>
Thanks for helping me with the clouds, anons. They need work visually to account for the optimizations but they're rendering extremely quickly now.

I do have one more question, however. For some reason, this line of code that I'm using for blending the final product is, out of the blue, TANKING my performance and I have no idea why.

float3 clouds = lerp(sunAmount, 0, pow(shadowSum.x, 0.4));


This has never been a problem before, which is extremely strange. If I remove the lerp the performance doesn't increase, and if I replace the pow with a precomputed texture lookup it doesn't speed up either. Why would such a simple operation be causing this much of a performance hit?
>>
>>59437820
thats how i was given the code sorry ill reformat it
 
add $t0, $zero, $zero
loop: beq $a1, $zero, finish
add $t0, $t0, $a0
sub $a1, $a1, 1
j loop
finish: addi $t0, $t0, 100
add $v0, $t0, $zero


// $s0 -> int *p = intArrary;
// $s1 -> a
P[0] = 0;
int a = 2;
p[1] = a;
p[a] = a;
>>
File: cloud volumetric lighting.png (859KB, 1158x604px) Image search: [Google]
cloud volumetric lighting.png
859KB, 1158x604px
>>59437826
almost forgot
>>
Why doesn't fucking GDB work in code::Blocks

> warning:GDB:failed to set controlling terminal

then it just gives a segfault, ignoring a breakpoint I know it should have hit

Am I just not using breakpoints right? or is it broken? FUCK
>>
>>59437930
>He doesn't use Vim+GDB
>>
>>59437888
int func(int a0, int a1)
{
int t0 = 0;
for (; a1 != 0; --a1) {
t0 += a0;
}
t0 += 100;
return t0;
}

It's some kind of naive multiplication function which adds 100 at the end, for some reason.
>>
File: dahli cloudsxz.gif (2MB, 543x297px) Image search: [Google]
dahli cloudsxz.gif
2MB, 543x297px
>>59437929
>>59437826
Actually, what the fuck. The issue is WAY stranger than that.

If I access a certain variable past a certain point in the code, performance tanks.

What the fuck could be causing behavior like that?
>>
>>59438006
Is your program thrashing the cache?
>>
>>59437979
Thanks anon. Could you help me on the second one to convert it to MIPS. I dont know what P[ ] mean
>>
>>59438014
I don't think so. It's a shader so it doesn't access the disk at all, unless you're referring to a different meaning of "thrash the cache"
>>
>>59437979
You just did his homework for him. Good job.
>>
>>59438048
Cache has to do with CPU, not disk
>>
>>59438048
>the disk
No, I meant the data cache on the CPU.
Are you accessing a bunch of data randomly in memory?

>>59437979
Actually, I just remembered that MIPS has that whole delay slot shit.
My example might not be 100% correct. I'll leave it to you to make sure it's correct.
>>
>>59438058
not anon but
"In computer science, thrashing occurs when a computer's virtual memory subsystem is in a constant state of paging, rapidly exchanging data in memory for data on disk"
?
>>
File: busy.png (7KB, 741x104px) Image search: [Google]
busy.png
7KB, 741x104px
>tfw multithreading
>>
>>59437826
texture lookup is heavier than pow. that said, a single pow per fragment shouldn't be end of the world.

how does shadowSum.x * something fare?
>>
>>59434445
go to where is located the file and read it
>>
>>59438071
There is more than one type of thrashing.
Maybe I should say "Does your program have a lot of cache misses?" then.
>>
>>59438006
your kernel ran out of registers, most likely. whats your hardware?
>>
>>59438125
>your kernel ran out of registers
What? I have a feeling you have no idea what you're talking about.
>>
[/code]template<int i> void f()
{
switch(i)
{
case 1: // ...
case 2: // ...
case 3: // ...
case 4: // ...
case 5: // ...
// ...
}
}[/code]
will gcc be smart enough to optimize the whole switch thing away?
>>
File: 1488590790614.jpg (20KB, 306x423px) Image search: [Google]
1488590790614.jpg
20KB, 306x423px
>>59438125
>your kernel ran out of registers
>>
>>59438070
I'm using a lot of variables, but the majority of them are uniform. I just don't see how a variable that's written to so much in my code would suddenly be considered to be unimportant. I'm not even near my GPU's memory max.

>>59438089
>how does shadowSum.x * something fare?
Even just returning shadowSum.x makes the performance shit the bed.

>>59438121
I don't think it does

Time for even more strangeness:
No lag:
work /= Steps;
return float4(work, work, work, 1);
shadowSum.y = saturate(shadowSum.y);
shadowSum.x = saturate(1 - shadowSum.x);

No lag:
work /= Steps;
shadowSum.y = saturate(shadowSum.y);
shadowSum.x = saturate(1 - shadowSum.x);
return float4(work, work, work, 1);

Incredible amounts of lag:
work /= Steps;
shadowSum.y = saturate(shadowSum.y);
shadowSum.x = saturate(1 - shadowSum.x);
return float4(work - shadowSum.x, work, work, 1);
>>
>>59438155
Should be. Templating is done statically.
>>
>>59438159
Fuck, I didn't even know that we were talking about GPU programming. I was asking about CPU shit.
I don't really know much about the memory and performance characteristics of GPUs.
>>
>>59438228
Oh, sorry for not mentioning that anon. I thought it was implied because I was workin on a cloud shader
Thanks for trying to help, at any rate.
>>
>>59438245
>I thought it was implied because I was workin on a cloud shader
Yeah, looking back you did imply that.
I just focused on "performance gets really shit after larger input", which is usually a cache thing on CPUs.
>>
>>59438134
>>59438157
I think they're talking about the GPU.
>>
>>59438286
I can see that.
>>
Sometimes in C code I've seen elements (e.g. nodes of a graph) being allocated as an array and then accessed and generally referred to by array indexes rather than pointers.

Is there a reason to do that?
>>
How should I design a register-based virtual machine?
Are instructions supposed to be able to operate directly on memory by moving/adding to a stack? What I'm most confused about is how I would keep track of where variables are pushed. Is it just about the compiler saving the address?
>>
>>59438574
Do you mean contiguously? This is the way to proceed for high performance programs due to the way modern CPUs work. Note array indice are syntactic sugar for pointer arithmetic.
https://en.wikipedia.org/wiki/CPU_cache#Cache_miss
If that's not what you asked about I think I didn't understand.
>>
>compile the simplest possible Win32 program (doesn't even create any actual windows, just displays a messagebox and exits)
>169KB EXE
>run strip on the EXE
>now it's 9KB
Why?
>>
>>59438595

>How should I design a register-based virtual machine?
Same way you would design a VM for any real instruction set?

>Are instructions supposed to be able to operate directly on memory by moving/adding to a stack?
You have load and store instructions. One register will hold the memory address, one register will hold the value to be moved to/from. The "stack" isn't really some special place in memory. It's just wherever you've decided to place the stack pointer, which is typically one of your general purpose registers.

>What I'm most confused about is how I would keep track of where variables are pushed
You've got a big block of memory. Somewhere in here is where your stack pointer is pointing to. When you push a value, you increment or decrement the stack pointer and store a value at that location.

>Is it just about the compiler saving the address?
Compilers don't store absolute addresses for stack variables. They store offsets from the stack pointer.
>>
>>59438617
I meant that e.g. for a linked list instead of a struct like

struct Node {
/* some data */
Node *next;
}


you'd have something like

struct node_t {
/* some data */
int next_index;
}


So the index of the next node in the node array will be stored rather than a pointer to the node.
>>
>>59438685
(ignore the Node/node_t difference, I'm sleepy and it doesn't matter for the example)
>>
>>59438125
I think you need buy more registers. They're on sale on Tom's Hardware.

You could also try to free some pointers. That should reduce the gizmo memory usage.
>>
>>59438699
*and it should be struct Node rather than just Node in the first example pointer obviously
>>
>>59438685
It's trivially serializable; pointers are not.

If the use case involves saving that to a file, reallocating it often or generally moving it around then it can be a better approach than pointers.
>>
>>59438006
>>59437929
what engine?
>>
New thread:
>>59438776
>>59438776
>>59438776
>>
any neural net autists ITT?
how do i normalize many independent sequences? they're all in a different range, and ranges may overlap between two sequences
should i normalize the data as if it were one sequence or each sequence independently?
Thread posts: 320
Thread images: 34


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