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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 313
Thread images: 31

File: 1487784419585.jpg (222KB, 914x1200px) Image search: [Google]
1487784419585.jpg
222KB, 914x1200px
What are you working on, /g/?

Old thread: >>59338603
>>
First for Java
>>
Programming in a language without I/O
is the ultimate proof that you actually program purely for fun.
>>
>>59342491
OOP = pOOP
>>
File: monads.png (797KB, 793x670px) Image search: [Google]
monads.png
797KB, 793x670px
>>
With the risk of sounding like a retard I will ask this question:

I am a NEET who doesn't want to leave the house. All I do is read books, but a writing career is almost impossible so I can't bank my hopes on that.

I have tried learning programming before, but I just couldn't wrap my mind around it and gave up. I guess I was just being an idiot, getting frustrated, and then quitting. I would like to pick it up again, but with the express reason of getting a job. The language must meet the following criteria: fast to pick up, makes me money.

What should I look into?
>>
>>59342520
Java
>>
>>59342520
Java
>>
Idris > Haskell > other languages
>>
>>59342520
Lisp
>>
File: 1456053172552.jpg (9KB, 199x185px) Image search: [Google]
1456053172552.jpg
9KB, 199x185px
>>59342491
Hey /g/uys i want to learn how to start in programming, where should i start if i don't know literally anything?
>starting from the bottom
>any tips for a beginner?
>>
>>59342520
mcdonalds application
>>
>>59342534
Idris < Haskell < Python < other languages
>>
>>59342536
Python
>>
>>59342534
>Idris
Trash.
>Haskell
Trash.
>>
>>59342524
>>59342525

>>59342535

Can you tell me more?

>>59342537

God no.
>>
>>59342536
https://docs.oracle.com/javase/tutorial/
>>
>>59342491
Way back in the day for fun I programming a toy OS. I could just write the binary to floppy and boot a machine. I tried to look into making a toy OS again, and I was looking at using GRUB so I could use it to handle the dirty work of getting into a standard environment, but I couldnt even figure out how to get GRUB to boot it. How the fuck do you install GRUB and make it able to boot your kernel?
>>
Reminder that if you can't program in C then you're not a true programmer.
>>
>>59342554
LISP is very good for improving your programming skills,
but Java has the most jobs and is fast to pick up.
>>
File: 1488822636673.jpg (76KB, 887x686px) Image search: [Google]
1488822636673.jpg
76KB, 887x686px
>>59342540
but python is not a programming language
>>
>>59342559
s/C/C++
>>
>>59342546
>Other languages
Trash.
>>
>>59342520
>I have tried learning programming before, but I just couldn't wrap my mind around it and gave up.

how did you try? did you try coding? what language? what books did you read how many hours did you spend trying? we need details
>>
>>59342569

So I should learn Java, get a job with Java, and then learn Lisp if I want?
>>
File: hipster fedora.jpg (18KB, 236x354px) Image search: [Google]
hipster fedora.jpg
18KB, 236x354px
>>59342575
>>
>>59342558
I think you can just write it to a partition on your harddrive and run update-grub and it should detect it (maybe).
>>
>>59342520
I suggest checking out job sites browsing job postings in your area and observe the different languages requirements. Like for example in your area some languages the posts may require a lot more like degree than versus other languages.
>>
>>59342534
Tell me about Idris.
>>
>>59342587
t. Python/Ruby/Javascript trash
>>
>>59342597
I'll let its creator elucidate you.

http://www.youtube.com/watch?v=X36ye-1x_HQ
>>
File: 1487638432167.png (347KB, 454x600px) Image search: [Google]
1487638432167.png
347KB, 454x600px
>>59342597
>>
>>59342582
>So I should learn Java, get a job with Java, and then learn Lisp if I want?

it's not quite that easy
>>
>>59342580

I tried, yeah. I tried Python and C. A bit of C# too. Someone said I should try to program a video game, so I downloaded a lot of different books on how to do different things. Mostly the "learn X the hard way" book series. I legitimately didn't like it. I would try for a few hours each time and then get frustrated, but I was also going through stuff in my life that frustrated me and added to the frustration of not being able to make something work.

>>59342589

Makes sense. I was actually about to do that before this post even but I got distracted.
>>
>>59342520
>The language must meet the following criteria: fast to pick up, makes me money.

html/css

nothing is easier to learn and htmlmonkeys are always in demand
>>
>>59342520
I had trouble grasping programming until I worked through 'learn python the hard way'. Most people talk shit about it but it was really great for me. And it was pretty quick also.
>>
>>59342615
>I tried, yeah. I tried Python and C. A bit of C# too. Someone said I should try to program a video game, so I downloaded a lot of different books on how to do different things. Mostly the "learn X the hard way" book series. I legitimately didn't like it. I would try for a few hours each time and then get frustrated

did you get as far as making a "hello world" program?

where did you run into trouble

a few hours is nothing anon
>>
File: 1408286397292.jpg (22KB, 189x258px) Image search: [Google]
1408286397292.jpg
22KB, 189x258px
>>59342540
>>59342556
>thanks lawds, i will be start as soon as possible, it's time to get into the business
>long live to lizard king
>>
>>59342609
Can you write compilers in it?
>>
>>59342624
even front end web devs need to know javascript and it's a lot more design-oriented. web dev is a shitty line of work to go into if it's not already your specialty or your passion
>>
>>59342652
Nope, but you can certainly write trash in it.
>>
>>59342653
>even front end web devs need to know javascript

I worked for 2 years as a web dev and only used html5, css and like the smallest ammount of ruby

just depends on what kind of sites you are working on, I know people who make $40,000 per year doing nothing but adding photos and text to wordpress sites for small businesses
>>
>>59342652
Yes!
>>
>>59342669
t. webshit
>>
>>59342615
The Learn X The Hard Way books are shit.

