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

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

Thread replies: 255
Thread images: 33
File: 4aX1VW1 (1).png (819 KB, 1282x722) Image search: [Google]
4aX1VW1 (1).png
819 KB, 1282x722
Old thread at >>51680061

What are you working on, /g/?
>>
First for Java
>>
2nd for Go
>>
third for turd lol
>>
I need help. I have two identical programs compiled with MinGW G++ on Windows 7 and for some reason geometry shaders aren't working on Windows 8 or 10. I'm trying to troubleshoot what could be causing this the only thing it could be is geometry shading. Do I have to compile on Windows 8 or 10 or is there some kind of problem with geometry shading? Shading in general is working fine across systems, it's just when I get geometry shaders involved.
>>
>following Tour of C++
>write simple class and test main
>compile
>many, many errors
hm
>>
Is there a C book that acts like a man page for every C library header?

K&R doesn't go into implementation details at all.
>>
>>51686209
it prints the printable characters fine, but character codes 187, 191, and 239 all turn in to -17, -65, -69 (i.e. the correct character code minus 256) any idea why?
Node* treeBuilder(int* characterFrequency)
{
PriorityQueue huffmanPQ;
for(int i = 0; i < 256; i++)
{
if(characterFrequency[i] > 0)
{
Node* newNode = new Node(i);
insert(huffmanPQ, newNode, characterFrequency[i]);
}
}
if(traceLevel==2)
{
printf("Printing initial queue:\n");
printPriorityQueue(huffmanPQ, myItemPrinter, myPriorityPrinter);
}
while(!isEmpty(huffmanPQ))
{
Node* leaf1;
int priority1;
remove(huffmanPQ, leaf1, priority1);
if(traceLevel==2)
{
printf("First removal:\n");
printPriorityQueue(huffmanPQ, myItemPrinter, myPriorityPrinter);
}
Node* leaf2;
int priority2;
remove(huffmanPQ, leaf2, priority2);
if(traceLevel==2)
{
printf("Second removal:\n");
printPriorityQueue(huffmanPQ, myItemPrinter, myPriorityPrinter);
}
Node* nonleaf = new Node(leaf1, leaf2);
if(!isEmpty(huffmanPQ))
{
insert(huffmanPQ, nonleaf, priority1+priority2);
if(traceLevel==2)
{
printf("Combined inserted:\n");
printPriorityQueue(huffmanPQ, myItemPrinter, myPriorityPrinter);
}
}
else
{
return nonleaf;
}
}
}
>>
>>51686204
man <standard library>
>>
>>51686231
"char" is typically signed, i.e. it holds values in the range -128 to 127.
>>
>>51686231
Annotate your code Jesus fuck.
>>
Working on the implementation of linearity in my language's type theory.

My current idea is that every value that wants to be linear will contain a "linear nugget", or a value that has no information other than that it may only be used linearly. The module system will prevent users from being able to deconstruct the aggregated linear values (can't deconstruct through pattern matching if you're not allowed to mention the constructor).

In order to create or destroy these "nuggets", you will need to use a module/function/block tagged as "unsafe", which is also required to do FFI. "Unsafe" basically just means that you're doing something that the compiler cannot verify, so it has to trust you.
>>
>>51686259
Oh, and the other benefit of "unsafe" is that they are the only places where it is possible to introduce a bug. So the amount of code you have to check when debugging is vastly narrowed down. And if you're getting a bug even though you aren't using any unsafe parts yourself, you know that the problem is coming from upstream.
>>
working on a script that detects if a thread is started with an anime image & automatically hides it if it is
>>
>>51686251
oh, ok thanks
>>
>>51686086
>monkey trouble
>>
>>51686332
What's easier?
Detecting the diversity of the color palette (anime pics have large swarths of empty color) or uploading it to iqdb and blocking the thread if it returns a high confidence match?
>>
>>51686399
use a neural net
>>
>>51686332
>>51686399
>blocking anime
>not blocking traps
gay
>>
>>51686105
wut, there is no Go in OpenBSD? why don't you simply install it by hand and distribute the binary?

>>51686399
why not both, the 1st first, and the second only if the 1st step fails
>>
>>51686473
you have a neural net that can detect anime images?

would you mind uploading the trained weights? i would like to block anime images myself
>>
>>51686478
How would a software know a character is a trap?
It would literally have to be a neural net that crossreferences the pic on google to grab the show name and then looks for "crossdress" or "trap" keywords in close proximity to mentions of the show.
And then it would still fail whenever the show gets a shortened nickname.
>>
>>51686478
>program to determine whether an anime "girl" is a girl or a trap

I would legitimately pay money for this. It's so fucking annoying spending 2/3 hours a week sorting through images searching for bulges and flagging them for deletion if present.
>>
Finally got paging installed and malloc sort of working on my OS.
>>
>>51686399
what about checking if the contour is black?

