[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Extra juicy! | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 329
Thread images: 30

File: anime computer.jpg (154KB, 1280x720px) Image search: [iqdb] [SauceNao] [Google]
anime computer.jpg
154KB, 1280x720px
Old thread: >>51500924

What are working on, /g/?
>>
JEWS
>>
>tfw ugly
>>
File: Logo_lisp.gif (11KB, 700x385px) Image search: [iqdb] [SauceNao] [Google]
Logo_lisp.gif
11KB, 700x385px
>>51512898
Building a Lisp, implemented in the following way with the help of Objective-C, YaCC, Lex, and itself:

This Lisp is called Valutron. It is architected as an integrated compiler-VM; essentially, this means that code, when entered at the REPL, is first converted into Cons trees, and then mapped down to primitive operations at the stage of evaluation. These primitive operations control a register VM, which operates on Cons cells and Objective-C objects representing Lisp values, and which is implemented as threaded code for maximum performance.

This form was chosen to make it possible to implement continuations easily and to promote good performance. At this point I have described how it implements a basic Scheme-esque Lisp. The VM, as I explained, operates natively on Cons cells. Implemented in Valutron itself are more extensible versions of some primitives like eval; these functions are registered with the VM and, from there on, replace the primitives with themselves.

Here is where Valutron offers a feature called V-expressions. V-expressions are an alternative to S-expression notation for code. They are low in the number of brackets characteristic of S-expressions, and are instead primarily algebraic-style infix. These are implemented by using reader macros. I am going to look into integrating a shift/reduce GLR parser that may have productions and rules dynamically altered at runtime, which will allow the extension and modification of V-expression syntax as well as even creating new DSLs with unique syntax.

The pièce de résistance is an object model inspired by the CL Object System, the first ever standardised object-oriented system, which was designed as part of Common Lisp. This is implemented in terms of the Objective-C runtime and hence the full dynamism of Smalltalk, Objective-C, and CLOS are available. The Objective-C runtime used was extended in order to support double dispatch, making available CLOS' characteristic multi-methods.
>>
I'm having difficulty wrapping my head around linked lists.
What is this example doing, and why is it assigning NULL to the first node's *next pointer?
node *curr, *head;
head = NULL;

int i;
for (i = 1; i <= 100000; i++)
{
curr = (node *) malloc(sizeof(node));
curr->data = i;
curr->next = head;
head = curr;
}
>>
>>51512915
>YaCC, Lex
For a lisp? Seriously?
>>
>>51512936
>casting from void*
>sizeof (node) instead of sizeof *curr

It creates 100k nodes in a linked list. It assigns null there because it's where the list ends.
>>
7th for C
>>
hey gais what language is smash bros coded in?
>>
>>51513049
SML
>>
>>51513049
nintendo SDKs use C/C++, and support was recently added for Unity3D
>>
>>51512936
imagine a chain. These nodes are all linked to create a chain. The last one in the list will be linking to nothing because it is the end of the list. When you make a doubly linked list it will link to the first element in the list.
>>
>>51513102
>support was recently added for Unity3D
fuck's sake
>>
>>51512993
I don't believe in writing my own parsing algorithms.
>>
>>51513138
why you mad?
>>
Working on an HTML 5 chatroom:
http://raskie.com:85
>>
>>51513174
Are you serious? Using lex and yacc for parsing sexpr or anything similar is inane. Literally kill yourself.
>>
>>51513119
well ok

how would I go about freeing that memory I allocated?
Do i just run through the loop again, copy the curr->next to a temporary pointer and then free that pointer?
>>
>>51513205
Why would I write my own parser when I can use Lex and YaCC to create one for me?

Anyway, it works. That's more than can be said for the one you suggest I write from scratch (what is code reuse and sensible library use?), because that one does nothing - it doesn't exist.
>>
File: image_71.jpg (92KB, 850x478px) Image search: [iqdb] [SauceNao] [Google]
image_71.jpg
92KB, 850x478px
I'm interested in learning some programming. What would be so good resources to learn from, IDE's to use, and which programming language would be easiest to get into?
Probably not gonna turn it into much just a new thing to learn how to do.
>>
>>51512936
This example is very misleading, because the first node created (which data is 1) will end up being the last element of the list.
Of course, the most efficient way of adding nodes in a linked list is adding it at the beginning, so you don't have to traverse the list to add the node. A good exercise here would be to rewrite that example by writing the function that takes an integer and a list and add a node containing the integer to the beginning of the list. It's not exactly how it happens it the loop of your example.
>>
>>51513231
Writing a "parser" for sexpr will probably take you less lines than lex/yacc.
I seriously can't believe why shitheads like this are allowed to exist, holy shit.
>>
>>51512898
Isn't this that one anime with sexy kids and traps?
>>
>>51513175
unity3d games look, run and play like shit. if there's anything nintendo has going for it it is quality and social (real-life social) games. unity3d is going to make nintendo games more like other console games except nintendo has much weaker hardware that isn't going to run well.
>>
>>51513272
Tbh, the Lex and Yacc versions are probably more readable. Also it's likely that it's faster than a hand-written parser would be.
>>
>>51513346
>unity3d games look, run and play like shit.
Who gives a shit as long as they're fun? KSP is made in unity. That justifies it in my book.
>>
>>51513385
>Who gives a shit as long as they're fun?
You're not going to have any fun with a game that runs terribly on the Wii U's already anemic hardware.
>>
int main() {
return (int) malloc(1000);
}


this triggers the autists who say pointers != ints
>>
Anyone knows where I could find a PDF on this Color Science: Concepts and Methods, Quantitative Data and Formulae ?

I'm desperate
>>
>>51513239
>What would be so good resources to learn from
http://greenteapress.com/thinkpython/ is my go-to introductory programming text. It's one of the few books that actually teach and explain the key challenges involved, rather than just mentioning them and hoping for the best. Also, it's free.

>IDE's to use
I strongly recommend you work without any until you are comfortable working with more barebones tools. Once you understand exactly what is going on when you develop things, then you can start using tools that automate parts of the process where you don't see it. When you start noticing tedious *but not challenging* aspects of your programming, then you can start exploring tools that lift some of that burden, but no earlier.

>and which programming language would be easiest to get into?
Python is generally hailed as friendly on beginners yet powerful for real-world projects. The book I recommend above uses it, and it's probably the best general-purpose language to start programming with in the absence of specific preferences.
>>
>>51513413
pointers arent ints
but sure you can cast them to ints if you like
>>
>>51513403
you could easily just optimise it to run fine on wii. Drop the polycount, effects etc.

Monument valley is another unity games. Looks amazing, and sports a flawlessly smooth framerate.
>>
>>51513413
Well, it doesn't necessarily fit in an int. But of course casting a pointer to an int is a valid operation, if somewhat of a meaningless one.
>>
>>51513413
You can cast to whatever you want, but why?
>>
Java vs C#? Which is better?
>>
>>51513512
C#
>>
>>51513413
this is cancerous.
>>
>>51513512
nether
>>
>>51513512
C# is a better language, but a terrible platform, which makes it useless.
>>
>>51513512
java
>>
>>51513534
i thought C# was available on linux with it being open source and everything
>>
>>51513534
>but a terrible platform
It's a great platform. What makes you think it's bad?
>>
>>51512936
Just for you: an expert programmer's interpretation of simple lists.

In this implementation, we use a dummy head node, meaning that we have a pointer called ``head'' which isn't used to store a value but instead just serves to remember where the beginning is.

#include <stdio.h> 
#include <stdlib.h>
#include <assert.h>

struct node {
int val;
struct node *next;
};

struct node *
new_node(void) {
struct node *n = malloc(sizeof(struct node));
n->val = 0;
n->next = NULL;
return n;
}

struct node *
make_node(int val) {
struct node *n = new_node();
n->val = val;
return n;
}

size_t
length(struct node *head) {
size_t len = 0;
for (struct node *cur = head->next; cur; cur = cur->next)
++len;
return len;
}

void
insert(struct node *head, int val, size_t index) {
assert(index <= length(head));

struct node *n = make_node(val);
struct node *cur = head;
for (size_t i = 0; i < index; ++i) {
cur = cur->next;
}
n->next = cur->next;
cur->next = n;
}

void
append(struct node *head, int val) {
insert(head, val, length(head));
}

void
prepend(struct node *head, int val) {
insert(head, val, 0);
}

void
print(struct node *head) {
printf("list of length %zu: ", length(head));
printf("[ ");
for (struct node *cur = head->next; cur; cur = cur->next) {
printf("%d", cur->val);
if (cur->next)
printf(", ");
}
printf(" ]\n");
}

int main(void) {
struct node *list = new_node();
for (size_t i = 0; i < 3; ++i)
append(list, i);
prepend(list, -1);
insert(list, 444, 3);
print(list);
return 0;
}
>>
>>51513426
thanks guy
>>
dude... *hits bong* ...monads... *exhales* ...lmao
>>
how do you reset a sprite color
>>
>>51513824
very careful
>>
>>51513706
Why do you post all your types on a separate line?
>>
>>51513706
>asserts
FOR WHAT REASON
>>
>>51513881
For the same reason any and all asserts are used, you dolt.

(Not that guy.)
>>
>>51513879
it's BSD coding style
The justification I've heard for it is that its really easy to find where you've defined a function by searching for ^function_name
>>
File: 50278999_p0.jpg (458KB, 600x800px) Image search: [iqdb] [SauceNao] [Google]
50278999_p0.jpg
458KB, 600x800px
Just a brief bit of noise here.

I'm using MSYS2 and can't seem to find any documentation about how make is able to interpret paths in a makefile. I'm trying to build a program that depends on zlib and can't figure out how to point to the "system installed" version. I copied its headers and referenced them as ./zlib/zlib.a etc, but know there's a better "right" way to do this.

How do I reference libraries and headers (in an MSYS environment)?
>>
>>51513912
The GNU style has the same characteristic.
>>
>>51513928
You specify the directories to search for headers by using -I switches when invoking the compiler. You specify the directories to search for libraries by using -L switches when invoking the linker.

For header paths, the specified directories shouldn't include any component which is part of the header name. E.g. if the OpenGL headers are /usr/local/include/GL/gl.h etc, you'd use -I/usr/local/include, because the header is named <GL/gl.h>.
>>
/g/ I need an advice

I have an opportunity to enroll in UC San Diego for computer science, but it seems their major is more Math centered

Like, it's more of a math major than computer science major, which is okay for me but...

How good is that for employers seeking a CS degree? Should I just enroll on a college that is more focused on computer science?
>>
>>51513879
Both what he said >>51513912 and that function definitions can get pretty wordy.

 
/* Newlines are misplaced here. */
const struct inode *security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{
...
}
/* better: */
const struct inode *
security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) {
...
}
>>
>>51514066
computer science is math, though
maths is a very good skill to have for jobs, too
>>
>>51514066
>wtf i just wanted to program video games
>>
>>51514030
I was looking at it, again, and finally stopped to see the obvious. The makefile was never trying to reference system libraries, it was expecting a local directory. So I guess what I had set up was what it was made for to begin with... Fixed it by pointing explicitly though.

