[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 32
File: 1428780772552.jpg (22 KB, 380x286) Image search: [Google]
1428780772552.jpg
22 KB, 380x286
2010 edition

Previous thread at >>52138645

What are you working on, /g/?
>>
Fixing the obamacare website
>>
Reposting in case the thread dies before anyone helps me.

I'm trying to write a method that returns a converted bitmap so I can actually use it.

    class ImageConvert
{
public static ImageSource(string imageToConvert)
{
var bitmap = new System.Drawing.Bitmap(imageToConvert);
BitmapSource convertedImage = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
return convertedImage;
bitmap.Dispose();

}
}


It refuses to work. I'm not sure how to get it to return "convertedImage". Can't seem to get the return type to take.
>>
File: loU3WSd.webm (2 MB, 720x404) Image search: [Google]
loU3WSd.webm
2 MB, 720x404
Ask your beloved programming literate anything.
>>
>>52142773
Why do you love Java so much?
>>
File: mems.jpg (15 KB, 389x103) Image search: [Google]
mems.jpg
15 KB, 389x103
nth for I could be doing something to advance humanity, but I'm too deep in the memes
>>
6th for I want to learn graphics programming but vulkan is right around the corner.
>>
>>52142807
just learn opengl fgt
>>
File: java.jpg (47 KB, 385x499) Image search: [Google]
java.jpg
47 KB, 385x499
Is this a decent guide for learning Java?
>>
>>52142807
people have been saying this for 1½+ years in /dpt/
>>
RIP Ian Murdock

>>52142851
Any guide that teaches you Java is guaranteed not to be good
>>
>>52142807
Learn it with Mantle or D3D12 then.
>>
>>52142760
I don't think you should dispose of the bitmap AFTER returning something.
>>
>>52142851
probably

>>52142870
epic meme
>>
>>52142795
>python
you're a lost cause
>>
>>52142891
My bad, it's code from elsewhere that I'm copying to use, just haven't worked the rest of it out yet because I can't find a return type that it likes, and actually have the "return convertedImage;" work.
>>
File: 1451440533383.jpg (71 KB, 640x640) Image search: [Google]
1451440533383.jpg
71 KB, 640x640
>>52142921
I'm lost in the fit grills lad
>>
>>52142964
4th, bottom row pls
>>
File: mems.jpg (362 KB, 1366x768) Image search: [Google]
mems.jpg
362 KB, 1366x768
>>52142978
m8, I decided to offer a bigger selection, which is it again?
>>
File: wpid-20131209_215433-kdcollage.jpg (61 KB, 640x640) Image search: [Google]
wpid-20131209_215433-kdcollage.jpg
61 KB, 640x640
>>52142964
>tfw no gf
>>
>>52142986
0,5
>>
File: not_today.webm (1 MB, 720x404) Image search: [Google]
not_today.webm
1 MB, 720x404
>>52142791
java has democratized the best of software engineering: oop, design patterns, exceptions, garbage collection, no more pointers (unsafe, messy), no more unsigned types (unsafe, messy), concurrency, interfaces over multiple inheritance (messy), no preprocessor (unsafe, messy), ... java literally revolutionized programming in both enterprise and academia.
>>
>>52142986
what
i mean 2,5
I don't know why I can't think today.
>>
>>52142997
could you flip this horizontally for me?
>>
File: 1451443632205.gif (2 MB, 500x557) Image search: [Google]
1451443632205.gif
2 MB, 500x557
>>52142998
>>
File: Bait.png (220 KB, 387x545) Image search: [Google]
Bait.png
220 KB, 387x545
@52143016
>>
File: 1451454994687.jpg (82 KB, 871x960) Image search: [Google]
1451454994687.jpg
82 KB, 871x960
>>52143017
>>
>>52143047
good lord. thanks.
be back in 41 seconds.
>>
File: temp.jpg (94 KB, 640x640) Image search: [Google]
temp.jpg
94 KB, 640x640
>>52143023
did it in mspaint so probably shit compression
>>
>>52143074
thanks, this way it looks like she's taking her top off
>>
>>52143093
nice
>>
File: 1451499561411.jpg (31 KB, 460x316) Image search: [Google]
1451499561411.jpg
31 KB, 460x316
>>52143047
Alright, I'm going to stop, we need to keep this on-topic

For reference, here is my code again. You may need to change functions based on python version (I use 2.7), and have requests installed

import urllib,sys,requests,os

board,thread=sys.argv[1:]

url="https://a.4cdn.org/"+board+"/thread/"+thread+".json"

posts=requests.get(url).json()["posts"]

newDir=os.getcwd()+"\\"+board+"\\"+thread

if not os.path.exists(newDir):
os.makedirs(newDir)

for keys in posts:
if "tim" in keys:
urllib.urlretrieve("https://i.4cdn.org/"+board+"/"+str(keys["tim"])
+keys["ext"],newDir+"\\"+str(keys["tim"])+keys["ext"])
>>
>>52142899
Java is a genuinely shitty language m8.
>>
im gonna go shave this massive beard and get paid to do it. working from home is neat.
>>
>>52143118
oh and run the following:
filename.py board threadNumber

or replace board and thread in the code itself and run as normal
>>
File: 084.png (102 KB, 300x256) Image search: [Google]
084.png
102 KB, 300x256
>>52143124
>python is good
>lisp is good
>hasklel is good
>C# is good
>java is genuinely shitty
>>
>>52143129
>working from home is neat.
Mabye I should be a cam whore too
>>
>>52143165
python is shit
lisp is shit
haskell is shit
java is shit
>>
>>52143185
and C# is shit? it's pretty similar to java m8
>>
>>52143197
Never before has any voice uttered the words of such bait here in /dpt/
>>
>>52143170
i WISH that were my job.
but at least I can drink beer and smoke while working.
>>
>>52143124
why though? You don't understand it or just haven't tried it?
>inb4 more meme shouting
>>
>>52142701
Could you not find a non-stock photo, OP?
>>
File: 1448506151250.gif (997 KB, 500x332) Image search: [Google]
1448506151250.gif
997 KB, 500x332
>>52143016
Nigger you are a fucking retarded
>>
File: 1451370879859.jpg (481 KB, 1920x1080) Image search: [Google]
1451370879859.jpg
481 KB, 1920x1080
Why is web development so disgusting?
I installed the emscripten portable sdk, which git clones and builds the latest versions of their toolchain, (nodejs, clang, llvm...) and it takes over 8 hours to build.
The SDK itself is nearly 2 gigabytes, and I still haven't gotten any C code to run reliably in my browser.
>check out autogenerated js file
>13000 lines of boilerplate garbage
>my c program was a simple hello world
>>
>>52143430
explain
>>
>>52143185
haskell is great though. and lisp isn't really a language, rather a natural phenomena from parsing symbols into a tree structure.
>>
>>52143433
>web development so disgusting
>cannot program for shit so he downloads a ton of shit
>>
>>52143118
Do not run, it is a virus.
>>
File: 1445253567568.jpg (11 KB, 300x201) Image search: [Google]
1445253567568.jpg
11 KB, 300x201
>>52143458
>he doesnt know C++
>what is c#
>What is democracy
>he doesnt understand CS
>he goes to codecamps
>>
>>52143558
>What is democracy
http://www.merriam-webster.com/dictionary/democratize
": to make (something) available to all people : to make it possible for all people to understand (something)"
>>
>>52143140
>>52143140
OSError: [Errno 13] Permission denied:



do you even test the code before ?
>>
>>52143607
democratize is a different word
>>
Shut the fuck up Austin.
>>
File: 1450657668600.gif (906 KB, 500x349) Image search: [Google]
1450657668600.gif
906 KB, 500x349
>>52143607
>he cant understand c++
>being too stupid to learn a non-meme language
>>
>>52143654
i wrote "democratized" (>>52143016)
>>
>>52143614
I did just this code and it still works:
import urllib,sys,requests,os

board,thread=sys.argv[1:]

url="https://a.4cdn.org/"+board+"/thread/"+thread+".json"

posts=requests.get(url).json()["posts"]
title=posts[0]["semantic_url"]

newDir=os.getcwd()+"\\"+board+"\\"+title+" ("+thread+")"

if not os.path.exists(newDir):
os.makedirs(newDir)

for keys in posts:
if "tim" in keys:
urllib.urlretrieve("https://i.4cdn.org/"+board+"/"+str(keys["tim"])
+keys["ext"],newDir+"\\"+str(keys["tim"])+keys["ext"])


You must have changed it so that path.exists doesn't match makedirs
>>
>>52143016
>no more unsigned types (unsafe, messy)
>>
>inheritance-based, nominal OOP
>not row-polymorphic, structural OOP
>>
File: pls.png (123 KB, 763x263) Image search: [Google]
pls.png
123 KB, 763x263
>>
>>52143764
...what the hell are you trying to accomplish?
>>
>>52143704
" Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple." -- James Gosling (PhD), Creator of The Java Programming Language.
>>
>>52143730
>OOP
nice meme
>>
>>52143693
thats because you have backslashes
in linux that doesnt work
it must be:
newDir=os.getcwd()+"//"+board+"//"+thread
>>
>>52143764
i want gcc/g++ to know where the jni.h is so i can compile for windows and not just android
>>
>>52143793
Signed types have a signed bit as their most significant bit and unsigned types don't.
By omitting the ability to store negative values, you can store a value twice the size of a signed integer in an unsigned integer type.
>>
>>52143793
and how does that imply unsigned types are unsafe and messy?

Why are Java supporters so fucking stupid?
>>
>>52143793
>Quoting a retarded
>>
>>52143793
Java is simple, yet everyone who uses it is incompetent.
>>
>>52143811
ah had no idea lad, I have yet to get linux on my laptop

i'll add a check for it anyway
>>
>>52143814
You need to feed it .c files, what do you think it is supposed to do with a single -I argument?
>>
>>52143792
>>52143814
basically i want to do

gcc -I/usr/lib/jvm/jdk1.7.0_07/include


but in windows

http://stackoverflow.com/questions/14529720/how-to-make-jni-h-be-found
http://stackoverflow.com/questions/14589971/how-to-make-gcc-accept-spaces-in-path
>>
>>52143433
>using abstraction tools for baby
just code it in javascript anon
>>
>>52143844
it's an I, not a lowercase L
>>
are shells a meme?
>>
>>52143865
>learning javascript
>no static typing
>functions inside of functions
>no classes

nah
>>
>>52143877
everything is a meme, that includes you and me.
>>
>>52143890
meme
e
m
e
>>
>>52143819
what happens when you mix signed and unsigned in expression ?

>>52143820
https://google.github.io/styleguide/cppguide.html#Integer_Types

>>52143821
>>52143831
please, don't bully.
>>
>>52143871
God dammit just hand it some .c files to compile
>>
>tfw wish I knew about the legendary slides to operator before uni so I could impress the lads
>>
>>52143913
Each type has it's applications, you don't mix signed and unsigned types unless you know what you're doing.
In fact, don't use unsigned types if you don't trust yourself to not screw up.
>>
>>52143884
>he doesn't like anonymous functions
Average static typing retard. Lambdas too hard for you?
>>
>>52143966
I still don't know why an anonymous function withing a function would be considered useful.
What good are lambdas?
>>
>>52143884
>>functions inside of functions
this triggers the functional programming fags
>>
File: oops.png (9 KB, 555x109) Image search: [Google]
oops.png
9 KB, 555x109
Just finished automating putting tracking numbers into orders for my parent's business. Before, my mom had to check the email every day and put in the numbers into orders. Some of them she missed which resulted in angry customers asking why they didn't ship.

I knew php before, but I used a bunch of skills I am currently learning in community college Computer Science, especially OOP. I made the script check UPS emails, then when I wanted to add emails that were sent directly from a company, it took so little effort to add in, while before without OOP it felt cumbersome adding stuff in.
>>
>>52143913
>This code will never terminate!
That's some pretty retarded shit. The compiler should certainly always notice that bug. I'd be pretty shocked if C# didn't catch this 100% of the time. Though i've never run into a bug like this before.

>Don't use an unsigned type.
Equally retarded. What if you are dealing with image data? How else do you represent the RGB values of a 24-bit pixel except as 3 unsigned bytes? This is some idiotic shit.
>>
>>52143978
functions inside of functions is standard fp
>>
Why doesn't C# support multiple inheritance?
>>
>>52144086
interfaces
>>
>>52144086
Because it's considered messy. You can "inherit" multiple interfaces though.
>>
>>52144020
it's simple for a compiler to check for (uint >= 0) comparisons, but if that 0 is a calculated value from somewhere else that the compiler can't trace then you're fucked.
>>
>>52144086
multiple inheritance is dangerous and mostly for memetic purposes
>>
>>52143976
It lets you quickly make short, non-reusable functions without having to declare them independently.

If you need a callback function for example, or custom logic for a function. Let's say you want to add 5 to each element of an array. With a map() function and an anonymous function:

var myArray = [1,2,3,4,5,6];
myArray.map(function(val) {
return val + 5;
});


This is much concise and clear than having a separate named function just to add 5 to its argument. I know it's a retarded example but for demonstration purposes I think it's good enough.
>>
>>52143918
got it to work now

i added

-I"C:\Program Files\Java\jdk1.7.0_71\include\"


to gcc-opts and g++-opts in my windows32 ant build script :^)
>>
>>52144102
Ok but why doesn't it support both?
>>
>>52144145
Why don't you just add 5 in the same function?
>>
>>52144165
u avin a laugh?
>>
>>52144113
I understand that but I would like to have the possibility to choose...
>>
>>52144172
map takes a function as a parameter
>>
>using C makes me smart
lol
>>
>>52143118
Python is ugly as fuck
>>
>>52144191
Why don't you just make a separate function?
Better yet, why not make it a member function as part of the map object?
>>
>>52144188
>choosing multiple inheritance
>1 or 2 days before 2016
>>
>>52144194
>using python makes me non-retarded
>>
>>52144208
I don't see how
>>
File: anger.jpg (35 KB, 467x508) Image search: [Google]
anger.jpg
35 KB, 467x508
>>52144086
>what is the diamond problem?
>What are interfaces?
>>
>>52144118
>but if that 0 is a calculated value from somewhere else that the compiler can't trace then you're fucked.
I struggle to imagine a real code example like that that isn't poorly written.

