[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

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

Thread replies: 325
Thread images: 50
File: chip8.gif (80 KB, 961x491) Image search: [iqdb] [SauceNao] [Google]
chip8.gif
80 KB, 961x491
CHIP-8 emulation edition
>>
File: o.webm (777 KB, 1440x896) Image search: [iqdb] [SauceNao] [Google]
o.webm
777 KB, 1440x896
>>52455220
Very nice
How long did it take you to make this?
Im working on an image generator currently, but i plan on making a CHIP-8 emulator too in the future.
>>
You inspired me to work on a CHIP-8 emulator too, OP.
>>
for (size_t 
i, x, y = x = i = 0;

i < n;

i++,
(y = i / h),
(x = i % h),
std::cout << i << ": " << x << ", " << y << '\n'
);
>>
>>52455220
You should make Custer's Revenge, OP.
>>
>>52455290
disgust
>>
>>52455253
>How long did it take you to make this?
Took me about a week, but I only put in a few hours each night since I'm usually tired after work. Finished it doing it all morning today. I needed help with doing audio and binary file reading though since I only just picked up SDL and C. I wouldn't consider it a difficult project, I finished the 21 opcodes vm for the synacor challenge, so this was just that + SDL stuff

>>52455284
VM dev is fun
>>
>>52455293
It looks doable and I'll try it in the future, but I want something I can put on my github for now lel
>>
>Barely post in /dpt/ any more

IRC is superior if you actually want to talk about things.
irc.rizon.net #dpt
>>
>>52455440
#/g/sicp is the only channel that i recognize.
>>
raw opengl masterrace
>>
http://shdr.bkcore.com/
>>
>>52455440
Stop spamming your shit IRC.
>>
File: 1427428721675.png (34 KB, 450x367) Image search: [iqdb] [SauceNao] [Google]
1427428721675.png
34 KB, 450x367
>>52455480
I want to get into OpenGL programming but i cant because my PC is old and doesn't support anything above OpenGL1.1
>>
Filthy javascript scrub here looking for fellow mud-dwelling peasants to answer a question for me:

Eloquent Javascript vs You Don't Know JS?

I've got a bit of experience under my belt coding, I can build single pages that piggyback off APIs to provide some small service.

I'm interested in learning more about closures, relearning "this", learning about OO programming, learning about prototypal inheritence, learning about functional programming.

I could do with less of an intro to general principles of programming ("it's like baking a cake, or herding a stupid child" analogies, etc.)
>>
>>52455545
>OpenGL1.1
What the fuck? What are your specs? I thought my computer was old..
>>
>>52455545
get a cheapo gpu

or do you have a smartphone? you can do GL ES 2.0 or 3.0 on it
>>
>>52455545
Don't be sad, anything newer than OGL 2 is retarded anyway (unless you're a professional vidya gaems developer).
>>
>>52455567
>Pentium 4, 3GHz
>80 GB HDD
>2 GB DDR2 RAM
>doesn't have PCIe slots, just a PCI slot
>mobo doesn't support even a C2D
>Intel iGPU, cant even run basic games from 2003

>>52455583
>tfw no PCIe slot
Is it possible to do OpenGL on phone? I'd love to try that out
>>
>>52455555
you'd be better off learning java, and F# or something for functional programming
>>
>>52455613
yeah android and iOS devices support GL ES 2.0 or higher except for the really ancient ones
>>
Does it have any affect on the speed if I don't include semicolons at the end of expressions in JavaScript?

If not, I'm just going to stop using them.
>>
Friendly reminder that Java a shit
>>
// The Add Program
#include <iostream>

//add declaration
int add(int a, int b);

//displays a sample use of the add function
int main(void)
{
using std::cout;
using std::cin;

int number1, number2;

cout << "Enter the first value to be summed: ";

cin >> number1;

cout << "\nEnter the second: ";

cin >> number2;

cout << "\nThe sum is: " << add(number1, number2) << "\n";

return 0;
}

//adds two numbers and returns the sum
int add(int a, int b)
{
return a + b;
}


Am I overusing whitespace? Also why do people have a beef with GNU style indents?
>>
>>52455614
Language switiching is not an option; I'm just interested in ways functional programming could be implemented within js
>>
File: Névtelen.png (41 KB, 677x498) Image search: [iqdb] [SauceNao] [Google]
Névtelen.png
41 KB, 677x498
can someone pl tell me what are the other forms of this kind of challenge?
i know there is triangle, nazi sign and tornado
(i dont know how to do the last one, any help greatly appreciated)
>>
>>52455688
int main(void)
{
using std::cout;
using std::cin;

int number1;
int number2;

cout << "Enter the first value to be summed: ";
cin >> number1;
cout << "\nEnter the second: ";
cin >> number2;
cout << "\nThe sum is: " << add(number1, number2) << "\n";

return 0;
}
>>
File: CWeYEUvWoAA5Z3V.png (194 KB, 831x793) Image search: [iqdb] [SauceNao] [Google]
CWeYEUvWoAA5Z3V.png
194 KB, 831x793
>>52455711
nigger pls go
>>
File: 1452446300011.png (229 KB, 628x708) Image search: [iqdb] [SauceNao] [Google]
1452446300011.png
229 KB, 628x708
I'm so sick of people saying X is shit.

If it works why does it matter what language something is in.
>>
>>52455711
javascript is unironically shit though

for learning resources on javascript try in >>>/g/wdg
>>
>>52455739
Thanks, that's the alternative I was considering.
>>
>>52455751
>what is performance
>>
>>52455714
nazi sign is easy
tornado is as easy as simulating the y value of a sine wave as x increases but drawing it downwards, and then you add variables to affect how wide it is, how fast it goes down, how quickly it loops, etc
>>
>>52455714
>magyar programozo
sup man how's the country doing ?
Also do you like orban ?
>>
File: 1394336815284.jpg (43 KB, 433x378) Image search: [iqdb] [SauceNao] [Google]
1394336815284.jpg
43 KB, 433x378
>>52455714
> c plusz plusz

