[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 29
File: Naganohara.Mio.full.526669.jpg (89 KB, 1280x720) Image search: [Google]
Naganohara.Mio.full.526669.jpg
89 KB, 1280x720
old stale bread >>54169459

what are you working on Mr. Dijkstra?
>>
C is a gigantic meme spread by closet pajeets.
>>
>>54175632
Creating a plan to rid the world of goto statements
>>
>>54175632
An algorithm to solve this stupid maze
>>
Are there any .net core/.net native benchmarks? v.s. .net framework, some language on the platform v.s. another language, or native v.s. not native on core? Linux performance being particularly of interest.

I've been trying to find some but google results are much too noisy, can't find shit capn.
>>
>>54175689
But goto is the idiomatic way of doing error handling and resource cleanup in C
>>
File: Untitled.png (37 KB, 348x204) Image search: [Google]
Untitled.png
37 KB, 348x204
well played, OP
>>
>>54175683
This is a fact. Nobody on /g/ who ever recommends C even knows anything about it. Hell, just see in the previous thread the tard, his tree, and the pajeets encouraging him to use incorrect code.
>>
So /g/ I cannot for the life of me figure out how to implement this. Essentially I have a class object and I want to read a file that goes line by line that looks like this

What is 1 + 1?
1: 1
2: 2
3: 3
4: 4
2


and assign each individual line to a class object such as .setQuestion, .set answerOne, ect. to each individual question object I have. How the hell would I go about doing that? Posted below is my pathetic attempt at it. Yes, I understand I am not even close.

int main()
{
int count = 0;
int max = 10;

ifstream inFile;

inFile.open("TriviaQuestions.txt");

Question q1, q2, q3, q4, q5, q6, q7, q8, q9, q10;
Question list[10] = { q1, q2, q3, q4, q5, q6, q7, q8, q9, q10 };

for (int i = 0; i < count; i++)
{
string temp;
while (!inFile.eof() && count < max)
{
inFile >> temp;
list[1].setTriviaQuestion(temp);
cout << list[1].getTriviaQuestion();
}
}
}

It's c++ by the way.
>>
>>54175694
Go right
>>
Daily reminder to filter ALL tripfags (no exceptions). Out of all this board's cancers, they are the simplest to purge. Above all, DO NOT RESPOND to their posts.
>>
>>54175723
The plan involves eradicating C.
>>
>>54175746
Should you lead by example
>>
>>54175746
FUCKING THIS
>>
>>54175759
Why? C is still useful
>>
>>54175730
ayy
>>
File: Screenshot_2016-04-22-19-08-40.png (984 KB, 1440x2560) Image search: [Google]
Screenshot_2016-04-22-19-08-40.png
984 KB, 1440x2560
>>
>>54175759
Rustfag go home
>>
you did it /g/
>>
>>54175871
/g/ is my home
>>
If I wanted to make a game what language would be best? I heard Python is good if you want to make indie and C++ if you want to work on AAA titles. I think it was in an old /dpt/. I enjoy physical books, would you recommend buying one for said program?
>>
>>54176218
>>54176195
For indie shit? C#

For AAA shit? C++
>>
>>54176259
Odd way to spell F# and ocaml.
>>
I made a thing for giving a search query a name that gets implicitly inserted into normal searches.

Useful for when you only want to automatically exclude results without having to type it into the query every time or if you want to save long queries.
>>
>>54175871
>using python

K
>>
>>54176282
I'm a F# man myself. But I'm picturing the average faggot trying to make a game won't have the interest to learn it. C# is popular for games so you have a lot of community support for any problems you run into. But yeah, if I was making games I'd use F#. Made one in F# before actually, but never quite finished it. Bleh.

Ocaml doesn't really have great support for gamedev.
>>
File: FUCK MY SHIT UP.jpg (36 KB, 350x386) Image search: [Google]
FUCK MY SHIT UP.jpg
36 KB, 350x386
God damn, why byte handling by programming languages is so fucked up. I just want to manipulate my 32bit words and put them into a fucking file.

>write 4 bytes 0xDE 0xAD 0xBE 0xEF
>xxd file
>DEADBEEF
>need 32bit word
>lolfuckyou no & and | on byte arrays
>the only alternative is 32bit unsigned int
>write 0xDEADBEEF
>xxd file
>EFBEADDE
JUST
>>
>>54176366
So use a real language like C or Java and quit bitching.
>>
>>54176409
>EFBEADDE
There's an easy way to fix this
>>
>>54176409
Endianness.
>>
>>54176409
I'm not sure what you mean because you don't make sense, but "byte handling" (bit fiddling?) isn't fucked up at all.
>>
>>54176411
Who's bitching? I don't care for "real languages". I care for langugaes that help me make the things i want to make faster, easier and better.
>>
>>54176430
K
>>
>>54176430
>>54176447
>being this retarded
>>
R is bliss.
>>
Wow so, sorry to be that anon with 2 questions but what would a good book to buy for a C# beginner?
>>
I feel like I'm too dumb for SICP; I was stuck on 1.19 for like a day and I still haven't really gotten close to figuring it out
Anybody else have this kind of experience?
>>
Where should i go to start learning c++, already know basics of c
>>
>>54176547
this one maybe http://www.amazon.com/C-Players-Guide-2nd/dp/0985580127/ref=sr_1_1?s=books&ie=UTF8&qid=1461373315&sr=1-1&keywords=C%23
>>
>>54176423
>>54176424
Obviously, I'm using little endian. Big endian solves the problem, but it doesn't make much sense to me.

If I loaded my 0xDEADBEEF from file into register, would it have value 3735928559 (i.e. 0xDEADBEEF)? Would adding one give me 0xDEADBEF0?
>>
>>54176409

>no & and | on byte arrays
I am not sure what language you are using, but in C, it is perfectly legal to use bitwise operators on unsigned chars (bytes) and such.

And if you are reading these in as 32 bit integers, of course you are going to be running into endianness problems. Don't do that if the order of the bytes matters.
>>
>>54176611
Thank you for your time! I went to Amazon and it brought up 100 pages. of results, 73 after filtering English!
>>
>>54176662
I went to amazon and searched "C#" and that was the first result ;p. Though it looks good though. Popular, well reviewed and aimed at beginners. Can't be too bad.
>>
>>54175392
http://www.nask.co
my biggest project... and no one uses it ;_;
>>
>>54175799
Only because of Arduino.
>>
>>54176725
http://nask.co/L/XRbjLsvi6Z?a=1

Might help if the website actually said what it's for..
>>
>>54176725
nice drum and bass generator faggot

http://www.nask.co/L/pic8VwCmIL
>>
>>54176725
http://nask.co/L/9XfE43wmuU
>>
>>54176725
you should probably post this on the subreddit programming.


great stuff my man!
>>
>>54176614

Consider we have the following in memory:

Address | Value
--------+-------
0x100 | DE
0x101 | AD
0x102 | BE
0x103 | EF


We decide to load a 32-bit word from address 0x100 into a register, let's call it r1.

If we are on a Big Endian machine, r1 will hold the value 0xDEADBEEF, or 3735928559
If we are on a Little Endian machine, r1 will hold the value 0xEFBEADDE, or 4022250974

On a Little Endian machine, if we were to increment r1, it would hold 0xEFBEADDF, or 4022250975. Stored back into memory, at the same address, it would look like this:

Address | Value
--------+-------
0x100 | DF
0x101 | AD
0x102 | BE
0x103 | EF


On a Big Endian machine, if we were to increment r1, it would hold 0xDEADBEF0, or 3735928560. Stored back into memory, at the same address, it would look like this:

Address | Value
--------+-------
0x100 | DE
0x101 | AD
0x102 | BE
0x103 | F0


I am not going to explain middle endian systems. They are weird.
>>
http://nask.co/L/XztQtfy5KB
>>
I landed an interview with Microsoft but I'm a physics major with pretty much zero coding knowledge. What do I need to learn to fake being competent? The interview is in, let's see... three days.
>>
>>54176738

And, you know, the millions of libraries that revolve around C. The language interpreters, operating systems, and so on...
>>
>>54176741
can you describe it for me? I still don't know how to make a short phrase that describes it, so that the user understands right away... should I just add a how-to or something?


>>54176749
well, it's useful, that's what I care about...


btw, do you guys like the UI?
>>
>>54176793
If you applied for a dev position and you don't know how to program, cancel it right now.
Nobody learns programming in 3 days.
I didn't even feel confident in writing shitty toy programs until 6 months into learning.
>>
>>54176580
Yeah, the wizard book is a little heavy on the math. If you're going through SICP because you want to learn Scheme, try out The Scheme Programming Language by Kent Dybvig and then go back to SICP.
>>
Does anyone have any idea how I could go around writing a script to do something when someone on a mumble server undeafens?
>>
>>54176806
>can you describe it for me?
A service that reads text messages out load.
>>
>>54175715
bump
>>
>>54176814

I'm applying to be a program manager, whatever that means. I've gotten pretty mixed opinions on the internet about how much coding is actually involved in that role or if it's just abstracted problem solving (which it turns out physics makes you really good at).
>>
>>54176836
loud*
>>
>>54176814
>>54176848

Also I can fumble around Python but that's pretty much it.
>>
http://nask.co/L/z3eLkhKhCp
>>
>>54176836
thanks! that is indeed a good description.

>>54176757
kek

>>54176758
yeah, I will, thanks for the suggestion!
>>
How can I make a hugs program that returns how many times certain element appears in an array?
>>
File: hug.jpg (147 KB, 500x564) Image search: [Google]
hug.jpg
147 KB, 500x564
>>54176973
>hugs
>>
>>54176973
a what?
>>
>>54176725
It's okay. Microsoft sam is better still.

http://nask.co/L/eWMzzAxQul
>>
>>54175737
you need to go back and read more from the book you're learning from and/or docs on fstreams and strings. what you're trying to do sounds trivial and if you can't figure it out just hold your breath and plug your nose until it occurs to you
>>
>>54176973
use ghc instead
>>
>>54177186
yes, I know... if I had some money, I'd build a better version / use better TTS engines, but I don't have it. the site itself cost me nothing. the whole idea of the site was to have some fun, learn stuff and see if someone would actually use it
plus, as I said, no one uses is, so there is not even a motivation to improve it, at least for now.
>>
>>54176725
my suggestion: make two buttons where the Leave a Message button is, one says "play message" with an audio icon which will play the message and the second says "get url" which makes the url populate into a box below the buttons. your pop-up window is annoying.

other than that its a neat little project but speech programs are really only useful for blind people and they don't tend to spend much time on the internet
>>
Kek http://nask.co/L/qYd2030W5E
>>
>>54175737
>Question q1, q2...
>Question list[10] = {...
you don't have to do this
>>
>>54177212
I actually feel like I understand how to read lines into a text file but I can't get this because it's to a certain object type (which is question) so it won't allow it otherwise
>>54177410
teach me otherwise? My teacher fucking sucks and takes 3-4 days to respond to emails and only otherwise provides the textbook for a resource.
>>
>>54175737
>for (int i = 0; i < count; i++)
count = 0 so the for loop won't execute. I think you mean max, or something.
>>
>>54177442
Question list[10];

is all you need
>>
>>54177514
How does it know that the q1, q2, ect objects are in there tho?
>>
>>54177442
read the fuuarking textbook
a good C++ book is Absolute C++
it has a cake on the front
>>
Thinking about a masters in computer vision.

Thoughts on the field?
>>
>>54177550
read a fucking book jesus christ

when you say
Question list[10];

it builds an array of 10 questions
how fucking hard is it
>>
>>54177565
neato
>>
>>54177569
>>54177553
Don't get mad at me guys i'm trying my best. Also I would probably take a look into that textbook if I didn't have a final for the retched class in a week.
>>
>>54177637
I'm the same guy getting mad at you
It's stupid that they're teaching you C++ as your first language anyway

It would help you to read through the first chapter or two of that textbook honestly
>>
>>54177637
fail it, you deserve to. now fuck off.
>>
>>54177647
The thing is this isn't my first language. I took python before this and now i'm taking this c++ class in conjunction with a java class. Java goes smoothly as all hell and I can usually knock out my weeks work in an hour or two but c++ on the otherhand takes hours upon hours.
>>54177651
believe it or not I actually have a b+ in there right now :)
>>
>>54177663
>python first
even worse
>>
>>54177028
>>54177132
It's some retarded Haskel variation i think. My professor asked me to do some shit in it, and I really know pretty much nothing of it
>>
if the first time you program is in a class you are always going to fail where others who taught themselves succeed
>>
File: good stuff.gif (984 KB, 245x180) Image search: [Google]
good stuff.gif
984 KB, 245x180
>>54176776
Thank you very much, I think I finally get it now.
>implying I won't forget it again

Lower addresses store least significant bytes on little endian machines.

Little Endian
Address | Hex | Bin // 8bit word
--------+-----+7--- ---0
0x103 | DE |1110 1111
0x102 | AD |1011 1110
0x101 | BE |1010 1101
0x100 | EF |1101 1110
2^7=128 bit ^ ^ 2^0=1 bit

Address | Hex // 16bit word
--------+15--0
0x102 | DEAD
0x100 | BEEF

Address | Hex // 32bit word
--------+31------0
0x104 | B16B00B5
0x100 | DEADBEEF

<-- increasing address
Addr |0x103 |0x102 |0x101 |0x100
Hex | DE | AD | BE | EF


Which in turn makes data stored in files feel "natural" in big endian, growing to the right.
6865 6C6C 6F5F 776F 726C 640A
h e l l o _ w o r l d \n


I will have to remember it's Hebrew-like right-to-left addressing by Jews from Intel.

I also looked at UTF-8, since it was partly of my interest and I see it's actually storing multibyte characters as 8 bit words.
>>
>>54177682
>this is what "self-taught" autists actually believe
>>
>>54177647
C++ is the best first language. It weeds out the bad programmers.
>>
>>54177734
C++ is a bit of a clusterfuck tho
>>
>>54177714
I'm not a self-taught autist, but when I started University had already been programming for a couple years. The people that are forced to drop out are always the ones that started programming when they started classes, and never programmed outside of assignments.
>>
>>54177744
Not really m8. It's programmatically logical.
>>
>>54177734
For that purpose it's great, but for practical learning purposes I disagree. You could say Haskell is a good first language, because it weeds out even more idiots.
>>
>>54177734
>>54177744
I know i'm not comparing it to much from the hatred both java and python get on here, but python and java are a lot less fucky than c++. Plus my teacher insists on making us use imported files for every fucking program and it's fucking annoying as all shit.
>>54177752
All programming is logical m8
>>
>>54177752
I mean in terms of features, syntax, etc. It's a Frankenstein monster. Initializer lists are a good example

constructor(int a, char b) : a(1), b('a') {}


The committee decided that they wanted a way to initialize variables outside of a constructor's body. C++ already has a pretty well defined grammar though, so they cobbled some awkward looking shit together.
>>
>>54177764
>All programming is logical
good response

C++ is fucky, Java stripped C++ of its fuckiness and resulted in streamlined crap, Python is a shortcut to programming, so it's bad to learn first, but great to learn second or third.

C is the best language to learn first, guaranteed.
>>
>>54177793
>Python is a shortcut to programming

because it's a 4th gen language or for other reasons?
>>
I briefly considered using C# or F# unironically but then I realized that something like 50% of .net libraries are pay-for, and 80% or so of the libraries I looked at were closed-source.
>>
>>54177352
thanks for the suggestion. I didn't think the modal could annoy the users..
>>
>>54177844
I assume by 4th gen language you mean heavily abstracted, very easy to write, etc, then yeah.
It's great to learn python when you already know how to program, all of the fundementals, etc.
You're far more out of touch if you learn how to cast spells before learning where magic comes from.
>>
>work for computer repair shop
>boss wants to write support application for customer computers
>prototype in nodejs with electron framework for portability
>notice project is 120mb with literally 20 lines of html, 30 js, and 30 css
>apparently the electron framework is fucking 120mb

is this the future?
>>
>>54177844
Because it's a 4th gen language full stop. It's built on 4 generations of understanding of programming, but a beginning programmer isn't. That's why a lang like C++ is good for learning.
>>
>>54177898
>assume by 4th gen language you mean heavily abstracted, very easy to write, etc, then yeah.

that's pretty much exactly what it means

https://en.wikipedia.org/wiki/Fourth-generation_programming_language
>>
>>54177906
relevant
>>
>>54177920
Haven't heard the term before. Neat, thanks.
>>
>>54177912
I nominate this post for most retarded /dpt/ post of the year!
>>
>>54177931
what about C lol
>>
>>54177906
windows 98 was only around 185mb installed.

but electron is so big because you're embedding, pretty much, chrome with every application

>>54177931
this isn't really relevant, he's talking about disk space, not memory usage and java != javascript
>>
>>54177945
Care to explain your wrong position?
>>
>>54177931
>rust using that much memory
>everything beating C++
>felix and nim not most useless in both categories
lol
>>
>>54177906
People are trending towards that since machines have gotten more powerful. Is it easy? Yes. Is it fun? No.
>>
>>54177967
>>54177962
>>54177954
>>54177931
https://github.com/kostya/benchmarks
>>
>>54177962
>>54177975
man i just want something i can package for windows or os x in one go that isn't bloated as fuck. is that so much to ask?
>>
>>54177989
>dmd performed faster then gdc and ldc2 on the first one
welp, it's complete bullshit
>>
>>54177704

>I will have to remember it's Hebrew-like right-to-left addressing by Jews from Intel.

It actually has its uses. Namely, it's easier to downcast. Say I have a 64 bit integer. I want to convert to 32 bit. Rather than adding 4 to the address and then loading the word into memory, I can instead just load a word from the same address, since the lowest bytes are stored at the lowest addresses. While Little Endian may seem confusing at times, but it's damn useful.

Also, x86 isn't the only architecture that uses Little Endian -- it's just that it's the most commonly used architecture that only uses Little Endian. ARM and MIPS are both considered Bi-Endian, meaning they can be configured for either Little or Big Endian (and ARM also supports something called Middle Endian, which is a weird thing). The ARM chips in your phone are probably Little Endian.
>>
File: Screenshot_20160423_125008.png (11 KB, 125x536) Image search: [Google]
Screenshot_20160423_125008.png
11 KB, 125x536
>>54177989
yep, I'm sure all these solutions are pretty much identical but for the choice of language
>>
>>54177989
D D D D D D
>>
>>54178052
even though they were using a 2 year old version of LDC

surprised gdc did that shit on some of them. I wish they showed the compiler flags
>>
>>54177989
Python - 472 seconds

KK EE KK
>>
>>54178101
Here https://github.com/kostya/benchmarks/blob/master/brainfuck/build.sh
>>
>>54177871
is this true?

I'm starting to learn C#, only because there are tons of job postings for C#/.NET dev in my country, plus because of some libs for mobile/cross platform stuff
...
>>
>>54178134
>in my country
poo in loo?
>>
>>54178024
I'm aware of advantages, I appreciate them. What you quoted I rather treat as a happy little merch- mnemonic.

I'm currently playing with ARM assembly, namely writing a minimal assembler (fuck GAS), that's why I ran into such problems.

I'm still not sure what language would be best to quickly implement it, that would take file handling off my shoulders and let me concentrate on coding up translator. Currently poking Go, but programming such things in it is a seriously annoying. I'm considering Perl, Awk or even bash. C would be nice, but I want to move to ASM anyway, so it's more of a throwaway assembler, to get things started.
>>
>>54178132
>no -boundscheck=off
shenanigans!
>>
>>54178134
I only checked for things that matter to me (GUI, web, gpgpu). Maybe it's not the same in other domains.
>>
help, how should I format my indenting on this?
// Returns the last 20 s
function getLastX(socket){
GameRoom.find({}, 'cards userid roomID dungeon region date')
.sort({date:1})
.limit(20)
.exec(
function(err, rooms){
if (err) return console.error(err);
socket.emit('lastXentries', rooms);
//console.log(rooms);
});
}
>>
Would learning javascript as my first language give me bad habits?
>>
>>54178183
The indenting is fine, but please:
){ -> ) {
>>
I'm working on a Roguelike game for fun

I want to expand the number of items I have in the game - currently I have just one (health)

My idea was to declare different struct types - weapon, artifact, consumable, etc., each one with variables specifically tailored to its purpose. However, if I want to store say 1000 of these things that could possibly exist, how would you recommend doing that? Should I create some sort of text document that the game can then read data from?
>>
>>54178196
yes, unless you plan on only ever programming in JavaScript
>>
>>54177787
this
>join a startup
>3 other coworkers for programming
>they all do initializer lists in a completely different format
>they saw nothing wrong with this
>neither did the manager
>>
File: bill nye girls in tech.jpg (17 KB, 236x236) Image search: [Google]
bill nye girls in tech.jpg
17 KB, 236x236
why do you keep bullying girls who want to become koders?
>>
>>54178206
It doesn't have to be a text file, but it sounds like it should be a file.
What exactly do you mean store them? Do you mean where you can find them in the game? Or the inventory?
>>
>>54178217
>startup
>sepples
run
>>
>>54178217
that's what you get for joining a hipster startup that has no guidelines/can't use a linter hook on commit
>>
>>54178226
but anon, we are girls
>>
>>54178212
I just thought it would be easier.
>>
>>54178197
are you suggesting that I use the new arrow function syntax? I mean, I can check and see if it's supported, but for multiple args, i think I'm still going have to do something like
(arg1, arg2) => {

}

rather than
function(arg1, arg2){

}


>>54178196
maybe not if you
"use strict"
>>
File: 1437519264846.jpg (115 KB, 640x960) Image search: [Google]
1437519264846.jpg
115 KB, 640x960
>>54178226
>>54178247
This, pic related is me
>>
>>54178258
he's suggesting you do
function(args) {

rather than
function(args){
>>
>>54178226

Bill Nye is right, we need to even things out. How come black men are only 6% of the population, yet they get to be 51% of homicide offenders.
>>
>>54178197
oooooh you mean put spaces between curlies and parenthesis. sure, i usually do that anyways.

QUICK! Remind me how to change my tabs to 2 spaces in VIM so I can stop with this 4 space tabbing that apparently javascript snobs don't like
>>
>>54178258
n o
I guess the format of my post was not clear
I meant:
s/){/) {
>>
>>54178227
I have a list of like 1000 objects - swords, axes, armor, etc. Rather than just hardcode this in (to fit with the procedurally generated overview), I want to be able to randomly select from my list of objects to place in a level. I'm looking for a good way of storing this object information that works well with C
>>
File: me.jpg (89 KB, 606x458) Image search: [Google]
me.jpg
89 KB, 606x458
>>54178269
>>
>>54178278
when will this sed meme end
>>
>>54178281
Me on the left
>>
>>54178269
LONDON
O
N
D
O
N
>>
File: thereugocutie.png (31 KB, 555x208) Image search: [Google]
thereugocutie.png
31 KB, 555x208
>>54178270
>>54178197
>>54178278
>>
File: Sif.gif (35 KB, 230x200) Image search: [Google]
Sif.gif
35 KB, 230x200
>>54178272
delete this
>>
>>54178280
That's a tough call. I think the best option would be an array, but of course on start, read the data into the array from a file. I don't think it's worth opening, reading, and closing a file any time you want to access it. In factt that's retarded.

If you're worried about having an array of that size present in your program, don't worry about it. To make yourself feel better, maybe use unsigned chars instead of ints if you have numbers that are always under 256, for example.
>>
>>54178297
thanks darling
I actually just realized the exec(function...
Maybe indent that once? Logically you would think it would be indented once more than the .exec( but honestly I don't know.
>>
>>54178297
jesus ew use " for strings

and also is this that dumb language where you literally can't put the braces in the right spot?
>>
>>54178328
Yeah that was my biggest concern, you're looking at a decent amount of memory to store the items but I think that's less worrisome than the system call overhead to read from the file during runtime

Thanks !
>>
>>54178376
Just think about all of the data that's always present in programs you use, even games you play. They have all of their assets loaded constantly, using loads of ram. Yours will be fine.
>>
>>54178272
Based tripfag
>>
>>54178367
it's javascript
>>54178358
i wanted to avoid indenting a million times
>>
>>54178428
Make your indent size 4 instead of 8
:)
>>
>>54178441
It is four
>>
>>54178441
make it 3 spaces
>>
>>54178479
then make it 8
>>
Why is Haskell so perfect?
>>
>>54178543
good question
>>
>>54178543
Let's see it average two ints
>>
>>54178562
>ints
not in haskell you dummy
>>
>>54176725
http://nask.co/L/LO1HIh5JOP
>>
>>54178569
discrete quantities?
>>
>>54178562
Prelude > let average a b = (a + b) % 2 
Prelude > fromRational (average 2 3)
2.5
>>
>>54177753
haskell isn't hard though.
tell me what's hard

inb4 monads
monads are just a class of types that have extra information and support composition through (>>=)
that's all it is, a monoid
>>
>>54178134
south america, they ask mostly for web devs. my interest is mobile/UI stuff.
>>
>>54178642
crockford's law right here
>>
>>54178663
fuck. this ^ for >>54178147 and >>54178178
>>
wo http://nask.co/L/2ivNUVcbp4?a=1
>>
>>54178670
I'm sorry I just saw it in a jewtube vid
but it makes sense
(.) is a way for functions to be added, and id is mzero
(>>=) is like (.) but for functions that return take pure values but return monads
and return () is mzero
maybe I'm just dumb
>>
What are the advantages of encapsulation?
>>
>>54178808
you prevent the whack-a-mole effect
>>
>>54178808
modular program design. It seems like shit at first but it can be helpful.
>>
>>54178808
a section of an encapsulated program only need to know about certain things, making reasoning easier
>>
>>54178772
one of the best explanations ive seen for this was monads as composition on a railroad track: http://fsharpforfunandprofit.com/posts/recipe-part2/
yes, it's a generalized composition, but it's more powerful than just that.
>>
I love you guys so much I would like to paypal one of you guys a pizza
>>
>>54179125
i accept your offer sir
>>
>>54179007
Yes and the really cool thing is that the same syntax can specify loops. For example
numbers :: [Int] 
numbers = do
a <- [1,2,3,4]
b <- [1,2]
guard (a < 4)
return (a,b)

is roughly equivalent to
List<Int> numbers = []
for (Int a : [1,2,3,4]) {
for(Int b : [1,2]) {
if (a < 4) {
numbers.addAll( [ (a,b) ] );
}
}
}
>>
Are there any higher level libraries for programming for X?
>>
>>54177569
>read a fucking book jesus christ
>how fucking hard is it

Dude's a beginner and seems normal enough, asking nicely for help. Here comes someone with the knowledge and instead of helping, you imply he's stupid for not having the same experience as you.

You suck dude. We were all new at one point. Try and sympathize, like a human being would.
>>
>>54179309
I know this friendo, my excuse is that I was stressed out irl at the time; I'm sure it did no harm to him anyway

You also suck for being a white knight though, even though you're right
>>
>>54179309
When I was a beginner I didn't ask a bunch of strangers on the internet that have a reputation of being not nice to beginners because I'm not retarded
>>
am i correct in saying the difference between an interface in java and cpp is that in java an interface cannot contain the logic of the method bodies and instead servers purely as a class with method prototypes, while in cpp an interface is mroe like an abstract class where the methods aren't just prototypes but can also have logic inside of them?
>>
>>54179388
interface in java = pure abstract class in cpp
>>
i hate all of you
>>
>>54179406
abstract classes in cpp can have logic in their bodies though right? how is what you said the case then because in java cant interfaces not contain any of that logic and serve as only prototypes?
>>
>>54179413
It's okay pajeet
>>
>>54179420
>>pure
>>
>>54179432
oh thanks i get what you're saying
>>
>>54179339
I almost killed myself because you got angry at me over question lists
>>
>>54179443
Essentially, C++ has the option to define member functions in your 'interface' while not defining others, Java does not (If I know correctly, I don't know Java intimately)
>>
>>54179444
You can chose to either be upset by being a noob or do something about it
>>
>>54179444
kek
>>
File: encapsulation.png (125 KB, 613x349) Image search: [Google]
encapsulation.png
125 KB, 613x349
>>54178808
>>
I need a language to help with configuration management of a bunch of isolated systems.
everything my company uses is batch scripts. it's getting old quick
I know a good amount of programming fundamentals and some OOP
>>
>>54179505
python
>>
>>54179505
python
>>
When I see example programs for libraries, I often find people using a lot of global variables, referencing them in their functions, and not passing anything to them. Should I actually be programming like this?
>>
>>54179656
No dont use a lot of global variables, its bad practice. Read the follow:

http://c2.com/cgi/wiki?GlobalVariablesAreBad
>>
>>54179501
>the places to look for the bug are localized
only if you completely ignore getters and setters and make all logic for a data type part of the class. which makes it confusing as fuck because now none of the code is tied down to the place where it should logically be.
>>54179656
no, people just write shitty code in examples because of laziness. it gets annoying having to update things to each release of your library so you end up writing shitty/hacky code for the tests/examples every single time
>>
Amazon Web Services and Bizspark were both recommended to me as a free servers for kickstarting a multiplayer game.
Which should I go with?
>>
>>54179684
What the hell is this website anyway, it's got a bunch of ramblings, but they're so interesting
>>
File: 1461192120584.gif (2 MB, 320x235) Image search: [Google]
1461192120584.gif
2 MB, 320x235
>custom computation expressions in f#
>>
Reposting here since the solo thread wasn't getting posts.

What's the best way to insert an element into a container assuming a finite amount of memory? The course I'm using says to replicate the internal array with +1 size, copy the data over, and delete the original. Is there a better way to insert, without doubling the memory use?
>>
>>54180082
just use a linked list
>>
>>54180082
doubling is the best method

>>54180097
top kek
>>
File: 1453020605537.jpg (8 KB, 196x250) Image search: [Google]
1453020605537.jpg
8 KB, 196x250
>>54179917
I'm not sure, but it sounds like a smart autist from /g/ wrote it. Thats why i like it kek. The dude knows what hes talking about
>>
>>54180108
Doubling? What do you mean?
>>
>>54180159
he means have a size (number of elements) and a reserve size (number of allocated elements)

if the reserve is bigger than the size + number of new elements, just increase the size
otherwise, double the reserve and allocate twice as much memory
>>
>>54180159
don't use +1 size, use *2 size
i.e., in C:
if (vector->size == vector->memory_space) {
vector->array = realloc(vector->array, 2 * vector->memory_space * sizeof(the_type_of_the_array));
vector->memory_space *= 2;
}

This way you're only reallocing if you hit the threshold 2x your past threshold, it's been proven to be the most efficient method.

Some people think 1.5x is better, because you will eventually claim back memory you once used, see http://stackoverflow.com/questions/1100311/what-is-the-ideal-growth-rate-for-a-dynamically-allocated-array for a better explanation. I personally disagree with this idea, because it assumes that previously used memory is contiguous, unless I'm misunderstanding.
>>
>>54180116
>total lack of CSS
>fuck web devs
>GoToHell

definitely a /dpt/tard
>>
>>54180218
So you're saying that the array should always be sizeof(T) * N^2 bytes long? That makes sense, but what if you approach the maximum memory? EG the array is 30 bytes long and there is 20 more bytes of memory left. Should you go to 50 or should you throw an error and refuse to size-up?
>>
>>54180263
Go to 50
>>
>>54176725
I just found out, someone tried to submit feedback, and it returned an error... I hadn't noticed this bug, thanks anon, and I'm sorry that I couldn't receive your feedback ;_;
>>
>>54180293
Okay, thanks. Another scenario: There is 50 bytes of memory. 20 bytes are taken up by a char[]. How do you size up the char[] to 40 bytes in the available space?
>>
File: flat_1000x1000_075_f.u5.jpg (162 KB, 937x1000) Image search: [Google]
flat_1000x1000_075_f.u5.jpg
162 KB, 937x1000
>>54175632
How much memory does the computer set aside for my program, especially if it has a lot of dynamically sized data structures?
>>
Are scripters allowed? I write powershell scripts.
>>
What language m8. This varies wildly
>>
>>54180340
Is that all you do?
>>
File: 1452346762178.png (378 KB, 1450x1080) Image search: [Google]
1452346762178.png
378 KB, 1450x1080
sorry if this is the wrong thread, didn't feel like it was important enough to merit its own, but does anyone have an updated version of this pic and/or the other style (from v1.2/1.4/3.0~), perhaps from 2016? cheers
>>
>>54180313
I just gotta say I'm autistic about website design and you did a bang up job anon, proud of you
>>
>>54180368
>tfw too colourblind to see the difference between the yellow and green
>>
>>54177989
Christ, Python is so fucking slow, why the hell do people use that shit?
>>
>>54180358
As far as windows goes, yes. I'm a sysadmin so I try to script as much of my job as possible.
>>
>>54180399
really?
well, I gotta say, I got lots of help, but thanks for the compliment :)
>>
>>54180407
>but muh abstraction
>>
>>54180319
If you can't get enough contiguous memory for the minimum size, it fails

Also, dunno which language you're using but C++'s vector has a shrink_to_fit function that shrinks the reserved memory to the minimum to hold the data
>>
File: merge.png (41 KB, 1336x288) Image search: [Google]
merge.png
41 KB, 1336x288
tfw your professor is teaching you how programming jobs work in the real world
>>
>>54180416
Yup, it's simple, formats correctly, nothing superfluous, and even processes quickly. Things most websites don't do these days unfortunately.
>>
>>54180454
Do you think he was conscious when writing that sentence?
>>
>>54180463
I run my web app in openshift, and the backend is written in Go :)

BTW, I open-sourced it partially, here's a lib to use TTS engines to create media files (audios, videos):
https://github.com/pqyptixa/tts2media
>>
>>54180468
he was probably crying inside while he copied down the curriculum from the higherups
>>
>>54180468
unfortunately, yes. he's the second teacher of the class and he just started this year, he's repurposing a lot of material from the other teacher since he has to. the other teacher, by sheer coincidence, is the author of our textbook. makes ya think huh.
>>
File: microexpressions-contempt.jpg (28 KB, 524x336) Image search: [Google]
microexpressions-contempt.jpg
28 KB, 524x336
>>54177714
95% of class-taught programmers are going to be only competent with making CRUD apps, forever
Luckily the job market is all about making CRUD apps
>>54179917
>>54180116
Hi newfags, C2 was the first wiki, it's crowd sourced by everyone who was programming in 1995+10
example page http://c2.com/cgi/wiki?RichardStallman
>>
>>54175715
It's very actively developed, benchmarks are platform-dependent and compiler version-dependent so they become obsolete rather quickly. Who's gonna bother wasting time running benchmarks and posting results when they are pretty much useless. If you're not too lazy you could just run some benchmarks yourself though, if you don't know what algorithms to implement - check out source code of https://benchmarksgame.alioth.debian.org/ submissions, most likely you won't have to modify code of C# solutions to compile them for .net core, so you could compare them to mono, clang, whatever you want
>>
wonder how Go compares to C# in terms of performance and resource usage
>>
>>54180857
Blows it out of the water in both, but you can expect the fleet of pajeet.nets to come and defend C#
>>
File: 1454424592785.png (245 KB, 382x417) Image search: [Google]
1454424592785.png
245 KB, 382x417
>>54180552
>The moreyouknow.jpg
Never would have guessed, thats cool.
>>
>>54178275
:set tabwidth=2
>>
>>54178134
Not true at all.
>>
File: 1440239787945.jpg (65 KB, 1280x720) Image search: [Google]
1440239787945.jpg
65 KB, 1280x720
/g/ help me, I have no motivation to work on my projects, and my design skills suck which contributes to my first problem.
>>
>>54180857
C# uses a JIT compiler (it gets compiled to the native architecture the first time it runs), so except for that first run, both are comparable. C# is a higher level, more productive language, with a much bigger standard library, ecosystem and third-party library support so in the end C# makes *you* faster.
>>
>>54181670
aqua is a slut
>>
>>54181853
Ok, that wasn't the point of my post though.
>>
>>54181857
she's still a slut lmao
>>
File: GiXfONL.jpg (664 KB, 2592x1936) Image search: [Google]
GiXfONL.jpg
664 KB, 2592x1936
Ask your favorite programming literate anything
>>
>>54181894
>reddit
>>
>>54181894
post butt
>>
>>54181933
what about it?
also check'd
Thread replies: 255
Thread images: 29

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.