In any case the usefulness of having unsigned ints far outweighs the chance of creating a bug like this. I don't even know the last time I saw something like i >= 0 is a for loop anywhere, or anything else.

unsigned ints are more type safe and memory efficient. Good luck doing things like image manipulation without unsigned ints.
>>
>>52143976
they support closed variables, which are necessary for event handlers. try doing this type of code in C++:
function configureSomeBs() {
var numberOfClicks = 0;
App.onClick = function(){
++numberOfClicks;
};
App.onClose = function(){
alert("you clicked "+numberOfClicks+" times!");
};
}
>>
>>52144215
Not him
>Why don't you just make a separate function?
Needless, especially for non-reused code

>Better yet, why not make it a member function as part of the map object?
You mean the built-in map function? Add that non-reused code into a map function called from wherever, but only using that code in 1 specific place?
>>
>>52144188
yep. Well, in C# you can't. You will be encouraged to use composition instead.
>>
>>52144215
What are you talking about?

Map is a member function of an array that applies a function to every element in the array and returns the results

e.g. in f#
[|1..10|] |> Array.map ((*) 2)
will give you [|2..20|]
(*) 2 is partial application and could be thought of as the lambda
fun f -> f * 2
>>
>>52144260
Why don't you just write out what map does as part of the function itself instead or trying to make it a member function, especially when it only has to add += 5 once.
>>
>>52143966
I like functional programming and static typing.
>>
>>52144239
Sorry, I'm quite new to programming...
I do know what interfaces are but really, what is the diamond problem?
>>
>>52144287
illustrate in pseudocode what you're talking about

