[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: 22
File: 1447215635967.png (679 KB, 600x602) Image search: [Google]
1447215635967.png
679 KB, 600x602
Previous thread at >>51722977

What are you working on, /g/?
>>
DirectX is overrated.
>>
>>51726786
self loathing
>>
>>51726786
making a diagram drawer in sepples for practice
>>
first for ruby
>>
So normally when I work w/ php and sql, I use WinSCP. However, I want to be able to use html/php to upload a file as well. However, I can't for the life of me get it to work.
$target_dir = "http://turing.cs.myschoolname.edu/~mydirectory/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image


// Allow certain file formats
if($imageFileType != "csv") {
echo "$imageFileType";
echo "Sorry, only .csv files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
}
else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
}
else {
echo "Sorry, there was an error uploading your file. ";
echo "$target_dir ";
echo "$imageFileType ";
}
}


How do I tell if my error is w/ the code, or w/ me putting in the wrong address?
>>
>>51726803
It really pains me to hear laypeople talking about graphics libraries as a way to shitpost about graphics cards or game performance.
>>
File: RMS.png (97 KB, 203x235) Image search: [Google]
RMS.png
97 KB, 203x235
>>51726786
Thinking of learning a new programming language, higher level than C but lower then python or clojure. Any ideas? Go's type system makes me uncomfortable.
>>
>>51726708
No, we focus on source code processing (lexical analysis, parsing, semantic analysis), LL and LR grammars, etc. Assembly is some other class but we talked a bit about VM code and its optimization (hence CIL)
>>
>>51726822
that's how you get SQL injections
>>
File: Valutron.png (17 KB, 750x216) Image search: [Google]
Valutron.png
17 KB, 750x216
>>51726786
The algorithmic language Valutron.

Valutron is my algorithmic language for programming computers. Derived principally from Scheme (as defined in R6RS) and from ISO Lisp it provides an object-oriented and functional environment in which to build software.

The two main features Valutron offers that define it apart from other languages are, first, a powerful object model descended from iLOS (ISO Lisp Object System) and that of Objective-SmallTalk, which permits extreme dynamism and uses total-late-bound multimethods; the second, a code representation called V-expressions, which provide an algebraic syntax option for the language.

The implementation I am working on is called Valutron QuickSilver Performance Engine. It is written in Objective-C. Input is first transformed into Cons trees and then compiled into bytecode, which is executed in a precision virtual machine whose design incorporates influence from Gnu Guile and the SECD Machine. A clean Trace-and-Sweep garbage collector is used to manage memory use; this collector is very efficient and fast, and leaves little reason for anyone to prefer manual management.

Finally, Valutron offers a pleasant interactive REPL environment.
>>
>>51726838
C++
>>
Java is inelegant.
D is dead
Rust represents Ds hopes and dreams
The Golang experiment has failed.
Pure functional programming is a meme
Multiparadigm functional programming has a lot of value.
Mia Malkova is the best porn star.

These are the facts
>>
>>51726838
If you don't care about memery, you can try C# or Java.
>>
File: snapshot33.png (123 KB, 1095x720) Image search: [Google]
snapshot33.png
123 KB, 1095x720
>>51726848
Here's a photo of Valutron's REPL prompt
>>
>>51726853
>Pure functional programming is a meme
>Multiparadigm functional programming has a lot of value.
"Pure" doesn't mean no side effects. With linear types, any function can have side effects and yet still be pure.
>>
>>51726786

I'm planning on writing a shell script for my Linux device in Python. Basically the script is designed to do the following:

1. Identify if a portable HDD is mounted or not
2. If so, check if there's a SD-card mounted
3. Transfer all data from the SD-card to the HDD

I'm still kinda on the edge if I should use Python or not for this.
>>
>>51726848
>>51726867
>VIRTUAL MACHINE
>INTERPRETED
>>
>>51726843
What do you mean? I'm trying to set up a page so where when an Admin logs in, they can click "import file," they browse for a file, and then it uploads it to my server
>>
This is DPT: http://nask.co/see/xV0O7OAwzg
>>
File: jsexec.png (110 KB, 1470x1531) Image search: [Google]
jsexec.png
110 KB, 1470x1531
a win 10 modern app that executes your javascript and has a few callbacks to fuck around with the console window
>>
>>51726853
>Java is inelegant.
no
>Multiparadigm functional programming has a lot of value.
specialization>universality
>Mia Malkova is the best porn star.
AFAIK Kayden Kross is still alive, so no
>>
File: 1437092297581.jpg (885 KB, 2448x3264) Image search: [Google]
1437092297581.jpg
885 KB, 2448x3264
>The implementation I am working on is called Valutron QuickSilver Performance Engine. It is written in Objective-C. Input is first transformed into Cons trees and then compiled into bytecode, which is executed in a precision virtual machine whose design incorporates influence from Gnu Guile and the SECD Machine. A clean Trace-and-Sweep garbage collector is used to manage memory use; this collector is very efficient and fast, and leaves little reason for anyone to prefer manual management.
>>
>>51726892
please posting this
>>
>>51726906
Literally everything in this post is wrong.
>>
>>51726763
>"new" is just a function that is part of the prototype table that returns the object (table)
Well I can run that function, even in the old way, both ways must not return the table. I can do:
self = { 
name = "test",
var = 0
}
return self