Thanks.
>>
>>51513208
it wouldnt even be that complicated. Since the memory is a part of the heap and it is still just in ram you could just se. first and next to null. The other other allocations of memory are then freed and you would then just have to clear the objects. If your program was stringent on clearing out all memory you could have a clearing function that simply invoked the destructor for each object/node at the end of your reallocation phase. like garbage collection.
>>
>>51514066
>How good is that for employers seeking a CS degree?
It depends specifically on what you want to do. The qualifications associated with the term "CS" are almost meaningless now, as different places treat it as a code monkey degree or a mathematics degree or somewhere in between.
>>
>>51513208
void
free_nodes(struct node *head) {
struct node *cur = head;
while (cur) {
struct node *next = cur->next;
free(cur);
cur = next;
}
}
>>
>>51513480
Well, I can see a specific case where you don't want to do pointer arithmetic with this value, like peeking into memory with a byte granularity.
>>
>>51513272
The guy is already building his own lisp, he's too far gone from reality son, let it go.
>>
>>51514521
Then you cast to char* and back.

Pointers aren't as simple as linear addresses on all platforms, and if you aren't trying to support the most esoteric of hardware you shouldn't even bother with C. Pointer arithmetic will not always be equivalent to integer arithmetic.
>>
>>51514337
>>51514084
>>51514148
I don't mind math, I have high grades on all my math courses so I don't really care if it's math centered or not

If I'm looking to program artificial intelligence and specialize in that area, is that really the way to go? And if employers would want to see more Computer Science classes instead of more math classes, if you understand what I'm saying.

Would you do a math-centered CS course for AI /g/? Thanks for the replies btw
>>
>>51514568
>And if employers would want to see more Computer Science classes instead of more math classes, if you understand what I'm saying.
CS is applied math or just specialized math courses anyways unless you're at some shitty school that treats it solely as Oracle-certified Java training.
>>
What is an uniary minus in C++?

Seems like it just gives the variables vaule but negative. Like

int a = 7
cout << -a
{/code}

Would just print -7. Would that also change a in place to be -7? I dont understand why this is a thing,
>>
>>51514584
Oh okay
I'm sorry for being confused, here I heard each UC has a different focus of computer science courses, which made me wonder which one to go. I heard UC San Diego was more "math than CS" so I didn't really know what that meant

I might just go to San Diego I guess.
Thanks
>>
>>51514568
>If I'm looking to program artificial intelligence and specialize in that area, is that really the way to go?
Yes, absolutely. AI is *particularly* math-heavy; specifically, it is heavy in the fields of math typically studied in mathematics programs (linear algebra, probability theory, multivariate calculus, that sort of thing), as opposed to the mathematics specific to theoretical computer science like automata theory.

>And if employers would want to see more Computer Science classes instead of more math classes, if you understand what I'm saying.
Some do and some don't. Many employers just want more cheap code monkeys to abuse, and thus want CS programs to function as close as possible to trade schools. Others are indeed interested in employees that actually know the shit necessary to push the envelope, which is the kind of activity where you really do need all that CS background.
>>
>>51514625
-a
a.operator-()
normally returns decltype(a) and is const
>>
>>51514625
Yes, a minus gives the variable's value, but negative. If you weren't stupid that would be obvious.
>>
File: KRC.jpg (125KB, 300x377px) Image search: [iqdb] [SauceNao] [Google]
KRC.jpg
125KB, 300x377px
>>51512915
Lisp is a fucking horrible hipster langage. It has NOTHING that isn't in C. The same with Objective-C.

