[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: 360
Thread images: 28

File: ballmer_peak.png (91KB, 652x592px) Image search: [Google]
ballmer_peak.png
91KB, 652x592px
Previous: >>57390345

What are you working on, /g/
>>
Learning C++, so I'm slowly writing an application in gtkmm.

I only wanna kill myself a little bit.
>>
>>57395045
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?
>>
File: 1450188787035.jpg (103KB, 800x600px) Image search: [Google]
1450188787035.jpg
103KB, 800x600px
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
>>
>>57395123
bRed
>>
>>57395169
double f( double x )
{
if( x == 0 ) return 0;
else return -inf
}
>>
>>57395123

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.

>>57395085

C
It's okay
GCC
>>
>>57395169
function a(x) {
let k = 10
return k/x
}
>>
File: istenvertebarmok.jpg (509KB, 1020x976px) Image search: [Google]
istenvertebarmok.jpg
509KB, 1020x976px
>>57395169
You will have to become animaymay first.
>>
>>57395085
Ocaml (many-many paradigms, modern language design)!
>>
>>>57394832
>>>57394832

Please.
>>
>>57395429
Install Linux and use GCC.
>>
Thanks.
>>
>>57395436
Or FreeBSD with Clang.
>>
>>57395436
>>57395429
Or if you're using Windows 10 you can just install WSL and run GCC natively
>>
>>57395452
Yes that works.

>>57395454
Don't do this, it won't work.
>>
>>57395454
don't use crap
>>
>>57395461
>>57395468
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:

>>57394536
>>57394558

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.
>>
File: cpp 2.jpg (20KB, 360x193px) Image search: [Google]
cpp 2.jpg
20KB, 360x193px
>>57395045
>What are you working on, /g/
Learning C++, SFML and OpenGL...
>>
>>57395471
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.
>>
>>57395483
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.
>>
>>57395085
>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.
>>
>>57395481
same here, except I use C and CSFML
>>
>>57395500
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.
>>
>>57395524
k
>>
>>57395519
>non-ironically using C
>2016
I feel sorry for you, at least C++ has STL
>>
Anyone who uses jetbrain is a fucking shill
>>
>>57395547
but sepples is horrible, anon
>>
>>57395514
>75%
What do you mean by this?
>>
>>57395476
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
>>
>>57395597
Yes in 75/100 cases
>>
>>57395481
What are you doing with SFML anon?
>>
>>57395585
>Anyone who uses jetbrain is a fucking shill
Just using it is shilling?
I don't think you know what the word means.
>>
>>57395783
Simply for creating a window, handling user input and sockets.
>>
File: 2016-11-05_11:44:13.png (341KB, 1920x1080px) Image search: [Google]
2016-11-05_11:44:13.png
341KB, 1920x1080px
>>57395878
>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
>>
File: 1468957425030.png (108KB, 1047x924px) Image search: [Google]
1468957425030.png
108KB, 1047x924px
>>57395634
>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.

https://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.
>>
>>57395915
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
>>
File: Untitled.png (191KB, 1920x1080px) Image search: [Google]
Untitled.png
191KB, 1920x1080px
>>57395878
>>57395915
SFML thread?
>>
>>57395301
don't learn ocaml,
has horrendous syntax and isn't functional enough
>>
>>57396048
Nice, post webm anon
>>
>>57395915
Your GUI system looks really nice. How are you rendering it, software or OpenGL?
>>
>>57396109
I use a lib called SFMLGUI, it's very intuitive
It's uses SFML rendering and openGL internally
>>
File: le webm.webm (3MB, 798x798px) Image search: [Google]
le webm.webm
3MB, 798x798px
Playing with Processing.
>>
>>57395429
>>57394832
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).

