/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Cred Forums?

Other urls found in this thread:

amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504
github.com/chrippa/livestreamer/blob/ab80dbd6560f6f9835865b2fc9f9c6015aee5658/src/livestreamer/plugins/periscope.py
en.cppreference.com/w/cpp/chrono/high_resolution_clock/now
youtube.com/watch?v=KlPC3O1DVcg
elm-lang.org/assets/blog/error-messages/0.16/incomplete.png
elm-lang.org/assets/blog/error-messages/0.16/if-branches.png
flockler.com/thumbs/1992/truthy_s830x0_q80_noupscale.png
elm-lang.org/assets/blog/error-messages/0.15.1/naming.png
github.com/golang/tools
en.cppreference.com/w/
docs.oracle.com/javase/tutorial/
pastebin.com/G6RZqm7u
github.com/majestrate/bdsmail/
lwn.net/Articles/693189/
ufile.io/e8f01
twitter.com/SFWRedditImages

>What are you working on, Cred Forums?

Almost done with my GPUDirect RDMA benchmarking utility.

>your mom

Funny.

What compiler do i use for C

K&R's book is so old

So we eat pancakes soon?

what does each person represent

g++

visual studios' compiler

Yeah

gcc

Dining philosophers

A toy program to practice my C.
#include
#include "map.h"
#include "point.h"

void
init_map(char *file)
{
map_width = 10;
map_height = 10;
map_size = map_width * map_height;
map = malloc(map_size * sizeof(struct cell));

struct pnt *c_point = malloc(sizeof(struct pnt));
struct cell *c_cell = malloc(sizeof(struct cell));
for (int i = 0; i < map_height; ++i) {
for (int j = 0; j < map_width; ++j) {
c_point->x = j; c_point->y = i;
c_cell = get_cell(c_point);

c_point->x = j; c_point->y = i + 1;
c_cell->north = get_cell(c_point);

c_point->x = j + 1; c_point->y = i;
c_cell->east = get_cell(c_point);

c_point->x = j; c_point->y = i + 1;
c_cell->south = get_cell(c_point);

c_point->x = j - 1; c_point->y = i;
c_cell->west = get_cell(c_point);

c_cell->type = GRASS;
c_cell->content = &no_item;
}
}
}

struct cell *
get_cell(struct pnt *point)
{
int index = point->y * map_height + point->x;

if (index >= 0 && index < map_size) {
return &map[point->y * map_height + point->x];
}
else {
return &no_cell;
}
}

void
draw_map(void)
{
char *data = malloc(map_size + map_height + 1);

int index = 0;
struct pnt *c_pnt = malloc(sizeof(struct pnt));
for (int i = 0; i < map_height; ++i) {
for (int j = 0; j < map_width; ++j) {
c_pnt->x = j; c_pnt->y = i;
data[index] = cell_to_char(get_cell(c_pnt));
++index;
}
data[index] = '\n';
++index;
}
data[index] = '\0';

printf(data);
}

char
cell_to_char(struct cell *cel)
{
char rtn;

switch (cel->type) {
case GRASS:
rtn = ',';
break;
case MUD:
rtn = '~';
break;
case COBBLE:
rtn = '-';
break;
case NONE:
default:
rtn = '0';
break;
}

return rtn;
}

void
destroy_map(void)
{
free(map);
}

write your own, fucking pajeet

gcc

Who's the semen demon?

You are mother

Winona Ryder

K&R tells you to use cc.
$ cc --version
cc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I dropped K&R and started reading this one instead:
amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504

Did I fuck up?

Some chick that got raped and and killed by a serial killer. The serial killer took that photo of her moments before she was killed.

Regina Kay Walters.

This photo was taken by serial killer, Robert Ben Rhoades right before he killed the 14-year-old Walters. Rhoades was famous for touring the country in an 18-wheeler truck that was fully equipped with a torture chamber. This photo was taken in an abandoned barn in Illinois where Rhoades murdered Walters. Before killing her, Rhoades cut off her hair and forced her to wear the black dress and heels you see her wearing in the picture.

>cut off her hair and forced her to wear the black dress and heels you see her wearing in the picture.
That's fucking hot.

Holy fuck, why do people like Python so much? I'm trying to fix some retard's broken script and the syntax is disgusting, looks like a total nightmare. Definitely not any better than just writing it in C/Java/whatever.

Probably gonna just recode my own implementation in C, I don't know how anyone can fuck up something this simple. It's literally just extracting a token from a URL, sending a GET request, parsing the JSON response, and then passing that response into another program. And somehow it still reads like ass.

>Autism - the post

>Holy fuck
>C/Java/whatever
>Java
>write shit in C that doesnt need to be written in C
>muh syntax dude, totally matters

i dont know

>snakefags will defend this
class Periscope(Plugin):
@classmethod
def can_handle_url(cls, url):
return _url_re.match(url)

def _get_streams(self):
match = _url_re.match(self.url)
res = http.get(STREAM_INFO_URL,
params=match.groupdict(),
acceptable_status=STATUS_UNAVAILABLE)

if res.status_code in STATUS_UNAVAILABLE:
return

playlist_url = http.json(res, schema=_stream_schema)
return HLSStream.parse_variant_playlist(self.session, playlist_url)

>my friend can't program Python and I'm a Python illiterate therefore Python is shit

Your friend is a retard and you're even more retarded.

