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

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

Thread replies: 255
Thread images: 23
File: trap programmer.png (1 MB, 1702x2471) Image search: [Google]
trap programmer.png
1 MB, 1702x2471
Previous thread: >>51443261

What are you working on, /g/?
>>
First for C.
First for functional programming is fucking retarded.
First for people who like traps are 100% faggots.
>>
porgramming in MIPS assembly
>>
So I have two tables, and I'm trying to set "projectScore" equal to "projectAvgScore." I tried just making projectScore a Foreign Key in the PROJECTSCORE table, but I kept getting an error in foreign key constraint of table. I've spent the last 3 hours trying to fix it but can't fucking figure it out.

create table PROJECT (
projectID int(10) NOT NULL AUTO_INCREMENT,
studentFName VARCHAR(20),
studentLName VARCHAR(20),
projectScore int(2) NOT NULL,
divisionNum int NOT NULL,
categoryNum int NOT NULL,
PRIMARY KEY (projectID)
)ENGINE=InnoDB;


create table PROJECTSCORE (
projectID int(10) NOT NULL,
projectAvgScore int(2) NOT NULL,
judgeCounter int,
scoreSum int,
FOREIGN KEY (projectID) REFERENCES PROJECT(projectID),
PRIMARY KEY (projectID, projectAvgScore)
)ENGINE=InnoDB;


The SQL command should be:
INSERT INTO PROJECT (projectScore) SELECT projectAvgScore FROM PROJECTSCORE WHERE projectID = 1;


This adds a projectID = 21 instead updating projectID = 1
>>
I did one of the moderate challenges on codeeval and now they're giving me links to apply for jobs.
Are these legit or just generic job listings?
>>
>>51449776
legit if you live in the states. sends your resume over. you are one of many though.
>>
>>51449735
What if I write C while dressed like a girl?
>>
>>51449735
Yeah, if you like developing shit slow as fuck (but hey, at least it runs fast, right?). For the people with more mental plasticity than you and who actually want to get shit built, >>51449847

>still using Java/C/C++ on the regular
>shiggy
>>
>>51449928
functional programming is a meme
>>
>>51449735
What we call functional programming is somewhat of a shibboleth for good-taste programming. We prefer the best programming languages, like Ocaml and Clojure, but we don’t actually restrict ourselves to writing functional programs. Do we use C when it’s the right tool for the job? Hell yeah. Do we put mutable state into a program when it makes it simpler (as is sometimes the case)? Hell yeah. On the other hand, we trust the aesthetic and architectural decisions made by brilliant, experienced, gray-bearded engineers far more than we trust business fads.
>>
>>51449952
You know how I know you've never solved any non-small real-world problems in a reasonable time frame?
>>
>>51449986
Because you've never done it either?
>>
How do you compare dates in SQL? I have a DATETIME field that only contains a date (no time), and I want to compare it to a string with the same formatting (dd.mm.yyyy).
But when I do this:
SELECT [ID] FROM [Table] WHERE [date_field] > '01.01.2015';

It gives me records from before that date as well.
I'm not sure what kind of database this is (oracle etc.), only have remote access.
>>
File: 1444378145195.png (2 MB, 1696x2467) Image search: [Google]
1444378145195.png
2 MB, 1696x2467
>>51449882
then you've become a living meme
>>
>>51450021
>>51449718
who the fuck keeps making these?
>>
>>51449988
I finish shit, motherfucker. Why would I use anything low-level if the problem doesn't require it and high-level techniques get it done faster and with less code?

Why would you use C unless you're working close to the hardware? Why would you use C++ unless you're working on a 3D game engine or embedded systems? And why do all the best-performing companies in my area doing actual software development want Clojure and Scala devs, despite everyone claming "there are less jobs in FP"?
>>
>>51450042
autist
>>
File: Variables2.png (26 KB, 481x1173) Image search: [Google]
Variables2.png
26 KB, 481x1173
So I'm not a programmer really, working on it. and I'm making a turn based RPG combat game

I've read up on tables and how I should be using them more, I kind of get them now, but don't see how they can do this

But is there a faster way to transfer loads of variables onto other variables? I mean this isn't too slow since I set it up so I could easily copy and paste it, but there has to be a better way right?


The Variables with P are player variables, so they store the player's character(s) info, and the T variables are temporary variables for storing in battle info

There are 8 character slots, and current 4(later 8) in battle slots with 4 as a front row, and I'm going to add a back row mechanic later.

So I need to be able to move the permanent variables into temporary ones for battles, and I'll be turning each into it's own function so it can refresh at will.

tl:dr:
How do I make a bunch of variables equal a bunch of other variables faster? Otherwise I have to write this out at least 32 times, and probably hundreds of times for enemy variables