http://msys2.github.io/
>>
>>57396060
>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
>>
>>57395915
>>57396048
What resources are you using for learning SFML?
>>
File: output.webm (1MB, 1022x788px) Image search: [Google]
output.webm
1MB, 1022x788px
>>57396072
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.
>>
>>57396202
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.
>>
File: shot_001.png (86KB, 1023x767px) Image search: [Google]
shot_001.png
86KB, 1023x767px
>>57396119
Whoa, that's exactly what I've been looking for. I thought imgui was my only option, but SFGUI (http://sfgui.sfml-dev.de/) looks so much better.

The default skin reminds me of what Steam used to look like back in the day.
>>
>>57396205
very nice, now do asteroid-asteroid collisions

>>57396221
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?
>>
>>57395429
>>57396146
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.
>>
File: man the trash cans.png (118KB, 518x285px) Image search: [Google]
man the trash cans.png
118KB, 518x285px
>>57395045
>xkcd
>>
File: Untitled.png (178KB, 1024x790px) Image search: [Google]
Untitled.png
178KB, 1024x790px
>>57396235
>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.
>>
>>57396148
*procedural programming CAN be replaced with functional programming
>>
>>57396405
Don't destroy asteroids when they collide, make them bounce back anon
>>
>>57396256
Download SFML and learn c++
>>
File: 1465476689902.png (379KB, 595x634px) Image search: [Google]
1465476689902.png
379KB, 595x634px
what computer language should I use to do the project eule challenges? C?
>>
>>57396504
Haskell
>>
>>57396504
Pen and paper.
>>
>>57396256
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.
>>
>>57396504
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.
>>
>>57396562
/dpt/ hates fun
>>
#include <iostream>
#include <fstream>
using namespace std;

int x;
int y;

int main()
{
cout << "enter filename" << endl;
cin >> x;

cout << "enter input" << endl;
cin >> y;

ofstream file;
file.open(x".txt");
file << y << endl;
file.close ();
}



2 questions, obviously using int isnt working, but i also cant name the file x".txt".

Can i have a hand Or rather a point in the right direction
>>
>>57396569
>j*va
>fun
Enjoy your LeggableDecoratorFactoryVisitor classes.
>>
>>57396562
>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
>>
>>57396593
you need to use std::string for file paths
>>
>>57396593
>x".txt"
What is this even supposed to do in your mind?
>>
>>57396593

>x".txt"

what
>>
>>57395301
Stop
>>
>>57396605
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?

>https://www.youtube.com/watch?v=yci5FuI1ovk
Like this, but 2D
>>
>>57396622
>>57396618
name the file x.txt, since before it was working as "filename.txt".
>>
File: output.webm (887KB, 1024x790px) Image search: [Google]
output.webm
887KB, 1024x790px
>>57396426
Jelly rocks.
>>57396235
>>57396405
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.
>>
>>57396663
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?
>>
>>57396256
Use Spring Security for this.
>>
File: 1470366437689.jpg (86KB, 600x719px) Image search: [Google]
1470366437689.jpg
86KB, 600x719px
>>57396593
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.
>>
File: output.webm (737KB, 1024x790px) Image search: [Google]
output.webm
737KB, 1024x790px
>>57396698
No more explosions after they become small since the small rocks have no mass.
>>
>>57396663
Forced OOP and the consequent boilerplate it requires are cancer.
>>
>>57396719
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.
>>
>>57395061
I'm also learning c++.
I'm using qt and it's fun.
>>
>>57396598
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
>>
>>57396733
Correct, was just to see what they'd do since anon asked about it.
>>
>>57396730
>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
>>
>>57396778
>color
>unsigned int
waste of memory
>>
>>57396778
RGBA
>>
>>57396778
Everyone uses RGBA
>>
>>57396778
I'd go with RGBA, however don't assume unsigned int is 32bit.
>>57396841
False. Cairo (a popular 2D vector library) uses ARGB for example.
>>
>>57396748
No release can circumvent "public static void main".
>>
>>57396865
>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.
>>
>>57396899
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)
>>
>>57395214
>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.
>>
>>57396919
Vim, IDEA, QtCreator.
>>
File: 2016-10-16_12-36-14.png (139KB, 1280x766px) Image search: [Google]
2016-10-16_12-36-14.png
139KB, 1280x766px
>>57396919
GNU Emacs.
>>
>>57396921
>CamelCase is unfortunately common in C and C++ libraries, but it's objectively wrong.
CameCase is extremely useful to separate types from variable names.
>>
>>57396919
CodeBlocks, just werks and it's lightweight
>>
>>57396935
+1 to codeblocks, also vim if I need to write something on Linux.
>>
>>57396934
Yeah, I forgot about that. CamelCase is okay in C type names (structs, unions, typedefs.) Definitely not in function names, variable names or member names though.
>>
How do i hide the console when running a gui program? Like i dont want it to pop up at all
>>
>>57396955
I'll assume you're on Windows, you need to compile for the GUI subsystem, not the Console subsystem.
Check your build settings.
>>
>>57396955
Conmpile without console.
>>
>>57396921
C does not use snake case in the standard library.
>>
>>57396687
is this a python thing
>>
>>57396993
Yes it does. It's more prominent in C11 (quick_exit, atomic_*, thrd_*) but C89 has jmp_buf and va_*.
>>
Why doesn't the C standard precisely specify how many bytes its types (like int) are supposed to have? Is it supposed to achieve some sort of an architectural independency? Does it really provide that, or is it just some obsolete idea? What's the point?
>>
>>57397039
Oh right, I forgot about the C11 stuff.
For the most part, it uses a very terse naming scheme.
>>
>>57397053
>Is it supposed to achieve some sort of an architectural independency? Does it really provide that, or is it just some obsolete idea? What's the point?
Yes, and yes.

C was invented at a time where everybody was using different, crazy kinds of processors.
Nowadays it seems strange because pretty much everyone's using x86 or ARM, but this allows C to be efficient everywhere.
>>
we lost
Look at my massive !Johnson uses Angular and windows 10 now
>>
>>57397053
>What's the point?
C is old as shit, that's the point.
If you want consistent variable sizes then use the types in stdint.h and typedef them to have reasonable names like u8, s32, etc.
>>
>>57397056
Yeah, I'm looking through the docs now and most names are terse stuff like strtoul. stdarg.h is undeniably snake_case though and there are some upper-snake case macros like RAND_MAX. It definitely seems like most of the snake_case stuff came in with C11. Maybe C++'s influence?
>>
Post some programming related music, preferably something like the Java song

