/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

asterisk.org/get-started
github.com/yasp-dota/yasp)
en.cppreference.com/w/c/string/byte/strlen
twitter.com/NSFWRedditImage

FIRST 4 TRAPS!

Creating a model where each input is classified with just one label is easy - stuff all outputs into softmax for probabilities and use cross entropy to compare that with inputted one-hot class vectors for loss function.

What if in my system and input can have any number of labels (among predefined)?

With my 4 labels I created four softmax nodes; final loss function is the sum of losses for my four classifiers - each of them decides whether the label applies to the input or not.

Is this a good idea?

while(1) {
printf("Please don't use an anime image next time!\nThank you!");
}

I'm trying to read some tile map data from a file, but when I loop through a string containing the data, it acts as if every character is a '\n'. I can't see why it would be doing this, I guarantee that data is not a bunch of newlines.

Can somebody see where I went wrong?

int layer_count = 0;
for (tinyxml2::XMLNode* layer_node = level_node->FirstChild(); layer_node; layer_node = layer_node->NextSibling())
{
std::string layer_node_name = layer_node->ToElement()->Name();
if (layer_node_name == "layer")
{
std::string layer_string = layer_node->ToElement()->GetText();
layer_string.erase(std::remove(layer_string.begin(), layer_string.end(), ' '), layer_string.end()); // remove spaces from layer data
std::cout

in the second for loop, shouldn't that be

for (char& c : layer_data)

//rather than

for (char& c : layer_string)

Wouldn't compile.

I don't see an issue here
the error is probably at the location where you use the characters

>Accidently write for segments in segments: in Python
>No error
>Use another function from the standard library that should only accept a single string
>Give it "segment.text" instead, which doesn't even fucking exist as a variable anywhere
>No error
>Just hangs
What the fuck

>using Python
No sympathy for you, faggot

LLVM Question: Is it possible to store llvm::GlobalVariable (s) in one Module and load them in another Module and how to ? Modules are created under the same llvm::Context.

The error only occurs when I try to access layer_data[y][anything above 0]. It would be out of range because the vector is supposed to stop at a newline character. And it just so happens that there is a newline character at the beginning of each vector, which is dumb.

Reverse traps only, please

Unsafe languages such as Python and Ruby should be banned in industry

So everything but Rust and purely functional languages are out?

>No error

Why would it error?

segments = ['1', '2', '3']

for segments in segments:
print (segments)


it'll just cancel out and print segments.

>Rust
>Safe

Yes, unsafe languages have held us back for too long and have cost trillions of yen

I'm working on an IRC like protocol for VOIP, and a server for that protocol.

so like 2 bucks?

More like hundreds of dollars, don't be so racist bro

>Working on an implementation of Hangman.
I'm trying to learn how to work with APIs hosted on a server (given a word, I want its definition).
>The dictionary is a text-file which contains about 350K+ words, one word each line.
>Using OO - load the dictionary once when an instance of the game logic is created - ctor spawns a dictionaryLoader thread which works in the background.

you simply need to read the documentation for that api
there's no other way unless there's a public swagger interface or wsdl or something to that effect

Purely functional languages aren't safe. They appear to be safe just enough to get grants (the spherical cow meme). GHC still crashes on some programs. Coq programs still run out of memory. They pretend these aren't problems.

Rust isn't safe either.

Coq and Rust are both less safe than Java.

Go > *

What's wrong with Ruby?

Never heard of Asterisk desu

>there is literally only one language Go is better than
>nobody has ever heard of said language

>tfw Go barely beats out a framework
asterisk.org/get-started

>asterisk is GPL
>Go is BSD

Is that the only reason why it's better? kek

Nice generics

Go is a retarded language, designed for use by retards

>Go
>designed

>look at me I'm a elite programmer, I masturbate to my functional language!

>hating go makes you functional
>functional programmers using the term 'generics'

Wait, I take that back

Hating Go might not make you functional, but liking it certainly makes you dysfunctional

>what are types
>type b don't hurt me
>type b don't hurt me
> no more

optional typing is the single most important feature of a programming language nowadays

c#, scala, typescript, haskell

languages that hurt
c, java, javascript, python, perl ...

most advanced typesystem that actually is used -> Haskell

>optional typing
The fuck is this bullshit. Typing should be mandatory.

^

But what would happen to the code bootcamps for autistic children.

>most advanced typesystem
>Haskell
Spoken like a true "pretend to know everything while I know nothing" faggot.

>perl
Have you even bothered to check out Perl 6? I doubt it.

Hopefully, they will end. They create American pajeets.

Nothing is wrong with it.

Back in the past Twitter abandoned Ruby, because they didn't get what Ruby was designed for and what it was NOT designed for.

If you want Message Queues in an insane amount, you should rather use something like Erlang, which was especially designed for such purposes..

Now how cool is that today we have Elixir, wich is pretty close to Ruby but runs on the Erlang Virtual Machine - which leverages stuff like WhatsApp (you might have heard of it) and had 99,9999999 % server uptime at Ericson. It's a beast and THE mother of all languages when it comes to cuncurrency.


Elixir is so sexy (and of course it's functional).

I was looking at some code the other day to convert a comma-delimited string like "1,2,3,4" into a list of integers.

The code was on Java 7, so it’s still written like it’s 1999: with a loop, parsing ints and appending to the result inside the loop.


why modern ((((((programmers)))))) are such whiny bitches

>bwaaah i'm a programmer and they expect me to know things

>muh maps and filters make a language functional

Is there any FUNCTIONAL reason to echo my HTML in between PHP statements rather than dropping in and out?

Because the formatting it disgusting when it's echoed. It still WORKS when I drop in and out between modules, but will there be any significant performance hit?

I'd like to retain color-coded formatting so other devs can eventually manage it more nicely.

Like, I WILL echo it if there's a significant performance hit to doing this, but I'd really prefer not to. Editing echoed content is a fucking pain in the ass, because EVERYTHING is grey

He meant usable languages with libraries and a big community, not little languages such as Idris and Agda.
Hindley-Milner's about as good as you can get right now in popular languages.

ehm, this is the best practice, I do not see the problem.

>like it’s 1999
Did the programming standards suddenly change or something? kek

>libraries
You can use libraries from Haskell and C easily in both of these.

>and a big community
So, not haskell.

Haskell's type system is less advanced than C++'s.

Haskell is unusable.

>undefined
>Monad contains fail
>typeclass hierarchy is disjointed and doesn't do inheritance in most places where it should
>MonadPlus is two classes merged into one
>no way to enforce that functions are total

I'm starting to look at a huge program on github. I have some experience in Java, but this (github.com/yasp-dota/yasp) is so big I hardly know where to start. I want to look at the parser mainly, should I just click on random files? How do I wrap my head around whats happening in the big ass program, both in the individual files and in the whole thing?

111111111111
111111511111
111111111111


If this data was in a string without newlines or spaces, how could I work out the number needed to access 5?

>no way of representing multiple uses of the same typeclass
>language extensions effectively necessary but not "standard"
>language extensions often incompatible

etc etc

>tfw some people on Sup Forums call themselves programmers despite never coding anything in Haskell

size_t i;
for (;str[i]!='5';++i);

I also know the width and height of the data, forgot to mention.

>tried to make an Android app for fun
>doesn't support Java 8
for what purpose?

*size_t i = 0;

Most Haskell implementations other than GHC feel so crippled after using GHC with even just one or two language extensions.

I'm not sure what the best solution to wanting multiple instances for some typeclasses some of the time is. Coherency is a really nice property the rest of the time (of course, GHC doesn't actually enforce it, IIRC)

Then there's all the people whinging about monad transformers

Clone or download it so you can navigate the files in your favorite editor. Or since it's in Java, maybe an IDE. Either way it will be better than opening a bunch of browser tabs so you can cross-reference different modules.

Just don't use PHP, it became obsolete years ago, and it has a shitty design. Just use node.

Just use another Prelude that's better for you?
I agree that the inclusion of fail is stupid af, but at least you can change your prelude.
Concerning the problem with total functions, you just need to read the docs I guess? And type gives a lot of info about it, even though there's no theoritical way to know about it.

Yeah sure but it's still a pain in the ass for a small gain. The change we need in today's software is to a Hindley-Milner type system, which would be so beneficial, and this change would be critical. I don't believe that a change to a typesystem such as Agda's would be that beneficial.
As for the the multiple use typeclass, are you referring to the List/ZipList Monad implementation for example?

Coherency is guaranteed by the usual restrictions on typeclasses (I think?), but the IncoherentInstances extension allows you to make typeclass instances that might result in incoherency

Named instances

pseudo-code:
while(read line){
idx_5 = line.indexOf('5')
if (idx_5 != -1){
// ...
}
}

I might have been thinking of uniqueness. Either way, I find that typeclasses are really convenient and work the way I want 90% of the time, and I'd be loath to give that up.

>Just use node.
Why node over something like rails or django?

>use node, rails, or django
Why node, rails, or django over something like scotty, servant, or yesod?

node is more popular
you can use those if you want. I like django alot, personally

Playing around with memory management in C, since I don't have much experience
#ifndef SAFESTR
#define SAFESTR
#include
#include

/**
* char *safecat(char *dest, char *src)
* Concatenates src to dest, but almost guarantees that dest will be large
* enough, assuming enough memory
* Return Values:
* On success: returns pointer to resulting string
* On error: returns NULL
*/
char *safecat(char **dest, char *src)
{
int sized = strlen(*dest);
int sizes = strlen(src);
char *newstring;
if ((newstring = calloc(sized + sizes + 1, 1)) == NULL)
return NULL;
strcpy(newstring, *dest);
strcat(newstring, src);
free(*dest);
*dest = newstring;
return *dest;
}

#endif
Is there anything wrong with this in terms of functionality (leaks in the function, etc.)?

Well you could use them both but I don't like ruby or python.

Do you have any experience with Yesod? I haven't been able to try it myself, is it really comfy writing code with it or is it really tedious?

How is this better than just looking at the individual probabilities in the final output of a more standard model? They're telling you what the probability of your sample belonging to a class is, so presumably if there are two classes it could belong to both of those entries will be higher.

Also this doesn't scale well. If you wanted to use it on something with 1000 classes you'd need 1000 weight matrices. Might be better to use an image-to-sequence model with LSTMs.

Rails/Django have been around for a long time, meaning there are a lot of gems/packages available.

In addition, to be honest, node has always scared me off because I've never managed to have an enjoyable experience with npm. Pip is alright, but bundle blows both out of the water.
It can't be helped

I don't really know node yet, DO have to finish this entire site within a month, and am using MySQL, which is integrated into PHP.

Also, what about clients who are NOT using JavaScript?
Plus I have no idea if my host will be offering Node support.

C'mon, Sup Forumsuys, I'm just asking if there's gonna be a performance hit.. Not a suggestion on an alternative language/library I don't know/am not prepared to use/which may not suit all my needs

Learning c++ and Vim. I just finished vimtutor and configuring vimrc.

I'm new to programming and c++ in general but I hope to get better practicing every day.

I was just memeing, I've only heard that it's good. I can only say to try their tutorial.

The biggest complaints I've seen are that it has a lot of dependencies (so is likely to cause conflicts in an environment with already-installed packages), but that can be managed with cabal sandboxes or stack.

Yesod is on the heavier end of haskell web libraries though, so if it's a smaller project a smaller library might work better. Yesod is modular and many of its things exist as their own library that you could use outside yesod.

Yeah I've heard about smaller frameworks for haskell. How's stack by the way? I've never used stack or cabal because I'm on Gentoo and there's a dev-haskell category on portage.

Also I've been writing my own typesystem in Haskell, I've already got a simply typed lambda calculus down with a typechecker, now I need to work out the type inference algorithm.

27 year and some fags STILL use int for sizes.
Literally when will they learn?


>en.cppreference.com/w/c/string/byte/strlen
>size_t strlen( const char *str );
>size_t

Nigger

Good luck, user. c:

This
int genocide when?

hey guys I'm shopping for a new editor on winblows

I use notepad++ which I think is great because
1. easily definable hotkeys
2. You can supply command line arguments when you press the hotkeys (i.e, you can feed an external batch program your file's location and therefore run any language from the command line from within notepad++ in a fashion that isn't defined for each file)

but it doesn't alert you when you misspell variables which is bad
so any other text editors that can do 1 and 2 already would be nice, if they can also track variable use (which creates annoying bugs which takes a lot of time to iron out if uncaught)

Sublime Text
Atom

Can't argue with those quad dubs

>winblows
kek

>notepad++
gay

doublegay

Just go for emacs

What's the point of size_t if you can use unsigned int?

>emacs
It's like you want RSI

I actually have two hands, so no.

Dumb processing question... Even though the API says size(int, int) must be the first piece of code in the setup() method, when I put size() in setup(), I get an error.

However, when I put size() in settings, it works fine.

size_t holds any address difference

One will work on all systems, the other will fail in spectacular ways and generate countless security flaws.

How do I learn C++?

Should I buy Programming: Principles and Practice Using C++? It seems pretty expensive but if it's the best resource then I'll get it.

What the fuck? No

Because it cna be a different size.

That's ptrdiff_t.

The largest size of allocated memory doesn't have to be the same size as the largest difference between pointers.

Oops, meant this

install YouCompleteMe

stack makes it easy to have multiple versions of GHC (including GHCJS). Also nicer than cabal sandboxes because you don't have to recompile everything for each package as long as the dependencies are resolved to use the same versions. I use stack for new projects.

yes, nowadays you do
Arrays.asList(string.split(",")).stream().map(Integer::parseInt).collect(Collectors.toList())

>tokens meme
no

I bought C++ primer but I can't keep the pages open.

Guess that's it then.

>.asList
>.stream
>.toList
Disgusting

Wow friendo time to switch to Haskell, this is purely functional code right here.