I can do the same thing with 5 statements, and that's including the library imports.

Must be a total retard who wrote the initial script because that's something that takes 10 LoC top in Python with requests & json libraries and you wouldn't be complaining about rewriting 10 LoC program.

Still working on akari-bbs!
I started code tag support last week but I got distracted with client-side fluff.

The guy sucks at Python so bad he has to ask his friend (you) to help him, even though you don't even know any Python.

How the fuck did you come to the conclusion that your friend's shitty script is somehow an typical example of idiomatic Python code?

The Doenning-Kruger is strong with you.

It's not a hard problem so I have no idea why the solution is so contrived. I know jack shit about Python (this is my second exposure to it) so maybe if all Python code isn't this fucking terrible it's an OK language, I don't know.

I just want to watch Periscope streams in VLC but apparently this plugin's been broken for months and no one cares enough to fix it, another great victory for OSS.

I assumed this was idiomatic Python code because it's part of a pretty popular package and most of the code looks like this.

why are the colors fucked up?

So let me get this straight... You're actually writing a plugin. Your "friend" is actually the VLC community? You have only barely seen Python code and you think you're somehow able to contribute to the VLC project? You think writing an application plugin is the same thing as a script that sends a single HTTP request and parses it?

>VLC
>idiomatic anything
Pick one.

>You think writing an application plugin is the same thing as a script that sends a single HTTP request and parses it?
yes

cuck dad, son, daughter, milf mom, adopted refugee child

I guess this is the first time you're writing a plugin then.

cuck

Any C++ tl;dr books for people who already know how to program?

I want to learn C++ but I don't want to go over what is a variable for the 9999999th time

No, I never mentioned my "friend" or anything like that. There is a script that shipped with this package that, supposedly, parses a periscope URL, sends a GET request, and extracts a video stream from the JSON response. The script is broken. I decided to fix it. Unfortunately it was written by someone who, I can only assume, is a total retard. I have no intention of contributing my code back to the project.

This package passes the stream INTO VLC. It doesn't handle any of the video decoding itself. It is a truly trivial problem.

>Any C++ tl;dr books for people who already know how to program?
Effective C++ + More Effective C++

After that,
Effective Modern C++

After that
Exceptional C++ and More Exceptional C++

After that
Unbelievable C++ programming

Trivial, yes. But it does require minimal knowledge of how the VLC ecosystem works as well as Python barebone knowledge.

>these are all real

I thought this was a meme reply, I'll check them out

>these are all real
proof C++ warps the brains of those using it for too long

Friendly reminder that the Haskell reference book for beginners is called "Learn you a Haskell for great good!" and that the Lisp reference book is called "Structure and Interpretation of Computer Programs".

>"Learn you a Haskell for great good!"
dopey

btw thats not a lisp reference book, its a very basic introductory CS book

>Lisp reference book is called "Structure and Interpretation of Computer Programs"
firstly that's for scheme, a dialect of lisp, and second whats wrong with that?

working on some java, this is pretty triggering, assignment be like 4/4 style, 8/8 correct documentation, 4/4 documentation, but presentation be like 3/4, christ man, all cause of this "inconsistent indentation"

Thought I'd pick up Go again to make myself an automatic RSS downloader. I already regret it.
It runs fine, but none of the fields are filled.
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"os/user"
)

type config struct {
directory string
tasks []task
}

type task struct {
url string
title string
}

func newConfig() (*config, error) {
usr, err := user.Current()
if err != nil {
return nil, err
}
path := fmt.Sprintf("%s/.bulkrss.json", usr.HomeDir)
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var conf config
err = json.Unmarshal(data, &conf)
if err != nil {
return nil, err
}
return &conf, nil
}

~/.bulkrss.json
{
"directory": "/tmp",
"tasks": [{
"url": "nyaa.se/?page=rss",
"title": "*"
}, {
"url": "sukebei.nyaa.se/?page=rss",
"title": "*"
}
]
}

>its a very basic introductory CS book
Everybody uses it as an introductory book to functional programming. Nobody has used it as an introductory CS book since the mid 80s, except maybe MIT because they're """"special"""".

you're looking at this livestreamer plugin?

github.com/chrippa/livestreamer/blob/ab80dbd6560f6f9835865b2fc9f9c6015aee5658/src/livestreamer/plugins/periscope.py

i don't see what's so bad about this

>firstly that's for scheme, a dialect of lisp, and second whats wrong with that?
Because nobody actually writes computer programs in Scheme.

You lost a mark because you had a space too much?

you might not, but that sounds like a personal problem

LOL

The fucking millennial didn't even have the attention span to try to understand fucking 50 lines of code before he decided to blog about it on Cred Forums.

You should've used an automatic formatter dumb nigger.

Well I've had people in this very thread tell me it's not "idiomatic Python", but beyond that, the far bigger problem is that it doesn't fucking work.

>.py

>Well I've had people in this very thread tell me it's not "idiomatic Python"
It's not, this shit right here is bad form
if res.status_code in STATUS_UNAVAILABLE:
return

playlist_url = http.json(res, schema=_stream_schema)
if "hls_url" in playlist_url:
return HLSStream.parse_variant_playlist(self.session, playlist_url["hls_url"])
elif "replay_url" in playlist_url:
self.logger.info("Live Stream ended, using replay instead")
return dict(replay=HLSStream(self.session, playlist_url["replay_url"]))
else:
return


