[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: 322
Thread images: 36

File: March_for_Science.jpg (140KB, 1200x974px) Image search: [Google]
March_for_Science.jpg
140KB, 1200x974px
What are you working on, /g/?

Previous thread: >>60077582
>>
>>60084350
First for D
>>
>>60084350
It's an OK joke.
>>
>>60084387
Necrophilia is illegal
>>
>>60084445
Says the one who can't stop spouting dead memes
>>
File: codemonkey at facebook.png (360KB, 391x391px) Image search: [Google]
codemonkey at facebook.png
360KB, 391x391px
Friendly reminder that this is your life at any sufficiently large software company in 2017.
>>
His sign needs a semaphore
>>
>>60084465
He's just tired of the degeneracy at the floor.
>>
File: your life at facebook.jpg (1MB, 2048x1537px) Image search: [Google]
your life at facebook.jpg
1MB, 2048x1537px
>>60084502
This is your life at your adult daycare startup!
>>
>>60084521
Did they try to recreate an Indian sweatshop?
>>
What's the best IDE for C/C++?
>>
>>60084611
Microsoft Word
>>
>>60084465
This is the guy that does all the work >>60084521 these people should be doing.
>>
>>60084521
That must be an horrible place to work.
>>
>>60084611
Pelles
>>
>>60084630
For Linux?
>>
>>60084611
MSVS but only if you're on Windows and don't need C++14/17 that much
otherwise just a text editor with a bunch of plugins
>>
>>60084521
>BLM poster
>not a single black person in sight
MUH EQUALITY
>>
>>60084637
lol I thought the same thing first time I saw that pic
>>
>>60084251
Not exactly.
There's plenty of situations where function calls are good. They're more efficient because of instruction cache and other such things.
It's usually referred to as outlining when the compiler takes straight sequential code and pulls it out into functions which it calls.
And it's the reason the compiler doesn't always inline eveything, it's not always the best thing to do.
>>60084224
Yes that's exactly what's going on. The thing is that for operators you in general have very small functions that would be more efficient if they weren't called as functions but rather had their assembly just inserted where the call was. The call is superflous and a function call can be seen as an optimization barrier. It increases the dependency between registers and addresses so the optimizer has less room to move.
So ideally (without regard for executable size) you'd have the compiler inline EVERYTHING and then outline stuff for you as it sees fit. But optimization is hard, it's not really feasible to do that right now.
So while operator overloads aren't actually a problem in the abstract (they shouldn't have performance impacts at all, like any function call) they happen to be very harmful because code that looks like
vec4 a,b,c,d;
d=a+b*c;

Has 3 function calls and potentially an overloaded assignment operator (making 4).
It's very easy to overwhelm the compiler like this.

But as I said. It's entirely valid to use operator overloading, you just have to look at your assembly after the fact when you care about the performance and remove it if necessary.

It's a developing aid. It's unnecessary to write out the non-operator overloading version before there's a performance concern. That's one thing that's very good about operator overloads. Unlike a lot of abstractions they're very shallow so they don't have a large code impact, they're easy to remove when you need to. It's just a copy and paste.
>>
>>60084465
If kill myself if I had a Facebook ™ branded plushy on my desk.
>>
Why am I stuck in the while loop?

#include <stdio.h>


count_char(){

long num_of_chars;

num_of_chars = 0;
while (getchar() != EOF)
++num_of_chars;

printf("%ld \n", num_of_chars);

return 0;
}


main() {


count_char();

}
>>
>>60084729
Hugging those plushies is his only emotional relief in this development hell. You'd grow to appreciate them.
>>
>>60084465
>every day I drift further and further from humanity
>>
>>60084723
>And it's the reason the compiler doesn't always inline eveything, it's not always the best thing to do.
Ignoring bugs or the compiler doing the wrong thing. Obviously.
But if it was as obvious as "inline everything" it could easily be done and we wouldn't even talk about this.
>>
>>60084738
I don't know what getchar() is doing.
>>
>>60084738
what's EOF
>>
>>60084738
because the loop waits for you to input a EOL character and you don't.
>>
>>60084812
'\004'
>>
>>60084820
This.
>>
I want to write an HTML parser just for fun. But then it occurred to me: I would have to read the entire file into a string before I could even start parsing, because I don't know where the matching end tag for the currently open tag is. Am I correct in this assumption or is there a more efficient way? I don't really want to buffer the entire fucking file.
>>
Is it possible to create a n number of functional elements in winforms?
I am making a program that reads user input, and upon that, it displays a n amount of elements (one element includes 1 label, 2 radio buttons, 1 image which should change upon the selected radio button and 1 static image), all with different data.

I alrady made it so, that the static picture displays n amount of times, but I dont know if it's possible to create usable radio buttons for the other image.
Please help, I've been working on this for the last week.
>>
>>60084723
Can't you inline the function call in c++?
Kinda like this:
use std::ops::Add;

#[derive(Debug)]
struct Foo(u32);

impl Add for Foo {
type Output = Foo;

#[inline(always)]
fn add(self, rhs: Foo) -> Foo {
Foo(self.0 + rhs.0)
}
}

fn main() {
println!("{:?}", Foo(2) + Foo(5));
}

Output: Foo(7)
In Rust, but the idea is the same.
>>
>>60084820
>>60084837