Pic related: it's what you morons need to read.
>>
>>51513879
not them but it helps to creafe coherency with other disciplinary imperatives. For example, writing. Like in writing, you generally elaborate over a series of sentences and then make a new line when an idea is complete.
"My class needs ints. An int for this, an an int for that, so on and so forth."
"Now, my class needs a pointer to manage those ints."
"Now I'll need a character array."

"Now that we have our variables, let's define a manner for those ints to be explicitly incorporated into our program.
Firstly, we need to describe the numeric operations to those ints. This can be described as such. Thus to be surmised as such.
Secondly, we must define a compositional adjunction for these operations in pairs. Adding one will increment. In contrast, subtracting one will decrement.
Next, we'll need a top down view of the operations. Let's take our pointer and ... ..."

"With our numbers in order we will now need to appropriate function to our character array.
First, we will need to allow for functorial insertion and extraction via the front or from any particular indexed point in the array.
Next, we will need to allow for a characterized/comparative search in our array, which used in conjunction with our primary index functions should allow for extraction.
Etc, etc."

It helps with organization. Just incase it helps, know that whitespace is completely ignored by the compjler. You could write

void fart
()

{ code code code
}

and the compiler would use it to define a function. Ultimately, there is a syntax that it seeks out so make sure not to split words with whitespace. Not that you would but we are on 4chan and the contrarian tumblrinas and keks happen by some times to fuck with the whole thing we have going here.
>>
File: CPP.jpg (57KB, 320x320px) Image search: [iqdb] [SauceNao] [Google]
CPP.jpg
57KB, 320x320px
>>51514705
C is a fucking horrible hipster language. It has NOTHING that isn't in C++. The same with Objective-C.

Pic related: it's what you morons need to read.
>>
Help me reverse a list /g/
rrev [] = []
rrev (x:xs) = rrev xs ++ x

*Main> rrev [1,2,3]
<interactive>:4:7:
No instance for (Num [a0]) arising from the literal `1'
Possible fix: add an instance declaration for (Num [a0])
In the expression: 1
In the first argument of `rrev', namely `[1, 2, 3]'
In the expression: rrev [1, 2, 3]
>>
How do I comprehend Java OOP?
>>
>>51514768
"x" is just a value, not a list. So you can't use "++" on it.
>>
>>51514763
Ill read this after programming principles and practice using c++
>>
>>51514768
[1,2,3].reverse()
>>
>>51514768
best lang coming through
le_list[::-1]
reversed(le_list)
>>
>>51514769
Do a lot of programming without it. Then you'll be able to know when certain things would have been useful.

It's better than learning it without any experience, then thinking that you have to apply it everywhere.
>>
>>51514769
the essence of objects
>>
File: D Lang.jpg (31KB, 383x499px) Image search: [iqdb] [SauceNao] [Google]
D Lang.jpg
31KB, 383x499px
>>51514763
C++ is a fucking horrible hipster language. It has NOTHING that isn't in D. The same with Objective-C.

Pic related: it's what you morons need to read.
>>
>>51514763
I don't think you understand.

C++ is another hipster language.Much like Lisp, another hipster language, it offers NOTHING over C. The same for Haskell, Java, Node.js, and all the other stupid shit.

Drop your C++, Haskell, Lisp, Java, and Ruby. Start using a real man's language. The hipster languages won't even exist soon. Like Fortran or Cobol they seemed cool for a while, maybe even 20 years if they were lucky, but they never lasted any longer before people realised that they offered nothing that you couldn't do even better in straight C.
>>
>>51514859
I don't think you understand.

C is another hipster language.Much like Lisp, another hipster language, it offers NOTHING over C++. The same for Haskell, Java, Node.js, and all the other stupid shit.

Drop your C, Haskell, Lisp, Java, and Ruby. Start using a real man's language. The hipster languages won't even exist soon. Like Fortran or Cobol they seemed cool for a while, maybe even 20 years if they were lucky, but they never lasted any longer before people realised that they offered nothing that you couldn't do even better in straight C++.
>>
>>51514851
What about that gc though?
>>
Does anybody have any experience using any APIs for parsing natural text / named entity recognition? Curious to hear what your experiences were. Seems like there are myriad tools out there.

what's the deal with nerds on this board saying that C > everything. There are factors other than "can i tell the computer to do anything it can do" that are attractive.
>>
>>51514859
I don't think you understand.

Some people here write actual software.
>>
>>51514912
Prolog
>>
>>51514908
extern C
>>
>>51514920
just looking for an existing API that I can use. I don't have time to try to make something myself. Probably going with GATE at the moment.
>>
>>51514798
That's what I was supposed to get from the error message? Jesus christ that's cryptic.
>>
>>51514925
That doesn't make any fucking sense at all.
>>
>>51514965
It always helps to provide an explicit type expression. When type inference is involved, error messages may not make sense.
>>
>>51514991
ignore him
core.stdc.stdlib.malloc
core.stdc.stdlib.free
>>
>>51515006
Yeah but the whole library uses the GC. Doing things from scratch in D would still be better than C (what isn't) but you lose so much.
>>
>>51514965
>>51515004
*type declaration. But you get the point.
>>
>>51512898
>tfw programming assignment that I have no idea how to do is due in a few hours
>Its easy guise, just create a data structure for this problem youve never encountered in java which is a language youve never used before.
Just gonna take the L on this one.
>>
>>51515051
extern (C++)
>>
I wrote a function in bash that traps itself on SIGWINCH. Is that a bad idea?

my_function(){
trap 'my_function' SIGWINCH

if [ some_stuff == whatever ]; then
# do stuff
else
trap - SIGWINCH
fi
}
>>
>>51515099
extern (Haskell)
>>
>>51515051
>>51515099
>>51515108

scratch all that

@nogc
function attribute

D is working on making the whole std lib (phobos) @nogc compliant

rip other languages
>>
>>51515133
you'd still need to malloc though
or write code to malloc for you, it is D after all
>>
>>51515151
holy shit that get
>D officially best language
>>
>>51515151
D has destructors unlike C, so you can write data structures once and not end up spending all your mental energy trying not to create memory leaks.
>>
File: logo-sun.jpg (20KB, 360x193px) Image search: [iqdb] [SauceNao] [Google]
logo-sun.jpg
20KB, 360x193px
>>51515173
Innovation!
>>
c# newbie here, how do i properly do exception handling for StreamReaders?

        StreamReader reader;

try {
reader = new StreamReader(path);
}
catch (Exception e) {
//log error, throw popup, etc
}
finally {
reader.Close();
}


If i do the above then reader.Close() complains that it's an unassigned variable.
If i put the declaration inside try, then reader doesn't exist in the finally block at all.
If i put the initialization before try, i can get unhandled exceptions from the constructor.

What the fuck to do?
>>
>>51515208
The exception would get thrown inside the constructor, before the variable is assigned.
>>
File: 1448346356458.jpg (674KB, 2000x1516px) Image search: [iqdb] [SauceNao] [Google]
1448346356458.jpg
674KB, 2000x1516px
D! D! D!
>>
Processingfag from yesterday, I need help
Entity swimmer;
void setup()
{
size(600, 600);
swimmer = new Entity(100, 100);
}

void draw()
{
background(50, 50, 255);
swimmer.move();
swimmer.display();
}

class Entity
{
int posX; //starting horiz. position
int posY; //starting vert. position
float speedX; //horizontal speed
}

void Entity(int startX, int startY)
{
posX = startX;
posY = startY;
speedX = 25;
}
void move()
{
if (keyPressed)
{
if (key == "LEFT")
{
posX -= speedX;
}
if (key == "RIGHT")
{
posX += speedX;
}
}
}


//display
void display()
{
fill(255);
rectMode(CENTER);
rect(posX, posY, 20, 20);

}

It's giving me an error whenever I attempt to compile it. Help.
>>
>>51515208
>>51515219
Oh, and what that means is that while you can't call Close(), you don't have to.
>>
>>51515232
someone already told you what to do
class Entity
{
int posX;
// etc
} <- move this to the bottom, after all the other junk
>>
>>51515221
desu the parameter stuff (ref/inout/scope/etc) is nonsense
>>
>>51515249
So I'm suppose to split initialization and reading into two try/catch blocks? It seems like the only reasonable way to do it...

        StreamReader reader;

try {
reader = new StreamReader(path);
}
catch (Exception e) {
// log/display file error
return;
}

try {
// read
}
catch {
// log/display reading error
}
finally {
reader.Close();
}


Right?
>>
>>51515232
Your class needs to contain the methods you're trying to give it
class Cheese{
int etc;
int et2;
void Cut()
{
//etc
}
void Slice()
{
//etc
}
}
>>
File: gay_lambda.gif (8KB, 648x432px) Image search: [iqdb] [SauceNao] [Google]
gay_lambda.gif
8KB, 648x432px
>>51514705
This guy is true. Fuck your Lisp, >51512915. You functional faggots are the cancer that is destroying programming.

Pic related: Lambda means gay.
>>
i just got a job offer for a C# shop that pays 6 figures

i've only done ruby, php, perl professionally and i've messed around with c, c++.. but it's always been in linux

i pretty much have to accept because of the money.. but how bad is it going to be f a m i l y ?
>>
>>51515297
Can confirm, Lambda is Greek, so it either means gay or debt
>>
>>51515298
Pretty bad, champ
>>
>>51515297
>doesn't like dick in ass
what are you, gay?
>>
>>51515297
functional is the future of programming : ^ )
>>
>>51515283
You can clean it up quite a bit with "using". Even if an exception is thrown inside, the Dispose method (which for a StreamReader is the same as Close) gets called.
try {
using(StreamReader reader = new StreamReader(path)) {
// use it
}
} catch(Exception e) {
// log
}
>>
>>51513512

