/dpt/ - Daily Programming Thread

Previous: What are you working on, Sup Forums

Other urls found in this thread:

gitlab.com/bollocks/combatbeard
msys2.github.io/
sfgui.sfml-dev.de/)
youtube.com/watch?v=yci5FuI1ovk
twitter.com/NSFWRedditVideo

Learning C++, so I'm slowly writing an application in gtkmm.

I only wanna kill myself a little bit.

Repost from the last thread since i didn't realize it was dying.

What is a good first language to learn?
Is C# a good first language?
What is a good compiler/IDE to use?

boldRed or bold_red?

How much anime do I have to watch to become a 100% better programmer?

Write a program that returns f(x) where f(x) is the percentage increase in programmer skill and x is the number of hours watching anime

bRed

double f( double x )
{
if( x == 0 ) return 0;
else return -inf
}

Java: boldRed
C#: BoldRed
Ruby, Python: bold_red
C, C++: Whatever clashes the least with the libraries you are using. If there's an even split, prefer bold_red.

C
It's okay
GCC

function a(x) {
let k = 10
return k/x
}

You will have to become animaymay first.

Ocaml (many-many paradigms, modern language design)!

>
>

Please.

Install Linux and use GCC.

Thanks.

Or FreeBSD with Clang.

Or if you're using Windows 10 you can just install WSL and run GCC natively

Yes that works.

Don't do this, it won't work.

don't use crap

It works fine, gcc is one of the few things that works perfectly on WSL.

I don't know if he's still around but someone asked about how to build an irc client in the previous thread:

Learn to open a tcp socket in your programming language. Then learn that every irc message has 3 components: prefix, command, parameters. These things can mean different things based on the command. A message to be seen in a channel will look like
:nick!name@address PRIVMSG #channel :text of the message\r\n

prefix: nick!name@address - who it came from
command: PRIVMSG private message command
parameter 1: #channel first parameter of a privmsg is the target. if it's a person it's their nick. if it's a channel it begins with a special channel character. # is the most common in my experience.
parameter 2: :text of the message
if a parameter is a string that can contain spaces it begins with a colon. this means you only get one string like this in message and it has to go at the end because this is saying space is no longer to be treated as a delimiter.

\r\n: all messages end with this. multiple messages can come in a packet. a message can be broken up between two packets. tcp guarantees you can count on receiving packets in order but any device, including yours, can choose how to break up the packets.

>What are you working on, Sup Forums
Learning C++, SFML and OpenGL...

Header file includes, cmake, proper library and dependency management, GNU utilities and a usable terminal with proper functions are all good examples of things that do not work perfectly.

Don't use windows.

This shit all works fine, have you even used it or are you just regurgitating garbage you've read here? I ditched my dual boot setup as soon as WSL became available and I've not had a single problem with any of the utilities I used on Linux.

>What is a good first language to learn?
C++ (in all seriousness)
>Is C# a good first language?
75%
>What is a good compiler/IDE to use?
I suppose you are reffering to C#, so Visual Studio.

same here, except I use C and CSFML

Lol, none of it does. It's a complete mess, it'd be less of a pain to setup dual boot for a linux distro or even virtualize an entire install then even attempt in-windows linux. I keep windows sitting around for system administration and gave it a go when it became a thing. Windows 10 is still a mess and so is the state of getting C support working. It will end in headaches and frustration not even worth bothering with.

> I ditched my dual boot setup as soon as WSL became available and I've not had a single problem with any of the utilities I used on Linux.

Shill confirmed.

k

>non-ironically using C
>2016
I feel sorry for you, at least C++ has STL

Anyone who uses jetbrain is a fucking shill

but sepples is horrible, user

>75%
What do you mean by this?

may i add sth

the guy also asked how to proceed without feeling that he had too-vague an idea, or that he was going too much into useless detail

take the hands on approach

look for the protocol specification, but also open an irc client and wireshark and see how the dance actually looks like for each distinct command, for example /list may actually come back in chunks, or messages you can send may be have a fixed limit, etc

then imitate it

Yes in 75/100 cases

What are you doing with SFML user?