you can do the memestar
>>
>>52455766
no idea how to control speed and what those variable would be
im doing it in c++
>>
>>52455759
Negligible for most things.

I bet you put salt in the kettle so it boils 0.00001s faster.
>>
File: 1451751832808.png (17 KB, 418x359) Image search: [iqdb] [SauceNao] [Google]
1451751832808.png
17 KB, 418x359
>>52455787
>c++
>>
File: 1426548231392.png (141 KB, 800x600) Image search: [iqdb] [SauceNao] [Google]
1426548231392.png
141 KB, 800x600
>>52455714
>>
>>52455771
it's pretty shit desu. only old grannies like orban
>>52455779
memestar?
>>
File: fibonacci meme.png (4 KB, 220x139) Image search: [iqdb] [SauceNao] [Google]
fibonacci meme.png
4 KB, 220x139
>>52455714
         MEMEMEMEMEME     
MEME MEM
EME EME
MEM M
ME EM
ME MEME EME
E EME MEM
M MEME
>>
>>52455613
Dude come on, you could buy or build a halfway decent computer for a couple hundred bucks.

Why are you still using that?
>>
>error: expected type-specifier before ‘ComponentC’
Every fucking time
>>
>>52455751
I guess that means PHP isn't shit
>>
>>52455807
Sztem is örult az ember, sok szerencsét a következönek
>>
>>52455711
Not sure what books are good for that. But there's lots of talks about functional shit in JS.
>>
>>52455814
I live in a country with crazy overpriced hardware
A raspi zero costs upto 50$ including everything
>>
>>52455833
nem is tudtam, hogy magyar vagy
kellemes estét
>>
>>52455830
Languages aren't shit, projects are.

There are many good projects written in PHP.
>>
>>52455848
nem vagyok magyar, egyaltalan. De szeretek nyelveket tanulni.
>>
>>52455751
It's shit because window tearing, input lag and bloat. It's also generally very bug prone due to it being laughably over complicated.
>>
>>52455867
és hogy oldanád meg a fibonacci görbét?
ötletem sincs
>>
>>52455858
>Languages aren't shit
Most are in one way or another
>>
>>52455807

M M M
E E E
MMM
MEMEMEM
MMM
E E E
M M M

>>
>>52455613
> Is it possible to do OpenGL on phone?
Most current generation phones support at least OpenGL ES 2.0.

While it's a pale imitation of desktop OpenGL, it is at least modern OpenGL (shaders rather than the fixed-function pipeline).

Another option is WebGL (basically OpenGL ES 2.0 bindings for JavaScript), but I'm not sure whether that requires a GPU (on Windows, WebGL is normally implemented using DirectX rather than OpenGL, so your OpenGL drivers don't matter).
>>
>>52455924
ill try it
>>
>>52455840
it's really time for you to upgrade imo

if you don't have much money you can get something very basic like this:
http://pcpartpicker.com/p/hZW6kL

and add a discrete gpu like a gtx 970 or r9 290x if you can afford one
>>
>>52455879
He wasn't actually talking about X11.
But enjoy this:

> IV) The X Server is huge and stupid. Before we (the community) began to scrap pieces of it and work around it, it was almost an entire OS.
> A) Don't believe me? X had its own print server. It got binned after someone added Xprint support to glxgears.
> B) It was a binary interpreter for ELF, COFF and a.out.
>>
auto multiply (int x, int y) -> int;


This is valid C++11. Why did it take 5 years from the standard adding it until I saw anyone using it? Why aren't we ushering in a golden age of ->?
>>
>>52455960
because it isn't needed and C++ has enough features as it is
>>
>>52455613
>Pentium 4
>>
Is it true that string comparisons are really slow in C++? I use them a lot but it doesn't seem to slow my programs down at all.
>>
>>52456006
>it isn't needed

http://www.cprogramming.com/c++11/c++11-auto-decltype-return-value-after-function.html#decltype

Read the section "decltype"
>>
>>52455957
I think X and everything built on top of it is just about the worst thing about linux. It's the posterchild for everything wrong about FOSS.

I knew he wasn't talking about X11, I was just having some fun =p
>>
>>52456050
libstdc++ performs string comparison O(n!)
glibc does this in O(n)
Don't fall for the BSD meme.
>>
>>52455833
>>52455848
>>52455867
>>>/int/
>>
>>52455714
here's meme tornado

#include <iostream>
#include <cmath>
#include <unistd.h>
#include <string>

using namespace std;

#define PI 3.141592654/180;

int main()
{
string str ("_-^-_-^-_-^-_-^-_-^-_-^-_-^-4chan");
unsigned long strsize = str.length()-1;
while(1){
for(int i=0; i<360; i++){
if (i%20 == 0){
cout << " ";
double pimag = i*PI;
double sinfunc = sin(pimag) +1;
double space = sinfunc*20;
for(int j=0; j<floor(space); j++){
cout << " ";
}
str = str[strsize] + str;
str.erase(strsize+1,1);
cout << str << endl;
usleep(100000);
}
}
}
return 0;
}
>>
>>52456050
You're likely not writing programs where comparing strings is a significant part of the running time of the program.
>>
Did someone say meme star?

var reverse = function(str) {
var val = "";

for(var i = 1; i <= str.length; i++) {
val += str[str.length - i];
}

return val;
};