Depends on where you want to work.
>>
File: golden_ratio.gif (16KB, 649x512px) Image search: [iqdb] [SauceNao] [Google]
golden_ratio.gif
16KB, 649x512px
/dpt/, do you believe?
>>
>>51515381
what does that even mean.
>>
>>51515429
your love is truuuuu~~
>>
>>51513706
>Just for you: an expert programmer's interpretation of simple lists.
just fuck off
>>
>>51515297
Functional programming is Cultural Marxism applied to programming.
>>
If you use one of the following languages: C++, Ruby, Lisp, Objective-C, Haskell, Rust, PHP, Visual Basic, C#, Scheme, Node.js, Python, Julia, Pyston, Nimrod, D, or (WORST OF ALL) Google Golang: You use a fucking horrible hipster langage. It has NOTHING that isn't in C, one of few languages to have survived for more than 25 years. All of the languages I listed above will be dead, or almost dead, within 25 years of their creation.

Pick up a copy of Kernighan and Ritchie's The C Programming Language. Written in 1973, it will teach you how to program for real, and make compiled programs. Not to talk a pile of trash into a hipster interpreter.
>>
>>51513706
Where are the frees?
Please tell me you're not actually wasting memory like this.
>>
>>51515514
>It has NOTHING that isn't in C
ITT: Anon rediscovers the Turing machine
>>
>>51513413
I'm more triggered at the lack of indentation.
>>
>>51513512
C.
>>
On the tenth page of my language specification. Finally finished the section about the core syntax, now I'm writing up about its module system. I've already come up with a few ideas that I really like and will definitely keep in the final language.
>>
>>51515514
Sorry C-uck, I have real software to write and can't waste time rewriting data structures and string libraries.
>>
>>51515573
What's your language like lad?
>>
File: qwer2.jpg (776KB, 1199x7206px) Image search: [iqdb] [SauceNao] [Google]
qwer2.jpg
776KB, 1199x7206px
If you use any of these languages, you're a shit programmer.
>>
>>51515585
It's kind of meant to be a successor to MLs (specifically OCaml) so the syntax is very similar to SML, OCaml, etc. It also gets a few features out of Haskell (type classes, etc.) but it isn't that similar to it. The main features are:
>dependent typing
>powerful modules
>good metaprogramming
>>
can someone explain to me what a hashset is and how its not just a set. Ive heard its a common question during an interview.
>>
>>51515614
>Terra not listed
Phew, dodged a bullet. I can continue to enjoy my multi-stage programming in peace. Won't you join me?

http://terralang.org/
>>
>>51515620
>dependent typing
Copycat.

I kid. Personally, I prefer Haskell syntax to ML syntax but ML modules are quite nice.

>>51515632
A hash set is an implementation of the set ADT. It uses a hash table as the method of determining whether a given element is already contained.
>>
>>51515614
Good thing I use ISPC.

Take note of the power of SIMD C-ucks.
>>
>>51515614
>not using C+=
>not conforming with the CoC
>>
>>51515632
hashsets are O(1). sets are something else.
hashsets are implemented using a hashtable.
>>
>>51515285
>>51515263
Fuck, disregard.
But yeah, now I'm getting a NullPointerException error whenever it tries to call move() and display()
>>
>>51515523
Serializing a list doesn't hold all unused objects in memory and with enough breakpoints in the code you can make sure only the used memory gets handled over.

Unless you're working on AI, and a rigorous one at that, you don't really need to kill yourself over a few 4kb class declarations. It's one thing to code well and it's another thing to write programs.
>>
>>51515650
Terra has to be the biggest fuck up I've ever seen.

All that work and you still just use malloc and free for memory.

What a waste.
>>
>>51515679
What would you prefer?
>>
>>51515666
> Unless you're working on AI, and a rigorous one at that,

I'm not surprised people don't know what the fuck they are talking about.

I'm surprised when they don't realize they do.
>>
>>51515665
Disregard that, too. Left out a line of code.
Now I just need to get it to move properly since it won't budge
>>
>>51515691
destructors and move semantics
>>
>>51515651
Yeah, I get it. There are some things I really like in Haskell, but I can't really get behind a lot of the syntax. I'm trying my best to get away from the disgusting/awkward parts of the ML syntax but it is pretty difficult.

Anyways, yours will probably be better because there's no way this type system will be at all sane~
>>
>>51515665
move() and display() are functions native to Processing. You might want to keep those out of the class declaration. Don't forget to update the move() function to change the positions from within the Swimmer entity rather than as global variables.

move()
{
swimmer.posx += 25
}

instead of

move()
{
posx += 25
}

kind of thing
>>
>>51515666
those 4kb add up, especially if that wasteful function is called hundreds of times a minute.
>>
>>51515710
What?
>>
>>51515762
But it won't work outside of the class declaration. Unless I've come to a terrible misunderstanding and I need to re-evaluate my life choices. Which I do
>>
>>51515876
Why not try one of those youtube Processing tutorials? I remember watching one and thinking it was simple enough. I'd help you out a bit more but I'm on what amounts to a 56k modem right now.
>>
bool f(){
bool x=true;
if (x==true){
return true;
}
else{
return false;
}
}