https://www.youtube.com/watch?v=KC8lt--rEEo
>>
File: ohno.png (77KB, 1678x478px) Image search: [Google]
ohno.png
77KB, 1678x478px
>>57397074
proofs
>>
>>57397088
Older C standards were limited in the maximum length of symbols (hence the minified method names). C++ got around this by just saying "implementation-defined mangling" meaning the symbols the linker sees aren't the ones the developer writes, and C11 decided that every modern linker supported longer names anyway.
>>
File: 15983518725.jpg (67KB, 680x1020px) Image search: [Google]
15983518725.jpg
67KB, 680x1020px
How did you guys learn to program?
For long time i have tried to learn the most common languages used for practical programming and it always goes like this
>interest peaks for reasons unknown
>find lots of basic tutorials
>watch them for hours and try writing examples
>realize everything i have learnt so far is impractical
>keep following tutorials
>try writing most basic program on my own and fail
>quit
Have done this like 10 times. Should i just end myself?
>>
>>57397078
>and typedef them to have reasonable names like u8, s32, etc.
Please don't do this.
>>
>>57397132
Yes, you clearly don't have the will to learn a language
>>
>>57397132
Went to uni for CE, being forced to learn really helped me
>>
>>57397133
Nobody in their right mind uses uint32_t over u32. You can search it on GitHub and see that it's a fairly common thing that nearly everybody does.
>>
>>57397132
I just started reading and making magic things without really understanding what was going on. Then I kept going and kept learning.

>watching tutorials
Best way to not learn anything.
>>
>>57397132

same way you learn how to drive, play a guitar, swim, etc : practice
>>
>>57397132
I always feel like i know nothing, when i got my first job i was scared, when i got my first project i was terrified. But when you start working, everything starts to be clear, you + google + stackoverflow = programming.
>>
>>57397053
C is intended as a portable language.
>>
>>57397064
>>57397078
But how was that supposed to help from the programmers point of view back then? If you were writing your code to be independent you'd always had to assume the lower bounds on your types for it to be portable. If you didn't write code with that intention in mind, your code wouldn't be portable anyway.
I just don't see how was that supposed to help portability.

>>57397163
>Nobody in their right mind uses uint32_t over u32
Why is that?
>>
>>57397194
>But how was that supposed to help from the programmers point of view back then? If you were writing your code to be independent you'd always had to assume the lower bounds on your types for it to be portable. If you didn't write code with that intention in mind, your code wouldn't be portable anyway.
>I just don't see how was that supposed to help portability.
That's what C does, it gives you a lower bound for your types, and defines some optional types with exact size (uint*_t) that might not exist on every platform.
>>
>>57397194
>Why is that?
Because it just ends up making things like function parameters silly long.
>>
>>57397194
Because before c99 there weren't any standardized fixed-width type.
>>
>>57397163
I used to define my own types, but I stopped that many, many years ago. Now I use the uint32_t, int16_t, etc. types constantly in my code and been doing so for about 10 years now.
>>
>>57397242
>I used to define my own types, but I stopped that many, many years ago.
Why? Even Linux uses the standard shortened names like s32.
>>
>>57397253
>>I used to define my own types, but I stopped that many, many years ago.
>Why? Even Linux uses the standard shortened names like s32.
And when was that code written?

>>57397224
>Because it just ends up making things like function parameters silly long.

No more than const, struct, unsigned, etc. Want long names? Check out http://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_assist_2502/api_references/!!RECORDS_C_WLAN.gsp
>>
>>57397278
>And when was that code written?
I mean most new code uses the shortened form. You can search stuff on GitHub and see.
>No more than const, struct, unsigned, etc. Want long names?
I guess I just don't see the reason to use the verbose naming that nearly everyone else avoids.
>>
>>57397053
>Is it supposed to achieve some sort of an architectural independency?
Yeah.
>Does it really provide that
To some degree. It depends on the implementer of your compiler and the programmer.

>What's the point?
Say you have a 16 bit system. A 32 bit integer is "long" as in expensive. 16 bit is what you want if you just want an int. On a PC 32 is what you'd want. Going with 16 doesn't make operations faster on most processors. If you need a specific size no matter what, you should go with cstdint.
>>
Where do i learn about modern C++? Currently im reading a generic C++ book but it doesn't touch the latest memes like smart pointers, auto and so on
>>
>>57397253
Because I don't go around redefining and aliasing built-in language keywords and constructs to my own liking, so why would I redefine built-in standard types?

And saying "even Linux uses" is irrelevant. IDGAF what the Linux kernel does. I don't write kernels and I am not Linus and he does not define my code style.
>>
>>57397278
>And when was that code written?
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 19) typedef __signed__ char __s8;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 20) typedef unsigned char __u8;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 21)
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 22) typedef __signed__ short __s16;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 23) typedef unsigned short __u16;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 24)
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 25) typedef __signed__ int __s32;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 26) typedef unsigned int __u32;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 27)
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 28) #ifdef __GNUC__
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 29) __extension__ typedef __signed__ long long __s64;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 30) __extension__ typedef unsigned long long __u64;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 31) #else
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 32) typedef __signed__ long long __s64;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 33) typedef unsigned long long __u64;
8a1ab315 (David Howells 2012-10-04 18:20:15 +0100 34) #endif


;^)
>>
doesn't it also depends on your current skills? your function definition is unsound.
>>
>>57397053
#include <stdint.h>
gives you types like int64_t
if you want control over subbytes, use a union.
>>
>>57397034
No, my codes clearly c++
>>
>>57397357
>so why would I redefine built-in standard types?
Because it makes your code easier to read and you won't have to do stupid BSD-style multi-line function parameters just because you have a few ints in your params.
>And saying "even Linux uses" is irrelevant. IDGAF what the Linux kernel does.
It's just a point to say it's not an inherently bad thing like you were saying. Really your whole point against this it is that it isn't standard which is silly. Everybody uses it so it might as well be standard and it isn't nearly as good of a point as anti-over-verbosity.
>>
>>57397436
>anti-over-verbosity
I feel like I'm already gonna get shit for this.
>>
File: SS_023.png (142KB, 1651x1010px) Image search: [Google]
SS_023.png
142KB, 1651x1010px
How do i fix this blurry shit anons.
Help me vim masters
>>
>>57396135
That's pretty cool, what determines the particle's path?
>>
>>57397534
Get a real font and a non-retarded colorscheme for one
>>
>>57397436
>won't have to do stupid BSD-style multi-line function parameters