var star = function(str) {
var val = "\n";

for(var i = 0; i < str.length - 1; i++){
val += (" ".repeat(i) + ( str[i] + " ".repeat(str.length - (2 + i)) ).repeat(2) + str[i] + "\n");
}

val += str + reverse(str.substring(0, str.length - 1)) + "\n";

for(var i = 2; i <= str.length; i++){
val += (" ".repeat(str.length - i) + ( str[str.length - i] + " ".repeat(i - 2)).repeat(2) + str[str.length - i] + "\n");
}

return val;
};

star("VOTE UKIP!")
>>
>>52455960
what's the point of auto if you are declaring the return type?
>>
>>52456146
>>52456067
>>
>>52456135
now do it in c++ fagget
aint no one reading your shitty language
>>
>>52456163
>http://www.cprogramming.com/c++11/c++11-auto-decltype-return-value-after-function.html#decltype
i don't understand what this adds because it seems that templates already handle generic types?
>>
File: 1452530965310.png (193 KB, 397x547) Image search: [iqdb] [SauceNao] [Google]
1452530965310.png
193 KB, 397x547
>>52456190
There's nothing wrong with JavaScript senpai.
>>
File: haruka.jpg (45 KB, 200x309) Image search: [iqdb] [SauceNao] [Google]
haruka.jpg
45 KB, 200x309
>>52456133
That doesn't answer my question.
>>
>>52456205
>>52456146
tell me if I'm wrong, but I'm pretty sure you can just template <A, B> and accept type A and use B as the return type
>>
>>52456006
>>52456146
>>52456205
It's needed and useful because in some cases you cannot determine the return type of a function without knowing the parameter types. Or, if you can, it can be more beneficial to tie them to the parameter types in case they change. Before, you could not access the parameters because they came after the expression for the return type. "auto" in this context just means "The return type comes later after the parameters have been parsed"
>>
File: trig.gif (3 MB, 961x491) Image search: [iqdb] [SauceNao] [Google]
trig.gif
3 MB, 961x491
>>52456116
disgusting
import math,time
msg = 'OSGTP !!Ju67JuF6jBe sucks dick+++++++++'
freq = 0.01
amplitude = 40
speed= 0.01
i = 0
while True:
s= amplitude*(math.sin(2*math.pi*freq*i)+1)
print(int(s)*' ' +msg)
msg = msg[1:]+msg[0]
time.sleep(speed)
i+= 1
>>
>>52456232
oh I see. for handling types at run time, this would be useful
>>
>>52456223
leave.
>>
>>52456116
Surprisingly simpler than OP.
>>
File: 1420763526695.jpg (20 KB, 249x249) Image search: [iqdb] [SauceNao] [Google]
1420763526695.jpg
20 KB, 249x249
>tfw your professor uses at&t syntax

TRIGGERING MY AUTISM
FUCKING REEEEEEEEEEEEEEEEEEEEEE
>>
>>52456050
> Is it true that string comparisons are really slow in C++?
No. At least, no slower than in any other language. Actually, comparing std::strings is faster than strcmp(); because the length is part of the string, an equality comparison can compare most of the data word-by-word rather than byte-by-byte, whereas strcmp() has to check for the null terminator.

But in the worst case, string compares are proportional to the length of the string, so you try to avoid using them directly as "keys" for lookups if you're going to do that a lot. Instead, it's better to intern strings so that you can compare pointers or handles rather than the data.
>>
File: 1452441773900.png (246 KB, 452x760) Image search: [iqdb] [SauceNao] [Google]
1452441773900.png
246 KB, 452x760
>>52456252
But you're in the minority, anon.

Most of us aren't autistic about languages.
>>
>>52456285
Enjoy those percent signs
>>
File: 1452446496816.png (616 KB, 895x892) Image search: [iqdb] [SauceNao] [Google]
1452446496816.png
616 KB, 895x892
Quick, give me something fun to code.
>>
>>52456322
CHIP-8 emulator
or GameBoy emulator if you're feeling hardcore
>>
>>52456322
A random 4chan shitpost generator.
>>
>>52456251
No it wouldn't.
>>
>>52456350
then I don't understand the point of it if it doesn't do anything different than static type handling at compile time. templates already do this
>>
>>52456322
Romanji to katakana converter
>>
So i have a 10Mb xml file, i need to replicate. I need to change some leaf variables, and duplicate some internal nodes in the output.

Im using python, whats a good module that i can use to parse the input xml, and output the modified xml?
>>
>>52456322
>>52456334
GB tech reference.. for reference
http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf
>>
I'm playing around with C# and I'm wondering if it's possible to natively get an image from a webcam. Does anybody have any experience with that? Every solution I looked up was basically "use a library lol who cares about licenses", but I'd rather see if it's possible natively.
>>
>>52456227
That requires that you specify the return type implicitly. Sometimes, it's far from trivial to determine the relationship between the two (it's often whatever a particular function overload returns).
>>
>>52456380
template <typename L, typename T>
auto invoke(L function, T parameter) -> decltype(function(parameter))
{
return function(parameter);
}
>>
>>52456425
yeah I'm sure there's cases for this in some project. luckily i've never seen them
>>
>>52456422
Reported, hidden, called the cops, called the Fire Department, called pizza hut, called the USN, called the Royal Navy, called the Red Army, called the FBI. called the CIA, called Interpol, called the KGB, called the USMC, called the USAF, called the Royal Air force, called MI 6, called Scotland Yard, called the US National Guard of every state, called NYPD, called Obama, called the Queen, called Putin, called David Cameron, called every Governor of every US State, used my time phone to call Winston Church hill, As well as Hitler, Stalin, Theodore Roosevelt, George Washington, Montezuma, ever Caesar, and Gilgamesh, called US Army, called British Army in every era, called every phone sexline, called papa john's, called the US Coast Guard, called my State Senators, called my Senators, called every republican in the US, called Dr. Who, called the Pope, called my local Gang lords, called the State Patrol of ever state west of the Mississippi, called all of my local news channels, called Star Fleet, called The Sun, called The national enquirer, called CNN, called Scot Pelly, called Steven Colbert, called half of the Mexican Drug Cartels, called Nintendo, called the Japan Maritime Self-Defense Force, called the head of the Illuminati, called ever free mason, called bilderberg, called my neighbors, called the mayor of ever city in France, called my mom, called the Emperor of Man, and called every school district in Canada.
>>
>>52456440
oh alright, this makes a ton of sense
>>
File: 1451779320598.png (20 KB, 418x359) Image search: [iqdb] [SauceNao] [Google]
1451779320598.png
20 KB, 418x359
>>52456440
>not in code tags
>opening parens on new line
>>
>>52456085
>libstdc++ performs string comparison O(n!)
for real? that's utterly retarded
>>
>>52456422
this seems to do it: https://www.nuget.org/packages/MMaitre.MediaCaptureWPF/