Guess how often I see this as a TA.
also how do you make blocks of code.
>>
>>51515971
{code}
code here
{/code}
with square brackets
>>
>>51515728
>d*structors and m*ve
k-kuffar! get out!!
>>
hello dpt
anyone still awake?
>>
>>51516005
bool f(){
bool x=true;
if (x==true){
return true;
}
else{
return false;
}
}
>>
>>51515876


int rectWidth;

void setup() {
size(640, 360);
noStroke();
background(0);
rectWidth = width/4;
}

void draw() {
// keep draw() here to continue looping while waiting for keys
}

void keyPressed() {
int keyIndex = -1;
if (key >= 'A' && key <= 'Z') {
keyIndex = key - 'A';
} else if (key >= 'a' && key <= 'z') {
keyIndex = key - 'a';
}
if (keyIndex == -1) {
// If it's not a letter key, clear the screen
background(0);
} else {
// It's a letter key, fill a rectangle
fill(millis() % 255);
float x = map(keyIndex, 0, 25, 0, width - rectWidth);
rect(x, 0, rectWidth, height);
}
}


Hey, if this code is telling of the functionality then that means your move function shouldn't have keyPressed as a condition and that instead you should create a keyPressed() function and write your code in there.
>>
>>51516061
>>51515971
yeah, the indentation is horrible
>>
>>51516061
dude use some indentation
christ
>>
how do i make video game
>>
>>51516108
Game game = new Game("3D");
game.addBadGuys();
game.makeExplosionsLookReallyCool();
game.enableSecretFinalBoss();
game.setYouCanDoAnything(true);
game.start();
>>
>>51516139
you forgot
game.addLensFlare();
>>
i dont feel well dpt
hold me
>>
>>51516207
*holds*


I bet what I just did is against the CoC though, sorry if it triggered you
>>
File: 1390637423220.gif (320KB, 500x373px) Image search: [iqdb] [SauceNao] [Google]
1390637423220.gif
320KB, 500x373px
In MATLAB in particular, I have a vector that is going to change a LOT. (Basically going to record inputs from a user in a vector)

Would it be faster to make a fuckhuge vector and then trim off the zeros, or just concatenate the old vector + new input everytime? I know its faster to preallocate the vector rather than extending it every iteration, but I'm wondering if that rings true for cat(1, a, b) as well.
>>
File: yh9zw.png (69KB, 750x453px) Image search: [iqdb] [SauceNao] [Google]
yh9zw.png
69KB, 750x453px
>>51516253
ah, yes
but - I guess you consented!
>>
That got morbid pretty quick
>>
>>51513119
that's a circular linked list, dumbass
>>
File: possibly cheating..png (37KB, 584x613px) Image search: [iqdb] [SauceNao] [Google]
possibly cheating..png
37KB, 584x613px
>not using your own code to read dpt
>not using your own code to use someone else's code to read dpt
>>
>>51516287
problems like this are the most interesting, imo
>>51516274
>Would it be faster
if only there was a standard way to test the speed of things
if only there was a way to get the time, run the two differing codes, then compare their execution speed
we'll have to wait for the 22nd century, I guess
>>
>>51516316
Does D come with a JSON library?
>>
>>51516332
import std.json;
auto x = parseJSON(string);
x["key"]...
>>
>>51516355
Nifty
>>
File: SCAN0083.jpg (692KB, 1853x1285px) Image search: [iqdb] [SauceNao] [Google]
SCAN0083.jpg
692KB, 1853x1285px
>>51516070
I should probably post my assignment page
>>
>>51516253
Nevermind I'm good now.
I did a ton of blow but I evened it out with some beers.
>>
>>51516359
better edition:

get("https://a.4cdn.org/" ~ board ~ "/thread/" ~ thread ~ ".json")
.parseJSON
["posts"]
.array
.each!((JSONValue str) => str["com"].writeln);
>>
wasm when
>>
>>51516413
last x posts:
.array
[$-x..$]

fuck I love D
>>
>>51515876
Hey guy, try this code out. My Processing is still downloading but here's some code that should work if the examples themselves aren't fucked.

class Entity
{
int posX, posY, speed;
Entity()
{
posX = 0; //starting horiz. position
posY = 0; //starting vert. position
speed = 25; //horizontal speed
}
Entity(int startX, int startY)
{
posX = startX;
posY = startY;
speed = 25;
}

}


void setup()
{
size(600, 600);
noStroke();
background(50, 50, 255);
Entity swimmer = new Entity();
}

void draw()
{
if (keyPressed)
{
fill( 50, 50, 255 );
rect( swimmer.posX, swimmer.posY, 50, 50 );
if (key == UP)
{
swimmer.posY += speed;
}
if (key == DOWN)
{
swimmer.posY -= speed;
}
if (key == LEFT)
{
swimmer.posX -= speed;
}
if (key == RIGHT)
{
swimmer.posX += speed;
}

}
fill( 255 );
rect(swimmer.posX, swimmer.posY, 50, 50);
}


I didn't use the second constructor but it should still work.
>>
>>51516413
why does C# syntax have to be so bloated
new HttpClient().GetStringAsync("https://a.4cdn.org/" + board + "/thread/" + thread + ".json")
.ContinueWith(x => (JsonConvert.DeserializeObject(x.Result) as JObject)
["posts"]
.ToList()
.ForEach(post => Console.WriteLine(post["com"]))
).Wait();
>>
>>51516321
Hmm. Okay. I guess I probably should have thought of that but at the time it wasn't something that donned on me.

It's definitely quicker to preallocate and delete the unused terms than it is to just increase the vector size. For my purposes, it probably isn't all that big of a deal but it's nice to know into the future.

Cheers anon
>>
>>51515576
You're right you can't write a library once and use it multiple times in C or even download libraries. Shit is legitimately impossible
>>
>>51516454
Same
I haven't gotten too deep into it, but I'm liking what I've seen so far.
>>51516506
wew
>>
>>51516507
in the general case
whenever you're unsure about performance...benchmark the fuck out of it.
make an objective decision yourself instead of relying on what others say
>>
>>51516294
Oh yeah, my mistake.

It's circular. In a doubly linked list each node has a reference to a before and next node. A circular doubly linked list has a reference to the front from the back and each node in it has a reference to the next and before nodes.

Sorry about thanks.

Thanks for the correction, anon!
>>
>>51512915
>>51514705
MEMORY
O
D
E
L
>>
Null terminated byte arrays
Significant whitespace
cin/cout
>>
File: 194.png (36KB, 400x259px) Image search: [iqdb] [SauceNao] [Google]
194.png
36KB, 400x259px
Hey /dpt/ I have a noob python question

I have an arbitrarily-sized list of bins -- [0, 2.5, 10, 11, 20]. The "size" of the bin can change from number to number as well, no pattern to it.

If I have a number, how can I determine which range-based bin that number belongs to? I.e. if I have int 1, it will show it belongs to the (0, 2.5) bin. If I have 5, it'll show itself as belonging to (2.5, 10), etc

Also, how can I return the bin's index?