Yes I realize my variable names are horrible, going to stick with (Capital)(lower case(Number)(letter) from now on rather than having half of them be all caps
>>
>>51450220
>that code
I had a sudden glimpse of the abyss. What language is this?
>>
Look up arrays.
They're incredibly useful.
>>
http://lmgtfy.com/?q=How+do+you+compare+dates+in+SQL%3F
>>
>>51450220
DRY = Don't Repeat Yourself

For example, you could have an instance of the character with all that data. Then you'd place that instance into a party/battle/whatever slot, and could refer to that character's equipment through that slot. Or if you want you could have a table (or other collection) and clone it.

Basically, read up on arrays, (hash)maps, enums... they will make your job incredibly easier.
>>
>>51450283
>>51450005
>>
>>51450276
Lua
>>
>>51450295
But the temporary variables can change in battle freely, and the permanent variables hold important info that's permanent since you can lose HP/MP in battle
>>
>>51450426
A character should have a max HP (pool size) and a current HP.
>>
>>51450283
>>51450299
why respond when you cant help? kill yourself, of course ive tried googling this shit
>>
>>51450444
but the temporary variable already does that job, and the max HP for the game is 50, characters can gain bonus HP however
>>
>>51449735

http://conal.net/blog/posts/the-c-language-is-purely-functional
>>
>>51450515
I bet you haven't even figured out structs yet.
You can literally assign an HP/MP/condition all at once and treat it like a single data structure.
You can even use it like a data type and make an array of type PlayerCharacters.

Seriously, go learn some programming before you make something worth turning into a CS grad meme.
>>
>>51450513
Try google a bit more.
>>
>>51450546
I know of structs,couldn't get the code from the website working though

And I'm not sure how putting my data into a single structure would help it, wouldn't I have to remember the order of it inside the struct/table?
>>
>>51449735
But Haskell and C go along like bread and butter.
>>
>>51450585
Try (hash)maps. They consists of keys paired with values. So your keys would be strings like "currentHP" and values would be ints and what not. Then you could get the value by calling the corresponding key in the map.
>>
>>51450614
But isn't that the same as just having variables with X name?
>>
>Can someone give me a hint for how to solve the 0/1 knapsack problem. I keep coming up with solutions but they're all greedy
>>
>>51450635

Only sort of. You'll be able to access and modify them in mostly the same way, something like

map["CurrentHP"] = 100;


But they do what data structures do best: make everything look less like a pile of hot garbage.
>>
File: rage.png (20 KB, 381x400) Image search: [Google]
rage.png
20 KB, 381x400
Trying to fix annoying rounding errors in my GUI's scrollbar code.

No matter how carefully I calculate the thumb position and size, I can always find some combination of total size, visible size and scroll position that causes a rounding error and annoyingly leaves a small one-pixel crack somewhere. Fuck!
>>
>>51450684
Snap to the edges if it's <2 pixels to the edge or some shit.
>>
>>51450667

Use the double penetration approach. Fairly straightforward, but it's not as space efficient.

Here's a professor's lecture on the problem:

http://cse.unl.edu/~goddard/Courses/CSCE310J/Lectures/Lecture8-DynamicProgramming.pdf
>>
>>51450702
But that's a hack! I don't do hacks!

Shit. I'm afraid I have to hack it unless I want to waste my whole day on this... :-(
>>
>>51450737
Then enjoy your floating point arithmetic.
>>
>>51450737
>But that's a hack!

As far as hacks go, that barely scrapes the surface of shittiness.

It could be much, much, worse.
>>
>>51450791
>>51450753
It's currently all-integer code.

It's not that I can't hack the calculation. I did that. But that hack then messed up the code that calculates where to scroll the screen when the scrollbar is dragged with the mouse. So I hacked that part too. But that caused problems in yet another place. So it's hacks piled on top of hacks. The original code was 15 lines, now it's 30 with hacks. I can't accept that.
>>
>>51449865
> ()))})($(
> the best

are you for real
>>
>>51450862
How about fixing those rounding problems then.
>>
>>51449760
POST THE ERROR MESSAGE, DUMBASS
>>
>>51450684
In C, integer division and converting a float to an int truncate rather than round.

Also, with floating point, x*(1/y) is typically not equal to x/y even when x is an exact multiple of y. So don't calculate a scale factor a/b then multiply y=(a/b)*x. Store the scale as numerator and denominator and calculate y=(a*x)/b using integers.

There may be other issues. In particular, whether the scale factor (ratio of scrollbar movement to document scroll offset) is less than or greater than 1 probably need to be separate cases. The latter is typically more complex, as not all possible scrollbar positions are used, and you want to ensure that the used positions include the minimum and maximum.
>>
>>51450545
>C is purely functional
>by the way, I'm talking about C preprocessor, not about actual language
>a lot of parts of C preprocessor are functional, except for those cases where it is not
>and that means C is purely functional

is this a joke or is that guy a retard
>>
File: 1447042753722.jpg (424 KB, 1920x1200) Image search: [Google]
1447042753722.jpg
424 KB, 1920x1200
>>51449718
Working on a higher or lower card game, I am extremely new to programming and I am on babby's first logic error. Been stepping through each piece of code for an hour, still can't figure it out.

What do you /g/ents do when you are stuck on a logic error?

This is C# by the way.
>>
>>51450978
> you want to ensure that the used positions include the minimum and maximum.
scrollbar_offset = document_offset * (scrollbar_range-1) / (document_range-1)

Where
scrollbar_range = scrollbar_height - thumb_height
document_range = document_height - viewport_height

The -1 is necessary to avoid leaving a space below the thumb when you're at the end of the document.
>>
>>51451042
how about you post the fucknig error
>>
>>51451058
There is no error, it is a LOGIC error. Nothing shows up, it is just doing something it is not supposed to do.
>>
>>51450005
dd.mm.yyyy is usually not valid SQL datetime format. Try to determine and use correct format. You may also try casting/converting into datetime.
>>
Trying to FizzBuzz on codeeval.
Failed due to the entire thing being in comments (I didn't notice bacause I haven't used Python in a while and there's no syntax highlighting so I just didn't care). This is probably why FizzBuzz have such a great failure rate.
>>
>>51451069
Talk to a duck.
>>
>>51451042
Calculate each result yourself and check if it matches with the output of your application.
>>
>>51451113
I tried talking to a picture of a black guy, but it isn't working fuck.

I swear to christ 70% of programming is thinking of what to do, 15% going through my shitty code, and 15% actually coding.
>>
>>51451069
The error is your code, post the code and describe the error.
What I do:
>make the following method:
private void write(string s, params Object[] args)
{
Console.WriteLine("[" + s + "]", args);
}

>call method for every area where there's updated variables (usually inside a loop or before an if statement)
>make sure variables are what I actually want
>when the problem's fixed comment out Console.WriteLine
>delete the call to write when you finish
Before you ask, I use a custom write method so I can change it between writing to textboxes/console/etc whenever necessary and to add those square brackets to make sure I can see the whitespace.
>>
>>51451163
Uh, you don't know how to step through with a debugger?
>>
>>51451236
Yeah but that's annoying. With this it's guaranteed write once and every time something happens it automatically updates in the console (for example, mouse movement).
Hell, the only time I really use the debugger is to quickly break at specific lines to check the data of large objects or to tell me that event's actually being called.
>>
File: pgrammerfuel.jpg (67 KB, 687x720) Image search: [Google]
pgrammerfuel.jpg
67 KB, 687x720
>>51451042
Oddly enough your problem can be fixed by reciting/explaining your code out-loud to someone else or an object. If it is a logic error it would sound retarded to say out loud and you'd find it fairly quickly.
>>
>>51449718
fuck what's the name of the original
>>
I just reinstalled win, and now visual studio recompiles everything even if there are no changes. What's wrong with it?
>>
>>51451009
>is this a joke

Yes.
>>
looking at making a giant robot MOO. mite b fun.
>>
>>51451163
1. You could make it so it only prints the shit in Debug builds
2. You could parameterize the output stream
And then you can just leave it in and have excellend debug output when you want and none if you don't, also redirecting it to a file would be a breeze.
Unless C# can't do that. Which would make me very sad.
>>
>>51451411
System time is wrong, files' last modification date is in the future.

Also, the obvious
>installed win
>>
>>51451472
You probably could do that, I'm just too stupid and/or lazy to do it.
Was also thinking of just making it a public method in some utility class that took an extra argument (error number or something) so I can turn off some and keep others active.
It's hardly a professional solution.
>>
>>51451479
>System time is wrong
most likely since even after setting the tz, the clock is still ~10 hours into the future
shouldn't windows pull that clock from the internet?

>installed win
because I fucked up my arch install, had to format the drive, do it all over again :^)
>>
Hi, /dpt/.
I have a 30GB SQL database file thing that I need to work with. The problem is that I've never worked with any DBMS other than redis. So trying to fuck around on my own in mysql isn't helping me understand it.

Can anyone recommend a good beginner's tutorial for MySQL?
>>
>>51449718
>What are you working on, /g/?
The official /dpt/ C toolkit: a sate of art, community driven, FOSS, general utility library for C.
>>
>>51451536
>shouldn't windows pull that clock from the internet?
Yeah, I have the activated as well. It just never does it. Always have to do it manually.
>>
>/g/ programmers have an unusually high ratio of C "it's the most hardcore" fanboys
>4chan has a high ratio of NEETs

Hmmmm
>>
>>51451614

It's probably just a coincidence.
>>
>>51451690
None... none of you have jobs, do you?
>>
>>51451697
Stop reminding me how much of a useless piece of shit I am ;_;
I never feel qualified (hell, I'm probably not) and I'm really not sure what area I'd want to go into.
>>
>>51450069
The C cultists here aren't real programmers and just write toy programs to have open in desktop threads.
>>
>>51451697
Joke's on you, I do have a job.
>>
>>51451697

I'm going to school, and I also had/have job(s). In fact, I think most people on /dpt/ are employed, it's just that there's an unusually high concentration of neets here.
>>
>>51451266
No, it's not annoying, it's much faster and better. Peppering your code with random print statements and making sure to track them down and remove them later is annoying.
>>
File: top 10 programming language.jpg (172 KB, 940x1031) Image search: [Google]
top 10 programming language.jpg
172 KB, 940x1031
>>51451768
>>51451772
And what languages do you use for real work? And which would you use if you had the freedom of choice? Let me guess, neither is C.

>>51451797
I think the right way to do debug print is to have it controlled by a single global debug flag (or build setting). So you don't need to comment each one out.
>>
>>51451797
>right click method
>call hierarchy
Better yet:
>delete/comment out method
>errors highlight where they are
But yes, take extra time pausing while you step through or to retype shit and getting an output that takes extra time to read because you didn't format it yourself.
>>
>>51451822
>what languages do you use for real work?

Whatever becomes necessary. C++, Java, or C# for Wandows.

It depends.

>which would you use if you had the freedom of choice?

C#. It's too good.

>Let me guess, neither is C.

You win.
>>
>>51451797
Stepping through the debugger to track down problems quickly becomes very pointless as soon as multiple interacting threads are introduced.
Debug statements also skew the time relations, but not nearly as bad as that.
>>
>>51451766
I can confirm that as a professional C programmer. I come here for the laughs.
>>
>>51451822
I'm and Android developer, so most of my work is in Java. I would only use C if I had to do embedded stuff, which I don't. Using C for general application development (i.e. 'apps') is just batshit insane. C is great if you want to know exactly what is going on. That's why it'll never fade away in the embedded industry or software that has to interact with drivers. C is also useful for educational purposes, since it lacks basic functionality like sorting, dynamic arrays etc.
Ideally I want to do less UI work. Android is full of 'muh material design' hipsters. I've been to several Google events and it's amusing to see how material design advocates are praising material design. Either writing b2b software or backend development.
>>
File: out.webm (485 KB, 768x832) Image search: [Google]
out.webm
485 KB, 768x832
>>51449718
The code for a settings dialog. (only the sync page and half of the vo settings are working at the moment.)
>>
>>51451888
>Stepping through the debugger to track down problems quickly becomes very pointless as soon as multiple interacting threads are introduced.
Why do you say that?
>>
>>51451963
If you had read the post to the end you'd already have your answer.
>>
>>51452045
I did, but he didn't explain why a debugger is pointless in multithreading situations. He just claimed debug statements were better.
>>
>>51452086
Are you trolling or fucking dense or have you never had to debug multithreaded programs before?
>>
>>51452139
I do it all the time. Debuggers are particularly good for it.
>>
>>51452086
>>51452139
No wait, maybe you are just retarded. Let me start off differently. With a quiz.

If you have a multithreaded application which does stupid shit because of threading errors, what could happen if you change the time either of the involved threads requires to process its data?
>>
File: C.png (136 KB, 2000x2126) Image search: [Google]
C.png
136 KB, 2000x2126
>>
>>51451944
This is starting to look really nice. Keep up the good work. I think a lot of people are waiting for a good mpv GUI and Linux MPC-HC alternative.
>>
File: mathtex.gif (4 KB, 274x80) Image search: [Google]
mathtex.gif
4 KB, 274x80
if a i have a view matrix with a layout like pic related and want to multiply it with a Vector4, do i multiply it as is (red) to calculate the X coordinate of the resulting Vector4 or do i need to transpose it first (blue)?
>>
>>51452207
what the fuck
i dont know why 4chan fucked up the picture
>>
>>51452160
>what could happen if you change the time either of the involved threads requires to process its data?
lots of things synchronization issues, race conditions etc. But I would imagine most of those would be errors in the code anyways. You shouldn't really have code that's dependant on a thread finish certain tasks within a certain amount of time, since that is typically not very predicable. Especially for the kind of work that separate threads tend to be created for.

I'm not really sure what you're saying though. Using a debugger must suck because it will probably break something? When you break in C#, all threads a paused. The debugger lets you see the call stacks of all the currently running threads. So I'm not sure where an issue is likely to come up.
>>
>>51449970
lmao the only time lets say, a lisp is "the right time for the job" is when you're sitting around circlejerking with your boyfriend and one of you can only get off to parens, 2bh senpaitachi)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
>>
>>51452354
tool*
>>
How do I start contributing to open source projects dpt?
>>
File: 1435317768008.jpg (43 KB, 402x480) Image search: [Google]
1435317768008.jpg
43 KB, 402x480
>>51452458
1) Find open source project
2) Contribute to it.
>>
>>51452253
>But I would imagine most of those would be errors in the code anyways.
No fucking shit.
Why even use a debugger? Just write correct code.
>>
>>51452487
Thanks, Anon!
>>
>>51452565
Because the debugger wouldn;t cause any extra problems with that anyways, and in fact is rather excellent for getting to the bottom of them. The .NET one at least is.
>>
>>51452646
Any changes in thread runtime can make existing problems disappear. Regardless whether you only stop the thread you're debugging or you're stopping all of them and just step through one.
>>
>>51452683
Sure, that's *possible*. I've been in a situation like that personally. That hardly makes multithread debugging "pointless". It can be incredibly useful the freeze all threads, and see what the current state of each thread is at a given time to learn more about what might be causing you problem.
>>
I wanna do something low level. I'm fucking tired of web apps and shit. wat do?
>>
>>51452854
I feel your pain. Tired of all this 'web app' faggotry
>>
>>51452854
Buy Arduino.
>>
>>51452854
Make a VM.
>>
>>51452854