and print the self variables before I return it, but ultimately I can't get to those later either.

I understand Lua, I understand it's concept; as for how far the rabit hole goes, I do know the answer to that.

I did alot simpler things in lua (compared to this), there's no resources like lazyfoo around on going step by step on using it for making a game, so this is a steep step up. I haven't taken a computer class in lua, and probably won't as it's not available in my geographical area (C# or Java is all there is).
>>
>>51726906
>no
Objectively so
>specialization>universality
Those words an multi/single paradigm are mutually exclusive.
>AFAIK Kayden Kross is still alive, so no
Well that's your opinion I suppose
>>
>>51726906
>specialization>universality
and what does Java "specialise" in?
>>
>>51726951
OOP
>>
>>51726940
Are you sure they're not returning the table? The problem could be happening when setting/getting with the registry.
>>
>>51726951
inelegance.
>>
>>51726951
ENTERPRISE
>>
>>51726906
java senpai knows what's up
>>
>>51726962
Why is that good?
The fact that Java is so obsessed with strict OOP is widely considered one of the worst things about it. At least they finally fucking added lambda's. Only took them 10 fucking years after C# doing it.

Do you think JS would be better if you removed all the functional stuff in it and made it "imperative" only? Functional shit in JS is the only thing that makes it bearable.
>>
>>51726951
>>51726972
Being good at representing real life entities due to the object oriented nature.
>>
>>51727008
>using OOP to model "real life" relationships
Burn in hell.
>>
>>51726951
verbosity
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>51726996
nice meme
>>
repost from old thread.

I'm programming a simple vocabulary game for a bunch of high school students. The thing is nearly done, but I got a suggestion I don't know how to implement. I want to highlight the right answer when a student clicks the wrong one.

 Private Sub btnOption1_Click(sender As Object, e As EventArgs) Handles btnOption1.Click
For Each key In correct1
If btnOption1.Text.Equals(key) Then
Correct = Correct + 1
allpoints = allpoints - 2
btnOption1.BackColor = Color.Green
End If
Next
For Each key In incorrect1
If btnOption1.Text.Equals(key) Then
Incorrect = Incorrect + 1
allpoints = allpoints + 2
btnOption1.BackColor = Color.Red



I declared the correct word to be taken from a text file.

 Dim Keyword(10) As String
Dim Word1(10), Word2(10), Word3(10), Word4(10) As String
Dim correct1() As String = IO.File.ReadAllLines("CorrectWords.txt")
Dim incorrect1() As String = IO.File.ReadAllLines("IncorrectWords.txt")



But the right answer doesn't trigger unless the button is pressed, so I can't just declare "whateverbuttonwascorrect.backcolor = color.green" so what can I enter to highlight the correct choice? I know I enter it into the incorrect subsection, but I have no idea what to enter.

Yes, it's windows, and yes, it's visual basic. I'm a complete beginner when it comes to programming. I don't mind if you insult me for it, but I'd appreciate some guidance, please.
>>
remember when /dpt/ universally agreed that java was bad
when tripfags were the only ones that used windows
>>
>>51727008
C# does it better.
Or Stab if you simply must use the JVM
>>
>>51727020
>being too stupid to understand OOP
>>
>>51727020
Oh boy, I wonder why every serious enterprise is using C# to work with databases.

Take your OOP memes somewhere else.
>>
>>51726879
It is a high-speed performance engine whose design takes cues from the best-in-class.

>>51726924
I don't know what you're implying.

>>51727020
OOP maps well to the real world, if you use an appropriate OOP solution. One example of a well-built object model is that of Valutron; being a student of psychology and with extensive knowledge of sociology, I was able to draw upon a wealth of material and interpret it, to try to match the Valutron object model to the way in which we interact with the world and with each other.
>>
>>51727030
>the most popular programming language is bad
>the less popular language that is a near identical copy of the most popular language is good
how can you not realize how much of a smug fucking stupid ass hipster you are
>>
>>51727045
>>51727068
>>51727073
OOP should be used to tastefully apply encapsulation, polymorphism, and inheritance to make your code better. Not to arbitrarily reflect how humans see things in real life. Go fuck yourselves, all of you.
>>
>>51727099
>being too stupid to understand OOP
>>
>>51727094
>near identical copy
In the same way that c++ is a near identical copy to C.
Idiomatic C# has been vastly ahead of java since version 2 in features and functionality.
>>
FizzBuzz in CIL:
http://pastebin.com/PaZwXSLz
>crashes in Main
>I wouldn't mind if some CIL expert would take a look
>>
>>51727094
Assembly is the most popular programming language
>>
>>51727094
I didn't say anything about a good language in my post, friend
>>
File: 1448870372218.gif (3 MB, 550x309) Image search: [Google]
1448870372218.gif
3 MB, 550x309
>>51727094
>the most popular programming language is bad
Yup
>mfw Java still can't pass by reference
>>
File: 1443448342317.jpg (182 KB, 639x960) Image search: [Google]
1443448342317.jpg
182 KB, 639x960
>One example of a well-built object model is that of Valutron; being a student of psychology and with extensive knowledge of sociology, I was able to draw upon a wealth of material and interpret it, to try to match the Valutron object model to the way in which we interact with the world and with each other.
>>
>>51727138
>not understanding anything
every parameter is passed by reference
>>
>>51727156
>doesn't understand java
>accuses others of same
Java passes objects by copy of reference.
You can't, for example, pass primitives as references.

>pick all images of signs with street names
>this task requires multiple correct solutions
Fuck off captcha
>>
>>51727156
Talk to me when Java can do this
import std.stdio;

void fun(ref int a, in int b)
{
a += b;
}

void main()
{
int x = 2, y = 1;

void fun(x, y);

writeln(x); //prints 3
}
>>
>>51727185
make a class that holds a union for every primitive

But yeah, I have had some captchas make me pick street signs 5+ times.
>>
>>51727185
just use wrapper classes, god dammit
>>
>>51727125
Probably noone gives a flying fuck but my program tried to return an integer from the Fizzbuzz method but the stack was empty. Making Fizzbuzz return void solves the issue.
>>
>>51727210
c# can do it multiple ways. (I'm not going to translate the code to match yours because I'm lazy)
static unsafe void Increment(int* i)
{
*i++;
}
static void Increment(ref int i)
{
i++;
}


you could also use the out keyword though that has some rules I'm not sure about (I think the value is write only until it's initialized)
>>
>>51727283
There's no way to compare in java because of how it autoboxes, but in C# a datastructure of ints is about 3 times faster and requires only a fraction of the memory that the same structure of Integers cost.
>>
>>51726925
what?
>>
private TreeTableColumn setSizeColumn(){
TreeTableColumn<File, String> col = new TreeTableColumn<>("Size");
col.setCellValueFactory(
(CellDataFeatures<File, String> p) -> {
ReadOnlyStringWrapper wrap;
File file = p.getValue().getValue();
String curPath = file.getPath();
long size = file.length();
if(file.isDirectory()){
if(storageCache.containsKey(curPath)){
wrap = new ReadOnlyStringWrapper( getByteSize(storageCache.get(curPath)) );
}else{
try{
size = FileItem.getSize(curPath, subDirs, subFiles);
storageCache.put(curPath, size);
wrap = new ReadOnlyStringWrapper(getByteSize(size));
}catch(IOException e){
storageCache.put(curPath, new Long(0));
wrap = new ReadOnlyStringWrapper(getByteSize(0));
}
}
}else if(file.isFile()){
storageCache.put(curPath, size);
wrap = new ReadOnlyStringWrapper(getByteSize(size));
}else{
storageCache.put(curPath, new Long(0));
wrap = new ReadOnlyStringWrapper(getByteSize(0));
}
return wrap;
}
);
col.setComparator(new sizeComparator());
return col;
}
>>
tfw convinced some retard at my uni to submit this for his assignment