I thought getchar() adds it at the end of the user input?
>>
>>60084850
In a real-world environment, you don't have a "file", you get the page via http and can parse chunk by chunk.
That being said, you can easily memory map the file, but just think about how long it takes you to open a 7MB jpeg, it doesn't take long and your html file won't easily surpass that. And then there is the fact that you're doing this just for fun and performance shouldn't be a concern anyway.
>>
>>60084861
You can but it doesn't always happen even though it should.
This is all in response to: >>60083619 >>60083804
An example of the compiler not doing the right thing.
It's unlikely that Rust solves that better than C++ given how much effort there is behind C++ comparatively but who knows.
>#[inline(always)]
It exists on (virtually all) compilers, not as a language feature. But in C++ it's constraining the compiler to never break that code out into a function. Which is also harmful.
>>
>>60084902
http://en.cppreference.com/w/c/io/getchar
>>
>>60084902
Assuming this is user input from stdin (you type shit into the terminal) how would you tell it to end your input?
>>
>C++
In all the mess of standard library iterators and streams, how the fuck do I just read a file containing a bunch of 32bit words into a std::vector<uint32_t>? I can read into a char vector and reinterpret_cast, but that's shit.
>>
>>60084907
>It's unlikely that Rust solves that better than C++ given how much effort there is behind C++ comparatively
This needs to be emphasized. Rust is very young and does not have even a tenth of the work that has gone into optimizing C++. Maybe in 2037 it will be as fast as C++ is today.
>>
>>60084931
man 2 read
>>
File: 1485736556566.gif (2MB, 200x150px) Image search: [Google]
1485736556566.gif
2MB, 200x150px
>>60084350
I chuckled
>>
>>60084947
That's unportable C.
>>
>>60084947
man 2 girl
>>
>>60084961
>C
>unportable
what?
>>
>>60084961
>implying reading 32bit words is readable in C

>>60084963
Is it a joke? Really?
>>
>>60084919
>>60084920


So I noticed ctrl-d will end it, but it returns 1 higher than expected, is it counting ctrl-d as a character?
>>
>>60084931
Sane, straightforward and most efficient way:

vector.reserve(size_of_file / 4)
uint32_t *p = vector.data()
read directly into p with fread() or filestream.read()
(assuming endianess of file data is same as system program is running on, and that they are all contiguous of course)
>>
>>60084970
read() is in unistd.h which is unportable.
It is in C (I asked for C++) AND it is unportable. Not C is unportable.
>>
>>60084970
it's unix c, not portable to nt
>>
>>60084981
Difficult know. It's not the most normal way to do input to actually have the user use ctrl+d to terminate. Can't really help you. If you open your debugger or print the characters as they're input you might catch it. It shouldn't actually count the EOL since it breaks when it sees EOL.
>>
>>60084981
No idea, it prints the correct amount of inserted characters for me.
>>
>>60084981
ctl-d is the character '\004'
it is not EOF
>>
>>60085058
Don't be rude anon you're just causing confusion here.
>>
what's the cleanest way to make this also record the nominations it uses? a tuple of an integer and a list of values for the number of coins used for each denomination? maybe it's just b/c i don't use tuples in python hardly at all but that seems a bit complicated

def makingChange(denoms, amount):
optimums = {}
optimums[0] = 0
optimums[1] = 1 # to make change for 1 cent, use a single 1 cent coin
for i in range(2, amount+1):
next = [i-x for x in denoms if i-x >= 0]
optimums[i] = min(map(lambda x: optimums[x], next)) + 1
return optimums[amount]

for i in range(1, 101):
print(i, " : ", makingChange([1,5,10,25], i))
>>
How do I implement a json parser in C?
I mean, how would I deal with nested json subvalues of arbitrary depth?
This just seems like it would bloat up my parser a lot.
>>
>>60085091
With a stack.
>>
>>60085070
Technically EOF is platform specific.
>>
>>60085091
Parsing JSON isn't trivial: http://seriot.ch/parsing_json.php
>>
>>60085100
Yes. That's what I'm saying. It's not helping someone who's new to consider that right now.
>>
>>60085115
No. Please that's a joke.
>>
>>60085091
You use a json library instead of wasting your time.
>>
>>60085077
because looking at it now it seems like i won't be able to do the list comprehension and lambda map if i want to also do that. that i would have to use loops
>>
>>60085012
unstid.h is part of the Portable Operating System Interface.
>>
>>60085185
Implementd by less than 1% of the computers.
>>
>>60085194
Are you saying there are over 150 billion computers in the world?
>>
>>60084851
Please
Help
>>
Learning C. Am i going to run into problems switching between Linux and FreeBSD? Will binarys work as long as they're both compiled on x86?
>>
>>60085226
It depends of what a computer is.
>>
>>60085129

no i thought it was a good comment, at least I know the code sorta works,
>>
>>60085234
GNU/Linux*
>>
>>60085243
Well android accounts for 1.4 billion alone, so if that is <1%, there as to be at least 139 billion non-POSIX computers out there.
>>
>>60085234
They are not binary compatible, but FreeBSD has a Linux emulation layer which works reasonably well, but if it's a panorama making use of new Linux-kernel specific stuff, it's probably not gonna work.
>>
>>60085271
Ho shit I forgot the android "Linux". But they're not really computer.
>>
>>60085271
Sure Android has builtin POSIX?

OTOH servers are overwhelmingly unices and if VMs count as computer then we're done arguing.
>>
>>60084685
LibreOffice Writer
>>
>>60084738
should be
while ((getchar()) != EOF)
>>
>>60085232