Is there a faster way to do this than the naive comparison-based method? I'd rather not use numpy.
>>
File: 1383399938741.png (84KB, 629x350px) Image search: [iqdb] [SauceNao] [Google]
1383399938741.png
84KB, 629x350px
>>51516501
It's not working, but I might have pasted it wrong.
Actually, if you wouldn't mind, can you maybe shoot me a Skype request? It'd make shit a ton easier.
ID: screwattacked
>>
I have 12 hours to learn Erlang. Where should I start?
>>
File: 1439590011623.jpg (259KB, 1000x1502px) Image search: [iqdb] [SauceNao] [Google]
1439590011623.jpg
259KB, 1000x1502px
>>51516599
Here.
>>
>>51516584
as the list is sorted, the answer wants you to use a binary search. look that up.
>>
File: d2.png (40KB, 1179x517px) Image search: [iqdb] [SauceNao] [Google]
d2.png
40KB, 1179x517px
>>51516506
now do this
>>
>>51516584
index = None
for i in range(len(bins) - 1):
if i >= bins[i] && i < bins[i + 1]:
index = i


You can then use the index (of the bin's lower bound) to get the bounds of the bin.
>>
>>51516506
And people say monads are just a meme.
>>
Unix question here

Reading up on chmod documentation (yes i'm that new)

I understand that chmod u+s sets a file to run with it's owners permissions, but my confusion is to why it's u+s not o+s.

i would've thought that if i run a file i don't own, i would fall under Other permissions, not user permissions. What am i missing?
>>
>>51516584
if i understand you correctly, do you mean something *conceptually* like this?
bins=[0,2.5,10,11,20]
binning=lambda n:list((n[i],n[i+1]) for i in range(len(n)-1))
def findBin(i,n):
for l in range(len(n)):
if i>=n[l][0] and i<n[l][1]:
return l

print(findBin(4,binning(bins))) # should put it in bins[1], so this returns 1


I'm trying to think of the smarter intuition behind this that avoids a lot of this stupid for loop crap, but it's escaping me at the moment. I have a headache and it's been a long day.
>>
If you don't know morse code then you literally have no right to call yourself a programmer.
>>
>>51516657
filter your html encodings faggot
>>
>>51516721
nty
>>
File: 9e7yk.png (52KB, 939x393px) Image search: [iqdb] [SauceNao] [Google]
9e7yk.png
52KB, 939x393px
>>51516657
why do you use two regexs
the second contains the first
just for good measure, I included it anyway
>>51516721
as you wish
>>51516686
uh, what? there were no monads used in mine or the other guy's code
>>
>>51516741
>why do you use two regexs
oh, you replaced with new line
didn't see that. oh well.
regex is hardly needed for that, though. string replacement would be much faster.
>>
>>51516741
Nope, it's definitely a monad. ContinueWith is bind, and Wait is sort of like the monad's "run" operation.

https://ruudvanasseldonk.com/2013/05/01/the-task-monad-in-csharp
>>
just parse the page with html.
regex.
simple
  o  o
\____/
>>
>>51516701
never mind i'm a dumbass.
>>
>>51516769
oh, I guess in that way.
ContinueWith isn't used much anyhow, as C# has 'await'.
that link looks to be implementing something similar to javascript's Promises, though
>>
>>51515514
Python's 25th anniversary is in February next year, only a few months away. C++, Scheme, Lisp, Haskell, and Objective-C have already been around for over 25 years. VB is also almost 25 years old, I think.
>>
open ModularSelectors

module Selection =
getOS >>= \os ->
getArch >>= \arch ->
select[operating_sytem = os, architecture = arch]
open MyModule Selection

r8
>>
I'm thinking of remaking a minimalist version of Zork, but as a Bash script. Thoughts on who would want to see this or whether there's something stopping me from doing it?

Doing it cause I'm bored and like to code, no other real reasons or goals.
>>
>>51513757
Personally I would learn C++/Java/Python. Those are typically the 3 languages that most big name companies want you to be proficient in starting. There are exceptions, like I think Apple uses mostly C, but anyway, if you learn one of those, then learning new languages is generally easy.
>>
File: 1440203491333.jpg (40KB, 600x450px) Image search: [iqdb] [SauceNao] [Google]
1440203491333.jpg
40KB, 600x450px
>be imperative programmer
>always make fun of anons on /g/ for functional programming, muh monads, muh currying, muh endofunctors, etc
>taking compsci final exam
>question 3
>"Show how the curried function definition mult x y z = x ∗ y ∗ z can be understood in terms of lambda expressions."
>mfw I should have studied haskell
>>
>>51516880
Honestly I would use Python. It seems simple enough to do in bash, but I think it falls more in the domain of Perl/Python/Ruby than in shell scripting.
>>
>>51516907
Functional programming is fundamentally ingrained into computer science. Things like computability theory and type theory would be nonsensical if the models had side effects and weren't pure like lambda calculi.
>>
>>51516316
Okay, this might be a really really dumb question but, why are your imports in your main?
>>
>>51516605
What anime specifically? I didn't know they had an anime on Erlang.
>>
>>51516940
>I'm wondering if there's anything faster
Are you having performance problems that you can pin on this bit of code?
>>
File: 1416064879504.jpg (90KB, 797x810px) Image search: [iqdb] [SauceNao] [Google]
1416064879504.jpg
90KB, 797x810px
>>51516707
>>51516674
These two work but I'm wondering if there's anything faster, might have to implement binary search like >>51516623 mentioned or use bisect.bisect in some way

thanks btw
>>
>>51513512
java
>>
>>51516907
If you are studying computer science and refusing to learn about functional programming, you're an idiot. The imperative and functional perspectives have been around since the formalization of computer science, with Turning's Turing Machines and Church's Lambda Calculus. You should really take the time to understand both. If you don't, you'll be a worse programmer, and a worthless computer scientist.
>>
>>51516969
What do you like about Java over C#?
>>
>>51516953
>>51516964
Yep, just using %timeit in ipython and the runtime seems to blow up for large amounts of numbers to be binned or large amounts of bins.

That's for my implementation, though and >>51516707
might be quite a bit faster, gonna check right now.
>>
Would you rather be prone to premature optimization, or premature ejaculation?
>>
>>51517015
According to most people, I already prematurely optimize (plus I have good stamina in bed) so I'll stick with what I've got.
>>
File: d3.png (55KB, 1034x716px) Image search: [iqdb] [SauceNao] [Google]
d3.png
55KB, 1034x716px
now it uses a higher order function

>>51516944
So they stay in my main
>>
>>51516940
Ah, just remembered it; your mention of bisect gave it to me. Given that you have the bins list in order (or if not, that you can sort them quickly enough with built in methods), I would suggest bisect_left.

from bisect import bisect_left
bins=[0,2.5,10,11,20]
brrr=lambda bins,n:bisect_left(bins, n)-1
print(brrr(bins,4))
>>
>>51516952
I have no idea.
I've watched one anime in my life and that was Black Lagoon or something, because a friend pretty much forced me.
If you consider stuff like pokemon and dragon ball Z an anime I guess that too, but that was when I was in elementary school, so I just consider them "cartoons that were on TV".

I don't really watch cartoons as an adult. Maybe stuff like Rick and Morty, American Dad, or mostly the Simpsons because I grew up with the Simpsons as well, but that's about it.

I was just making playful banter on how you should off yourself for a language I actually know nothing about.
>>
>>51517049
You do realize that the get() call is a monstrosity right?
>>
>>51517065
By the way, this is the most honest post you'll ever get from me. I'm drunk and I need to be up in less than 6 hours for work, yet the cocaine is saying "you should finish this rock!". So, good night, I'm going to force myself into bed.
>>
>>51517071
you're right
i've converted it to

("https://a.4cdn.org/" ~ board ~ "/thread/" ~ thread ~ ".json").
get

thank you for pointing out this failure
>>
So lua has this thing called the registry, not sure what it entirely does. But I see it has the code:

/* variable with an unique address */
static const char Key = 'k';

/* store a number */
lua_pushlightuserdata(L, (void *)&Key); /* push address */
lua_pushnumber(L, myNumber); /* push value */
/* registry[&Key] = myNumber */
lua_settable(L, LUA_REGISTRYINDEX);

/* retrieve a number */
lua_pushlightuserdata(L, (void *)&Key); /* push address */
lua_gettable(L, LUA_REGISTRYINDEX); /* retrieve value */
myNumber = lua_tonumber(L, -1); /* convert to number */


I think I get what this is saying, I might not, so I would like to get a better understanding.

So can push a string (does it have to be a string) onto a table, and have it equal to something (such as a number, can it only equal a number/string?)

Is this something that might work with an entity component system? Is this similar to metatables? Do you need both to coexist? Is one better than the other or are they too different to say?
>>
how does setf in common lisp work?
like why does set-x/y-velocity work but not reset-velocity?
(defmethod set-x-velocity ((me moveable-entity) xvel∆)
(setf (slot-value me 'xvel) (+ (slot-value me 'xvel) xvel∆))
me)

(defmethod set-y-velocity ((me moveable-entity) yvel∆)
(setf (slot-value me 'yvel) (+ (slot-value me 'yvel) yvel∆))
me)

