[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: 314
Thread images: 21

File: 1480546174720.png (102KB, 1000x1071px) Image search: [Google]
1480546174720.png
102KB, 1000x1071px
What are you working on, /g/?

Old thread: >>58137159
Functional programming thread: >>58141396
>>
>>58141853
bitches delete this it's upside down
>>
>>58141853
I see you didn't bother checking to see if there was another thread
Retard
>>
Do people actually go the the functional programming thread?
I like the idea. It's more detached from most other programming.
>>
>>58141648
I'm honestly not sure I follow.

Why would any of that need classes with objects?
Just make a module for it. $_POST whatever is needed, and then depending on certain POST criteria, switch between your modules and only load the modules related to the POSTed data.

if it's credit card info, name, etc. whatever, you would just need to send the (serialized if AJAX) array, ofc with some form of encryption, and... idk...
switch($_POST['PAGE_LOAD']){
case 'NEW_PAYMENT':
require_once('modules/paymentProcessor.php');
//and then other options
}
//This time, I didn't forget the brackets


I just see no need for classes in features like this
>>
>>58141853
Don't change the OP format, idiot.
You don't need to link other stupid threads.
>>
why this image every time
there are several images in the world
>>
>>58141883
Check the last thread, it was good
>>
>>58141888
Because it doesn't distract from discussion generally.
It's good to have a standard.
Like how Dwight is for /sqt/
>>
>>58141893
last thread was way better than this one
>>
A tech startup is difficult.

I have my plan and everything but what's the point?

Why not just generate revenue first then start a company?

Do I need something groundbreaking before finding investors like y-combinator?

To live comfortably I would need about 2.5 mil ad views per month which would be about 300k uniques. At that point whats even the point of seeking investors for seed?
>>
>>58141885
>Just make a module for it.

The modules would need modules, and that maze would eventually become unwieldy.

OOP would be more elegant when you show orders to the user and to the fulfillment people, and to the auditing tools, etc.

OOP is scoped modules.

Imagine trying to process hundreds of orders in a loop with your modules. Global state? Side effects? It's an accident waiting to happen. Objects data-hide keeping scope clean.
>>
>>58141936
Well. If you throw away others money you're risking less than when you throw away your own money.
>>
>>58141936
investors == advertising

that's the mystery.
>>
>>58141936
ycombinator doesn't give you a whole lot of money. it seems to be more about connections than anything else
>>
>>58141955
A valid point. Fortunately it cost me 5 dollars a year for the domain, servers will scale, 100 ios dev fee.

200 a year isn't really harmful to a person funding theirself.
>>
File: lainroom.png (1MB, 2400x1800px) Image search: [Google]
lainroom.png
1MB, 2400x1800px
>>58141736
halp!
>>
Working on a terminfo/termcap handling library for Rust.

The one available in the term crate doesn't even support extended capabilities, which makes it useless for anything modern.

in b4
>terminals
>modern
>>
>>58142002
Sounds to me like it'd make sense to just not bother with funding and see if you run into troubles rather than worrying so much.

I'm sure investors would prefer to see a more mature project than an immature one either way.
>>
>>58141946
I suppose that makes sense.

I mean, I WRITE PHP, but I'm not 100% sure how it operates under the hood.
Aren't POST requests handled procedurally, so even if a million came in at once, it still follows a FIFO processing structure?
In other words, as long as the array is the only data to be processed, how would it cross requests if they're not time-based?
>>
File: neuralnet_cropped.webm (533KB, 646x268px) Image search: [Google]
neuralnet_cropped.webm
533KB, 646x268px
Here's some progress on a little neural net I whipped up to play my simple console hurdle game. I'm using Encog and it's actually really straightforward.

The net is feedforward and is trained using resilient propogation. It's got three inputs (tiles until the nearest hurdle, tiles until the second nearest hurdle, " " third nearest hurdle), a hidden layer with two neurons, and two outputs (the preference for a long jump and the preference for a high jump). I also have a midair dash feature that's available in the regular version but I'll have to adjust the net in order to use it (right now it doesn't process the net to determine input when it's jumping).

Anybody worked on similar stuff before? I'm trying to optimize the design of my net. The ultimate goal is a simple RTS/Total War-style game in Unity that plays itself against hard-coded AI as well as against human players.
>>
>>58142025
This is my experience with a lot of Rust libraries.

They're functional, but often pretty limited.
>>
>>58141900
There are four /dpt/-related pictures: one with upside down girl and SICP, the same one but with K&R C, Ritsuko and Misato pictures.
>>
>>58142014
at cursory glance, your makefile looks reasonable but you should add a default target
>>
We need to host a technical blog and some guidelines, and possibly other documentation. Where is/are the best place/places for this?
>>
>>58142025
>>58142084
Except winapi. That's a good one. Very complete.
>>
Hi guys. On the phone, can't type much. Just here to say you are the best programming community outta here and the best subreddit of /g/ by far. Hope you all got a nice year programming wise. See you on christmas at midnight to exchange our cheers in our favorite programming language.
>>
>>58142225
github lets you host static pages for free, you could also just make a wordpress
>>
>>58142225
>>58142248
We're not on github, this is for private code.
>>
>>58142261
to be clear: you don't want people outside of your organization to see any of this?
>>
>>58142281
Yes.
>>
>>58142236
Except winapi is just raw bindings to the Windows API, it doesn't implement anything by itself.
>>
>>58142300
For all the COM interfaces he's implemented Deref for superclasses.
>>
>>58142225
>best place
Some paid hosting service/self hosted
>free
Bitbucket has been ok in my experience.
>>
>>58142320
That still falls under the same thing, it's just wrapping things up, it's not an implementation of anything.

It's on the same tier as the objc and friends crates.

Or nix.
>>
>>58142373
It's still really thorough for something that hasn't been autogenerated.
>>
So we've concluded SCIP as the only book to even mention procedural programming?
>>58141008
Someone need to get on writing a book.
>>
>>58142385
I'll give you that, but we were talking about something else, something on the line "here's a mail parser, oh wait, you need to extract attachments? not done yet! (issue opened 8 months ago)".
>>
>>58142389
But isn't structured programming is much about procedural programming?
>>
>>58142482
That's definitely how most Rust libraries go.
>>
>>58142491
Well its like if I were asking for OOP and you gave me procedural.
>>
>>58142523
When I learned VB.NET after VB6, I felt no difference.
>>
File: 1481405173555.jpg (64KB, 300x300px) Image search: [Google]
1481405173555.jpg
64KB, 300x300px
>>58142239
Y-y-you are nice too.
>>
If I were to make a modem emulator, what should I take into consideration?
>>
>>58142877
The noise it makes is really important.
>>
File: board2.jpg (129KB, 970x728px) Image search: [Google]
board2.jpg
129KB, 970x728px
I'd like to create a program for 8-bit microcontroller (AVR) to control the traffic lights for a T-junction with pedestrian crossing. I'm planning to use some LEDs as traffic lights and two pushbuttons.

How should I get started with it?

I currently have this shift register IC and some LEDs on the breadboard. It's just a test circuit to see if everything works. The microcontroller model is AT90S2313.
>>
Guys, need a nickcame for my programming team
>>
Name my C framework for TCP and UDP servers that can be used to make online chats, games, and so on.
>>
>>58142981
Computer Wizards
>>
>>58143052

Name it UGSP - Unprotected Gay Sex Protocol.
>>
>>58143075
It's not a protocol though
>>
>>58143096

It is now.
>>
>>58142225
I didn't really know what I was looking for, I was looking for a static site generator. I'm going with Jekyll.
>>
how do i prevent multiple people from opening up the same form and over writing each other with the data they input? i'm using php
>>
>>58142065
That's pretty retarded my dude. You should be using reinforcement learning for this.
>>
>>58143290

Use some sort of unique ID? What are you doing exactly? And why are you using PHP?
>>
>>58143290
Give an example of how this would happen.
>>
>>58143365
i'm over my mind
>>
>>58143365

idk just decided on php/pdo. My app will be used by a small team to CRUD to a database. Each has their own computer. If person A opens one of the forms that will write to the DB and before they submit it person B opens up the same form and inputs data and submits, the db will keep only the data the last person entered. Hopefully i'm explaining clearly

>>58143379

idk thats why im asking
>>
>>58143447

basically is there anyway i can "lock" the form from being submitted if the form is already opened by someone else? it's just a form in a new window/tab
>>
>>58143477
Yes. Check and see if there is data in the database. If there is then print out "Form has already been submitted." Instead of the form.
>>
>>58143518

the form populates data whens its opened and each user might change some of it if they have to, so i dont really know how checking if there's data or not would work. There's always some data.
>>
>>58143561
So then you want people to be able to submit over other people submissions...

Oh..

Add column boolean "edit". Set true when form in focus or on document load, set false after submission or hitting cancel button. If edit is true then disable form inputs and say "someone is already editing this document."
>>
>>58143447
Why would want to lock a row just for displaying a form?

>>58143614
If the person simply closes the window instead of clicking cancel the row will be locked forever.
>>
print('{:b}'.format(5))[/code[

why does the number 101 appear?
>>
>>58143670

i dont. I want to say something like "hey you have this form open and its order number 123, this order number is currently under edit, you can't save under this order number until the other user is done"

OR i was thinking if a user saves, then somehow the other user will see the form update immediately if they have it open?
>>
>>58143706
b is binary
101 is 5 in binary
101 = 4 + 1
>>
>>58143706
OH nevermind, :b was binary

excuse my retardism
>>
>>58143708
>i dont. I want to say something like "hey you have this form open and its order number 123, this order number is currently under edit, you can't save under this order number until the other user is done"
That is bad practice. One user can lock the system. Save both changes and apply only the most recent one.

You may optionally offer a merge option for someone.

>OR i was thinking if a user saves, then somehow the other user will see the form update immediately if they have it open?
That is also bad practice. But you can do with JS.


Do you want to do a distributed document editing system? If so it's better to just use git.
>>
>>58143780

yeah right now its set to only save the most recent one. I guess it's really tough to prevent. Even if 2 people are logged onto the same facebook account or something and they change their profile picture, the last persons will only count. I think...
>>
>>58142239
>best programming community outta here and the best subreddit of /g/
>subreddit of /g/
>subreddit
>>
>>58143670
Smcreate aan update column then with TIMESTAMP.

If x minutes passes then reset edit to false.
>>
>>58143670
Your alternative is using sockets for live editing. You wont get much better solutions with PHP. Create it first, then solve the problems that arise like "what if they hit the x"
>>
>>58143808
Now the user has only x minutes to edit the document. Which might be too long and still lock the row or too short and don't allow for editing properly.

>Your alternative is using sockets for live editing
Just timestamp each edit and use the later.

>Create it first, then solve the problems that arise like "what if they hit the x"
Stop posting.
>>
>>58143831
>>58143866
Second part meant to (You)
>>
>>58143808
>>58143831
>>58143866
>>58143877

lol im just gonna leave it as is. The chances of multiple users having the form opened for the same order number and updating that info are low. Just something I thought of that worried me a little bit
>>
i've been learning python but also interested in game development. what lower-level language should i learn?
>>
>>58143928
C. Ignore C++ fags. C++ is a disgrace. Your C code will still be compatible with C++ code and libraries.
>>
>>58143928
CCCC
C
C
CCCC
>>
>>58143928
C is awful for games because it has almost no abstraction and misses many libraries. Unless you're alright with starting from a very low level like Handmade Hero, C would be a terrible choice.

It would still be worse than C++, Rust, etc. if all you're using is C libraries.

>>58143939
C cannot use C++ libraries unless they have a C API.
>>
>>58143928
https://hero.handmade.network/episodes
>>
>>58143928
C++
>>
>>58143956
>because it has almost no abstraction
Only if you're incapable of thinking outside the confines of OOP.
>and misses many libraries
You can write C code and compile it with a CPP compiler. Just use things like methods when you need it for one of the libraries you're using.
>>
>>58143983
C has no:
templates
lambdas
overloading
type inference
To name a few things that aren't OO.
>>
>>58143956
>C cannot use C++ libraries unless they have a C API.
Just use a search engine for fucks sake.
>>
>>58143993
So?
If you had just those, and not the means of abstraction that C has, you'd be completely fucked.
>>
>>58144015
Search engines magically allow C to call functions with C++ name mangling?

>>58144040
C has no means of abstraction that C++ lacks.
>>
>>58143993
>templates
meme
>lambdas
slightly useful
>overloading
Just use an array.
>type inference
meme
>>
>>58144049
>Search engines magically allow C to call functions with C++ name mangling?
Yes.

>C has no means of abstraction that C++ lacks.
C++ has nothing over C that is actually useful.
>>
>>58144049
Sure. And I'm telling you that isn't anywhere near as big of a deal as you seem to think.

Also, nice tactical retreat. From "C has literally no abstraction" to "C has fewer means of abstraction than C++".
>>
>>58143939
>>58143943
>>58143956
>>58143971
what about C#?
>>
>>58144087
I said almost no abstraction. It has functions and opaque pointers and that's really it.

>>58144091
C# is not very low level but it is very good for gamedev using a framework like MonoGame.
>>
>got a copy of K&R ANSI C
>struggling through the first chapter's exercises
it'll get easier right?

it's not cheating if I look up the answers from time to time if it helps me understand where I'm going wrong, right?
>>
>>58144091
Never used it but if you want something more high level might as well use something more portable and that actually works well. Java.
>>
>>58144091
C# is cancerous and OSGTP must be eliminated.
>>
>>58144091
C# isn't really much lower level than Python.
That said, I do like it and the fact that microsoft is open sourcing a lot of it is encouraging.

Unity (scripted with C#) is a pretty good game engine for your purposes.
>>
>>58144106
>it'll get easier right?
No.

>it's not cheating if I look up the answers from time to time if it helps me understand where I'm going wrong, right?
No, it's meant for people that already know how to program. Looking the solutions is probably the best way.
>>
>>58144098
by "lower level" in >>58143928 i just mean lower than python, being a very high-level language.

sorry i'm not very knowledgeable.

>>58144120
>>58144117
>>58144108
thanks anons. so do you think C++ is necessary? i'm discounting C posters as trolling unless they are actually serious?

i do have a copy of the c programming language i have yet to read, so i cant say i havent thought about it
>>
>>58144091
Depends on what your goal is. You can certainly make games in C#, but that's not C#'s primary domain. You want to learn C++ at some point if you are interested in professional game development.
>>
>>58144140
C++ is better than C# if you're interested in making a game from "scratch" (i.e. platform APIs).
>>
Currently, I'm working on incorporating Opus into my TV program. I'm also thinking about integrating RSS (or Atom) and email notifications into my TV program. Does /g/ use feed readers?
>>
>>58144140
>i do have a copy of the c programming language i have yet to read, so i cant say i havent thought about it
Just fucking read it. It's less than 200 pages and you need only 40 to start running. Also if you know C you basically will know C++(a meme language, keep in mind).
>>
>>58144140
You can do fine with C and SDL. SDL is one of the most popular libraries. It works with C++ too, of course.
>>
>>58144106
It gets harder from there, so you just have to get better. Review the text and do ALL the exercises.
>>
>>58144162
>C++(a meme language, keep in mind).
Can /dpt/ sink any lower than this?
>>
>>58144154
>RSS

What year is it?
>>
>>58144150
>>58144149
thanks. my goal isn't quite making games professionally, or "from scratch", but since I am running linux i don't really have access to the more popular engines like Unity and Unreal, or even Game Maker (my tool of choice until I switched OS's).

>>58144162
>>58144163
Will do. I hear it's a bit archaic as a reference book, anything to watch out for?

can i throw some C code in a text editor and have it run like any newer or high level language?
>>
>>58144126
then how the hell do I "learn to program"?

I've asked in here before and people give me conflicting answers. I ask for beginner's resources, they tell me "K&R and write your own programs" but I've been down this path before and it never works.
I'm sure you've heard this spiel before so I won't say what you already know

I have a copy of SICP coming in the mail but it's very technical. I mean, it's worth a shot, right?
>>
>>58144170
>if a lot of people use then it's good
fuck off pajeet

The developers have no idea of what they are doing, they just keep adding abstractions instead of improving what they already have.
>>
>>58144140
>>58144163
C and SDL would work fine.
>>58144174
>not using RSS
>not following Stallman's feed
>>
>>58144190
I thought meme languages were languages that not many people use?
>>
>>58142944
FYI, the pushbuttons on American crosswalks don't do anything.

If they did, it could create a situation where some lame fuck couldn't hobble across in time, violating the Americans with Disabilities Act
>>
>>58144188
I actually learned to program with K&R. It is not meant to that but will give you an excellent base.

I read SICP a long time ago, I think it's good. It is much easier if you already had the first semester of a STEM course. Which I hadn't.
>>
>>58144154
I use Venus on my Pi and then have it display the feeds over the local network with nginx.
>>
>>58144190
>>58144199
Or languages deemed "useless"? Like Haskell?
>>
>>58144199
Meme languages are languages that aren't used in the real world. Haskell and Brainfuck the only 100% meme language that I see.
>>
>>58144188
Also, the best way is probably getting the basics from the book and doing something yourself.

Read the first 40 or 50 pages and take some notes. Then start a small project that does something you like. Learn with the problems it will present you. Keep reading the boot thou.
>>
>>58144229
Yes, so calling C++ a meme language is just ridiculous.
>>
have you upgraded yet, /dpt/?
>>
>>58144199
C++ is a meme language because it just adds feature on top of feature.
The requirements for a new feature, in practice, are:
There is at least one paper about it or;
People ask for it.
>>
File: IMG_20161224_031148987.jpg (207KB, 2000x1125px) Image search: [Google]
IMG_20161224_031148987.jpg
207KB, 2000x1125px
We have (shitty) icons now.
For some strange reason it still shows me friday, but that would be something wrong with that api call, but whatever. Not important atm.

Now we gotta make it look some-kind-of-pretty
>>
>>58144199
>>58144226
>>58144237
(there is no formal definition for the term "meme language")
>>
>>58144250
Not a copyleft license.
I'm not a cuck.
>>
>>58144229
>>58144252
>>58144259
>>58144226
>literally the opposite of a meme

meme languages are widely-used, but bad.

like Java.
>>
>>58144186
I don't know much about Unity, but I would double check that it doesn't work on Linux. I though it was supposed to be cross-platform.
>>
>>58144272
This has never been how /dpt/ used the term until just now.

I will agree that the term is much more apt at describing languages like C++ or Java.
>>
>>58144223
I'm going to integrate a tiny webserver, just enough to spit out the RSS information. I don't know how I'm going to get email to work (anything I send from a local server gets caught by spam filters).

>>58144272
That's retarded, Java is not a bad language. Haskell and Brainfuck are
>>
>>58144235
the problem I've always had is that I get an idea, and the book gives me the tools.

The problem is I don't know how to use the tools to actually implement what I want to do.

It's hard to describe.

For example, I really, really want to make a bare-bones text editor. Like a very lightweight nano.

I know I need input, output, and some small interface.

I have scanf, getchar, and printf.
How then do I make an interface? As in, how do I display a consistent bar at the top of the screen? How do I make the bar scale with the window size? When I'm writing a file to disk, do I need to include some sort of metadata or is that all there is to it?

I guess my hubris is my downfall because I don't want to have to google around and copy someone else's implementation. I want to be able to figure it out for myself.
>>
>>58143831
>just do the minimum and push it, it doesn't matter if it works

God I hate Agile fags

>>58144108
>recommending Java for games

>>58144188
fuck all of that as an absolute beginner, you will hit the wall and burn out almost immediately

https://www.coursera.org/learn/python/
>>
>>58144229
Literally the worst post I've ever read here.

Memes are religions.
>>
>>58144106
If you don't already know how to program, K&R (by itself) is not going to be the best way to learn.

>>58144188
SICP is quite dense, but if you can work through it, do it - it's got some very good info.

>>58144140
Whether you want to write C or C++ code you'll probably want to learn C first because C++ is effectively just C with a bunch of things added in.

>>58144186
Unity works on Linux, nigga.
>>
>>58144188
IMO, K&R is easier. They are very different books though. If SICP is too difficult, look into the book How to Design Programs, which is aimed at beginners. I have not read it myself, but it's supposed to be a gentler introduction to Scheme (specifically Racket).

Sometimes, repeatedly failing at the same thing implies the method is faulty: "insanity is trying the same thing multiple times and expecting different results. On the other hand, sometimes it's really just our fault. "K&R has not been tried and found wanting. It has been found difficult and left untried."
>>
thanks guys. I never got an answer on
>>58144186 though

>I hear it's a bit archaic as a reference book, anything to watch out for?
>can i throw some C code in a text editor and have it run like any newer or high level language?
>>
>>58144268
>gpl cuck
GCC isn't under a strict copyleft license either otherwise all programs compiled by it (they all link to libgcc) would require gplv3 licenses.
>>
>>58143313
Thanks, I'll look into this.
>>
>>58144308
>I have scanf, getchar, and printf
scanf and getchar aren't powerful enough. You need to change the input mode in the terminal so you get individual keystrokes instead of typing until enter is struck. I forget the name of it, but I tried to make an editor before.

Is you editor going to do anything cool?

>how do I display a consistent bar at the top of the screen
You can output control characters to the terminal that allow you to control the position of the cursor. You can also blank lines and the entire screen. I controlled this by creating an old and a new version of the screen, and I jumped to the lines where data is different, blanked the line, and printed it with one print statement (excluding \n at the end). It worked pretty well (when I got it to work). If you want to edit remotely (SSH), I would be weary of blanking and redrawing the entire screen every time. I'll read up on this

>How do I make the bar scale with the window size
You can get the dimensions of the terminal window through ioctl commands in Linux (termio.h header, winsize)

>When i'm writing a file to disk, do I need to include some sort of metadata or is that all there is to it
By metadata, are you talking about last modified date and filename? Those are taken care of by the file system, so you don't have to worry about that. You should be able to pipe the entire file into a ofstream and just output the data (of course you need to open the file with a filename).
>>
>>58144308
>The problem is I don't know how to use the tools to actually implement what I want to do.
Everyone goes through that.

Start with a more simple editor.
It has it own command line.
It can show the content of the file up to, idk, 40 lines a time.
It shows line numbers.
It can display the next 40 lines with a command.
It can show the last 40 lines with a command.
You can pick a line number and edit it.

>When I'm writing a file to disk, do I need to include some sort of metadata or is that all there is to it?
If it's just text there is no need for metadata.


>How then do I make an interface? As in, how do I display a consistent bar at the top of the screen? How do I make the bar scale with the window size?
Platform dependent, look for a cli library and see how they implemented.

>I guess my hubris is my downfall because I don't want to have to google around and copy someone else's implementation. I want to be able to figure it out for myself.
I have this problem too.
Somethings you simply won't be able to figure by yourself without knowing a massive software stack.

You can also download nano or ed and go through the source. Don't copy, just see how it's done.
>>
>>58144369
This should help get you started

https://www.nervanasys.com/demystifying-deep-reinforcement-learning/
>>
>>58144398
>>58144397
that's some pretty sick timing dude
>>
>>58144363

BSD is best license.
>>
>>58144405
true senpai
>>
There is a world filter for f.a.m., lads.
>>
>>58144420
NTR is the worst fetish
>>
File: slowpoke_pokemon.jpg (27KB, 600x655px) Image search: [Google]
slowpoke_pokemon.jpg
27KB, 600x655px
>>58144446
you don't say
>>
>>58144361
Are you are talking about K&R? Yes, it absolutely is archaic as far as the C language goes. But as far as learning foundational programming concepts, it is still useful. And if you're learning C++, use a C++ book.
>>
>>58144063

>Just use an array
I fail to see how this solves the problem at all. You want the same name to be used for functions of different type signatures, including functions of different numbers of arguments.

>>58144420

Apache 2 is best license.
>>
>>58144405
Hadn't noticed the post numbers.

>>58144460
I don't use meme words so I didn't know.
I know there was one on /fit/ in the start of 2015.
>>
I'm also interested in Game Development and have played with SDL and OpenAL but yet to get OpenGL working.

So a few questions:
Would Scheme LISP be good? [0]
Are there any good tutorials on OpenGL with Lisp apart from the demo included with SDL2?
Should I implement a JIT compiler or Bytecode interpreter for AI? [1]
Should I implement the Server <-> Client model early or rewrite later for it? [2]
Is "Computational Oriented Matroids" worth the read for this?
What books should I read?

I already have isolated, simple versions of the AI gene pool, network model, bytecode interpreter, ect...

[0] Currently using Chicken Scheme with SDL2, OpenGL, and OpenAL while flicking through SICP ch 2, 3, & 4
[1] Game AI are part of a genetic algorithm where the game itself is the fitness function. Once each pool AI config has a score the selection process begins to bring the new batch of AI and replacing the bad ones with children from the best + random good. JIT would make running AI code faster but introduce overhead with pool->live. AI also aren't unallocated as allocating every time we need a new one is retarded.
[2] Single player but want to eventually have at least two players at once

It's 2:35am so hopefully the mess above is legible.
>>
>>58144478
>Hadn't noticed the post numbers
I was talking about the timestamp
>posted on the exact same second
>>
>>58144308
some more of the questions that pop into my mind when I'm thinking how I'll make this thing

So the text has been input. I want to use a key combo to bring up a save prompt, just like in nano.
How do I actually listen for the specific combo? The most immediate way I could see to do it is just have a check for "Is _____ pressed?" every time the program loops. But when I start thinking about it, not only is that stupid and wasteful, I again don't know how to implement it.

>>58144397
>>58144398

I used "metadata" because I don't know the correct terminology.
I'm talking about some form of padding with embedded information at the beginning of a file.
Like, "This file is a .txt file. It has UTF-8 encoding. It..." and then after that nonsense is the actual text the user input.

my editor would be more of a proof-of-concept for me, and just a tool for me to practice what I learned. Not really anything anyone else would use. At least at first.

>You need to change the input mode in the terminal so you get individual keystrokes instead of typing until enter is struck
most of this went over my head. How would I change the terminal mode?

I'm not making much sense because I lack the vocabulary to properly explain.
>>
>>58144308
use ncurses and implement a line editor first with simple commands.
ed is a good start since it's simple, build on it form there
>>
>>58144491
>How would I change the terminal mode?
In Linux/POSIX, look at https://linux.die.net/man/3/tcgetattr (and tcsetattr)

I have no idea how to do it through the command prompt in windows

You don't have to worry about UTF-8 just yet, but there isn't any special care needed in writing it (just reading and interpreting)
The type of the file doesn't typically exist beyond the file name (some formats do that, but it isn't required). UTF-8 encoding is
>>
>>58144520
>>58144491
>>58144397
that special mode is called "canonical mode" and should cover your input and output needs
>>
What you listening to?

I can't find anything that I like </3
>>
>>58144545
Christmas music?
>>
>>58144458

I agree. NTR is the worst. Good thing it's not one of my fetishes.
>>
>>58144545
https://www.youtube.com/watch?v=21TUJbKmITY
>>
How should I save data at the end of each level of my game, in Java?

I need to save 3 floats, and I need to be able to overwrite these 3 floats, and also display them.

I have an unknown number of levels, so I will need to have this be expandable.

Where do I even start?
>>
>>58144545
https://soundcloud.com/rinsefm/spoony231216
>>
>>58143896
It's not a good task for PHP.

Solutions I offered were hacky, but that's because this is like making a useable vase out of play-doh.

I would use sockets, as would most people, for a task like that.
>>
>>58144188
I started with K&R C but wish I had SICP.

Pick which looks the most legible:
C
for (size_t i = 10; i!=0; i--){
printf("%d\n", i);
}


Lisp
(let loop ((i 10))
(if (zero? i)
'done
(begin
(printf "~S~%" i)
(loop (- i 1)))))


Or even Haskell (written like a beginner would) (use LYAH)
loop 0 = return ()
loop n = do putStrLn (show n); loop (n - 1)
>>
>>58144635
I've read the first 50 pages of both K&R and SICP

I prefer LISP. I just have """"more""" """"experience""""" using/trying to learn C.
>>
>>58144585
save in text format, JSON, csv, newline separated with or without "name = value", ect... all depends on what you plan to change later
>>
Guys, I need some genius ideas for BasicTV
>>58144585
JSON seems like the best idea
>>
File: 1482242138570.jpg (122KB, 600x600px) Image search: [Google]
1482242138570.jpg
122KB, 600x600px
>>58142239
Y-you too
>>
>>58144662
Then I guess going with SICP would be the enjoyable one and K&R C would be the easy path...

Could do both at the same time as chapter 2 is easy (most of it) to implement in C, It's what I kind of did (translated lisp to Haskell and C when learning).

Can also learn a large set of C libs/functions if you use Chicken Scheme posix, posix-extras, mathh, ect...
>>
File: JUST.png (234KB, 1365x451px) Image search: [Google]
JUST.png
234KB, 1365x451px
JUST
U
S
T
>>
>>58144739

Does it have Pong or Breakout yet?
>>
rate my attempt at K&R exercise 1-8
#include <stdio.h>
void main(){
int c, nl, tab, blank;

nl = 0;
tab = 0;
blank = 0;
while(1){
while(( c = getchar()) !=EOF){
if ( c == '\n')
++nl;
else if ( c == '\t')
++tab;
else if ( c == ' ' )
++blank;
}
printf("NLs\tTABs\tBLANKs\n");
printf("%3d\t%3d\t%3d\n", nl, tab, blank);
}
}
>>
>>58144766
m-muh bleeding edge
>>
>>58144739
>>58144739
I meant for that screenshot to have my TODO list so far (removed too technical details)
* TODO Audio support
- [ ] Implement ALSA support
- [ ] Implement Opus support
- [ ] Implement MP3 decoding (all planned encoding is Opus)
* TODO Video support
- [ ] Fix V4L2 color
- [ ] Implement V4L2 frame interval
- [ ] Implement MP4 decoding
* TODO Input
- [ ] Install IR receiver on Raspberry Pi
- [ ] Finish IR receiver code
- [ ] Formalize API for input
- [ ] Include some networked style control (web interface?)
* TODO Menus
- [ ] Support TrueType fonts
- [ ] Allow for scrollable lists
- [ ] Tie a function or another menu with a menu entry
- [ ] Directly tie macro sequences to menu entries
- [ ] Make everything changeable from the menu (ties with previous point)
* TODO Nice Things in General
- [ ] Implement a notification system
- [ ] Customize what information gets notified through settings
- [ ] When it is live
- [ ] When a program is set to record, and the data is on the network
- [ ] Various network statistics
- [ ] Bitcoin donations to the node wallet
- [ ] Send to an RSS feed
- [ ] Send to an email address

>>58144767
Not yet, but I added a new video frame type that makes that a lot easier. I'll have that done soon, though.
>>
What do you guys think of using a genetic algorithm to train/modify behaviour of NPCs to fight the player?

would have a dead and live pool where after all have been tested the dead pool is run through the selection, crossover, and mutation process to produce the new population.
>>
>>58144789
int printf(const char *s, ...);
void main()
{
int c, nl, tab, blank;
nl = tab = blank = 0;
for (;;) {
while (( c = getchar()) != -1) {
if ( c == '\n') {
++nl;
} else if ( c == '\t') {
++tab;
} else if ( c == ' ' ) {
++blank;
}
}
printf("Number of blanks: %d\n", nb);
printf("Number of tabs: %d\n", nt);
printf("Number of newlines: %d\n", nl);
}
}
>>
>>58144842
>nl = tab = blank = 0;
I was wondering if you could do something like this
>>
>>58144766
>internal compiler error
I only had this problem when I overclocked my computer and I didn't realize it was faulting. What compiler are you using?
>>
>>58144842
Consider writing comparisons in the opposite order from assignments: x=3 but if(3==x). That will guard against typos turning connditionals into unwitting assignments. I say this only because you have adjacent conditionals and assignments of the same variable—it can be hard to proofread that in longer code samples.
>>
>>58144859
g++ 6.2.1
>>
>>58144789
> void main
int main(void)
OR
int main(int argc, char **argv)
ONLY

also use switch
switch (c = getchar()){
case EOF: results(); return 0;
case '\n': nl+=1; break;
case '\t': tab+=1; break;
...
default: break;
}
>>
>>58144933
I got g++ 5.4.0 (Ubuntu), is that an unstable version?
>>
>>58144188
Don't force yourself to read SICP page to page.
You can get more than enough to start programming with the first two or three chapters, even skipping some of the more mathematical stuff if that isn't your thing.

It's a book you can come back to again and again with a little more knowledge each time.

The bottom line is that you want to be programming alongside your reading. Scheme's minimal syntax and interpreted nature makes that really easy to start doing.
>>
>>58144955
https://www.archlinux.org/packages/core/x86_64/gcc/
>>
>>58144943
>switch for 3 ifs
you don't even know what switches are for

kys
>>
>>58144983
Ouch, submit a bug report and try clang if you can't get back to g++ 5
>>
>>58144993
Syntactic sugar for 'if else' if there aren't enough values for a jump table. It compiles to the same thing anyway (unless the compiler is retarded)
>>
clojure and clojurescript
>>
What's better? Lisp-1 or Lisp-2?
>>
>>58145137
Lisp-3
>>
>>58145137

Lisp-1
>>
Anyone have experience with URLrequests in Swift 3? Can't seem how to actually save my result into a variable, as I can't return it from inside the task.
>>
learning C, currently trying to build a bitmap parser. should be straight forward enough.
if anyone has any good resources that go more indepth on BMP that'd be great :)

pic kinda related
>>
>tfw rust ugly as fuck and has shitloads of restrictions
>tfw I like it
whats wrong with me?
building a MVC framework in Rust btw
>>
>>58145244
>rust
>like it
>MVC
BLEH
>>
>>58145248
you're entitled to your opinion lol
>>
>>58145248
rust is fine.
bringing MVC to is like feeding a puppy chocolate
cool and neat on their own, but combined it will die.
>>
>>58145283
>lol
BLEH
>>
>>58145310
wanna elaborate on that? it seems you know very little about rust and MVC
>>
>>58145325
umm ok? lol
>>
>>58145310
>but combined it will die.
No, it will just start violently shitting everywhere
>>
File: plotly.png (12KB, 560x140px) Image search: [Google]
plotly.png
12KB, 560x140px
If a project is open source does that mean I can integrate it within my project freely for commercial use?

I want to use plotly but I'm not sure if I can or not
>>
Who here /drunk on Friday evening/?
>>
>>58145439
Depends on the license
>>
>>58145439
why not use bokeh instead?
>>
Should I learn Rust, or more C++? I can get by in C++03, but I'm by no means an advanced user of it. Never used Rust or a more recent C++.
>>
>>58143928
make the game in python?

>>58145345
>>58145358
>>
>>58145500
From what I read in the docs, Rust is a better designed and more restrictive C++
>>
>>58145522
Thanks famalamalam
>>
>>58145477
Here's the license. Am I good?

>>58145484
I'll check it out
>>
>>58145536
you're welcome babe x
>>
>>58145544
ok nevermind I should be good. I'll just include the license/copyright in all the pages with plotly in it

https://tldrlegal.com/license/mit-license
>>
>>58145544
AIUI you're good to go as long as you include the license with anything you distribute that uses the library. IANAL though.
>>
>>58145581
thanks fammy
>>
>>58145500
>>58145522 is exactly right. It's what C++ should have been.
>>
File: 123450.gif (166KB, 360x359px) Image search: [Google]
123450.gif
166KB, 360x359px
Check out rule 123450 of a 3-color cellular automaton

I was bored today
>>
>>58145614
what language?
>>
>>58145624
Mathematica

ArrayPlot ~Map~ CellularAutomaton[{123450, {3, 1}, {1, 1}}, {{{1}}, 0}, 100]
>>
>>58145500
please god just learn c++14
>>
>>58145624
brainfuck, although with an extension that draws a dot (X, Y) on the screen, where X is the current cell and Y is the next one.
>>
>>58145658
Why? What does it have that's better than Rust?
>>
>>58145688
patterns
>>
>>58145704
Fucking patterns?? That all?
>>
>>58142877
>modem emulator
Like what are you trying to do? Signal conversion? That's pretty trivial in code. I'm pretty sure there's some online resource on it.

Are you trying to make a physical box?
>>
>>58145688
It's just a prettier language. I can't stand Rust's syntax.
>>
>>58145688

Templates.

But chances are, you don't need C++'s advanced type system anyways.
>>
File: Untitled.png (2MB, 1920x1080px) Image search: [Google]
Untitled.png
2MB, 1920x1080px
improving Overlay options for browser. it's taking many hours but I think it's worth it.
>>
>>58145796
>But chances are, you don't need C++'s advanced type system anyways.

>advanced

That's one way of putting it.
The templating system in C++ is a fucking turing machine.
>>
>>58145829
So are C macros.
>>
>>58145951
basically the same thing as templates
>>
>>58145963
>two Turing-complete languages are basically the same thing
Gee, ya think??
>>
>>58145829

I am aware, and like I said, you probably won't need them. But that would be one major advantage of C++. Rust's generics aren't that flexible by comparison.

Otherwise, both languages have similar feature sets. A major advantage to C++ would likely be available jobs and library support if you're really looking for a good reason to continue on with C++.

>>58145951
>>58145963

C++ templates are nothing like macros. Macros are a literal text substitution, while templates are typesafe.
>>
>>58145974
Are you saying Rust and Python are basically the same thing? Are you saying brainfuck and Erlang are basically the same thing? Kys.
>>
You know what would be really nice to have
A unary operator that would flip a boolean value
I know about ! or 'not' in some languages, but I mean
!boolean
instead of
boolean = !boolean
>>
I have two for loops, one going backwards, and the other going forwards. The boundary values are the same. I only use one of them at a time. The one I use depends on a value called d which is either +1 or -1. Is there some number magic I can use to condense them into one single for loop?
>>
>>58146020
boolean ^= true
>>
>>58144402
Thanks!
>>
>>58145796
How are templates better than Rust macros, or even full on generics? Sure, variable templates in C++14 are a nice QoL over '11 / '98, but its still not the type/template deduction in '17 and nowhere near as nice to work with as Rust macros (which are approaching a statically typed variant of Scheme's hygienic macros..).

Of the things C++ have ahead of Rust, I wouldn't consider its template system remotely competitive.
>>
I wrote this perl script to download an image from a direct link. Is there any way I can make it download all images from a page, such as a google images search page?

use LWP::UserAgent;

$get = "https://upload.wikimedia.org/wikipedia/commons/1/1a/Tatung-einstein-computer.png";

my $AGENT = LWP::UserAgent->new;
my $REQUEST = HTTP::Request->new('GET', $get);
my $response = $AGENT->request($REQUEST);

if($response->is_success) {
print "Content-Type: image/jpeg \n\n";

@IMG = $response->content;

open(W,">test.jpg");
binmode(W);
binmode STDOUT;

print W @IMG;

close(W);
print @IMG;
}
>>
>>58146298
please tell me what language this is so I can avoid it
>$
>::
>->
>>
>>58146303
>I wrote this perl script
>>
>>58146303
>I wrote this perl script
>please tell me what language this is
>>
I need image filter ideas.
>>
>>58146197
You can't do
Vector<4, float>
in Rust.
>>
>>58146303
I literally put the word "perl" in the first 5 words of the sentence

also I enjoy perl over python for simple scripts
>>
>>58146323
That's kinda shit.
>>
>>58146307
>>58146309
>>58146327
i thought perl was a web server
>>
>>58146333
No but it's not hard to make a web server in perl, it's also used for server-side scripting with CGI
>>
>>58146327
>>58146309
>>58146307
Oh, missed that. How funny.
>>
>>58146323
The RFC that would enable this is kind of depressing. They say they want to do it but that it's a bigger priority right now to improve fucking error messages (this is from like a day ago). Also, the lead language designer couldn't figure out simple inference rules in the proposal.
>>
>>58146321
Brighten!
>>
>>58146384

p-pls.
>>
>>58146321
Filter negresses :^))
>>
File: 12pxmedian.jpg (249KB, 1229x1192px) Image search: [Google]
12pxmedian.jpg
249KB, 1229x1192px
>>58146411

That has already been the subject of my filtering.
>>
>>58146381
Just another example of the stunning incompetence of SJWs. Why couldn't the real engineers stay in control of the project instead of letting it be ruined by witches who sacrifice children to Satan for liberal powers?
>>
>>58146506
Rust could be so much more than it is.
>>
>>58146381
>They say they want to do it but that it's a bigger priority right now to improve fucking error messages

To be fair, they are following a roadmap. They generally accept other changes if YOU put in the work, but they are spending their time on what they picked for the year.
>>
>>58146453
Nigs shouldn't be allowed to live in this world
>>
>>58143806
How new are you?
>>
>>58146671

Incredibly rude.
>>
>>58146678
Nigs being allowed to live is what's truly rude
>>
Why didn't you just link this thread? >>58129383
>>
Stop linking to the function program thread, /dpt/ is slow enough.

What's the point in dividing discussion?
>>
How do I learn JavaScript senpai?
>>
>>58146805

https://www.youtube.com/watch?v=fju9ii8YsGs

https://www.youtube.com/watch?v=fGdd9qNwQdQ&list=PLoYCgNOIyGACTDHuZtn0qoBdpzV9c327V

https://www.youtube.com/watch?v=fGdd9qNwQdQ&list=PLoYCgNOIyGACnrXwo5HMCfOH9VT05znGv

https://www.youtube.com/watch?v=HkFlM73G-hk&list=PLoYCgNOIyGABs-wDaaxChu82q_xQgUb4f

>>>/g/wdg
>>
>>58146832
JavaScript is programming, this is a programming thread.

People can discuss JavaScript here if they want.

Personally I'm sick of these /fpt/ and /wdg/ thread splitting threads.
>>
>>58146805
MPJ is comfy:

https://www.youtube.com/watch?v=PhUb7y9WZGs
>>
>>58146805
>>58146832
>>58146843
Samefag

>>>/g/wdg
>>
>>58146843
>asks for help learning javascript
>Doesn't want to go where the most information regarding javascript is

?????????
>>
JavaScript is cringy but pretty powerful. Back end JS confuses the hell out of me though
>>
>>58146867
>JavaScript is cringy
how?
>>
>>58146858
I didn't ask for help learning JavaScript, that was a different anon.
>>
>>58146854
https://www.reddit.com/
>>
How are robots programmed? How does the machinery know how and when to move. You're not out putting anything to a screen so I are confuse.
>>
>>58146867
JavaScript is pretty comfy if people would just stop using the prototype meme and only used factory functions to create objects.

Yeah, factory functions aren't as efficient as prototypal inheritance, but unless you're creating 10,000 objects per frame it doesn't matter.
>>
>>58146905
>How does the machinery know how and when to move.
It doesn't. It drives into walls.
>>
>>58146905
instead of printing a number to a screen, you send a number to a port, which is connected to the wire, and the wire goes to the motor, the motor reads the number, and starts running according to the number.
>>
File: 1435932629195.gif (622KB, 500x375px) Image search: [Google]
1435932629195.gif
622KB, 500x375px
>have a python script that runs 24/7
>decide to rewrite it in C++ to consume less resources
>spend a week doing it
>functionally-identical C++ program eats almost twice the CPU resources of the original python script (instructions/cycles measured with perf)

am i retarded
where is the performance i was promised?
i thought i optimized everything
>>
how do I into mutex
>>
>>58146940
>i thought i optimized everything
you didn't
>>
>>58146940
you might be retarded
>>
>>58146940
Joke's on you. C++ is slow if you don't write it just like C.
>>
>>58146940
You are probably passing things by value.
>>
>>58146980

Python babby doesn't know how to use le pointers?
>>
>>58146985
That was my first guess, yes.
>>
>>58146985
>using pointers in 2016
Use references
>>
>>58146958
well... yeah.
I guess 75% of my optimization strategy was just "C++ is fast, my program will be fast by default!", but that didn't work out like that in the end.

>>58146967
fug. Should have went with Assembly as I originally intended (but that would have taken months, let's be honest).

>>58146980
Nope, I'm using references where possible. I'm glad I remembered to do that in the early stages.


I'm having a hard time believing Python is faster at reading files, operating on strings, and dumping JSON than C++. I must be retarded.
>>
>>58146997
References are pointers.
>>
File: both.png (88KB, 260x260px) Image search: [Google]
both.png
88KB, 260x260px
>>58146997
>>
>>58147002
No, they aren't.
>>
>>58147008
Pointers can be null
Don't use pointers if you don't want null.
Don't use pointers only to then do a null check.
>>
In C++, is there a way to round down to the nearest n value? I want to round a number down to the nearest multiple of 32.
>>
File: 1482564583674.gif (2MB, 320x240px) Image search: [Google]
1482564583674.gif
2MB, 320x240px
>>58147017
>>
>>58147022
(x / 32) * 32
>>
>>58147022
x/32*32
>>
>>58147022

You know, I just had that problem last night. :^)
>>
>>58147034

x/32(32)

if x is 32, is this 32 or 1/32?
>>
>>58147022
x-x%32
>>
>>58147044
>no /
nice
>>
>>58147056
Dividing by 32 is a fucking shift.
>>
>>58147064
What if it isn't 32?
>>
>>58147086
That would be a different problem. Also I'm not convinced % wouldn't just be implemented using division and subtraction anyways.
>>
Memes aside, what are the most essential programming languages should learn?

C++, Java, and JavaScript?
>>
NewFag here, what's the syntax for entering code on this page?
>>
>>58147118

>>58147118

>>58147118

>>58147118

NEW
>>
>>58147119
Shit, I forgot the bump limit was 310, not 300 now.

Sorry, lads.
>>
>>58147108
<code>code</code>
except []s rather than <>s
>>
>>58146940

Post both programs.
>>
>>58147162
They're both over 500 lines and not pretty at all, I can't just dump that trash here.
I'll figure something out on my own.
>>
>>58146967

Actually, idiomatic C++ can still be pretty damn fast. You have to know what the fuck everything is doing though.

>>58147011

They are not pointers in the sense that you can't do the same operations on them as you could a pointer in C. They are pointers in the sense that they are literally just syntactic sugar over a pointer.
>>
>>58147184
They aren't pointers but are implemented with pointers
>>
>>58147123
>4chan doesn't have bump limit consistency
>no consistency
shit 4chin developers
>>
C# class for hitting an SQL database rather than using entity, runs SQL or stored procedures. SQL Params are cached

https://github.com/spitefulgod/SQLConnector

Can't post the code, too long
>>
>>58147207

>but are implemented with pointers
More specifically, implemented AS pointers. Which means that they are pointers.
>>
>>58147328
Just like arrays
>>
>>58147344

More or less. Except arrays are only slightly more complicated because they involve changing the stack pointer to allocate memory temporarily. References are literally just syntactic sugar for a pointer.
>>
>>58147363
Just like most datastructures
Thread posts: 314
Thread images: 21


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