>>51686513
let's do it ITT, then.
we need a logo ASAP
>>
File: 1447832306816.png (420 KB, 726x537) Image search: [Google]
1447832306816.png
420 KB, 726x537
>>51686513
>draw a girl
>call it a boy
your neural net can't tell the difference
what's the difference between bulge and a puffy vulva to a computer?
>>
>>51686498
I don't, but I'm sure you can find some online and if not you could just train it yourself.
>>
>>51686399
the latter is easier but not as reliable. if a picture is a screencap (like this thread) it misses it more often than not & if i lower the recognition threshold i get too many false positives. i'm in the middle of a rewrite to incorporate the former to account for this
>>
//MyClass.hpp
template <typename T>
class MyClass {
public:
int thing();
};

//MyClass.cpp
template <typename T>
MyClass<T>::thing() {}
// isn't this how you do it? wiki/compiler aren't helping
>>
>>51686636
You forgot the return type in the definition.
>>
>>51686646
thanks boy
>>
>>51686584
>draw a girl
>call it a boy
That's a girl, not a trap
>>
>>51686519
The bar is so low with programming anyone with an ass that warms a seat can get a job.

It's crazy how incompetent you can be and still get a job and even be considered mediocre.
>>
File: 9a1hQfU.jpg (63 KB, 1280x720) Image search: [Google]
9a1hQfU.jpg
63 KB, 1280x720
>>51686676
tell that to /a/
>this is a japanese boy detective
>>
>>51686680
Where are you located and where is this true? I am seriously considering packing up and moving to a city with better job prospects.

Literally the only jobs here are fluff positions like SENIOR JAVA ARCHITECT. Nothing entry level.
>>
I've got an svn repo on a secure server, a personal server I ssh into and my laptop. the secure server is only accessible from the personal server. Right now I'm basically using svn on the server and scp'ing the stuff to my computer to work on. Is there an easy way to make this simpler?

repostin on live thread
>>
>>51686783
yeah use git
>>
>>51686799
That would change absolutely nothing
>>
>>51686773
So say you're a senior java architect. No one knows what the fuck they are doing.

Also actual job listing aren't the only way to get a job. Pound the pavement, send your resume out to 100 companies. Don't just wait for shit to be posted on a website or come to you.
>>
i am linking it
why is this happening
It's something to do with templates isn't it?
this is my last retard sepples question of the day
#include <iostream>
#include "Vector.hpp"

int main() {
Vector<int> myvect(5);


for (int i = 0; i < myvect.size(); i++) {
myvect[i] = i * 2;
}

for (int i = 0; i < myvect.size(); i++) {
std::cout << myvect[i] << std::endl;
}

return 0;
}
→ cat Vector.hpp
template <typename T>
class Vector {
public:
Vector(int s);
~Vector();
int size();
T& operator[](int i);

private:
int sz;
T *elems;
};
→ cat Vector.cpp
#include <stdexcept>
#include "Vector.hpp"

template <typename T>
Vector<T>::Vector(int s) {
if (s < 0) {
throw std::length_error{};
}
this->elems = new T[s];
this->sz = s;
}

template <typename T>
Vector<T>::~Vector() {
delete[] this->elems;
}

template <typename T>
int Vector<T>::size() {
return this->sz;
}

template <typename T>
T& Vector<T>::operator[](int i) {
if (i < 0 || i >= this->size()) {
throw std::out_of_range{"Vector::operator[]"};
}
return this->elems[i];
}
→ g++ main.cpp Vector.cpp -std=c++14
/tmp/cccqrElu.o: In function `main':
main.cpp:(.text+0x16): undefined reference to `Vector<int>::Vector(int)'
main.cpp:(.text+0x29): undefined reference to `Vector<int>::size()'
main.cpp:(.text+0x44): undefined reference to `Vector<int>::operator[](int)'
main.cpp:(.text+0x67): undefined reference to `Vector<int>::size()'
main.cpp:(.text+0x82): undefined reference to `Vector<int>::operator[](int)'
main.cpp:(.text+0xb4): undefined reference to `Vector<int>::~Vector()'
main.cpp:(.text+0xc7): undefined reference to `Vector<int>::~Vector()'
collect2: error: ld returned 1 exit status
>>
>>51686858
All templated functions must be defined in the header. Only full specializations may be defined in the source file.
>>
>>51686858
All template code needs to be in a header file, you can't compile them and link them, you can only compile and link code that uses instances of them.
>>
>>51686903
Nice, thanks.
>>
File: angry_pepe.jpg (39 KB, 900x900) Image search: [Google]
angry_pepe.jpg
39 KB, 900x900
FUCK JAVA, IF YOU THINK THAT JAVA IS A GOOD IDEA FUCKING KILL YOURSELF, YOU ARE THE CANCER THAT THE WORLD IS SUFFERING FROM, FUCK YOU FUCK YOU FUCK YOU, I WISH FOR JAMES GOSLING TO FUCKING DIE A PAINFUL DEAD FUCK YOU.
JAVA IS MORE ABOUT CIRCLEJERKING ABOUT GETTERS AND SETTERS AND MAKING NEW FILES THAT IMPLEMENT GLUE METHODS THAN ACTUALLY PROGRAMMING.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I want to cry
>>
>>51686977
are you mad bro? is java too big for your little head?
>>
>>51686977
dumb frogposter
>>
how do I learn powershell scripting?
>>
File: javabean.jpg (93 KB, 682x732) Image search: [Google]
javabean.jpg
93 KB, 682x732
>>51686991
>>51686992
I fixed my problems by using the C preprocessor :^)
Eclipse whines but who cares, lol
>>
>>51687023
you download busybox.exe and learn to use that instead
>>
>>51687086
> java
> eclipse
> c preprocessor