Android App
>>
What are some good programming sites to keep up with? I love reading programming articles but it feels like every programming site has turned to mostly navel gazing programming culture discussion and "language hits version 1.X!"
>>
>>51453355
stack overflow is the only one i use
>>
>>51453355
>>51453465
>stack overflow
only programming site that actually focuses on programming
>>
>>51452207
As is, red, provided that you do matrix times vector and not vector times matrix
>>
File: index.jpg (11 KB, 195x258) Image search: [Google]
index.jpg
11 KB, 195x258
Is this book still worth reading, even with the outdated code examples and instruction? And if so, why?
>>
I am practicing with some standard coreutils like grep, sed and sort. Right now I'm trying to sort the output of last by the day of the month on which the user logged in, regardless of month. so I tried something like this
last | sort -n -k6,6

But some numbers are still out of order when I do that. What would be the correct command?
>>
>>51453994
It's a great book if you're new to C. Once you've finished the book, read up on the latest C standard.
>>
Why would anyone unironically program in Brainfuck?

That syntax is hard to understand for the sake of being hard. A better solution is just program in Assembly, which is literally computer language and thousands of times faster.
>>
>>51454041
Are you retarded? Why do you think the language is called Brainfuck?
>>
>>51454041
As a challenge
Using it to train other key concepts like writing interpreters/compilers
Perhaps to reason about things, since the language is so small (unlikely)
>>
Guys I'm trying to display a chart with ASP.NET MVC from a Mysql database. I have found hundreds of online tutorials but none is working for me.
If I try to do it directly in the view then I get an error
>{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}
@using WebMatrix.Data;
@{
var db = Database.Open("MySQLConnection");
var data = db.Query("SELECT user_IP, user_Country FROM user_stats");
var myChart = new Chart(width: 600, height: 400)
.AddTitle("Naslov")
.DataBindTable(dataSource: data, xField: "user_IP")
.Write();

}
>>
>>51454053
Are you blind? Those nigger cocks on your eyes are preventing you to read "unironically"?
>>
>>51454077
you really should be doing this stuff in the controller and not in the view itself
>>
>>51454087
You're still retarded for asking stupid questions.
>>
>>51454097
I know, the view was my last resort since I tried doing it in the controller but I get an error
>data does not exist in the current context
        private void chart(String userIP, String userCountry)
{
cWebTrafficDb checkUserStatsWrapper = new cWebTrafficDb();
checkUserStatsWrapper.cmd.CommandText = string.Format("select * from user_stats where user_ip = '{0}'", userIP);
MySqlDataReader reader = checkUserStatsWrapper.cmd.ExecuteReader();

cWebTrafficDb insertUserStatsWrapper = new cWebTrafficDb();
var myChart = new Chart(width: 600, height: 400)
.DataBindTable(data, "Name")
.AddSeries("Default",
xValue: data, xField: "Name",
yValues: data, yFields: "Price");
}