(defmethod reset-velocity ((me moveable-entity))
(set-y-velocity me 0)
(set-x-velocity me 0)
me)
>>
File: d4.png (30KB, 662x681px) Image search: [iqdb] [SauceNao] [Google]
d4.png
30KB, 662x681px
>>51517049
>>
>>51517224
it's the most beautiful code i've ever written
it's mostly just calling someone else's code
>>
>>51517174
Well, you're persistent, I'll give you that.

The reason I told you about the registry is because it's a way to associate Lua values (functions) with C values. That way, you're able to give different objects different Lua functions to call for updating/drawing/whatever.

Integrating this with components is something else entirely, and it might not even be very useful. Typically, an ECS gives you enough flexibility that you don't need to also use scripting at that level.

Metatables aren't really useful for this, but it would be quite useful to have some sort of class system on the C side so that you can share the same Lua functions between many objects.
>>
>>51517224
It's cute how codemonkeys write glue code for other people's libraries and think they actually made something.
>>
>>51516599
learn Go instead, 12 hours is more than enough for the basics
tour.golang.org
>>
>>51517298
>he didn't write his own regex library
>he didn't write his own web fetching library
>he used language features
haters gonna hate
>>
>>51517298
Libraries are there to be used, anon.
>>
>>51517322
Importing a library is not a language feature.
It's using other people's code.

>>51517339

It's unavoidable if you want to do anything productive, but if literally all your code is just calling other people's functions, you're a codemonkey.
>>
>>51517342
>implying i would want to work as a programmer
>>
>>51517287
so in C I would need a struct with an array, and I would need a way to send information from that specific struct to lua and back?
>>
>>51512915
github link?
>>
>>51517349
I don't know what that has to do with anything.

You can just use the registry to have each object associated with a Lua table created by a constructor (also a Lua function) or something which gets passed into the update/draw functions.
>>
C is a good first language because it pretty much forces you to implement your own libraries before you can do anything useful.
>>
>>51517369
>C
>forces you to implement your own libraries
meme tier joke
>>
>>51517369
That's a reason why C is a bad first language (and isn't true regardless). You don't want new programmers to get discouraged because every task seems unapproachably complicated, and you don't want them to learn a terrible NIH mindset.

C is a good first language because it forces you to build a mental model for your code that is similar to what actually happens on a real machine. This mental model is invaluable for really understanding programming, and is the kind of thing that you might not pick up from, say, Python.
>>
>>51517409
>C is a good first language because it forces you to build a mental model for your code that is similar to what actually happens on a real machine.
This. Also, being forced to write every free() or at least call every "destructor" shows you exactly what garbage collectors have to do for you behind your back. This applies also to things like non-trivial copies, virtual function calls, etc.
>>
>>51517409
>what actually happens on a real machine
Types don't real
>>
>>51517442
>what are special-purpose registers
>>
>>51517442
C's types are really just there as a convenient way to talk about sizes and offsets. They're not for safety.
>>
>>51517449
>special purpose registers are strongly typed
>>
>>51517473
no
>>
>>51517442
Sure, buy they're a useful abstraction. I said "similar" not "1:1 with physical reality".
>>
>>51517361
i'm a little lost now

i've got notepad open, and I put together something that might or might not be in the right direction:

typedef struct
{
boolean used;
int startX;
int startY;
char *name;
} EntityStruct;

EntityStruct ENT[768];

//entity created by using one that isn't used; giving it a starting x and y coordinate, and the name of the object.
//example: ENT[0].name is "player"

void UpdateEntity (int ID, double timestep)
{
//assuming this is correct
lua_pushlightuserdata( LS, (void*)&ENT[ID].name );
lua_pushnumber( LS, ID );
lua_pushnumber( LS, timestep );
//grabbing the function
//running it
}

void DrawEntity (int ID, double interpolation)
{

}
>>
>>51517487
They can't be for safety. The language is extremely weakly-typed; it's easy to do things like reinterpret data with unions or cast pointers. In fact, it's often required that you do stuff like that, like passing captured values using void pointers into callbacks to create closure.
>>
>>51517535
>C's types are really just there as a convenient way to talk about sizes and offsets.
no.
>>
>>51517554
Care to substantiate that?
>>
>>51517518
All I mean is that the Lua side is only concerned with the logic itself, and the C side does all the bookkeeping including looping through all the objects and calling the appropriate Lua functions (hooks).

So Lua would have a constructor to create a table for the object, an update function that takes that table and delta time and updates the table, and a draw function that takes the table and outputs some kind of draw call or whatever, the specifics don't matter.

The C side doesn't care about what the objects are doing, it just stores references to each Lua function and object table and brings them up at the appropriate times when going through all the objects.
>>
>>51517561
int
bool
float
pointers
>>
>>51517409
>C is a awful first language because it forces you to master techniques before you even understand the underlying principles involved.*
ftfy anon.
>>
>>51513272
>you should reinvent the wheel/roll your own code and waste time on a possibly less efficient end result when a perfectly good solution programed by people who know what they're doing already exists

Literally stop programming and commit seppuku
>>
>>51517608
I'm not sure what you mean by that.