>>>/sqt/
>>
>>60085234
Who cares about binary compatibility besides Jewish software vendors? My bytecode is source code, hacker at heart till death do us apart!
>>
>>60085319
Bullshit. Don't listen to him, parens (except function call parens and if/while/for parens) are used to counter operaror priority. In this case, those are unnecessary
>>
>>60085319
No, that'd be only true if you were assigning to a variable with getchar() inside of the while statement.
>>
>>60084851
Well it should be or else winforms doesn't deserve the title of programming language, which I wouldn't know. Now fuck off.
>>
>>60085323
The post is programming related, but because nobody can answer it, it belongs in sqt?
Fuck off pajeet
>>
>>60085337
There is literally nothing wrong with being jewish.
>>
>>60085405
>pajeet
pls no racism
>>
>>60085234
Speaking of which, how does one ship binaries on Linux to make sure they run on various systems?
All of my libraries that I use are not GPL-cancer so I can statically link them, will that suffice given GLIBC major version on the target system is the same?
>>
>>60085445
>>>/b/
>>
bwahah holy shit! the memes are real
https://www.youtube.com/watch?v=CRUa_09IOVU
>>
>>60085261
Trash/Linux*
>>
>>60084940
Well there's LLVM. Offsets a lot of that.
>>
>>60085534
Now you have two problems.
>>
>>60085505
Trash/systemd*
>>
>>60085492
OOL NI OOP
>>
>>60085554
How so?
>>
>>60085492
https://www.youtube.com/watch?v=zPTY1hKq3SU
>>
>>60085077
Please respond
>>
I want to have a single game world state that's operated on by a lot of threads (client connections). I could probably queue up all actions that each client has taken (one queue per client), and then on each server tick, copy over those actions and calculate them then broadcast the new game world state to every client. Is there a better way to do this?
>>
кoт
>>
>>60085653
man youtube-dl
>>
idea stolen. thanks! should be a fun weekend project
>>
>*** - APPLY: argument list given to SYSTEM::ERROR-OF-TYPE is dotted
> (terminated by
> "Lambda lists with dots are only allowed in macros, not here: A")


agh what the hell. there are no lists with dots in my program...
>>
>>60085612
>nareshit
>>
Trying to download albums from youtube.

I'm running into a small problem: When I download the audio from the URL I input, youtube-dl converts it into a webm file, even though I specify the output file to be in mp3? What am I doing wrong?
>>
>>60085697
>weak typing
>>
>>60085653
https://askubuntu.com/a/178991
>>
>>60085644
Wrong board.
>>>/v/
>>
File: dyingorangutan.jpg (25KB, 579x329px) Image search: [Google]
dyingorangutan.jpg
25KB, 579x329px
>>60085492
>1000 students in a single classroom
Holy shit
>>
>>60085703
>>60085673
Thanks, but I accidentally forgot to include the image here>>60085701 . I meant to say that I'm trying to make a python script, so I'm not terribly sure this would work for my purposes.
>>
>>60085605
LLVM is big, slow, buggy, produces substandard machine code, supports very few architectures, contains hard-coded assumptions that are invalid on quite a few architectures. New backends are very difficult to write, break frequently, and are unceremoniously dropped as soon as the LLVM developers don't feel like maintaining them. The toolchain is not self-sufficient, depending on system linkers, despite all the hype about cross-compilation being built in.

LLVM is a parasite on the GCC ecosystem.
>>
>>60085735
What's the matter pajeet? Are you triggered because someone is programming something more complex than fizzbuzz?
>>
>>60085291

Ok that makes sense. But basic programs should compile on both without changes atleast? I guess what I mean is, the standard libraries are relatively consistent and/or the same?
>>
>>60085774
I'm simply saying that your post doesn't belong on this board.
Fuck off to either one of these:
>>>/v/
>>>/vg/
>>
>>60085740
The webm is the video right? Hasn't it also extracted the audio and not told you on the log? And there's a keep-video option that you can probably set to False if you don't need the webm... Well it should be False by default AFAICT
>>
>>60085746
>LLVM is a parasite on the GCC ecosystem.
How can something be a parasite on a parasite?
>>
>>60085077
Way I'm gonna be doing it is having a simple tuple with the club count and a list of the coins. They're just appended to the end. At the end, I'll parse the final club list. A lot less complicated than having them be arrays and incrementing the specific values. More space tho. Ty for the help guys xx
>>
>>60085814
gcc is a parasite on what?
>>
>>60085816
Coin* autocorrect
>>
>>60085814
it eats free software and spits out rotten apples
>>
>>60085829
Pastel
>>
File: 1479969671118.jpg (75KB, 1159x873px) Image search: [Google]
1479969671118.jpg
75KB, 1159x873px
C style for loop macro in Rust
macro_rules! cfor {
// for (; ...; ...) { ... }
(; $($rest: tt)*) => {
cfor!((); $($rest)*)
};
// for ($init; ; ...) { ... }
($($init: stmt),+; ; $($rest: tt)*) => {
// avoid the `while true` lint
cfor!($($init),+; !false; $($rest)*)
};

// for ($init; $cond; ) { ... }
($($init: stmt),+; $cond: expr; ; $body: block) => {
cfor!{$($init),+; $cond; (); $body}
};

// for ($init; $cond; $step) { $body }
($($init: stmt),+; $cond: expr; $($step: expr),+; $body: block) => {
{
$($init;)+
while $cond {
let mut _first = true;
let mut _continue = false;

loop {
// if we *don't* hit this, there was a `break` in
// the body (otherwise the loop fell-through or
// was `continue`d.)
if !_first { _continue = true; break }
_first = false;

$body
}
if !_continue {
// the `if` wasn't hit, so we should propagate the.
break
}

$($step;)+
}
}
};
}