Disregard the select and variables.
>>
Hey /g/. I have a C struct (struct1) that contains a pointer (struct1.pointer) to another struct (struct2). When I first initialise struct1, I set its struct1.pointer to NULL. Then, later, I change it with struct1.pointer = malloc(sizeof(struct2*)). The problem is that I get a memory corruption error in the malloc. Am I doing something fundamentally stupid here ? It seems that the error disappears when I do not set struct2.pointer to NULL, but I get another crash somewhere else in the program because struct1.pointer contains garbage values.
>>
>>51449735
>implying you can't have a referentially transparent functional programming language with manual memory management and no GC
>>
>>51454399
Why not just sizeof(struct2)? You are trying to dereference it with that asterisk, aren't you? If so, what are you trying to dereference exactly?
>>
This fucking C++ ebook I'm reading for an EE course is ridiculous

sometimes it's the little things:
   string lineString;        // Holds line of text
>>
>>51454480
Because I'm one dumb motherfucker.
Thank you Anon.
>>
File: when the bomb doesn't go off.jpg (23 KB, 448x373) Image search: [Google]
when the bomb doesn't go off.jpg
23 KB, 448x373
Why are programming textbooks so awful? I'm really starting to think that the grim truth about programming is that if you don't start young, you're pretty much fucked. Something about how kids learn and blah blah blah, but the stats say that programmers pretty much never read books on the subject. And I have literally never met a decent programmer who wasn't at least a middle class white kid who played Doom and shit, even curries start young. Name one well known programmer who started past age 18.