What do you mean "natively"? I don't think there's anything is the standard library to let you do it.
>>
>>52456466
template <typename L, typename T>
auto invoke(L function, T parameter) -> decltype(function(parameter)){



return function(parameter);
}
>>
>>52456401
xml.etree.ElementTree

xml.parsers.expat is more efficient but it's fairly bare-bones, and for a 10Mb file efficiency doesn't really matter.
>>
>>52456224
operations on strings are always relatively slow
>>
>>52456478
You retarded m8?
>>
File: 1451754656606.png (17 KB, 418x359) Image search: [iqdb] [SauceNao] [Google]
1451754656606.png
17 KB, 418x359
>>52456478
>>
>>52456232
so it's fucking pointless

'auto', 'var', 'let' is disgusting
>>
>>52456510
>'auto', 'var', 'let' is the only way to write good code
fixed
>>
File: uwotm8.png (14 KB, 418x359) Image search: [iqdb] [SauceNao] [Google]
uwotm8.png
14 KB, 418x359
>>52456495
>>
>>52456467
Why do you think string comparison is so slow?
>>
>>52456442
> yeah I'm sure there's cases for this in some project. luckily i've never seen them
95% of features added in C++11 and C++14 are only necessary for code which needs to be generic, robust, re-usable and efficient, all at the same time.
>>
>>52456474
Sorry, what I meant by natively was within the .NET Framework. I think that one uses WinRT's MediaCapture that was ported. I know the mobile frameworks have that functionality built-in, but I'm not sure about desktop applications.

>>52456447
Not getting images of people without consent, just wondering if it's possible to superimpose images over webcam captures.
>>
>>52456577
it's a shame it's still a shit language
>>
>>52456565
you can do it in O(n)

O(n!) is donkey tier retarded
>>
There's this neat trick to do string comparison in O(1) if you change the first character
>>
>>52456565
compare(std::string a, std::string b) {
if (a.length() != b.length()) {
return false;
}
for (int i = 0; i < a.length(); ++i) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}

fixed
>>
>>52456585
> O(n!) is donkey tier retarded
I'm fairly sure the O(n!) claim is a troll.
>>
>I prefer to write out all my types even when it's trivial for the compiler to infer them and for the reader to infer them from context
>>
>>52456636
I'm very serious :DDDDDDD
>>
>>52456626
doesn't work senpai
>>
>>52456565
int equals(char *s1, char *s2)
{
for ( ; *s1 != '\0'; s1++, s2++)
if (*s1 != *s2)
return 0;
return *s2 == '\0';
}
>>
>>52456626
>for (int i = 0; i < a.length(); ++i)
>a.length()
oh boy
>>
>>52456626
nice bait
>>
>>52456682
What's wrong with a.length()?
>>
>>52456682
Complexity
C++11
Constant
>>
File: size difference.jpg (24 KB, 953x499) Image search: [iqdb] [SauceNao] [Google]
size difference.jpg
24 KB, 953x499
For something that is essentially 64x32 pixels blown up, would it look nicer to have it smaller? Would it repel the fullscreen crowd?
>>
>>52456673
You don't really need the for loop there, you can just say
if (*s1++ != *s2++)
>>
i have an idea for a game. can one of you make it
>>
File: 83421.png (14 KB, 203x248) Image search: [iqdb] [SauceNao] [Google]
83421.png
14 KB, 203x248
>>52456725
>>
>>52456626
You're confusing compare() with operator==() and operator!=().

compare() returns a negative, zero or positive value like strcmp(). It's defined as using the compare() method of the associated char_traits class (i.e. if you override the behaviour by creating a custom basic_string<> instance with a custom char_traits type; this is sometimes used e.g. to create strings where comparisons are case-insensitive or use locale-specific comparisons).
>>
>>52456755
is it small enough for chip-8? if so, I'll give it a go
>>
>>52456756
I mean you can just use a while loop in place of a for loop.
>>
>>52456243
it's c++ you dip not babby python
>>
>>52456791
C++ is actually the bigger meme lmao
>>
>>52456765
do you know java or c++
>>
>>52456808
Yeah I know them. I'm not fluent with the OO paradigm though
>>
File: Carmack.png (56 KB, 722x486) Image search: [iqdb] [SauceNao] [Google]
Carmack.png
56 KB, 722x486
>>52456800
>C++
>a meme
>>
>>52456755
i'm busy with my own game but if you don't mind if someone "steals" your idea you can post it here and someone might make it but don't count on it
>>
int cmp(char *str1, char *str2)
{
while(*str1++ == *str2++ && *str1 && *str2)
;
return *str1 == *str2;
}
>>
>>52456824
>C++ isn't a meme
love this meme
>>
>>52456817
that's fine as long as you're fluent in libgdx or unity
>>
>>52456847
libGDX is shit and Unity is C# m8
>>
I seen a normie on my facebook call something he didn't like a meme today, /g/.

