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

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: 340
Thread images: 29

File: dpt.webm (1MB, 1280x720px) Image search: [Google]
dpt.webm
1MB, 1280x720px
Old thread >>57712158

Official Discord channel: https://discord.gg/xcVHA2Y

What are you working on, /g/?
>>
First for java
>>
java is literally the best language
>>
Name a better language than java
>protip: you can't
>>
If you want a job, you need to learn Java
>>
>>57717239
mah nigga

>king of jobs
>/g/ shits on it
It's like I want to be mad but I'm just too busy drowning in money
>>
>>57717278
this
>>
>>57717275
>not creating your own job with hasklel
>>
>>57717275
>If you want a job and you're stupid, you need to learn Java
ftfy
>>
>>57717291
>salary is lazily evaluated
>>
Currently I am working on implementing algorithms in Java and C.
>>
i worte my irc bot but it's not welcome in teh channel was annoying people.

might start on an irc client or some new project today.
>>
File: 1480187072128.png (521B, 163x209px) Image search: [Google]
1480187072128.png
521B, 163x209px
post a screen shot of the last code you wrote
>>
>>57716952
You need to add the package to you'''re build probably.
>>57717275
Not true but fuck. I had to 'learn' java for my first job.
Thank God for Native.loadLibrary though.
Can do all my 'java' in C instead.
>>
File: SCR_1480266623.png (22KB, 153x608px) Image search: [Google]
SCR_1480266623.png
22KB, 153x608px
>>57717384
>screenshot of the code
i guess sublime is useful for something, picrelated
>>
File: bot.png (180KB, 1366x768px) Image search: [Google]
bot.png
180KB, 1366x768px
i really need to get vim configured properly today as with a better colorscheme.
>>
>>57717384
I can't let you steal my code :^)

its a java try block without a catch or finally, something I read in a book which surprisingly works
>>
File: current project.png (13KB, 658x311px) Image search: [Google]
current project.png
13KB, 658x311px
>>57717384
started programming a few months ago
i think i'm getting there
wrote this without looking at any references
>>
>>57717490
not enough comments. You'll come back to that code in 6 months and not know what you were trying to achieve.
>>
>>57717490
>This stops the program
good chuckle, 7/10
>>
>>57717465
that's a lot of python code
>>
>>57717413
>creating unmaintainable, non portable code

Great way to get fired and ruin the codebase
>>
>>57717536
for you
>>
>>57717536
about 300 lines, not that many.
>>
File: smug dummy.jpg (26KB, 600x628px) Image search: [Google]
smug dummy.jpg
26KB, 600x628px
>>57717465
Great image famalam, good thing you picked a casual's editor.
>>
>>57717466
compare_list = [i for i in txt_file]
>>
>>57717548
Sure, but at least he got to satisfy his autism right?
>>
having a lot of fun with rails
>>
>>57717548
Nah I claimed it was for performance reasons.
And given java it was. Along with the fact that I had to keep everyone else out of the code base to maintain some semblance of code sanity.
>portability
It's perfectly portable C anon. They got the source.

Java is just not made to be run and java programmers are just not made to be employed.
>>
>>57717575
what can you do with rails that you can't do in another language?
>>
>>57717557
>you picked a casual's editor
how dare you, i use Vim. i opened sublime just to take the screenshot of the its little preview thing.
>>
>>57717584
How many C programmers are in the company besides you?
>>
>>57717600
besides me? 213.
it's microsoft.
>>
>>57717600
None were on that project. It was a client application where they basically just wanted to do some online (as opposed to offline in the sense of offline rendering) work to save them money while they were using pajeets for the AWT.

Management was happy. Offered me a lot to stay but you have to aim for happiness.

Not sure what happened with that department. Hopefully all lost their jobs.
>>
>>57717611
You're using Java in Microsoft?
>>
>>57717466
https://github.com/junegunn/seoul256.vim
>>
My girlfriend's learning C# so she can join in with the project I'm working on.

How do I make her leave me alone?
>>
>>57717705
send her tutorials on functional programming with C# and maybe she'll quit
>>
Snake in SFML.
>>
>>57717705
Just pander to her until she realises programming is too hard for her. It will happen sooner than later.
>>
>>57717715
I don't think that will work, she is very persistent.

She asks me to look through her code to help her, and there's comments like
// I love you so much, thank you for helping me <3 xxx

and I just want to punch her in the face
>>
>>57717490
//this kills the developer
>>
>>57717756
>tfw when I'd love a qt gf who wants me to help her learn C#
thanks for making me feel lonely faggot
>>
>>57717705
Tell her you're only into 'useful abstractions' and send her a complete mess of OOP garbage coupled with delegates which you pass around everywhere and overload the assignment operator on (if possible, I don't care for C#).

Seriously just tell her you don't like the idea and hug her hard or dump her.

Why would you keep her if you couldn't even work with her?
You can easily get a fwb in this day and age and you clearly don't care for her at all.
>>
>>57717756
>>I love you
>fuck you
fuck you
>>
Putting the finishing touches and polish on my OS homework. Documentation, test cases, commenting code, etc.
>>
>>57717756
Fuck.
Pack her up and send her to me. I will treat her well I promise.
>>
File: 1448741735544.jpg (20KB, 320x267px) Image search: [Google]
1448741735544.jpg
20KB, 320x267px
>>57717756
That's adorable.
>>
>>57717756
>and I just want to punch her in the face
But why?
>>
>>57717756
shit that didnt happen
>>
>>57717862
>all programmers are social outcasts
Is that the idea?
Or is the idea of a girl being nice to you when you help her just unfathomable to you?
>>
>>57717384
>>
>>57717886
>Or is the idea of a girl being nice to you when you help her just unfathomable to you?
Pretty much this
>>
>tfw programming slave
>have to help relatives son learn programming to get him a job
>paid less than minimum wage
>spent 4 hours on a Sunday writing a solitaire program and explaining every detail repeatedly
This is killing me.
>>
>>57717895
Is mfilter not good for this?
I guess that doesn't give an error message
>>
>>57717433
>having any hope of using legacy stuff on proprietary platforms
Don't be this foolish.
>>
>>57717973
Are you talking about fns? That's quasiquoting, not a list comprehension
>>
>>57718016
Nvm, I was talking about unless but unless is slightly different anyway
>>
>>57717862
maybe she's at uni and learning C# for a course and pretending she wants to help anon so he will spoonfeed her
>>
>he still programs in ALGOL style languages
http://home.pipeline.com/~hbaker1/ForthStack.html
>>
File: subdraw.png (6KB, 465x250px) Image search: [Google]
subdraw.png
6KB, 465x250px
>>57717384

Not very exciting.
>>
>>57718164
>
{
s;
}
>>
File: ricardo-stallmanu-peppers.png (2MB, 1240x930px) Image search: [Google]
ricardo-stallmanu-peppers.png
2MB, 1240x930px
>>57718164

It makes pepper pics.
>>
>>57718186
nice
>>
>>57718175

C# community style is allman. You can hate it, but it's not going anywhere.
>>
File: Capture.png (15KB, 636x182px) Image search: [Google]
Capture.png
15KB, 636x182px
>>57718164
>>
>>57718277
pretty disgusting desu
>>
>>57718308
it's for test generation desu desu
>>
>>57718209
>allman
>all man
This is why we need feminism
>>
>>57718315
>all man
sounds pretty gay
>>
function check(key){
if(!key || key.length != 32) { return false; }

var i = 0, bytes = [], ts = 0, rnd = 0, chs = 0, xor = 0;

for(i = 0; i < 16; ++i) {
bytes.push(parseInt(key.substr((i*2),2),16));

if(i < 4) {
ts += bytes[i] << (i*8);
}else if(i < 6) {
rnd += bytes[i] << ((i-4)*8);
}else if(i < 14) {
xor = xor ^ bytes[i];
}else {
chs += bytes[i] << ((i-14)*8);
}
}

return (ts%rnd == (chs-xor) ? true : false);
};


Is this safe or can you crack it?
>>
How do I take one element out of an array and place it into a new array if it meets certain conditions in c? Right now i have
int function(char array[]){
int res if (game->score1 >= 2 && game->score1 == game->score2 )
res = memcpy(New array, array, strlen(array[1]))
return res;
}
elese{
return 0;
}

But since I dont make the new array in the funtion I am not able to do this, is there anyother way?


}
>>
>>57718277

Java was a mistake :^)
>>
>>57718322
>yoloscript
>safe
>>
>>57717061
Thanks anon. This is the result:
use std::collections::HashMap;
use std::env;

fn main() {
let mut whitelist = HashMap::new();
whitelist.insert("white", vec!["purple", "red", "green", "orange"]);
whitelist.insert("red", vec!["green"]);
whitelist.insert("black", vec!["black", "purple", "red"]);
whitelist.insert("orange", vec!["red", "black"]);
whitelist.insert("green", vec!["orange", "white"]);
whitelist.insert("purple", vec!["black", "red"]);

let args: Vec<_> = env::args().skip(1).collect();

let mut prev_arg_opt: Option<String> = None;
for arg in args {
if let Some(prev_arg) = prev_arg_opt {
if !whitelist[prev_arg.as_str()].contains(& arg.as_str()) {
println!("Boom");
return;
}
}
prev_arg_opt = Some(arg.to_string());
}

println!("Bomb defused");
}
>>
>>57718483
Does Rust(?) not have a way to insert all of those at once?
>>
>>57717275
>Learned Java at university.
>Started working with COBOL.
>>
>>57718506
I couldn't find that in the docs.
>>
>>57718588
How about this
// i don't know rust tuple syntax
for (k,v) in vec![("white", vec!["purple", "red", "green", "orange"]), ..., ... ] {
whitelist.insert(k,v);
}
>>
>>57718647
oh and you could move that vec![("white", vec![...]), ("black", vec![...])] outside and just have

for (k,v) in assocs
whitelist.insert(k,v);
>>
>>57718663
I don't really like that idea. It adds more complexity for a simple problem.
>>
>>57718725
it should be in the library anyway

>>oh just do vec![1,2,3]
>that just adds complexity to a simple problem
>vec.insert(1); vec.insert(2); vec.insert(3);
>>
Is programming compatible with Islam?
>>
File: 1443393146063.jpg (7KB, 196x222px) Image search: [Google]
1443393146063.jpg
7KB, 196x222px
Is there a such thing as using wildcard operators on function calls, specifically in C#? Say I have 5 functions with similar names, like firstFunc(), secondFunc() thirdFunc(), and so on.

Is there a way to call these like *Func() or %var%Func()? If not C# then which language can do this?
>>
>>57718352
Allocate the memory where you need it. Use a vector rather than an array.

Iterate over the container, searching for the element which matches the condition, and when you find it (if you find it), insert it in the vector. Easy.
>>
Why do dynamic languages exist? Is it because there aren't enough programmers who can use static languages?
>>
>>57718790
uh....

If you REALLY want to do that, you can figure out how to do it with reflection.

Why would you want to do this? Sounds like you want to use higher order functions instead.
>>
>>57718828
It would eliminate tons of lines by using a simple iterator through those functions. But thanks, I think reflection might do it for me.
>>
>>57718875
No matter what the problem is, reflection is the wrong solution.

Reflection only exists to work around a bad language's limitations.
>>
>>57718875
How many functions do you need to run?
>>
>>57718816
I have to return it as an array sadly
>>
>>57718816
I don't know the context of the >>57718352 posters function, but it really sounds like >>57718352 wants a linked-list, not a char array.
>>
>>57718904
Around 100, which calls depending on certain user input. This is why I need to iterate through function names instead of writing 100 separate if else's like a fucking monkey.
>>
>>57718929
what does the program do?

Sounds like there should be a much better way of doing that. What do the functions do in general?
>>
what language will help me stop being a useless neet? i've been trying to learn python but anons say it's better to learn C or C++ what to do?
>>
>>57718906
Then you have two choices (well three, but static allocation in this instance is stupid). Accept it as a parameter and allocate it before the function call, on the stack or on the heap.

Or allocate the new array on the heap and possibly set the new size to some predetermined value (possibly size+1 of the input array, or size*2, depending on the circumstances).

>>57718914
Linked lists often have worse empirical run times than vectors due to factors like caching. Even when linked lists have better theoretical complexity, this is often the case. Its not possible to tell really without examining it further, but he says he has to return an array so its probably a homework assignment and linked lists may not even be an option.

>>57718913
Its possible to know of other cultures without being part of them. Its called not being retarded.
>>
>>57717232
that's a lovely discord server you've got there senpai
>>
>>57718993
OCaml
>>
>>57718955
The functions write data to the user depending on what the user picked. It's characters from a game, so each function gives a bunch of different sets of data. So having an iterator through the function names with the data would be infinitely better and more condense than tons of if elses. As said though, reflection might be the solution here, even if it's deemed bad.
>>
>>57718993
Idris

>>57719028
Trash stuck in the 90s

>>57719001
Thou art a Pajeet
Thou shittest in the street
Delete thy post and remain discreet
>>
>>57717275
>If you want a job, you need to learn Java
You misspelled " C hashtag "
>>
>>57719050
>proven wrong
>lol ur a street shitter because i say so!
sure thing retard :^)
>>
>>57718993
Stick to Python. Alternatives being C#, Java, Ruby or PHP. I'm not getting on the merit of the language. It's just that there are a lot of entry level jobs for those languages.
>>
>>57719075
Pajeet code:

try {
/* ... */
} catch (Throwable t) {
// catch the exception to stop the program crashing
}
>>
>>57718775
With all of the pushes for women in tech it won't be soon.
>>
>>57719075
Found this on Friday, did you write it?

} catch (Exception e) {
throw new Exception("An error occurred executing the process.");
}
>>
>>57719042
what is the UI like? Is it like a combo box, and matching a value of the combobox to a certain function? Matching the name of a string the user selected with a function?
>>
>>57718313
Even more disgusting
Why can't you just write Java code that calls other Java code for your tests?
>>
>>57719197
basically it's like if combobox.text == character name string, then call function, but multiple that by 100 for each character function. Been trying to think of ways to make it as concise as possible for the sake of maintaining pretty code
>>
>>57719291
why not have
combobox.value = actualFunctionYouWantToCall
?
>>
StringBuilder sb = new StringBuilder();
sb.add("There was a" + (ex instanceof Exception ? "n exception" : " throwable") + " thrown when f was called with" + (a != null ? " a = " + a.toString() : "") + (a != null && b != null ? "," : " null arguments") + (b != null ? " b = " + b.toString : "") + " " + ex.getMessage());
return sb.toString();
>>
>>57719042
Nigga put the functions in classes as methods and put class instances in a list and look up an instance from the list, this shit is OOP 101
>>
>>57719001

Did not see the >>57718906 reply. My guess is homework assignment as well. When you say vector, that might be dependent on the libraries and versions for/of C available to >>57718906 . If it was a homework assignment, the original poster might not quite be to the point of making vectors in C by hand yet.
>>
>>57719327
kys
>>
>>57719349
Hime why do you never cast the return value of malloc?
>>
File: Screenshot (9).png (82KB, 763x787px) Image search: [Google]
Screenshot (9).png
82KB, 763x787px
>>
>>57719327
that's not how you use stringbuilder
>>
>>57719383
That's the joke
>>
LocalDate getTomorrowsDate() {
Thread.sleep(25 * 60 * 60 * 1000); // extra hour to handle daylight savings time
return LocalDate.now();
}
>>
>>57719327
>there was a throwable thrown
>>
>>57719446
Yes?
>>
>>57719371

You /can/ cast the return value of malloc. You never do it in C because you don't need to. Ideally, wouldn't you just be checking for a failure (NULL) when malloc returns? If you are malloc'ing something that fits into the size of a double, why would you cast your thing to an int or a char?
>>
>>57718784
I said nazi or nazi sympathizer. I'm sorry for you if you can't understand why posting nazi flags is not innocent.
>>
>>57717756
Your girlfriend is reddit
>>
>>57719602
>history book depicts swastikas
>HURR NAZI SYMPATHIZERS!!!!
>>
>>57719619
You're stupid.
>>
File: image.png (185KB, 1680x1050px) Image search: [Google]
image.png
185KB, 1680x1050px
>>57717384
Exploring the deepest, darkest corners of Racket.
>>
>>57719642
>old memes in the window

kys
>>
>>57719642
>unreadable meme font
>>
Currently learning what pointer variables are and how to use them. Just finished this:
http://pastebin.com/BHifhu3u


Sample run:
Enter a fraction [a/b] (negative value to exit): 
16384/2048
1: 16384 % 2048 = 0 GCD found.
------
Reduced: 8/1

Enter a fraction [a/b] (negative value to exit):
346/56
1: 346 % 56 = 10
2: 56 % 10 = 6
3: 10 % 6 = 4
4: 6 % 4 = 2
5: 4 % 2 = 0 GCD found.
------
Reduced: 173/28
>>
>>57719637
Why do liberals always do shit like this? Like, say "you're stupid/you're racist/you're a bigot" but not give any reason for why they think that?

Why would someone say things like that? Do they just say to convince themselves?
>>
>>57719602
Swastikas have literally existed since at least the early Stone Age. Depicting a swastika != Posting a Nazi flag
>>
>>57719697
When they say that, you know that they've lost.
>>
https://www.reddit.com/r/dailyprogrammer/comments/55nior/20161003_challenge_286_easy_reverse_factorial/
use std::env;

fn main() {
let num = env::args().last().unwrap().parse::<i32>().unwrap();
match is_factorial(2, num) {
Some(x) => println!("{} = {}!", num, x),
None => println!("{} NONE", num),
};
}

fn is_factorial(mut i: i32, mut x: i32) -> Option<i32> {
if x % i != 0 {
None
} else if x / i == 1 {
Some(i)
} else {
x /= i;
i += 1;
is_factorial(i, x)
}
}
>>
>>57719697
No. I'm delimiting sides. Those who agree for posting "innocent" swastika and those who think nazi must be fought.
>>
>>57719766
I'm on the side against censorship.

Some of my friends are the nicest people you'll ever meet, they deplore Nazi ideology, but they wear Nazi uniforms because it's the only way they can cope with their agoraphobia and fear of public speaking and social situations.
>>
>>57718813
>draw a swastika in 6th grade english
>teacher calls me a nazi and makes me pay reparations to the school
>>
>>57719766
What the fuck are you even saying now? You're so coked up on important liberal rage you've lost the ability to form coherent sentences. Go play minecraft for a few hours until you calm down.
>>
>>57719806
>get school lunch
>alphabet pasta
>lunch lady slops it into my bowl
>go sit down
>snotty kid sitting next to me notices my pasta has sort-of formed the sequence of characters "HEILHITLER"
>he runs and squeals to a teacher
>I get detention
>>
Working on a database project. Making a website that's basically a text board version of 4chan.
>>
>>57719766
>believing the holohoax
>being this much of a good goy

wew
>>
>>57719821
>important liberal rage
I think you mean 'impotent', or maybe 'self-important'.
>>
>>57719602
If I post my waifu are you automatically going to assume I'm actually married to her?
>>
>>57719766
No one's arguing whether a swastika is harmless, you mental midget. We're just calling you retarded because you think posting a swastika on 4chan signifies that someone is a nazi.
>>
>>57719849
>Be 1896
>Write "Heil Hitler" in my best writing
>Show my teacher, Mrs Goldenstein
>"You're handwriting still isn't improving, Adolf," she says to me
>I'll show her.. I'll show them all
>>
my program segfaults and i am unsure of where the problem is happening

what tools can i use to solve this?
>>
>>57719988
valgrind
>>
Nice job on the derail swastika guys. It really helped this /dpt/ thread.
>>
>>57720014
Thanks
>>
>>57720014
any time
>>
 None
} else if x / i == 1 {
Some(i)
} else {
>>
>>57720014
I'd argue it's the anon that was triggered by a swastika on 4chan that derailed it.
>>
>>57720014
>Complains about derailing
Inadvertantly keeps up the shitposting, resulting in (at the time of this post) 5 more derailing posts.
>>
Hey /dpt/
do you still argue about color schemes sometimes?
if you have nothing better to do please post your color schemes
I need inspiration, I'm bored by my color schemes
and what font do you use to code?
>>
I'm making a C library with unit testing and CMake. I've got a CMakeLists.txt in the root, src and tests directories. When I try doing an out-of-source build in a 'build' directory located in the root, it compiles the library and the tests in their source code directories. Any tips?
# /CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
project(MyLib)
enable_testing()
add_subdirectory(src)
add_subdirectory(tests)


# /src/CMakeLists.txt

include_directories(.)
set(SRC
MyLib_core.c
)
add_library(MyLib ${SRC})


# /tests/CMakeLists.txt

enable_testing()
find_package(Check REQUIRED)
include_directories(${CHECK_INCLUDE_DIRS})
set(LIBS ${LIBS} ${CHECK_LIBRARIES} MyLib)
include_directories(. ../src)
set(TESTS
MyLib_core.c
)
add_executable(test_MyLib ${TESTS})
target_link_libraries(test_MyLib ${LIBS})
add_test(test_MyLib ${CMAKE_CURRENT_BINARY_DIR}/test_MyLib)


It works when I run CMake on either subdirectory, but not the root. Is add_subdirectory forcing it to compile in source?
>>
>>57720100
Times New Roman
>>
File: tsdare.png (2MB, 1360x1200px) Image search: [Google]
tsdare.png
2MB, 1360x1200px
>>57719685
Font is readable. Always check with the unscaled picture (https://i.4cdn.org/g/1480275006950.png)

>>57719682
I don't get it.

>>57717756
>not having a programming literate tsundere gf
>>
>>57720100
>inb4 >>>>>>>code
>>
>>57720080
>Inadvertantly

You sure about that? He's doing it on purpose and then feigning ignorance.
>>
>>57720116
I did look at the full picture, it's unreadable garbage, not at all comfy, I have to strain my eyes to make sense of it.
>>
>>57720130
>unreadable
*illegible
>>
>>57720080
I'm not complaining, I'm praising. Are you reading sarcasm where it shouldn't be?
>>
>>57720116
awful font and colors
>>
>>57720100
I write in zapfino.
>>
>>57720158
how does derailing a thread help it?
>>
>>57720180
flood of postings and it's constantly on page 1
>>57720178
nice
>>
>>57720120
I didn't agree with the use of this word as I wrote it, but I couldn't think of the correct word used to portray what I really meant, so I used said word instead.
As I'm writing this, I am still thinking of the word I should use, but I don't know what it is.
A word not as strong as purposely, but not as abscent minded as inadvertantly. Somewhere inbetween.
Let me know if you have any suggestions.

>>57720158
>Are you reading sarcasm where it shouldn't be?
I am not
>>
What is the use of ContT?
>>
>>57720178
literally the only good font for programming
>>
>>57718483
Small nits:

use std::collections::HashMap;
use std::env;

fn main() {
let mut whitelist = HashMap::new();
whitelist.insert("white", vec!["purple", "red", "green", "orange"]);
whitelist.insert("red", vec!["green"]);
whitelist.insert("black", vec!["black", "purple", "red"]);
whitelist.insert("orange", vec!["red", "black"]);
whitelist.insert("green", vec!["orange", "white"]);
whitelist.insert("purple", vec!["black", "red"]);

let mut prev_arg_opt: Option<String> = None;
for arg in env::args().skip(1) {
if let Some(prev_arg) = prev_arg_opt {
if !whitelist[&prev_arg].contains(&arg) {
println!("Boom");
return;
}
}
prev_arg_opt = Some(arg);
}

println!("Bomb defused");
}


env::args()
already produces an iterator over strings, so there's no need to collect them into a Vec and arg is already a String, the call to
.to_string()
is needless.
Also, if you have String foo and call something that expects a
&str
, you can just use &foo instead of foo.as_str(), due to how the Deref trait works.
>>
>>57720162
it's randomized every time i type a character.
>>
>>57720205
Continuations. You can do loads of cool stuff, it's like goto on meth
>>
File: sp-720.png (73KB, 720x315px) Image search: [Google]
sp-720.png
73KB, 720x315px
>>57720100
>and what font do you use to code?

Fira Mono. It feels a lot like Consolas, except it hints correctly on linux and isn't license-pozzed.
>>
>>57720049
?
>>
I'm making a program that takes a large grayscale image and a smaller image and tries to find segments of the larger image that are similar to the smaller image. I was thinking of converting both image to 2d arrays and then go through the larger array in segments of the size of the second array and find the sum of squared differences for each of the segments.

Is this a retarded idea? Are there any better methods?
>>
>>57720103
Ah, figured it out. Had to add a binary path to the subdirectory commands.
>>
>>57720264
I forgot to add, there is a version called "FiraCode" that is mono but it has ligatures for common programming stuff such as "==", if you're into that sort of thing.
>>
How would I use perlin noise to make a simple game map in Processing? This is what I have now, but it produces repeating patterns which I obviously don't want:
for(int i = 0; i < 600; i++){
for(int j = 0; j < 600; j++){
map[i][j] = noise(i, j);
}
}

I read that if you use perlin noise in loops, you need some step value, but I didn't understand what I was supposed to do. Any suggestions on how to fix it.

*noise() is perlin noise, not simplex noise
>>
File: 2016-11-27-153226_566x433_scrot.png (17KB, 566x433px) Image search: [Google]
2016-11-27-153226_566x433_scrot.png
17KB, 566x433px
>>57717384
>>
>>57720178
can you showcase more haskell with that font?
show something with guards
something with bind, or apply, any of those "unreadable" haskell symbols
>>
>>57720238
this really bothers me, but is it possible to put the function name outside the list?
>>
Make is a very nice development ecosystem, the only thing it lacks is a decent build automation tool.
>>
>>57720687
(define add (lambda (x y) (+ x y)))
>>
>>57717895
Dear god Haskell is such a ugly piece of shit language, worse than C++ at this point. The core devs apparently cant say no to any PhD and merge all kinds of ridiculously extensions into the language.
>>
>>57720713
so I can do
(define penis (girth inches) ...)
instead of
(define (penis girth inches) ...)

with no problem?
>>
>>57720690
hmm, maybe
!whitelist[prev_arg.as_str()].contains(&&arg)
?
>>
>>57720726
>haskell
>unreadable
>>
>>57720736
That doesn't work either:
error[E0308]: mismatched types
--> src/main.rs:16:55
|
16 | if !whitelist[prev_arg.as_str()].contains(&&arg) {
| ^^^^^ expected str, found struct `std::string::String`
|
= note: expected type `&&str`
= note: found type `&&std::string::String`

error: aborting due to previous error

error: Could not compile `293-easy`.

To learn more, run the command again with --verbose.
>>
>>57720726
They aren't 'merged into the language', that's what makes them extensions. They're often merged into the compiler, and then users can test them.
A lot of extensions should be standardised, imho.
>>
>popular linear algebra library
>cant assign a value to a coefficient individually, have to create a new matrix/vector
yes i fucking mad
>>
>>57720731
no, not in racket.

note that with clojure and common lisp, it's

(defun name (args) ...)
>>
>>57720764
>matrix/vector
>needing a library
what else do you need from that library that you use that shit?
>>
>>57720756
Well, huh, just use .as_str() then.

I think it's because deref coercion only works on &str, not on &&str.
>>
Do programs written in strongly typed languages actually contain less bugs?
>>
>>57720873
100% of the time.
>>
>>57720873
Yes.
>>
>>57720873
And if it's written in COQ it contains 0 bugs (don't argue, it's true).
>>
File: lispbest.jpg (253KB, 840x412px) Image search: [Google]
lispbest.jpg
253KB, 840x412px
>>57720873
>>
>>57720918
clojure is not lisp
>>
>>57720908
can you write gui in coq?
>>
>>57720671
Isn't it gorgeous? Code is absolute nonsense, but it highlights many of the common operators used in haskell.
>>
>>57720940
You can write anything in any language anon.
>>
>>57720873
At runtime, yes. Type checking is done at compile time.
>>
>>57720918
Is Clojure strongly typed?
>>
>>57720803
>deref coercion only works on &str, not on &&str.

&*str
>>
>>57720936
http://clojure.org/
Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system.
>>
>>57720873
>less bugs
>less
Fewer.

You can't even write in English without bugs.
>>
>>57720961
no

>>57720956
wrong
>>
>>57720992
less is for R and few for N?
>>
File: bug-density-no-filter.png (8KB, 483x331px) Image search: [Google]
bug-density-no-filter.png
8KB, 483x331px
>>57720873
No, Haskell is as bad as Javascript.
>>
File: nice pizza.gif (387KB, 206x210px) Image search: [Google]
nice pizza.gif
387KB, 206x210px
>>57720955
>>
>>57717232
>Threa
>>
>>57720962
error[E0308]: mismatched types
--> src/main.rs:16:55
|
16 | if !whitelist[prev_arg.as_str()].contains(&*arg) {
| ^^^^^ expected &str, found str
|
= note: expected type `&&str`
= note: found type `&str`

error: aborting due to previous error

error: Could not compile `293-easy`.

To learn more, run the command again with --verbose.
>>
>>57721010
not its not, faggot
>>
>>57720974
It's not a real LISP unless it's made by a Jew. Rich Hickey is English and therefore only a Jew in spirit.
>>
>>57721010
>Unlabeled X-axis
>>
>>57720956
theoretically, but realistically, can I do it?
>>
>>57721025
Get schooled cuck

http://labs.ig.com/static-typing-promise
>>
>>57721003
Pretty much.
>>
In Javascript, I have something that calls a function which has a number in the middle of its name: uniformMatrix3fv.
Can I make this "uniformMatrix (dimension+1) fv"?
I tried uniformMatrix[dimension+1]fv but surprisingly it didn't work.

Also, I don't know much about Javascript compiling, so is that significantly less efficient than an if statement that chooses between 3 and 4 fv?
>>
>>57721040
Yes. It's just a functional language.
>>
File: gmZLebD.png (13KB, 842x411px) Image search: [Google]
gmZLebD.png
13KB, 842x411px
So, the output of this shit is
"44, 44, 44, 44, 55, 44 occurs 4 times, 66, 55 occurs 1 times"

How do I do like
"44, 44, 55, 55, 66, end
44 occurs 2 times
55 occurs 2 times
66 occurs 1 times"

I am borderline retarded and have no idea. Should I use case with arrays? Any tips?
>>
>>57720992
this is my kind of autism
>>
>>57721043
this is fake
>>
>>57720992
>>57721003
Imagine having different > and < operators for integers and floats.
>>
is calloc faster than a stack char buf[] then memset?
>>
>>57721105
http://danluu.com/empirical-pl/
>The summary of the summary is that most studies find very small effects, if any.
>>
>>57721111
We call that OCaml.
>>
>>57721131
but, it compiles, so it works..
>>
>>57721105
Type correctness does not equal program correctness, Haskell cucks will deny this.
>>
>>57721022
Well, you DID coerce it. Now you just need the correct level of indirection.

&&*arg


I must confess that I've not worked much with hashmap and strings in Rust. I kinda feel there is a simpler solution to this whole mess. I'm also too lazy to read your whole reply chain, so I have no idea what you're actually doing. I'm just going off the error message.
>>
>>57721161
You don't know what is Coq.
>>
>>57721161
see>>57721152
>>
>>57721188
I don't consider theorem provers that are not turing complete programming languages.
>>
>>57721188
It's what I gave your mother last night.
>>
>>57721172
&&*arg works
>>
>>57721207
You're more and more ridiculous. They wrote a C compiler in Coq.
>>
Linear types.
>>
>>57721188
Coq? Is that something for Cuqs
>>
>>57721188
if you develop a type system that is able to prove all correct programs to be correct, you guaranteed to receive the next Turing award.
>>
>>57721161
Not in Haskell, no.

>>57721267
That's impossible but also not necessary.
>>
File: kys.jpg (66KB, 500x509px) Image search: [Google]
kys.jpg
66KB, 500x509px
are there actual assembly wizards browsing /dpt/?
>>
>>57721010
Okay, so I reversed image searched that.

This is bug density. Static typing is a time saver in larger projects and that is it's major benefit (minus the speed/memory usage improvement).

But that is STATIC vs DYNAMIC typing, which has DICK ALL to do with STRONGLY vs WEAKLY typed languages, you fucking mong.
>>
>>57721234
And yet they cant figure out how to write a "while (true)" loop
>>
File: 1449700279793.png (74KB, 300x256px) Image search: [Google]
1449700279793.png
74KB, 300x256px
>X only works in 99.9% cases so it's useless
That's 99.9% of code that cannot be a source of a bug.
>>
File: powerofrust.png (158KB, 1235x813px) Image search: [Google]
powerofrust.png
158KB, 1235x813px
>>57721279
I crafted some stuffs in assembly like my own RC4 implementation to secure my data/communications.
>>
>>57721121
Yes and no.

mmap is lazy so a calloc call actually only reserves address space and defers the RAM allocation and zeroing until you first try to access it. Memset will do that immediately, so it will be MUCH slower than the calloc call. But essentially the same time will be used later when the calloced memory is first accessed.

Still, calloc is superior in some ways here since if you end up never touching what you've allocated (it can happen) then you haven't wasted time zeroing RAM.

That's how it works on systems with paged virtual memory anyway.
>>
>>57721326
Also that's just in practice right now, where FFI is necessary. If the OS and everything were programmed with such a language from the ground up, any issues would be down to a mismatch between the hardware specification and the hardware itself.
>>
Why does everything user zlib? Is it that great?
>>
>>57721414
Nu-FOSS fags who aren't decisive enough to use the GPL.
>>
>>57721353
fuck C man

so glad I use a high level language and don't have to think about shit like this
>>
>>57721447
C gives you the freedom to choose. High level languages just go "fuck it, malloc is good enough most of the time, here you go".
>>
>>57721428
I meant the library, not the licence.
>>
>>57721478
c also takes 20 years to master
>>
>>57721497
So it has a higher skill cap, what's your point? You can do more with it than you can in higher level languages.
>>
How do I escape with an asterisk in Java? I want a readLine loop to end once it hits a String of "* *".
>>
>>57721543
what if I want to build quick applications?
what if I want to do things an elegant way
>>
>>57721543
>You can do more with it than you can in higher level languages
k tard
>>
Where do I go to learn how to make fast/optimal programs? Like O(n) and lower stuff? I've just been writing things to work and not pay attention to time/space complexity
>>
>>57721543
C is a high level language. The whole "closer to the metal" thing is a meme. It's close to a 1960s-1970s abstraction of a computer which is unlike the way modern computers operate.

The only reason it's slightly more performant than alternatives like Rust is decades of compiler refinement and optimization.
>>
>>57721543
>You can do more with it than you can in higher level languages.
Describe one program that I can write with C that I can't write with python.
>>
>>57721620
>higher
>>
>>57721620
exactly, assembler is high level as well, tru haX00rs only use machine code
>>
>>57721657
Except assembly is actually close to the metal being architecture-specific.
>>
>>57721588
>what if I want to build quick applications?

I would say anything worth doing is worth doing right. And although not every program should be in C, doing something "quick" should be reserved for things you plan to throw away.

>elegant
don't make me laugh

>>57721620
I'm not saying "everything should be C". Calm your 'tism. You're arguing against something I'm not even implying.

>>57721597
>>57721630
Anything below the kernel level, you dunce. You need languages like C to make your stupid abstractions.
>>
>>57721687
why don't you like elegant?
>>
Does tfwnogf hinder your programming efficiency?
>>
>>57721687
Done quickly and released trumps done right and incomplete every single time.
>>
>>57721630
Anything with hard real-time constraints.
>>
>>57721742
Until it breaks and you get sued
>>
>>57721732
Because it's a word script-fags use to masturbate to their own creation, even though it's full of buggy edge-cases that they glossed over.

>>57721742
Nice false dichotomy.

>>57721752
Also a good point. Although, things like java could still accomplish that with a lot of work making sure that GC doesn't run.
>>
>>57720873
>>57720918
CORRELATION
DOESN'T
IMPLY
CAUSATION
REEEEEEEEEEEEEEEEEEEEE

>coffeescript has the most bugs
lmao
>>
>>57721740
I had to make my own tea and food when I was single and now my wife does it for me while I focus on programming.

I would be ironing my shirts for the coming work week three years ago but she is doing that at the moment while I refactor my code and shitpost on /g/.
>>
>>57721786
It's also going by github issues, which a lot of the time aren't even bugs, just people bitching about documentation and such.
>>
>>57721787
why are you calling your mom your wife
>>
The real question is: is there anything you can do in C that you can't do in Rust?
>>
>>57721828
My mum never ironed my clothes past my early teens tbqh. I had to do it myself.
>>
>>57721619
Start by learning the time complexity for operations on common containers (list, vector, btree, etc). Learn why comparison-based sorts can't be faster than O(n.log(n)).

Learn to figure out lower bounds on the time complexity of a problem; e.g. any algorithm which has to "touch" every element in a container can't be faster than O(n).

Ask yourself if you could make the algorithm faster if you had an "oracle" which could provide information in O(1) time, then figure out how you might create such a thing (or at least a close-enough approximation to it). E.g. if you keep asking the same question repeatedly, a cache will give you an O(1) answer for anything already in the cache.
>>
>>57721822
I was thinking something like this, at least, the graph we see is # of repositories vs # of _reported bugs_

>>57721838
I think custom memory allocation is a bitch in Rust, although I'm sure it's possible with a lot of unsafe{} blocks
>>
>>57721828
I do the opposite. I call my wife mom.


And she calls me dad.
>>
>>57721619
You start by ignoring all that shit and profile your code like a pragmatic empiricist, using tricks to make it faster where it is slow, you don't masturbate over complexity classes like a comp.sci/mathtard.
>>
>>57721884
Complexity is the low hanging fruit of optimization, though.
>>
>>57721838
Unions
>>
File: 220px-Oedipus.jpg (13KB, 220x289px) Image search: [Google]
220px-Oedipus.jpg
13KB, 220x289px
>>57721872
>>
>>57721687
>below the kernel level
You mean things like embedded systems? Genuine question.
>>57721752
I still can write the program in any high level language, it will just have worse latency, but my point was that there isn't anything C can do that high level langs can't. Not whether C can do it better.
>>
>>57721906
It's always been possible to do something equivalent with transmutation, and now Rust has unions, too.
>>
>>57721884
>Like a compsci/mathtard

Wew, fail your major?
>>
>>57721919
>there isn't anything C can do that high level langs can't.
Ever heard of turing completeness?
You can do anything in lambda calculus, SK combinations, or fucking brainfuck. This is a worthless discussion
>>
>>57721864
No more than in C. You only need unsafe for calling e.g. malloc, free, doing pointer arithmetic, etc.

>>57721919
Some languages may literally not be able to meet certain constraints for a given problem.
>>
>>57721781
> things like java could still accomplish that with a lot of work making sure that GC doesn't run.
It needs more than that. You also need O(1) allocation, containers with predictable worst-case access (no unbalanced trees or hash tables which rely upon collisions being "statistically unlikely"). And you need everything in physical RAM (i.e. everything relevant mlock()ed).
>>
>>57721956
> What are non-functional requirements?
>>
>>57721786
CoffeeScript is weakly typed tho
>>
>>57721973
RAM is too slow.

Open your third eye and become cache-aware.
>>
>>57721630
high throughput code that doesn't cost all your processing power, for example filesystems. multi threaded anything, because global interpreter lock. any non-shit game that pushes your CPU and GPU to the limit.

basically anything that needs to do any heavy lifting whatsoever. and yeah, pypy will get you some of the way it still isn't fast enough for many tasks
>>
>>57720873
yes
>>
>>57721912
Jealous?
>>
>>57721956
>This is a worthless discussion
Yeah, but that other guy said you can do more in C, and my mission in life is to monitor /dpt/ and prove people wrong.
>>57721962
>Some languages may literally not be able to meet certain constraints for a given problem.
Could you elaborate?
>>
>>57721862
Will I need strong math skills? I struggled with calc
>>
>>57721973
>containers with predictable worst-case access (no unbalanced trees or hash tables which rely upon collisions being "statistically unlikely").
How does this not apply to C?

>>57721996
Yes, they are important, but >>57721919 was trying to argue about what C and other languages "can do", not about what tasks they can accomplish.

>>57722008
I agree that weakly typed languages make it easier to introduce bugs but that graph doesn't prove anything, and is a good example of very weak statistics.

>>57722052
>Yeah, but that other guy said you can do more in C, and my mission in life is to monitor /dpt/ and prove people wrong.
A noble goal.
>>
>>57721787
smelly, ugly poo in loo pajit detected
>>
>>57721903
> Complexity is the low hanging fruit of optimization, though.
Yes, in the sense that it can potentially give massive speed increases with relatively little effort (compared to low-level stuff which gives you a 1% speed-up for every day you spend on it).

No, in the sense that if you have a complete project created without much thought having been given to time complexity, you may not be able to significantly improve the time complexity without a complete re-design and re-write.
>>
>>57722068
>that graph doesn't prove anything
it does imply things though
>>
>>57722052
I think it's pretty easy to see that if the optimal C program barely meets time and space requirements, any interpreted and garbage collected language will not even come close.
>>
>>57722078
I'm Polish.
>>
>>57722091
No, it hardly even suggests anything.
>>
>>57721687
>Anything below the kernel level, you dunce. You need languages like C to make your stupid abstractions.
No, you don't need C for that. Case in point: https://en.wikipedia.org/wiki/Genera_(operating_system)
>>
>>57722116
It suggests langugaes have a relationship with the amount of bugs a project is likely to have per commit
>>
>>57722128
There's no way it actually is all written in LISP. You need assembly even to hook into the very low level shit needed to make an OS from scratch.
>>
>>57722091
Since the "bugs" are determined by how many GitHub issues there are it could just as easily be implying that nobody uses libraries or applications written in the languages with a low frequency of "bugs".
>>
>>57722217
Could be. Could also be the langugaes are a factor.
>>
>>57722198
According to the wikipedia article:
> Genera is a commercial operating system and development environment for Lisp machines developed by Symbolics
The hardware was actually built to run Lisp. Lisp pretty much /is/ assembler for those.
>>
>>57720873
Yes, but unless you are using a dependent type system types will only catch trivial bugs.
>>
>>57722269
What's a "trivial bug"?
>>
>>57722198
ZetaLisp could generate machine code for Lisp Machines directly. There was no assembly on that hardware.
>>
>>57722243
>>57722288
Why would anyone build a lisp machine? What's the point of these over a x86?
>>
>>57722301
When the first Lisp Machine was produced, x86 barely existed yet. Read up on the history of MIT AI Lab if you want to know why these were built.
>>
Rate my 4chan popularity sorter
var posts = Array.from(document.querySelectorAll(".replyContainer"));
posts.forEach(element => {
element.popularity = element.querySelectorAll(".backlink a").length;
element.parentElement.removeChild(element);
});
posts.sort((a, b) => {
return b.popularity - a.popularity;
});
var thread = document.querySelector(".thread");
posts.forEach(element => thread.appendChild(element));
>>
>>57717232
fuck this reddit tier op image
>>
>Cheated on my programming test today

I hate myself
>>
>>57722269
>>57722284
It's hard to define what bugs can and cannot be caught by a particular type system without overhead.

An example of something that requires dependent types to catch is out-of-bounds indexing where the bounds are determined dynamically. In order to write a statically safe array indexing function, you need to say that the input index must be proven to be less than the length of the array you're indexing. Because proofs are values and propositions are types, you need this length at the type level, which means if you want it to be determined dynamically you need dependent types to get it there.
>>
>>57722528
i hate you too
>>
>>57722528
how?
>>
>>57722528
>teacher told us to disconnect our rj45's and not Google
>I didn't disconnect it
/D E V I L I S H/
>>
>>57722528
Good.

I'm a professional programmer and I cheat every day.
>>
NEW THREAD

>>57722586
>>57722586
>>57722586
>>57722586
>>57722586

NEW THREAD
>>
>>57722464
not bad
>>
>>57722551
The tests for my course are exclusively "What is the output" questions so I just copy and pasted the code into an inline compiler.
>>
>>57722169
Who's to say the usage of git is similar between the different programming cultures the languages foster?

Many C programmers are ultra conservative because (I speculate but in my own experience with people) they've been burned so many times.

Developers file a large chunk of the issues. So, yeah.
>>
>>57722611
>what is the output
Eh, they deserve to be cheated on. Don't feel bad. You're not being tested on the skills that matter.

It's true that understanding the operations is good and those operations in sequence lets you understand your output. But it's not the only way to program.

I hope you cleared the shell command history though.
>>
>>57717384
It's spaghetti
>>
have to write a game for uni
it's shit, the rules are shit, it's total ass and I hate it
we aren't allowed to use anything, no libraries, no methods on strings or anything
this is so disgusting
and it's in java
I hate my life
>>
>>57722784
Use it to learn to be efficient
>>
>>57722784
hahahhahaha
>>
>>57722784
but that's the c way, anon, you just have to adopt that lifestyle, otherwise you'll be a code monkey
>>
>>57722784
Your uni is shit, otherwise it would let you chose the language.
>>
>>57722828
we can, in higher terms
>>
>>57722651
>They're not testing you on the skills that matter

That's what I told myself too, here's hoping I'm right
>>
>>57722981
But java is shit.
>>
>>57721903
In some cases. In my experience you get a lot more out of just knowing your requirements and how your software performs in the real world. Turning an n^2 problem into a log n problem is a waste of time if n will never be large and you're doing IO n times when you shouldn't be.
>>
best book on php?
Thread posts: 340
Thread images: 29


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