The learning curve seems really weird, it's not like other difficult subjects. With stuff like graphic design you can pretty much just gruel through it and make progress, but with coding you seem to either get it or you don't, and I've spent hours getting almost nowhere. Website tutorials on programming are terrible, textbooks on programming are terrible, so how the hell are people learning to program?
>>
>>51454534
Are you learning by yourself, or is someone teaching you this stuff while you are reading up on programming?
>>
>>51454534
Internet resources are often written by people who don't know what they're talking about themselves.
Textbooks are often written as a supplement to university courses.

You're just finding inappropriate material.
>>
A alternative lexical analizer generator, the idea is replace the old Lex and Flex
>>
>>51454534
buy books about programming in a book store. not university text books.

What kind of stuff are you trying to learn?
>>
>>51454564
>>51454568
I'm learning myself and wasting weeks on bullshit.

What typically happens:

>hey this book looks good
>starts by explaining the difference between software and hardware
>of course I already know this because I'm not 5 years old
>next page: wall of text involving a shitload of unexplained concepts that I only vaguely know from reading and giving up on other programming textbooks

It's retarded, a book will assume you don't know the difference between hardware and software, then the next page expects you to be compiling from notepad. I'm getting nowhere because instead of working through the books like any other subject, I'm getting progress-halting stuck on every other page.

>oh look here's a simple concept he could have explained in two sentences and it's mired in such obfuscated language that it took me 3 hours on google to realize I need to use single quotes instead of double quotes
>>
>>51449718