this might be even more retarded than the people who use haskell
>>
>>51686926
>header files
Kek. It's hilarious how many people drink the kool-aid.
>>
SWIFT
W
I
F
T
>>
>>51687142
>java
I am forced to

>eclipse
I am forced to

>c preprocessor
I am forced to if I do not want to write tons of glue code.
>>
>>51687147
What?
>>
>>51687165
Your to retarded to work. Just stop your job right now.
>>
>>51687147
I answered his question, do you have any idea what the fuck you're talking about?

FYI a good idea would be to just not reply and save yourself some humiliation.
>>
>>51687199
>your to
stop
>>
>>51687150

>tfw swift and other new meme languages will make programming a dead end career unless you're really talented
>>
>>51687170
If your header files are literally anything but a place to lay out your structs, your code is already horrendous.

Function prototypes shouldn't be necessary in well-structured code. Functions should all be declared as they're needed, with main() at the very bottom of your file.

When compiling, instead of making the compiler parse and link hundreds of disparate files, it's much more efficient (in terms of both compilation time AND execution time) to concatenate all of your code with #includes and process it as a single file. Doing this lets the compiler inline functions project-wide.
>>
>>51687258
People make structs that aren't templated?
>>
>>51687258
>Function prototypes shouldn't be necessary in well-structured code.
What is mutual recursion?

>Doing this lets the compiler inline functions project-wide.
LTO is already a thing without having to totally sacrifice incremental builds.
>>
>Functions should all be declared as they're needed, with main() at the very bottom of your file.
Nah, fuck off Grandpa.
>>
>>51687284
>using templates

Enjoy your code bloat. If you want real metaprogramming that isn't shit, I highly suggest writing your own DSL and not relying on C++'s aborted implementation.
>>
>>51687295
my code won't compile otherwise
>>
>>51687288
Mutual recursion is an exception, but it's generally pretty rare anyway. There's nothing stopping you from putting the prototype before the relevant pair of functions.
>>
>instead of just using templates, save bloat by writing an entire new programming language
>>
>>51687307
or programming in D
>>
>>51687307
What do you mean bloat? explain
>>
Either you use templates and generate more code, or you use generics and generate less efficient code. Your choice.
>>
File: 1442526249444.png (6 KB, 281x215) Image search: [Google]
1442526249444.png
6 KB, 281x215
Hey guys, wanna hear a joke?
Go's type system.
>>
I like templates
>>
>>51687370
>not just writing your own metaprogramming functions that work better than templates
>>
>>51687380
I don't get it.
What type system?
>>
>>51687393
Enlighten me as to how they work without generating specializations or using generics (void pointers).
>>
File: 1447230701697.png (351 KB, 342x391) Image search: [Google]
1447230701697.png
351 KB, 342x391
>>51687384
I won'r use templates because I don't understand how they work or how they are useful.
>>
File: dpt87.png (20 KB, 1896x116) Image search: [Google]
dpt87.png
20 KB, 1896x116
i don't understand what i'm supposed to do on this step. i made an int array[256] where each position in a character and the number stored in it is the frequency of that character in the file. i made a priority queue using the frequencies at priorities and converted it into this tree
Printing tree.
-17: level 8
-65: level 8
newline: level 8
E: level 9
D: level 9
q: level 6
p: level 5
l: level 4
i: level 3
r: level 4
n: level 4
g: level 7
f: level 7
x: level 7
v: level 7
b: level 7
U: level 9
L: level 9
-69: level 9
h: level 9
.: level 7
,: level 7
u: level 4
o: level 4
a: level 4
t: level 4
c: level 5
m: level 5
space: level 3
s: level 5
d: level 5
e: level 4