I already write my code like this

void mangle_array(uint8_t *ptr,
const size_t len)
{
...
}

int do_something_complex(struct foo *a,
struct bar *b,
const uint32_t c,
const size_t d)
{
}

// and in the C++ land:

bool className::doSomethingComplex(foo &a,
foo &b,
const uint32_t c,
const size_t d)
{
}



so it's not a problem for me. Almost all code I've written in the past decade looks like that.

The hard thing is finding good names; names that aren't too short (like "narg" and "Narg" shit I've seen in some "high-quality" code that took me a long time to figure out that "Narg" means the total number of arguments and "narg" means the current argument) and not too long (see: any Java project ever).

Once you figure out that, writing some uint32_t's isn't a problem.
>>
>>57397549
And 4chan can't handle indentations properly, it seems. But you get the point.
>>
>>57397549
>so it's not a problem for me. Almost all code I've written in the past decade looks like that.
What resolution is your monitor? Whenever I read BSD-styled code I feel like I'm running out of space at 1080p.
>>
>>57397545
i just installed this
https://github.com/skwp/dotfiles
>>
>>57397585
You should make your own dotfiles instead of copying some retard on the interwebs
>>
>>57397590
sure, but this one looked ok, screenshot looked ok too
>>
>>57397436
>>57397549
Oh also, since we were going on about non-standards that everyone uses because they're gr8.
>#pragma once
Love that shit.
>>
>>57397618
Nobody uses #pragma once, what the fuck.
Your codebase must be hell.
>>
so I get that making it complicated and ask for short ,long and double is useful for saving ressources, but what's the point with unsigned? Does it really matter?
>>
>>57397572
Three monitors: one 1280x1024, one 1680x1050 and one 1920x1080. And one 1024x768 CRT (now broken) which is what I was using when I started to use the _t types, actually.

I've never ran out of screen space for code.
>>
>>57397673
>Nobody uses #pragma once, what the fuck.
Anon, you're crazy. I'm sorry.
>>
>>57397703
Oh man enjoy your 1980's codebase, I guess.
>>
>>57397706
C++14 but k.
>>
>>57397703
On my OOP classes we used it in like every .h file
>>
>>57397719
It's not C++14 if you're using non-standard extensions.
>>
>>57397729
k grandpa, can't wait 'till a few years from now when you're avoiding the non-standard modules system after everyone's using it
>>
>>57397779
Modules is a TS, as soon as Clang/GCC implement it I'll use it.

#pragma once is a broken extension that can bite you in the ass later.
Your editor can generate header guards just fine, use it.
>>
>>57397163
>You can search it on *PlebHub and see that it's a fairly common thing that nearly everybody does.
real programmers don't have time for bullshit like *hubs
>>
File: intelligent-rage-feels.jpg (110KB, 601x601px) Image search: [Google]
intelligent-rage-feels.jpg
110KB, 601x601px
how do i return functions as arguments in java? what is a more powerful language than java that i can still use in interviews?
>>
>>57397811
>#pragma once
>broken
Haha no.
It's only broken in the presence of symlinks. Which will most likely break any build system anyway.
>>
>>57397883
Use C++ and return a std::function, which allows you to return any of:
- A function pointer
- A bound function (through std::bind)
- A lambda
- A callable object
>>
>>57397828
More than half of developers reused code from open source projects in a recent project. Code is often reused by copy and pasting classes or packages from open source projects to a developer's own project, but large development companies often have entire systems in place dealing with reusing code
>>
Was the concept of closures intentional?
>>
>>57397908
You're trying really hard to defend a broken by design, nonstandard solution.
Header guards work fine, and their planned replacement is modules. Introducing nonstandard extensions helps nobody.
>>
>>57397908
It's also broken if you have two libraries that each use different versions of the same header only library. Honestly though these situations are nitpicks rare unless you're on a gigantic codebase and I've personally had more issues with just fucking up include guards myself with typos or shitty copypastas.
>>57397945
>You're trying really hard to defend a broken by design, nonstandard solution.
He's somebody else, m8.
>>
>>57397959
>He's somebody else, m8.
Doesn't change my point at all.
>>
>>57397883
First create a class with the function, then create an object of said class. Bam, just pass it around all over the place
>>
Is this a known bug with GHC 7.6.3?
>>
Does IntelliJ come bundled with the JDK and java runtimes, or do i need to install those separately?
>>
What are some good resources for concurrent algorithms?
>>
>>57397994
try
:set -XNoMonomorphismRestriction
>>
>>57398074
Yup, that worked
>>
>>57398115
in GHC8 it's enabled by default I think
>>
>>57397991
i don't see any way to define a property in a class as being a function though. i need to be able to call a function, and use its return value as a function. the only other alternative would be an absolutely massive switch
>>
>>57397883
https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Method.html
>>
>>57398137
is this new with java 8? i dont think i'm using that one currently but i may have to upgrade then
>>
>>57398151
no, as far as i can tell, it's already present in java 1.1.4 (1997)
>>
I'm learning swift for my job and wow, when you get into it it's just so comfy.
I don't think I've ever used a comfier language before.
>>
who /-pedantic/
>>
>>57395123
bold-red :^)
>>
>>57395123
bold_Red
>>
File: wow anon.jpg (78KB, 884x574px) Image search: [Google]
wow anon.jpg
78KB, 884x574px
>>57398286
>not -pendatic-errors
>>
>>57395123
Bold_Red
>>
>>57395123
br
>>
>>57398386
gib moni
>>
>C
>Haskell
>LISP
Are these 3 languages really the only ones that /dpt/ does not look down upon?

