[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: 331
Thread images: 40

What are you working on, /g/?

Old thread: >>59616097
>>
>>59620334
Lisp is the most powerful programming language.
>>
First for python
>>
File: 1474936903245.png (138KB, 279x375px) Image search: [Google]
1474936903245.png
138KB, 279x375px
starting from absolutely nothing, how long would it take to become competent or even good at programming /dpt/?

asking... for a friend
>>
>>59620364
>tfw press enter and you see a faggot post popping up just before your post
>>
4th for 8086
>>
Can you be a good programmer if you suck at math?
>>
>>59620385
>>59620381
goddamnit
>>
http://paste.debian.net/924804/

Wrote a simple formula expander that applies distribute law of multiplication over addition. Currently rewriting it to make it cleaner and so that I can evaluate numbers.
>>
>>59620380
That depends on so many variables and factors it's impossible to estimate. Anywhere from 2 years to 5.

But it's not only programming, it's also understanding your environment/computer, learn good programming/development/software engineering practices, learning algorithms and data structures etc.
>>
>>59620380
Not too long if you learn the important stuff
Learning what to write and how to go about writing it is far more important than knowing how to write in my opinion
>>
>>59620364
>>59620381
>>59620403
dominated by lithpfags
>>
>>59620396
You're doomed!
>>
>>59620396

How are your linguistics skills and logic?
>>
>>59620334
could you stop spamming our board with your shitty threads, please? You guys are the scum of computer science.
>>
>>59620396
Yes.
>>
>>59620474
Post code or gtfo
>>
>>59620474
>our
Who are "we"?
>>
>>59620474
This is the only CS thread on this board
>>
File: advanced_data_structures.png (327KB, 805x657px) Image search: [Google]
advanced_data_structures.png
327KB, 805x657px
>>59620396
Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.
>>
>>59620519
kys
>>
>>59620334
My wife Aoba is so damn cute!
>>
I made this:
http://codereview.stackexchange.com/questions/159056/find-all-distinct-8x8-chessboards-where-5-queens-attack-occupy-every-square

I was inspired by this:
>>59601324 (Cross-thread) (Cross-thread)

Please help to improve
>>
>>59620508
>tfw you realize this entire board is just one guy called Anonymous
>>
I despise this thread.
>>
>>59620519
Implying that combinatorics/discrete math is hard. It requires some problem solving skills, but very little general theory.
>>
what i can use to easily access to com ports and sockets on windows
>>
>>59620407
Why would you do that instead of using (pre|post)fix notation for everything?
>>
>>59620586
/sci/, get out, we smart here too

we smart
we good
we independent

we script gods
>>
>>59620634
>we script gods
I'm curious, how does one script a god?
>>
>>59620594
Lisp
http://quickdocs.org/usocket/
>>
>>59620642
import god
>>
>>59620642
Guaranteed Overnight Delivery requires advanced knowledge of the Graph theory
>>
>>59620674
Guaranteed Overnight Delivery System
(GODS)
>>
>>59620519
>Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.
Programming is a difficult branch of applied math, therefore pure mathematics is more suitable for poor mathematicians? If you want to hide your inferiority complex better I suggest you review basic logic.
>>
>>59620721
application of mathematics demands much more than being good at maths.
>>
>>59620739
Application of mathematics doesn't demand much more than being good at maths.
>>
So what do you think of Servo, /dpt/?
>>
>>59620739
>
>>
>>59620779
It's not Lisp, therefore it's trash.
>>
>>59620750
how are you gonna use maths to optimize, for example, a car engine if you don't know anything about the underlying mechanics of the said engine? being good at applying maths requires you to be a polymath.
>>
>>59620829
Simply, just formal mathematics to prove that there could exist a better engine and voilá.
>>
>>59620797
Whats are the advantages of Lisp?
>>
>>59620779
By the time it will ship Mozilla will be long dead
>>
Trying to write an emulator using this tutorial:
http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/

It appears that I'll need to draw pixel by pixel, but how would I go about doing that with SDL? I'm very unfamiliar with graphics in programs. Should I just wait until after I complete some of the other tasks?
>>
>>59620838
You manifestly don't know what you are talking about. Everything is not ruled by pure theory, see Merge sort vs Quicksort for an example; A computer scientist would tell you that Merge Sort is faster while a Computer Engineer would tell you that it's Quicksort... both would actually have right.
>>
>>59620897
they have nightly builds out right now, currently building it myself because the speed increases are really impressive.
>>
>>59620847
Common Lisp
-simple syntax any retard could memorize
-support for multiple programming paradigms
-programmable programming language (you can extend the language as much as you want, preserving its longevity)
-large number of libraries
-rather complete standard for a language from 1984
-multiple options for compilers
-per above, can be embedded in other languages/good FFI
-compiles to native code
-expressive and performant
>>
>>59620913
That's because recursive merge sort (when you break down an unsorted list to smaller and smaller partitions) IS quicksort, god damn it.
>>
File: $.gif (1002KB, 250x251px) Image search: [Google]
$.gif
1002KB, 250x251px
>>59620898
The easiest way I can think of is to draw your pixels to a unsigned char * buffer that's a pretend image frame and then upload that image as a texture and draw it via opengl.

Other alternatives could include using GL_POINTS and pretending they are your pixels where each point represents a pixel in your viewport, but this could get some errors just because GL_POINTS.

I think OpenGL even has a setPixel type call back in the old fixed function pipeline.
>>
>>59620943
So in other words there are no advantages?
>>
>>59620968
This question is meaningless, for every programming language is a Lisp in disguise.
>>
>>59620960
Can you do two-dimensional drawings in OpenGL? all the tutorials I've seen focus mainly on the 3D aspects of OpenGL
>>
>>59620968
The biggest advantage is the macro system and stuff like closures and lambdas, but the latter is making its way into mainstream langs now.
>>
>>59620396
I find the cooler stuff is always requires some math knowledge to understand
>>
>>59620978
Yes, you can render 2D drawings by having an ortho projection rather than perspective projection.
>>
>>59620977
It doesn't even have dependent types, it's a toy """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""language"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""".
>>59620987
So in other words there are no advantages?
>>
>>59621001
There's no use in talking to an inane shitposter like you.
>>
>>59621021
Your toy is utter trash.
>>
>>59621001
You can define types that depend on values in Lisp. So even in that area, Lisp won.
>>
>>59620946

Not that dude, but mergesort and quicksort are very different algorithms. Quicksort 'sorts' the array as it recurses by moving unsorted elements into semi-sorted 'larger' and 'smaller' subarrays around a (usually randomly chosen) pivot, then recursing on the two subarrays. Choosing a 'good' pivot has had a lot of theoretical work put into it.

Mergesort on the other hand, does almost all the work on the way back up from the base case (i.e. an array of size 1), by continuously 'merging' two sorted sub arrays into a single sorted subarray. In mergesort you can also see an interesting tradeoff in time vs space complexity, i.e. O(n) extra space to build each sorted subarray at each step for O(nlgn) RT, vs O(1) extra space, but O(n^2) total RT, since you have to 'walk down' elements in place in the intermediate merging step of two subarrays in worst case.
>>
>>59621032
Post your own implementation of CoC right now.
>>
>>59621042
I just misread this as memesort

brb writing memesort
>>
>>59621032
>You can define types that depend on values in Lisp. So in that area, Lisp lost.
ftfy
Types shouldn't contain dynamic data. That's pure heresy
>>
>>59621101
Are you brain dead? You don't need any form of dynamic garbage for dependent types.
>>
C noob here

If I see this as a parameter in a function signature:
const uchar4* const inputImageRGBA


I understand it's a constant pointer pointing to a constant unsigned char type, but should I assume it's an array or something? It's called "inputImageRGBA" so imagine it must be an array, but how can I tell from the signature what exactly it is? Do I just test if
inputImageRGBA[2]
points to something? I'm so confused
>>
@59621119
nice plebbit spacing
>>
>>59621136
the spacing is actually due to the code tags rather than me using my newlines
>>
>>59621112
Depends on what you mean by "dependent types."

Not for types that depend on types.
But "types that depend on values" is pretty much the definition of dynamic garbage.

All types should be known and complete at compile time, anything else is dynamic heresy
>>
>>59621119
You read the documentation and see how they intended it to work. Is there also parameters for size or width/height?
>>
>>59621162
Yeah there's params for numRows and numCols
>>
File: Capture.png (166KB, 722x359px) Image search: [Google]
Capture.png
166KB, 722x359px
lisp was a mistake.
>>
>>59621161
Please at least learn the basics of what you're talking about before spouting such garbage. You're just making yourself look like an idiot (which you are)
Even such inexpressive languages as Idris erase all type information at runtime. This is by definition incompatible with dynamic heresy.
>>
>>59621205
I am currently working on a device to help me remove certain things from our world. Lisp is very high on that list.
>>
>>59621205
>>59621240
Lisp will never die.
>>
>>59621240
And the 4chan is the first to wipe.
>>
>>59621256
Indeed, a language can't die. That doesn't somehow make it less shit.
>>
>>59621240
Let me know when its ready. We need justice.
>>
File: dt170328.gif (121KB, 900x280px) Image search: [Google]
dt170328.gif
121KB, 900x280px
LOL
>>
>>59621287
so deep anon:)
>>
>>59621176
It's probably an array then mate.
>>
>>59621205
I hope your eyes enjoy this:
(labels ((fact (n)
(declare (inline fact))
(cond ((zerop n) 1)
(t (* (fact (1- n)) n))))))
>>
Holy shit! What's man supposed to use if he just wants to develop gui applications to pc and mobile platform?
I tried kivy and it was nice but trying to do anything gui related in python just makes you want to kill yourself and ain't nobody got time to learn their shitty kv-language.
I know there's qt but it's such heap of sepples turd and compiling anything with is extremely convoluted.
>>
>>59621205
>lisp was a mistake.

