[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: 30

File: C.jpg (93KB, 768x1024px) Image search: [Google]
C.jpg
93KB, 768x1024px
What are you working on, /g/?

Old thread: >>58811703
>>
>>58816435
skewed prng
>>
>>58816435
https://youtu.be/CHLzbscw1kE
Go > *
>>
Lets write a business app that will make us all money
>>
File: 1473014534007.png (342KB, 640x640px) Image search: [Google]
1473014534007.png
342KB, 640x640px
>>58816435
Why are there no good cross-platform GUI libraries for C?
>>
rewriting the Linux kernel in CLisp
>>
Just finished a very useful function in Haskell. It truly is a beautiful language.

f x y = liftA2 ((join .) . (:)) (pure <$> x) (many' $ liftA2 (on (<>) pure) x y)
>>
Is Rust white and based? Should I learn it?
>>
>>58816459
this
someone design the logo
>>
>>58816486
Rust only accepts trannies.
>>
File: IRECOGNIZETHATBULGE_zps192fa8c1.png (20KB, 213x334px) Image search: [Google]
IRECOGNIZETHATBULGE_zps192fa8c1.png
20KB, 213x334px
>>58816489
>>
>>58816501
I can pretend to be one. Is it a good language?
>>
Why can't we treat CPU like we do with GPU and have drivers for it?

So no more Linux x85, Linux x64, Linux ARM, etc...

But a General Linux and different drivers depending on your CPU.
>>
rust turned me into a girl (male) still with bengus
>>
>>58816489
we need a great ideas guy for a unique and creative solution
>>
>>58816466

ncurses

SDL

a pointer to video memory
>>
>>58816505
They require a timestamped pic of your mutilated genitalia when you sign up.

Also no.
>>
>>58816511
do you have a feminine penis?
>>
File: 1472590278389.gif (12KB, 500x500px) Image search: [Google]
1472590278389.gif
12KB, 500x500px
>>58816435
Serious question, isn't there a website where I can request with other people something, like in a bid, and programmers can join and get money by doing it?

Programmer making better drivers like this guy https://www.kickstarter.com/projects/1327597961/better-support-for-mt7620a-n-in-openwrt-lede have a good idea. Why the fuck we don't see more?
>>
>>58816514

We're gonna use agile + scrum and maximize our ROI with inclusive business practices
>>
>>58816527
That's an oxymoron.
>>
>>58816527
yeah i |bepis| unsafe { transmute(bepis) } it
>>
>>58816466
because it's C

you're not supposed to write GUI stuff in it
>>
>>58816534
how is this different from any other ROI software with the same business practices?
>>
>>58816524
>They require a timestamped pic of your mutilated genitalia when you sign up.
I have a negro who is willing to give up his manhood. I will pretend to be him for bonus negro points.
>Also no.
Why?
>>
>>58816553
So then how do people make GUI applications in C?
>>
>>58816555

it connects to your iphone
>>
>>58816524
Rust will be good in 5 years, I promise
>>
>>58816567
With great pain and anguish.
>>
>>58816567
Win32 on Windows.
Don't know about others.
>>
>>58816435
This picture has nothing to do with C
>>
>>58816435
Thank you for posting a cat image.

Please continue to make new threads. You can even make them early if you like.
>>
>>58816580
or programming
or /g/
or 4chan
>>
>>58816534
we need a game changer app that will disruptively synergyze and leverage our long term organic growth, and start a paradigm shift that will influence and innovate the big data coopetition
>>
>>58816567
>>58816578
Xlib on Linux, but it's a pain.
There's also GTK et al but honestly it's all crap
>>
>>58816426
To the guy in the last thread- you recommended the book "How to Design Programs". I'm looking at it on amazon right now, is 22 bucks a decent price for it (used)? Also, I see it was written quite a few years ago, is the information still accurate? Or is this more a guideline type of book that explains core concepts and ideas, not necessarily "type this code that actually doesn't even work anymore because it's outdated"?
>>
>>58816593
>>58816578
>>58816575
So then why did I waste all my time learning C if I can't even make GUI applications with it?
>>
>>58816604
Complete text is online for free.

Also that is a very good book.
>>
>>58816612
I didn't say you couldn't, I just said it would cause you great pain and anguish.
>>
>>58816612
Why can't you?
>>
>>58816580
you can't claim that and Dennis Ritchie is dead

>C-at
>>
>>58816604
http://www.ccs.neu.edu/home/matthias/HtDP2e/part_preface.html
Get cracking.
>>
>>58816612
>So then why did I waste all my time learning C
you've been trolled
>>
>>58816612
https://en.wikipedia.org/wiki/Xlib#Example
>>
>>58816618
Alright cool. I'll buy a copy, I like having a physical book. I get distracted when reading online and end up shitposting on here instead (like right now).

Thanks. I'll post my code for that exercise once I get it working to get your opinion on how it looks if you don't mind. I've figured out how to print the smallest and largest number, working on getting it to add everything together in the vector now.
>>
>>58816645
>you can't claim that
free speech faggot
>>
>>58816662
Second edition is significantly improved over the first, so I'd recommend the online 2e.

Happy hacking. This book and language are probably the best possible start to learning to program.
>>
>>58816686
>alternative facts

gb2 pol
>>
>>58816662
Nice work.
Note that HtDP does definitely not teach C++ so if you are really attached to that language you will have to re-learn it. But HtDP gives a good foundation to programming in general
>>
File: Varg.jpg (50KB, 356x454px) Image search: [Google]
Varg.jpg
50KB, 356x454px
>>58816693
Stop using that phrase incorrectly:
https://en.wikipedia.org/wiki/Alternative_facts_%28law%29
>>
>>58816662
you should learn Java it will be more useful to you as a programmer
>>
>>58816435
can people still get programming jobs without a degree of any kind? All I want is like 30-35k a year, what should I learn and where should I learn it?
>>
>>58816743
>>>/g/wdg
>>
>>58816531
Reminder that you can make money by completing open-source bounties https://www.bountysource.com/
>>
why can't they just make c# as fast as c++ so nobody has to live through the c++ hell
>>
Does anyone have the picture of of programming challenges/ objectives on it?
>>
>>58816792
learn Go. easier than those two, great support, lots of features
start here https://tour.golang.org
>>
File: 1486327211135.jpg (70KB, 896x999px) Image search: [Google]
1486327211135.jpg
70KB, 896x999px
>>58816589
>>
>>58816849
anime, cats, and programming go hand in hand
>>
>>58816807
stop shilling your shitty,templateless language
>>
>>58816867
>templates
the shittest kind of parametric polymorphism
>>
>using createJS for a class
how the fuck do I see how many sides a polystar has? polystar.sides doesn't return anything
>>
>>58816891
>its shit because i dont have it
wwwwwwwwwwwwwwwwww
>>
File: kukuru dance.gif (877KB, 448x252px) Image search: [Google]
kukuru dance.gif
877KB, 448x252px
>>58816860
but how can you combine the 3 into 1 product
>>
>>58816900
What are you talking about?
Haskell has parametric polymorphism.
And it's not some template shit.
>>
what is a framework?
>>
>>58816867
https://github.com/golang/go/wiki/GoForCPPProgrammers
https://appliedgo.net/generics/
>>
File: 1445815487448.png (81KB, 780x780px) Image search: [Google]
1445815487448.png
81KB, 780x780px
Is there any benefit to using C++ when I can perfectly implement my project purely in C code?
>>
>>58816867
>t. leftist pajeet
>>
>>58816969
Strictly speaking, no. In reality it will probably be easier even if you can occasionally use C++ features.
>>
>>58816612
https://github.com/ocornut/imgui
https://github.com/vurtun/nuklear
https://github.com/andlabs/libui
>>
File: insults.png (43KB, 667x778px) Image search: [Google]
insults.png
43KB, 667x778px
Thinking of making some sort of 4chan desktop browser app (similar to clover, but desktop only, like the "messenger" standalone app). Would this be similar to building a small-scale browser? And more importantly, how should I go about learning how to implement certain features?

Pic semi related. I actually sort of want to do this but will fully admit it's really stupid
>>
>>58817009
4chan has an official api. Look at that and go from there.
>>
>>58817009
https://github.com/4chan/4chan-API
Learn how to parse JSON in your language of choice, essentially.
>>
>>58816969
Yes. Stop being a wanker and use a normal language.
>>
>>58817009
Sounds pretty trivial, something more useful would be a program that scans through a specified board every X seconds and alerts and links you to threads or posts that contain some search terms you've entered
>>
>>58816690
>>58816707
Alright, I've got it working. Here's my code.
#include "R:\C++\std_lib_facilities.h"

int main()
{
cout << "Input some numbers. When you're done, type a letter followed by Enter: \n";

vector<double> distance; // initialized vector dist to 0

double dist = 0;
for (double dist; cin >> dist; ) // for loop, when numbers are input, store them in dist
distance.push_back(dist); // take the dist numbers and put them at the end of our vector

double sum = 0; // initialize a way to add values of dist together
for (double x : distance) sum += x;

sort(distance); // sort ths dists so it'll be in numerical order so I can output the smallest and largest (this seems janked)

cout << "The smallest distance is: " << distance[0] << endl; // print the smallest distance
cout << "The largest distance is: " << distance[distance.size()-1] << endl; // print the smallest distance
cout << "The sum of all inputs is: " << sum << endl;
cout << "The average of all inputs is: " << sum / distance.size() << endl;
}


Let me know what you all think/where I can improve. As far as getting the sum of the inputs to work, I found the line "for (double x : distance) sum += x;" a few pages back in the book, but he doesn't really exactly explain what's going on there. I assume the 'x' just stands for 'whatever is input'?
>>
File: r.png (42KB, 1024x743px) Image search: [Google]
r.png
42KB, 1024x743px
>>58817009
the API makes it easy to read threads and even whole boards
pick a language and go to town
>>
>>58817103
Also note that I am fully aware that using namespace std is terrible practice, but that's how Bjarne has it set up in the file I have listed in the #include (he's mentioned several times that it's bad practice in the book, but that file is what he's instructed me to use). But I trust his judgement and will use it for now since that's what he's said to do.
>>
>>58817070
I was also thinking of adding an automatic reply notification (checks every 10-ish seconds for updates/replies to your posts)
>>
>>58817134
wait you're using "std_lib_facilities.h" in a book other than "Programming: Principles and Practice using C++"? I'm going through that book and it seemed like he made that header file specifically for it
>>
>>58817009
I made a python script that could download all images and piped thread information to desktop display.
Was pretty neat unfortunately I lost the code.
>>
I asked on stupid questions thread, but no reply.

Can anyone give me a link to something that can explain how to link libraries, make makefiles, etc.
I keep trying to use libraries in C and really have no idea how to link them when I compile with clang.
like math, stdlib, etc
>>
>>58817181
I am currently reading through "Programming: Principles and Practice using C++". The other book I was discussing earlier (How to Design Programs) was recommended to me in the previous thread, so I plan to read that once I buy a copy. Sorry for the confusion.

To clarify- yes, I am currently working through Stroustrup's PP&P using C++ right now, and the code I posted was from an exercise I just finished in chapter 4.
>>
>tfw you are all plebs at programming
>>
>>58817226
>chapter 4
literally going through chapter 4 right now

Want to work together?
>>
i've almost recreated what took me 30 minutes in c# in c++ and it only took like 5 hours

holy fk
>>
>>58817248
I'd love to. There's so much I feel like I'm not understanding.
How far in are you? I just finished exercise 2 at the end.
>>
>>58817267
impossible, what are you making
>>
>>58817103

>#include with an absolute path
>>
>>58817234
If with the skills I have I am considered a pleb I feel bad for you anon
>>
File: linus-sim.png (882KB, 1109x845px) Image search: [Google]
linus-sim.png
882KB, 1109x845px
>>
>>58817306
I can finish up the chapter and get started on the drills/exercises real soon. Contact info? (or, if you're really paranoid about putting it on 4chan we can just use a really specific common interest on omegle)
>>
>>58817336
thanks for using an anime image
>>
How am I supposed to free fields within a struct once I'm done with them (after I loaded them in a hash table with malloc)?
>>
>>58817374
free(object->field)
free(object)
>>
How about a self-driving car neural network which leverages the internet of things?
>>
>>58817336

How do you get The Sims working on W10? I couldn't get it to run right.
>>
>>58817325
Like I've said many times, this isn't some masterful state-of-the-art shit I'm doing over here, I'm working through a beginner book that says for now I should do it like that. I'm gonna go ahead and trust the creator of the C++ language over someone that calls themselves "Ruby Senpai" for now.

>>58817346
Cool. I just set up a dummy email-
[email protected]
shoot me a message there and we'll figure shit out.
>>
>>58817434
It's actually Windows 8.1 I'm running. For old games, it would be wise to set up a VM. I have one that runs x86 XP for Baldur's Gate and the like.
>>
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss
off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

>infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
>inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional advantage.

But I'm sure you'd like it more than git
>>
>>58817486
Java or C++ which is better?
>>
Hey guys im trying to make a simple gui to login to projecteuler.net, solve problems and post them via the gui instead of using a browser and shit, how do I go about doing this? Ive got a basic gui setup but don't have anything in it yet, Ive never done this thing before, how can I make it so I can login a website via python? would it be a http get request?I dont think project euler has an api so idk
>>
>>58817509
you're replying to ancient pasta anon
>>
>>58817441
ssssssssssssssent ;)
>>
>>58817513
look up how http requests and responses work in python it will solve mostly all your questions
>>
>>58817486
>You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap

So, I'm not meant to use libraries, that's the main reason for using C++
>>
File: 1450096593291.png (131KB, 555x378px) Image search: [Google]
1450096593291.png
131KB, 555x378px
>>58817513
>he set up a gui before doing the actual logic
>>
File: 1486099745329.png (44KB, 658x662px) Image search: [Google]
1486099745329.png
44KB, 658x662px
>>58817486
>mfw implicit function declarations in C
>>
>>58817567
can you blame him when he is lacking the major concepts to do such a project such as http requests, responses, and cookies?
>>
>>58817513
lol
>>
>>58817575
That picture does reflect your retardation quite well
>>
File: terry_snap1.png (442KB, 1083x646px) Image search: [Google]
terry_snap1.png
442KB, 1083x646px
>>
>>58817607
Did I say you could reply to me??
>>
>>58817558
How do I know what element im trying to request on the page? Like, how do I navigate to the login request?
>>
>>58817486
nice pasta
>>
File: 15540708.jpg (146KB, 2381x1129px) Image search: [Google]
15540708.jpg
146KB, 2381x1129px
I don't think
switch (var)
{
case 1 ... 9: //won't work
var++;
continue;
default:
break;
}
will work in Clang.
What are some more GCC specific C examples that I can find?
>>
>>58817318
i'm changing the world as we know it
>>
>>58816990
nuklear looks fucking amazing, holy shit.
>>
File: 1457203773228.png (19KB, 495x433px) Image search: [Google]
1457203773228.png
19KB, 495x433px
>you can't overload functions in C
Why am I using this shitlang again?
>>
>>58817802
>you can't dispatch on overloads at runtime in C++
Why would you use that shit language again?
>>
>>58817802
because you fell for the /g/ meme
>>
>>58817802
you can overload functions in Java
>>
File: 1359323501194.jpg (64KB, 600x456px) Image search: [Google]
1359323501194.jpg
64KB, 600x456px
>>58817802
That's the shittiest reason to hate C I've ever ehard
>>
>>58817802
Overloading is generally a sign of bad design.
>>
>>58817829
>>58817828

+
>Float x Float -> Float
>Int x Int -> Int
etc
>>
>>58816990
Imgui isnt c at least but c++, dont know bout the rest
>>
File: 1477270339038.png (692KB, 963x720px) Image search: [Google]
1477270339038.png
692KB, 963x720px
>>58817842
>What is typecasting
>>
>>58817567
the logic is trivial, I just cant get the gui to just werk.
>>
>tfw no trap gf to program and cuddle with

hell I'd even consider a 3d woman also but I swear it's not gay to cuddle with a trap
>>
File: 1484077194202.gif (287KB, 500x281px) Image search: [Google]
1484077194202.gif
287KB, 500x281px
>>58817866
Ok, so between integer and floating point addition, which is cast to which?
>>
>>58817879
(int) float1*float2
>>
Overloading (ad hoc polymorphism) is fine, the problem is when it's mixed with implicit conversion.
>>
>>58817879
Precise -> Less precise
Write the function once, have it return a float and take floats, and cast the result to an int as necessary (and the parameters to float as necessary)

e.g.
int x = (int)func( (float)intvar1, (float)intvar2 );
float y = func( floatvar1, floatvar2);
>>
>>58817894
You don't seem to understand
>>
>>58817917
Inefficient and imprecise.
>>
File: 1452565699409.gif (5KB, 102x136px) Image search: [Google]
1452565699409.gif
5KB, 102x136px
>>58817878
>wanting to interact physically with other humans
thought I was posting with like minded individuals
>>
>>58817917
No, we're discussing how + totally only has one type and everything else is just casting.

You know, how it's a myth that + actually works on integers, floats and doubles differently, generating different machine code, and how + is actually just a purely monomorphic function that only works on 1 type that everything else is just cast to. (and presumably back from)
>>
>>58817930
you can only control human urges for so long before you crave such urges
>>
>>58817486
Nice pasta, but Ada mixed with C (because some autist gives it hard to use pascal-like syntax) is the unironically the only sane choice.
>>
>>58817902
overloading and ad hoc polymorphism aren't the same things at all
implicit conversion is like overloading but automatic for types that have implicit conversions.
check out how C++ does it. in some ways it's shitty because you can't easily reason about the code. in other ways it's really nice because it lets you implement a lot of things that are usually hard wired to the compiler in other languages (e.g. string literals, move and copy semantics). also lets you "disguise" types with other types which could possibly be useful for extending functionality without changing older codebases
>>
>>58817945
>overloading and ad hoc polymorphism aren't the same things at all
>In programming languages, ad hoc polymorphism is a kind of polymorphism in which polymorphic functions can be applied to arguments of different types, because a polymorphic function can denote a number of distinct and potentially heterogeneous implementations depending on the type of argument(s) to which it is applied.
>>
I'm not sure if I should be proud or disgusted with my header to pforth C bindings tool...
Thing reads header files and generates C code based on them...

This is the garbage it spits out... only need to finish the function table output and it will be capable of producing bindings for use with pforth.
...
static cell_t CglfwSetDropCallback(cell_t v0,cell_t v1){return glfwSetDropCallback(v0,v1);}
static cell_t CglfwJoystickPresent(cell_t v0){return glfwJoystickPresent(v0);}
static void CglfwSetClipboardString(cell_t v0,cell_t v1){glfwSetClipboardString(v0,v1);}
static cell_t CglfwGetTime(){return glfwGetTime();}
static void CglfwSetTime(cell_t v0){glfwSetTime(v0);}
static void CglfwMakeContextCurrent(cell_t v0){glfwMakeContextCurrent(v0);}
static void CglfwSwapBuffers(cell_t v0){glfwSwapBuffers(v0);}
static void CglfwSwapInterval(cell_t v0){glfwSwapInterval(v0);}
static cell_t CglfwExtensionSupported(cell_t v0){return glfwExtensionSupported(v0);}
...
>>
File: akarin kek.png (395KB, 960x955px) Image search: [Google]
akarin kek.png
395KB, 960x955px
Whats the point of C again? apart from being fast?

How will """"""""low level"""""""" cucks defend their position against scripting languages?

>xD look at me writing code looks ebin hard
>takes 2 hours to do a simple thing in a scripting langugae

hmm.... e-pen is big
>>
>>58817995
akarin is cute but please don't insult akari-bbs anon
>>
>>58817995
Ask your OS
>>
>>58818008
If C is so good, why is it necessary to use asm with it?
>>
>>58817995
give me an example of "a simple thing in a scripting langugae"
>>
>>58818018
write a function that gathers all elements from a binary tree satisfying a given predicate

performance and efficiency are not a concern
>>
>>58818027
>performance and efficiency are not a concern
lol you even have to add this because you know your shitlang will take a million years to run this
>>
>>58817995
You can develop applications in C just as quickly as in Java and with similar levels of correctness. I understand you probably haven't had a real job yet, or even completed the first half of your degree, but there are a host of tools around C that make working with it very easy.

Writing Tests for C is also a lot easier to do than with most scripting languages and you can turn them on or off with a flag in your makefile.

C also has a gigantic fuckload of libraries meaning you almost never have to do anything but glue libraries together when making "modern" software.

I'm sorry you can't figure out how to use libraries. Maybe try reading a book?
>>
Why do other programming languages even exist when all you need is the God of all programming languages Java?
>>
>>58818039
>a million years
>>
>>58817995
OS dev

I agree, FORTH is much better as it's low level, scales quickly to high level when needed, and can even be used as a scripting language
>>
>>58818010
What?
>>
>>58818027
You can do this in <5 lines in C, your point?
>>
Isn't it possible to create a programming language thats high leveld that can also be optimized to be the fastest? Genuinely why the fuck are there so many programming languages that are turing complete but have niche uses? The fuck is the point if its turing complete but only use it to do one fucking thing.

Or are people too dumb to find a solution to this?
>>
>>58818010
Since when?
Only times you use asm is when you know the compiler won't do better or you are writing a compiler...
>>
>>58818098
data Tree a = Leaf a | Fork (Tree a) (Tree a)

list (Leaf x) = [x]
list (Fork l r) = list l ++ list r

gather p = filter p . list
>>
>>58818098
write a function to draw a right angled triangle in text like the following in as few lines as possible:
     #
##
###
####
#####
######


this is just to see how simple tasks look in C
>>
should a chair object have a sit on chair method or should a person object have a sit on chair method?
>>
>>58818117
nice, you accomplished the task with some arcane lines of shitlang
>>
>>58818144
list (Leaf x) = [x]


>huh, I wonder what
list (Leaf 3)

>is equal to?
>guess it's just too complicated for me!
>>
>>58818137
Person.sit(Chair)
also
>implying people are objects
>>
>>58818137
Whos in control? The person or the chair? common sense...
>>
>>58818136
this is actually probably pretty easy with printf, which might be one of the few good things C actually came up with
>>
>>58818137
The chair should have a sit method that takes an object parameter and that function calls the objects sit function which takes a person object
>>
>>58818136
#include <stdio.h>

int main()
{
for (int i = 1; i <= 6; ++i)
printf("%*.*s\n", 6, i, "######");
}
>>
how do people ever do projects as a beginner or intermediate

If a beginner or intermediate can realistically do the project then it's either already been down 10 times better (in which case it's not exciting), or the problem is trivial (in which case it's not exciting)

how to escape this hell
>>
>>58816435
Can someone help me make my student website look good?

I've got to turn it in for a project, just give me some tips.
http://student.fgcu.edu/bjaviles4619/
>>
>>58818184
Actually, I just realised that printf statement is slightly more complicated than it needs to be:
printf("%6.*s\n", i, "######");
>>
>>58817441

What fucking beginner book are you reading? No one does #include with an absolute path. It makes your code completely non-portable, even between computers with the same operating system.
>>
>>58818144
Haskell is actually a good language which can produce quite efficient code if used correctly while maintaining a high abstraction from the machine. One thing it does better than C is parallel processing as all you need to do is turn on the compiler flag and it will workout where it can (you can even force it) unlike C where you must write several lines to do the same.

>>58818176
it is and is mainly used for comparing how other languages handle such a simple task
: tri dup 1+ 1 do cr dup i - spaces i 0 do [char] # emit loop loop ;

Plus it's surprising how many here can't even do it
>>
>>58818193
grind away at it like an rpg
>>
>>58818207
I don't care about memes like "portability"
>>
>>58818210
forgot to drop before leaving compile mode
>>
>>58818207
It's probably a book that doesn't even cover makefiles.
>>
>>58818220
i hate rpgs
>>
>>58818222
>retards who can't even use autotools are allowed to post on /g/
>>
>>58818228
there is no escape from it you have to program lots of small projects then you get better to intermediate ones then you have to read blogs on data structures, algorithms, math problem solving, more stuff until you can do the advanced ones
>>
>>58818234
>autotools
Disjusting.
Just stick to plain makefiles. They're so much nicer.
>>
>>58818193
Ignore the outside world and work on it for fun.
I usually just write programs to allow for my lazy behaviour patterns to continue.
e.g this one >>58817964 was to avoid writing boilerplate over and over
>>
>>58818238
>I have never written software that anyone one else would ever want to use: The post
>>
>>58818236
i have a bachelors in math with a CS minor so the theoretical part isn't a problem

the practical side of designing big programs, reading big codebases, figuring out what i want to make, etc are the problem

>>58818241
my point was that unless it solves a novel problem or it's actually conceptually difficult it's not fun
>>
>>58818154
>>58818210
Haskell is a mess, imagine having to maintain code that's not your own in this garbarge, not only is it slow but the syntax is overly cryptic just for the sake of sparing 2-3 lines of code
>>
>>58818251
Yeah, pretty much.
Everything I have written was just for me.
I try not to do anything pointlessly non-portable though.
>>
>>58818259
>>58818154
>>
>>58818257
yeah and the practical executions comes by doing lots and lots of writing small projects and code working your way up like I said before it's a long learning process
>>
>>58818193
Yeah it's pretty demotivating but you still have to do it to get better

sort of sucks
>>
>>58818278
>>58818273
i think this is the bane (for you) of trying to learn programming
>>
>>58818257
>>58818193
>unless it solves a novel problem or it's actually conceptually difficult it's not fun
Guess programming isn't your thing, I've stayed up long nights and lost much sleep working on writing trivial programs for no reason, I think it's really fun
>>
>>58818222

Anon, there's making a program that only builds on one operating system, and then there's making a program that only builds on one fucking computer. You should, at bare minimum, use a path relative to the source file, or relative to your compiler's search path for headers. Otherwise... okay, imagine you're working with a few coworkers on a project. I'll play devil's advocate here and say you're both using Visual Studio and Windows 10, and that you only really expect the program to target Windows 10. You submit a patch to your Git repo (or whatever VCS you use), and your coworker downloads it to add his own. You both have the same operating system with the same updates, and the same version of Visual Studio. When your coworker tries to build, however, he runs into a problem. His filesystem doesn't look the same as yours. In fact, he doesn't even have an R:\ drive. He just has a C:\ drive. Now he has to structure his filesystem to look identical to yours, when the program should be self contained on its own, so that regardless of where it is cloned into, and regardless of what the rest of the filesytem looks like, it should build regardless.

You're going to make life hell for your coworkers in the future, Anon. Take my advice: your book is bunk.
>>
>>58818302
i dont mind practically trivial but conceptually nontrivial problems (essentially, most math problems)

unfortunately that doesn't help with large projects
>>
>>58818310
I'd recommend implementing big stuff that is already "done" if you want to learn and get some good practice...

Write a super shitty web-browser. Write a web server(much easier). Write a database or a compiler, etc.
>>
>>58818310
I think you need to learn about design patterns for medium to large programs is your issue
>>
>>58818222
You will when your program leaves your computer
>>
>>58818327
>compiler
That's one of those things where it's not something that's "been done", because you can compile whatever the fuck you want to, including a new programming language.
Writing a good compiler is pretty difficult, though.

>>58818329
>design patterns
I really hope you're not talking about """""design patterns""""".
>>
>>58818340
you need to learn to shut off the part of your brain that thinks it is trivial and just do it and write those small projects and work your way up
>>
>>58818329
i think you're right. i'm also trying to read through moderately sized codebases of interesting projects

>>58818327
yeah maybe but the knowledge that it's been done and my attempt will be shitty and offer nothing new isn't fun
>>
>>58818353
I'm not the original anon you were taking to. I was just throwing in my opinion.
But yes, that anon needs to stop worrying about the scope of his projects and just do something.
>>
>>58818257
well for a beginner a tool such as that would be difficult since they need to learn how parsing works. If it's in C then sprintf, fprintf, ect... but I see what you mean. Guess they could always go for a game engine as it's on the list for being one of the most complex projects to work on if OpenGL, OpenAl, Vulkan, ect... are involved.

>>58818259
The syntax is considerably simpler than C. Quite a large part of the syntax is actually just normal functions written to simplify the code. Speed depends on what your backend target is (llvm is getting there iirc) and how you write the code as sometimes it can generate code equivalent to the fastest possible implementation in C.

>>58818310
you need to stop thinking so much about it and start the first project that comes to mind.
>>
>>58818367
>The syntax is considerably simpler than C
No anon, I think you mean considerably "different" than C.
Haskell syntax is not "simple".
>>
>>58818365
>>58818367
>But yes, that anon needs to stop worrying about the scope of his projects and just do something.
>you need to stop thinking so much about it and start the first project that comes to mind.

it is decided

what about reading code tho
>>
>>58818357
>>58818365
https://www.youtube.com/watch?v=KxGRhd_iWuE
>>
>>58818385
>Haskell syntax is not "simple".
Never heard anything more wrong
>>
>>58818357
Would suggest thinking forth and SICP

>>58818385
it is when you realise most of the code is actually just functions which allow you to "pipe" output from one function to the input of another and the use of anonymous functions makes design a lot easier.

iirc this is most of the syntax
<id> :: <type>
<id> = <expr>
let <id> = <expr> in <expr>
data <id> = <id/symbol> <optional type> | ...
type <id> = <type>
and the rest is sugar
>>
>>58818436
Please why haskell syntax is more simple than C syntax.
Function calls, function signatures, list comprehensions, pattern matching, typeclasses, $, and so on.
I think you're probably confusing referential transparency with simple syntax.

Even then, it would help if you actually defined what you mean by simple.
>>
>>58818476
>and the rest is sugar
And is still part of the syntax, and is not exempt from discussion/criticism.
>>
>>58818396
read suckless, ffmpeg, openbsd, any clean codebase you can find.

Also thinking-forth will prepare you for larger projects in any language from just the first few chapters as it covers nearly every part of design you want to know.
>>
is there a c++ alternative to winforms or is this where i give up? should i use SFML or SDL? i need some buttons, some text input and a square to display data.
>>
>>58818476
ill look into thinking forth. all those projects you listed are C, right? Also they're huge.

How to find clean codebases of moderate size for higher level languages?
>>
>>58818518
gtk? qt?
>>
>>58818518
theres also glfw
>>
>>58818518

Qt
GTK+
FLTK
WxWidgets

Don't use SDL or SFML for regular old GUI shit. Use them when you need a buffer to draw images on, such as in games.
>>
>>58817754
Bump
>>
>>58818488
$ isn't syntax, it's an operator defined in the standard library

You can't just rattle off stuff like that and think it immediately makes it complicated.
Every single operator in C is its own syntax, nevermind literals, arrays, (for types) pointers, function pointers, arrays, macros, etc

Every Haskell operator is a library function, with the exception of tuple operators (e.g. (,)) and (:) (which doesn't need to be special syntax)

C also has function calls, except to pass multiple arguments you give a list ( .., .., .. ) so this also cancels out Haskell's tuple syntax, as well as its function application

Type classes aren't a great deal of syntax -
instance _ where

Signatures don't have much syntax either.
:: -> and =>
>>
>>58818530
well there's GHC if you like haskell, chicken scheme if you have an interest for a lisp, and... running out of things here...

Most will be C as it's the most widely used language but you can find projects in other languages that are good. I mostly deal with C, Forth, Scheme, and Haskell so projects related to them are the only ones I can recommend.

The book is great as it covers how to design your data structures to solve tasks without needing much code at all (look at the roman numerals solution) and you can go off making your own games in just a few lines, maybe get forth running on an arduino and start EE related projects with it.
>>
>>58818589
>and (:) (which doesn't need to be special syntax)
and I also wish it wasn't

plus if TypeInType and GADTs ever get standardised, I hope they make tuples a library feature too.
>>
I can assume that the program will just ignore the labels if it haven't encountered the corresponding "goto" command right? My program isn't just skipping the entire section of the code that follows the label right? It's that fucking stupid it is?
>>
Do virtual functions need to be in the header in C++?
>>
being a Chad sucks I want to program but women keep messaging me on my phone but when I turn it off to do programming they get mad at me later

What it do?
>>
>>58818724
are you fucking these women? because if not that just makes you a beta orbiter
>>
>>58818738
few of them yes other 2 I enjoy to have intellectual discussions with
>>
>>58818724
Real Chads wouldn't give a fuck
>>
>>58818756
well anon you have to make sacrifices somewhere

whether that be getting your dick wet and/or intellectual discussions (lol) or programming time, that's up to you
>>
>>58818769
>>58818771
I think I am going to have to choose programming
>>
>>58818708
nvm, I'm retarded
>>
>>58818195
well played, friend.
>>
File: 1485649359022.jpg (133KB, 800x800px) Image search: [Google]
1485649359022.jpg
133KB, 800x800px
>>58818308
baited for this exact response
>>
>>58818195
bjaviles please
>>
>>58818724
Just tell them that you need to do work and learn shit so you can rake in the big jew monies later.
>>
COMPUTERS ARE SO FUCKING FAST
>>
>>58818877
And yet we have memesters who peddle shit like Python and Java, so we don't get to enjoy any of that speed.
>>
>>58818869
what are big jew monies?
>>
Noobie question:

What does overloading an insertion operator do in C++? Does it make it so you can cout objects that aren't accessible in that particular function? I'm confused about the purpose of this feature.
>>
>>58818923
>insertion operator
What?
>>
Case 1. Java programmers learn C++. People expect this to be hard, and it is actually hard.

Case 2. C++ programmers learn Java. People expect this to be easy, and it is actually easy.

Case 3. Java programmers learn Rust. People expect this to be hard, and it is actually hard.

Case 4. C++ programmers learn Rust. For some reasons, people expect this to be easy, but it is actually hard. In my experience, it is equally hard for C++ programmers to learn Rust as for Java programmers to learn Rust.
>>
>>58818877
all the more reason to go faster
>>
>>58818929
can i borrow this argument for the next computer club debate
>>
>>58818923
Operators themselves have no real properties (except order of operations)
You can make >> and << do whatever you want
In fact, in regular C (and for most C++ types), they're bit shift operators, nothing to do with streams.

You could use an overload of << that has a std::ostream& on the left to cout.
You could also call the function "print".
>>
>>58818945
Um... No?
>>
>>58818953
:( fine i'll just clone it
>>
Rust competes with C++
Go competes with python.

They are not competitors
>>
>>58818963
Should I learn rust? I'm a cute girl
>>
>>58819061
learn Haskell and C
>>
>>58819061
Aren't we all.
>>
>>58819143
already planning on learning Haskell pretty soon but I'm torn between rust and C.
>>
why do women suck at programming?
>>
>>58819175
Rust is the better C++.

Go is a good language as well, it's created by UNIX and C people. Go should be a good general purpose programming language.
>>
File: tmp_15621-MJI20Jm287017866.jpg (388KB, 886x1253px) Image search: [Google]
tmp_15621-MJI20Jm287017866.jpg
388KB, 886x1253px
I started replying to people asking for homework help and I just did my first job for $20 but I'm very nervous waiting to hear back from them after sending my code.

It was a noob project, some inventory system for what must be an intro 2nd semester class. But I'm freaking out and can't sleep.

I rarely show my code to people so this is new to me.
>>
>>58819185
C was a language designed for the creators, and it shows.
Go was a language designed for someone significantly stupider than the creators, and it shows.
>>
>>58819214
Ken Thompson would disagree.
>>
>>58819149
I am neither cute, nor a girl.

>>58819185
Go might make an okay general purpose language, particularly if it would be replacing another garbage collected language, such as Java. It doesn't make a good systems language though.
>>
>>58819278
please don't use a misleading name/trip
>>
>>58819278
>a good systems language though.
Rust
>>
>>58819214
Rob Pike started work on Go because he was sick of writing servers in C++ and Java.
>>
>>58819291

Though there are more women than men that use the name Ruby, it is gender neutral, and in fact, was once a common nickname for men named Reuben. Moreover, I first started using this name in a /vp/ thread roleplaying as one of the male protagonists from the Pokemon manga. I continued using it on /g/ due to my preference for the programming language of the same name.

Do not be misled -- I have stated on countless occasions that I am a man.

>>58819293

Rust is an acceptable systems language. Although strictly speaking, I have met someone recently who was able to use a Prolog program to find a bug in Rust's type system. That is, not the compiler per se, but the specification of the language itself. Apparently they never formally proved the type system to be correct.
>>
>>58819375
I lose more of the little respect I had for you every single day.
>>
>>58819230
That's right!
>>
>>58818193
I just struggled to understand a for loop that was making a function call in C++ for the last 4 hours for a program that literally is just a convoluted way of finding the square roots of the numbers 0 thru 100.

Now that I understand how it works, I feel great. It was a stupid fucking program, it's totally useless to even me, but I'm so glad I did it.

And I asked for help, and an anon here stuck with me for 4 hours and helped me wrap my head around everything that was going on. This place is cool as shit sometimes.
>>
>>58819397

Please, tell me how I can lose all of it.
>>
https://www.reddit.com/r/HandmadeQuake/comments/4d6993/linus_torvaldss_double_pointer_problem/
>>
>>58819489
You post a link to your youtube channel of you doing unboxings or lets plays or something like that.
>>
>>58819509
>Actually linking to reddit
Kill yourself, mate.
>>
>>58819527
?
>>
>>58819489
Nothing, just carry on being a huge faggot. Literally just be yourself.
>>
>>58819521

I don't have a youtube channel. Wouldn't do unboxing videos, don't have the time to do lets plays. Have considered making a channel to make a C programming tutorial.
>>
>>58819570
bet you have a stinky bearded multichin you obese slag
>>
Yey new to 4 chan, I see programming thread, I think dis gona be good, i enter and see shit storm around dissing random dude. What a great day!
>>
>>58819643
Why do you care?
>>
>>58819670
Lurk more and kill yourself.
Any order is fine.
>>
Best resources for learning rust?
>>
>>58819699
Too bad there aren't many
>>
I'm learning C, I know a bit of the language already and by now I'm doing the examples of "The C programming language". I'm amazed by the quality of the code, what a beautiful code! I hope to write code as beautiful some day.
>>
>>58819712
I can't tell if you're shitposting or being sincere. I hope it's the latter.
>>
>>58819375
I must ask: why do you use a trip? Also rping is bretty gay, but I've fapped to traps
>>
>>58819859
It's the latter
>>
>>58817766
Elliot go away
>>
>>58817567
>tfw university course forces this
i still don't get why
>>
>>58816435
Working java.

Say I need to call some methods in no particular order, but would like to randomize the order I call them in each time, how could I go about doing this?

My current idea is to make a List of method calls, something like this:
List<> methodsTo Call = new List<>();
List.add(method1()).
List.add(method2())
List.add(method3()).

Now we just shuffle the list, and iterate through:
Collections.shuffle(methodsToCall)

and voila:
For meth in methodsToCall:
execute the method here?


Only problem is the above approach isnt really supported by the language. There must be a way to get this to work without dealing with generic types or interfaces, making all the methods in their own objects or something silly like that.


Tl;dr can anyone find a way to randomize the order of executing some methods?
>>
>>58819909
what about a switch statement and generating a random number?
>>
>>58818136
That triangle has 6 lines so I'd say the fewest possible amount of lines that can be drawn in is 6.
>>
>>58819183
becuz its not ur dick lol
>>
I want to build a calculator. Is QML a good choice?
>>
>>58819988
i guess?
>>
>>58820016
Well I thought people would shit on QML just because.
>>
What is the best way to compute pararelly on RPi with OpenCV? Any good tutorials?
>>
File: file.png (4KB, 236x303px) Image search: [Google]
file.png
4KB, 236x303px
let's say you have a grid like pic related. it can have an arbitrary size and the blockings are random.
Now I want to fill the unblocked grid with 4x4, 3x3, 2x2 and 1x1 tiles. the biggest possible tile should always be utilised. so fill it with the least possible tiles.
is there an algorithm that addresses such a (trivial) problem? wiki or a paper? seems something that was solved like 50 years ago.
>>
>>58819867

>why do you use a trip?
If one is going to use a name, one may as well use a trip.

>Also rping is bretty gay
To be fair, it wasn't a lewd RP.

>but I've fapped to traps
So has everyone else in /dpt/.

>>58819988

It should be okay. Why do you want to build a calculator?
>>
File: 1468031539090.gif (415KB, 500x500px) Image search: [Google]
1468031539090.gif
415KB, 500x500px
>>58820170
>Why do you want to build a calculator?
Just a pet project. I just want to learn Go.
>>
>>58819909
>>58819924
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {

private static void print1() {
System.out.println("1");
}

private static void print2() {
System.out.println("2");
}

private static void print3() {
System.out.println("3");
}

private static void print4() {
System.out.println("4");
}

private static void print5() {
System.out.println("5");
}

public static void main(String[] args) throws ClassNotFoundException {
final Class<Main> d = Main.class;
final Method[] methods = d.getDeclaredMethods();

// feel free to shuffle the array of methods at this point, if you like

for (final Method m : methods) {
if (!m.getName().startsWith("print")) {
continue;
}
try {
m.invoke(null);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}

}

}


Output:
5
1
3
2
4
>>
>>58820170
>So has everyone else in /dpt/.
Stop projecting your RPing ponyfag.
>>
>>58820243
Oops, in this line:
public static void main(String[] args) throws ClassNotFoundException {


The "throws..." bit is unnecessary. You can just have:
public static void main(String[] args) {
>>
What's a good cross platform GUI library?
>>
>>58820245

Your reading comprehension is shit. I'm saying everyone in /dpt/ has fapped to traps.

>>58820278

Qt.
>>
>>58820310
I thought /g/ hated Qt
>>
File: creasey.png (265KB, 990x832px) Image search: [Google]
creasey.png
265KB, 990x832px
>>58820043

>mfw madly Googling QML to find something to shit on
>>
>>58816475
this isn't lisp, you can use pipe operator instead of brackets
>>
>>58820243

Much easier in Java 8 without using reflection

import java.util.ArrayList;
import java.util.List;

public class Main {

public static void method1() {
// do something
}

public static void method2(String msg) {
System.out.println(msg);
}

public static void main(String[] args) {
List<Runnable> toInvoke = new ArrayList<>();
toInvoke.add(Main::method1);
toInvoke.add(() -> method2("Hello World"));

// Shuffle at this point

for(Runnable r : toInvoke) {
r.run();
}
}

}
>>
>>58820043
>Well I thought people would shit on QML just because.
real hardcore /g/ compsci phds would use ASSEMBLY
>>
>>58820310
>I'm saying everyone in /dpt/ has fapped to traps.
I'm not some closet fag in denial.
I do not fap to men who look like girls.
>>
>>58820374
Ruby isn't a fag, ruby's a girl.
>>
>>58819699

Dragon Dildo.
>>
>>58820322

Many do. It's bloated as hell, and its signal/slot interface is kinda clunky. But I'll be damned if it isn't the most cross platform library you can get. It's also under a nice license -- the LGPL.

>>58820388

I'm not a girl.
>>
>>58820465
If you're not a girl, then why do you have my little pony dolls?
>>
>>58816969
no, i need people to keep writing libraries in C since they interface better with other languages
>>
>>58820501
No, please stop writing stuff in C.
>>
>>58820322
The alternative, namely GTK+, is much worse.
>>
>>58820514
C is the white man's programming language tho
>>
>>58820523
I am not white so Idgaf.
>>
>>58816969
It's easier to write correct C++ code.

>>58820501
You can always write C bindings for your C++ library, but that's besides the point. Anon said nothing about writing a library.
>>
>>58820529
and u never will be with that kind of attitude
>>
>>58820530
>Actually advocating for C++
Kill yourself, my man.
>>
New thread:
>>58820533
>>58820533
>>58820533
>>
>>58820538
Good.
>>
>>58820111
Use Prolog, make the machine to think the solution for you.
>>
>>58818488
$ is just a function. And that's a pretty exhaustive list of syntax elements.
Thread posts: 317
Thread images: 30


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