maybe my brain's fried but i have no idea what it's asking me to do or what the point of it is. the task is to compress a text file on a character basis
>>
>>51687408
You have a program that parses your source code for you and, when it finds certain tokens, compares against something (maybe we can call it a template) and then expands the token appropriately.
>>
>>51687432
So, generating specializations?
>>
>>51687258
>>51687307
Let's seem some brilliant stuff you've written.

Do you ever reuse pieces or do you just write the same shit over and over like most Ctards.
>>
File: jbtemplates.png (42 KB, 638x357) Image search: [Google]
jbtemplates.png
42 KB, 638x357
>>51687362
>>51687411
>>
>>51687432
Isn't that how template programming works in C++?
>>
>>51687446
Jesus Christ.
>>
>>51687432

In D, you can import a file as a string literal at compile time. You can perform almost arbitrary operations on it, and then insert it as code.
>>
File: z3f1WiK.jpg (62 KB, 551x550) Image search: [Google]
z3f1WiK.jpg
62 KB, 551x550
>>51687432
What do you think templates are you fucking moron.
>>
>>51687446
>I will avoid using what I don't understand
That makes sense.
>>
>>51687465
I do that in C as well. It's called preprocessing.
>>
>>51687477
How does a games developer not know how to use constructors?
>>
>>51687479
Let's see some of it big talker. You can't do the same stuff with the shitty C preprocessor that you can with C++ templates or D mixins.

Code or get the fuck out
>>
>>51687479
No, you don't.
>>
>>51687514
I don't use C's preprocessor. I use one I wrote myself, in C.
>>
>>51687529
It's shit compared to D
>>
>>51687529
beautiful
>>
>>51687540
But my optimized C code runs faster than D code, which is all that matters.
>>
>>51687529
So you generate specializations of functions? How is what you did not a shit version of templates or a shit version of D's mixins.
>>
>>51687432
>>51687479
>>51687529
>completely fucking missing the point
>>
Im making an Auschwitz simulator in C++ for fun and learning
>>
>>51687501
He's stubborn in learning about writing code in a different paradigm.
>>
>>51687555
Doubt it.
>>
>>51687555
You are way full of shit man, let's seem some code.
>>
>>51687545
The entire point was that instead of using some language's poorly-designed-by-committee solution to metaprogramming, a DSL is a better choice with very little required time investment.

>>51687556
The template spec is filled with unnecessary bloat and it's incredibly easy to abuse them.
>>
>>51687575
>Auschwitz simulator
What happens?

>>51687580
>templates can be abused
explain
>>
File: conv.png (2 MB, 885x633) Image search: [Google]
conv.png
2 MB, 885x633
I have an 8-bit AVR microcontroller development board and I would like to interface this device with it (pic related). My goal is to use it for connecting analog sensors (light + temperature) to the microcontroller to perform some measurements as the μC itself does not have any A/D conversion capabilities.

This device is an A/D and D/A converter chip equipped with i2c bus. As I have never used any bus with a μC, which resources would you recommend for learning about interfacing i2c devices with microcontrollers?
>>
>>51687596
I have literally had coworkers misusing templates result in compile times bloating to minutes. Replacing their use of templates with a DSL + custom preprocessor brought our compile time back down to 3 seconds, and even retards can use it.
>>
>>51687580
You still haven't answered my original question.
>>51687370
>>51687408
>>
>>51687596
it's still very early in the development, but you can get jews and gas || incinerate them
>>
>>51686142

Hmm... can you describe the bugs in more detail for what you're getting on Windows 8 and 10 compared to Windows 7?
>>
>>51687580
Show some examples

> The template spec is filled with unnecessary bloat and it's incredibly easy to abuse them.

Are you writing a compiler? No, you are not.

You reinvented templates and you want to think that there is some reason you work like a fool. You claim better speed than D which is a huge red flag because anyone who cares about speed would know that any difference in speed between the languages/compilers pales in comparison to the architecture of the program by a factor of 100 to 1000.
>>
>>51687619
Explain what misuse of templates is

>>51687626
Please don't tell me you believe in that bullshit
>>
>>51687647
If Hitler didn't kill 6,000,000 Jews why look up to him?
>>
>>51687657
That's a valid point, actually
>>
>>51687647
obviously the jews died of starvation by allies bombing the food before it came in to Auschwitz
>>
>>51687657
Because he conquered Europe?
>>
>>51686086
Just started researching physically based shading. After that I'm not sure what to do, maybe make an entire renderer with an editor or something
>>
Why are C fags so deluded?
>>
>>51687699
It's like a religion. It's more painful to admit you are wrong and learn something new than to fight and rationalize.
>>
Check my php script, leave a comment
http://tymko.2fh.co/gbook172/gbook.php
>>
>>51687726
>>
>>51687726
Why would I admit to being wrong of something with which I have no issues? Anti-C fags are much more fanatical on /g/ than C fags.
>>
>want to do entity scripting in an engine with C