http://pastebin.com/6fyhyP79
>>
post ide
stupid nerds
>>
>>51727366
>if (x) { while (x) {} }
need chemo tbf
>>
File: wuFEOxT.jpg (195 KB, 1050x1600) Image search: [Google]
wuFEOxT.jpg
195 KB, 1050x1600
>>51727366
>what's wrong with tha- OH GOD
>>
>>51726951
giving indians something to do when they're not shitting in the streets
>>
>>51727094
>not using windows or liking java = hipster
... what are you even doing in /g/ ?
>>
>>51727138
it doesn't want to. it's designed like that on purpose
>>
>>51727210
java doesn't want to. if you just read main(), you should be able to infer that it will print 2
>>
>>51727435
>being in denial of being a hipster
typical trait of a hipster
>>
>>51727472
are you retarded? hipsters are proud of their hipsterism...
>>
>>51727458
>if you just read main(), you should be able to infer that it will print 2
According to what?
>>
This is why any lisp based language is shit and why you should never program in it.
(define merge-lists
(lambda (l1 l2)
(cond ((null? l1)
l2
(cond ((null? l2)
l1
(cond ((< (car l1) (car l2))
(cons (car l1) (merge-lists (cdr l1) l2))
(cons (car l2) (merge-lists (cdr l2) l1))))))))))

(define even-numbers
(lambda (l)
(cond ((null? l)
'()
(cond ((null? (cdr l))
'()
(cons (car (cdr l)) (even-numbers (cdr (cdr l))))))))))

(define odd-numbers
(lambda (l)
(cond ((null? l)
'()
(cond ((null? (cdr l))
(list (car l))
(cons (car l) (odd-numbers (cdr (cdrl))))))))))

(define merge-sort
(lambda (l)
(cond ((null? l)
l
(cond ((null? (cdr l))
l
(merge-lists
(merge-sort (odd-numbers l))
(merge-sort (even-numbers l)))))))))
>>
>>51727492
since x is a primitive and java doesn't have pass by reference. simply passing a value to a method can't change the value.
>>
>>51727506
Yes?
That's not Java I posted
>>
>>51727488
posers call themselves hipsters. real hipsters think they're normal.
>>
>>51727521
holy shit how fucking stupid can you be
>Talk to me when Java can do this
i responded with
>java doesn't want to
and explained why it doesn't want to
>>
File: tumblr_neegv2mxLi1riyb8io1_500.png (380 KB, 500x429) Image search: [Google]
tumblr_neegv2mxLi1riyb8io1_500.png
380 KB, 500x429
>>51727029