Read The C Programming Language. It's a good logical progression through a language with exercises to make you think and not do this stupid monotonous task because you're too stupid to actually logically model a system and implement it.
>>
>>59342673
What should I be using to do that?
>>
>>59342682
If your language can't evaluate forms during read-time, it's trash.
>>
>>59342685
TCPL is written for people who already know how to program.
>>
>>59342694
Probably Haskell for anything serious, Idris is still immature from what I understand.
>>
I didn't get any internships and I'm graduating next semester. Am I fucked?
>>
>>59342685
I second that the "Learn X the hard way" books are garbage if you aren't mentally challenged. Zed Shaw is a hack.
If you want to learn python try "automate the boring stuff instead.
>>
>>59342694
Haskell, or OCaml, or Idris

Idris might be awkward, since you need to formally prove to the Idris compiler that your program fits some specification
>>
>>59342720
it's not ideal but what can you do, don't take extra semesters just to get internships, you just gotta hustle and work on projects for your resume and try to get your foot in the door
>>
>>59342731
How do you know an Idris compiler is formally verified? On that note, how do you know if Idris tells you a program is correct, it isn't lying or incorrect?
>>
>>59342740
Alright. Honestly I feel like I learned a ton this past year so I could probably make some cool projects over summer.

Any advice for job hunting? Are there any websites that are good for finding jobs?
>>
>>59342536
Java, pic related is my recommended book
Beginners should be taught strongly typed languages to begin with so they know what is what rather than being thrown into something like Python where they won't understand or care about half the concepts they used.

>>59342582
It's not really that straight forward but if you put your mind to it, you could make it happen.

Anyways, if you do get Java down, try taking Clojure for a spin after. Basically Lisp with the benefits of Java and the JVM.

>>59342615
>>59342685
>>59342730
I used the "Learn Python the Hard Way" book but I just couldn't put up with it. I also don't understand why he thinks Python 2 is still good to teach to people when the industry is trying to move towards Python 3.
>>
>>59342731
What are the main differences between Haskell and OCaml? I'm only familiar with the former.
>since you need to formally prove to the Idris compiler that your program fits some specification
What do you mean? Is there some theorem prover mode?
>>
>>59342751
It is possible that there are bugs in the Idris typechecker, but they are just that, bugs, and not a problem with the language.
>>
>>59342751
Because Edwin.
>>
>>59342789
Haskell is pure and OCaml is not
OCaml has polymorphic variants and records (row polymorphism), Haskell does not
OCaml's module and record system is allegedly pretty good, Haskell's is not
GHC Haskell adds a ton of extensions, especially type and syntax stuff, some of which are not found in OCaml

Haskell has type classes and ad hoc polymorphism (overloading), OCaml does not
>>
>>59342698
That disclaimer is only there because they didn't want the expectation that they'd go over simple, universal concepts, and then disappoint, nor was it their goal. However, if you've actually read TCPL you'd know in most cases they end up giving a (very) brief explanation of what concepts are before showing the C implementation.

>Now, for some explanations about the program itself. A C program, whatever its size, consists of functions and
>variables. A function contains statements that specify the computing operations to be done, and variables store
>values used during the computation.

>One method of communicating data between functions is for the calling function to provide a list of values, called
>arguments, to the function it calls.

>A sequence of characters in double quotes, like "hello, world\n", is called a character string or string
>constant.

Similar statements are found throughout the book, so yeah, it's not explicitly written for new programmers, but it's certainly written in a way that new programmers can easily follow, and I find the avoidance of the "you don't know what the fuck you're doing so I'll spell it out for you" attitude to be beneficial, as the text encourages you to think and solve problems using the tools and methods that have been proved to you.
>>
>>59342491
If you can't extend your language's syntax seamlessly, it's trash.
>>
>>59342774
>I also don't understand why he thinks Python 2 is still good to teach
Yeah, what the fuck? The ONLY valid reason to have used Python 2 for the past seven years is if you're working with a legacy codebase that can't be easily converted. If you're learning it new, learning 2 over 3 has been full retard for the past nine years.
>>
Could a kind soul post a snippet of how to iterate over an utf-8 string in C?
>>
>>59342855
Sure.
HACKING MODE...
C...
iterate over an utf-8 string
>>
>>59342774
i see your point, and i will thank you for it.
>start hardcore and it will be easy once you get it
>>
>>59342855
(loop for x across foo)
>>
completely fucking new to HTML and just trying to do something basic

 <!DOCTYPE html>
<html>
<body>

<h1 style= "color:#ffcccc;>" Hello world </h1>

what did i fuck up here
>>
>>59342927
Close your tags.
>>
>>59342927

<h1 is not properly closed
>>
>>59342959
>>59342986
Thx also How do I change the color as the
 color:#ffcccc;> 
 didnt work
>>
>>59342855
https://en.wikipedia.org/wiki/UTF-8#Description
just skip any byte that has the two high order bits set to 10.
>>
>>59343011

close your tag properly and it should work
>>
>>59342774
>Volume 1
Fuck me. It's not that big of a language.
>>
building a quiz app and need to have the editText string compared to the answer string and the total score increase by one... i know im stuck on something stupid.