Why must normies take our memes?
>>
>>52456860
how about unreal or cryengine
>>
>>52456860
or starling
>>
>>52456873
>using facebook
Fucking normie. Leave
>>
>>52456875
>>52456885
how about if you want a video game done, you go to vg/agdg?

we deal with mostly other things, but if the idea is small enough for chip-8 I'll do it as a personal project

now what's the idea? Don't worry, we're not gonna "steal" it
>>
>>52456843
>love this meme
nice meme
>>
>>52456673
int equals(char *sl, char *s2)
{
while (*sl && *s1++ == *s2++) ;
return *sl == *s2;
}
>>
File: 1452420834970.png (536 KB, 600x720) Image search: [iqdb] [SauceNao] [Google]
1452420834970.png
536 KB, 600x720
What are those comfy blankets that have sleeves called?
>>
>>52456906
stop meming you two
ration your memes
>>
>>52456919
ponchos I think
>>
>>52456894
this isn't /r9k/ faggot.

kill yourself
>>
>>52456800
The only people who call c++ a meme are old man C programmers and babby python programmers. You're the latter.
>>
>>52456919
women?
>>
>>52456929
>tfw you're wrong
>because I'm both
lmao no regrets, C++ just doesn't ring right with me
>>
>>52456901
nothing too fancy but sort of an rpg/pokemon-style game where you capture and train waifus and battle other waifu trainers
>>
>>52456837
int cmp(char *str1, char *str2)
{
while(!(*str1++ - *str2++) && *str1)
;
return *str1 == *str2;
}
>>
>>52456940
yeah that's way too big for a 4k ram chip-8 emulator, try
>>>/vg/agdg
>>
>>52456899
Deleting it doesn't cause the embarrassment to go away, anon.

We all saw what you did.
>>
>>52456963
no bully
>>
>>52456936
In what way?
>>
>>52456944
>new line just for the semicolon
>>
>>52456583
I think i did something like this years ago: https://stackoverflow.com/questions/4953211/how-do-i-capture-video-from-a-webcam

Worked fine
>>
>>52456940
it'll be more fun for you if you make it yourself
>>
>>52456972
Maybe I used it too long, 8 years and I just don't like it
>>
C++ is old and bloated

Can't spell sharp future without F#
>>
>>52456979
NO BULLY
int cmp(char *str1, char *str2)
{
while((*str1++ - *str2++ + *str1)) ;
return *str1 == *str2;
}
>>
>>52457002
j/k
>>
>>52457033
>space for a semicolon

You absolute worthless piece of utter fucking shit I hope you die slowly and painfully with no friends, family or loved ones because they've all killed themselves in front of you out of their utter fucking shame for you you cunt
>>
>>52457033
Oh, and please do not respond again unless you're being conducive to this thread. Thanks!
>>
File: 1450989852450.jpg (27 KB, 512x384) Image search: [iqdb] [SauceNao] [Google]
1450989852450.jpg
27 KB, 512x384
>>52457017
>cli language

okay
>>
>>52456919
Slanket, Snuggie, Freedom Blanket, Doojo, Toasty Wrap, Cuddlee, Dreamie, or Kanguru.
>>
>>52457101

Are you seriously advocating for languages that can't do CLI? I don't even fucking know any
>>
>>52456085

http://en.cppreference.com/w/cpp/string/basic_string/operator_cmp
>Complexity
>Linear in the size of the strings.

http://en.cppreference.com/w/cpp/string/basic_string/compare
All definitions except the first call the first. The first definition of compare invokes Traits::compare where Traits is the traits_type template parameter. For all type instantiations that use the default parameters for traits_type (which includes std::string, std::wstring, std::u16string and std::u32string), the value used is std::char_traits<charT>. Now let's look at the char_traits<charT> compare function:

http://en.cppreference.com/w/cpp/string/char_traits/compare
>Complexity
>Linear in count.
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay


Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [iqdb] [SauceNao] [Google]
1451683583776.gif
2 MB, 400x600
pls recommend ideas for chip-8 lads, so far I've got:
Game of Life
Nokia Snake
Pong
Tetris
Pacman
>>
>>52457067
>>52457083
int cmp(char *str1, char *str2)
{
while((*str1++ - *str2++ + *str1));
return !(*str1 ^ *str2);
}

fuk u
>>
File: 1407905937240.jpg (23 KB, 500x375) Image search: [iqdb] [SauceNao] [Google]
1407905937240.jpg
23 KB, 500x375
>>52456837
>>52456944
>>52456979
>Using the same variable more than once when operators with side effects are used
Undefined behaviour.
>>
>>52457143
digital clock
>>
>>52457101
It's CIL or CLR, mate. Not CLI.
>>
>this is the c++ official website
>implying c++ isn't a meme

http://www.open-std.org/jtc1/sc22/wg21/
>>
>>52457134
Ask your programming wizardry literate anything
>>
>>52457134
>Software Alchemist is GOAT
STOP APPROPRIATING MY TITLE REEEEEE
>>52457159
int cmp(char *str1, char *str2)
{
while((*str1 + *str1++ - *str2++));
return !(*str1 ^ *str2);
}
>>
>>52457161
that it? u avin a digital laff m8?
>>
File: CatBeard.jpg (142 KB, 700x900) Image search: [iqdb] [SauceNao] [Google]
CatBeard.jpg
142 KB, 700x900
>>52456940
Capturing waifus sounds a bit misogynistic and problematic. Maybe the player should have to perform a courtship ritual of some kind.
>>
>>52457167
>this is an ISO website
>these are the same people that do the metric system
>>
>>52457143
What is the game of life meme all about?