>do I have structs on the C side?
>do I use a table on the lua side?

>what is the registry?
>how would it be used with C?

>absolutely no documentation

then how was it done years back?
>>
I can choose programming in my next semester, the only problem is it's Pascal. Is it relevant, is it interesting? I had C and C++ for 3 years and learned some PhP and javascript on the side. Should I go for it?
>>
Having second thoughts about my "linear nugget" proposal.

The other thing I was thinking about was simply having a wrapper that made any value inside of it linear. To use the value, you would simply map a function over it; the wrapper would act like a functor.

This is all within the core type theory anyways; it's only introduced at elaboration time, so you would never (as a programmer) be touching either concept.
>>
>>51687785
>Learning a language that sounds like it was named after a fancy waiter.
>>
>>51687785
I did pascal, it's basically visual basically
>>
>>51687785
CHANGE SCHOOLS NOW
>>
>>51687771
> C is fine
> are you too stupid to manage your own memory?
> code reuse? that's for idiots
> no I don't write software anyone else uses, why?
>>
>>51687780
You're not a very creative thinker, are you? Have you done anything for yourself in the last couple of weeks you've been stuck on this?

The registry is documented just fine. If you're as familiar with C and Lua as you claimed you were, you shouldn't be having any issues with it.
>>
>>51687820
C is fine for what it's used for. Right tool for the right job. Every good programmer can appreciate the benefits of using C for certain tasks.
>>
>>51687780
>then how was it done years back?
in C++.
>>
>>51687850
C is the right tool for the job when there is no other compiler for your architecture.
>>
>>51687803
>>51687806
>>51687809
just yes or no bros
>>
>>51687876
How about extremely low level stuff like drivers and kernels?
>>
>>51687886
NO
>>
>>51687902
C++ works just fine for that. You'd have to forget a bunch of the STL but that's not a big loss.
>>
>>51687886
yes if its the only (real) programming language available
>>
>>51687902
Their aren't many people doing "extremely low level stuff" and most drivers outside of Linux are C++.
>>
>>51687902
>>51687916

C++ can do anything as low level as C can
>>
File: wheeeeee.gif (499 KB, 300x250) Image search: [Google]
wheeeeee.gif
499 KB, 300x250
Hey guys, should I be casting the return value of malloc and pointers i'm about to free like
free((char *) string);
>>
>>51687902
There is no advantage to C over C++ as a language and many advantages to C++.
>>
>>51687785
>the only problem is it's Pascal

Hahaha oh wow college education can be a joke.
>>
>>51687927
Can being the keyword, but most low level projects are building on top of 20 year old technology.
>>
>>51687911
>>51687927
True. But then C++ has a lot of complexity. If not everyone on your team is a experienced C++ dev, then using C can be advantage.
>>
>>51687959
You can write C++ code with the same complexity as C code. Most C code is valid C++ code.
>>
>>51687928
NO
>>
>>51687825
>Have you done anything for yourself in the last couple of weeks you've been stuck on this?

I learned to drive a stickshift and shitposted on /o/; I also completed several shots for a music video in NukeX and Resolve.

>If you're as familiar with C and Lua as you claimed you were, you shouldn't be having any issues with it.

If it shows me exactly what I want then there would be no issue; I had something working, but then it began "bottlenecking" if that's the right term.
>>
>>51687959
> C
> advantage

A good C++ programmer should be able to write programs that are far less complex than C, with complexity being the interactions you have to take into account at any one time.

C++ allows complexity to be broken up far better than C.
>>
If everything was written in C, the world would be a better place, prove me wrong.
>>
>>51688018
What would C be written in?
>>
>>51687996
I'm talking about complexity in terms of all the stuff you have to learn to be able to understand any piece of C++ code and design and write good C++ code.
>>
>>51688025
It's already written in C m8.
>>
>>51688018
There was a time when everything was written in C and software was broken as fuck.

Go back to windows 3.1 if you think that.
>>
>>51688025
The C compiler is written in C
>>
>>51687785
Yes, if you aren't the kind of autist that freaks out when "{" is written as "begin", you'll be fine.
>>
>>51688032
It's far better in the long run, the complexity of even C++ is far outweighed by the complexity of a non-trivial piece of software.
>>
How to learn C?
>>
>>51688059
>It's far better in the long run
That really depends on the project. Certainly if you have plenty of good C++ programmers, C++ seems like the best option.
>>
File: cat.gif (16 KB, 180x236) Image search: [Google]
cat.gif
16 KB, 180x236
>>51688074
by reading pic related
>>
>>51688074
http://c.learncodethehardway.org/book/
>>
>>51687967
C code is shitty C++ code.
C code is not shitty C code.
>>
>>51687928
We talked about it faggot in the last thread.
>>
>>51688099
C won't save you from bad programmers.
>>
CS freshman working with Python 3.5 here.