Where do you guys get ideas for projects? I'm here learning Python (coming from Java/Android) but I have zero ideas on what to build.
>>
>>51454647
You know, you're allowed to Google specific things you don't understand when reading a book.
>>
>>51454534
You don't need to start programming early in life, but your brain probably needs to have a proclivity for math/logic in order to easily absorb programming concepts. I started programming when I was 22 and I've had no problems.
>>
>>51454627
I've tried books on C++, Java, and Python, but I would prefer to actually have a solid foundation of knowledge that seems to come with knowing a low level language.
>>
>>51454534
>filename
kek'd
>>
>>51454660
read in a list of names and numbers and store them in a binary search tree based on the name
>>
>>51454664
Reread the last line of the post.
>>
>>51454683
so... get a book on C then? What are you trying to accomplish with programming?
>>
>>51454695
Alright, I'm not sure what your problem is then, other than having ADHD.
>>
what's 'dynamic programming'?
>>
>>51454689

Lol I don't wand to build some shit algorithms dude, that's boring.
>>
>>51454683
you need K&R
>>
>>51454716
programming with a dynamically typed programming language.
>>
>>51454716
Marketspeak for "memoization".

>>51454749
No.
>>
>>51454749
C++?
>>
>>51454697
What is a book on C that doesn't go from

>here's the difference between software and hardware

to

>lmao hack into the FBI mainframe and defeat the matrix

on the next page? That's pretty much my only criteria. Haven't checked out any books on C but what are some good ones?
>>
>>51454762
>having trouble with the command line
>>
>>51454647
What book(s) are you reading? Post some of the concepts you feel were just "dropped" on you.
>>
>>51454761
that's statically typed, not dynamically typed.

>>51454762
Dunno. But then I haven't read any books like that before either. A thing with learning a programming langugae sometimes is that there's a lot of concepts you have to understand at the same time before you can understand how anything really works. There's no avoiding things appearing complicated at the start. But if you read a good book on it from cover to cover you should know everything you need to know to write good code.
>>
>Foundations of Python network programming

Anyone read this? I'm thinking of doing some networking programming.
>>
>>51454647
>notepad
There's your problem. Get into Linux and you'll find programming a lot more convenient and easier to understand.
>>
>>51454399
>sizeof(struct2*)
That's returning the size of a memory address I think? In which case that almost certainly ends horribly.
>>
>>51454534
I was similar, I couldn't understand it for the life of me, you just have to have it explained in a way that makes it click.
I think my main problem was while I was reading it I wasn't actually understanding it, I was just reading it and hoping information stuck (that's what happens when you go from college to uni I suppose). Don't treat it like a normal book.
Also, the exercises in those books are really useful for a beginner, be sure to do them.
>>
>>51451869
>C#. It's too good.

show me a real problem that you actually solved because it seems like you're retarded
>>
>>51454850
Why not Go?
>>
>>51455017

I wanted to learn python and know nothing about network programming besides building some simple servers and such, so I thought it might be a good idea. Do you suggest otherwise?
>>
>>51455053
I'm not very familiar with Python, so I cannot help you.
Someone on /dpt/ suggested me using Go for my server and I'm pretty happy with it. But that won't help you if you want to learn Python.
>>
>>51453355
define programming sites
what kind of topic gamedev/webdev/embeded/...?

if you have problems/ need code examples use google which will probably lead you to stackoverflow 90% of the time

General Programming news, dunno, might be interesting if someone knows a good site. For specific topics/languages I use google and check out latest blog posts or official websites.

I also occasional listen to some presentation on InfoQ.com.
>>
ignore tranny threads

report tranny posters
>>
>>51455110

I don't even know dude, I think I'll just skip Python for now. I have literally no idea on what to build with python and just further reading books is pointless now. I've already read the official tutorial.
>>
>>51455110
are you a noob? if so, did it take you long to learn Go?
I'm happy that people are happy with Go, but I wonder how much time would it take for a noob to learn Go.
>>
>>51454983
C# is one of the best productivity languages out there though.
>>
>>51455295
Not >>51455110, but I've been looking at Go recently as well, seems like a fairly beginner friendly language.
>>
>>51455383
>no macros
>shitty templates, no specialisation
>>
Hey /g/uys just started learning Java this month and so far I still am pretty new. Although I have this idea for a website that I think has quite a bit of potential. Just wondering if anyone could give me some advice.

What should I learn if I want to create my own website?
Can my (future) knowledge of java be used in developing my website?
Also would any experienced programmers here be interested in talking with me?
>>
>>51455429
doesn't have macros, but has a lot of other nice things.

What do you mean by specialisation?
>>
>>51455503
template specialisation

and macros are a big deal
>>
>>51445700
>>51445717
>>
>>51449928
>>>51449847
I was thinking "good parody, OP" and then I googled the text.

Functional programming is the programming equivalent of those fedora atheist memes.
>>
>>51455525
I know. And C# has a lot other nice features too.
>>
>>51455554
doesn't have template specialisation
doesn't have macros
forced garbage collection

it's shit
>>
>>51455552
someone post the article where they compare functional programmers to cult members
>>
>>51455410
you sure? the slices vs arrays thing is kinda difficult to explain. also, variable shadowing, error management, ... and let's not even talk about concurrency
>>
>>51455629