I looked at it awhile ago and I didn't get it.

What is it supposed to do?
>>
>>52457121

I believe he is referring to F#'s dependency on the Common Language Infrastructure, rather than its ability to do Command Line Interface programs. Most languages do not run on the CLI as F# and C# do.

>>52457143

Rewrite Pokemon Red in Chip-8. If you want, I can give you a link to the Z80 assembly source code for it.
>>
File: non-binary logic.png (91 KB, 880x1360) Image search: [iqdb] [SauceNao] [Google]
non-binary logic.png
91 KB, 880x1360
>>52457197
how about capturing waif-u-s or waif-o-s (depending on what vowel they identify with)
>>
>>52457201
>doesn't know game of life or its implications
Your post is a meme

>>52457207
>Rewrite Pokemon Red in Chip-8
>4K RAM
Unless you're asking me to download more RAMs in which case I'll extend it and do it.

Where'd you get the Z80 code for it anyway?
>>
is everyone on /dpt/ implementing CHIP-8 emulators? Why waste our time on solved problems when we could be contributing to something great?
>>
>>52457232
It's just me tbqfh
>>
>>52457232
I'm busy reimplementing strcmp()
>>
>>52457198
AFAIK, they dont publish the final form of the C++ standard online. You can only find the final draft online and the release in a library, amirite?
>>
>>52457158
>redundant parens
srsly
>>
>>52457158
>*str1++ - *str2++ + *str1
pretty sure that's undefined behavior
>>
>>52457227

https://github.com/pret/pokered

It's a disassembly with comment annotations and proper symbol names.

Also, 4k? Damn. Gameboy ran on 8k DRAM and 8k Video RAM. I suppose you could try and write a simplified version, perhaps with less pokemon. Although you're boned if that 4k also has to hold the program ROM.
>>
>>52457272
>not using double protection to make extra sure loop variables don't fall out of scope
Look at this newbie programmer
>>
>>52457272
>>52457288
int cmp(char *str1, char *str2)
{
while(*str1 + *str1++ ^ *str2++);
return !(*str1 ^ *str2);
}

F
Find a flaw
>>
>>52455555
Secrets of the JavaScript Ninja is the best book for advanced Javascript out there. It's written buy the guy who wrote jQuery. I work on projects with 300,000+ lines of javascript at my day job and I can strongly recommend the book.
>>
>>52457232

CHIP-8 is babby's first intro to CPU emulation. It's a learning exercise.
>>
>>52457232
gotta learn how to crawl before you can walk
>>
>>52457304
Well 4K is what's given if you really want to restrict yourself and emulate closer to the hardware. imo it's a simple enough SDL-fueled assembly language that it's viable for simple 2D games, and challenging enough for games the size of poke red, but another hardware spec is that the screen is 64x32 pixels monochrome so you can't display much.

And yes, hardware holds both the interpreter and the program ROM, however modern emulators don't hold the interpreter since they make their own and because no code is supposed to touch addresses 0x000 to 0x200 unless you're accessing fonts
>>
>>52457307
What if str1 and str2 are of different lengths?

Also, str1 and str2 should be declared const.
>>
>>52457387
const * const
>>
>>52457307
>*str1 + *str1++
It's still undefined behaviour, fuckwit.
>>
File: le apple guy face.png (326 KB, 3388x3638) Image search: [iqdb] [SauceNao] [Google]
le apple guy face.png
326 KB, 3388x3638
>radio inits and works in sketch #1 but refuses to in sketch #2, even though config methods are identical
JUST
>>
>>52455555
I'd go for You Don't Know JS if you could only choose one, but going through both is the best option.
>>
>>52457304
>>52457372
Oh also thanks for the code, this is a hell of a beast compared to CHIP-8, but I guess a project isn't as satisfying if you can finish it in a day
>>
The sad truth to people calling F# supporters Microsoft shills:

Microsoft don't shill F#. They don't care about it.
>>
>>52457488
You're shilling their shitty .MEME framework.
>>
>>52457387
It works if they're different lengths
int cmp(const char *str1, const char *str2)
{
while(*str1 + *str1++ ^ *str2++);
return !(*str1 ^ *str2);
}
>>
>>52457501
nobody cares about .MEME

it's the language that's lovely
>>
>>52457507
OH SHIT I cannot read
brb fixing
>>
>>52457488
that's why it's open source
>>
>>52457517
The language is shit compared to the rest of the ML family.
>>
I already know C# and JavaScript, however, I want to learn C or C++ but I wont have the time for both (after work), which is better/faster or more useful from both, complexity or trivial stuff doesn't matter to me, I want to be able to code micro controllers and related stuff. Or if there is better language for that use, what is it ? In your opinion ofc
>>
>>52455840
>>52455613
>>52455545
I know that feel man, I saved up for a year to get decent computer that can hold some basic 3D stuff and its old now (2 years later) and I have no $$$ for better one, I'll probably gheto liquid cool it and clock it. It will be cheaper then buying new parts.
>>
>>52457533
same speed, C++ is more expressive, both have bloated syntax but so does C#
>>
>>52457533
C
>>
I am desperately in need of a software engineering project. The professor has given us no guidelines and I am unsure of what would make a good project. I was thinking about making a chat application, but I don't know...
>>
>>52457533
C and C++ are equivalent in speed. C++ is more productive and has a better type system, while C has compilers for more platforms.
>>
Whats a good book to learn modern (C++11) C++? I'm reading Accelerated C++ and I can sort tell that the book is outdated. It shouldn't be a beginners book, if that exists.
>>
>>52455587
No it's not.
OpenGL 3.3 is best OpenGL.
>>
>>52455253
Worked on a Chip8 myself and it took about 16 hours (without any special functions, only functionality). It really doesnt take much effort with only about 35 opcodes.
You should try adding Super 8 functions as well, there are only a few. Took me only an afternoon for this one.
>>
>>52457533
I literally finished my first C project, a CHIP-8 emulator in a week after work hours. Although, I used C++ for the better part of a decade, so some parts of it were similar. After this one week, I can only recommend C, C++ is just bloated and full of potential bad practices
>>
>>52457604
4.5 is objectively the best.
>>
>>52457585
CHIP-8 emulator
>>
>>52455613
You could just use a software implementation for OpenGL, such as mesa3D's software renderer.
>>
>>52457533
You're learning the same thing over and over again at this point. Why not something diffrent, like Prolog, LISP, or Haskell?
>>
>there are people itt who don't use ocaml
Why so masochistic?
>>
>>52457683
This minus Prolog