>Anyone who uses jetbrain is a fucking shill
Just using it is shilling?
I don't think you know what the word means.

Simply for creating a window, handling user input and sockets.

>sockets

noice, you'll see it's really easy to send data with SFML's sockets

I'm building a file picker for my program, look

>wireshark
Yeah also telnet and be your own client manually. All you have to know to start telnet irc is how to nick and user name to the server and set your modes. To keep your connection open you have to send a PONG with the same data as sent with PING before the timeout. Everything you can learn as you go.

gitlab.com/bollocks/combatbeard

I wrote a barebones library for a client that I use for a bot. The only bug I know about is if a message gets broke up between packets it drops it. I'm going to fix this when I'm not lazy. Hopefully tonight. The password control thing is vulnerable to replay attack so come up with something better if security really matters.

The part that can be considered the library are files named: channel ClientSocket configuration ircmessage kdircbot logger messagehandler mymessagehandler shawrap PracticalSocket. The rest are part of a bot I mess around with every once in a while. It's good as example code.

On it's own it will keep track of what channels its in and what users are in that channel. It will identify by sending identify password to nickserv. It will reply to pings. Other than that the rest is up to you. It parses the message in the prefix, command, parameters but you have to decide what it does with with a message handler.

Consider it WTFPL except the socket class. That's not mine. I request credit by including the URL with anything you distribute that uses it but I'm not going to throw a shit fit if you don't.

Yes, SFML is one of the biggest reasons I decided to learn C++ even though there are bindings for Java which is the language im most fluent in. I really like the simplicity

SFML thread?

don't learn ocaml,
has horrendous syntax and isn't functional enough

Nice, post webm user

Your GUI system looks really nice. How are you rendering it, software or OpenGL?

I use a lib called SFMLGUI, it's very intuitive
It's uses SFML rendering and openGL internally

Playing with Processing.

I suggest using msys2, if you want to write portable C or Windows specific C it will be better for you. Msys will compile native Windows executable without a *nix library dependency. Use cygwin if you want/need to write and compile code aimed at *nix.

msys2 gives you a package manager for a lot of dependencies which is nice compared to the smaller set included in regular msys. Cygwin also has its own package managment system but I don't think it's better than the msys2 one (pacman from Arch).

msys2.github.io/

>has horrendous syntax
it's good enough to parse
>isn't functional enough
that's a plus for a first programming language
imperative programming can't be replaced with functional programming

What resources are you using for learning SFML?

It's just an Asteroids clone so it should look pretty similar. Took a bit though since it didn't wanna capture the window size properly. I just changed compilers and spawning appears to be totally fucked up, hence the explosion on spawn. I must've been relying on undefined behavior or something because it used to work properly.

I just used the tutorials on their website. I didn't really have to learn much though since all I really had to do for my project was to create a window and draw some rectangles on it. Haven't got audio yet since I'm not sure how it works in the original Asteroids.

Whoa, that's exactly what I've been looking for. I thought imgui was my only option, but SFGUI (sfgui.sfml-dev.de/) looks so much better.

The default skin reminds me of what Steam used to look like back in the day.

very nice, now do asteroid-asteroid collisions

Yeah it's a pretty cool lib, you can connect function to buttons or whatever you want, it's very useful

I have a java assignment where I need to set up a secure login server. Just something that allows people to create usernames and passwords and login if they match. It must be secure.

Can anyone give me a hint on what to look up?

I should also point out that you can have both but obviously you don't want to link both in your path. I have msys2's bin linked in my path and drop into a cygwin shell if I need it, usually for third party software that relies on POSIX conventions/calls that are not implemented or are different in Windows and haven't been ported/patched yet.

Use whatever editor you come to like too, as long as you can get files into a directory that can be compiled you're set, if you like an IDE you can do that too and point it at your compiler.

>xkcd

>very nice, now do asteroid-asteroid collisions
Everything is ruined, rip.

Anyways it was pretty lame after fixing this bug since the smaller pieces would pretty much instantly destroy each other after two large asteroids collided.

*procedural programming CAN be replaced with functional programming

Don't destroy asteroids when they collide, make them bounce back user