Finally I can be comfy
>>
>>60085803
If we had a high rate of intelligent topics, I would agree. We don't.
>>
>>60085844
>I would agree
Nobody gives a fuck.
Manchild bullshit belongs on >>>/v/
>>
>>60085836
What is it?
>>
Can someone post a stupid programming challenge or something?

Preferably with akari saying it?
>>
>>60085702
?
>>
File: 1456401181293.webm (1MB, 798x596px) Image search: [Google]
1456401181293.webm
1MB, 798x596px
>>60085814
How is that impossible ? And GCC runs the planet fyi
>>
>>60085735

Uh, you do realize that games are programmed as well. Right? Or are your precious bloated lines of code reserved only for embezzling programs?
>>
>>60085644
That's how it's done, though I'm not aware of a networking API/library that requires you to use threads and queue messages yourself.
>>
>>60084685
Microsoft Word
>inb4 "but then i can't use it"
that's the point
>>
>>60085853
99% of this thread is man-child bullshit.
>>
>>60085858
/g/'s not your personal search engine.
>>
>>60085839
Fuck macros.
>>
>>60085867
>games
>>>/v/
>>>/vg/
>>
>>60084717
>the whole place looks like clown vomit
>first thing his eyes focus in on is the BLM poster
4chan everyone
>>
File: why.jpg (24KB, 277x480px) Image search: [Google]
why.jpg
24KB, 277x480px
>>60085839
Why tho?
>>
>>60085805
The webm is just the audio
>>
>>60085919
>ydl.download
I guess the post-processing step is in another method which you have to call afterwards.
>>
what if there were a data structure like an associative array except with multiple keys and each key is a property of the value(s) stored under it so you can just insert values without explicit keys and later be like "gimme all the values where this property is equal to this" and it could be multiple associative arrays each indexed by a different property of the values so that way you can use different properties to look up the values
>>
>>60085981
Weed is illegal
Stop now
>>
>>60085990
weed is nice, mang. who here /highaf/?
>>
>>60085981
That's just an associative array with a more complex key type.
>>
>>60085803
You are incorrect though.
>>
>>60085605
>>60085746
To add to that, LLVM takes the most when compiling a Rust program, e.g.:
rust-doom $ cargo rustc -- -Z time-passes
...
time: 0.034; rss: 47MB parsing
...
time: 0.138; rss: 122MB expansion
...
time: 0.075; rss: 137MB compute_incremental_hashes_map
...
time: 0.027; rss: 142MB type collecting
...
time: 0.043; rss: 151MB coherence checking
time: 0.099; rss: 152MB wf checking
time: 0.072; rss: 154MB item-types checking
time: 0.989; rss: 165MB item-bodies checking
...
time: 0.099; rss: 197MB MIR dump
...
time: 0.071; rss: 197MB MIR cleanup and validation
time: 0.117; rss: 197MB borrow checking
...
time: 0.101; rss: 197MB lint checking
...
time: 0.115; rss: 201MB MIR optimisations
...
time: 4.144; rss: 357MB translation
time: 0.000; rss: 357MB assert dep graph
time: 0.000; rss: 357MB serialize dep graph
time: 0.466; rss: 279MB llvm function passes [0]
time: 0.202; rss: 283MB llvm module passes [0]
time: 7.020; rss: 282MB codegen passes [0]
time: 0.001; rss: 282MB codegen passes [0]
time: 7.690; rss: 276MB LLVM passes
time: 0.000; rss: 276MB serialize work products
time: 1.587; rss: 160MB running linker
time: 1.591; rss: 160MB linking


I omitted most smaller stuff and only kept the biggest stuff as that was over the character limit otherwise. LLVM requires the most time.
>>
>>60086052
Ridiculous. Jai compiles itself in half a second.
>>
>>60086085
how
>>
>>60086085
A language cannot be compiled, are you talking about the compiler by any chance?
>>
>>60085869
I'm doing the networking part partially by hand, so that's why. Incoming messages are event-based and are handled in different threads than the thread that's calculating the next state.
>>
>>60086052
How does it LLVM compare (time wise) to GCC when compiling C?
>>
>>60086122
Unless you're making syscalls directly I have a hard time believing your API isn't already queuing things up behind the scenes. What are you starting from?
>>
File: success.png (344KB, 1920x1080px) Image search: [Google]
success.png
344KB, 1920x1080px
After fixing a bug where I forgot to break at the end of a switch statement, and another bug where I kept writing the cyclical redundancy check over the first bytes of the TCP payload...

I've done it. I have a DNP3 server that can execute read requests. Granted, it can only handle 2 types of objects, but that's all I'm going to need.
>>
What is the simplest (yet usable, not just plain lambda calculus) functional programming language?
>>
>>60086210
(((Scheme)))
>>
>>60086210
OCaml
~$ ocaml
OCaml version 4.04.1

# print_endline "it's fucking simple";;
it's fucking simple
- : unit = ()
#
>>
>>60086210
In what way is plain lambda calculus not usable?
>>
>>60084350
His sign needs an anime picture.
>>
>>60086256
image*
>>
>>60084611
KDevelop 4.x
>>
File: Cpp_Builder.png (249KB, 3360x2100px) Image search: [Google]
Cpp_Builder.png
249KB, 3360x2100px
>>60084611
C++ Builder
>>
>>60086210
F#
>>
>>60086319
Unironically this!
>>
>>60086259
thank you
>>
>>60086210
System F
>>
>>60086165
Things are definitely being queued up behind the scenes at the socket level if that's what you mean. When I said queueing I meant queueing commands at the application level, like "move my character towards the right". The issue is when/how to apply those commands to a shared game state, because the game state is controlled by a different thread, and multiple clients could be trying to affect the game state at the same time (say, loot the same item). I'm using .NET sockets, so it's not exactly low level stuff, but I still need a decent architecture at the high level.
>>
>>60085957
Found a solution. Apparently, there's a "postprocessor" series of options you can throw into the options that converts the file.The only bad thing is that it takes a lot longer to convert the file when compared ot the time needed to download it... here's the code:

import youtube_dl
import os

album_url = raw_input("Please enter the URL of the album you would like to download\n\t")

#album_name = raw_input("Please enter the name of the album\n\t")
options = {
'format': 'bestaudio/best', #Choice of quality
'extractaudio' : True, #Only keep audio
'audioformat' : "mp3", # convert to mp3
'noplaylist' : True, #only download the single song
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
}],
}
video_id = ""
album_name = ""
with youtube_dl.YoutubeDL(options) as ydl:
ydl.download([album_url])
r = ydl.extract_info(album_url, download=False) #Don't download
video_id = r['id']
album_name = r['title']


>>
>>60086343
You don't need the threads. You're making things much more complicated for yourself. The sockets buffer the received data so at the beginning of each tick you can simply read from them until they're empty to get all of the data received during the last tick. Deciding who gets the item when two or more people pick it up should be a game design question, not a threading and synchronization question.
>>
>>60086350
You could parallelize it by having one thread download the data and enqueue it and then a consumer thread that uses ffmpeg to extract just the mp3.
>>
File: qt application.jpg (135KB, 662x891px) Image search: [Google]
qt application.jpg
135KB, 662x891px
So I made a Qt program that generates a file tree browser starting from the folder you select. my downloads folder takes about half a second to load, but when i add folder icons it goes up to 10 seconds. the icons im using are 200kb each which must be part of the problem, but i think the other part is it is creating a new image for each icon? I'm using a Qt resource file that tells my program where my images are, and atm im just using a setIcon("PATH TO IMAGE") function for each tree item. Will i need to create a variable that caches the icon for a folder then tell each tree item to use that icon?
>>
>>60086394
I'm not quite sure how to do that, but that's a story for another time...
Thanks though!
>>
pthreads is cancer.
>>
>>60086469
you are cancer
>>
File: Untitled.png (262KB, 534x685px) Image search: [Google]
Untitled.png
262KB, 534x685px
Is this a good book? Are there better ones? First programming language, i just reached expressions.
>>
>>60086210
definitely Scheme, dont listen to >>60086321
>>
>>60086536
this was my textbook for a C++ class
the class was shit, I didn't even buy the textbook because we used it literally only a few times
i can only assume the textbook is also shit

also it's like 1000 pages, you can explain the entire C language in 100.
>>
R8 my data structure. It's a pointer that holds 3 extra bits of data.

class ShortPointer{
public:
ShortPointer(void* pv, short s){
val = reinterpret_cast<uintptr_t>(pv);
val |= (s & 0x0000007);
}
short getShort(){
return short(val & 0x0000007);
}
void* getPointer(){
return reinterpret_cast<void*>(val & 0xffffff8);
}
private:
uintptr_t val;
};
>>
>>60086580
Needs more templates.
>>
@60086580
>class
0/10
>>
File: 1480287132867.png (128KB, 303x306px) Image search: [Google]
1480287132867.png
128KB, 303x306px
>It's a rolling release language
>>
>>60086646
>language introduces sorely needed new features into the standard
>it'll take 10 years before I can use them because compilers take decades to catchup.
>>
>>60086646
>it's a dumb frogposter again
>>
>>60086658
>The standard committee isn't run almost exclusively by the compiler developers
>>
I did it senpaitachi!
(\xyz.xz(yz))(\x.z)(\x.a)
(\x.\y.\z.xz(yz))(\x.z)(\x.a)
[x := (\x.z)]
(\y.\z.(\x.z)z(yz))(\x.a)
[y := (\x.a)]
(\z.(\x.z)z((\x.a)z))
[x := z]
(\z.z((\x.a)z))
[x := z]
(\z.za)
>>
>>60086580