Prolog, creatively-speaking, is just a meme
>>
>>52457630
I don't know a lot of low level. Do you think this could be done in 15 weeks, assuming I need to do some learning?
>>
>>52457683
So if I know C#, I would possibly get better at either C or C++ faster ?
I am intrigued by Haskell tbq, and its on my "wishlist" .
>>
>>52457702
How much time do you have per day? I also didn't know low-level, and I found it pretty quick. chip-8 is very simple for low-level. If you want something even simpler, go to challenge.synacor.com. Their initial challenge is to write a virtual machine capable of executing only 21 opcodes, and it runs a binary file that contains a text adventure game. I did it in Python, no need to worry about graphics, sound, etc, it's all CLI
>>
File: 1452516540793.png (174 KB, 429x555) Image search: [iqdb] [SauceNao] [Google]
1452516540793.png
174 KB, 429x555
How do I get rid of my arrogant mentality, /dpt/?

I keep thinking everyone is retarded except me.
>>
How do you programatically determine whether to use jpeg or png to compress an image? imlib2 doesn't seem to provide any such function. I know in which situations each is better to use, from a disk usage perspective, but I don't see how to determine that programatically
>>
>>52457781
compete on some hackatons
>>
Is scheme/SCIP a good first language?
>>
int cmp(const char *str1, const char *str2)
{
while(*str1 && *str2 && !(*str1 ^ *str2)) { ++str1; ++str2; }
return !(*str1 ^ *str2);
}


The Final Solution
>>
>>52457585
Read up on neural networks, pick one good for pattern recognition and then make it recognize numbers or letters.
>>
>>52457802
What does it do?
>>
>>52457437
I'm out of ideas. I just don't know anymore. Either it's something very easy in plain sight, or a damn mysterious software bug.
>>
>>52457850
Compares two strings
>>
>>52457781
https://www.topcoder.com/
>>
>>52457784
I have a feeling that any decent heuristic will be slower than just doing both and seeing which file is smaller.
>>
>>52457781
Compare yourself to people who don't watch anime.
It's a real eye-opener.
>>
>>52457800
If you're good at maths yeah, it's not a complex language at all.
>>
>>52457781
hackerone.com

if you can't get a bounty, you don't know everything
>>
File: 1452442545840.png (174 KB, 429x570) Image search: [iqdb] [SauceNao] [Google]
1452442545840.png
174 KB, 429x570
Is node.js a meme?
>>
>>52457981
yeah and it's an old meme too
>>
>>52457981
running javascript outside of the browser is a meme
>>
How much prorgramming do I need to know in order to be smug about it?
>>
>>52458033
The more you learn, the more you become aware of how much you don't know.
>>
>>52458033
suprisingly, not much
just learn syntax and you can argue with people more skilled than you and still be technically correct
>>
>>52458033
programming is bottom of the rung, honestly. alone it is useless.
>>
>>52458057
I understand that, anon. But does Carmack feels the same way about it?
>>
>>52458006
running java is a meme
>>
>>52458078
Carmack seems quite humble.
>>
>>52458059
>technically correct
The best kind of correct.

>>52458067
What do you suggest, anon?
>>
>>52458033
6 months of low-level programming
>>
File: 1452448978219.png (188 KB, 575x372) Image search: [iqdb] [SauceNao] [Google]
1452448978219.png
188 KB, 575x372
>>52458057
>Anon thinks he's smart because he tells himself he doesn't know everything because of meme quote he read
>>
>>52457944
What is scheme like compared to C?
>>
>>52458033
Almost nothing in my experience
>>
>>52458117
Completely different
>>
>>52458059
if they're so smart why are they arguing with an amateur on a cambodian finger puppet forum?
>>
>>52458115
>anon thinks he's enlightened because he jays oh to lolly khan.
>>
>>52458117
Completely different paradigm

In C, it's imperative, you write instructions in a given order. In Scheme, it's declarative, you have all these loose functions floating about describing a behaviour, and you can pass them all different values and different functions. For example, you can write a pathfinding function that describes the best new spot to move to, and write various heuristic functions that describe how to calculate which spot is best, and pass them in.
>>
>>52458142
Not sure but it sure is entertaining
>>
Can I get an entry level, foot-in-the-door, low totem, grunt work job as a programmer knowing only one language, and with limited experience with it?
>>
>>52458172
Which one is the better first language?
>>
File: 1451683513443.gif (2 MB, 400x225) Image search: [iqdb] [SauceNao] [Google]
1451683513443.gif
2 MB, 400x225
>mfw discovering function pointers in C
>>
>>52458142
To feel superior. It is hard to feel superior when all your peers are good at what you do. But when someone bad shows up, you undermine them.
>>
Is there equivalent of c structs in java?
I made desktop version of what I'm making for android now and there are client and server programs. In c when I receive packet I just convert raw byte buffer onto struct and I can easily read what's inside and I want to do the same in java.
>>
>>52458103
If you look at projects that are cool, you will quickly notice that java in 21 days won't really get you there alone.