Can anyone help? I have to upload this to our web server by tomorrow night. I can't find the solution on google.
>>
>Java doesn't want to
Is Java your deity?
>>
>>51727561
Based Java is everyone's deity. Allah Akbar.
>>
>>51727549
upload ide
>>
>>51727521
C (and its predecessors) established that if you're passing a variable to a function that you aren't changing the value of that variable. References allow you to change values of variables passed to functions, so now if you call a function passing a variable in a language with references, you don't know just from seeing the function call whether or not it is changing the value of the variable.
>>
>>51727547
>if you just read main(), you should be able to infer that it will print 2
You said this like it was a general rule that wasn't limited to Java, and then starting saying shit we've already established. Sorry I didn't get what you were saying with your shitty English
>>
doing my last lisp homeworks of the quarter
>>
>>51727601
>butthurt
>>
>>51727590
As soon as you introduce anything but primitives, Java doesn't make any such guarantee.
>>
Too bad Java throws immutability out the window as soon as you have to put more than one value together.
>>
for encoding with huffman trees, how do i make my function that reads the tree stop when the tree's done being read it? either i get a segmentation fault or i don't get any compiler errors but it crashes my computer out
>>
>>51727627
yes it does, if you have a variable holding an object reference and you pass that variable to a method, then after that method call the variable will still hold the same object reference unless you explicitly assign something else to the variable.
>>
>>51727627
I'm not praising java, just bashing references, but even so, in Java, you know what is and isn't a primitive.
>>
>>51727678
>hurr it's not changing the value of the reference because it's only changing what it points to
Pedantic fuck.

>>51727683
Why does it matter? Why's it so great that it doesn't have references when it only works for primitives and strings anyways?
>>
>>51727708
>Pedantic fuck.
python babby.
>>
>>51727677
man, you've been asking this shit for days. why don't you ask in some IRC channel or something?
most people here are college students in their first years..
>>
>>51727708
did you read my whole post
>>
>>51727708
you clearly don't know what you're talking about
>>
>>51727728
i'm a second year college student myself lol
>>
>>51727728
What kind of read?
>>
what's more efficient. spritebatch or shaperenderer
>>
>mfw trying to get an abandoned C++ project that hasn't been updated in 5 years and uses nearly every boost feature to fucking compile
>commenting out includes
>commenting out parts of the configure script
>changing type definitions that gcc is yelling at me about
>if a type is ambiguous just choose one for christ's sake you listed them right there it's not like I know any better than you compiler-san
>it's been hours
>mfw just want to try this program out not even sure I want to use it
>>
>>51727928
They do completely different things.
>>
>>51727957
oh shit it's linking get hype
>>
>>51727962
for render()
>>
How come come the output of
import math
def fact(n):
math.factorial(n)

print math.factorial(3)
print fact(3)

is
6
None

?
>>
>>51728063
They do completely different things.
>>
>>51728071
>return math.factorial(n)
cmon dude
>>
>>51728074
stop trolling
>>
>>51728115
You can't compare the efficiency of two things if they don't do the same thing.
>>
>>51728099
Oh shit. Thanks a lot :)
>>
>>51727677
Use recursion.
if(node.left == null && node.right == null){
return
}
read(node.left);
read(node.right)

Obiously that's incomplete but I imagine it solves the no ending problem
>>
>>51727913
what?
>>
>>51728130
Well, you can. It's just meaningless.
Shaperender is absolutely less efficient by way of performance hit per call
>>
>>51728130
to draw a background you can use shaperenderer.rect or you can load a 3x3 plain textureregion and turn it into a sprite and draw with spritebatch. which is more efficient
>>
So far my OS has a basic VGA driver, IDt's & GDt's, a base IRQ system and a few of the more necessary Fault handlers. There is also basic paging and a heap implemented. What should I work on next?
>>
>>51728187
dang
>>
>>51728199
Which do YOU think is going to be faster?

Drawing a single untextured quad
vs.
Drawing tons of tiny, tiled, textured quads
>>
>>51728143
this is what i got now for the tree reader.
Node* treeFromBinary(BFILE* filename)
{
int x = readBit(filename);
if(x==1)
{
Node* leaf = new Node(readByte(filename));
return leaf;
}
else if(x==0)
{
Node *left = treeFromBinary(filename);
Node *right = treeFromBinary(filename);
Node *nonleaf = new Node(left, right);
return nonleaf;
}
else
{
return NULL;
}
}


the tree reader SEEMS like it works, but then when i use my print tree function on it after the fact, it prints everything in the tree except for the top-most, right-most spot where it tells me segmentation fault.

this is the print tree function
void printTree(Node* treeToPrint)
{
printf("printing tree\n");
if(treeToPrint->kind == leaf)
{
printChar(treeToPrint->ch);
}
else
{
printf("(");
printTree(treeToPrint->left);
printf(", ");
printTree(treeToPrint->right);
printf(")");
}

}