Different return values and types based on some arbitrary state, that's very bad form indeed.

>but beyond that, the far bigger problem is that it doesn't fucking work.
It's still 50 lines of code mate.

Again, the problem is trivial: so why is the solution so overengineered and fragile? It should literally be three lines. One to extract the token from the URL, one to send the GET request, and one to parse the JSON and return the stream.

>Again, the problem is trivial: so why is the solution so overengineered and fragile?
V L C
L
C

> It should literally be three lines. One to extract the token from the URL, one to send the GET request, and one to parse the JSON and return the stream.
It should. Fix it.

pretty much, prof is really really hard on formatting in a very very specific way

>if everyone programmed in Scheme the world would be a better place

/prog/ pls, moot killed you for a reason.

scheme and other lisps are horrible

an someone help with this assignment. It involves inventory classes which inside, has a linked list of itemstacks. I keep getting "undefined reference" to Itemstack and item. There are other files that go with this, though my task was only to work on the inventory files.
#include
#include "Inventory.h"

// Allow the compiler to define the remaining
// comparison operators
using namespace std::rel_ops;

/**
*
*/
Inventory::Node::Node()
:data( Item(0, "Air"), 0 )
{
this->next = nullptr;
}

/**
*
*/
Inventory::Node::Node( ItemStack s )
:data(s)
{
this->next = nullptr;
}

/**
*
*/
Inventory::Inventory(){
this->first = nullptr;
this->last = nullptr;
this->slots = 10;
this->occupied = 0;
}

bool Inventory::addItems(ItemStack stack){

Node *new_node = nullptr;

new_node = new Node;


if( this->occupied == 0){
this->first = new_node;
this->last = new_node;
this->occupied++;
return true;
}

if (this->occupied < slots){
Node *it = new Node;
it = this->first;
bool match = false;

while (it != nullptr){
if (stack.getItem().getName() == it->data.getItem().getName()){
it->data.addItems(stack.size());
it = it->next;
}

if(match == false){
(this->last)->next = new_node;
this->last = new_node;
this->occupied++;
}
return true;
}

return false;
}

}