Completely fucked on 64 bit platforms given those shit literals. Also assumes data is 8-byte aligned.
>>
>>60086646
>>60086658
>>60086663
>>60086694
What are these posts supposed to represent?
>>
Is C# worthwhile to learn?
>>
>>60086787
Do you have any previous experience with programming?
>>
>>60086787
Learn C#, then you will already know Java and can get a job
>>
I don't get the point of enums
>>
>>60086926
Which language?
>>
>>60086937
C
>>
heh
>>
>>60086926
They're useful for error handling, state flags, and other numerical constants that your program uses.
Basically, it prevents you from having to assign arbitrary numbers to constants, C will just do it for you.
enum err_code {
NO_ERROR,
ERR_OFFLINE,
ERR_MEM,
...
>>
Why is using labels generally frowned upon?
>>
>>60087009
it makes control flow a mess.
Their only acceptable use is error handling, or breaking out of 4+ nested loops that require cleanup, which is why you're even allowed to have them at all.
>>
>>60086822
Yes, but why does that matter? I'm asking if it has utility more so than other similar languages and what the general industry use for it is.

>>60086834
Are they really that similar? I have a bit of C++ and I feel like C# is close to it as well.
>>
>>60087008
Where did he say "C"?
>>
File: Momoyo.jpg (17KB, 300x423px) Image search: [Google]
Momoyo.jpg
17KB, 300x423px
After extensive research, I have come to the conclusion that Idris is in fact, a meme.
That is all.
>>
1+1

or
1 + 1
>>
>>60087192
Your research is pretty shit. I know for a fact that Idris is a programming language.
That would mean it can't possibly be a meme (assuming non-plebbit definitions of "meme").
>>
>>60087194
1.add(1)
>>
>>60087194
>tfw you never get done with anything because you're a fucking autist when it comes to formatting your code
>>
>>60087192
kafir
>>
>>60087194
1++
>>
>>60087194
2
>>
>>60084521
how the fuck do any of them get any work done when there's so much noise around them
>>
>>60087194
+ 1 1
>>
File: 1458499832048.png (444KB, 800x600px) Image search: [Google]
1458499832048.png
444KB, 800x600px
Oh my god, here we go again. I hate "open-sores" faggots

Closed source is better because anyone who has worked on highly complicated code knows that as soon as you start letting amateurs fuck with your code, it makes your life harder. Good projects are complicated beyond anything most of us could possibly contribute to, so why bother to make it open source?

It's closed source because they want it to work. It's not closed source because of some massive conspiracy. It's not close source so the dev can sell it via patreon. It's not closed source because he stole code from someone.

It's closed source because CEMU is complicated beyond what most people could possibly contribute to, and opening it up to everyone with a computer to contribute to is only going to make it worse, not better.

I know that nobody understands this, or wants to understand it, because it's the giant circlejerk that the dev is hiding something, but he's not. I know none of you will apologize when someday, as promised, the code is actually opened up and everyone sees that there's nothing to hide.
>>
>>60087221
Absolute garbage.
>>60087252
Acceptable.
>>60087266
Why? Maybe 1 + 1 is in normal form already in his language.
>>60087282
1 1 + is better.
>>
>>60087284
>implying closed source code ain't made by code monkeys

I don't know if you're idiot or serious.
>>
>>60087284
>Closed source is better because anyone who has worked on highly complicated code knows that as soon as you start letting amateurs fuck with your code, it makes your life harder.
Good thing pull REQUESTS are how people contribute.

>It's not close source so the dev can sell it via patreon.
There's no other explanation.
>>
>>60084395
That's a joke, ok?
>>
>>60087284
>>60087302
>>60087324
Not programming. Fuck off to your containment thread.
>>>/g/fglt/
>>
>>60087194
succ (succ zero)
>>
>>60087302
Did he say this somewhere?
>>
>>60087358
>as soon as you start letting amateurs fuck with your code, it makes your life harder
That is describing 99% of closed software inn world.
>>
>>60086232

I think a simple litmus test for whether a programming language is usable is whether the average programmer could use it for some complicated task which is useful for more than just academic circle jerking. Say, making a video game, or a compiler, or a webserver.
>>
File: 1470851517867.gif (1MB, 499x499px) Image search: [Google]
1470851517867.gif
1MB, 499x499px
>>60087252
struct integer {
int operator+() {
return ++val;
}
int val;
};

integer n{1};
int k = +n;
>>
>>60087284
I don't like political freedom because I don't have a degree in it: the post.
>>
>be spic in spic shithole
>wants to make gaymus
>enter college and study CS
>realize I don't want to study CS
>ask my professor how many semesters do I need to make games
>he tells me I can do games after the second year
>tfw I want to be in literature rather than CS
>tfw not even a brainlet nor I find math hard
Should I stick for one more year, learn all the math and later swith to literature?
Or should I self study the math and CS shit on my own on the next six months?
>>
>>60087379
Lambda calculus with syscalls, then.
>>
File: 2017-04-26-154743_696x216_scrot.png (24KB, 696x216px) Image search: [Google]
2017-04-26-154743_696x216_scrot.png
24KB, 696x216px
Do my homework for me.
>>
>>60087378
>I think
Opinion discarded.
>>
>>60087402
>going to school for CS to make games
>asking how many semesters you "need"
>not a brainlet
Sure, cristian.
>>
File: d4EZg7o.jpg (131KB, 485x750px) Image search: [Google]
d4EZg7o.jpg
131KB, 485x750px
>>60087383
int k = 1+(+n);
>>
>>60087416
c
>>
>>60087402
>tfw I want to be in literature rather than CS
You're fucking stupid. Even for a spic.
>>
@60087379
Only a retard could think this.
By definition, a usable language is a language which can be used. Any language can be used, therefore every language is usable.
"a language usable by the average programmer" is not the same as "usable language".
>>
>>60087416
I would pick C, but this is only true in C89.
GNU C and C99 allow variable length arrays with array members not computable at compile time.
>>
>>60087416
Just guessing but I think c is correct
>>
>>60087416
Strictly speaking, all are wrong.
>>
>>60087432
How hard would be to self teach myself the first two years of CS in my mom basement in six months?
>>
>>60087416
#3
>>
>>60087469

>"@"
>>
How do we make the shittiest fizzbuzz possible that still works and doesn't waste time with meaningless loops?
>>
>>60087500
Probably pretty easy. Most CS programs are designed for retards.
>>
>>60087471
c99 allows variable length arrays? i thought that wasn't until c11
>>
>>60087512
Did this post have a point?
>>
>>60087524
You were wrong.
>>
why does my C program work fine when invoked from the command line but segfault when invoked from my PHP script with exactly the same parameters
>>
>>60087598
reimplement it in rust lad
>>
>>60087416
Tell your professor to just create the array dynamically and use realloc if he needs more space, jeez
>>
>>60087194
Whatever your fmt tool defaults to
>>60087221
>not checkedAdd(1,1)
>>60087252
Good one
>>
>>60087409

In theory, I can train a neural network in brainfuck. It's turing complete, so I can do all of the transformations necessary to do any sort of computation, and realistically, I don't ACTUALLY need anything other than stdin to pass model parameters and training data, and stdout to spit out the weights.

In practice, you're not going to get anyone to fucking do that. For an ANN, I'd likely use Python, R, or C++. If I don't have libraries to handle most of the work, I'd prefer Ruby or C++. Regardless, even assembly is a more practical choice than Brainfuck.

Just because something is theoretically possible does not mean it's practical. Sure, you could use a modified lambda calculus with syscalls to make a useful application, but chances are you'd be better served by any number of languages. Even Haskell is arguably a decent language. If I could only program in Haskell for the rest of my life, I'd be greatly displeased, but I'd manage.
>>
should i tell my computer club's supervisor that i want to be the webmaster this coming year and that i'm quitting my current position regardless? the current guy (indian ethnicity) hasn't done anything on the site the past 6 months, just a page saying hello world. i'm the treasurer and it sucks ass. thinking about learning ruby for rails and i want a reason to
>>
>>60087697

>Rails
Yuck!
>>
>>60087744
the only reason ruby is popular is because of rails
>>
>>60087744

>Yails
Ruck!
>>
>>60087618
>java
>pointers
>>
File: IMG_7223.jpg (126KB, 684x690px) Image search: [Google]
IMG_7223.jpg
126KB, 684x690px
Realistically speaking how long will t take me to "learn" code if I practice half an hour a day? I want to be proficient
>>
>>60087772
not denying this but ruby is a great language in and of itself and rails is shit
>>
>>60087782
>java
>>
>in C, empty struct definitions are allowed, they will be size zero
>you can make an array of structs of size zero

what the fuck???
>>
>>60087815
such is the state of the current CS programmes
>>
>>60087772
I'm not really concerned with the popularity of the language. Ruby is a nice language for a lot of tasks. Rails is a bloated framework though.

>>60087471
In C11, compilers are not required to support VLAs.
>>
>>60087844
It's called memory allocation
>>
>>60087844
What's wrong with that?
>>
>>60087855
I assume there will be some memory used in order for the system to know the existence of these zero size structs?
>>
Can I get a math buff/programmer to help me clear out this doubt of mine?
// Function to calculate the absolute value of a number
#include <stdio.h>

float absoluteValue (float x)
{
if ( x < 0 )
x = -x;
return (x);
}

// Function to compute the square root of a number
float squareRoot (float x){

const float epsilon = .00001;
float guess = 1.0;
while ( absoluteValue (guess * guess - x) >= epsilon )
guess = ( x / guess + guess ) / 2.0;
return guess;
}

int main (void)
{
printf ("squareRoot (2.0) = %f\n", squareRoot (2.0));
printf ("squareRoot (144.0) = %f\n", squareRoot (144.0));
printf ("squareRoot (17.5) = %f\n", squareRoot (17.5));

return 0;
}

Output
squareRoot (2.0) = 1.414216
squareRoot (144.0) = 12.000000
squareRoot (17.5) = 4.183300



Now, my question is simple. I get the gist of how the problem works. The doubt that I have is this "epsilon" number. I know it is used for "precision", however, why exactly does it stop on the "output" numbers? Especially 12.000000(144.0), how is this number smaller than (.00001)?
It might be a stupid question, but I can't go on without understanding this simple thing. Thanks in advance.
>>
>>60087844
>in C, empty struct definitions are allowed
No they aren't. In GNU C they're allowed as an extension, and do indeed have size 0. However, precisely for this reason, instantiating them is undefined behavior.

You """"""""can"""""""" have arrays of empty structs. A program will result. It might crash, but it will be a program.
>>
>>60086107
https://www.youtube.com/watch?v=HLk4eiGUic8
Here's exactly how.
Nothing special really he just tried to make it a little bit fast.
This is the kind of stuff that makes you doubt the ability of large groups of people.
>>
@60087658
If you can't do that both using a very simple Turing machine (brainfuck) and lambda calculus with syscalls, then you're just a mediocre programmer.
>>
>>60087933
Nope! Instead of doing that, it'll just fuck you over.
See: >>60087958
>>
>>60087958
What's the point of disallowing it?
>>
File: are_you_fucking_serious (2).jpg (128KB, 548x575px) Image search: [Google]
are_you_fucking_serious (2).jpg
128KB, 548x575px
>>60087934
Are you seriously this stupid? Epsilon is the tolerance for the difference between the square of the approximation for the square root of the input x. The program terminates if the difference between the square of the approximate and the input is smaller than epsilon.
>>
>>60087958
>G*U C
Garbage. And he didn't say that anywhere.
>>
What's a good way to suspend a thread from inside itself, and then unsuspend it from another thread?
I noticed RVM is spending way too much time checking for interrupts.
>>
File: yablewit.jpg (15KB, 273x276px) Image search: [Google]
yablewit.jpg
15KB, 273x276px
>>60087966
>@60087658
>>
>>60088008
He could be really new.
>>
>>60088016
He implied it by saying empty structs were allowed
>>
>>60088008
>The program terminates if the difference between the square of the approximate and the input is smaller than epsilon.
Is whoever wrote that program seriously that fucking stupid?
>>
>>60088117
>can't prove convergence of Babylonian approximatino to the square root
No anon, you're the stupid one.
>>
>>60088023
Semaphore.
>>
>>60088083
let x be a blatantly false thing about C.
When I say "x is allowed in C" am I implying that x is allowed in another language?
>>
>>60088008
>>60088045
Apparently yes, I am retarded. So, correct me if I am wrong, so that means when
guess * guess - 144 = 0

It's when the program terminates? Anyways, thanks for the help anon.
>>
>>60088129
read your SICP
>>
>>60088131
Yes, if that other language is a version of C in which it's allowed.
>>
File: 1460440988318.png (158KB, 672x808px) Image search: [Google]
1460440988318.png
158KB, 672x808px
>>60088029
>>
>>60087790
half an hour a day is not enough. sometimes it takes that amount of time just for finding an error you made in your code.
>>
>>60084521
>only two people have actual code up
>It's a white guy and an asian guy
>the rest are browsing facebook while working at facebook, or chatting and goofing off
>they're all females

It's like a diorama of modern tech sector.
>>
File: images (3).jpg (3KB, 225x225px) Image search: [Google]
images (3).jpg
3KB, 225x225px
>>60088214
>>
>>60088132
While loops runs iff the conditional is satisfied.
>>
>>60088117
was written a couple thousand years ago mate
https://en.wikipedia.org/wiki/Methods_of_computing_square_roots
>>
>>60088228
>It's like a diorama of /dpt/
/ftfy/
>>
File: 1492198776767.gif (836KB, 500x451px) Image search: [Google]
1492198776767.gif
836KB, 500x451px
>>60085839
>using a language feature to mimic another language feature
You can use C's features in C too
>>
What language would you teach your 12 years old self?
>>
>>60088126
>>60088243
I'm talking about the part where the program terminates.

Why the fuck does it terminate there. What idiot would have it terminate there.

Pretty sure it's supposed to RETURN THE RESULT and THEN terminate.
>>
>>60088294
Japanese.
>>
>>60088312
read the program, idiot. it's not written in assembly, or chinese either
>>
>>60088312
>>
>>60088294
C#
>>
File: 1447090709173.jpg (76KB, 414x340px) Image search: [Google]
1447090709173.jpg
76KB, 414x340px
>>60088293
>Rust can do this thing C can
>why aren't you just using C then?
>>
Is there a single thing all programming languages prohibit? Including not yet invented ones.
>>
@60088411 (You)
>>
File: solve (5).png (754KB, 1280x720px) Image search: [Google]
solve (5).png
754KB, 1280x720px
>>60088411
Solving undecidable problems
>>
>>60086210
haskell
>>
>>60088411
fun
>>
>>60088127
Thank you!
>>
>>60088417
What was this supposed to mean?
>>60088421
That's not the same as the language prohibiting something. The universe already does that.
>>
>>60088411
An infinite amount of instructions, for reasons out of their reach.
>>
>>60088433
Does any language actually set an upper limit on the number of instructions?
>>
>>60088445
LMC (if you consider it a programming language) can't go above 100 instructions, I believe.
>>
>>60088445
memory does, and cache
>>
>>60088445
you can embed such a language in Idris or Haskell
>>
>>60088457
Great answer. But did you notice that neither of those are languages?
>>
File: test (2).png (716KB, 811x599px) Image search: [Google]
test (2).png
716KB, 811x599px
>>60088431
>the universe prohibits a Turing machine (i.e. a manmade structure) from solving certain problems
Hint: it's the manmade structure that's prohibiting this, not the universe.
>>
>>60088411
Getting a job
>>
>>60088471
uncomputable functions aren't a manmade structure though
>>
>>60088467
;) python has a recursion limit, but im not smart enough to know if that even answers the question
>>
>>60088457
Neither of those are languages.
>>60088462
Or in any other language really.
>>60088471
Isn't an undecidable problem by its nature unsolvable? Turing machines (or anything equivalent to them) can solve all solvable problems.
>>
>>60088498
>Or in any other language really
not as straightforwardly
>>
>>60088411
No because there's a retarded language called C that will let you do the stupidest things every other language prohibits.
>>
File: 1458668770614.jpg (12KB, 236x265px) Image search: [Google]
1458668770614.jpg
12KB, 236x265px
Realistically, should I be adding I/O to my language at all?
>>
New thread, now with more dubs:
>>60088699
>>60088699
>>60088699
>>
>>60088695
I/O is useles
>>
>>60088695