it works when my encoded file only contained the tree, but when i made it also have the compressed characters now i get a segmentation faut at the last spot
>>
>>51728205
are you using the osdev wiki as a resource? what other resources are you using? ive been thinking of putting my 2nd pi to use and starting to work on an extremely basic OS as a way of learning assembly. am i in over my head already if i don't already have a good assembly foundation?
>>
>>51728223
Ah jeeze. I'd try to help but I have an exam in 5 hours(interestingly enough, huffman is likely going to show his head) and need to go to bed sorry.
>>
>>51728220
i'm not that familiar with openGL but i'd say the latter. the thing is i'd have to implement a new object to go along with the sprite method and change the gradient instead of the convenient color parameters in the shaperenderer shape itself
>>
>>51728232
I have a few resources I use. James Molloy is good, but make sure you know the issues in his Tuts. Also Bran's Kern-Dev is good. I did use a lot of the OSDev wiki at first. Lurk moar on their forums. Trust me an account with those forums is priceless. Just don't ask questions expecting them to be nice to newbies. Also the Pi is ARM architechture. It's a different ISA than intel
>>
File: feels strongman.png (42 KB, 129x111) Image search: [Google]
feels strongman.png
42 KB, 129x111
>>51728251
thanks anyways
>>
>>51728252
FYI, it's the former. By far.
>>
>>51728264
that's what i meant
>>
>>51728259
thanks mate. also damn i hadn't even considered the pi is ARM. oh well, probably more convenient to emulate on my dev pc anyway.
>>
How bad does "Self employed" look on my resume when it comes to programming jobs? I finished two years of community college then started doing online freelancing bullshit, and I've been doing that for 3 years now. Thinking about trying to get a "real" job because it's a pain in the ass dealing with clients. I'm pretty much a NEET, then when I lucky with a decent project I live off the money until the next score, usually several months later.

Having this "gap" in my employment history seems like it'd make me hard to hire. Am I overthinking things?
>>
>>51728313
say freelance
>>
>>51728313

Huh? Don't tell me you actually put "self-employed" in your resume, put down the freelance stuff that you're proud of.
>>
>>51728313
don't actually write "self-employed", just say freelance. better yet, start an LLC and just attribute all your past freelancing to that and instead say that you started your own development firm and have worked with X Y and Z clients for the past X years. you probably don't even need to LLC.
>>
>>51728293
Just make sure you know how to build a good cross compiler.

What's your dev machine? I assume linux.
>>
>>51728313
>expecting to ever get a job after 3 years of being philosopher and entrepreneur
>>
>>51728408
in all honesty i do most of my work on windows but i have a linux mint install for when i want to play with linux. i don't really understand what makes linux a better dev environment. am i a bad person for enjoying visual studio?
>>
why would a tree have a segmentation fault when you try to print it or use it, but not when you're constructing it?
>>
>>51728442
why not? what's the problem?
>>
>>51728469
No. just don't expect to be able to do OS Dev well without understanding the in's and out's of linux. I do develop on windows sometimes, But even then it's under cgwin.
>>
>>51728516
**cygwin
>>
>>51728516
This. Whatever you do, do NOT use Windows as a role model for your OS. It's rotten to the kernel.
>>
>>51728539
>do NOT use Windows as a role model for your OS. It's rotten to the kernel
Same for linux actually, if you are going to make a OS make it good and modern.
>>
>>51728539
That's not what I'm saying at all. I just mean the tools available for osdev in it's current form are not well implemented in a windows environment without some emulation. Windows, while it has it's faults does some things well. Nothing is perfect; To say Linux is the best or Windows is or Mac or FreeBSD etc... is just naive
>>
>>51728561
That's also true. Microkernel architectures are probably best.

>>51728569
My point still stands. I'm not saying anything's the best, I'm saying that Windows is bad.
>>
>>51726966
it could be, but self should let me access it and it's not; do you know what area I should look at?
>>
While we're on this topic, can somebody explain why Linux is hailed as a god-tier developer platform? What makes programming on Linux better than on Windows? Is it preference or is there some actual edge that Linux has over Windows regarding development?
>>
>>51728579
Well, first of all, fix the new function so that it does what it's supposed to, return a table from nothing.

Then track whether it's nil coming out of the function, and if not, if it's nil coming out of the registry.
>>
>>51728498
>why would a tree have a segmentation fault

Get a stack trace for the segfault and you'll know why.
>>
>>51728591
i can install and use a library in under 5 seconds + install time
>>
>>51728600
Are you referring to the fact that Linux uses package managers? Even then, that's kind of a minimal time boost. Doesn't take me very long to download a library and install it on Windows.
>>
>>51728591
More tools that are much more readily available on Linux.
>>
>>51728591
Dealing with libraries is a royal pain on Windows. Also, you have some god-tier tools like the Valgrind suite that simply aren't available otherwise.
>>
>>51728569
This
You can't inject a thread in another process in linux for a example, nor you can read the memory from another process.

>>51728591
Package managers are awesome and avoid dll/library hell. It is even better when programming due to the -dev packages.

The best compilers are native to it, unlike windows where you have to use stupid hacks like cygwin.

Terminal that does not suck dicks, same for the shell and the utilities.

Superior editors are native to it.

More things that I am forgetting.

>>51728619
It saves you from the mess.
>>
>>51728591
Linux has package managers for installing 3rd party libraries and putting their libs and headers in the right places so they can be used right away in a C/C++ program.

On Windows, you have to add them to your includepath and libpath manually, and possibly build the library yourself if it wasn't built for the correct bit width or MSVC version.