there's no comparison needed, they're one and the same
>>
>>51455585
>forced garbage collection

This is how I know you don't know shit. And here you were trying to call me out.
>>
>>51455585
if you like metaprogramming so much why don't you try a language with real macros?
>>
>>51455585
there are dialects of C# without any GC and there's also a way to disable it inside parts of your code. please go read up on this shit before you start arguing about it
>>
Just let me get this straight.

When you talk shit about "functional programmers" are you talking about "people who use functional programming languages" in general or about "people who talk about how using functional programming languages makes them superior"?
>>
>>51455676
Fuck off speech impediment, C++ macros are turing complete

>>51455663
It specifically calls it unsafe, it actively doesn't want you to use it
>>
>>51455720
there isn't that much of a difference
>>
>>51455733
Well, there's a pretty big difference between essentially attacking functional programming itself and attacking those who use it to act elitist.
>>
>>51455727
>C++ macros are turing complete
so is brainfuck
>>
>>51455663
Is shilling for C# all you ever do in these threads?
>>
>>51455663
>TRIPCODE
>>
>>51455585
Why so salty?

Managed memory is nice when you can spare the performance costs. There's awesome debugging tools like being able to edit code on the fly. async/await keywords are extremely useful these days.
>>
Daily reminder - if your language doesn't have partial specialisation, it doesn't have templates and it doesn't have generics
>>
Why have templates when you can have dependent types and pattern matching over those types?
>>
>>51455727
>It specifically calls it unsafe

Fair enough, but it also means that GC is not forced. And it's not even akin to sun.misc.unsafe because it's sticking around, just for interop reasons.

>>51455760