EditText answerQuestionOne = (EditText) findViewById(R.id.answer_question_one);
String answerOne = answerQuestionOne.getText().toString();
if (answerQuestionOne == "rotary") {
totalScore = totalScore + 1;
>>
>>59343041
It's a verbose book, but I got through it by taking notes from it and other sources and studying those rather than studying directly from the book.
>>
>>59343060
If that's java you need to use equals() to compare strings
>"a".equals("b")
>>
>>59343060
Use .equals for strings or compareTo, not ==
>>
>>59343060
Okay. Good luck.
>>
rotary is the answer. answerQuestionOne== "rotary" does not work. need them both to be strings?
>>
thanks
>>
>>59343016
I'd also need to add cases for 110, 1110, 11110.

Yesterday I found 3 libs in C: utf8proc, MicroUTF-8 and libutf. But I don't know how to use any of those three
>>
>>59342751
>>59342793
what a load of shit, the program is written by hand, just because it has strong typing doesn't mean it does exactly what the programmer (or the specification) had in mind
>>
if ("answerQuestionOne".equals("rotary") ) {
totalScore = totalScore + 1;
>>
>>59343099
The types are the specification.
Very strong type systems like Idris allow you to express almost any specification to the typechecker.
>>
>>59343060
learn the basics of java and how to look things up on google before you start making apps
>>
>>59342855
Store each UTF-8 character in a data type large enough to fit any UTF-8 character. Make a pointer to each character, Put these pointers in an array. Iterate over the array of standard sized pointers.
>>
>>59343130
Can I construct the Y combinator in it?
>>
>>59343174
provided you first construct the lambda calculus
>>
Anyone code a compiler or assembler? Have to code a MIPS32 assembler in C for my CS class and it sucks yo
>>
>>59343326
Trash.
>>
>>59343326
Isn't an assembler just a glorified find and replacer?
>>
>>59343421
Bretty much. Except there are some pain in the asses such as psuedo instructions and the passes required to elide comments, build the symbol table, etc.
>>
>>59343083
>need them both to be strings?
yes
"rotary" is a String
answerOne is a String

and to compare strings (or compare any object by value rather than object identity), do answerOne.equals("rotary")
>>
>>59343083
>no one told him he needs to .equals() for objects
>>
>>59343513
see >>59343486
>>
>>59343516
I mean his book/prof/learning resource
>>
File: 1484507643714.jpg (76KB, 288x402px) Image search: [Google]
1484507643714.jpg
76KB, 288x402px
>>59343486
>>59343513
>>59343516
>objects
>>
>>59342491
A tool to keep track of my color palette, that boots up as fast as an image viewer. Currently working on the schema for how the custom file should look like.
Instead of making my own schema would it run faster if i used xml or json? my schema would be compressed alot more and be much much shorter
>>
>>59343534
Strings are objects in java. I have no doubt the implementation uses arrays of chars
>>
>>59343525
oh. well there are a lot of things people won't tell you and you'll have to figure things out for yourself. but this was something he would have known if he had paid attention to learning material such as https://docs.oracle.com/javase/tutorial/ instead of skipping ahead and trying to make an app straight away. it's like those manchildren in >>>/vg/agdg who dive straight into making games when they don't know much of anything
>>
>banned from stackoverflow

If there's one place more autistic than /g/
>>
>>59343573
kek

what did you do
>>
>>59343573
stop being a shit
>>
>>59343580
shat on OOP like the cancer it is.
>>
>>59343580
>>59343582
Nothing? I have a +33 net "karma" or whatever the fuck. I got -3 today because I posted code with a silly error I glossed over and then I got banned
>>
>>59343615
sure, post the link to that code
>>
>>59343561

they are not really objects, and at very least should be considered special case objects since they have unique properties
>>
>>59343629
http://stackoverflow.com/questions/42703945/why-wont-my-c-code-compile?noredirect=1

I literally said #def instead #define for the include guard kek. Stared at it for like 20 min too
>>
File: Untitled.png (131KB, 1920x1080px) Image search: [Google]
Untitled.png
131KB, 1920x1080px
>>59342491
Would one of you guys mind helping me with pic related? I'll post with what I have so far is someone doesn't mind helping.
>>
>>59342520
pearl
>>
>>59343664
Think it's because of your poor quality post.

This is one i made a few days ago:
http://stackoverflow.com/questions/42638015/iterate-over-a-collection-of-custom-classes-with-alea-gpu
>>
File: 0ba585b1f24ff2d65db617ac16235401.png (144KB, 1920x1048px) Image search: [Google]
0ba585b1f24ff2d65db617ac16235401.png
144KB, 1920x1048px
It's kind of confusing to newbies for comparing strings because == works in simple examples. In pic related I made a simple comparison using == and made sure javac didn't optimize it away. For those cases when it works it's either
A. javac optmized it away
B. javac reused the same constant from the constant pool
In pic related in the bottom right you'll see that "a" for both strings is only represented by one constant in the constant pool. If you look at the ldc (load constant) calls you'll see they both load constant #2 ("a").
>>
>>59343688
its for Java btw
>>
>>59343647
https://www.ntu.edu.sg/home/ehchua/programming/java/J3d_String.html

They are objects and they are also special. That was a pretty interesting read, I had no idea about the common pool for literals
>>
>>59343688
i wish i knew how to help you..
but i don't desu..
sorry about it
>also nice digits
>>
>>59343688
is this your homework?

captcha: granata camping
>>
>>59343664
but are you really banned or did your question just get put on hold?
>>
>>59343704
Try taking a look at hex dumps of a simple class file (they'll be near the beginning). String literals btw are in the format of length then characters.
>>
>>59343697
I'm aware, since "error caused by typos" or whatever the wording is a strict no no on their site. I just wanna know why I'm banned when I have positive "karma".

>>59343723
both

Sucks because I use the site a lot. The only way they say to unban yourself is to edit your posts until people upvote them, which will never happen because nobody reads old posts. I could answer but they didn't explicitly say that as a method of unbanning yourself so idk.
>>
>>59343739
karma doesn't mean shit when you're not posting quality content
>>
File: Noi_Shin_Doll.jpg (309KB, 600x800px) Image search: [Google]
Noi_Shin_Doll.jpg
309KB, 600x800px
https://github.com/baklava151/VirtMachine
Think I'm going to work on my VM
What else does this piece of shit need
>>
>>59343707
it is for homework, yes. unfortunately is is due in about an hour. i thnk i'm almost finished though

>>59343706
thanks anyway bro
>>
Anyone feel like a language is shit after you're proficient at it?
>>
>>59343761
Just post what you have so far in like a hastebin or something.
t. "Professional" java developer
>>
>>59343763
Eventually you get to a point where you learn that languages are tools and shouldn't be shoe horned into every application. Trying to use a language for something that it wasn't built for is usually shit.
>>
>>59343775
unfortunately i'm not familiar with that. i'm still a complete noob when it comes to computers :(
>>
>>59343790
https://hastebin.com/
>>
>>59343688
this is too easy

>>59343790
nigga what
>>
>>59343763
Not when I learned Lisp. I feel like a golden god.
>>
>>59343759
What about pointer read and writes where it. You tell it to write to where a memory address is pointer to for example.
>>
>>59343801
SAME, LEARNING HASKELL AND THIS SHIT IS GLORIOUS
>>
File: 1428568497014.jpg (68KB, 301x725px) Image search: [Google]
1428568497014.jpg
68KB, 301x725px
>>59343763
Felt the same after finishing a few projects in Python
>>
>>59342491
Using CMake, should I use find_package in my root CMakeLists or my src/ one?
>>
>>59343806
what part are you at
>>
Any C niggas know why strtol() is yelling at me?

gcc: warning: passing argument 1 of strtol() makes pointer from integer without a case

char* IMM = strtok(NULL, " \t");
char* endPtr;
int16_t imm = strtol(IMM, &endPtr, 10);

I ran anyway and checked in gdb and IMM was '0' before it segfaulted (the character zero not the NULL pointer). What the fuck
>>
>>59342558
I figured out how to get grub installed on a disk image file and when the VM loads grub works and it can boot a bare linux kernel (i just used the linux kernel as a placeholder to test to see if grub was installed and can boot an OS).
Now, how to figure out how to write my hello world kernel that grub recognizes and can boot?
>>
>>59343844
After using duck typing for years, I finally found out an Integer is not the same thing as a String!
>>
>>59343850
*cast, not case
>>
>>59343860
whew
>>
File: hZhjl.png (7KB, 320x401px) Image search: [Google]
hZhjl.png
7KB, 320x401px
>>59343844
Trying to make a GUI right now desu.

Also slogging through "A gentle intorduction to haskell"

anything but gentle
>>
>>59343798
holy shit this is awesome; thank you for sharing

https://hastebin.com/rusorovago.cs
https://hastebin.com/yeqenajequ.java
https://hastebin.com/piqesunawa.cs

the game class needs a lot of work still. i'll report back in a bit to update it
>>
Help git created .merge_file_<hash?> files all over the root of my repo after fixing a bunch of conflicts

I can't find shit about them on the nets, dubs decide if i delete or keep 8)
>>
>>59343874
for some reason when it prints the grid it doesn't include the periods... i'm still trying to figure out whats up with that too
>>
>>59343850
Try making IMM const.
Also, initialize endPtr.
Also, I hope you called strtok on a previous buffer.
>>
>>59342824
That's not actually enough to learn programming in general. It's like trying to learn Calculus using Stewart if you've never taken a higher level math class before. It's hopeless.
>>
>>59343889
Delete the entire repo
>>
File: 1367779163128.jpg (65KB, 700x551px) Image search: [Google]
1367779163128.jpg
65KB, 700x551px
>>59343868
Picture related.
>>
>>59343902
>not learning calculus for the first time from Rudin
>>
>>59343903
I'd get sued
>>
>>59343868
there's always the wikibook
>>
>>59343921
>not going straight to Royden's Real Analysis
>>
>>59343902
Stuart makes TCPL feel like babby mode tho.
>>
>>59343874
So, what do you need help with?
First thoughts:
>Map is a bad class name because it may be confused with a java.util.Map which it clearly is not
>I'm not a fan of storing the "render" of the map you currently have. I would say to just store like ids in the 2d array. Then make a render function which would take that data and turn it into characters. The problem with your current approach is that you are having to clean up behind you in your moving methods. I'm not a fan of having toString() being your "render" method. toString should be used for more "debug" where it would print out unique variables that are useful to know / useful to identify the object.

>>59343892
Is the problem with your toString method?
>>
>>59343326
Assemblers are fucking easy dude. Compilers are another ballgame. Assembler can be described with fucking regular expressions.
>>
I hope you make no programs with input/output, /dpt/!
Do you?
>>
>>59343959
Most of my programs have type IO ()
>>
>>59343932
oh yeah. Don't make dumb comments like
>datafields
Everyone knows that they are data fields. Comments should be used to document unobvious things, problems / improvements that should be made, and notes on confusing logic you are doing.
>>
>>59343929
That's because learning to program is baby mode.
>>
>>59343922
manually delete everything you don't want
>>
>>59343874
In the first file (Hero class), you shouldn't be assigning values to the class's private variables in their declarations, instead just declare them and let the constructor define them.

For the third file, I'd suggest adding something like this at the bottom:

do {
command = input.next().charAt(0);
if(command == 'U') map.moveUp();
if(command == 'D') map.moveDown();
if(command == 'R') map.moveRight();
if(command == 'L') map.moveLeft();
System.out.println(map.toString());
} while(command != 'Q');
>>
>>59343977
>>59343932
sorry wish i could explain but i'm scrambling to just get something to turn in in the next 30 min thank you for your time though
>>
>>59344072
most most appreciated. i was doing something like this but was using a while loop instead. this makes more sense though
>>
I'm trying to implement connected component labeling, but my flood fill is not working. I have written flood fill countless times but I can't get this to work for some reason. Can I get a second pair of eyes to look at it? I've been staring at it and testing it etc for at least an hour now.

http://pastebin.com/YQP2Nqv6

I get some very strange output, most notably that a coordinate is removed from the queue several times after only being added once:
http://pastebin.com/aFHGVa32

Thanks.
>>
Anyone here ever created a chrom{e,ium} extension? Sounds comfy to me. Share some experiences?
>>
>>59344078
You probably already see it but the > in your for loops should be <
(int i = 0; i > width; i++)
>>
File: 14328.jpg (3MB, 4300x2866px) Image search: [Google]
14328.jpg
3MB, 4300x2866px
>>59342491
Need halp.
I wrote this (based on http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/tutorial/tutdaytime1.html) to print some html from a web server.

#include <iostream>
#include <boost/asio.hpp>
#include <boost/array.hpp>

using boost::asio::ip::tcp;

int main(int argc, char **argv)
{
try
{
if (argc < 2)
{
std::cerr << "Usage: requests <host>" << std::endl;
return EXIT_FAILURE;
}

boost::asio::io_service io;
tcp::resolver resolver(io);
tcp::resolver::query query(argv[1], "http");
tcp::resolver::iterator ei = resolver.resolve(query);
tcp::resolver::iterator end;
tcp::socket socket(io);

boost::system::error_code err = boost::asio::error::host_not_found;
while (err && ei != end)
{
socket.close();
socket.connect(*ei++, err);
}

if (err)
throw boost::system::system_error(err);

for (;;)
{
boost::array<char, 128> buf;
boost::system::error_code err;

size_t len = socket.read_some(boost::asio::buffer(buf), err);

if (err == boost::asio::error::eof)
break;
else if (err)
throw boost::system::system_error(err);

std::cout.write(buf.data(), len);
}
}
catch (std::exception &e)
{
std::cerr << e.what() << std::endl;
}

return EXIT_SUCCESS;
}


This just hangs for a second and exits silently, why?
>>
>>59344212
yeah i caught it. thank you very much anon.

it works fine except it gives me an array index out of bounds error if i try going off of the map. i thought modding out by the height and width would resolve this?

say if we have a 3x3 grid and i immediately try to go left, we would have the row at -1, which is..
wait, i should have modded out by width - 1 and height - 1 huh?
>>
>>59344310
Just do some bounds checking before accessing the index of the array. Make sure that it doesn't go below 0 and doesn't go greater than or equal to the length.
>>
>>59344137
Okay what the fuck.
I moved some declarations around so that some coordinates had minimal scoping and it fixed it.
I'm pretty pissed off, but at least I can go to sleep now.
>>
>>59344326
I can't express my gratitude enough.

I'm going to get a bite to each now. Until next time anon.
>>
How the fuck do I choose a name for my project???
>>
>>59344473
"Project1"
>>
Fuck me, why am I so stupid.
I have two lines defined by a point and an angle. How can I know where they intersect?
>>
>>59344488
Are they coplanar?
>>
>>59342559
If you don't write software for a living then you're not a true programmer.
>>
>>59344491
Yes they are.
>>
>>59344496
R1 = P + uD
R2 = S + vF

P and S are points on each line
D and F are direction vectors

D, F, S and P are known
find u and v such that
uD - vF = S - P
>>
>get in-development, questionably documented API
>Full of void pointers because C can't into genetics
>>
>>59344581
>>>Haskell
>>
File: 1485196939927.jpg (266KB, 905x881px) Image search: [Google]
1485196939927.jpg
266KB, 905x881px
>>59344581
>C can't into genetics
>genetics
>>
>>59344581
Void pointers are fine.
>>
Anyone have a list, link, or image of some moderate to challenging programming projects? Looking for something to do.
>>
>>59344539
Thanks for trying to help me anon but I can't even figure that out on my own. I think I found several stackoverflow threads that describe solutions that are similar to yours but each time I've tried using them I have some missing parameter.
I've also spent a day on various wikipedia pages about polar coordinates but I just can't wrap my head around it.
Being made aware that you're just a smart code monkey is really frustrating.
>>
>>59344724
>Being made aware that you're just a smart code monkey is really frustrating.

i know this feel
>>
>>59344724
To convert an angle to a direction vector use
>d = [cos(a), sin(a)]
>>
>>59344772
If I manage to solve that, will u and v be the x and y coordinates of the intersection point of my two lines?
>>
>>59344858
no
>>
>>59344858
No, you'll need to take u to calculate P + uD
>>
>stick some specific functions to some specific data so we wouldn't need to think about methods of accessing and interpretating the data within special data-sticked-to-functions thingies
Why it was considered bad?
>>
>>59344908
Because people with inferior text editors couldn't autogenerate those functions or were too dumb to use processors that would do it for them.
>>
>>59344892
>>59344908
what
>>
Does anyone know how to autocomplete from included folders automatically in sublime text?
>>
>>59344883
>>59344888
Well I guess I'm really too stupid for that shit. I'll just flunk this course, drop out and go back to kernel hacking like the fucking monkey I am.
Thanks for the help anon.

>>59344954
He's talking about OOP.
>>
>>59344980
>Well I guess I'm really too stupid for that shit. I'll just flunk this course, drop out and go back to kernel hacking like the fucking monkey I am.
>Thanks for the help anon.
just look up a formula
>>
>>59344976
*included files
>>
>>59344980
>>59344994
https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
>>
>>59344994
That's what I've been doing for the past three days but I can't figure out how to translate them into code.

>>59345003
Already been on this page. Unless there's something I don't understand in there, it doesn't talk about lines defined as point+angle.
>>
>>59345018
you have an angle

you convert it into a direction a -> (cos a, sin a)

you get another point on the line by adding any non-zero amount of the direction
>>
>>59342491
Rewriting the Linux kernel with no I/O.
>>
Who here registered their copy of sublime text with Affinity Inc?
>>
>>59345028
Already thought about that but it's just a hack, isn't it? If my points aren't far enough from each other my segments won't intersect.
>>
>>59345040
... what?
>>
>>59345036
Do you get to bring friends?
>>
>>59345036
how would you know that your rewriting
you can't have output of the result of your job
>>
>>59342506
what languages are inherently limited to not having IO though? Even brainfuck can take input apparently.
>>
>>59343421
>>59343935
Retards.
>>
File: Selection_003.png (564KB, 889x536px) Image search: [Google]
Selection_003.png
564KB, 889x536px
What's the fastest, most efficient manner to make a lot of JSON queries? I need some data and I want it swiftly.

I'm thinking Python. Some NODE utility might be useful. Share your wisdom, codan wizards.
>>
>>59345055
rapidjson (or jansson if you don't like C++), libcurl.
>>
>>59345048
Why would I need to run it?
>>
>>59345043
Alright, I think I now understand what was wrong with my thinking. I'll try to implement what you suggest. Thank you for your time anon.
>>
>>59345040
Do you know what the sin and cos functions do?

given a vector v in R^2, |v| * cos(theta) gives you the magnitude of the vector in the x-direction, and |v| * sin(theta) gives you the magnitude in the y-direction.
>>
>>59344302
Please respond.
>>
>>59345040
double a = Math.PI / 4;
double a1 = Math.cos(a);
double a2 = Math.sin(a);
double x1 = 0;
double y1 = 0;

double b = -Math.PI / 4;
double b1 = Math.cos(b);
double b2 = Math.sin(b);
double x2 = 0;
double y2 = 10;

double v1 = (x2 - x1);
double v2 = (y2 - y1);
double det = a1 * b2 - b1 * a2;

double t = (b2 * v1 - b1 * v2) / det;

System.out.println((t * a1 + x1) + "!" + (t * a2 + x2));

Implemented your problem (code is shit so you won't copy paste). Feel free to ask any questions about how it was done.
>>
>>59345040
>it's just a hack, isn't it?
you'll have to use trigonometry to get a point from an angle. and then with the extra points you can do the line-line intersection
>>
life is too interesting for code
>>
File: 1452284600763.jpg (47KB, 483x611px) Image search: [Google]
1452284600763.jpg
47KB, 483x611px
>>59345311
>STEMlords btfo
>>
>>59344581
C is not meant to be used any longer in this decade. Either use C++ or move to Rust if you want safety.
>>
>>59345444
>Rust
Wew
>>
>>59345454
At least it's not C cancer
>>
>>59345444
What does he mean by genetics?
>>
>>59345459
The answer can be found by looking at your keyboard, anon.
>>
>>59345459
He meant generics. It's okay, an average C toddler does not know what generics mean and so he does not understand it was a typo.
>>
>>59345468
Fair enough. C is like a languagelet, doesn't have any features. Might as well use brainfuck and show off epeen. Doesn't even have lazy evaluations.
>>
>>59345457
If honestly rather use Ada.
>>
File: 1489216935193.gif (980KB, 305x320px) Image search: [Google]
1489216935193.gif
980KB, 305x320px
>>59342491
>that pic


reminds me of someone...
>>
>>59345487
If it's not c or python it's a good choice.
>>
>>59345481
>Doesn't even have lazy evaluations.
gee wtf I hate C now
>>
File: tmp_2828-1488949829289148430556.jpg (2MB, 2000x2610px) Image search: [Google]
tmp_2828-1488949829289148430556.jpg
2MB, 2000x2610px
Remember to report C disgrace posts because the poster quickly shits up the thread.
>>
>>59345506
Can't handle the fact that c is literal garbage, eh?

Here, learn and stay envious https://en.wikipedia.org/wiki/Generic_programming
c is a disservice to intelligent programmers.
>>
>>59345524
at least it's not Rust
>>
>>59345547
Rust is better than C in every way possible
>>
>>59345569
except practical, performant code and systems programming that is reasonably portable

... aka the entire point of C
>>
>>59345587
>performant ""code""
If you have written a project larger than a 5 files in src/ you would, by now, have realized almost all the performance drain comes from your algorithm. Furthermore having no exception handling, operator overloading, generics, strict type checking and memory safety in any form is not practical.
>>
>>59345049
>what languages are inherently limited to not having IO though?
Some Anon is currently designing a language without I/O. Finally we can fully commit to recreational programming with no pretense of """usefulness""".
>>
>>59345587
>performant
not an English word.
>>
File: haskell quote.png (1MB, 790x960px) Image search: [Google]
haskell quote.png
1MB, 790x960px
>>59345606
>it will be even more useless than Haskell
>>
>>59345468
What are genetic algorithms?
>>
>>59345611
Get out of here you communist dog
Do you work for the BBC?
>>
>>59345600
Holy shit I actually know what a lot of these terms mean...
>>
File: Selection_20170311_09:56:56.png (9KB, 369x106px) Image search: [Google]
Selection_20170311_09:56:56.png
9KB, 369x106px
>>59345622
>>
>>59345170
I'm back, thanks for the snippet.
I guess my problem is that I don't understand some of the concepts used here. For instance I understand that v1 is x2's position relative to x1's and the same thing applies for v2, but I don't understant what the determinant means. I don't understand how multiplying the width of an object with the height of another and then substracting the height of that first object times the width of the second one makes sense.
>>
>>59345651
I can't wait for the civil war
The BBC offices will burn
>>
>>59345600
>algorithms
A performance drain, and a big one for sure, but you can't tell me with a straight face that an algorithm implemented in Python is faster than C. Run time costs matter.

>ll those useless masturbatory """features"""
Yeah no. Nice try though. All those things either have a run time or compile time cost.
>>
A long discussion on whether "performant" is an English word:
http://english.stackexchange.com/questions/38945/what-is-wrong-with-the-word-performant
>>
>>59345675
1. Comparing Rust's performance to that of c is reasonable, comparing Rust's performance to that of python is not. As of now, Rust is faster than C++ and it even is faster than C in rare cases. Over-generalization is not going to save your argument here.

2. Features are not a bad thing. An intelligent programmer knows when to use relevant features while c toddlers cannot fathom the use of modern features and thus stay confined in their small world.
>>
>>59345663
I'm solving the system of equations by rref'ing the augmented matrix.
On your own try calculating rref([[a, b, c][d, e, f]]) (that's a 2x3 matrix)
>>
>>59345663
The most important thing to know about the determinant isxthat they control volume. Suppose A: R^n->R^n is a linear transformation. det(A) is the a real number.

Let U be a (measurable) subset of R^n with volume V. Then, the volume of A(U) is precisely

|det(A)| * V.

Of course you can have that det(A) is negative, which would mean the orientation is flipped. Let us know if you have any other questions.
>>
Nim has a syntax similar to python imo. I wish Nim could replace Python one day. However it's not the syntax only that makes Python such a popular language, it's the abundance of libraries
>>
>>59345712
>rust performance to c is comparable
No it isn't actually. There are many more run time costs to rust. Anything system related implemented in Rust is not going to be better performing than the same implemented in C.
>features are not a bad thing
Yeah sure, when your goal is making your life easier and not making your program perform better is more important.
There are valid use cases for rust, like browsers, or large user applications, but it is shit for things C excels at like kernels, and low level libraries.
All those things you listed don't protect your code from shitty programmers.
>>
>>59344302
gdb
>>
>>59345798
*and not when
>>
>>59345772
I wish both would die with no heirs
>>
I fucking hate objects
>>
how do I name my projects
>>
>>59345953
in the name of our gods
>>
>>59345933
seconded
>>
>mfw functions are first-class values in Lua
Not even lack of integers can stop me from loving Lua.
>>
>>59343688
Interesting parts of Map.java
    public Map(final Hero hero, final int width, final int height) {
this.hero = hero;
this.width = width;
this.height = height;

// check to make sure args are valid
if (width < 1 || height < 1 || hero == null || hero.getName().length() == 0) {
throw new IllegalArgumentException(
"Illegal argument: hero can't be null or have a 0 length name and width and height both need to be > 0.");
}

// set up the tiles
tiles = new char[width][height];
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
tiles[i][j] = '.';
}
}

// place hero's initial in top left
tiles[0][0] = hero.getName().charAt(0);
}

public void moveDown() {
move(hero::setRow, hero.getRow(), 1, height);
}

private void move(final Consumer<Integer> heroSet, final int currentPos, final int offset, final int maxPos) {
// reset hero's indicator in tiles to dot since they are about to move
tiles[hero.getRow()][hero.getColumn()] = '.';

// move the hero. floorMod sanitizes the input if it's < 0 or >= maxPos
heroSet.accept(Math.floorMod(currentPos + offset, maxPos));

// set the hero's initial at their new position in the tiles
tiles[hero.getRow()][hero.getColumn()] = hero.getName().charAt(0);
}

/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return Arrays.stream(tiles).map(String::valueOf).collect(Collectors.joining(System.lineSeparator()));
}
>>
>>59346091
>>>haskell
>>
>>59346106
Should have used Arrays.fill to set up the tiles.

>>59343688
Let me know if you'd like to see any more of the program.
>>
>>59346091
>first-class values
no, they're just values.
>>
>>59346124
Clojure
>>
File: lua.png (276KB, 730x666px) Image search: [Google]
lua.png
276KB, 730x666px
>>59346091
>Lua
Good goy.
>>
>>59346199
>trash
Um... sure?
>>
>>59346199
He said first class functions, not dynatrash
>>
File: 1486602658036.jpg (170KB, 1200x849px) Image search: [Google]
1486602658036.jpg
170KB, 1200x849px
>>2015
>>2016
>2017
>/g/ is still circlejerking around FizzBuzz
>>59327915

Let's find a new coding problem that's slightly more challenging (but not too much)
>>
>>59345723
>>59345743
I guess I still don't get it. When running the code snippet here >>59345170 with the following lines:
{x: 0, y: 50, angle: 270 }
{x: 50, y: 100, angle: 0 }
{x: 100, y: 50, angle: 90 }
{x: 50, y: 0, angle: 180 }

I get four points that form a nice square at the top of my screen. However, if I move each point 100 pixels to the right, the given square moves away both from the left and the top of the screen. Why is that? And why doesn't adding 100 to each y coordinate move the rectangle away from the top (and the left) of the screen?
>>
I need some help using Spring and JPA to create an sql database schema. here are my 3 possible tables:

>Employee_table
>employeeID
>username
>email

>Token_balance_table
>tokensReceived
>tokensToGive

>Token_transactions_table
>giverEmployeeID
>recipientEmployeeID
>amount
>comment

Each employee obviously has one token balance. But each employee will have multiple transactions, and each transaction will contain the details of the employee giving tokens and the employee receiving tokens.

How can I set this up? I'm thinking the token table could be @Embeddable and stored in the @Entity Employee table, but that's giving me issues with keeping the tokens unique to that employee.
>>
>>59346202
I am a Jew :^)
>>
>>59344302
fuckin kiddo

shoulda used libcurl
>>
>>59346260
Implement a quadtree for more performant collision detection in a system with millions of objects.
>>
shit thread
>>
>>59346322
I'm assuming you will have a employeeID FK in the token balance table.

I don't know much about the Spring ORM but in Hibernate I'd just do something like @OneToOne for the token balance table and @OneToMany for the transactions.
>>
>>59346536
>I'd just do something like @OneToOne for the token balance table

I did consider that but I thought I could just use @Embeddable for the token balance table and do it that way
>>
>>59346584
Ah, ok. I see what you're trying to do.

I know that this is for Hibernate, but try this:
https://dzone.com/tutorials/java/hibernate/hibernate-example/hibernate-mapping-component-using-annotations-1.html

Replace "Student" with your employee table and "Address" with your token balance table.
>>
OOP is trash.
>>
Could someone help me?

I am programming in C++ using SDL2 library. Everything works well on windows 10 with runtime library setting set to multi-threaded debug dll(debug) or multi-threaded dll(release). However if the same program is run on windows 7 then only multi-threaded debug dll works and multi-threaded dll does not.

How to make release version work on windows 7?
Could setting Runtime Library on release version to multi-threaded debug dll cause problems in the future, is it even a problem?
>>
>>59342520
>I am a NEET who doesn't want to leave the house
>what should I look into?
I suggest going to see a doctor because you probably have depression and social anxiety and that's going to hinder your intellectual capabilities, willpower and is going to make you drop your spaghetti when you need to go to a job interview.

Also Java or C#. My first choice would be C# but that requires using Windows and some of you retards use inferior OSes.
>>
daily reminder that /dpt/ can't average two ints correctly in C.
>>
>>59347612
fuck off I can
>>
>>59347577
>C# but that requires using Windows
But that's wrong.
>>
>>59347612
Anyone can do that given a clear definition of what correctly means.
>>
>>59347674
Mono is a joke
>>
>>59347612
define correctly
>>
>>59347612
Do I have to post my function for the 50th time?
>>
File: image.jpg (103KB, 1024x921px) Image search: [Google]
image.jpg
103KB, 1024x921px
what do people here think about python?

wrote some basic scripts with it years ago when i learned it but im considering gaining a more in depth knowledge now
>>
>>59347755
(instead (lisp (use (i))))
>>
>>59347755
it's shit.
highly paid shit.
>>
>>59346447
You first.
>>
>>59347755
I'm not sure why anyone would learn Python in great depth unless you're developing the language or its tools.
>>
>>59347847
I'm not sure why anyone would learn C in great depth unless you're developing the language or its tools.
>>
>>59347847
i didnt ask for reasons to learn it obviously i have them.

i asked what you think of the language dumbfuck
>>
>>59347889
It's trash.
>>
>>59347875
In C you have total control over what's going on. It makes perfect sense to learn it in depth (and it's very small which helps) OOP Python is just a high level mess you can sort of, kind of use to do shit very, very slowly.
>>
>>59347690
>>59347741
>>59347754
>>59347620
What do you think "correct" means? Anyways..
1. The function must take in two integers and return an int that is the average of both.
2. You may not copy-paste it from someone else. Do an original solution.
3. The truncated result must be the same as you would get if you truncated it in a calculator.
4. Don't pretend to be stupid, you know what averaging means.
>>
>>59347962
int average(int a, int b)
{
return((a + b) / 2);
}
>>
>>59347940
>In C you have total control over what's going on.
That is the problem.
You lose control over the shit happening around, but if you can control it all, you'd rather become some dictator instead of programmer.
>>
>>59348001
You're supposed to be the dictator of the processor, not just try to kind of influence it through Guido van Rossum's layer of bad ideas.
>>
>>59347977
Integer overflow.
>>
>>59348080
A calculator doesn't prevent that either.
>>
>>59347962
(defun average (a b)
(declare (fixnum a b) (optimize speed space (safety 0)))
(/ (+ a b) 2))
>>
>>59347540
Maybe it has something to do with vc redistributables? I vaguely remember having problems with building sdl app a few years ago.
>>
>>59345054
Explain
>>
>>59342520
It's very hard to go through a career working from home. It's a privilege most earn after working at the company for a long time.
Freelance or other self employment is the best way to get to that stage quickly.
Webdevs can often be freelance because they are expected to create shoddy products.
Freelance C programming (or other more respected areas of programming) isn't exactly .. sustainable:
https://www.freelancer.com/jobs/C-Programming/1/
You do consulting for companies if you're a self employed C programmer, but that requires experience and merits.
>>
>>59348235
Types are gay
(defun average (a)
(declare (type (cons integer) a) (optimize speed space (safety 0)))
(/ (the integer (reduce '+ a)) 2))
>>
Programming in Python < Programming in C < Programming in Haskell <<<<<<<<< Programming anytginh useful ever
>>
>>59348361
I don't know how to do math:
(defun average (a)
(declare (type (cons integer) a) (optimize speed space (safety 0)))
(/ (the integer (reduce '+ a)) (length a)))
>>
File: 1481991802614.png (1MB, 1440x1080px) Image search: [Google]
1481991802614.png
1MB, 1440x1080px
>>59342520
M8 you can do anything you fucking want in life if you approach it with the right attitude. In the end it doesn't matter what you do, just how well you do it, that's the business mindset.
Open a fucking lemonade stand for all I care, if you play that shit right you'll make more money than 90% of /g/ users.
You don't have to get a job, or fit in, you just have to burn that candle at both ends. If you do that, then you won't have any regrets regardless of whether you succeeded or not.
Trust me when I say, if you're worrying about -what- to do, then your problem is far more psychological and can't be solved by switching occupations. If you want to kick back and live on a passive income, then guess what, you can do that shit too. You might have jack shit right now, but there's potential everywhere you look. A true wizard knows how to turn lead into gold. Excuse my sperg.
>>
>>59342491
Hey lads, i just download Java Oracle for start my study in the programming field
Any tips for a beginner? where should i step first to not trigger the mine?
>>
New thread:

>>59348632
>>59348632
>>59348632
>>
>>59348618
What language are you translating from?
>>
>go to 4chan-x repository
>its fucking coffee script

How do I convert this clusterfuck back to readable javascript so that it's actually possible to understans what it's doing?
Thread posts: 313
Thread images: 31


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