at this point, the only alternative I'm thinking of that you might mean is have map inside this one other function, at which point you still have a non-reused function out there
>>
>>52144317
>The "diamond problem" (sometimes referred to as the "deadly diamond of death") is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and C have overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C?
>>
>>52144317
you might want to watch Blood Diamond, it'll open up to you the problem we currently experience with diamonds
>>
File: 1046.jpg (52 KB, 471x694) Image search: [Google]
1046.jpg
52 KB, 471x694
What the fuck is the difference beetween structure and class in c++?
>>
>>52144318
Write the problem without having to use a lambda function.
It's much cleaner.
>>
>>52144287
I want to double each element of an array
Array.map((*)2)

I want to add 5 to process each element of an array
Array.map(processFunction)


You're saying we should do this instead?

Array.mapTimes2 // function that I will only ever use once
Array.mapProcessfunction // function that I will only ever use once

Every time I want a different map I have to write a new non-generic property for the generic Array class?
>>
>>52144086
Because XNA is built on component pattern, it wouldn't make any sense to be able to inherit drawable, updatable, parent et. al classes, without having to copy-paste implementations again.
>>
>>52144346
replace "to add5 to process" with to process
add5 was a redundant example
>>
>>52144345
map takes a function as an argument though

if you're advocating not using map, which is incredibly useful for what it does, just to avoid using lambdas, then you're off your rockers mate
>>
>>52144267
>Map is a member function of an array that applies a function to every element in the array and returns the results