Nah, I actually don't talk about C# that much.
>>
>>51455819
because complex type systems frighten most programmers (probably since they're so heavily based in math)
>>
>>51455819
>tfw you've never used templates
>>
>>51455585
What kind of stuff can you do with templates that can't be done with generics just as easily?
>>
>>51455899
see >>51455819
also see any decent use of templates ever
>>
>>51455899
Templates can do more than just types. You can have them take values (units of measure in C++ do this: http://www.boost.org/doc/libs/1_55_0/doc/html/boost_units/Units.html) and they can be partially applied.
>>
>>51455925
Templates aren't fully dependent types, they're just type-level programming.
>>
File: fug.png (97 KB, 499x504) Image search: [Google]
fug.png
97 KB, 499x504
Hey guys, is C a good language for learning, or is the whole 'more efficient coding in other languages after learning C' thing a meme?
>>
>>51455960

You should learn it just for the sake of learning C. It'll come in handy at some point.
>>
>>51455930
What's the point though exactly? Why pass a value to a template when you can just pass it to a real function instead?
>>
What is the proper way to delete all data in a hashtable in c++?

it consist of a string and a pointer.
My plan was to loop through the table and call delete on all the pointers and then clear the table but that is not possible.
For now I just call delete on all pointers but I would prefer to remove the indexing string as well.

What is the approach?
>>
>>51455960
Learn C, Forth, Common Lisp, Java, Prolog and Haskell.
Then you can pick any language you want and stick to it, because you will have mastered every paradigm in existence.
>>
>>51456075
good list
>>
>>51456087
Thanks. I feel like it might be lacking something actually. Any ideas on what's missing?
>>
File: C++.png (66 KB, 1418x624) Image search: [Google]
C++.png
66 KB, 1418x624
// Daily Valid C++ Reminder //
>>
>>51456016
It has the same point as dependent typing. It lets you move code into the type system, both to save code from being used later and to have slightly increased safety (although dependent types are significantly safer than plain old templates).
>>
>>51456096
one of the array-based languages is the only real hole I can see
>>
>>51456075
Forth seems redundant, given C
Also, Haskell and Prolog could be coalesced into Agda or Idris
>>
>>51456126
Runtime edition

Meta<int> operator "" _mi(unsigned long long int x) { return store(int(x)); }
int main4()
{
return ((3_mi & 4_mi) | Demo<int>::Squared) >> Ty<Demo<int>::Sum>();
}
>>
>>51456075
>>51456149
>>51456154
We should make a "language wheel" (like the colour wheel), with the most important languages as "primaries" and so on.
>>
>>51456239
>with C++ in the centre because it's the best multi paradigm language
>>
>>51456126
>>51456237
what's the difference between brainfuck and C++?
>>
>>51456257
No, with C++ *near* the centre because it's that disgusting grey-ish looking colour you get when you mix different colours.
>>
>>51456274
That makes a lot of sense actually
>>
>>51456268
C++ operators are overloadable
>>
>>51455542
>fuck is C++ really the best language
yep
>>
>>51456154
>Forth seems redundant, given C
what the fuck ??
>>
>>51445700
The one I'm designing

>good templating
>macros
Dependent types

>operator overloading
First-class type classes + custom, mixfix operators

>is not interpreted
>has lambdas
Check
>>
>>51456338
>The one I'm designing

Which is?
>>
>>51445700
>>51456338
Oh, and it does have manual memory management

>>51456359
I've posted about it several times, the one with dependent/linear types
>>
>>51456368
>I've posted about it several times

Go on. :)
>>
>>51456368
Which is?
>>
>>51456268

I should point out it's only valid C++ once you have about 7 relatively short helper classes. The | and >> through and into functions are operators overloaded on a template class. The _mi is a user defined literal that automatically converts literals to literals of this class. The functions have some constraints - if you're using the compile time version, you need a struct that can be templated with the argument types and has a static Invoke function. (And you wrap it into an object with Ty<...>()).

Basically just a small library. The runtime example really is simple - it just has to take the right type. You could use inline lambdas if you wanted.

>>51456338
Do dependent types allow for partial specialisation?
>>
>>51456384
>>51456397
Unlike most projects on /g/, I've decided to just work on it and not make up a name/logo/CoC before it has any substance. So it's not really identifiable.

I'm the one always going on about linear capabilities and stuff like that.

>>51456415
What C++ calls template specialization is just pattern matching over types. So yes, "partial specialization" is definitely possible.
>>
>>51456483
>I've decided to [...] work on it

Well, you're already 90% ahead of most posters here.
>>
>>51456503
And I have actually gotten a good bit done. I've mostly formalized it into a type theory, although I've been reiterating on it and not making substantial (to someone on the outside at least) progress lately.
>>
>>51450220
Holy shit you fucking faggot you still haven't read up on tables? I told you to like two days ago. You aren't going to get anywhere programming video games if you don't know how to program.
>>
>>51456525

Sounds pretty neat, m80. Now, of course, I'm a retard about all this fancy type-shit and whatnot, but it'd be interesting to learn more about it, and take in a new language at the same time.

Keep us updated, I guess.
>>
>>51456483
no logo? why no logo? you should have a logo bro.
no logo = no real project.
>>
Why aren't you coding in nim, /dpt/?
>>
>>51456338
How do dependent types make for better macros? I'm sure he was talking about making the macro system more than text substitution by allowing the creation of language syntax like Rust.
>>
>>51450156
that could be anybody on this website
>>
>>51456415
>Do dependent types allow for partial specialisation?
You can partially apply the types~
>>
>>51456338
ayy same here, although im trying my best to incorporate a true macro system
>>
>>51456706
>like Rust
you mean like lisp right?
>>
>>51456774
Originally yeah. I'm not super familiar with Lisp, which is why I said Rust.
>>
>>51456706
Well, macros are just compile-time programming, and so are dependent types to a certain extent. I suppose dependent types aren't REALLY usable as a full macro system unless you have some way to access the AST of the language (like Template Haskell).

The presence of mixfix operators lets you do a lot of custom syntax. Idris also has a system that makes things like monad or arrow notation part of the standard library, so I'll probably look into that as well.

The thing about macros is that they're not really part of a language, they're ways to program the parser, at least when talking about compiled languages.
>>
>>51454041
https://esolangs.org/wiki/Joke_language_list
>>
don't forget to filter:
/^!/
>>
>>51456877
What have you done so far and what are your problems (specify)?
>>
>>51456871
Or maybe 'Anonymize' on 4chanX?
>>
Long time lurker, first time poster.

My dad has done programming for most of his adult life, and always wanted to teach me. The most I ever did was some Java scripts in Eclipse and some tinkering with an Android VM. That was years ago, and now I'm bored enough to get interested in it again.

Where should I start? Is there a pastebin or a beginners wiki I can read? I'm interested in stuff like C#, Python and Ruby. Or really anything else.
>>
>>51456903
you still see tripfag posts and it gets confusing when people refer to them by name
best policy is to filter tripfags and recursively filter any post that replies to a tripfag
>>
>>51456947

Thank you for posting.
>>
>>51456937
start wherever you like. What kind of stuff do you want to do with programming?
>>
hey guys can i get some help with a cache simulator?
"All further lines contain integer addresses that your simulation attempts to read from main memory through the cache, one per line."

How do I read from the main memory?
>>
>>51454087
>unironically using the word 'unironically'
>>
>>51456965
The user first inputs
# sets,
# lines per set
# bytes per block
m, where m is m-bit addresses
>>
>>51456961
I can't imagine I would enjoy doing it professionally, but I've always had tons of personal productivity program ideas floating around in my head.

I mostly want to use Python for visual novels and Ruby for personal websites, but I feel like that would be easier once I familiarize myself with a widely known and supported language (learn how to learn).
>>
Criisizing Go for not having generics is a joke. Generics is an example of why C++ is bad. C++ is not a 'multiparadigm' language, it has a single paradigm which is everything is inhertance based OO. The fact that everything is a class or sub-class is very constraining and a very narrow way of looking at programming problems. Design patterns have to be used to break out of this way of programming. You cant program imperatively because even things like strings, I/O, vectors are all part of OO. When you have to use preprocessing macros (thats all templates are, saying they are turing complete is stretching the definition) to hide code should be an indicator that something is wrong. C++ is dependent on macros to change the language because of its instance on being backward compatible with C. The core language of C++ can never be change so the new language standards are constant heaping on new template libraries to do things that would be trivial to add to languages like Go and D. C++ is a legacy language born out of tight memory constraints and primitive operating systems that forced the use of systems languages to write directly to memory. Those days are gone, and C++ should be gone as well.
Thread replies: 255
Thread images: 23

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.