[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: 317
Thread images: 32

File: K&R c.png (1MB, 1000x1400px) Image search: [Google]
K&R c.png
1MB, 1000x1400px
old thread: >>62465093

What are you working on, /g/?
>>
File: NOWAY.png (9KB, 633x758px) Image search: [Google]
NOWAY.png
9KB, 633x758px
> tfw virgin JS is gonna die in your lifetime crushed by chad wasm
>>
why the fuck is visual studio so fucking fat

it wanted me to install 40 fucking gigs of bullshit before i said fuck this and just downloaded VS code instead
>>
>>62470608
VS code is just an editor, it has no development toolchain out of the box.

Even on linux, installing only the GNU coreutils and the GCC toolchain is close to 600MB for lots of stuff you'll never use.
>>
>>62470608
use VC6 instead
neat and comfy before they added 2 decades of bloat
>>
>>62470625
>600MB
awful
>>
>>62470608
Lad, everything Microsoft makes is fucking bloatware. Have you ever seen Word? It's full of so much useless shit, it's not even funny
>>
I want to learn Rust but I've heard that it's an SJW language. Should I bite the bullet?
>>
Reading ACPI tables and working on the PCI subsystem for my arm64 server based OS.
>>
>>62470647
Learn Hasklel.
>>
>>62470647
everyone should give it a try and form their own opinion.
>>
>>62470647
How does this meme keep proliferating on this board? Nobody uses Rust. It's like the 40th most used language, extremely low on the list
>>
>>62470647
In order to write anything of value in Rust you need to disable the memory borrower using unsafe blocks, defeating the whole point of static memory correctness.
>>
>>62470608
VS is not fat it is just thicc
>>
File: 1503937708014.jpg (1MB, 500x2855px) Image search: [Google]
1503937708014.jpg
1MB, 500x2855px
>>62470536
Read a proper book you worthless hack.
>>
>>62470659
>asking brainlets to for their own opinion
Spotted the brainlet
>>
>>62470703
>can't even quote me properly
hello pajeet
>>
>>62470721
>t. self hating pajeet
>>
>>62470733
If i was a pajeet, I would have killed myself by now, lad.
>>
>>62470675

Honestly, with the exception of some library code, you probably won't need much in the way of unsafe blocks in Rust.
>>
>>62470746
Translated:
>I keep a catalog of my katana and kimono collection on my Linux computer
>>
>>62470777
jokes on both of us, my main computer is wangblows 8.1
I like OpenBSD and Debian though.
>>
>>62470792
>windows 8.1
Jesus lad, why? Don't get me wrong, 10 is a piece of shit also, but it's slightly better than 8.1
>>
File: 1504989094287.jpg (54KB, 480x661px) Image search: [Google]
1504989094287.jpg
54KB, 480x661px
>>62465584
Literally landed a job like that a month ago. I'm working on software for scientific data analysis, i have no degree(got kicked off uni last semester) or professional experience, it's a desktop aplication in C++ so no web shit, the gui is super basic so there's not much work on that. The pay isn't too high cause I'm a junior but it's not bad, I can even save up a good amount every month.

>tfw just three months ago i was standing on a bridge contemplating suicide after failing college and now i'm living the dream

Don't lose hope friend.
>>
>>62470904
Why'd you get kicked out of university?
>>
>>62470550
does your friend live in australia?
>>
>>62470608
You selected Xamarin, didn't you?

That includes multiple Java and Android SDKs, as well as Android VMs.
>>
>>62470871
>but it's slightly better than 8.1
I disagree, installed it to try Gigantic way back and I hated every second of it.
Way too much bloat, idled hotter and with more resources, and felt clunky.
8.1 is pretty much perfect to me, though I still long for the day i can completely switch to a Linex or BSD.

Keep in mind 8 and 8.1 are basically two different OS's with how much things changed.
And
>>
>>62470687
C is first and assembly is second to last? How silly
>>
>>62470914
10 has less OS overhead than 8.1...
>>
File: dpt.jpg (34KB, 292x452px) Image search: [Google]
dpt.jpg
34KB, 292x452px
>>62470536
>>
>>62470904
Failed one class twice. It was my fault cause I didn't study enough, but in my defense the class was hard and I was already dealing with depressions and anxiety from all the tests the school threw at me (one of the top schools in the country). Work is much more comfy, as soon as I started working the depression almost completely faded and I no longer have anxiety attacks. Maybe school just wasn't for me.
>>
>>62470955
i meant to reply to you: >>62470907
>>
>>62470934
proof?
I may have been remembering wrong but i do remember even post-patching, it felt generally slower.
>>
>>62470955
what school?
>>
>>62470971
>felt
>>
File: felt.png (2MB, 1920x1080px) Image search: [Google]
felt.png
2MB, 1920x1080px
>>62470955
>>62470992
>>
File: dpt-poster.jpg (517KB, 1521x1076px) Image search: [Google]
dpt-poster.jpg
517KB, 1521x1076px
>>62470997
>>
Whats the best online college for getting a Bachelor's degree in CS for programming? What school offers more than just java?
>>
>>62470536
Learning how to automate my tinder matching so it only swiping right if their height and weight match the ratio I set for my own.

aprox 6foot 1.222 inches

aprox 210 lb

Fucking mobile is abysmal though this was a bad project idea
>>
>>62471024
oregon state
>>
I'm trying to use Mongoose/Jquery/Node, but my PUT method is never being called.

  $('form').on('submit', function(){

var item = $('form input');
var todo = {item: item.val()};

$.ajax({
type: 'PUT',
url: '/todo/' + id,
data: todo,
success: function(data){
location.reload();
}
});

return false;

});


for the method

app.put('/todo/:id', urlencodedParser, function(req, res) {
console.log("It reaches!");
Todo.findByIdAndUpdate(req.params.id,
{ "$push": { "item": req.body } },
function (err, data) {
if (err) throw err;
}
);
});
>>
I could never understand std::array properly. For example I have this struct and enum class
  struct type {
public:
std::string monName;
char monSymbol;
int monHealth, monDamage, monGold;
type(std::string nm, char sym, int h, int d, int g)
: monName{nm}, monSymbol{sym}, monHealth{h}, monDamage{d}, monGold{g} {}
};

This legacy style array works
type monsters[size_t(Type::MAX_TYPES)]{{"dragon", 'D', 20, 4, 100},
{"orc", 'o', 4, 2, 25},
{"slime", 's', 1, 1, 10}};


However std::array complains that it's missing braces:

  std::array<type, size_t(Type::MAX_TYPES)> monsters2{
type{"dragon", 'D', 20, 4, 100}, type{"orc", 'o', 4, 2, 25},
type{"slime", 's', 1, 1, 10}};
>>
>>62470921
>assembly is second last
You're a fucking idiot.
>>
>>62471102
Forgot the enum class
enum class Type { DRAGON, ORC, SLIME, MAX_TYPES };
>>
>>62471102
>Sepples was a fucking mistake
>- Balding Danish Gnome
>>
>>62471102
maybe you need an extra set of braces? like
monsters2{ { ... } }

you could also try

monsters2{ std::initializer_list<type> {...} }
>>
>>62471160
lamo
that actually was the reason. Silly me
  std::array<type, size_t(Type::MAX_TYPES)> monsters2{{
type{"dragon", 'D', 20, 4, 100}, type{"orc", 'o', 4, 2, 25},
type{"slime", 's', 1, 1, 10}}};
>>
>>62471180
*silly sepples
>>
Python was a bad idea
>>
Nim is a good idea
>>
>>62471227
If by good you mean bad and by idea you mean even worse
>>
>>62471227
Nim
Is a
Mistake
>>
>>62471240
awful
try again
>>
>>62471102
>>62471180
Meanwhile, in a sane language:
struct type {
const char *name;
char symbol;
int health;
int damage;
int gold;
};

enum {
DRAGON,
ORC,
SLIME,
MAX_TYPES,
};

struct type monsters[MAX_TYPES] = {
[DRAGON] = {
.name = "dragon",
.symbol = 'D',
.health = 20,
.damage = 4,
.gold = 100,
},
[ORC] = {
.name = "orc",
.symbol = 'o',
.health = 4,
.damage = 2,
.gold = 25,
},
[SLIME] = {
.name = "slime",
.symbol = 's',
.health = 1,
.damage = 1,
.gold = 10,
},
};
>>
>>62471046
>oregon state

Why?
>>
>>62471309
Do you even try?
  enum class Type { DRAGON, ORC, SLIME, MAX_TYPES };
struct type {
std::string monName;
char monSymbol;
int monHealth, monDamage, monGold;

type(std::string nm, char sym, int h, int d, int g)
: monName{nm}, monSymbol{sym}, monHealth{h}, monDamage{d}, monGold{g} {}
};


std::array<type, size_t(Type::MAX_TYPES)> monsters2{
{type{"dragon", 'D', 20, 4, 100}, type{"orc", 'o', 4, 2, 25},
type{"slime", 's', 1, 1, 10}}};
>>
>>62471352
>Completely dependent of struct member ordering
>Completely dependent on enum ordering
>No correspondence for what each initialiser is actually for; you just need to remember ir
>Syntactically looks like shit
0/10, try harder next time.
>>
>>62471378
>Completely dependent of struct member ordering
Yes, this avoids confusion
>Completely dependent on enum ordering
As it should be. Literally.
>No correspondence for what each initialiser is actually for
Ordering
>>
What is /g/'s opinion on Rust? It seems like a really nice language and a lot of projects are transitioning to it like Gtk and Tor.
>>
>>62471412
How the fuck are you justifying that reliance on ordering is better?
What happens in the extremely likely situation where you want to change the definition of "type"?
>>
>>62471431
it's dead
>>
>>62471438
How so?
>>
>>62471435
honestly if you're trying to write a robust RPG engine, you won't hardcode any of the NPC types and you'll import them during runtime in some kind of XML or JSON format.
How would you handle DLC, for example?
>>
File: 1458503550803.gif (2MB, 600x540px) Image search: [Google]
1458503550803.gif
2MB, 600x540px
12/18 chapter finished
Can't wait to start on the Qt book

>>62471431
Rust kinda lacks in GUI tools. Which is why I moved to C++ (Qt Quick) for my big project.

>>62471435
>change the definition of "type"?
By changing the definition do you mean constructor overloading?

> reliance on ordering is better?
Yes, I can easily loop through the members and manipulate them if need be

I'm not really good at OOP tho
>>
>>62471474
>By changing the definition do you mean constructor overloading?
I mean adding more members or just changing ANYTHING.
>Yes, I can easily loop through the members and manipulate them if need be
You can easily loop through mine too. You're just not restricted to declare things in an exact order.
>>
File: 642102_4e20_2.jpg (26KB, 750x422px) Image search: [Google]
642102_4e20_2.jpg
26KB, 750x422px
How does everybody here feel about the Go language?
>>
File: 1465542231484.jpg (159KB, 454x558px) Image search: [Google]
1465542231484.jpg
159KB, 454x558px
>>62471474
that's awful logic but i forgive you since you posted an akarin gif
>>
>>62471309
>>62471352
hello lads
struct Monster
{
string name;
char symbol;
int health;
int damage;
int gold;
};

struct Dragon { alias this Monster; }
struct Orc { alias this Monster; }
struct Slime { alias this Monster; }

void main()
{
auto dragon = new Monster;
dragon.name = "dragon";
dragon.symbol = 'd';
dragon.health = 20;
dragon.damage = 4;
dragon.gold = 100;

auto orc = new Monster;
orc.name = "orc";
orc.symbol = 'o';
orc.health = 4;
orc.damage = 2;
orc.gold = 25;

auto slime = new Monster;
slime.name = "slime";
slime.symbol = 's';
slime.health = 1;
slime.damage = 1;
slime.gold = 10;
};
>>
>>62471527
That's fucking retarded.
>>
File: 15822597.jpg (5KB, 370x334px) Image search: [Google]
15822597.jpg
5KB, 370x334px
>>62471527
Where is your lookup table?
>>
>>62471550
don't need one
>>62471537
i could do it a few other ways.
>>
>>62471502
But anon, if I am going to change the type definition, this is all enclosed within a class, I'll just update the base class, which will allow the properties to be inherited in deriv classes
>>
>>62471351
nevermind, the oregon state online comp sci program is only for those who already have a 4-year bachelor's degree
>>
>>62471527
wew, im a fucking idiot.
should be
struct Monster
{
string name;
char symbol;
int health;
int damage;
int gold;
};

struct Dragon { Monster m; alias m this; }
struct Orc { Monster m; alias m this ;}
struct Slime { Monster m; alias m this; }

void main()
{
auto dragon = new Dragon;
dragon.name = "dragon";
dragon.symbol = 'd';
dragon.health = 20;
dragon.damage = 4;
dragon.gold = 100;

auto orc = new Orc;
orc.name = "orc";
orc.symbol = 'o';
orc.health = 4;
orc.damage = 2;
orc.gold = 25;

auto slime = new Slime;
slime.name = "slime";
slime.symbol = 's';
slime.health = 1;
slime.damage = 1;
slime.gold = 10;
};
>>
>>62471666
enumerate?
>>
What is the purpose of the enum in the monster example?
Why not use a const string& or const string*?
You can just compare the pointers.

If you have an enum, why have a lookup table at all?
You're just limiting dynamic data with static info
>>
File: 1505619774182.jpg (7KB, 370x334px) Image search: [Google]
1505619774182.jpg
7KB, 370x334px
>>62471655
Where is you lookup table?
>>
>>62471747
i don't need one lad, i just told you.
lookup tables are shit in this context.
>>
ive been doing the microsoft dev c# thing for so long now that im starting to feel emotionally attracted to bob
>>
#ifdef _WIN32
size_t arr[90000;
#endif
>>
>>62471958
you forgot something
>>
>>62471958
Patrician choice
>>
What's the most verbose and tedious language that's not sepples,rust or java?
>>
>>62472015
C#
>>
>>62472024
He said not Java
>>
File: score.png (16KB, 921x282px) Image search: [Google]
score.png
16KB, 921x282px
fug
>>
File: akari93.jpg (615KB, 2188x2860px) Image search: [Google]
akari93.jpg
615KB, 2188x2860px
>>62471958
I'll do you one better.

#ifdef _WIN32
int main[-1u] = { 1 };
#endif
>>
>>62472056
I miss being a uni-fag. Damn.

I should have picked Software Engineering, easy degree. Would totally BTFO all the units.
But alas I picked Telecom Engineering.
Then I had a gf
Then we broke up
Then I lost my motivation
Then I dropped out

But at least it allows me to dig deep into programming. I'd still love to go to a community college and do some competitive studies. Competition is very important.

But between my night time job and hobo tier life, I can't make up my mind
>>
>D fags never came up with any code, much less an "elegant implementation"
LOL

>>62470675
unsafe blocks don't disable the borrow checker, brainlet.
>>
>>62472128
You know what they say, only brainlets call others brainlets
>>
File: lain-bash-omaru.gif (17KB, 500x400px) Image search: [Google]
lain-bash-omaru.gif
17KB, 500x400px
>>62472134
Damn, you caught me
>>
Should I use intrusive or non-intrusive lists? Cache performance and low latency lookups are important
>>
I was writing some python to detect whistling frequencies earlier today. Once I get better alsa lib I might do it live on the mic. The idea is to use whistling as an input, send the results of some command off to a raspi + stepper attached to my deadbolt, and unlock the door by whistling into a bluetooth headset or somesuch.

The end game is a simple way to drive a computer if my hands are busy. Like voice recognition, but skipping the AI part.

Have a different project to simplify certain laser cutter pattern design tasks with a pygobject getup. Coming along decently enough.
>>
>>62472209
Why on earth wouldn't you use intrusive lists if you can?
>Cache performance and low latency lookups are important
Then a list probably isn't the appropriate structure.
>>
>>62472225
Fug I don't know. It's my first time using Boost libraries and I wasn't sure. I need more documentation to read

I got inspiration to use a list from here

https://quant.stackexchange.com/questions/1379/implementing-data-structures-in-a-limit-order-book
>>
File: 1441684460338.jpg (92KB, 1280x720px) Image search: [Google]
1441684460338.jpg
92KB, 1280x720px
>>62472277
>Sepples
>Boost
Jesus christ.
>>
>>62472307
No bully anon what would you use that is just as fast
>>
>>62472324
Use C; roll your own.
There is no reason to use Sepples or libraries that add even more bloat for any purpose.
>>
>>62472307
>pic
s2 when
>>
Is there a fast way to sort an array of strings? Or do I need I need to bubblesort this
>>
>>62472357
Fair enough. That was my first instinct but I wanted experience using C++/STL/Boost [spoiler]for employment purposes[/spoiler]
>>
>>62472387
just qsort that shit
>>
>Rust is dead
Why do Cfags actually believe this? Especially since a lot of projects are moving to Rust such as Tor and GTK.
https://siliconislandblog.wordpress.com/2016/10/31/thoughts-on-dx-gnome-and-rust/
https://wiki.gnome.org/Hackfests/Rust2017-2
https://wiki.gnome.org/Hackfests/Rust2017
>>
>>62472056
what was the test over

i got raped by exams and always thought i was a brainlet, until i graduated and realized my school was just insane
>>
>>62472387
Never use bubble, insertion or selection sort.
>>
>>62472447
Noob's python.
>>
>>62472448
>insertion
Actually, insertion sorts is good for small and almost-sorted arrays.
>>
I made a wrapper to stream crunchyroll hd, no ads, with no premium account, and it streams to mpv.

Aditionally it remembers where the episode you where watching, you can search episode by number or just use next to see the next one, all from the terminal

powered by python

who wants me to share it ? :D
>>
>>62472548
Just torrent, fag.
>>
>>62472548
>streaming
>>
File: 1460488711043.jpg (24KB, 471x449px) Image search: [Google]
1460488711043.jpg
24KB, 471x449px
>>62471024
also wondering this
>>
>>62472556
>>62472562

Don't make me sick, why would I want to go and open a browser look for the anime I want look for quality I'm looking for + subtitles, remember the last chapter I was watching, remember the state on my player.

with my script I do it like this

animewatcher 'one piece or ane anime' 781

>plays one piece HD, with subs in eng, spa, portuguese.

wanna see next episode?

animewatcher next

wanna play from where you left?

animewatcher play

wanna see what animes are you watching and pick one to autoplay?

animewatcher

completely superior to torrenting
>>
>>62472556
why would he if he has 0 ads anyway?
>>
>>62472609
reported for that eye-cancerous spacing
>>
Can you learn to program without going through textbooks and just use them for reference? I've tried going through texbooks for concepts but I loss attention and switch between books I get no where. Maybe I should say away from text as far as possible and just solve my own problems...I mean how did great programmers learn to program when all these texts/resources didn't exist?
>>
>>62472625
It's called reddit spacing.
>>
>>62472741
textbooks are by far the worst way to learn programming
jump into a beginner tutorial for your language of choice which gives 2 paragraphs tops for each topic, followed by examples of use
then, take what you've learned and write a little program that uses it
>>
>>62472741
I've read some text books later, but I never read them when I started. The best way to learn programming is by doing it - its like driving a bike in that sense. Grab some beginner language tutorial and give it ago, and once you've got the most important bits down, try making your own programs and searching the internet any time a problem you can't solve comes up or you think something could be done much more efficiently.
>>
>>62472857
http://www.learncpp.com/
something like this?

I used this way back when I started and learned so much in a month before picking up a textbook because of school,I think I only over complicated things with textbooks.
>>
is there a C version of Python's "struct" library?
>>
How do you guys go about reading programming books?
I've got a copy of C++ Primer sitting next to me, but I don't have the attention span to just read it for more than a few minutes at a time.
>>
>>62473013
Just memcpy some shit around.
>>
>>62473134
I read most of that book while on the bus to work. Tbh I don't think I ever gained much out of it.
>>
>>62473325
What books have you read that you got a lot out of?
>>
File: tumblr_mya5xy0IY11qzxvd3o2_1280.png (211KB, 829x456px) Image search: [Google]
tumblr_mya5xy0IY11qzxvd3o2_1280.png
211KB, 829x456px
why do people still learn java if c# is just better
>>
>>62473341
None when it comes to general programming or langauges, that's the only book I've ever read in that department at all. I've read some more specific programming-related works like Real-Time Collision Detection which were actually useful though.
>>
>>62473363
Not everyone is into bondage to Microsoft.
>>
File: 1477256692698.png (177KB, 1746x928px) Image search: [Google]
1477256692698.png
177KB, 1746x928px
>>62470536
Making a falling sand game clone.
>>
>>62473536
Make sure to use comonads!
>>
>>62470672
it's safe and fast
obviously nobody is using it yet because it's a new language
>>
>>62473608
>fast
how did this get parroted around so much, rust is slow for a systems.
>>
>>62473636
How isn't it fast? Ripgrep is much faster than silver surfer.
>>
>>62473608
>new
It's been around since 2010... Go has been around since 2009 and has way more people using it.
>>
>>62473721
Go 1.0 was released in 2012.
Rust 1.0 was released in 2015.
It doesn't make sense comparing language popularities pre-1.0 releases, as nobody is gonna use an unstable language.
>>
is there anyone here who would be willing to code for a stranger over the internet?i would pay but not a lot

its a hard project for me because im shit at it and dont have enough time, but its actually a small project. basically i want a demo showcasing what a particular java library can do, you would pick some small, well documented tutorials and demos from the internet and stick them together. you would need to know java and javascript.

[email protected]
>>
>>62472609
I actually use double space format for a majortity of my posts

I believe its easier on the eyes and works as a form of punctuation in a digital conversation. Its both a period and a new paragraph start in one.

But you have taken it too far. Single space with green text like :

Wanna see next episode?:
>aniewatcher next
Wanna play from where you left?
>>
File: 1500361643643.png (29KB, 571x618px) Image search: [Google]
1500361643643.png
29KB, 571x618px
>>62472609
>>
>>62473898
>>>/r9k/
>>
Perl is better than python
FTP is a good protocol
C is better than C++ and Rust
Init systems should use shell scripts
>>
>>62470625
>600mb vs 40gb
anon..
>>
>>62470644
I bet that Doom Easter Egg is still in Microsoft Excel's source code
>>
>>62473363
why do people still learn C if C++ is just better
>>
>>62474326
why do people still learn C++ if Haskell is just better
>>
>>62474326
>name mangling
>unstable ABI
>cluster fuck syntax
>constantly changing standard
>the other people that program in sepples
>>
>>62473636
Pajeet please, we've been over this. You gotta back your claims with evidence.

https://sites.google.com/view/energy-efficiency-languages/results
>>
>>62474399
>constantly changing standard

Every 3 years, Anon.
>>
>>62474471
>pascal beating out everyone in pi
>fucking typescript in regex
pretty weird, but that's pretty surprising desu
>>
i can program, but i really want to learn style and making code that not only works but is good as far as engineering and good practices if you know what i mean

what are some books
is clean code good?
>>
>>62474811
The Practice of Programming by Brian Kernighan and Rob Pike.
>>
Can anyone tell me a program that parses c++ code and outputs a relation tree between the classes?
>>
>>62474924
doxygen maybe?
>>
I'm studying cs and I'm being taught C at the moment but I was told that I can write my assignments in C++ if I want to. Is there a real reason why I would learn C instead of C++? I suppose I'm not gonna be a system programmer when I graduate but the closer to metal I am the better I suppose. On the other hand, C++ is just an extension of C as far as I know so I don't really see a point in learning C thought the idea of writing my own compiler is really tempting. I'm currently half way through Teach Yourself C in 24 Hours.
>>
>>62474997
C is better for learning because of its simplicity. C++ is such a large and complicated language that, even though it may partially be an extension of C, modern C++ doesn't look at all like C and two developers might struggle to understand each others' C++.
Just stick with C, for your studies at the very least.
>>
>>62474997
C++ is a horrible language that will rot your brain. It's twice as bad as things like krokodil.
>C++ is just an extension of C as far as I know
This is not a correct way to think about it. C and C++ are completely different languages.
>>
>>62472741
Iv come to the conclusion that learning a programming language with textbooks is a fruitless pursuit as learning a spoken language through textbooks,its so far removed from from reality and limited in learning your better off just thinking about programming something and string stuff together as much possible to it to work.
>>
>>62475031
1. learning a proglang with book is good
2. learning a real lang with book is even better
3. it's only removed from reality if you can't read
4. learning a real language is very much different than learning a proglang

sucker
>>
>>62470608
>why the fuck is visual studio so fucking fat
a lot of awesomeness takes up a lot of space
>>
>>62474326
C++ is not always necessary

when you go "proper C++" it can actually hurt speed quite a bit
>>
depression made me a brainlet
>>
>>62475159
it's known to do that

meditate every day to reverse the damage in the same brain areas, scientifically proven to work
>>
>>62475159
>intelligence can change
you were always a brainlet
>>
>>62475108
I'm disregard this whole post as it sounds like its full of shit.
>>
hello world
>>
>>62475158
>"proper C++"
>""""""""""""""proper C++""""""""""""""
whatever that means
oh right, it means nothing
>>
>>62475369
yea thats why i speak 4 languages and can program and that's just my dabbling in hobbies
>>
>>62475453
>4 languages

US English, UK English, AU English and Colonial English?
>>
How do I SOCK_STREAM and SOCK_DGRAM?

Currently I have a server that does:
>socket()
>bind()
>listen()
>accept()
>read(), write()
and client:
>socket()
>connect()
>read(), write()
Server socket type is set to SOCK_STREAM. Is this the correct way of communicating with streams? How do I datagram?
>>
>>62475471
yes

>How do I datagram?
server: socket() -> bind() -> recvfrom()
client: socket() -> sendto()
I think
>>
>>62475442
>"C++"
>"""""""""""""""""""C++""""""""""""""""
Whatever that means.
>>
File: 1490946421480.gif (3MB, 250x255px) Image search: [Google]
1490946421480.gif
3MB, 250x255px
>>62475108
>2. learning a real lang with book is even better
>>
>>62475533
Thanks.
How do I handle multiple clients now? With streams I used select() with fd_set being populated by accept(). How do I know where to recvfrom?
>>
>>62475585
dumb drillhaired bitch
>>
File: 1501859166766.jpg (16KB, 348x342px) Image search: [Google]
1501859166766.jpg
16KB, 348x342px
>just used a ctype.h function
>didn't include it
>tfw it worked
N-NANI?
>>
>>62470606
Chad actually moves back up the tree of abstraction once he learned Assembly.
Never noticed how a lot of reverse engineers and hackers write Python even though they obviously know ASM?
>>
>>62475599
You recvfrom() on the socket you called bind() on
UDP is connectionless, the only indication of the source of the packet comes from the fields of the sockaddr_in (or sockaddr_in6) structure you pass to the recvfrom() call
>>
>>62475614
it's part of the standard library so the functions are linked to your program. The header only tells you that there exists function with prototype. Compiler should give you a warning or maybe even error though.
>>
>>62475614
The object your .c file gets compiled to has some field that says it requires that function from the standard library you eventually link to
Function calls themselves all (kinda) follow the same semantics (depending on the ABI) so it doesn't depend on type information at all
>>
>>62475599
gethostbyaddr()
>>
>>62475585
it's where you ALWAYS start to get the fundamental baisics - building blocks
alphabet, grammar, sounds, pronouns, some common nouns
when you have those - use media to get used to the sound of the language and start writing, and then talking to someone

if you don't start with the basics it takes so much longer and you end up with a shallow understanding of the language at best
or you end up speaking in phrases at worst

if i wanted to i could really learn japanese in less than a year, but im not an animefaggot like you
>>
>>62475442
>>62475555
It means having a pathological fear of C arrays and plain structs.
It means writing code that's a challenge to the optimizer.
It means having bloated classes overwhelming CPU cache.

Proper C++ means many bad things, brainlet.
>>
>>62475614
The other anons explained why the linking worked, but in terms of why ctype functions in particular worked without issues is a bit of a coincidence related to old legacy cruft.
In C89 and pre-standard C, if the compiler didn't know about a function, it would basically assume everything was an int and went through the default argument promotions. It's invalid these days, but compilers still accept it (with warnings), so they can facilitate old code.
The ctype functions happen to return ints and take ints, so it worked out.
>>
>>62475633
Can I do similar thin with streams?
Like somehow get client's sockaddr_in from fd or something?
>>
>>62475729
thing*
>>
>>62475729
getpeername()
http://man7.org/linux/man-pages/man2/socket.2.html
look at the "SEE ALSO" part of this page
>>
>>62475702
Does std::array even have slices?
>>
>>62475754
And client needs to bind before connecting, yes?
>>
File: 1502482697123.png (711KB, 1600x2162px) Image search: [Google]
1502482697123.png
711KB, 1600x2162px
>>62475687
>if i wanted to i could really learn japanese in less than a year
>He thinks everyone wants to learn some useless eastern moonrunes

I learned Dutch and then English.
Dutch without any textbooks, I became fluent relatively fast, compared to english in which I still can't express myself correctly despite following a textbooks.
Half the vocabulary is same as French, and the sentence structure is very similar to Dutch. That's the only thing that helped me in English (and memes).
>>
https://twitter.com/oshepherd/status/909154205608431617

C is such a magical language.
>>
>>62472421
>https://twitter.com/oshepherd/status/909154205608431617
It's just a /g/ meme
>>
>>62475860
That's not really surprising. Plus that is only valid in C99 and not valid in C89/90 and C11.
>>
>>62475860
Why though
>>
>>62475932
It's still valid in C11.

>>62475860
>>62475947
That's a quirk of VLAs.
>>
>>62472421
No one cares about Rust, all the excitement is about C++17.
>>
>>62475948
Just another reason that arrays in parameter declarations should be banned, I suppose.
>>
File: ignore_sepples.jpg (77KB, 677x463px) Image search: [Google]
ignore_sepples.jpg
77KB, 677x463px
Threadly reminder.
>>
>>62475957
All C++17 adds is shit Rust does better
>>
>>62475948
Kind of, since C11 makes VLA optional and not a requirement like in C99.
>>
>>62475976
Try to do generic programming in Rust. Rust is a joke.
>>
>>62475891
>[they/them]
kys
>>
>>62476005
Rust's generics are fine though.
>>
>>62475963
It's just C being consistent with its own rules. It's benign, and something you'll say "oh, that's interesting" and probably forget about.
The array syntax in function declarations does sort of have its own benefits:
void fn(size_t n, int arr[static n]) {
// ...
}

will specify that 'arr' is non-null and will point to at least 'n' elements. Unfortunately compilers don't really make use of this (I think clang does the non-null thing), but it is more self-documenting.

>>62475993
Realistically, unless you're doing some embedded shit with some crappy proprietary compiler, you have VLAs available to you.
It's was fully expected that VLAs would be widely supported, as compilers were coming off of C99. It's just there as a concession to those who were complaining.
>>
>>62476005
>Sepplesfag
>Doesn't even have traits
Those grapes sure are sour, aren't they?

inb4 m-muh C++xyz+3
>>
>>62476041
I don't believe Rust has VLA static arrays, which is interesting.
>>
File: 1482074514476.jpg (63KB, 1021x356px) Image search: [Google]
1482074514476.jpg
63KB, 1021x356px
>>62470536
I want to impregnate Hime.
>>
>>62475860
Why can you even declare VLAs in function arguments?
>>
File: perpetual-thinking.gif (617KB, 498x498px) Image search: [Google]
perpetual-thinking.gif
617KB, 498x498px
So why doesn't your favorite language have decent metaprogramming facilities, /g/? Are you stupid or do you just like working much harder than necessary?
>>
How do I set the Attribute Section of an ELF file?

Like so (readelf output):
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "Cortex-M4"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv4-D16
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_enum_size: small
Tag_ABI_HardFP_use: SP only
Tag_ABI_optimization_goals: Aggressive Size
Tag_CPU_unaligned_access: v6
>>
>>62476076
Because it's actually useful.
void fn(size_t w, size_t h, int arr[w][h]);

This is a function which takes a true 2D array.
>>
>>62476077
But mine does.
>>
>>62476077
It does, but I don't really need them since it has a powerful type system
>>
>>62476122
>I don't really need them since it has a powerful type system
Why do Haskell weenies think their type system is in any way, shape or form a replacement for metaprogramming?
>>
>>62476154
Metaprogramming is a language crutch
>>
>>62476154
Haskell has metaprogramming too though.
>>
how do I learn Idris
>>
>>62476178
>Metaprogramming is a language crutch
That's a cute baseless assertion you're pulling straight out of your ass.
>>
>>62476116
Are you sure it isn't a function which takes a pointer to a 1d array?
>>
>>62476191
buy m- the book
>>
>>62476183
>Haskell has metaprogramming too though
If you're talking about rewrite rules, that's not even a Haskell feature. It's a GHC feature, and it compares unfavorably to proper metaprogramming systems in my opinion, but sure, it's something.
>>
>>62476207
>pointer to a 1d array
Yes, that's what it technically is, due to array arguments silently being pointers instead.
However, it's a pointer to a VLA, and it will work just fine like a 2D array, just like you would expect.
>>
File: JUST.jpg (27KB, 600x424px) Image search: [Google]
JUST.jpg
27KB, 600x424px
>tfw preparing for the OCP
>>
>>62476034
Better if it had FUCKING HKTS
>>
>>62476041
Trying to document what your function does in its signature is foolish in C. Remember that char* could mean about 8 different things.
Types don't help in C, especially not when your declarations lie about the typed they specify.
>>
>>62476239
Not a Rust shill, but hasn't the RFC for HKTs been approved recently?
>>
>>62476233
That's interesting and useful.
>>
>>62476205
How is it? You metaprogram because your language isn't good enough to do the same normally.
>>
>>62476252
It's not about documentation, but compiler optimization.
>>
>>62476178
inb4 freeing lisplets
>>
>>62476034
Are rust generics template based or pointer based?
i.e. does F<A> have the same representation regardless of A?
>>
>>62476284
Which compilers do what optimizations with this?
>>
>>62476273
>to do the same normally
You mean to do metaprogramming without doing metaprogramming? Or are you so dense and unimaginative that you can't think of any scenario where generating code instead of writing it all manually is beneficial?
>>
>>62476252
>Documentation can't be perfect, so we shouldn't bother at all
So are you proposing that we remove types and just have "words" like in B?

>>62476284
That's what it was intended for, but as far as I'm aware, compilers don't take advantage of it.
>>
>>62476289
Rust's generics are template-style.
>>
>>62476289
They are compiled like templates.
>>
>>62476273
How is meta-programming *not* part of the language?
Or do you mean why don't imperative languages have the "a"nything concept?
>>
>>62476303
>>62476327

>generating code instead of writing it
Why would I need to generate code unless I am writing a compiler?
I operate in language which are capable of abstraction, so that I do not need to unnecessarily generate code at runtime just to do some trivial task like mapping a list.
>>
>>62476327
Can you try to be more coherent?
>>
How do I set poo to the loo?
&poo = &loo?
&poo = const& loo?
&poo{&loo}?
>>
>>62476358
kek
>>
>>62470536
Daily reminder to learn perl 6.
>>
>>62476358
poo = ref loo
>>
>>62476350
>Why would I need to generate code
So your "argument" is entirely based on your dense and unimaginative nature. Fair enough.

>generate code at runtime just to do some trivial task like mapping a list
What are you even talking about, brainlet? Which language with proper metaprogramming facilities uses them to map a list?
>>
>>62476388
Alright then, what's a situation that needs metaprogramming?
>>
>>62476356
I meant, is he asking why there is a need for templates/generics in the first place when in functional languages there is
function : a -> a 

Which is take anything and return anything, which could "feel" more natural instead of
function (T t) { return t; } 

Even though they are essentially the same thing barring how strict your type system is.
>>
>>62476231
TemplateHaskell?? Generics??
>>
>>62476358
You're asking the wrong question

loo.emplace_back(poo)
>>
>>62476401
>what's a situation that needs metaprogramming?
Any situation where you can save yourself work by generating the code instead of writing it manually. How is this hard to process?
>>
>>62470608
>not paying attention to the installer
c++ vss is like 7gbs or something
>>
>>62476431
Such as?
>>
>>62476408
>>62476425
>templates
>generics
Oh, so you're not even talking about rewrite rules... you're talking about something far more basic, constrained and primitive.
>>
>>62476431
this reminds me of the Blub case
>>
>>62476429
ass.push_back(poo)
>>
>parametric polymorphism is metaprogramming
Christ I thought we would be beyond this by now.
>>
>>62476448
nah, the first post wasn't him. But apparently he's just a brainlet who would rather hard code.
>>
>>62476388
>Which language with proper metaprogramming facilities uses them to map a list?

Wow, dense and unimaginative!
How stupid and naiive of you!
Why wouldn't you make performance worse by doing that?
Why wouldn't you use metaprogramming for literally anything?
>>
>>62476358
>for poos in loos:
>>
>>62476408
That's not metaprogramming you idiot, and that IS generic

function : forall a. a -> a
>>
>>62470625
>even on linux.
I'd just like to interject for moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX.
Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called Linux, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.
There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine's resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!
>>
>>62476479
generic / template stuff is still metaprogramming, just a really boring and primitive version. You're alleviating the other type cases so you're meta-programming.
>>
>>62476445
Such as automatically generating code to do delta compression, binary serialization and interpolation for every field of a game entity. Have fun writing it manually for every entity, or trying to simulate reflection.
>>
>>62476448
I'm not even the guy you're arguing with

rewrite rules are for something else, not metaprogramming

I don't even know what the argument is but you seem to think you're on some ivory tower kind of shit; what's your language anon? If it's some LISP-like don't even bother replying. All you're doing is just sitting there discarding other people's posts without specifying what you actually mean.
>>
>>62476508
No it isn't, generics isn't metaprogramming at all you idiot. Maybe you could say templates are metaprogramming in the minority of languages with generics that are template based and the minority of those that allow specialisation, but generics are not metaprogramming.
>>
File: 1477286674675.png (463KB, 743x720px) Image search: [Google]
1477286674675.png
463KB, 743x720px
>Open /dpt/
>It's another of those "generics == metaprogramming" episode
>>
>>62476466
>implying anyone said you should use metaprogramming where it doesn't save you any work and makes your program less clear and flexible
>>
>>62476507
wow
is this correct
sounds correct to me
>>
>>62476538
I use a language in which metaprogramming is unlikely to make anything more clear or more flexible.
>>
>>62476534
in Haskell Generics are metaprogramming, it's not "generic functions"; they allow working on structure of types directly; you just work on sums of products and any type is built from that
>>
>>62476508
I would argue that it is not metaprogramming because in theory (and sometimes in practice) you are not instantiating a different monomorphic function for each type argument.

Is using a compiled language metaprogramming because machine code is being generated that you did not write yourself? You have to draw the line somewhere or the term is meaningless.
>>
>>62476544
>I use a language in which metaprogramming is unlikely to make anything more clear or more flexible
Then that's a giant fault with your language, because it doesn't provide you with any alternative decent way to do (e.g.) >>62476514
>>
>>62476551
It's not metaprogramming, it's just higher level programming. You are not programming with programming, or programming the language, or anything like that.
>>
File: 1505648216378.jpg (47KB, 637x579px) Image search: [Google]
1505648216378.jpg
47KB, 637x579px
What's the deal with font sizes in text editors? I'm generating 24 high glyphs with freetype and they look different than in notepad with size 24
>>
>>62476580
at which point does it stop being high level programming and starts being metaprogramming?

Define metaprogramming or all of this is meaningless
>>
>>62476595
Metaprogramming is programming about programming
>>
>>62476599
ok then TemplateHaskell

bye
>>
>>62476581
in Windows they are usually fucked. Are you using Windows?
>>
>>62476611
Yes, TemplateHaskell is a GHC extension that is indeed metaprogramming, and that you very rarely need to use. People discourage use of it most of the time.

So what are you trying to say with this example?
>>
>>62476514
If the universe of types has an eliminator then there is no problem, you just inspect the fields. Then it boils down to whether you think constant folding and inlining are metaprogramming.
>>
>>62476635
He's saying that pedantically, it's metaprogramming. But you and others are saying, no it's not, because it's hardly doing anything worthwhile.
>>
>>62476635
Nothing, it's there for you to use it.

It's not used very rarely (t. professional Hasklel programmer) but if there are easy alternatives they are often used instead. It's needed far less frequently in most other languages because the base language is already very expressive.
>>
File: IMG_20170917_133838048.jpg (105KB, 4160x2340px) Image search: [Google]
IMG_20170917_133838048.jpg
105KB, 4160x2340px
>>62476616
Yes. Text ed font is larger
>>
>>62476646
And by "universe of types has an eliminator" I mean reflection, but without any connotations such as RTTI.
>>
>>62476661
You haven't been reading if that's your interpretation. See >>62476676
>>
>>62476646
Cool story, but if I asked you to do it, you would come up with nothing, or a horrifying pile of shit at best. We both know it.
>>
who needs generics and metaprogramming anyway lol
>>
>>62476795
>generics
yes, and rank 2 types

>metaprogramming
nah
>>
>>62476681
could be an OS thing. In Emacs the font sizes (and the fonts in general) were really bad when I used Windows, but now I am using Linux and it's beautiful
>>
>>62476771
Great argument.
>>
>>62476646
>there is no problem, you just inspect the fields.
Show me how it's done, senpai. No need to implement the entire thing. Just do it for field interpolation. You should be able to define a new type of entity and its data fields, and for every field you should be able to define what type of interpolation is used for that field (to keep it simple, linear interpolation or none). You should not have to write anything manually when defining a new type of entity. Go.
>>
>>62476795
lol
>>
>>62476795
t. Rob Pike
>>
>>62476804
See (>>62476836)
>>
>>62476836
I'm not gonna do your homework
>>
>>62476872
>it's totally easy and doable but i'm not gonna provide any evidence that i know what i'm talking about
Thanks for playing, nodev brainlet.
>>
>>62476903
>thanks for playing
>nodev
>brainlet

These are all terms used by cancerous faggots and vfags
>>
>>62476795
Back to Jewgle with you.
>>
>>62476915
So hold on a minute, if Haskell is so great and lets you accomplish what I said easily, why can't you provide an example of that? Surely it won't be more than the 50 lines of code it'd take in a language that supports proper metaprogramming.
>>
>>62476836
I'm on my phone, so I will try my best to explain.

First you design a universe to describe entities. Each entity is defined by a list of fields and types of interpolation. Then you write a type family that translates descriptions into types, and a general interpolation function that takes a description, two values of the type corresponding to the description (dependent type) and the interpolation parameter and perform the interpolation on the appropriate fields by looking at the description. With dependent types this is possible in a safe manner and efficient as well if the descriptions are constant and thus allow constant folding, unrolling etc.
>>
>>62476949
I'm not the anon you were responding to.
You just used one term only used by absolute cancer (thanks for playing) and one term only used by advdgd or however you spell it (nodev)
please leave
>>
>>62476949
I don't want to do your homework for you. I could do it, but I won't
>>
>>62476964
>b-b-b-but i'm o-on the phone!!
You can tell any cool stories you like on the internet about how easy it is, but they're worthless without an implementation. Thanks for playing, brainlet.
>>
File: 1496998730043.jpg (33KB, 493x386px) Image search: [Google]
1496998730043.jpg
33KB, 493x386px
>>62476964
>>62476975
>i-i-i can't do it because i'm on the p-phone
>i-i just d-don't want you to c-copy my glorious work
So this is the power of Haskell.
>>
>>62476990
I'm not typing out Agda/Idris/etc. on here. When I get to my PC I will reply with code.
>>
>>62476990
>thanks for playing
Once again you use this absolutely cancerous term
>>
>>62477007
>When I get to my PC I will reply with code
If that ever happens, and your example doesn't look like a thousand-line clusterfuck, I will publicly admit that I'm underestimating Haskell and perhaps look into these fancy features you're talking about. But let's face it, you will never do it.
>>
>>62477021
>Agda/Idris/etc.
>Haskell
Are you pretending to be retarded?
>>
>>62477038
No, he actually is retarded.
Why do you think he constantly begs for concrete examples, and can't even read basic pseudocode?
He's too stupid to program. I don't think he's ever written anything.
>>
>>62477038
And there's nothing fancy about it, it's just dependent types. Pretty standard stuff to have a universe U and a family U -> Type for more advanced generic programming.
>>
>>62477038
Oh, alright. Thought you were one of the 5 Haskell weenies trying to move the goalpost. Let's see your Agda/Idris/whatever code, then.
>>
File: 1496690244379.jpg (43KB, 390x470px) Image search: [Google]
1496690244379.jpg
43KB, 390x470px
>>62477063
>will shitpost for hours and hours
>won't take the 5 minutes it should supposedly take for him to prove his cool claims
I predict none of you is going to provide working code, and for very obvious reasons.
>>
>>62477131
Now you're posting images that nobody posts in /dpt/
Can it be any more obvious that you're just here to shit up the thread?
>>
>>62476514
Not him but you can do all of these things already in Haskell. Binary serialisation is standard usecase already. The other cases are possible with exactly the same approach: GHC derives Generic instance and you write a general implementation for all types (once). Done.
>>
New thread:

>>62477169
>>62477169
>>62477169
>>
>>62477153
Do you have any sort of explanation for the apparent reluctance of muh-type-system posters when it comes to providing a working example? You know no one will believe it when you claim you just don't want to "do my homework" in a language I don't use, right?
>>
>>62477168
>Not him but you can do all of these things already in Haskell.
Provide a working example for this small task: >>62476836
>>
>>62477208
data YouSuperCustomType = Player { x :: Int, y :: Int, health :: Int } | Tree { height :: Int }
deriving (Generic)

instance Binary YourSuperCustomType


That's it.
>>
>>62477236
Anon, you literally didn't read the post. Trust me. Please read the post and try again.
>>
>>62471180
Original compiled fine for me...
Thread posts: 317
Thread images: 32


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