Is there ANY way to call a method every x seconds that doesn't use time.sleep or threading?

I have no idea how threading works yet and it's fucking my shit up, and time.sleep just freezes everything in tkinter.
>>
>>51687991
>but then it began "bottlenecking" if that's the right term.
What EXACTLY do you mean by this?
>>
>>51688123
Didn't say it would. It just means you can use programmers who know C well enough on your code base pretty easy without having to know all of C++.
>>
>>51688108
That's a /really/ retarded argument.
>>
What does this do?
if(rp->p_flag & SSWAP) {
rp->p_flag =& ~SSWAP;
aretu(u.u_ssav);
}
>>
>>51688129
>Is there ANY way to call a method every x seconds
This is just bad, full stop.
>>
Finished my event bus in Go.
>>
>>51688145
some entities randomly stopped moving/working

most likely the order of operations in which I did things
>>
>>51687615
>interfacing i2c devices
google seems to show lots of results
>>
>>51688171
That's nowhere near how you use the term "bottleneck".

Post some code.
>>
>>51688155
No it isn't, it illustrates the point that C++ is a refinement of C, which it is.
>>
>>51688162
Why?
I want to decrease something by 1 every 10 seconds.
>>
File: YEAAAAAH COLA.jpg (141 KB, 1280x720) Image search: [Google]
YEAAAAAH COLA.jpg
141 KB, 1280x720
You have 10 seconds to explain why I shouldn't malloc every variable.
>>
File: recording_absolutelydisgusting.png (46 KB, 1361x550) Image search: [Google]
recording_absolutelydisgusting.png
46 KB, 1361x550
>>51688181
took that photo on 11/17

haven't worked in that project since

I have made a new project entirely for messing around with just entities and lua

once that's good, I can move that into the other project
>>
>>51688198
then calculate the number when you need it using the time at start
>>
>>51688205
Go ahead and do it and come back when you have a nervous breakdown.
>>
>>51688205
H E A P
E A
A E
P A E H
>>
>>51688205
Because this will happen
>>
>>51688205
Stacks are fast, heaps are not.
>>
>>51688106
That only teaches pointers and memory management in C. Do you imply that the only thing you need to learn is that and all other stuff can be picked up by writing / reading code?

>>51688107
I'll check it.
>>
>>51688212
But, you haven't even implemented anything I told you. Learn the registry, and use it instead of doing this half in C and half in Lua in some disgusting manner.
>>
>>51688107
this is really bad
don't even bother with it

zed shaw is a moron
>>
Hey /dpt/, I know you guys shit over web dev all the time (I do too, kek) but I need to write a web app. How do I go about writing an optimized JS application? I know that when you append |0 to the end of your javascript numbers, that forces them to be processed as integers, is there some way I can just declare integer instead of var and have that done automatically for me?

Basically, let's say I'm forced to write relatively high-performance Javascript. Is there a way?
>>
>>51688260
OH, you wanted a picture of recent code

Sorry m8, I am overloaded with all the different ways to do things, I don't even know which direction to go anymore
>>
>>51686204
The GNU libc reference manual is pretty good.

https://www.gnu.org/software/libc/manual/html_node/
>>
>>51688284
There actually is a way: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
Also tell the guy high-performance JS is a joke.
>>
>mfw you can play catch with pointers and free memory blocks long after they've gone out of scope

I fucking love C holy shit.
>>
~50 lines of code (bloat, i know)
D macro preprocessor
# at the start declares a macro, # afterwards declares the identifier of the macro (the position matters)

runs at compile time, so you could use mixin to insert the processed code

can't use macros in macros, or generate macros with macros yet

>>51688315
can be done in C++ and D
>>
>>51688315
>not just letting the OS manage your memory
Kek.
>>
File: 1422485801172.jpg (134 KB, 550x550) Image search: [Google]
1422485801172.jpg
134 KB, 550x550
>>51688315
>I love dangerous stuff that harms the stability and security of software
>muh low level language
>>
File: macros.png (2 KB, 167x128) Image search: [Google]
macros.png
2 KB, 167x128
>>51688358
>>
>>51688369
(\ is a space)
>>
In shellscripts, how do you get more than one option to work together? So, in this example, both options require an argument. But if I were to run this doing using both options at the same time, like -id or -di, then it treats the second option as if it were an argument and it doesn't work.

#!/bin/bash

options=':d:i:'

while getopts $options option
do
case $option in
d) du $OPTARG --max-depth=2 -k | sort -n
echo
;;
i) df $OPTARG -T | awk '{ print $1,$2,$6,$7 }' | column -t
echo
;;
esac
done
>>
>>51688285
Does this help at all?
void loadEntityPrototype(lua_State vm, int prototype, const char *path) {
luaL_dofile(vm, path);
lua_pushnumber(vm, prototype);
lua_getglobal(vm, "prototype");
lua_settable(vm, LUA_REGISTRYINDEX);
}