void Inventory::display(std::ostream& outs) const
{
Node* it = this->first;

outs

what do you think about making a java to c compiler for a senior honors project?

Okay I checked Effective C++ out and while it looks great and I'll still read it, it's not what I'm looking for right now

I should've said, learning C++ tl;dr books for people who already know how to program in other, higher level languages, but not C++.

High school? Sounds good mate.

Fixed it. The marshaller cannot handle unexported fields.

Haskell, pls

>The marshaller
Go does AbstractBeanFactory now?

I learned myself C++ from reading Effective C++ and More Effective C++, but I came from a C background. If you don't know C, I would say start with that before venturing into C++ country.

Kek what shithole college are you doing your CS degree at where that would be an honors project? Unless you're writing your own standard library. It'd be better to write a C compiler that spits out JVM bytecode.

No, the JSON (un)marshaller.

You mean a parser?

I dont know if its a good idea, but would it be possible to learn 3 languages within 9 months, i am currently going through java, i guess it would be one language per 3 months, cause i am looking for a job/coop/internship

Learn to bug fix the compiler errors.
Stop wasting time with books.

>system programming language
>JSON
And this is why Go is going to flop

Not that I like the "import from github" functionality either, that has to be a massive security issue.

IT'S A MARSHALLER

I'll consider this, thanks for the help

for your own use i think that's fine. i can almost guarantee that's what the first version of the linked script was
they do some validation of the url and response, and then need to do things slightly differently if the stream isn't live. none of that seems crazy if you're going to release it to a bunch of retards

ctrl+shift+f

>First, the import path is derived in an known way from the URL of the source code. For Bitbucket, GitHub, Google Code, and Launchpad, the root directory of the repository is identified by the repository's main URL, without the http:// prefix.

>the example:
import "github.com/golang/example/stringutil"

what the fuck
>this is real
>this is actually how you import code in Go

w/e
It's not meant to be used for systems programming. Pike already corrected that. The go get tool let's you steal shit from GitHub at light speed. Too bad it doesn't do versioning, so it's complete shit. Even though I hate Go as much as the rest of the world, the development time is generally really low software.

are you serious

Exactly!

I mean, what happens when somebody updates their repo and add code that isn't backwards compatible with your code?

Or even worse, what happens if someone adds malicious or botnet code into their repo?

But then again, Go is the brainchild of the botnet company so I guess it makes perfect sense to make backdoors into programs this way.

What is a good idea for a senior honors project then?

They aren't messing around with their "everything on the cloud" meme

>Too bad it doesn't do versioning
That means that it's completely useless. If somebody updates their code with a breaking change, suddenly all your code breaks.

This is some node.js-tier shit where a bunch of wannabe developers make neat frameworks without having even fundamental understandings of security.

they say that no matter what idea i suggest. if my project was to solve the halting problem, they'd say it's too simple. i only have 2 semesters to complete it whatever i pick

>That's fucking hot.
please seek professional help

>he hasn't solved the halting problem yet

Poo in loo, Pajeet.

He's just mucking around

she was probably a bitch anyways

Correct. It makes npm a work of art.
They did try to fix it by implementing vendoring, which basically comes down to 'clone the repo into your own project and remove its .git directory'. Other desperate attempts are 3rd party tools like Glide.
TL;DR Go is a trainwreck. Too bad D doesn't get much traction.

>please seek professional help
Good advice. Do you think Robert Rhoades is available to consult me on how to best live out my fantasy?

Interactive real-time fractal viewer with freely specifiable generating formulas, modifiable colorization methods (cyclic, histogram equalization, ...), analytical tools (plotter, traces, ...) and much more.
It manages about 6 billion cycles per second thanks to SSE. That's about 4000 cycles per pixel on a 1600x900 monitor. Easily runs in real-time (interactive!) due to pruning / interpolation.

Pic related is some weird sin fractal I discovered with cyclic hue coloring (no AA though).

she and her bf hd escaped from their homes

nothing of value was lost

Sounds like you have a linking problem.

Neat

I want to measure the amount of fps of my c++ program.
I have these two global variables:
clock_t begin = clock();
clock_t end = clock();


and this is where I measure the amount of fps:
end = clock();
double fps = CLOCKS_PER_SEC / (double)(end - begin);
begin = end;


Is this correct? It's giving me weird values.
e.g. when the fps should be between 500 and 1000, it gives me 500 or 1000 instead. when it should be above 1000, it gives me inf.

I know that it happens because (end-begin) goes to 0 when the program is too fast, but I don't think it should actually be 0 and give me fps=inf.

Don't use clock. Use _rdtsc.

Despite the memeing D gets on this board (and in real life), I really like D. I think its problem was that it was about 20 years too early and it had a chance to become relevant, but then the C++ committee picked up on the speed it was lagging behind and then rapidly standardised 11 and 14 and 17 coming around soon, turing C++ from some archaic templated C hell to a truly multi-paradigm, modern language.

you download the code to $GOPATH/src/ with the go tool. "github.com/golang/example/stringutil" is the path to the package you want to import

you know you could write your own package manager for it...
patches are welcome.

>patches are welcome
>B-BUH IT'S A BETA

Why would I write my own package manager for it? It sounds like it truly is FUBAR

Thank you for Correcting the Record.

>patches are welcome
I doubt that they would accept a patch that changes entirely how the package manager works and functions.

Like any derailed software project, Golang is forever cucked by their initial bad design.

>botnet compiler actually spawns HTTP connections to google
Holy fuck it wasn't just a Cred Forums meme, it's actually real

I've used C++ mostly with Qt, but I actually like the language. It's very powerful, but it the ecosystem is segmented. Some use exceptions, some don't. Some use raw pointers, some use unique_ptr or shared_ptr. I'll check out C++11/14/17 and see if I can write a REST API in for my pet project I have in mind. And as a bonus: it's free of SJW and Starbucks hipsters.
>changing tires on a car with a broken engine
Nah, I'd rather masturbate.

just use my nigga:
en.cppreference.com/w/cpp/chrono/high_resolution_clock/now

>taking go seriously in the first place

Cool.

Have you considered making a fragment shader version? Then it'd be even faster. You could even try generating the shader at run-time and recompiling it every time the parameters change.

>I doubt that they would accept a patch that changes entirely how the package manager works and functions.
no one said that. patches can create files, you know.

it doesn't

>this go drone
lol

Well, idiomatic C++ uses exception and RAII for what it's worth. RAII is an inherently good idea, it allows for constructs like this
void foo()
{
// function content
// ...

{ // minimal critical section
std::lock_guard lock(muh_mutex);

// i can do whatever here, even if an exception is thrown the lock is safely released
}
}


This is multithreading done right, and is very unlike the potentially dangerous ThreadDeath error that has haunted Java for ages

>I'll check out C++11/14/17 and see if I can write a REST API in for my pet project I have in mind
Well, I actually worked as a backend web developer using C++11 some years ago. It's a bit nitty gritty for web development, because you basically have to do FastCGI (which is the only point of doing C++ for web development in the first place) and there are only a handful of existing frameworks to build on. But aside from that, it's pretty nice to work with. Horribly slow compilation time for larger projects though, even with precompiled headers. Compiling the Linux kernel was faster than a clean build of the web project I worked on.

That's not a problem with the language, it's a problem with people.
If you tried to have the language enforce one style people will just move to another language that lets them do things the way they like, and segmentation stays the same.

Alright, turns out this was the C++ tl;dr book I was looking for, pretty good t.b.h

It's not related to Google. It's more of a collection of ideas ripped from Plan 9.

>it doesn't
Are you shilling or just naive?

My tcpdump trace says otherwise, but I guess Google shills will defend this and say that it simply checks for a new version.

I have that book. Somewhere.

I actually do some of the work in the fragment shader at the moment. The problem with outsourcing the main formula iterations to the GPU is that deep zooming requires arbitrary precision floats. Currently, I do that with my own little homebrew library that makes use of perturbation theory. I doubt that this will run faster on my GPU due to branches and bit fiddling that I perform in there.

this is good
it means go has proper encapsulation

I have written some simple C + FastCGI web applications, but I have to say it was a pain in the ass. what would you recommend if I wanted to write web applications in C++?

>RAII is an inherently good idea

WHEN WILL THIS MEME DIE? RAII and OOP are the epitome of cargo cult programming.

I know the basics of RAII and I like the idea. Your snippet reminds me of Rust (another language invented at Starbucks), but done right.
Do you have any other suggestions to write backend web stuff in? Python, Go and Rust are toys. Scala looks tempting, especially because I have a Java background.

But why does encapsulation not work with unexported structs? Is it because they're package scope?

>cargo cult programming
Wat?
I know what a cargo cult is, but please explain yourself.

I don't remember the name of the framework we used, I think it maybe was called blackbox. It's an apache one.

Anyway, use C++11 (preferably 14, but results may vary) and boost. Use Qt too, if possible. Both boost and Qt give you high-level functionality you'd miss otherwise.

Whatever you do, don't start writing your own minimal framework, that's pain as hell.

>Start fucking with C yesterday
>mfw it's actually fun

What have you done?

...

RAII has nothing to do with OOP you imbecile.

>Do you have any other suggestions to write backend web stuff in? Python, Go and Rust are toys. Scala looks tempting, especially because I have a Java background.
Scala is on my list of languages to try, but also Erlang. I would try Erlang first.

In the web dev job we actually also used Python for the non-workload-intensive endpoints. Python+flask is pretty neat for getting a simple REST API up and running pretty quick, and it's quite performant when configured correctly (read: long-running event loop, not a invoke--halt cycle). But of course, it will never beat C or C++ as a long-running FastCGI process.

Ah, twitter. The place where Starbucks "code artisans" loudly exclaim their uneducated opinions about topics they don't really know.

show us, then.
the go tool won't import from a remote server when compiling, if that's what you are implying. you have to download the package, by running "go get $URL"

muh Stroutroup cult

you're asking the json marshaller in another package to unmarshal a struct with private fields in your package
what do you think is gonna happen?
other languages simply allow you to do this because reflection allows you to break all encapsulation

Darn.

I recall reading about someone doing arbitrary-precision math with CUDA, but I don't know if it's applicable to this.

as opposed to the educated elites of Cred Forums?

I stopped caring about Haskell when I was introduced to the concept of monads. What a crock of shit. If your program can only be modify state by inventing a higher-order abstraction that can't exist, like some kind of programming deity, then you are fucking wrong and the abstraction is flawed. Same for type checking that basically says "the correct type is whatever the correct type is". That's what the error message said transcribed to words, but god forbid if i wrote in down in English instead of the meme Haskell runes that GHC marks me wrong.

Haskell is logical and category theory never lie my ass. Haskell is just as flawed as any other """functional""" language.

i hate programming

If I want to learn C should I start with that book by Kernighan or something more recent which explicitly follow the last standard?

>youtube.com/watch?v=KlPC3O1DVcg
C fags on suicide watch

Looking to move from C programming to start learning about Object Oriented Programming.

Someone recommend a good course using either C++, C# or Java?

meanwhile in elm, another ml-like lang:
elm-lang.org/assets/blog/error-messages/0.16/incomplete.png
elm-lang.org/assets/blog/error-messages/0.16/if-branches.png
flockler.com/thumbs/1992/truthy_s830x0_q80_noupscale.png
elm-lang.org/assets/blog/error-messages/0.15.1/naming.png

why are you here then?

THE CONCH HAS SPOKEN!

>show us, then.
This is what happens when I simply invoke go build source.go

> I can't grasp it, therefor it is shit.

Touché.

I did take a look at Python and Flask. It looked really nice, but I was a bit skeptical at the performance. It's not like my pet project will receive millions of concurrent users, but it'd be nice if it could handle ~100 users. It's database heavy, Python might just as well perform as good as C++. Also, Python is on the top of my list of just werks(tm) languages.

are you retarded or just pretending to be?
github.com/golang/tools

>2016-09-19
>Not using R

Why is it so beautiful, lads

the first comment is copypasta potential

Isn't that just traffic to the GitHub servers?

〉I'm new therefore I greentext

Why the fuck is it that the Racket FFI will work with some DLL's that I have installed, but not others? Jesus Christ, programming for Windows is such a god damn handful, I wonder how the platform ever got popular.

Which one guys?

Recommended Books/Tutorials?

Well, our light-weight endpoints (Python+flask with mongodb [yeah I know, hipster as fuck]) scaled to around 5000 concurrent users on a single server (the size of the company's largest client). I think that it would scale beyond that too. Of course not million of users, but thousands of users is more than good enough for many things.

I like Python for the extremely low development time, but it's easy to over-engineer things in Python (which of course is true for C++ as well).

this

i'm only interested in the result

again, why are you here?

both are great but C++ if i have to pick one

en.cppreference.com/w/
docs.oracle.com/javase/tutorial/

stateful operations occur within a particular kleisi category, this category can be embeded in Hask and run with pure code, the end result is type safe control of effects

RASMUS FOUND

suck my fucking dick you cunt
c++ is SHIT

why do you exist?

try tunning
proxychains go build source.goagain, the compiler won't download the package unless you tell it to download it...

I'm not looking for the manuals, but a tutorial or book that teaches it. I have only the most basic understanding of OO.

if you say so you obnoxious manchild weeb

the java tutorial teaches it

>implying Hask is a category

In what world is it pure?
>only the runtime is tainted, the code is """Pure"""

This level of mental gymnastics is truly astonishing.

>pure mathematics isn't pure because someone has to think it, this is a side effect in the mathematician's brain

>he writes code like
int main(){
return 0;
}

instead of
int main()
{
return 0;
}

lmao. I thought this place was for serious coders

main = return 0

You convinced me, I'll take a look at Python and Flask. It's sufficient for my needs.

I know plenty of mathematicians who would actually agree with this line of thinking, so the joke is on you.

>I know plenty of idiots who would agree with this line of thinking, so the joke is on you

main = lambda: 0

>he writes code like
int main()
{
return 0;
}

>instead of
int
main()
{
return 0;
}


Do you even bsd?

You're visibly upset.

I will look into that, thanks user!

brainlet

I'm not though

8/10 bait, well done.

I like the use of a shit tier indenting style decoy bait to hide the actual bait of the clueless noob trashing something they can't describe except by example.

>he writes programming101 tier C
>he thinks it makes him a serious coder

int main(void){
return 0;
}

is how i write it

afaik main() and main(void) are too different things

>too

guys why is my code not working?
#include
#include

int main()
{
printf("5 minute load times!\n");

return 0;
}

#include

Twice in one thread is just too much.

You forgot to copyright your program

why is she making that face?

I stopped caring about C when I was introduced to the concept of studio.h.

I'm a fan of
int
main
()
{
if
(image == anime)
{
puts
("Thank you for using an anime image!")
;
}
else
puts
("Please use an anime image next time!")
;
return
0
;
}

She's embarrassed by Hakase's childish manners.

pretty

aesthetic

no

wrong.
Her (much) younger brother threw her out of his room.

no

Why is she making this face?

She saw your dick.

That's the only face she ever makes

>dick
Do you mean feminine penis?

That's why she's my waifu :3

Is reverse engineering other peoples work an accepted method of learn JavaScript and HTML5?

>reverse engineering Javascript and HTML5
You say that like it's engineered in the first place

I found a website that does something similar to what i want to do.
I thought i'd sort of deconstruct the code bit by bit to figure out how it's done.

What's the best book to learn java?

lostallhope.com

but seriously i think the java tutorial, covers a lot of java + libraries

global vars is bad

Upvoted

why?

Upvoted

(lldb) p s
(int) $13 = 27
(lldb) p c
(int) $14 = 9
(lldb) p 27/9
(int) $15 = 3
(lldb) p s/c
(int) $16 = 1


Ok.

they're coarse and rough and irritating, and they get everywhere. but not like you. you're everything encapsulated, and properly scoped

because some guy at programmin 101 said so

tfw bug in code was really obvious but you spent ages pulling your hair out over it

I have a huge array of zeroes, but there are many sections of it that are !=0.
If I want to make the entire array 0, is it faster to memset the entire array or to memset each section individually?

stupid robot i'm glad

...

>lldb
kek

There's no easy answer. How big is this "huge array?" A memset has some overhead, and even though it makes use of CPU intrinsics to operate really fast, it's always going to be faster to *do less work*.

Memset is really fast but it's far from instant, especially for gigs and gigs of data. If >20% of your array is 1s and they're split all throughout the array then it's probably going to be faster to clear it in one big memset, but if the 1s are clustered, then you'll get more speed from only memsetting the relevant bits.

If you're really time-constrained you might want to consider calling calloc to get some fresh memory that's already been zeroed ahead of time by the OS.

neither because memset will get optimized away anyway

Why not just AND it with 0?
Guarantees its going to be zero.

Because that's not really efficient.

Are you retarded?

Don't be rude!

>pythonfags believe this

just write a for loop bro

>these are the people posting in /dpt/

GUYS I NEED A PROJECT TO WORK ON
I DONT HAVE ANYTHING TO DO
GIVE ME IDEAS

#include
#include

int main(void) {
int array[5];
memset(array, 0, 5);
for (int i = 0; i < 5; ++i) {
fprintf(stdout, "%d ", i);
}
return 0;
}


.LC0:
.string "%d "
main:
pushq %rbx
xorl %ebx, %ebx
.L2:
movq stdout(%rip), %rdi
movl %ebx, %edx
xorl %eax, %eax
movl $.LC0, %esi
addl $1, %ebx
call fprintf
cmpl $5, %ebx
jne .L2
xorl %eax, %eax
popq %rbx
ret

Suicide, you stupid frogposter

Code me a job

idiot memset uses a loop that;s what it does

what you think its some sort of magic thatll make your code run 100 time faster

OK, now randomly fill that array with clusters of 1s and make it 10 million ints long.

...

Back to r9k you go

A game.

But I have one question for /dpt/: How would I go about disabling the spacebar so that the player doesn't space-press the OK button?

Or even better, is there a way I can update the window on the left to show "Score: [user's score]"? It seems like once everything's painted I cannot update it.

That burden's upon you if you want to prove me wrong until then I'm right.

Caps for the first letter of variable name to make it public. Also json field name and struct field name can be different.
type LexicalEntry struct {
Word string `xml:"orthography"`
GrammaticalCategory string `xml:"grammaticalCategory"`
GrammaticalGender string `xml:"grammaticalGender"`
GrammaticalNumber string `xml:"grammaticalNumber"`
}

How can you make a loading screen in C++?

I've managed to easily make one in JavaScript with putting event listeners on the files, but I don't know how I should approach this in C++. The language is pretty straight forward for me so far. It just stops every time I load something. Of course, if the file is little, it's not noticeable, but still, I'm wondering how it should be done.

Okay, you're retarded -- I get it.

An optimized memcpy looks like this:
void X_aligned_memcpy_sse2(void* dest, const void* src, const unsigned long size)
{

__asm
{
mov esi, src; //src pointer
mov edi, dest; //dest pointer

mov ebx, size; //ebx is our counter
shr ebx, 7; //divide by 128 (8 * 128bit registers)


loop_copy:
prefetchnta 128[ESI]; //SSE2 prefetch
prefetchnta 160[ESI];
prefetchnta 192[ESI];
prefetchnta 224[ESI];

movdqa xmm0, 0[ESI]; //move data from src to registers
movdqa xmm1, 16[ESI];
movdqa xmm2, 32[ESI];
movdqa xmm3, 48[ESI];
movdqa xmm4, 64[ESI];
movdqa xmm5, 80[ESI];
movdqa xmm6, 96[ESI];
movdqa xmm7, 112[ESI];

movntdq 0[EDI], xmm0; //move data from registers to dest
movntdq 16[EDI], xmm1;
movntdq 32[EDI], xmm2;
movntdq 48[EDI], xmm3;
movntdq 64[EDI], xmm4;
movntdq 80[EDI], xmm5;
movntdq 96[EDI], xmm6;
movntdq 112[EDI], xmm7;

add esi, 128;
add edi, 128;
dec ebx;

jnz loop_copy; //loop please
loop_copy_end:
}
}


Fuck off, Pajeet.

>An optimized memcpy looks like this:
who gives a shit, just use whatever works

not him but you either fuck off or stop ruining the greatest general the web has known

Graphical, animated tower of hanoi solver for some height n.

Go through random projects on github and make some pull requests

make an AI that you communicate with and if you reach a certain level of autism it ghosts you so you have to start over

call it female specimen

...

don't make it focus the button right away, idiot

Hey guys so I wrote this for my noobie java course or whatever. What can I do better? What can I add? I just wanna learn as much as possible desu.

pastebin.com/G6RZqm7u

Writing a new file system in OCaml. It's called smugfs.

Redpill me on MVC

please tell me it's not heirarchical

If I were to buy a a pic microcontroller, timer ic^2 and some leds to make a small binary clock, would it interest some potential future employers?

finishing up my loli waifu simulator

link

>showing you my waifus source code
dont be disgusting

Threads.

Of course not. It's going to be as smug as possible.

>What are you working on, Cred Forums?
Refactoring

Why didn't you just write good code in the first place?

use proper names for your variables.
you could validate your answers, as you do u can set the answers as well.
format your strings instead of putting them in the middle of fucking everything, don't use the ternary operator inside of them either.
since you know ternary operators, use them instead of using a thousand if statements and only use them for assignments.
don't be faggot user

Projects grow and architectures change

whos the semon demon?

How the fuck does any of this run? Is this some newfangled java 8 meme?

seiga.nicovideo.jp/comic/21425
pretty nice comic

cutethanks

??

>pastebin.com/G6RZqm7u
>public static void main(String[] args) {
Oh
Well you could start by actually indenting your shit, god knows who thought it would be clever to put everything in line with main.

>two genders in 2016

This.
You should use represent gender with an n-dimensional vector representing the users own unique interpretation of their feelings.

Why is python so fucking slow?

It takes literally a week to generate a 2048 El-Gamal key using PyCrypto (or PyCryptodome).

2048-bit*

Because it is meant for small scripts, use something like C for cpu intensive programs

>python

>Why is python so fucking slow?
>It takes literally a week to generate a 2048 El-Gamal key using PyCrypto (or PyCryptodome).
perhaps you are just a fucking retard?

github.com/majestrate/bdsmail/

and yes it does works

How so? It's literally _one_ line of code:

k = ElGamal.generate(2048, os.urandom)

bretty cool user

why not fortran?

the cuck being cucked by the cucker

Clang

That's also viable, although not recommended.

and that should call C. if it doesn't then it's pebcak.

$ time python programthatgenerates2048bitelgamalkey.py
real 9m49.623s
user 9m36.250s
sys 0m13.257s
$


lol

grep -i 'model name' /proc/cpuinfo | head -n1

Does os.urandom read from /dev/urandom or /dev/random? If it's used for generating crypto graphic keys it should use /dev/random on linux which can block if there is insufficient entropy available.

isn't cc just an alias for gcc and only there for unix compatibility reasons

intel i5-3230 @ 2.60ghz

I'm pretty sure it does. At least, crashing the program shows that it is making calls to something called "_Numbers_gmp.py" which smells like GMP. Could be wrong though.

It uses urandom afaik.

lwn.net/Articles/693189/

It might block in some versions.

>In the Python 3.5.0 release,os.urandom()was changed to use the relatively newgetrandom()system callon Linux. Unless it has been called with theGRND_NONBLOCKflag,getrandom()will wait, if need be, for the system entropy pool to be initialized.os.urandom()does not supply that flag, meaning that it can block if the entropy pool has not yet accumulated enough randomness

>For Python3.5, theos.urandom()change will also be partially reverted, in that the function will, once again, be non-blocking. It will callgetrandom()with theGRND_NONBLOCKflag and, if that call fails, fall back to reading/dev/urandomas before. With these fixes in place, the blocking part of the change is effectively reverted and the immediate problem has been solved.

That pasted like shit, phone posting.

Is it possible to have an "autocompleted" scanner or other console input in Java? Like, it prompts the user for an input but there's something already queued for input as a suggestion to the user that they may delete if they want

Have you ever tried printing to stdin?

Yes it's possible, don't know if it exists though.

Thanks.

In the end, it might just be a combination of >python and bad luck.

I'm getting times which range between ~10 minutes and

Perhaps some of the DLLs you are trying to use it with are .NET CIL, rather than native code?

I have not
and now I have
it doesn't appear to have a function for printing to it.

Also that sounds inconvenient, just use readline style autocomplete where the user hits tab to complete.

It's not actually for the user, it's for me. I just don't want to keep entering the same test parameters time and time again but I also don't want to fuse the input

system.out.print() ????

that's printing to out, not in. if you were listening for input and you printed that and then hit enter, the scanner would read nothing at all.

have you thought that, perhaps, your program is waiting to get some entropy?

this is the kind of people that criticizes python.

If you're fine with tab completion, a quick easy solution would be to run your program through rlwrap with a wordlist(-f) containing your input.

This is assuming you're not using the windows console.

is there any good book for win api? I can't understand shit from microsoft's documentation website.

What's wrong Pajeet? MSDN is one of the best resources out there.

Windows via C/C++.

>What's wrong Pajeet?
I can't understand shit from microsoft's documentation website.
what does pajeet even mean?

He's calling you a low-skill unresourceful indian programmer

print "This program converts the tempurature between celsius, kelvin, and\
fahrenheit scales,enter the temperature followed by the first letter of the\
scale, e.g. 32c for 32 celsius"

#user enters input
temperature = raw_input(">")

#sets the letter at the end of the string as the variable entered_scale
entered_scale = temperature [-1]

print entered_scale

if entered_scale == "c":
new_scale = temperature.replace("c", "") #rips the letter off
celsius = int(new_scale) ## and converts string to interger
fahrenheit = celsius * 1.8 + 32 #logic
print "Fahrenheit = ", fahrenheit #prints answer to user
kelvin = celsius + 273.15
print "Kelvin = ", kelvin

elif entered_scale == "f":
new_scale = temperature.replace("f", "")
fahrenheit = int(new_scale)
celsius = (fahrenheit - 32) / 1.8
print "Celsius = ", celsius
kelvin = (fahrenheit + 459.67) * 0.55555556
print "Kelvin = ", kelvin

elif entered_scale == "k":
new_scale = temperature.replace("k", "")
kelvin = int(new_scale)
fahrenheit = kelvin * 0.55555556 - 459.67
print "Fahrenheit = ", fahrenheit
celsius = kelvin - 273.15
print "Celsius= ", celsius

so much repetition

serious people don't use fahrenheit

I had a zipf checker, forgot to save the finished version, now im stuck with the half finished one I forget how to fix

#get name of file and open it
name = raw_input('Enter file:')
handle = open(name, 'r')
text = handle.read()
words = text.split()


def percent(part,whole):
return part/whole * 100


wordlist = words
wordfreq = []
for w in wordlist:
wordfreq.append(wordlist.count(w))


print "\n"
print "Frequencies\n" +str(wordfreq) +"\n"
print "\n"
print "Pairs\n" +str(zip(wordlist, wordfreq)) +"\n"

import collections
from collections import Counter
lis7 =words

x = collections.Counter(lis7)
print "\n"
print "Word Ocurrence"
print([elt for elt, count in x.most_common()])
print "\n"
print "Number Occurence"
print (x.most_common())
print"\n"

total = sum(wordfreq)
percentages = {}
for lis7, wordfreq in x.most_common():
percentages[lis7] = percent(w,total)
print percentages
print percent(wordfreq,total)


it crashes at the end, but still is slightly usable

couldn't you just set new_scale to whatever is in entered_scale and avoid rewriting that in 3 separate instance

what is the best book for c++?
for someone who already knows how to program.

Bjarne's one.

what about java?

PLS????????????

You're simply missing the implementation files.

Thats not it, the problem is with these two files. I have a makefile that links everything. I am only supposed to change Inventory.cpp and its header.

No you posted the rest of the files in another thread you only have the headers.

new fred when?

I have the cpp's, I just didn't post them. When I compile the program all of the headers and cpp files are in the same folder, and a makefile links them. So it's something with the only two files I'm supposed to edit, which are the ones I posted in this thread.

Could you zip them all and upload somewhere? It's hard to guess.

guys? nobody can recommend me some solid java book? preferably taking into account that i already know programming.

>ufile.io/e8f01

This is the last one

Ok so it's definitely something wrong with the makefile. Not sure what yet, been a while since I used make.

sensei agreed to be my mentor for my senior honors project

give me some ideas

averaging ints in c

stupid fucking frogposter go away i hate your kind
it's not just a meme either

also

...

why the fuck are you still here
everyone hates you

I'm telling you, it can't be. The assignment is to only alter the inventory class and its functions.

Wait what, did you run the storage.exe, thats what it's supposed to look like. He gave us that for reference.

just keep the toads to yourself

PAGE 9 GUYS
EVERYONE PANIC[!!]

No I compiled it with g++ instead of the makefile and ran the compiled program (not storage) - and it worked. So it's the makefile that's faulty.

NEW THREAD

Oh sorry, I see it at the top. I'm retarded. So my code works, wow. Though I don't know what I'm going to do because the assignments are graded by an auto-grader and it has to be able to compile with the make file.

...