Choco is an attempt at making a package manager for Windows, but it doesn't do even a tenth of what Linux ones do.
>>
>>51728620
Could you name a few essential Linux-only tools that don't have Windows equivalents? Not being snarky I'm just genuinely curious.
>>
>>51728619
what I said holds true even for a beginner
I can write a battery monitor without using any library outside of the C standard, as a very minimal, basic example
everything is available to me
>>
>>51728644
/dev/battery?
>>
>>51728664
I used /sys/class/power_supply/BAT0/charge_full, charge_current, and charge_status
>>
>>51728593
it set it back to the style of what was given to me earlier.

if I print a self variable from the update function, local self is nil

not sure how I would print it as is in the new function

i've been looking around for any C functions I can use to check but all I have been able to find is something to dump the stack
>>
>>51728720
Well, when you call the "new" function from C, whatever it returns is put on top of the stack. So just print that.
>>
>>51728594
how do i do that with c++?
>>
>>51728749
gdb ./a.out
(gdb) run
... SIGSEV, Segmentation fault.
(gdb) backtrace
>>
>>51728628
bash
zsh
>>
>>51728737
it prints table so there should be a table then
>>
>>51728569
>Linux
http://www.nask.co/see/TGAPWvOyuU
>>
>>51728797
Okay, now figure out if getting it out of the registry during the update is working.
>>
>>51728628
aptitude/pacman/etc.
rsync
>>
I can't think of any that can't be imported or compiled by source.
>>51728781
I use a fully fledged bash (and zsh) btw on windows.

But some are harder to obtain or compile. grub and xorriso were a bitch for me.
>>
>>51728812
Msys2 has pcaman as it's default package manager. I'm sure rsync source is available
>>
>>51728808
>http://www.nask.co/see/TGAPWvOyuU
If this is some shit about GNU/Linux I'm not going to open it.
>>
>>51727366
 // clever hackery piping the inputs in and out to check they are valid, encoded for speed, much faster than conventional for loop and if comparison 



Anon I love your painfully obvious comments as well
PlaceCheese(); // this method places the cheese
>>
>>51727366
holy shit it just keeps getting worse my sides
>>
TONIGHT ON YOUR OPERATING SYSTEMS COURSE: 50 YEARS OF THE HISTORY OF COMPUTING AND WHY EVERY PROGRAMMER IS BATSHIT INSANE
>>
What drugs will make me a better programer?
>>
>>51729029
If you haven't hit puberty yet, take hormone blockers to delay its onset so you'll have more time to learn computers instead of thinking about girls.
>>
what's better. knowing several languages or knowing one language really well
>>
>>51728811
if I print what's at the top of the stack in the C function that calls the update, I get:

lua_pushnumber(LS, g_ENT[i].prototype);
lua_gettable(LS, LUA_REGISTRYINDEX);

>table
...the above
lua_pushstring(LS, "update");
lua_gettable(LS, -2);

>function
...the above
lua_pushlightuserdata(LS, g_ENT + i);
lua_gettable(LS, LUA_REGISTRYINDEX);

>nil

so does it have something to do with the userdata?
>>
>>51729039
>about girls
or boys
>>
>>51729047
Master of multiple languages > Master of one language > "I can write Hello World in 10 different languages!"
>>
Alright lads, do I study C, D or Assembly tonight?
>>
>>51729047
idk, trick question? learning a language shouldn't really take much effort so long as you understand the principles and concepts that are global across most languages. id say being REALLY good at one language (or a small few) is better than being monkey-tier in a bunch that you barely remember, if you put a gun to my head.
>>
>>51729029
If you haven't hit puberty yet, take testosterone blockers and estrogen to make you more cute and girly.
I wish I had done the same ;__;
>>
>>51729096
Or algorithms?
>>
>>51729105
same no homo tho
>>
>>51729048
Yeah, this is weird. It seems to somehow not be finding the key (pointer) in the registry.

By the way, I just found this:
http://www.lua.org/pil/27.3.2.html
Might be better to use that for the prototypes. Another thing you could do is use string keys for the prototypes, indexing them by name, and save the numeric references for the entity tables.
>>
>>51729105
People really need to stop suggesting that.
Sure, it lets you look like a girl, but you're permanently damaging your body and cutting decades off your life.
Of course, highly suicidal trannies don't give a fuck anyway.
>>
>>51729048
>>51729128
The other thing you could do, instead of using the registry, is create two tables (one for prototypes, one for entities) that you can both index by number without having to worry about collisions.
>>
my segmentation fault doesn't seem to be occuring at a time it would seem reasonable for it to occur. is it possible that my program encounters the segmentation fault, but then because of a delay or something i can't see what i should see prior to it? it's late and i'm tired
>>
>>51729211
Maybe you should stop trying to access memory not allocated to you.
>>
>>51729211
How are you detecting the place where you segfault? What is your program doing?
>>
>>51729130
>it lets you look like a girl
And this is one of the most awesome things in the world.
>>
So /g/, I just need some help on some refactoring I will need to do on some C code.

I have a bunch of code that basically is the following:

const char *name_list[] =
{
//This goes on for some time, just giving some names as example
"calendar_%d", "choice_%d", "clock%d", "a%d0", "a%d1", "it%03d", "t_turn%d", ...
}