Download SFML and learn c++

what computer language should I use to do the project eule challenges? C?

Haskell

Pen and paper.

Storage formats and encryption techniques (do not implement your own encryption methods, use a standard). Depending on how much you care and the scale you can probably get away with storing usernames in something like json but in a real case you'd probably use some kind of database like sqlite or postgres.

Make sure people can't access anything obviously and demand some kind of auth for every restricted request.

ASM

I started a CS course this fall. I'm learning Java and I wonder why it gets so much hate, until now it's been quite fun.

/dpt/ hates fun

#include
#include
using namespace std;

int x;
int y;

int main()
{
cout x;

cout y;

ofstream file;
file.open(x".txt");
file

>j*va
>fun
Enjoy your LeggableDecoratorFactoryVisitor classes.

>I wonder why it gets so much hate
are you using bluej?

I personally hate java because it lacks optimization when compared to c++. Its only taught because its easy and teaches bad practises

you need to use std::string for file paths

>x".txt"
What is this even supposed to do in your mind?

>x".txt"

what

Stop

I've been using Eclipse until now but I haven't considered anything else.

So basically people don't like Java because it's resource hungry and poorly optimized. But that's the price to pay for its portability isn't it ?

I want to create a neural network which causes 2D 'creatures' to evolve to better perform a set task.

I only know Java, would this be an okay language? I would use LibGDX and Box2D.

Any suggestions?

>youtube.com/watch?v=yci5FuI1ovk
Like this, but 2D

name the file x.txt, since before it was working as "filename.txt".

Jelly rocks.
Also figured out a way to do this, gonna post it after I can process the webm and then stop spamming the thread with webms.

yeah but then its hugely dependant. You cant run java without the java run time environment where as you can run a c++ executable without one. So can you really call something like that portable?

Use Spring Security for this.

Holy shit...
ofstream::open() expects a null terminated c style string. C++ has std::string so use that until the end.. cin will work with std::string. You can append .txt to it with the + operator x+".txt". then file.open(x.c_str()) will give the c string format file.open expects.

Get those damn variables out of global.

No more explosions after they become small since the small rocks have no mass.

Forced OOP and the consequent boilerplate it requires are cancer.

Well, the rock aren't supposed to break each other right?

>Writing my own version of GLFW using XCB
Jesus christ, why can't open source devs produce remotely useful documentation. It's just "Here's how to hello world" and "here's raw protocol docs that you won't know how to search unless you could just write the docs yourself".
All I want to know is what the fuck event I'm getting when I iconify my window. It's number 64 (reponse_type of 192). But it's some extension event and I don't see that I have enabled any fucking extensions.

I'm also learning c++.
I'm using qt and it's fun.

Java is getting less verbose with every release.
Also blame JEE, not Java itself.

I'm writing a c++ library, and i want it to be multiplatform.
Should i rely on qnetworkaccessmanager or libcurlpp?
I think using the whole qt framework just adds unnecessary bloat

Correct, was just to see what they'd do since user asked about it.

>boilerplate code
Didn't Spring Boot fixed this?

should I use RGBa or aRGB for alpha colors represented as unsigned ints? what's more standard/usual/comfortable? it's X11-related btw

>color
>unsigned int
waste of memory

RGBA

Everyone uses RGBA

I'd go with RGBA, however don't assume unsigned int is 32bit.
False. Cairo (a popular 2D vector library) uses ARGB for example.

No release can circumvent "public static void main".

>False. Cairo (a popular 2D vector library) uses ARGB for example.
Alright, I'll change it to "Pretty much everyone uses RGBA".
Notably example are all of OpenGL, and the PNG file format.

OpenGL supports both actually. I would know, since I had to display Cairo surfaces with OpenGL.

What do you use for programming anons?
>text editor (vim,emacs, sublime, atom etc)
>ide (eclipse,jetbrains, netbeans etc)

>C, C++: Whatever
C and C++ are snake_case languages too. Just look at their standard library functions. CamelCase is unfortunately common in C and C++ libraries, but it's objectively wrong.

Vim, IDEA, QtCreator.