>PHP
>Ruby
>Python
>Java
>C++
lmao noob pajeet tier

>Go
>Rust
SJW hipsters
>>
>>57398408
Those 3 languages are easily the best
>>
>>57398408
C++ is god tier, m8. Simple minds just have trouble understanding it.
>>
>>57398423
/dpt/ shits on C++ constantly
>>
>>57398408
>not replacing everything with a simple shell script.
>>
>>57398440
That's just the masses of pajeet java monkeys crying.
>>
>>57398408
>C++
>Pajeet

lol, no, kill urself
>>
pls no racism faggots
>>
>>57398460
Ironic racism isn't racism, nigger.
>>
>>57398408
>C++
>god tier

PICK TWO YOU FUCKING FAGGOT
>>
>>57398493
I thought C++ is improved C, hence plus plus.
>>
>>57398423
>>57398448
>>57398493
stop
>>
File: snap069.png (7KB, 340x140px) Image search: [Google]
snap069.png
7KB, 340x140px
>>57398505
Don't post shit if you don't want to get called out.
>>
>>57398516
who are you replying to
>>
>>57398408
Isn't ruby just python for girls?
>>
>>57398527
who are you quoting
>>
>>57398408
>caring this much about programming languages
How badly unemployed are you?
>>
>>57398532
what did he mean by this
>>
>>57398546
>implying implications
>>
holy shit, why is C so autistic?

why can't you just a=1 and that's motherfucking it?!

why do I need to read 20 chapters about the most autistic ways to declare every little special snowflake identity, size, age, gender and sexuality of a variable?

fuck this shit, I'm back to python
>>
>>57398408
>>57398418
>>57398423
>>57398440
>>57398445
>>57398447
>>57398448
>>57398493
>>57398504
>>57398505
>>57398516
>>57398527
>>57398530
>>57398532
>>57398546
How come I never see /g/ discuss eg. different DBMSs? As if all you were capable of was talking only about college dropout stuff.
>>
>>57398596
That's the "I learned one language and now I hate anything different because I don't understand it" syndrome, also know as being a shit programmer.
>>
>>57398616
Databases are a web development problem.
Just use SQLite to store small scale data, Postgres if you're serious, and Google's cloud DBs if you're petabyte scale.
>>
>>57398596
I'm so sorry that you're not flexible enough to be an engineer.
>>
>>57398408
desu, c is one of the worst pl ever made.
>>
https://turbo.github.io/
>>
>>57398596
Back in the days, programs needed to be very small and efficient. C did a good job, but with today's machines, C's efficience is pretty much obsolete.
>>
>>57398649
>Databases are a web development problem.
haha no
>>
>>57395045

Someone make a program that searches a git repo/directory for bad words

I always get paranoid that I forgot to delete something nasty within a project before I release it (e.g.
printf("nigga\n");
)
>>
>>57398727
just use grep
>>
>>57398695
>Ah snap! There was no error compiling the test kernel or running it, but the numbers don't check out. Please report your browser (+ version) and hardware configuration to us, so we can try to fix this. Deviation was 0.3326696250199651.

JavaScipt quality.
>>
>>57395180
int b
>>
>>57398727
use "ok" "nok" and "test", problem solved
>>
>>57398727
Literally git grep
>>
>>57398408
>Ada, C, Haskell, Ocaml, Common Lisp, Perl
True God-tier.
>>
>>57398740
>>57398753

yeah but I don't want to have to think of every unacceptable word on my own
>>
>>57398408
You forgot
>Java
and
>C#

which are the
>I make hundred thousand dollars a year tier

Which is the only tier that truly matters.
>>
>>57398797
Writting slurs in code is pretty bad tastes in the first place tbqh
>>
>>57398797
Don't use them in the first place.
>>
>>57396921
>>57396934
>>57396953
>thinking camelCase is PascalCase
plens >>>/out/
>>
>>57398649
>web development problem
and a problem for people working with CRMs, GISes, ERPs, in data sciences... even a great issue in automatic control.
>>
>>57398816
/dpt/ would rather be unemployed and using Haskell
than making $100000 with Java (lol pajeet noob tier)
>>
>>57398851
>making $100000 with Java
Is that your dream salary?
Meanwhile, a good senior C++ dev makes $250k+
>>
>>57395045
Bjarne says in his book that using {} to assign values to variables is better, like:

int a{10};
int b = {10};
int c;
c = {10};


I rarely see people doing this. Is there any downside with this way of assigning values?
>>
File: 1427592635037.jpg (82KB, 500x354px) Image search: [Google]
1427592635037.jpg
82KB, 500x354px
>>57398841
>>57398818
>>
>>57398876
The upside is you avoid the most parsing vexe, the downside is if you're not careful you run into accidental std::initializer_lists
>>
>>57398727
Stop it before it's too late. http://www.dailydot.com/society/github-code-search-racism-sexism-bigotry/
>>
File: 1363372055534.jpg (19KB, 399x281px) Image search: [Google]
1363372055534.jpg
19KB, 399x281px
>>57398881
You want to write naughty bad words in your code like a fucking teenager, and then you're too afraid to publish it.
Sounds to me like you're a little bitch.
>>
>>57398912