Sample prototype script:
prototype = {
new = function()
return {
name = "Sample",
foo = 0
}
end,

update = function(self)
self.foo = self.foo + 10
end,

draw = function(self)
return "%s(%d)":format(self.name, self.foo)
end
}
>>
>>51688364
>I'm too incompetent to write code that doesn't crash
>Better shit over people who can
>>
>>51688018
it is, that's why people can become rich profiting from retarded software bugs
>>
>>51688403
If an option requires an argument, you have to provide it, and you can't merge option flags (i.e. you have to use "-i<arg> -d<arg>").
>>
>>51686086
Just started making a GNOME Shell extension that shows MPV's video in a small floating window if I go away from MPV's current workspace so that I can keep watching while doing whatever I do in that workspace. Other plans I have are to make it change corners on click/hover in case it's covering something important, and making the size user configurable.
>>
>>51688412
yeah I also drive a car without brakes because I can calculate how much time the car takes to stop after I take my foot off the gas pedal because I studied physics. It's not my fault you're a shit driver who can't do the same.

This is your retarded logic
>>
>>51688183
Refinements remove things by definition. Whatever way of c++ is best, c++ is not a refinement by any means
>>
How do I get the subtraction of a set in C? Like let's say I have the series 1, 2, 3, 4 and I want to subtract 2 from it, then I need to return 1, 3, 4.

Do I pass arrays and shit? That seems like a lot of work.
>>
>>51687771
>Anti-C fags are much more fanatical on /g/ than C fags.

That is a damned lie.
>>
>>51688074

K & R

For functionality: Buy an arduino
>>
>>51688716
C has no built-in set type, so first decide how you are going to represent your sets.

http://stackoverflow.com/questions/2630738/c-how-to-implement-set-data-structure
>>
>>51686204
H&S
>>
it's literally impossible to make an array of strings in c++
>>
>>51688935
he's not wrong
>>
why is Swift code so ugly?
    switch mode {
case .Usage:
usage()

case .Clean:
try rmtree(try findSourceRoot(), ".build")

case .Build(let configuration):
let rootd = try findSourceRoot()
let manifest = try Manifest(path: "\(rootd)/Package.swift", baseURL: rootd)
let pkgname = manifest.package.name ?? rootd.basename
let depsdir = Path.join(rootd, "Packages")
let computedTargets = try determineTargets(packageName: pkgname, prefix: rootd, ignore: [depsdir])
let targets = try manifest.configureTargets(computedTargets)
let dependencies = try get(manifest.package.dependencies, prefix: depsdir)
let builddir = Path.join(getenv("SWIFT_BUILD_PATH") ?? Path.join(rootd, ".build"), configuration.dirname)

for pkg in dependencies {
try llbuild(srcroot: pkg.path, targets: try pkg.targets(), dependencies: dependencies, prefix: builddir, tmpdir: Path.join(builddir, "\(pkg.name).o"), configuration: configuration)
}

// build the current directory
try llbuild(srcroot: rootd, targets: targets, dependencies: dependencies, prefix: builddir, tmpdir: Path.join(builddir, "\(pkgname).o"), configuration: configuration)

case .Version:
print("Apple Swift Package Manager 0.1")
}

>
do ... catch
instead of
try ... catch

>BUT try is still a keyword that does different things
>must bind variables in pattern matching with let
>must use . in the names of enum constructors being matched
>must use case in enum definitions, but only required once and can be left out afterwards
>>
>>51688889
+=
>>
>>51688935
Yet another reason why C is better.
>>
>>51688952
>Developer Apple Inc.
gee, I wodner
>>
>>51688409
thanks, let me take a look and get back to you

sorry about the delay, I had to help someone transfer a DV tape through thunderbolt
>>
>>51689003
but that took so many ideas that could be good and puked on all of them
same problem as Objective-C, just more modern
>>
>>51688997
It's literally impossible to make an array of strings in any language
>>
>>51689026
>but that took so many ideas that could be good and puked on all of them
The Apple legacy
>>
File: halp.png (13 KB, 519x448) Image search: [Google]
halp.png
13 KB, 519x448
Im sutck with python with this problem:

So i have a class A with a function, this function is being called by a parent class every so often. Then i have an other class B that would watch class A and execute a function whenever a specific function of A is called by its parent class.

pic related (4chan and mook is a nigger and i cant post any code for some retarded reason)