Realistically, if you can't do I/O, every program is equivalent to either an empty program or an infinite loop.
>>
@60088887
Only in a retarded language.
>>
>>60088294
When I was 12 years old I learned ActionScript 2. I probably wouldn't suggest that
>>
File: wut.gif (854KB, 350x197px) Image search: [Google]
wut.gif
854KB, 350x197px
>>60087489
Can't remember the last time I saw a multiple choice test that didn't have at least one question with no one "correct" answer, or included questions related to trivia about the professor's hobbies that have no connection to the course material.

Last time I tried to contest some of those bad questions, the person I was meant to complain to was the one who set the damn paper, so of course he was correct and I was just "looking at it the wrong way".

If your course is weighted by more than 20% on multiple choice questions, you should just quit now.
>>
>>60088294
12 year old me managed to learn Python, so C or C++ wouldn't be too hard I assume.
>>
>>60087402
You should have gone to a university that has game development as a major.
>>
>>60087598
Does it use external files at all? Is the working directory the same from the PHP script?
Are the environment variables the same?
Does the PHP script (for some reason) not have access to some required library?
>>
>>60085746
Having actually worked both downstream and upstream on LLVM I'm really curious what your relationship is with LLVM? More specifically, I'm curious about the claims that backends break frequently and are difficult to write?
>>
File: 1484845857295.jpg (82KB, 500x453px) Image search: [Google]
1484845857295.jpg
82KB, 500x453px
>>60084521
It would be like working in fucking "Where's Waldo?"
Thread posts: 322
Thread images: 36


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