You're right, i'm a fucking white male
>>
>>57398999
Are you sorry?
>>
>I only take Haskell and C jobs
t. unemployed /dpt/ user
>>
hey /g/
I've been looking at particular examples of C++ over MS dev center and they all seem hell bent on using pointers as parameters to return some value. Why not just use simple "return" to get the object ? What's the point?
>>
>>57399070
Link to the example, maybe.
>>
>>57399070
so you can use the return value to signal an error code, for example
>>
>>57399125
How common is this outside of what Microsoft is doing?

>>57399109
Any of them.

Here's a shortened example though:

HRESULT GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir, IPin **ppPin)
{
....
if (PinDir == PinDirThis)
{
// Found a match. Return the IPin pointer to the caller.
*ppPin = pPin;
pEnum->Release();
return S_OK;
}
....
}
>>
>>57399070
Because in that case the function would always allocate new memory, even if you would want to reuse an existing block.

See also: placement-new.
>>
>>57399155
>Any of them.
Yeah, that's just the stupid MS coding conventions, gotta use a HRESULT and name your pointers pSomething.
>>
>>57399155
>How common is this outside of what Microsoft is doing?

Not uncommon but it's not uncommon either to return a struct or something else, for example you could also use this:
std::pair<bool, Something *> DoSomething()
{
if (failed) {
return {false, nullptr};
}

return {true, something};
}


And so on.
>>
>>57399155
That's COM code. Windows uses it extensively. Don't try to apply COM styles and techniques to anything else, because that path leads to decay and destruction. Just learn to ignore it and don't write COM code unless you have to.

Also, large parts of Windows dates back to 1980's. Things were different back then.
>>
>>57399155
It's very common everywhere if you don't have exceptions. E.g. I use this pattern everyday in C and Objective-C. (Though in Objective-C it is customary to return the error not the result via a pointer)
>>
>>57399006

yes daddy
>>
In python I'm using user input to determine what function to call. The functions themselves take up to 2 arguments so user input might be [function], [function] [arg1] or [function] [arg1] [arg2]. How do I make those two args optional?

so far I have something like this:

 while True:
operation = input()
op, arg1, arg2 = operation.split()
if op in functions:
if 'fun1' in op:
function1(arg1)
elif 'fun2' in op:
function2(arg1, arg2)
>>
>>57399210
Good, now go find some tumblrina with purple hair to donate your money to.
>>
whats the best language for mmorpgs
>>
>>57399216
function2(arg1=None, arg2=None)
or whatever other default value you want. Alternatively you can use *args or *kwargs: http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/
>>
>>57399221
C++
>>
>>57399221
you ain't making one if you have to ask
>>
>>57399244
I should have specified that the problem is in
op, arg1, arg2 = operations.split()


Python is expecting 3 strings yet might only get 1 or 2.
>>
>>57399221
Haskell is considered the de facto language for MMORPG development.
>>
>>57399221
rust
>>
>>57396703
Then again, consider the applications of java vs those of C++.
>>
>>57399282
There are many ways to deal with that, just think through the problem a little. Are you trying to make a command line application? If so, use argparse.

One approach:
cmd = operation.split()
if 'fun1' in cmd[0]:
function1(cmd[1])
elif 'fun2' in cmd[0]:
func2(cmd[1], cmd[2])
>>
>>57399216
Just abstract it bruh.

class Parser(object):
def __init__(self, data):
self.data = data
self.fun = None
self.args = None

self.parse()

def parse(self):
temp = self.data.split()
if not len(temp):
return

self.fun = temp[0]
self.args = temp[1:] if len(temp) > 1 else []

def arg(self, n):
return None if n + 1 > len(self.args) else self.args[n]

p = Parser("function")
print(p.fun)
print(p.args)
print(p.arg(0), p.arg(1))

p = Parser("function arg")
print(p.fun)
print(p.args)
print(p.arg(0), p.arg(1))

p = Parser("function arg1 arg2")
print(p.fun)
print(p.args)
print(p.arg(0), p.arg(1))
>>
What exactly does a build tool do? I always used IDEs before which I guess have that stuff integrated into it, but now I'm developing on linux and everything says to use a build tool.
>>
>>57399405
This is why people shouldn't start with an IDE.

The build tool is the program that tells the compiler what to do to transform your code into an executable.
Common build systems are CMake and Automake
>>
>>57399367
And here's a more practical example with some functions to call:
LUT = {
'sum': lambda x, y: x + y,
'sub': lambda x, y: x - y,
'neg': lambda x: -x,
'print': lambda v: print(*v)
}

class Parser(object):
def __init__(self, data):
self.data = data
self.fun = None
self.args = None

self.parse()

def parse(self):
temp = self.data.split()
if not len(temp):
return

self.fun = temp[0]
self.args = temp[1:] if len(temp) > 1 else []

def arg(self, n):
return None if n + 1 > len(self.args) else self.args[n]

def argi(self, n):
return int(self.arg(n))

def argsi(self):
return [int(arg) for arg in self.args]

p = Parser('sum 5 10')
print(LUT.get(p.fun)(*p.argsi()))

p = Parser('sub 10 5')
print(LUT.get(p.fun)(p.argi(0), p.argi(1)))

p = Parser('neg 10')
print(LUT.get(p.fun)(p.argi(0)))