I was trying to say that C forces you to learn the underlying principles involved in code before you can "master" much of anything. If you haven't learned those principles, you'll never move beyond toy programs in C (or you'll be doing a shitton of debugging).
>>
>>51517605
Sizes. And I guess picking the right instructions, e.g. integer add instead of floating-point add, etc.

You could have said there was more to it rather than just acting like I was completely wrong in typical 4chan fashion.
>>
What's the best programming language?
>>
>>51517656
C
>>
>>51517637
>I'm not sure what you mean by that.
Ask any freshman about working with strings in C++ vs doing the same in C, and I think you'll start to understand anon.
>>
>>51517605
>>51517643
To expand upon what other anon is trying to say: if you replaced every type in C with an array of bytes of equal length, and you could call all the intrinsics as functions rather than special operators on specific types, you wouldn't really lose anything.
>>
>>51517643
types don't real
>>
>>51517584
Well I gotta get going. I've been programming for years in C and C#, and i've known lua just as long, but none of this makes sense to me as I don't see the code for how it's done (or something similar). I just gotta think about it for awhile.
>>
>>51517409
>This mental model is invaluable for really understanding programming
programming is not even about computers.
>>
>>51517672
you wouldn't be programming in C, you'd be programming in a lower level language

and all the pesky C complaints would apply to C
>>
>>51517677
>I just gotta think about it for awhile.
Please do. I feel like you're just trying to throw your problem at somebody else instead of figuring it out for yourself and then giving up when you don't get an answer, because you haven't progressed in days. I can't read your mind, so I'm never going to be able to tell you exactly what you are looking for.
>>
>>51517673
That's what I'm saying. C's types are not really types in the mathematical sense, they're shorthand for various sizes, offsets, and sets of instructions.
>>
>>51517661
Oh, sure, that's true. C strings are a terrible mistake that have probably led to millions or billions of dollars being lost, and working with them is a pain in the ass.

I think C is a "good" first language, mainly for the reason I specified. It isn't an "ideal" first language.
>>
File: mt-stupid.png (43KB, 613x481px) Image search: [iqdb] [SauceNao] [Google]
mt-stupid.png
43KB, 613x481px
>>51517680
Computer science is not programming. Stop parroting (incorrectly, for that matter) things you hear on /g/ to sound profound.
>>
>>51514859
Honestly templates alone add so much to C++ that I'd rather use C++ over C for that alone
>>
>>51517705
C is too abstract to raise complaints at other languages

>no performance gain over C++
>>
>>51514859
>C++ is another hipster language
. . .
>HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA HA

lolwut nigger? C++ is older than you are.
>>
>>51517723
you should try D
you might have to make a new and delete function first so you don't have to worry about the gc or the different syntax
>>
>>51517732
What's your point? They're the same way in C++, although C++ honorably makes more of an effort to stop you from doing things that make them seem less like mathematical types.
>>
>>51517720
>Computer science is not programming.
k tard.
http://plato.stanford.edu/entries/computer-science/#Pro
>>
>>51517744
C is inferior to C++
The majority of C syntax is valid C++

C++ has costless extra features
>>
>>51517765
Preaching to the choir, mate. You're the one who brought up C++ in the first place.
>>
Huh. Lisp came before C. Didn't know that.
>>
>>51517786
That explains why C is better than lisp
>>
>>51517757
C is "close to the metal" so it forces you to think about and learn how most computers generally work.
AND
Programming is categorically about computers.
YET
Computer science is not programming.
BUT
Computer science is not necessarily about computers.

Capiche?
>>
>>51512898
I just finished writing an IRC drug game bot. Buy and sell different drugs. Just did it because I wanted to learn shelves in python. Bot is pretty fun too.
>>
>>51517803
*Computer science is not just about programming.
>>
>>51517803
C isn't very close to the metal
>>
>>51517821
Of languages that almost anyone uses, it is.
>>
import System.Random
import Data.List

main :: IO ()
main = do
randomGen <- newStdGen
let memes = randomRs ('a', 'z') randomGen
print (isInfixOf "topkek" memes) --True
>>
this is so nerdish
>>
>>51517858
This is so computers.
>>
ugly nerds
>>
>>51517858
That's so Raven
>>
>>51517803
programs must be written for people to read, and only incidentally for machines to execute. C is a horrible language due to the constraints imposed by the extreme hardwares limitations of the time (C was made to program UNIX, an os targeting the shittiest computer of the era (PDP)), C is especially bad for studying/building the most important concept of computer science and programming: Abstraction. This is 2015, no one should learn programming through C anymore, let the monster die in peace.
>>
>>51517858
heh did you expect something else friend?
also
>welcome to the internet. enjoying you're first day?
>>
>>51517900
>programs must be written for people to read, and only incidentally for machines to execute
Says who?

Also, look at pure functional programming languages, or at least at the type systems. With a sufficiently powerful type system that forces you to classify effects, you can learn everything you need to know about the function, bar how to fix a bug in its implementation, just by looking at the type. Write types (and docs) for people to read, write code for machines to execute.
>>
>>51517900
>>51517929
>C is especially bad for studying/building the most important concept of computer science and programming: Abstraction.
And how do you propose understanding abstraction without understanding what you're abstracting away from?
>>
spending over 90% of your free time on programming is too nerdish?
>>
>>51517929
>Says who?
Knuth, among others.
>>
>>51517937
>And how do you propose understanding abstraction without understanding what you're abstracting away from?
>>
can I assign eg. F8 to be automatic scrolling down, F7 to be automatic scrolling up?
>>
>>51517951
Literate programming arguably makes it easier to make the code for machines since you can add so much documentation right on the spot.

Try again, and also feel free to read the rest of my post.
>>
>>51517900
>programs must be written for people to read, and only incidentally for machines to execute
>C is especially bad for studying/building the most important concept of computer science and programming: Abstraction
True enough.

I still hold that C is a good language for learning due to the small number of primitives (you can learn about every part of C relatively quickly) and the closeness to the machine, but there are definitely better languages nowadays, especially for abstraction (which C is particularly shit at).

My pet language right now is Rust, but I'm not sure I'd recommend it as a learning language. Maybe in a year or so. C++ makes sense, but is horribly bloated and complicated. I've written maybe 100k lines of C++ (asspull number, haven't really thought about it) and while there's a lot of good stuff in there, you constantly feel its age.

Python is still what I recommend right now. Despite being high-level in non-zero-cost manner and being shit at concurrency, it has a ton of libraries, a clear / relatively intuitive syntax, a helpful community, and supports a variety of programming styles (procedural/oop/functional).

What language do you recommend for learning, if you don't know anything about what the learner wants to write?
>>
>>51517968
Yes.
>>
>>51518000
J a v a
a
v
a
>>
>>51518027
>java
Kill me now, I'd rather program in C++.
>>
>>51518000
>My pet language right now is Rust, but I'm not sure I'd recommend it as a learning language.
This is my opinion as well. It's pretty hard to appreciate the borrow checker without a background in C and/or C++ and functional stuff which is found will probably just confuse beginners.
>>
>>51517968
what's with the unrelated, retarded in /dpt/?
>>>/g/sqt
>>
>>51518047
D is best

Does rust have mixin (take compile time string & insert it as code)
>>
>>51518047
I agree. I mean, with my background in type theory I still struggle to appreciate the borrow checker.
>>
NEW THREAD

>>51518085
>>51518085
>>51518085

NEW THREAD
>>
File: penn_jillette.png.jpg (31KB, 300x400px) Image search: [iqdb] [SauceNao] [Google]
penn_jillette.png.jpg
31KB, 300x400px
>>51517973
>shitting on the Shakespeare of programming.
>proud of it too.
>
>>
>>51518097
I'm not shitting on him, retard. I'm shitting on YOU.
>>
>>51518071
>Does rust have mixin (take compile time string & insert it as code)
I'm not quite sure as I have never needed to use it. Rust has plugins which means that you can add language extensions, so I think you could add mixins that way if they aren't there.
>>
>>51515661
what happened to c+=?

where's the action going on? what irc channel is fsf on?
>>
>>51518058
I thought I could do it with a program
>>
>>51517968
>>51518264
just use a kb macro utility for you're platform anon.
>>
>>51518298
cheers mate
>>
>>51512936
use calloc
>>
File: latest[1].png (91KB, 398x284px) Image search: [iqdb] [SauceNao] [Google]
latest[1].png
91KB, 398x284px
>>51515429
I believe.
Thread posts: 329
Thread images: 30


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.