How do i do this?
>>
>>51688746
Nah. There's this huge "C tards are so stupid and fanatical" thing on /g/. But people that vocalize that are far more comman than the C tards. Mostly because Anti-C fags include the FP fags etc
>>
if a function can accept 3 parameters, do you have to send it 3 or can you send less?
>>
File: Untitled.png (38 KB, 703x367) Image search: [Google]
Untitled.png
38 KB, 703x367
>>51688935
What?
>>
@51689088
>Mostly because Anti-C fags include the FP fags etc
Here we go
>>
>>51689089
what do you mean can accept
if it's not variadic, no
>>
>>51689088
>tfw FP fag who has a hard on for C
>>
>>51689092
no one will fall for your shit garett
>>
Precedence is important.

I'm not an anti-C fag, I'm an anti-(C fag).
>>
>>51689092
an array has fixed size
a string does not
>>
>>51689129
Then explain how I just compiled and executed that program.
>>
>>51689129
>a string has no fixed size

Why are you making up definitions?
>>
>>51689127
Five star post

Rolling
>>
>>51689140
all strings but the last have the same length
>>
File: Untitle2d.png (42 KB, 713x410) Image search: [Google]
Untitle2d.png
42 KB, 713x410
>>51689187
There you go. I just changed the size of that array. That array of type std::string. You see where your logic might be faulty here?
>>
>>51688284
> High performance
> javascript

Look up asm.js
>>
C++ is so complicated holy shit
I need to slow down, do some practice problems or something
>>
>>51689205
oh
then the string content isn't stored in the array, just the header (which is constant size)
so its not really an array of strings
it's an array of metadata about strings
>>
>>51688693
> Refinements remove things by definition

C++ removes the need to micro-manage memory and removes the need to use functions instead of integrating data structures into expressions.

You can focus on the 'oh no more syntax' and get side tracked if you want though.
>>
>>51689028
why? You can make an "array" of "strings" in lots of languages, unless you're trying to argue over the definition of "array" or "string"
>>
File: content locked.png (72 KB, 473x353) Image search: [Google]
content locked.png
72 KB, 473x353
dammit, guess i gotta make a facebook now
>>
File: 1443576115872.gif (4 MB, 300x300) Image search: [Google]
1443576115872.gif
4 MB, 300x300
>>51689234
>Moving the goalposts
>>
>>51689254
cancer
don't visit that website ever again
>>
>>51688935
>>51688949
>>51688997
>>51689028
>>51689234

I know people still stuck on C are retards, but this is really above and beyond, even for you idiots.

Now I know why you guys don't get anything done, you're all about technicalities instead of reality.
>>
>>51689254
someone post the image with the locked-down sites and the 404 girl.
>>
char *stringArray[4] = {"An", "array", "of", "strings"};

Commies BTFO
>>
>>51689320
Not an array of strings.
>>
>>51687432
I can't believe those retards who made the language didn't think of that! We could call this "class plans" or "class arrangements"! No idea what that template garbage is but it sounds problematic
>>
>>51689333
If that's not an array of strings, then literally no language supports arrays of strings.
>>
>>51689333
Please give me your most likely super pedantic reason why that's not an array of strings
>>
>>51689350
that's his useless, pedantic point.
>>
>>51689350
>>51689356
Just ignore him. He is baiting you.
>>
>>51689356
Array of pointers to character that begin arrays. That notation is just syntactical sugar for assigning each pointer the address of the first character of each string.
>>
>>51686086
I am trying to implement a solution that doesn't run like absolute shit for the ugly numbers challenge. So far as I can tell, the fastest way to do this is described here: http://www.necessaryandsufficient.net/2008/08/google-code-jam-ugly-numbers/

But I only vaguely grasp why this is so much more efficient. I compiled an example solution that implemented this and for a 13 digit number it returned the result in less than a second. By comparison, my brute force garbage took like 2 minutes.

Could anyone break this method down into simpler terms?
>>
>>51689333
Triple threes confirms
>>
What is a string?
>>
>>51689398

Something you use to make clothes
>>
Why don't you metaprogram, /dpt/?

Why haven't you started programming code that programs for you yet?
>>
File: 1447218789771.jpg (834 KB, 1024x919) Image search: [Google]
1447218789771.jpg
834 KB, 1024x919
>>51689377
That's the dumbest shit I've ever heard. Who would even do that? Literally all the alternatives solutions provided create arrays of strings better than this in theory and in practice.
>>
>>51689398
A piece of text.

"String" <- the value of a string
>>
>>51688409
The code seems to work, thank you for that

After reading what prototype-based programming is (although the code shown was for javascript), and just so I understand this: when I create a "type" of entity (player, coin, goomba, etc) I call this code to put it into the lua state?

loadEntityPrototype( LS, 0, "objPlayer.lua" ); 


Is the next step for the "individual" entity that is going to be used?

I read the registry documentation again, so I set an entity to the prototype that's in the registry?

Sorry if I am off by a bit or alot
Thread replies: 255
Thread images: 33

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

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