//Unimportant code here

for(s = 0; s < (sizeof(names_list) / sizeof(char*)); s++)
{
//Unimportant code, limit gets set to 9 or 99 depending on some string flags in char array

for(i = 0; i < limit; i++)
{
char temp[MAX_NAME_LEN];

//This does not seem like the best way of doing this
sprintf(temp, names_list[s], i);

//char hashp[n].name[], const char* dirname
sprintf(hashp[n].name, "%s%s.tm2", dirname, temp);

//Unimportant, hash filename and move on.
hashp[n].hash = fnhash(hashp[n].name, n);
n++;
}
}


Is there possibly any more elegant/less verbose and safer way to copy a filename from a char array to another char array in C in a situation like I presented?

The way we are doing it right now is a serious security flaw and just sucks in general for anyone reading to understand. Anyone had a similar situation before and any tips/solutions on how to rewrite it?
>>
>>51729307
You will never be a girl, anon.
You will never bear children, and you will never be a mother.
>>
File: angry_pepe.jpg (39 KB, 900x900) Image search: [Google]
angry_pepe.jpg
39 KB, 900x900
>>51729332
>>
>>51729354
But you'll always have your shitty toad memes, you shitposter faggot
>>
File: smug maki.jpg (61 KB, 500x375) Image search: [Google]
smug maki.jpg
61 KB, 500x375
>>51729354
I'm just picturing this fat 20-something neet who wishes he was born a gril so he would never have to work because his worldview is so fucked up he honestly believes a woman of identical attractiveness to him can make it in this world just by sucking a few dicks.
>>
>>51729354
Stupid frogposting faggot
>>
>>51729312
First thing would be to use snprintf. That way you know you won't get a buffer overflow.

You could also call it once without outputting to anything to get the length, allocate a buffer of that length, and then output to the buffer.
>>
>>51729285
i had a segmentation fault before an else statement, but then i added a print after it saying printf("else done\n") THATS IT and then the else statement went through and wrote the "else done" and the segmentation fault occured after it. i feel like i'm chasing it down and whenever i'm about to pin it down it moves further down the line
>>
>>51729397
roastie please depart
>>
>>51729394
>>51729402
Pepe wasn't hated until a few months ago, what changed?
>>
>>51729440
it became completely mainstream, we found out it was mostly redditors who kept posting them after it hit facebook and then it became very obvious that every frog post was from an /r9k/ shitter and could be safely ignored for all intents and purposes.

It's like posting anime with your posts, except pretty much everyone knows you're a loser.
>>
>>51729440
Oh, I don't know, maybe because of fucking Reddit and /r9k/ autists obsessing over it and spreading it to literally every board on 4chan? It's fucking cancer and it needs to be eradicated.
>>
>>51729461
>>51729466
autists
>>
>>51729479
Kill yourself, frogposter.
>>
>>51729479
I'm not the one wishing i was a gril, anon.
>>
>>51729403

That's true but still with snprintf, you are looking at an unintended usage of the printf family, https://en.wikipedia.org/wiki/Uncontrolled_format_string

I would like to avoid this but I have no clue how to go about this. I could just try and funnel it into a new function but that just seems more verbose.
>>
>>51729312
In addition to what >>51729403 said, you can also elide temp completely using strcpy(hashp[n].name, dirname), then calling snprintf(hashp[n].name + strlen(dirname), ...) and then calling strcpy(hashp[n].name + strlen(dirname) + result_of_snprintf, ".tm2")

With buffer length checks all around, of course. Aren't you glad you chose C for this?

>>51729525
snprintf won't go past the end of the buffer size you give it, so you don't have to worry as long as you don't pass the user-provided data as the format string itself.
>>
>>51729525
I think you're fine, since you don't actually seem to be using user input as the format string. Literals chosen from an array are no less secure than directly using a literal.
>>
>>51729415
If you want to debug crashes using printf, you always need to fprintf to stderr because stdout is buffered. Otherwise, it will crash before stdout's buffer is flushed.

But forget I said that. Why didn't you just use gdb to get the stack trace? All you need is the stack trace.
>>
working on an ap comp sci project

how come this isn't working when I run it?
>>
>>51729675
Fuck off underage.
>>
>>51729675
Because you picked the wrong major. Have you considered liberal arts instead?
>>
>>51729675
How many lectures have you attended so far?

You need a main function.
>>
>>51729675
>/g/, help me with my homework! I'm too stupid to figure anything out myself!
Please Die.


Programs are executed step-by-step. Each line is executed, ONE AFTER ANOTHER.
By that logic, can you figure out why it isn't working? Look at your code, look at what it does and then kill yourself if you can't figure it out.
>>
>>51729675
>ap comp sci
hello underage

what specifically isn't working
>>
>>51726875
What is a shell script? How do you plan on making the python script run all the time waiting for a usb?
>>
>>51729705
im not underage im an 18y/o senior

when I click run I expect it to prompt me to enter my name and year of employment but nothing comes up at all
>>
>>51729727
ok well look at it stupid. You're prompting for a string before asking "what's your name"
so it's actually working just fine, you're just doin it wrong.
>>
>>51729684
>>51729687
>>51729694
>>51729701
>>51729705
>>51729711
ok I figured it out