Programming is a tool, it is only as good as what you can do with it. The more interesting stuff you work on the more you will find yourself studying other topics instead of programming.

If you want a list of things to keep you busy though, basically all of those undergrad CS classes that you will think are useless until you find yourself needing them.
>>
>>52458206
Scheme imo, if only because it's easier, you will inevitably have to understand functional programming even in languages that didn't use to have them (C++, Java) as it opens new doors, especially applications utilizing design patterns (so video games), and because C is actually quite difficult for a first language

Personally, I barely use Scheme, and use C a lot, but Scheme is the better first language
>>
>>52458229
classes with only instance variables and no methods.
>>
>>52458172
C and Scheme are actually the same paradigm, but objects in Scheme have unlimited extent.
>>
File: nj.png (1 MB, 700x992) Image search: [iqdb] [SauceNao] [Google]
nj.png
1 MB, 700x992
>>52458169
My love for anime girls is non-sexual, anon.

What was that meme quote I'm thinking of?

You know the one, anon.
>>
>>52458253
But can I just convert the raw buffer to this class then?
>>
>>52458279
No.
>>
>>52458279
Nope. Sorry, Java is not about speed. You'll have to have a packing and unpacking method I guess.
>>
new thread when ? :3
>>
>>52458279
>>52458229
I suggest you use Google Protocol Buffers (protobuf). It has optimized libraries for several languages.
>>
I figured out how to put vtables in my C structs, but since I still have to feed the function with it's own pointer, what's the point of member functions in C?

struct _vtable;
struct _object;

struct _vtable {
void (*func1) (struct _object *self);
void (*func2) (struct _object *self);
void (*func3) (struct _object *self);
};

struct _object {
int *data;
int size;
struct _vtable *vt;
};
>>
File: h4iOBOp.gif (2 MB, 335x249) Image search: [iqdb] [SauceNao] [Google]
h4iOBOp.gif
2 MB, 335x249
Ask your favorite programming literate anything.

>>52458229
java is object oriented, there no place for plain data containers.
>>
>>52458335
The point is to have polymorphism, just like virtual methods in C++.

Non-virtual methods in C++ are basically just regular free functions with the object as their first parameter.
>>
>>52458312
at 310+ replies
>>
>>52455220

You're a fucking cunt you wee wanker, I'll fucking slice you up
>>
>>52458368
>310
300 actually
>>
>>52458359
lmao what do u think an object is? doesnt sound like ur very literate
>>
>>52458368
>>52458387
you get banned for spamming if you post before page 6 now
>>
>>52458264
Azusa best girl.
>>
>>52458387
Fuck off.

>>52458400
Good. Is it actually being enforced?
>>
File: iio.png (614 KB, 640x890) Image search: [iqdb] [SauceNao] [Google]
iio.png
614 KB, 640x890
>>52458400
>lying on the internet
>>
>>52458387
>everyone look how retarded I am
>>
>>52458229
see if ByteBuffer helps you any
>>
>>52458416

Fuck off yourself you twat
>>
File: jSae4hO.jpg (136 KB, 1082x829) Image search: [iqdb] [SauceNao] [Google]
jSae4hO.jpg
136 KB, 1082x829
>>52458396
Object is a data and implementation abstraction technique: data is hidden behind operations like with abstract data types except that an object also abstracts the implementation of those operations. if you have objects with no operations, you are doing oop wrong.
>>
>>52458441

You're a fucking byte buffer, biting all the buffs you gaylord. Go slap yourself with a hatchet you prick
>>
>>52458465
>>52458465
>>52458465
NEW
>>
>>52458387
No, it was raised fucking months ago you fucking retard.
>>
>>52458452

Fuck up ya wanker
>>
>>52458479
Melt.
>>
>>52458479
fuck off, we're still at 304 posts
>>
>>52458491
yes but for the people of dp, it's still 300. tradition prevail.
>>
File: IMAG0031.jpg (884 KB, 1520x2688) Image search: [iqdb] [SauceNao] [Google]
IMAG0031.jpg
884 KB, 1520x2688
>>52458491
Suck a dick you moron, you've no fucking clue what you're talking about. You must have the brain capacity of a fucking sea urchin you carpet licking fool
>>
>>52458503

You fuck off
>>
NEW THREAD (at 310 posts!)

>>52458535
>>52458535
>>
>>52458525
The irony is stunning.
>>
>>52458527

You don't know how to add words diagonally? You must be one thick bastard.
>>
>>52458465
>>52458465
>>52458465
ACTUAL NEW
>>
>>52458033
about, hello world level.
>>
>everyone is making a dpt
fuck you, scums.
>>
>>52457683

Well Anon, he wants to write code for microcontrollers. None of these languages are ideal for a memory-constrained environment.
>>
File: c39.png (89 KB, 500x586) Image search: [iqdb] [SauceNao] [Google]
c39.png
89 KB, 500x586
>>52458554

I'll smash your face in with an iron
>>
>>52458550
REKT
>>
mods don't respect the rules of /dpt/
oh well
you heard it here first
The precedent set by the mods is ANYTHING GOES.
If your new thread was first, it stays, even if you posted it 309 posts away from bump limit.
>>
>>52458658
this
MODS = CODS
>>
>>52458658
have fun being benned
>>
>>52457903
not when the difference is in megabytes
>>
>>52459051
it's not like you're going to deal with 50000x40000 files
>>
>>52456698
It returns an unsigned int, and you got signed int in your loop.
Thread replies: 325
Thread images: 50
Thread DB ID: 425402



[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | 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.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.