p = Parser('print hello world')
LUT.get(p.fun)(p.args)
>>
>>57399428
Is that different from just writing a script to compile everything?
>>
>>57399445
Writing a script is essentially making your own very simple build tool.
You can do it, but unless you have a very small project you're going to waste a lot of time.
>>
File: image.png (109KB, 1680x1050px) Image search: [Google]
image.png
109KB, 1680x1050px
>>57395045
>What are you working on, /g/

r/dailyprogrammer #273 intermediate. Exploring the deepest, darkest corners of racket.
>>
As a complete beginner with no programming experience but with a very real interest to learn, is there any basic/beginner advice or steps you would give?
>>
>>57399501
I can't into reddit, how do I list all easy challenges starting from 1?
>>
>>57399435
An impressively overcomplicated solution to the problem. Do you work for the Apache Software Foundation?
>>
>>57399519
https://www.reddit.com/r/dailyprogrammer/wiki/challenges
>>
>>57399361
yeah I realised that' what I had to do, thanks.
>>
>>57399523
No, but I write C++ for a living so I guess that's comparable :^)
>>
>>57399512
Having fun. You won't learn if it's a chore, and you'll never be good if you were forced to do things.
>>
>>57399512
start with assembly and work your way up to haskell
>>
>>57398530
No, for >girls
>>
>>57399536
int main()
{
vector<int> v;
vector<int>::iterator it;

v.push_back(5);
v.push_back(7);
v.push_back(9);

for(it = v.begin(); it < v.end(); it++){
cout<<*it<<endl;

}
cout<<endl;

for(int i = 0; i < v.size(); i++){
cout<<v.at(i)<<endl;

}

return 0;
}


why should i use an iterator?
>>
>>57399643

You shouldn't, because it's 2016.
>>
>>57399643
You shouldn't, use for range loop instead:
for (const auto &value: v) {
cout << value << endl;
}
>>
>>57399672
This
>>
>>57399643
In this case you don't have to since you got contiguous data, but if you have a list you need an iterator. It's all about how the data is allocated under the hood. That's why there's several list-like data structures.
>>
>>57399608
This.
>>
>>57399672
Alright, an enhanced for loop but may i ask why you use the const keyword? Wouldn't that make the reference immutable?
>>
i've been drinking whiskey before doing maths recently, and have to say that the ballmer peak is real
>>
>>57399458
>You can do it, but unless you have a very small project you're going to waste a lot of time.
Not really.
I have given up build tools and just use simple build.bat/build.sh scripts and it has made my life way easier, shit just works, is extremly fast and you have complete control and understanding of every step.
It also has seemed much more convenient for other people because they don't need to download any new build tools and it's way easier to integrate into their own projects.

Fancy build tools are only really needed in extreme cases like multi million loc code bases that neef to conpile for a dozen different platforms - but that is not the norm, so don't overcomplicate the common case which is: windows/linux/mac on x86 and maybe arm.
>>
>>57399710
Yes but you're not modifying it, are you?
Also an actual use for iterator would be when you need to, say, erase elements as you go.
>>
>>57399031
What do you mean? A company saw the Haskell solution to fizzbuzz that I posted to github and immediately hired for a position paying $300k
>>
>>57399725
That's because you have a *small project*.

CMake provides a lot more than your hand-rolled scripts in less lines of code.

Does your script even check timestamps before rebuilding everything?
>>
namespace ExtensionMethods
{
public static class MyExtensions
{
public static int WordCount(this String str)
{
return str.Split(new char[] { ' ', '.', '?' },
StringSplitOptions.RemoveEmptyEntries).Length;
}
}
}


vs

extension String {
func wordCount() -> Int {
return self.components(separatedBy: " ").count
}
}


>Microsoft pajeets
>>
>>57399745
>Does your script even check timestamps before rebuilding everything?
don't even try to take away my coffee breaks, you fucker
>>
>>57399747
They do not do the same though.
>>
>>57395123
How can this even be a debate without knowing the scope of the variables declaration?
>>
>>57399745
>That's because you have a *small project*.
No, this scales up fine to tens or hundreds k line projects.
>CMake provides a lot more than your hand-rolled scripts in less lines of code.
Oh god no, cmake is fucking disgustingly verbose.
>Does your script even check timestamps before rebuilding everything?
No need, shit compiles instantly because I don't do retarded things like spread template aids all over the code base or incorporate braindead libraries like boost.
(As an example, I have customized my own version of glfw and I use a .bat file which recompiles everything on each build and it finishes faster than glfws standard cmake scripts)
>>
>>57399747
They don't do the same.
Also
>optimizing for character count