I had the println after the scan.nextline and nextInt

I put it before and it works now

thanks /g/
>>
>>51729727
Ok...

How do you expect the computer to know where the program starts?
Surely they explained this in one of the classes you ditched this semester.
>>
>>51729750
actually though you're also being stupid. it's got a main.
>public static void main(String[] args) {
that line right there. Are you unfamiliar with Java or something
>>
>>51729761
Do you even know what String[] args does?
>>
>>51729791
yes.
>>
>>51729761
>public static void main(String[] args)
Classic verbose Java
>>
>>51729796
And what does it do?
>>
>>51729822
I don't know if you think you're talking to the APCS kid but you're not - I've been trained in enterprise-quality java and I am the top Indian in the entire Oracle code monkey forces. String[] args are the arguments. You pass them to the program when you run it.
>javac faggot.java && java faggot args[0] args[1] args[2] etc
that sort of thing.
>>
>>51729201
so instead of the registry, have two tables

prototype = {}
entity = {}


and, for example, entity[0] could be based on the player, which is prototype[0]?

sorry if I didnt understand it
>>
so this is late night american timezone /dpt/ quality

it's fucking shit
>>
I have a Mouse class that has whether left or right button clicked, the position, etc. I have a UI class that has a mouse, and it's going to be used with everything in the application, so there will be a lot of UI::mouseLeftClick() and UI::mouseGetx/y() calls. Should UI just inherit from Mouse?
>>
>>51729890
This is what happens when you don't put a qt anime gril in the OP
>>
>>51729884
No, I mean having a table that stores all the prototypes and another that stores all the entities. Custom registries, if you will.
>>
>>51729890
>no anime girl/"girl" OP image
man what did you expect. We need to scare people like the high school kid off better.
>>
>>51729907
Is the Interface class a mouse? No? Then why the fuck would it
>>
>>51729907
Why the fuck not ui.mouse.leftClick() or ui.mouse.getX/Y()?
>>
>>51729940
should the Mouse member variable be public then??
>>
>>51729953
Yes? Or better yet, why have the mouse in the "UI" to begin with? That doesn't really make sense.
>>
>>51729953
Mouse should be a singleton, or a class with only static methods. This would be obvious to anyone who wasn't poisoned with object oriented dogma in their introduction to programming.
>>
>>51729972
I wrote in only C for a couple years and started learning C++ last week actually, heh.
I'll look into it, thanks.
>>
File: 1447671722855.jpg (31 KB, 449x546) Image search: [Google]
1447671722855.jpg
31 KB, 449x546
>>51729972
>Mouse should be a singleton
>This would be obvious to anyone who wasn't poisoned with object oriented dogma
>>
>>51729616
i don't know how to use it. i'm a sophomore, this is my 2nd actual programming class
>>
>>51729918
ah, I misread that, my bad

I found this, I might also pull some stuff from it since it looks like it has stuff involving the registry http://stackoverflow.com/questions/5448654/lua-c-api-handling-and-storing-additional-arguments
>>
>>51729616
>If you want to debug crashes using printf, you always need to fprintf to stderr because stdout is buffered. Otherwise, it will crash before stdout's buffer is flushed.
The linebreak in printf forces a flush in stdout
>>
>>51730037
You need to learn how to get a stack trace for a C/C++ program. You need to do that right now before you waste any more time. See >>51728763
>>
>>51729962
UI not as in like buttons/menus, I'm not sure why I called it UI in my post, in my program it's just called the SDL Interface. It's the mouse, keyboard, window, renderer, etc.
>>
>>51730066
Only when stdout is line-buffered.
>>
>>51730144
In the unlikely event that his stdout is not line-buffered, all he has to do is manually flush the stream. No need for him to mess with gdb just for this.
>>
I swear I'm getting permanent hearing damage from the alarm/beep. I don't know why I haven't put "xset b off" in my .xinitrc.
>>
>>51730173
>damage control
>>
>>51730183
Damage control would be me pretending I didn't say what I said. You were right, but what you said is hardly relevant in this context (I doubt his stdout is anything but a terminal), and even if you are, the fix is easy.
>>
ap comp sci guy here

one more question

i made another method, public String main (String name) {

but it says I need a return type but I thought String was the return type?

what do
>>
>>51730309
shouldn't you be like 3 months into ap cs already
>>
>>51730071
it's due tomorrow and i don't understand what he's saying and i googled it and i don't understand what google said
>>
>>51730331
yeah but we learned methods a long time ago and somehow I forgot despite getting an A in the class

I don't like java anyway I had more fun learning python for a few weeks over the summer on code academy than I had in this class, its fucking boring
>>
>>51730309
>public String main (String name) {
This means you're making a function that returns a String.
Change it to void if you didn't want to return anything.
>>
>>51730309
>>51730331
never mind I think I figured it out
>>51730401
but it is supposed to return a string
>>
>>51730378
with your current attitude you have no future
Highschool programming classes are always shit, if you wish to get anywhere, self study. You should know what the main method is within an hour of learning your first C-derived programming language.
>>
>>51730378
>I had more fun learning python for a few weeks over the summer on code academy than I had in this class, its fucking boring
Leave
>>
>>51730374
Run these commands.

gdb name_of_program
run
Thread replies: 255
Thread images: 22

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.