"map" is a function in the Array *module*, not Type.
>>
>>52144344
Nothing, except struct defaults to public and class defaults to private.

It should really be designed so that struct only allows you to create POD.
>>
>>52144379
In the example the other guy gave it was a member function

Imo it should be a member function too in f#
>>
>>52144338
Oh I see, nice
>>
>>52144378
>>52144346
all those years of writing javascript fried your brain m8
>>
>>52144247
>Good luck doing things like image manipulation without unsigned ints.
easy, java has unsigned right shift (>>>)
>>
I've been solving Codewars katas for a while now, and I had a very simplistic Node.js project to implement and test my solutions (Codewars has an absolutely horrible UI for any amount of actualy work), but the whole process of creating two files for both the solution and the test, and entering the details of the kata manually is too fucking cumbersome.

So I'm writing a Yeoman generator to do the stuff for me. It'll basically ask the slug or ID of the kata, fetch its data from Codewars API and generate everything for you. It'll even tell you the Mocha command to run it directly so you don't have to find it out yourself.
>>
>>52144391
>Imo it should be a member function too in f#
disgusting, no.
>>
File: MILLION DOLLAR QUESTION.png (2 KB, 355x301) Image search: [Google]
MILLION DOLLAR QUESTION.png
2 KB, 355x301
I'm going insane because what I thought was sound logic is giving me absurd results.

For collision detection purposes, I need to find the "radius" of a square, or any line from the center of a square to any point on its edge.

My problem is: given a square with sides of length L, and angle [theta] between the radius and the x-axis, find x, the length of the radius.

Mathematically I know the solution should be:

x(cos([theta]) = L/2 (use algebra to solve for x from here)

Yet no matter what I do when I crunch the numbers I keep coming out with a radius greater than L, the length of a side of the square, which should be impossible.

My only thought is that maybe I'm getting a bad [theta] value. Anybody encounter something like this before?
>>
>>52142998
>>52143024
>>52143017
>>52143047
That isn't how coordinates work.
It is (x, y), not (y, x).
>>
>>52144396
What the fuck are you talking about?
You realise this is fucking static and strongly typed, and doesn't lose any performance?

Let me guess, we shouldn't have generics or templates either. We should duplicate as much code as possible.
>>
>>52144396
you haven't been clear in what you've wanted this whole time, illustrate in pseudocode what you want to accomplish

>javascript
never used it
>>
>>52144399
?
>>
>>52144414
I don't want to have to keep typing |> Array.map
>>
>>52144413
in english lad
>>
>>52144425
welcome to the /dpt/, retard.
what is a multidimensional array.
>>
>>52143016
> programming literate
> actually means cargo cult programmer
>>
>>52144437
Illustrate why I would need a lambda function instead of writing it procedurally in the same function, or failing that, utilizing another function or member function of the type i'm working with.
>>
>>52144459
Multidimensional arrays still work in (x, y) idiot.
>>
>>52144425
2d arrays are typically (y, x)

(y, x) as in (row, column)
>>
>>52144490
off yourself you fuckin' sandnigger.
>>
>>52144475
if you're function uses closed variables, then you'd have to pass those variables to every function in the chain. with a lambda you get that for free.

lambdas aren't exactly a controversial subject. you should pick up a CS book sometime, maybe one written in the past 20 years or so...
>>
>>52144448
having it inside every single Array is messy though. Utility methods that transform data types should not be part of that data type. The data types shouldn't have dependencies on the functions that transform them.
>>
>>52144448
>rewrite the map function, but modifying it for purpose for 1 specific instance JUST because you want to avoid anonymous functions

>>52144475
>still hasn't illustrated
have you ever programmed?
>map
>procedural
clearly not

>>52144490
It doesn't you idiot
>>
>>52144475
Illustrate why I would want to use a for loop instead of goto.
Illustrate why I would want to use classes instead of structs with function pointers.
Illustrate why I would want to use C instead of assembly.
>>
>>52144490
        char[][] foo = new char[2][3];
foo[0][0] = 'a';
foo[0][1] = 'b';
foo[0][2] = 'c';
foo[1][0] = 'd';
foo[1][1] = 'e';
foo[1][2] = 'f';
for(char[] line : foo) {
System.out.println(line);
}


abc
def
>>
>>52144518
I'm not him. I'm saying I'd like to be able to use arr.map(function), rather than have to keep writing arr |> Array.map function

alternatively a polymorphic map function would be nice
>>
File: output.png (31 KB, 519x391) Image search: [Google]
output.png
31 KB, 519x391
So it looks like all this shit is being generated correctly for the type, but ppx_deriving is fucking up as far as I can tell, so it derives functions for all of the types in Conglomerate.Hide except for `t`. Which then means that the
let to_string = Hide.show_t
and to_json = Hide.t_of_yojson
and of_json = Hide.t_of_yojson

bit ends up with all those functions unbound and it fails to compile. Literally no clue why this is happening, because `t3_of_yojson` exists (for example). No matter what the structure of the top type ("t"), the deriver never uses it.
That said, all the code on my end works so we effectively have a full type provider.
>>
>>52144582
That's F# for you.
>>
>>52144582
Should have mentioned your issue was language-specific to be fair
>>
>>52144596
You can do polymorphism but it's a pain

static member functions can be polymorphic, and you can do other stuff too
>>
>>52144582
you can always do
open Seq

and then do
arr |> map function
>>
>>52144637
Seq.map doesn't work on arrays
>>
>>52144582
>alternatively a polymorphic map function would be nice
Seq.map
>>
>>52144637
Do you even know what "|>" does or are you just cargo culting?

"arr |> map function" is the exact same thing as "map function arr".
>>
lotta homework questions in here lately lads
>>
>>52144657
It does. It works on all collections.
>>
Is there a good Linux distro purely for programming out of the box? My current desktop isn't well suited to natively run Linux (graphics drivers) but it's more than powerful enough to VM it.

I really can't stand programming on Windows, I suppose I'll eventually have to get over it but that day is not today.
>>
>>52144676
probably some kids with last minute cramming
>>
>>52144667
>"arr |> map function" is the exact same thing as "map function arr".
no shit sherlock
>>
>>52144692
there are no good linux distros sorry
>>
>>52144676
Which is strange because it should still be Christmas break in most western countries.
>>
>>52144707
So why the fuck do you keep using it for no reason?
>>
>>52144690
Didn't realise
Does it return a sequence or the same container?
>>
is piping a meme?

If I knew how to use it with python files, it might be useful
>>
I need some form of opinion from someone about my second ever project, I'm a scrub and I need some guidance.

Would anyone at all who knows the first thing about C# and/or WPF mind looking at my project for me and giving me a dressing down about horrendous decisions. At the moment all I do is make it work, which is fine to a point but I don't want to start developing bad habits.
>>
>>52142851
>>52142851
yeah deitel and deitel are good, dunno if its that particular book but the authors r legit
>>
>>52144716
|> is for making code more readable. You can follow the order of data transformation by reading the code left to right, and top to bottom. So the code could be written like this:
[1 .. 10]
|> Seq.map ((+) 1)
|> Seq.map ((**) 2)
|> Seq.sum
|> (+) 20
|> printfn "%i"
>>
>>52144761
I can understand using it in that case but not for a one-liner.
>>
>>52144726
It accepts an IEnumerable and returns an IEnumerable.
>>
>>52144778
Why not?
>>
>>52144805
Because it's pointless and obscures the currying?
>>
>>52144415
x = (L/2)/(cos theta)
or equivalently
x = (L * cos theta)/2
Is this what you're doing?
>>
File: 1451480180582.jpg (409 KB, 4288x2848) Image search: [Google]
1451480180582.jpg
409 KB, 4288x2848
>>52143016
OOP IN LOO
>>
>>52144778
It's no harm in the one liner either. It's still nice to write code that reads like:
create a list of numbers from 1 to 10
then map that to a new list with each of those numbers squared.

by writing
[1 .. 10] |> List.map ((**) 2)


In any case, it kind of idiomatic F#. And I find myself adding new steps to that sort of code pretty often, so it's nice to have the |> pattern there to start with. Though it certainly doesn't always make sense and I don't always use it. It's just nice.

>>52144812
>obscures the currying?
?
>>
>>52144415

I haven't encountered anything like it, but I believe you're right. Try manually setting up a theta value and see if it comes out correctly. If it doesn't, then maybe it is something else aside from the equation that is adding onto the value. Is everything contained within its own class? Maybe something is randomly being added on.
>>
>>52144812
If you've got an object like an array
arr |> Array.map f
breaks up the object from the function being applied
>>
>>52144822
>x = (L * cos theta)/2
should obviously be x = L / (2 * cos theta)
>>
>>52144847
Imagine somebody new to F# was writing lots of functions that looked like this:
mapAddOne arr = arr |> Array.map ((+) 1)
filterGreaterThanTwo = arr |> Array.filter ((<) 2)

Without the use of the |> operator it's easy to see that you can eta-reduce. If that's how you write idiomatic F# then that's harmful IMO.

>>52144851
See, this is your problem, you're still thinking too OOP-centrically. That's cargo cult nonsense, it's not improving your code if you're not doing something like >>52144761.
>>
>>52144931
If you use algebraic data types, you're using OOP.
An array is an object, and is still an object in FP.
>>
>>52145041
>If you use algebraic data types, you're using OOP.

wrong

fuck off
>>
>>52145041
>If you use algebraic data types, you're using OOP.
You're categorically not. Algebraic data types have no fields or methods, no encapsulation, no subtyping, and no inheritance.
>>
>>52145074
he is baiting
>>
>>52144931
>Without the use of the |> operator it's easy to see that you can eta-reduce.
I'm not following you. The |> operator makes the currying even more obvious if anything. If you know what |> does, then I'm not sure why you could be confused at all by this.
>>
working on redoing an ios app that i'm selling
>>
>>52145052
>>52145074

>inheritance
not necessary for oop

>subtyping
not necessary for oop

>encapsulation
not necessary for oop

>methods
not necessary for oop

>members
product types are this
>>
>>52145107
I'm not confused. I just can't think of a way to justify using the |> operator in cases like >>52144637 or >>52144847 that aren't a holdover from what feels comfortable and OOP-like.
>>
>>52145131
>I just can't think of a way to justify using the |> operator in cases like >>52144637 (You) or >>52144847 (You)
I explained here why they are used. What do you not understand?

>>52144761
>>52144847
>that aren't a holdover from what feels comfortable and OOP-like.
pretend OOP does not exist, then tell me why the reasons i stated for using |> are bad. In F#, nothing OOP related is happening when using the |> operator.
>>
>>52145131
there's literally nothing wrong with OOP
x |> Array.map f
shows that the right side is the function and the left side is the parameter
>>
>If you define a varying variable in a vertex shader, its value will be interpolated (perspective-correct) over the primitive being rendered and you can access the interpolated value in the fragment shader.
if you just want to render a plain solid color, can you use a shader program with no varying variable to skip the interpolation to improve performance?
>>
>>52145122
Oh, it's the "OOP is the best paradigm because I'm going to redefine OOP to include everything" guy again.

>>52145166
Okay, then, it's bad because it's more typing for the same outcome. And it makes it harder to see chances to do eta-reduction.

>>52145170
Array.map is the function. f and arr are the parameters.
>>
>>52145200
>it's bad because it's more typing for the same outcome. And it makes it harder to see chances to do eta-reduction.
yes anon, those are trade offs. So don't use it if reducing you character count by 10-20% is more important than readability. It's not forced on you, it's just an option. haskell has the same operator.
>>
>>52145200
>>OOP includes everything
object oriented programming
that means programming with objects
not programming with objects that have methods and encapsulation and can inherit"

>more typing for the same outcome
It's clearer.

>ar..
Array.map f is itself a function, and it's the function being applied to arr
That's the whole point.
>>
File: 1383455083293.jpg (35 KB, 419x604) Image search: [Google]
1383455083293.jpg
35 KB, 419x604
Aced my school's intro to programming class (it was almost insultingly slow, the codeacademy course covered more), but I'm unsure if I'll be able to keep going to the school for financial reasons.

What are some good learning resources for beginners that know some fundamentals?

As far as long - term goals go, I'm looking more at the software/application engineering/development side of things.

The class was in Python, but I know a smidge of C# due to a few attempts to fumble around in Unity.
>>
>>52144822
>>52144849

Thanks for the feedback guys,

I tried punching in a manual theta of Pi/4 (45 degrees) and I got a consistent hypotenuse, so I have to be getting a wonky theta of some kind.

In Java, I'm trying to use Math.atan2(x,y), where x and y are the coordinates of the center of a square relative to the center of some circle (0,0) it's being checked against for whether or not the two are colliding. If the sum of the circle's radius and the square's "radius" is greater than the actual distance between their centers, then a collision is detected.

The weird part is that I tried using sin() instead of cos() and got the correct "radius" for the square, so maybe the test coordinates I was using had a square that was further up away from the circle than it was to the right of it than I thought.

Anyway thanks again, I guess I'll keep working on it.
>>
>>52145243
>yes anon, those are trade offs
Trade-off implies gain and loss, I'm only seeing losses here.

>haskell has the same operator
That it does, but it's only used in cases like >>52144761, which I already stated I have no problem with.

>>52145244
>that means programming with objects
An object has fields and/or methods. Algebraic data types have neither.

>It's clearer.
Why?

I only ever see it used in that pointless way with F#, which is a functional language with some OOP heritage. So it seems to me like it's just OOP cargo cultism.
>>
>>52145281
learn Haskell
>>
>>52145244
>object oriented programming
>that means programming with objects
>not programming with objects that have methods and encapsulation and can inherit"
no anon, you and me both know that the term "object oriented programming" is meaningless because it has been used in so many contrasting contexts that it has completly lost its meaning

seriously, i'm not even sure anymore how often people on /dpt/ argued the semantics of OOP, which is even more pointless than discussing semantics because there's no definite or even approximately correct answer and people just throw their own definition of OOP as defined by their set of experiences with OOP at others and others throw their pile of shit back

you are all fucking stupid
>>
>>52145299
>I'm only seeing losses here.
read this again >>52144761. You have not made clear why the points I made here not not positive things in your opinion.
>>
>>52145330
I'm talking about the specific cases in >>52144637 and >>52144847. I have already made this clear that I think the usage in >>52144761 is acceptable.
>>
>>52145281
>>52145307
Shouldn't the SICP always be the first recommendation though for anyone who wants to become a real programmer?

https://mitpress.mit.edu/sicp/full-text/book/book.html
>>
>>52145348
I picked up SICP when i first fell for the programming meme, I didn't understand shit.
I know C pretty well now, I still don't understand anything in SICP.
>>
>>52145299
An object has fields.
Product types literally have fields.

I said earlier that it shows that the right side is the function.
Plus, if you've got a match expression or a pattern or something where you can't just use the input binding as the parameter, it shows what's going in to the function.
>>
>>52145345
so what about >>52144847 ? Why do you think there is nothing positive about this?
>>
>>52145322
If you think programming with objects in mind is a poor definition of OOP, that's not my fault
>>
>>52145322
>the term "object oriented programming" is meaningless because it has been used in so many contrasting contexts that it has completly lost its meaning
your assburger is showing
>>
>>52145122
idiot
>>
>>52145371
>Product types literally have fields.
They don't. They have projections, not named fields.

>if you've got a match expression or a pattern or something where you can't just use the input binding as the parameter
What?

>>52145376
Because it's the same fucking thing as
List.map ((**) 2) [1..10]

except it mucks up the order of parameters to make it look like you're calling a "method" of an "object", adds extra typing, and makes eta reduction less obvious.
>>
>>52145384
it is a poor definition because it does not define "object", which suffers this exact issue
fuck off, i don't give a shit about your or one of the other 20,000 definitions for OOP
>>
>>52145409
arguing about something very precise within something very vague is pointless
>>
>>52145368

What people don't tell you is that SICP assumes you have a way of working in Scheme set up and ready to go. That in of itself took me searching for tutorials on just setting up for it.
>>
>>52145436
>except it mucks up the order of parameters to make it look like you're calling a "method" of an "object", adds extra typing, and makes eta reduction less obvious.
Yes you said all that, but I also listed some advantages, which you are claiming are not advantages at all. I'm asking why you think that is so.
>>
>>52145469
I don't know, but it seems like all the advantages except >>52144761 are completely preference-based while all the disadvantages are objective.

This isn't going anywhere, though. If that's "idiomatic F#" then keep doing it because that's what people will expect, I guess.
>>
>>52143793
unsigned is easy (N value bits, mod 2^N-1 on overflow), it's signed that's tricky in C.
>>
>>52145348
>>52145368
>>52145463
Beginner anon here.
I've heard a lot of mixed things about SICP- namely, that it's an incredibly helpful book, but is relatively impenetrable for those who are just getting started.

(I've also found out that MIT themselves replaced the book with something else that teaches Python instead in their own intro prog course.)
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52145502
>You're using |> because of cargo cultism
>there is no advantage to using them like you do
why do you think that is?
>I don't know
Got it. Thanks for the enlightening conversation anon.
>>
>>52145529
Ok can you recommend any brands of rope
>>
>>52145529
What if my language of choice doesn't exist yet?
>>
>>52145529
i don't see javascript or php on there
>>
>>52145529
>- C++
Over complicated bloated rotting dogshit
>- C#
MS botnet
>- Lua
dynamic typing
>- Python
dynamic typing
>- Elixir
dynamic typing
>- Haskell
unusable cultist bullshit bullshit
>- Bash
lol
>- Clojure
dynamic typing
>- D
abandonware
>>
>>52145586
You put your life on hold.
>>
>>52145586
Then it's not on the list, is it?
>>
>>52145599
>Dynamic typing is always bad
>>
File: watdo.png (6 KB, 816x460) Image search: [Google]
watdo.png
6 KB, 816x460
How do I do this shit in Python?
>>
>>52145657
Exclusively dynamic typing is bad. Very bad.
>>
>>52145657
you learn fast anon
>>
>>52145612
It will be on the list when it's done, I promise.
>>
>>52145599
>>- D
>abandonware

LIES! DAMNED LIES
>>
>>52145661
1 write lock 3 read locks
>>
>>52145661
https://docs.python.org/2/library/multiprocessing.html#sharing-state-between-processes
>>
>>52143118
Thanks, stolen and changed it to fit my needs
>>
>>52145695
>systems programming language
>gc by default
>>
>>52145661
A write semaphore and a read semaphore.
>>
>>52145661
https://docs.python.org/2/library/threading.html#condition-objects
>>
>>52145681
Dynamic typing has its purpose, if your writing for speed and/or safety then you shouldn't be using a strictly dynamically typed language anyway, shitting on something for not doing something its not supposed to is retarded
>>
>>52145730
>Dynamic typing has its purpose
It doesn't tho
>>
Is multithreading a meme?
>>
What kind of thread synchronization would you guys recommend for this kind of workload:

Start up N worker threads (N = number of cores)
They start out idle/waiting.
while forever:
main thread says, "ok guys, go do this task"
------ sync point
N threads working...
------ sync point
all finished, display result, keep looping (supposed to be real time, or at least keep displaying things continuously)
>>
>>52145730
What is dynamic typing's purpose?
>>
>>52145754
Yes. Multiple /dpt/ threads should be punishable by death.
>>
>>52145696
>>52145697
>>52145719

Why can't a language implement flagging a variable with something like... state or unscoped or something, and then just make it available for fucking with in any thread.
>>
>>52145767
Try to think about implementing this and you may discover the answers.
>>
>>52145760
Having dynamic types.
>>
>>52145767
multi-processing wasn't part of python's dna to begin with. if you want a language that does look into erlang
>>
>>52145750
>>52145760

nah, your right, instead of quickly prototyping code i should spend ten times the effort fucking around in C only to find out what i want isint practical.
>>
>>52145784
>you can either have dynamic typing or you can have C
Wow.
>>
>>52145767

int x;
auto t = std::thread([&x](){ x++; });
t.join()
>>
>>52145784
c isn't the opposite of dynamically typed 2bh
>>
>>52145791
Did you mean std::atomic<int> x?

>>52145767
You can access the variable from any thread just fine, the problem is that when you have multiple readers/writers, you will run into data race condition, and as such, you need either atomic operations or mutex locking.
>>
>>52145779

On init, pick a location in which memory to store?
Read/Write ops go to that location?
During compile time all references of the variable are set to point to wherever that address is?
>>
>>52145790
C is the defacto goto example for static typing
stop splitting hairs and make a rebuttal or stop posting
Thread replies: 255
Thread images: 32

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.