t. objc/swift deveoper
>>
>>57399576
Thanks anon, I like you
>>
>>57399848
>optimizing for character count
what did he mean by this
>>
>>57397811
>Modules is a TS
Modules are vaporware
>>
>>57398616
Because DBMSs are no fun. Except SQLite, all realtional databases I had to work with, were a major pain in the butt.
>>
Fuck Ubuntu.
I just spent all day tracking down a bug in my program, turns out their shit fucking window manager (unity) sends faked ShapeNotify extensions when applications are iconified/deiconified, even if the application has never altered their window shape. This crashes the application. Hell, it crashes most debug tools as they have no idea about the SHAPE extension until the application quries for it.
>>
>>57399947
don't expect linux to just work
>>
>>57399821
Have you tried using cmake to generate Ninja build files instead of Make/MSBuild?
The problem isn't CMake.
>>
is there a /dpg/ discord?
>inb4 get invited to some gay porn channel
>>
>>57395123
bold::red()
>>
FontFactory.make(new AbstractBoldFactoryBean(), BoldFontFactoryBeanAbstractFactory.RED)
>>
>>57399947
then fuck unity not ubuntu
>>
>>57395123
boldRed of course with C++
>>
>>57400079
>Implying anyone other than Ubuntu uses unity, or that ubuntu doesn't exclusively use unity.
Ubuntu IS unity, unity IS ubuntu.
>>
>>57397132
University and making small programs.
>>
Help with year 1 semester 1 homework (it's C) please:

I have to simulate an ATM in that the program must give the options to: 1. Verify if a PIN is correct or incorrect and 3 other (non-important) things.

Now obviously the program itself is easy to make, BUT i have to error check, (as in print an error message if these are entered) for character inputs (only numbers allowed) and that only 4 digits are entered

I have zero clue how to error check for characters. If I scanf for a number and enter a character I just get an infinite loop. We haven't done strings yet, but I have a hunch the answer lies there.

and for the size of the PIN I just have print an error message if pin is < 0 || > 9999 (which now that I think about doesn't even ensure that 4 digits are entered)
>>
>>57400144
what the fuck are you talking about? I use ubuntu and I don't even have a DE
>>
File: image.jpg.png (268KB, 500x426px) Image search: [Google]
image.jpg.png
268KB, 500x426px
If my ambition is to be a web dev and I'm serious about it, having read (and be reading) numerous books and actively working on projects, should I opt to stay in education or not?
>>
>>57400263
>>>/wdg/
>>
>>57400240
PINs despite their name are better thought of as a string than a number. You don't do math on PINs so there's no reason to store them as integers.

So, instead get 4 characters instead of a number. isdigit will tell you if the character is a digit.
>>
Rate my code?
http://pastebin.com/JqSXrJp5
>>
>>57399221
Erlang
>>
>>57400346
Thanks
>>
>>57400359
not python/10, congratulations, but why use static const chars? make them const members of window and you can change them easier
>>
>>57400538
Because I'm not writing Java?
They would be #defines in older code bases, but I can't stand macros.
>>
>>57400568
All you're doing is hiding variables for no reason
>>
>>57400359
Why don't you just use the default deleter?
>>
>>57400618
Default deleter uses operator delete which deallocates memory from new. I need to use free because xcb uses malloc internally.

>>57400606
They aren't variables. They are static consts. It's just moving them to an identifier to save on typos when I write
strlen("FOO"), "FOOF"
>>
>>57400649
Yes, just use constant members instead
>>
>>57400682
Then they become contractual to users of the class. If they are static they aren't exposed outside the TU.
>>
>>57400240
lol
>>
>>57400701
No they don't, they can be private
>>
>>57396504
Regardless what some /g's say Rust has been a great choice: https://rust-lang.org
>>
>>57400816

Wrong.
>>
Who /sfml/ here?
>>
>>57400824
Well for me at least it does, I guess it doesn't suit yours. I like to recommend it at least, due to how well it teaches to write good C.
>>
>>57400923

Rust has a large number of features that you don't have in C, and the borrow checker is overly aggressive.
>>
>>57400923
I really hate rust, and I think it's incredibly obnoxious to install an extension, then use a bunch of super thread safe magic to have a single global.
>>
>>57400824
>>Rust has been a great choice
>Wrong
Right
>>
>>57400967
Are you referring to the lazy_static library? I can agree that it's quite frustrating, hopefully it's simply a sign of how young rust is and that there needs much more work to be done to make things better.
>>
int main() {
int integer = 1337;
int *pointer = NULL;
pointer = &integer;
printf("Pointer: %d\n", *pointer);
return 0;
}

is this good practice
>>
>>57400998
>>>57400824
>>>Rust has been a great choice
>>Wrong
>Right
Sure
>>
>>57401004
>wasting 8 bytes
>>
>>57400998
>>>Rust has been a great choice
>>Wrong
>Right
Wrong.
>>
>>57400999
Yes. Though it has gotten better with async i/o being in the stdlib now.
>>
>>57401028
>>>>Rust has been a great choice
>>>Wrong
>>Right
>Wrong.
Right
>>
>>57401028
>disagreeing with yourself
>>
>>57401004
You use pointers when you need to, so this example is not good practice
>>
bjarne's book (principles and practice using c++) isn't the best book for beginners at all. I don't know exatly which, but it feels like some explanations are lacking.
>>
>>57401059
But anon, how can he become a five-star programmer without pointers?
>>
>>57401059
i just learn pointers and my questions is more about the NULL thing
>>
>>57401074
I would recommend you never set something to null when a valid initializer exists. If it's C++ use references when you can, failing that use nullptr (not NULL).
>>
new:
>>57401088

>>57401088

>>57401088
>>
>>57401004
Never ever use pointers, references is the way to go
>>
Had to install java again, today.
There's always someone needing help with some java project. Will i never get rid of it?
>>
>>57401074
My rule is if you have a generic allocator, meaning a function that gets called all over the place to allocate a new struct or something, null all the contents of the pointer then send it.
>>
New thread
>>57401138
>>
>>57401045
NUH-UH!
>>
>>57395202
double f(double x) {
if (x <= 0) return 0;
return -inf;
}
>>
>>57396778
use uint32_t or uint_fast32 instead of unsigned int
unsigned int isn't always 32 bits outside of x86
>>
>>57401685
>uint_fast32
Yeah, no. Compilers are actually really bad at optimizing the uint_fast*_t ones. Just using uint32_t will be better.
Thread posts: 360
Thread images: 28


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