The programmer is the mistake. Common Lisp supports normal loops to avoid using recursion for everything.
>>
>>59621310
Yeah I guess, I was wondering if there's a different way than making assumptions. I know that in Python people say the dynamic typing sucks cause you can't tell the type from the signature (unless you use type hints in 3.6), and you have to add comments to explain and comments get lost etc. I was expecting when trying C or C++ for this to actually be taken care of
>>
>>59621316
In CL if you use labels I know it declares function but it's not called unless you call it.
In Scheme if you try to do the same as labels
(let fn ((arg))
...)

I never know if the fn is executed straight away.
>>
>>59621318
H T M L
T
M
L
>>
File: Capture.png (144KB, 644x283px) Image search: [Google]
Capture.png
144KB, 644x283px
>>59621316
>>59621333
meanwhile in the first meme language.
>>
>>59621334
C and C++ are pretty much untyped garbage.
>>
>>59621343
That guy looks like he can't wait to tell somebody something.
>>
>>59621334
You just need to read the documentation. If a parameter is an array it's also almost always paired with a length otherwise good fucking luck working on it unless it's null ended like a char*
>>
>>59621339
not programming language or graphical library...
>>
>>59621205
No, you're just referring back to code from 1960 to make it look like a mistake.

Here's how REAL lisp code would do this.
(define ! (compose (curry apply *) (curryr build-list add1)))
>>
>>59621389
arbitrary requirement
>>
>>59621374
Oddly enough, ISWIM was actually meant to do that. Since apparently in the 60's NIH syndrome was rampant.
>>59621391
Better but the still a mess)))))))
>>
File: .gif (923KB, 450x259px) Image search: [Google]
.gif
923KB, 450x259px
>>59621391
>REAL lisp code
>posts Scheme code
>>
>>59621391
(define (factorial n)
(define (iter product counter)
(if (> counter n)
product
(iter (* counter product)
(+ counter 1))))
(iter 1 1))
>>
>>59620396
if you suck at math, you're probably not very intelligent. and intelligence helps with everything
>>
File: Crawling_in_my_Crawl.jpg (22KB, 480x269px) Image search: [Google]
Crawling_in_my_Crawl.jpg
22KB, 480x269px
>>59620681
>wee wuz truck driverz
>>
here's the error i'm getting
    Couldn't match type `[]' with `IO'
Expected type: IO ()
Actual type: [IO ()]
In a stmt of a 'do' block: map (\ x -> print x) $ mergesort values

and here's the code
main :: IO()
main = do
input <- getLine
let values = map read $ words input :: [Int]
map (\x -> print x) $ mergesort values


what doesn't it like? with just print $ mergesort values it works but it prints out like [1,2,3] and i want it 1\n2\n3
>>
>>59620519
wew lad
>>
It's pretty well established the /dpt/ hates OOP. But just because OOP is bad, that doesn't mean classes are bad, right?
>>
>>59621630
got it, mapM_ works
>>
File: Untitled.png (425KB, 1361x541px) Image search: [Google]
Untitled.png
425KB, 1361x541px
pretty impressive 2bh
>>
File: actual_winner.png (422KB, 1361x541px) Image search: [Google]
actual_winner.png
422KB, 1361x541px
>>59621746
>>
>>59620396
Depends on what you want to do with your programming and what your definition of 'good' programmer is.

Most modern programming seems to be just puzzling together API calls from number of frameworks and libs. You don't usually need much math for that. /dpt/ calls it Pajeet tier.

But as soon as you start solving actual 'interesting' algorithmic problems, yeah you're gonna need your maths.
>>
File: Capture.png (324KB, 737x500px) Image search: [Google]
Capture.png
324KB, 737x500px
>>59621773
lisp is shit more at 11
but this is also noteworthy
>>
>>59621746
this looks old. probably didn't use c++17.
>>
>>59621786
>>59621773
>>59621746
What the fuck is relational lisp?
>>
>>59620334
Can someone explain to me how to go about generating a UV map for an arbitrary mesh?
>>
File: 1489100693875.jpg (103KB, 500x500px) Image search: [Google]
1489100693875.jpg
103KB, 500x500px
Rate my hex converter!
char *to_hex(unsigned num)
{
char lut[16] = "0123456789ABCDEF";
static char hex[16] = { 0 };
unsigned idx = floor(log(num) / log(16));
while (num)
{
hex[idx--] = lut[num & 0x0F];
num >>= 4;
}
return hex;
}
>>
>>59621786
>lisp is shit

3 hour dev time
>>
File: 1479256782789.jpg (24KB, 353x530px) Image search: [Google]
1479256782789.jpg
24KB, 353x530px
how to check if integer is increasing or decreasing ?
>>
>>59621829
>using floating point in a hex converter
>>
File: b49.gif (1MB, 680x680px) Image search: [Google]
b49.gif
1MB, 680x680px
>>59621811
>current year
>using a C++ standard other than 98, in any year, ever
>mfw
>>
>>59621847
Learn English, fucktard.
>>
>>59621786
>haskell
>over 460 lines of documentation for 85 lines of code

Sounds about right.
>>
>>59621847
Is this bait, or are you actually retarded?

Go away.
>>
>>59621856
>c++98
>literally c with classes
yeah no thanks.
>>
>>59621861
thanks very helpfull :3
>>
>>59621842
>nearly 5 times as long for only a third of the time
>>
>>59621875
no?
>>
File: a45.gif (1MB, 640x360px) Image search: [Google]
a45.gif
1MB, 640x360px
>>59621876
>using classes in c++98
>mfw
>>
>>59621867
but muh one liners
>>
>>59621847
1. Keep track of what it is
2. Next time, compare what it is now to what it was before
>>
>>59621847
Pragma Loop_Variant (Increasing => Variable_Name)
>>
File: UVmap.png (25KB, 1920x224px) Image search: [Google]
UVmap.png
25KB, 1920x224px
>>59621815
Like this
>>
just how slow are fpu instructions exactly, compared to 64-bit integer arithmetic?
talking about 32-bit x86 specifically.
I kinda need to use fp math in an interrupt handler which would involve fxsave/fxrstor, and I'm not sure if it's worth the overhead.
>>
>>59621917
#pragma once
>>
>>59621851
it's faster than reversing the string because you didn't know how many long it was going to be
>>
>>59621879
You're welcome.
>>
>>59621931
string reversal's O(n)
>>
>>59621952
floating point multiplication is O(1)
>>
>>59621829
template <typename T>
auto to_hex(T n)
{
std::stringstream s { };
s << std::hex << n;
return s.str();
}
>>
>>59621966
the function is still O(n) overall though
>>
>>59621917
thanks for the help but i am using java ;_;.

>>59621915
i tryed it. It's not working.
>>
>tfw it's too hard to build useful applications
>>
>>59621886
So lisp is shit because...
...people are faster at writing it?
>>
>>59621829
wtf just use
.ToString("X")
nerd
>>
so which language is the best again?
they say
>javascript is for hipsterfaggots
>java is for indian subhumans
>c is for old fucks
>c++ is for people who like to hurt themselfs, cut and shit
>python for people who cant program
>ruby same as python
>haskell is meme
>>
>>59621995
He's mad because people are more productive in Lisp than his meme language
>>
>>59622033
C# is for hipsters, indians, old fucks, people who like to hurt themselves, people who can't program, and it's a meme.

It lets you get shit done, though, so I'm fine with that.
>>
>>59622033
Java because you actually finish programs in it
>>
>>59622033
Lisp is paren
>>
>>59622063
>c#
desu in my country serbia, firms are offering 1200 euros per month for junior.
That is like 4x bigger then for avarage job in serbia
>>
Is an invalid password an exception?
>>
>>59622033
rust
>>
>>59622116

It can be.
>>
>>59622116
No.
>>
>>59621920
Sure, but my triangles aren't in a strip. The hard part is getting them into a strip or something like that so I can lay them out in 2d
>>
>>59622033
Out of all of those, C seems the least insulting.
So C.
>>
File: 321.jpg (96KB, 1280x720px) Image search: [Google]
321.jpg
96KB, 1280x720px
Why does this not work? I thought it was working then looked again it wasn't.
//lex file
%{
#include <stdio.h>
#include "defs.h"
#include "y.tab.h"

%}
%%

"=" { return EQ; }
"==" { return EQQ; }
"!=" { return NE; }
//...

[0-9]+
{
printf("num:%s,%d\n",yytext,atoi(yytext));
yylval.i = atoi(yytext);
return NUMBER;
}

[a-zA-Z][a-zA-Z0-9]*
{
yylval.s = yytext;
return ID;
}
%%

expected expression before ‘=’ token
yylval.i = atoi(yytext);
error: expected expression before ‘=’ token
yylval.s = yytext;
>>
>>59622116
Exceptions are an exception.
Just return a fucking bool you retarded fuck. Exceptions are ugly.
>>
>>59622116
If you're thinking about returning null or doing something equally bad then just throw an exception instead
>>
>>59622194
Just write your own simple recursive descent parser instead of dealing with the shit that is lex and yacc.
RDP's are really simple to implement.
>>
>>59622116
Do you want it to be?

Make a custom exception type called InvalidPasswordException or something.
>>
>>59622177
The coordinates in a UV map are entirely arbitrary. The spatial relation of of the triangles in the map does not need to correspond in any way to the the spatial relation of the triangles in the mesh.
>>
>>59622205
>>Exceptions are ugly.
Returning success codes is even fucking worse.
>>
File: SUC CES S C O D E S.gif (498KB, 500x269px) Image search: [Google]
SUC CES S C O D E S.gif
498KB, 500x269px
>>59622274
>success codes
>>
>>59622274
No.
Exceptions are for exceptional situations, it's shouldn't be used to control program flow or in place of proper return values.
>>
>>59622230
This is really bad design.
>>
>>59622274
try
{
validatePwd(pwd);
}
catch
{
// blah blah
}


VS

if (!validatePwd(pwd))
{
// blah blah
}
>>
>>59622300
Actually, you're right. I wasn't paying attention to the context of your post. Sorry.
>>
>>59622300
>Exceptions are for exceptional situations, it's shouldn't be used to control program flow or in place of proper return values.
This

Use exceptions for unexpected states. A user entering an invalid password is not an unexpected state.

A client trying to act as if it is authorized without the proper authorization, however, is an unexpected state and warrants an exception.
>>
File: Screenshot (52).png (167KB, 518x424px) Image search: [Google]
Screenshot (52).png
167KB, 518x424px
>>59622245
That's a fair point. I guess my real question lies more in some constraints, like avoiding distortion and putting certain triangles next to each other in potentially impossible ways, then making minimal sacrifices to meet these requirements.

I currently have a solution that avoids distortion and scaling, but it doesn't really work for arbitrary meshes as it requires each piece of the model to have a way to specify its UVs in a rectangle, and it has no way of handling X is beside Y for a continuous texture.

The idea here is procedurally generated models and textures.
>>
>>59622274
You don't know what you're talking about
>>
>>59622300
>>59622332

I'm in college learning to write code like this >>59622230

What should I do?
>>
>>59622319
I would pull the method call out of the conditional expression and just assign it's return value to a variable.

Yeah, it seems unnecessary, but it is a bit clearer to anyone looking at your code after you. And the compiler will optimize it anyway.
>>
std::Option<T> or std::Result<T, E> are objectively superior to exceptions.
>>
>>59622300
>it's shouldn't be used to control program flow

Correct. Flow control should be performed solely with GOTO.
>>
>>59622371
Get a job.

Seriously, just get a coding internship somewhere. Real world experience is invaluable.
>>
>>59622392
Someone is going to respond to this bait.
>>
>>59622319
try { 
validatePwd(pwd);
log.info("logged in");
validateHasPermissionsToView(user);
update(user, model);
} catch (InvalidPermissionsException e) {
// blah blah
}

VS
if (validatePwd(pwd)) { 
log.info("user logged in");
if (validateHasPermissionsToView(user)) {
if (update(user, model) {
} else {
// blah blah
}
} else {
// blah blah
}
} else {
// blah blah
}
>>
>>59622392
agreed
>>
>>59622378
I actually think it's clearer the way it is.
Unnecessary lines and variables can actually make it more cluttered.

Anyone who isn't familiar with basic
if (!something())
patterns probably shouldn't be reading my code.
>>
Anyone ever implement a progress bar in a non-trivial C# XAML? All of the tutorials for using them to track progress shove all the logic in MainWindow and I have no idea how to track progress in other classes.
>>
>>59621856
>Use ANSI C
>Use C++98

Is that a local /dpt/ joke to use old(est) standards?
>>
>>59622457
Optimize your code so you won't need a progress bar.
>>
>>59622453
>Unnecessary lines and variables can actually make it more cluttered.

Yeah, if you don't use spacing or comments or whatever.

>Anyone who isn't familiar with basic if (!something()) patterns probably shouldn't be reading my code.
You might have a point here, but I never know if my code or snippets or whatever are going to be used to teach someone or just seen by a novice developer, so I like to make things as clear as possible.
>>
Does anyone here have experience with the Qt libraries/framework?
>>
>>59622505
Yes.
>>
>>59622340
That's a really big and diffusely defined optimization problem.

Maybe try adjusting your generation procedure to work well with your existing UV mapping solution instead? Sorry, i don't know.
>>
>>59622447
try { 
validatePwd(pwd);
log.info("logged in");
validateHasPermissionsToView(user);
update(user, model);
} catch (InvalidPermissionsException e) {
// blah blah
} catch (BullshitException e) {
// blah blah
} catch (MoreBullshitException e) {
// blah blah
} catch ...

VS
if(!validatePwd(pwd)) { 
// blah blah
}
log.info("user logged in");
if(!validateHasPermissionsToView(user)) {
// blah blah
}
if (!update(user, model) {
// blah blah
}
>>
>>59622505
Yes. It literally made me cry.
>>
File: monadic_waifu.jpg (9KB, 239x211px) Image search: [Google]
monadic_waifu.jpg
9KB, 239x211px
I'm gonna watch a monad video a day until I like them.
>>
>>59622553
those two code segments produce different results, try again
>>
>>59622457
I use MahApps' progress bar. Easy as hell to implement.
>>
>>59622560
https://common-lisp.net/project/cl-monad-macros/monad-macros.htm
>>
File: mahapps progress.webm (2MB, 984x630px) Image search: [Google]
mahapps progress.webm
2MB, 984x630px
>>59622575
>>
>>59622560
goodluck asuka
>>
>>59622365
If you're talking about not using exceptions for normal control flow, i already admitted i was wrong.

Otherwise i'd love to see you try to educate me.
>>
>>59622505
No, thank god.
>>
>>59620363
*obscures into irrelevancy*
*gets no users*
*gets not libraries*
>>
File: monad.gif (20KB, 160x140px) Image search: [Google]
monad.gif
20KB, 160x140px
>>59622560
What the problem with monads?
They are pretty decent quick warriors.
>>
>>59621391
is that racket?
>>
>>59622560
should take about 1 day
>>
>>59622568
How so?
>>
>>59622623
It has plenty of libraries. It's also used by NASA. :o
>>
>>59622623
userbase doesn't come by choosing hipster technology to implement thing but on the usefulness and marketing of thing.

Lisp have great deal of libraries and really easy c interface, also swig can generate common lisp bindings.
>>
>>59622228
They really are shit so I might have to... I was thinking I could in principle skip writing the lexer/parser (the parser side looks like it would need a lot of manually writing switches or something to generate the switches? I haven't written something like that before) if I got through the bugs and macroses... and I'd have gotten away with it if it weren't for this last bug.
>>
>>59622662
in the first block, if validatePwd(pwd) throws an exception, log.info is not run. in the second block, log.info is run even if validatePwd(pwd) returns false.
>>
>>59621773
>3 hours
lisp wins everytime
274 ain't shit considering that writing lisp is fast
>>
File: 1488719312194.jpg (323KB, 1440x810px) Image search: [Google]
1488719312194.jpg
323KB, 1440x810px
Where can I learn to write macros for object-oriented C?
>>
File: Capture.png (244KB, 731x564px) Image search: [Google]
Capture.png
244KB, 731x564px
>tfw functional languages fuel the botnet
>>
why is programming in unity so difficult?
>>
>>59621746
>(+ 85 465)
>550
that's the real loc dumbass
>>
https://tonyarcieri.com/it-s-time-for-a-memory-safety-intervention
>>
>>59622687
Not if there's a
return whatever;

or a
goto rest_of_code;

or an
exit()
>>
>>59622033
caring what others say was your mistake
just think for yourself you dumb faggot
I bet you installed gentoo because /g/ told you to.
>>
>>59622731
Documentation is just polishing, and optional in that regard. Which took up most of the time.
>>
>tfw too much of a brainlet to understand 2d multi dimensional arrays and clever math solutions to hard programming problems
>>
>>59622742
>https://tonyarcieri.com/it-s-time-for-a-memory-safety-intervention
> I’m sure curl has had plenty of low-severity logic bugs! And while it’s completely true that curl has had critical vulnerabilities that would be possible in any language, this doesn’t change that fact that memory safety vulnerabilities in curl are among the most severe.

So that guy is claiming shit out of his as and expecting people to take him seriously?
Fucking show that severe bug you double nigger.
>>
>>59622731
Also just found out the lisp implementation wasnt even complete or working apparently
>>
>>59622670
you mean hack libraries made by a single dev
what about the libraries that do something that is useful and not just decode json or bullshit like that
>>
PROGRAMMING ON AMPHETAMINES

Good idea? Has anybody tried it? My focus tends to diminish quickly and I think something like adderall would help.
>>
>>59622754
>return
not usable if you have code after the exception handling
>exit(), goto
r u kiddin m8

Exceptions are the PERFECT tool to use if you have multiple statements in a row, each of which may encounter an error. trying to shoe-horn exit codes will only result in pain. I take it you've never used monads?
>>
File: what am I doing wrong here.jpg (306KB, 1366x768px) Image search: [Google]
what am I doing wrong here.jpg
306KB, 1366x768px
Send help.
>>
File: 1407220426641.gif (2MB, 640x360px) Image search: [Google]
1407220426641.gif
2MB, 640x360px
>>59622556
Trap programmer hormones finally getting to you anon?
>>
>>59622827
amphetamines help with anything
>>
>>59622799
source, faggot
>>
Is taking a reference to a variable as an inargument practically the same as taking a pointer? When should I use one or the other?
>>
>>59622806
You must be thinking of Haskell. Common Lisp libraries are generally complete. http://quickdocs.org/
>>
>>59622861
I like how cl-charms is in there.
I tried cl-charms and it was utter garbage.
Didn't work half the time.
>>
>>59622844
You were born.
>>
ugh I'm using femtoseconds in my timer
just to avoid rounding errors and fpu math
please send help
>>
just took a drug test for a great job with a substantial pay raise..

i smoked pot a week ago. i used some method where you dilute your urine with water and fill it up with regular urine chemicals but i'm still very nervous

can some anons tell me everything will be okay??
>>
>>59622849
Someone pointed out the lisp one
https://youtu.be/IyR04U66z7E?t=48m1s
>lisp blew haskell away completely, but the difference if you read the paper was the haskell one worked

gonna go find the yale paper in a second
>>
>>59622701
There's a book called: Object-Oriented Programming with ansi-C. You might want to take a look. Also, why just don't use sepples?
>>
>>59622845
I don't even have an amusing reply to this.
>>
>>59622701
>macros
stopped reading right there
>>
>>59622701
Cello does this.
glib also provides some kind of class system.
>>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80193
c fags will defend this code
>>
how often do you make a git commit? I haven't ever worked in a professional environment so I'm just doing what makes sense for myself.

Say you code 2-3 hours on an evening, how many commits do you make? around 1,2? or 10?
>>
>>59623001
gcc is written in sepples nigger.
>>
>>59623034
where do I learn all that shit
I have no idea how to work that "git" crap
>>
>>59623034
every time it compiles after any change
>>
>>59623034
I dont use git.
Just local backup to two different disks and flashdrives.
>>
>>59622846
Do they help as much as striped programming socks?

How can I acquire amphetamines?
>>
File: cool.png (50KB, 400x479px) Image search: [Google]
cool.png
50KB, 400x479px
>>59623034
over 9000
>>
>>59623034
I read a book about gitscrub, and they say you should make a commit every 5 or 10 minutes. I usually make a commit when x feature is complete, so that could take from 5 minutes to a couple of hours.
I endup making from 1 to 4 commits a day. Sometimes just one. (All these for my presonal projects).
>>
>>59623034
A commit for every feature, bugfix or anything of the sort, sometimes I do a follow up commit if I forget something, or fix a typo, but they'll be squashed into one anyway when merging.
>>
>>59623034
whenever you think you accomplished something, however miniscule, and your code compiles and passes all the tests.
>>
I was doing MIT open courseware to brush up on C++. I finished the intro course, but the more useful course "Effective Programming in C++" has unusable lecture notes.

What would he an equivalent intermediate level course available online?
>>
>>59623034
depends on the nature of the project
I'd wait until I'm done rather than mini-commiting, so I guess one per day
>>
>>59623067
darknet
friends
drug dealers
or get a prescription
>>
>>59623097
Why just don't pick a book? The Bjarne's is really good, take the advanced one if you already know how to brogram.
>>
>>59622518
Have you done work with the QGraphics classes? Qgraphics items are by default mouse grabbers, so when I click them, the one that "caught the click" is the only one that is going to receive move events and the release event. Do you maybe know how to make an item release the mouse once it leaves its bounds?
>>
>>59623034
I commit every time my code compiles then squash all my commits into one before merging into master.
>>
>>59623052
I thought it was a hassle at first too but really it's worth more effort than it costs after a while. You can try the tutorial for git on codecademy, it goes into most of the things. After that only need to google once how to do "git push origin master" (you can name origin an master different but it's convention) to push to github and you're good. It really helps with looking back at previous versions of your code.

One of the greatest features is branching. Say you have a master branch with all stable releases, then you create one branch for developing, then from develop your branch to a GUI branch, and work on the backend on a different one at the same time.
>>
>>59623119
Sure. Anything to avoid doing intro level stuff again.
>>
>>59623001
No I won't. GCC a shit.
Use Clang.
>>
>>59623130
https://doc.qt.io/qt-4.8/qwidget.html#mouseTracking-prop
>>
>>59623082
>>59623142
wait to they automatically squash when merged? or is it just because it doesn't matter because you end up with a single point again?
>>
>>59623119
Which one is the Advanced one?
>>
File: 1479166362661.jpg (600KB, 1920x1080px) Image search: [Google]
1479166362661.jpg
600KB, 1920x1080px
I've gotta build a binary decoder for a surprise homework assignment. I've got a txt file filled with 0s and 1s and I need to translate it to either 7 or 8 bit ascii.

I'll obviously need a table for the decoding, but, is there some smarter way to get this table other than hard coding it myself? I'm just looking for cool suggestions to make the assignment more interesting. I was planning to just hammer out the code in python real quick but if someone has a smart ass suggestion I can turn in I'll probably do it.
>>
>>59623186
The one that isn't Principles and Practices in C++.
>>
>>59623180
that depends, if they get merged through websites like GitHub or GitLab, then yes, they get automatically squashed, otherwise you have to squash yourself
>>
>>59622843
>r u kiddin m8
I'm not.

>I take it you've never used monads?
Don't insult me if you have no arguments.
>>
>>59623173
That just might be it. I didn't want to ask you a really detailed question of what I'm really tryig to achieve, but this could help me out.
>>
>>59622933
>Also, why just don't use sepples?
It's just for education purposes, I don't program at all now.
>>
>>59622539
>That's a really big and diffusely defined optimization problem.
Yeah, generally everything I do turns out to be that way. Vaguely close to a well defined problem, but not close enough to use the well defined solution.

I guess I'm looking for something like what blender does. I tried to take a look at the source code for it but it's way bigger than I'd like and I'm not even sure if I'm in the right place.

My next idea would be to create a graph of connected triangles, then somehow figure out the least number of cuts that can arrange them properly?

Thanks for the help though, it's always good to discuss even if you don't come up with a solution.
>>
File: 1472515590369.png (2MB, 1920x1080px) Image search: [Google]
1472515590369.png
2MB, 1920x1080px
>>59620533
youre waifu a shit
>>
>>59623230
Oh, then I don't think doing OOP at this stage will do any good.
>>
>>59623199
Assuming the binary is regular ASCII encoding, the language already converts the binary of any Char type variable to a character. You know bit math?
>>
>>59623257
By "I don't program at all" I meant I don't work on programming projects.
I know how to program.
>>
>>59620519
>the poorer mathematicians had better remain pure mathematicians
really, now? i've seen quite a few dumbasses manage to half-ass their way through cs majors with little trouble, but i've never seen one do it with a math major
>>
>>59623212
good to know, never heard of this before

>select street signs
>it's an advertisement
>accept anyways
don't be too quick buying that self driving car guys
>>
>>59623275
>I know how to program.
> I meant I don't work on programming projects.
That's like an oxymoron, anon-chan. You learn to program by doing projects. Just learning the syntax's languages, statements, and quirks doesn't help that much.
You should start doing your own projects to gain experience fast.Best way to learn is by doing.
>>
things I learned today
repz ret

this is a thing apparently.
>>
Can someone give me some quick feedback on if I comment code too much? I'm practicing by making the 2048 game in python, and sometimes I feel like I write like one comment for every two lines of code
>>
>>59623327
The comments are mostly for your benefit, you should only be commenting if you're doing something in a counterintuitive way.

If you're documenting library functions, just give a short description at the top, no need to step through every line, it makes it harder to read for people who aren't literal retards
>>
>>59623327
commenting single lines is pretty redundant. But many enterprises would love you for already having the habit.

Personally, comments should never exceed actual LOC. Most of the time its either redundant or explaining away something you could be expressing better.
>>
>>59623267
>Assuming the binary is regular ASCII encoding, the language already converts the binary of any Char type variable to a character
I don't really get what you're implying here. My file can be either 7 or 8 bit ascii of 0s and 1s.
Part of the challenge is figuring out which one.
>You know bit math?
Yup
>>
>>59623327
Comments should only be used if the code is unclear. If your code loops over a collection, I can see that its looping over the collection and therefore you don't need to tell me. If you're doing something strange, write a comment that explains it, ESPECIALLY to give context, such as edge cases or domain-specific things. I don't really know python syntax so I can't say if your comments are too obvious or not.

The comments at the top of your functions are good. Those are used to skip reading over the code entirely. Unless a function has a bug, I just want to use it and assume it works.
>>
>>59623374
>>59623397
ok thanks guys.
I'd rather comment too much than not enough, especially in the beginning when maybe functions or something will change. And I'm still a beginner so reading my own code sometimes takes a while. For example in the pic flattening the array isn't exactly an intuitive line for me
>>
File: 1488756509521.jpg (27KB, 480x480px) Image search: [Google]
1488756509521.jpg
27KB, 480x480px
>>59623312
Not counting uni projects, I already worked as a script kiddie for two years.
I am not a complete newbie in programming.
>>
>>59620334
What are YOU working on, you animu lover
>>
>>59623327
Comment as much as makes sense for you and your current skill level. Strive to make your code easily understandable if you look it it again after a month or a year.

As your coding proficiency and idiom familiarity increases, comments tends go down.
>>
>>59623438
To expand on the function comments, some IDEs will bring up the comment above the function so that you don't have to go look at it
>>
Does the rust shill-squad consist entirely of fresh CS graduates that just learned what a buffer overflow is?
>>
>>59623327
Let your code be self-documenting.
>>
>>59623480
t. ultra-pajeet

seriously though not always possible with python, let alone for lower level languages. The only language I've ever seen that is almost entirely possible to self-document is Ruby. The synthax and OOP use is so perfect, even if you don't know much about ruby synthax you can almost read it like english
>>
File: 1359475492539.png (87KB, 250x250px) Image search: [Google]
1359475492539.png
87KB, 250x250px
>>59623479
Don't wake them up. They're the last thing this thread needs.
>>
>>59623480
It's code like yours that takes ages to decipher and fix
>>
>>59623520
Why even program when everything is in unsafe C?
>>
File: 1362372882523.jpg (3KB, 125x125px) Image search: [Google]
1362372882523.jpg
3KB, 125x125px
>>59623542
Oh no
Here they come
what have we done
>>
File: herdyoutalkinshit.jpg (24KB, 500x564px) Image search: [Google]
herdyoutalkinshit.jpg
24KB, 500x564px
>>59623520
>>59623479
Too late, fags
>>
>>59621829
why are you returning a pointer to stack allocated memory?
>>
>>59623327
I would use doc string @ top of inside of function definitions with a terse summary of what function does, parameters, and return values.
>>
>>59623590
No pain, no gain.
>>
>>59623556
Face it fagman, Rust is superior.
Even cURL acknowledged this fact in their last blog post
>>
>>59623590
Don't you see he posted an animu? He's obviously a troll or a fool
>>
>>59620334
Please desist from posting poorly drawn Japanese cartoons next time
>>
>>59623625
Take your pills.
>>
>>59623625
it's a static char buffer
it prevents having to free the return value unless you want to keep it for much longer, in which case you can just strdup it yourself.
>>
>>59623562
>>59623556
>>59623520
it was such a quality thread
>>
File: 1361918884095.png (42KB, 344x517px) Image search: [Google]
1361918884095.png
42KB, 344x517px
>>59623640
Everytime.
You're easily spotted, animu warlord.
>>
>>59623601
why inside the function? maybe this is just specific for sublime editor but now i can collapse all functions and still read the description. Is this convention?
>>
>>59623452
why is nico nii so perfect
I want to make violent rough love to her and have her rape me repeatedly
>>
seriously though I'm considering getting into either rust or c++. I want to develop for windows, maybe android (yes I know java, but you can at least compile c++ to android)
>>
>>59623674
There is a built in command called help in python. If you call help(function_name) from say the python console, it will read out the (first only?) doc string within the function.
>>
>>59623713
Who gives a shit?
>>
>>59623663
So?
Imagine how could your life be easier if you would never see anime pictures again.
Wanna know how to do that?
Don't open 4chan ever again.
>>
>>59623713
Learn both and make up your own mind. Unless you want to find a job, then learn c++.
>>
>>59623674
>>59623724
Also forgot to mention it works the same for classes
>>
>>59623737
I have a job, programming is just hobby.
>>
>>59623713
Do you want a quasi-functional language with the verbosity of an imperative?
Or a relic on top of a relic with bolted on modern features?
>>
>>59622033
Python, C/C++, and Java are all you ever need to know
>>
>>59623766
Why not them all?
>>
What's the best web framework with Rust? I need async IO and WebSockets for faster JSX hot reloading bundles Babel transpiler plugins please respond
>>
Dear /dpt/,

What are the programming languages you'd say you know well? Something you'd put on your resume, and you'd would feel comfortable doing the interview exercises in.
>>
>>59623812
I heard about this one before: https://rocket.rs/
I don't think it does async though.
>>
New thread:

>>59623850
>>59623850
>>59623850
>>
//Original version
void parse(char** tokens, char* buffer)
{
char* tok = strtok(buffer, " ");
if(tokens[0] != NULL)
free(tokens[0]);

tokens[0] = (char*)malloc(strlen(tok)+1);
strcpy(tokens[0], tok);

//Rest of function is irrelevant
}


//Updated version
void parse(char* cmd, char** args, char* buffer)
{
char* tok = strtok(buffer, " ");
if(cmd != NULL)
free(cmd);

cmd = (char*)malloc(strlen(tok)+1);
strcpy(cmd, tok);

//Rest of function is irrelevant
}


The rest of the function is irrelevant because it's otherwise identical (just copying the rest of the buffer tokens into the char**)
The second version however fails to actually put anything into the cmd array, and I have no idea why.
I've tried initializing char* cmd to NULL in the calling function, I've tried malloc'ing it in the calling function, but every time I get back a bunch of "invalid read size of 1" errors from valgrind, and trying to printf the variable yields nothing.

What could possibly be causing this?
>>
>>59623400
I suppose you could try both the 7 bit and 8 bit parse and see if any of them give whitespace characters.
>>
>>59623858
> and trying to printf the variable yields nothing.
More specifically, printing INSIDE the parse function is fine.
Printing AFTER yields the invalid reads.
>>
>>59623842
OCaml, C and C#
>>
>>59623766
ruby >>>>> python

I use both extensively (ruby for my own, python at work). Every week I find myself googling "how to do <ruby verbose single line thing> in python" to find stackoverflow posts with "well python doesn't have this feature, but you can just <ugly, non-intuitive, 5-line working only for this specific situation>"

Even though I'm about as proficient in either, I literally never find myself googling how to do something python can in ruby
>>
>>59623842
C, C++, OCaml
>>
>>59623913
You just don't know how to use Python, but Python can be used for machine learning, data science, scientific computing, and Ruby is irrelevant in those areas
>>
>>59622701
C is shit.

Use malbolge
>>
>>59623226
I ask because this pattern
if (...) { 
// error
}
if (...) {
// error
}
if (...) {
// error
}

is very repetitive and is the exact problem monads are trying to solve. an exception is a type of monad that allows you to rewrite that as
 
(...);
(...);
(...);
>>
>>59622844
You are using android studio.

Use xamarin fag.
>>
>>59623953
>Python can be used for machine learning, data science, scientific computing, and Ruby is irrelevant in those areas
I have to half agree. Python and Ruby can basically do the same things, only the syntax is different. Why python is so widespread is because of all the libs like numpy etc. This is also why I have to use it at work (scientific computing) but I like Ruby for my own projects
>>
>>59623906
Is it seg faulting outside of the function when you go to print cmd or just printing garbage? And inside right to the end of the function is printing cmd correct?
>>
File: Agreement.jpg (75KB, 640x640px) Image search: [Google]
Agreement.jpg
75KB, 640x640px
>>59622922
No in five years you will look like this
>>
>>59623186
>http://www.URLBiggy.com/CPlusPlus-advanced
>>
>>59624024

>>59624059
>>
>>59623590
>static
that's not on a stack
>>
>>59622935
Me neither
>>
>>59621119
>dereferencing array such that *array is the same as using array[0]
>a pointer to allocated memory is an array with length of sizeof(type) * 1
Thread posts: 331
Thread images: 40


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