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

/dpt/ - Daily Programming Thread

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

Thread replies: 340
Thread images: 35

File: hidamari_dpt_waifu2x_traps.png (2MB, 1618x1308px) Image search: [Google]
hidamari_dpt_waifu2x_traps.png
2MB, 1618x1308px
Old thread: >>61128103

What are you working on, /g/?
>>
Firsr for Lua JIT
>>
File: 1469253603646.png (101KB, 680x535px) Image search: [Google]
1469253603646.png
101KB, 680x535px
>>61136300
Anyone else here learning to program because they're a friendless NEET loser and have literally nothing else to do all day? Making lines on a screen move the way I wanted them to makes me feel accomplished for a few minutes before I remember how much of a useless failure i am and how much of a joke my life is. Also it helps me sleep at night because at least i was """productive""". I mean, I was gonna sit there staring at a computer screen all day anyways, at least this way i'm making some kind of progress, right? Right?
>>
>>61136348
>>>/r9k/
>>>/adv/
>>
>>61136352
shitboards. Let me rephrase my post to be on topic. What programming project will make me employable?
>>
Business idea: OCaml with good syntax
>>
>>61136360
Loli rape simulator.
>>
>>61136360
>What [...] will make me employable?
A degree
>>
File: 1493265185100.png (2MB, 1920x1080px) Image search: [Google]
1493265185100.png
2MB, 1920x1080px
>>61136300
C influenced languages get an automatic F in my book.
>>
>>61136360
Depends what kind of dev you want to be lad.
>front/back/full stack webdev
>Front/back/full for non-web
>embedded systems
>network
And then theres a whole other branch for games.
>>
File: Screenshot_20170629_061626.png (120KB, 459x480px) Image search: [Google]
Screenshot_20170629_061626.png
120KB, 459x480px
I took some classes for c++ and java almost a decade ago and now I want to get back into programming but have forgot most of what I learned. What books should I get for C, C++, Java, Python, and Bash?
>>
why cant I just learn a single language and when I need to program in another language I just remember how I did it in my learned language and just google "how to x in x"
>>
>>61136401
That's probably what most people do. A lot of programming knowledge is universal.
>>
>>61136400
start with the GNU C reference. Then read the linux programming interface and make some toy system programs
>>
File: 1497386323804.jpg (27KB, 395x395px) Image search: [Google]
1497386323804.jpg
27KB, 395x395px
>>61136425
>GNU C
>>
>>61136401
After a while you won't even be googling "how to x in x," you'll just be googling "x syntax cheat sheet" and "x standard library"
>>
File: 1497734509295.jpg (8KB, 242x150px) Image search: [Google]
1497734509295.jpg
8KB, 242x150px
how would you handle struct alignment in c++ in 32/64 bit code? looks like making all members the same size is the best way but shit stops working when you use pointers, should i store everything as 64 bit or what? storing pointers in uint64 on a 32 bit systems looks like a suicide
>>
>>61136675
Are you passing structs raw between programs or some shit?
Don't be stupid: serialise your shit properly.
>>
>>61136696
no, passing just between dll files. these dlls can be compiled by different compilers/versions and i want to avoid that one dll can have a different struct size than other
>>
>>61136741
Why the hell are you trying to link 32-bit and 64-bit code together?
That's just not going to work.
>>
File: Selection_027.png (238KB, 1292x1010px) Image search: [Google]
Selection_027.png
238KB, 1292x1010px
>>61136043 (You)
>>61136252 (You)
>>61136149 (You)
>>61136107
I for a fact was correct the compiler wasn't correctly configured and it had literally nothing to do with my code.
Left is my .pro of the QTCreator project which should be doing the same as what i did manually on the right side
(don't mind the error at execution it tries to connect to a not existing database).
This also means that the way i am trying? to use qmake is wrong though i don't get why because this is what i am supposed to do to add flags to the compiler
>>
>>61136761
no, the problem is
struct{
char* ptr;
int64 value;
};

but this compiled on gcc and vs can generate different struct sizes because of paddings, the solution could be
struct{
uint64 ptr;
int64 value;
};

this guarantees the same struct size on every compiler, but this is dirty when compiled on 32 bit systems, thats what i am talking about
>>
>>61136812
>but this compiled on gcc and vs can generate different struct sizes because of paddings
No they wouldn't.
>>
File: 1402886051076.jpg (126KB, 856x704px) Image search: [Google]
1402886051076.jpg
126KB, 856x704px
>>61136834
Also, I forgot to mention:
Good fucking luck trying to link C++ code from different compilers together.
>>
>>61136834
yes they would, exe compiled in gcc and dll compiled in vs could not work together because they align members with different padding, program would just crash
>>
>>61136851
it doesnt work for you because you assume everything is padded the same way, thats where you are wrong kiddo
>>
>>61136400
>C
K&R
>C++
wait until you know C
>Java
Thinking in Java, by Bruce Eckel
>Python
Learn python after C, you just need google and stackoverflow
>bash
About 2 hours max

This website has good basic introductions to the syntax of basically every language
https://learnxinyminutes.com/

Also you should learn Scheme from The Little Schemer and SICP. It's my favorite language and it's a lot of fun.
>>
>>61136853
The alignment restrictions in x86 for a pointer is 8 bytes (the same as its size).
There is no reason that a compiler would insert padding between those members.
However, there are MANY fundamental flaws of C++ preventing you from doing what you're trying to do.
Give up.
>>
>>61136872
>x86
x86-64 I mean.
>>
>>61136812
This seems like a terrible fucking idea. Learn proper IPC.
>>
>>61136872
except pointers are 4 bytes on 32 bit machines, and compiler would add padding
>>
>>61136909
You can't fucking link 32-bit and 64-bit code together in the first place, idiot.
That's a complete non-issue.
>>
Reminder that programming is a means to an end. A tool.

If you're not already well-versed in another useful topic, you're the definition of a code monkey.
>>
>>61136867

what about matlab
>>
>>61136921
Reminder that mathematics is a means to an end. A tool.

If you're not already well-versed in another useful topic, you're the definition of a number puncher.
>>
>>61136914
im not talking about mixing 32 and 64, the issue is that the first example in >>61136812 would work on x64 perfectly but its not guaranteed to work on x86 because on compiler added padding and other not
>>
>>61136948
Who the fuck cares? Why is it so important?
Chuck an alignas on it and shut the hell up.
>>
>>61136944
Not sure if this was intended to be ironic, but it's also true.
>>
>>61136962
fuck off nigger if you have nothing better to add
>>
>>61136943
Matlab is a very good tool for mathematical programming. Personally, I'd rather use Python or Scheme for that purpose, but matlab is a fine tool (matlab is actually built on top of python and numpy iirc).
It's definitely something to be familiar with. A lot of colleges are not allowing their students to use graphing calculators, and are instead using matlab in classrooms. Most academics I know love it, and most engineering types are at least neutral to it (they'd use a sliderule if they could though), so it can't be that fucking bad.

>>61136948
GCC has the packed attribute. Have you tried that?
>>
>>61136300
Working on a cyberpunk imageboard, 4kev.org
>>
>>61136944
>mathematics
>number
What did she mean by this?
>>
>>61137073
What? Are you implying that mathematics does not contain numbers?
"Field punchers" just doesn't have the same ring to it.
>>
>>61136300
we need to go 128-bit
>>
>>61137281
why
>>
>>61137288
you fucking retard

128-bit
wider
>>
>>61137281
We're nowhere near the address space limitations of 64-bit.
There is very little to be gained by going further.
>>
>>61137297
>dude 4k
>dude 5k
>dude 8k lmao
Its the same shit.
R&D is fine and should never stop.
But consumer 128b hardware is not fucking needed right now. We need to completely phase out 32b first.
>>
>>61137337
who says the address bus needs to be 128bit?
>>
The only languages which should have GC are functional languages. Prove me wrong.
>>
>>61137288
>>61137337
>>61137388

are you guys seriously this dumb or are you pretending to be retarded

128-bit
wider
OP HAS A PIC OF HIDAMARI SKETCH
>>
>>61137414
oh, you were making a reddit joke.
that explains it.
>>
so, when you guys first started out coding, how long would it take you to do a practice problem out of a book? like a math sequence like a fibonaci or collatz?
>>
>>61137412
>Prove me wrong
Unnecessary. You used the word "should".
>>
>>61137469
when i first started trying to code, i was not able to compile an hello world program for about two years. no, i am not joking. yes, i invested hours every day on trying to understand what the fuck coding was about.

now i don't have any problem with any kind of project i want to make, and i use daily programs i have made to help in my language learning, including a spartan e-reader that has the only purpose of maximizing language learning efficiency at the expense of other desiderable features
>>
>>61137469
>like a math sequence like a fibonaci or collatz?
These types of things are useless, and teach you absolutely nothing.
>>
>>61136360
Anything that shows you aren't a shit. I am making a decent salary for where I live and most of my experience is hobby stuff. I have 6 months work placement from school, a two year diploma, and everything else is personal life hobby projects.
>>
>>61136802
Kys pajeet
>>
>>61136500
"left fold in c#"

Apparently it's aggregate.
>>
>JBlow doesnt believe in DRY
Jai C O N F I R M E D DOA
>>
>>61137586
link?

jai will literally save programming, if you don't like what jai does you can basically make it become a completely different language thanks to the best metaprogramming in computer history, lisp can suck dicks
>>
>>61137617
https://youtu.be/K2rvoCQksG8?t=1h14m5s
Jai is not going to do anything but be another ded language the creator becomes delusional about.
>>
Seriously though where all the cute euro traps.
>>
>>61137583
Yeah, the functional part of C# tends to annoy people with a functional background, but I believe the motivation was to make the LINQ functions easier to understand for those with a SQL background, and those who otherwise don't have functional/set knowledge.

Personally, I find them easier to read and understand what they do, but I'm coming from the latter camp here.
>>
>>61137648
Yeah I understand that, and I don't really get upset about it. It just means doing a bit of documentation checking.
>>
>>61137638
>Jai is not going to do anything but be another ded language the creator becomes delusional about.

the thing jai has and no one language ever had is the metaprogramming.

you want a borrower like rust? you can. you want garbage collection? ok. you want pure functions? done. dependent types? sure. you want to enforce your style guide? you can make a metaprogram that aborts compilation if you don't follow it.

this is just not comparable to anything else.
>>
how do I use code format in comment again
>>
>>61137788
>a language with no std and anyone can inject their own bullshit
Wow, because that worked so well for Lisp, and is currently working great for haskell.
And jai already has dependent types, albeit in their current form the syntax is disgusting and hes unironcially using $T, $K
>>
>>61136921
good thing im also a pro gamer and a good personal trainer in the gym!
>>
>>61137809
read the rules

>>61137817
Lisp is a ball of mud
>>
>>61137835
And if he goes through with INFINITE META, so will jai.
A good language cannot be X & Y & Z & A with hacks. You choose one or the other.

Also why would you need metaops for pure functions?
>>
>>61136300
Lisp is the most powerful programming language.
>>
>>61137874
Being a ball of mud is not a bad thing. Lisp is a ball of mud because the more mud you stick on it, it's still Lisp. You can add OOP and functional programming, memory management, whatever you want, and it still looks like Lisp. You can implement every data structure you can imagine through lists.
Lisp is a ball of mud, in contrast with say APL, which is more like a diamond. It's very pretty and has good uses, but if you tried to stick more diamonds on it, you'd have a weird cluster of diamonds, held together with adhesive. APL does not lend itself to extension and adaptation.
I've not taken a close look at Jai, but it might have similar qualities. A language that does everything will either be incredibly simple like Lisp, or incredibly complicated, like say Scala.
>>
>>61137817
>lisp has no standard library
>>
>>61137950
No sane person wants a language that can do and be anything. It has no focus or hope of staying usable, and will always be inferior to specialized languages.
And god help you in trying to contribute to someone else's repo, say they go nuts and it's a whole other world just to build it.
>>
>>61138035
>that no true scotsman
Opinion discarded.
>>
>>61138035
Fuck off retard, Lisp has all the standard shit like arrays, strings, and a multitude of functions to compliment each type and constructs (OOP, Conditions, Packages, Streams)
>a whole other world to build it
Highely unlikely. Kys.
>>
>>61138088
>Highely unlikely. Kys.
With the claims of
>you want a borrower like rust? you can. you want garbage collection? ok. you want pure functions? done. dependent types? sure. you want to enforce your style guide? you can make a metaprogram that aborts compilation if you don't follow it.
Its not that unlikely.
>>
>>61138035
>No sane person wants a language that can do and be anything
Common Lisp and C++ would like a word with you. It's also interesting to note that the major modern OOP+imperative languages (Java, C#, C++) have been working to add better support for higher order functions, lambdas, and other functional principles.
>always be inferior to specialized languages
I can think of a few specialized languages that do very well for niche tasks, such as SQL or regular expressions. C could even be considered a specialized language, and it does very well for itself in resource constrained environments, but I wouldn't say that a specialized language is always better than a flexible language. Java (before it gained generics, functors, lambda's, and many of the other niceties we appreciate today) was fucking terrible, because development in Java mandated OOP for even the most minor tasks.
>And god help you in trying to contribute to someone else's repo
That's why communities develop idioms. C++ has them, Python has them, Common Lisp and Scheme have them. People figure out good ways to do things, and stick with those good ways, but that doesn't mean that these idioms need to be enforced by the language. If someone's project is a fucking mess, that's because they're bad at organizing a project, not because their language is bad.
>>
>>61138101
>Java was fucking terrible
>was
>>
>>61138101
>That's why communities develop idioms.
Please follow the reply chain.
His whole point was people can just enforce their own entire standards.
>>
>>61138109
Inane dpt trendie comment.
Contribute to the discussion with talking points, moron.
>>
>>61138123
you sound like a virgin lol
>>
>>61138035
>whole other world just to build it
have you even looked at jai? one of the selling points is that you don't even need a build system. any project using jai just needs to point the compiler at a single jai file and that jai file does all the work.

try to contribute to a repo in any other language without a standard for projects, like C/C++, then tell me how easy it was to build it. I can think of a dozen build systems off the top of my head, from the simplest makefile/bash script to batshit insane like bazel
>>
>>61138123
Not him but Java is still pretty much the same as it always was, new features like generics and lambdas are all just syntax sugar for the same old shit we used to do with casts and anonymous classes.
>>
>>61138132
is jai the new thing to shill in this thread
i didn't receive the shill memo
>>
>>61138100
Lisp is a body that bends to the will of time.
Realy important shit like OOP, GC, and Conditions, get added to the standard, and no-one can implement it in Lisp, you'd have to write your own Lisp.
>>
>>61138109
Ignore /g/ memes for a moment, modern Java with functors, an REPL, and generic programming is perfectly suitable for business applications. The only things it lacks that C# has that I can think of are easy C interop, something as good as ASP.NET, and properties
>>61138140
You're wrong, a lambda does not create an anonymous class, and generics provide compile time type safety.
>>61138117
And what is wrong with that?
>>61138154
Isn't CLOS implemented in Common Lisp?
>>
>>61138166
>Isn't CLOS implemented in CL?
Nope.
>>
Ok so I got this project in java to make a binary search tree with duplicates so each node is a linked list of items which are considered to be duplicates
I have to implement all the methods of the standard binary search tree class to this new class im making
the normal insert is:
protected BinaryNode<AnyType> insert( AnyType x, BinaryNode<AnyType> t )
{
if( t == null )
t = new BinaryNode<AnyType>( x );
else if( x.compareTo( t.element ) < 0 )
t.left = insert( x, t.left );
else if( x.compareTo( t.element ) > 0 )
t.right = insert( x, t.right );
else
throw new DuplicateItemException( x.toString( ) ); // Duplicate
return t;
}


I tried to make it with a linked list and it didn't work, the comapareTo method is said to be not found

protected BinaryNode<LinkedList> insert( LinkedList x, BinaryNode<LinkedList> t )
{
if( t == null )
t = new BinaryNode<LinkedList>( x );
else if( x.element().compareTo( t.element.element() ) < 0 )
t.left = insert( x, t.left );
else if( x.element().compareTo( t.element.element() ) > 0 )
t.right = insert( x, t.right );
else
throw new DuplicateItemException( x.toString( ) ); // Duplicate
return t;
}


There was this on the standard binary search tree class declaration
public class BinarySearchTree<AnyType extends Comparable<? super AnyType>>
can someone tell me what this is or does? I tried copying the same to my class but it didnt fix the problem. How do I fix my problem?
I basically don't know where the compareTo comes from even on the standard class.
>>
>>61136812
let me introduce you to templates in c++
>>
>>61138183
Let me clarify, it depends on the implementation, and stuff is mostly written in the Daddy language for efficiency purposes.
I'm not well versed in CLOS, though.
It seems more likely that CLOS be implemented in the Daddy language.
>>
>>61138183
>>61138218
I'm just looking at SBCL and I don't see CLOS anywhere in the very small body of C code they use.
https://github.com/sbcl/sbcl
You might be right for CLisp though, I don't know, I don't touch that Jewish shit

Regardless, I know for a fact that Scheme has many object systems, and all of them are in native Scheme.
>>
>>61136367
Its already been done by that other anon.
>>
>>61138218
>>61138224
He is just spewing bullshit. CLOS is implemented in CL. Early versions of CL did not include CLOS.
>>
>>61138200
In order to use the compareTo method on your LinkedList objects, your LinkedList class must implement Comparable<LinkedList>. This indicates that your object can be compared to itself. Then you'll have to write your own compareTo(LinkedList) method, which is left as an exercise to the reader.

https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
>>
File: 1496425515646.jpg (200KB, 1127x1079px) Image search: [Google]
1496425515646.jpg
200KB, 1127x1079px
>>61138154
>Realy important shit like OOP
>>
Why don't C and C++ have arbitrary width integer types?
It would be nice to be able to do something like
int<5> x;

if for some reason I ever needed specifically a 40-bit integer.
Being able to do
int<12> x;

would also be helpful if I ever needed more than 64 bits. I know that's by definition more than even any modern processor can address in one go, but that being the case, it would of course be handled with invisible extra memory accesses, just like large structs, right?
I know you can do this in C++ by implementing a bigint class but it would be nice to be able to do this in C.
>>
>>61136300
>What are you working on, /g/?- 96 posts and 8 image replies shown.

a twitter client for emacs that doesn't require an account using splinter
>>
>>61138334
include stdint.h silly
>>
>>61138264
how do I implement that
>>
>>61138334
but why
>>
>>61138355
SO has a lot of retards but it's pretty helpful for classwork type stuff
https://stackoverflow.com/questions/3718383/why-should-a-java-class-implement-comparable
https://stackoverflow.com/questions/21626439/how-to-implement-the-java-comparable-interface

>>61138334
Using a length that's less than a single word is totally useless.
>>
>>61138354
That wouldn't solve the problem at all. It only has powers of 2 up to 64, and they're not even parameterized, so if you ever have to dynamically decide what size of int you need, you're out of luck.
>>
>>61138334
In c++ i know you can do this, and in c I'm sure you can cook up some fancy macros fot it
>>
>>61138377
>if you ever have to dynamically decide what size of int you need, you're out of luck.
When do you need to do this?
>>
>>61138369
>Using a length that's less than a single word is totally useless.
I agree, why would you do that.
That being said, what about int<5>s and int<12>s.
(5 and 12 being widths in bytes, not widths in bits, because counting width by bytes is idiomatic C and C++)
>>
>>61138387
If you want a space of 5 bytes, then malloc 5 bytes.
>>
>>61138166
>The only things it lacks that C# has that I can think of are easy C interop
Appearantly theyre working on it
>>
>>61138384
Say for example if your program has to do math with arbitrarily large numbers.
It COULD just set a reasonable upper bound of 64 bits, but that would be a problem for two reasons:
1) If another integer size is faster on the target machine, you'd never get to take advantage of that speed, even in cases where your numbers would fit in that size.
2) What if a calculation needs more than 64 bits and overflow is undesirable.
>>
>>61138334
you can specify the bit width in a struct:
typedef struct A {
uint64_t x : 40;
};


note that sizeof(struct A) is still 64 bits.
>>
>>61138415
Yeah but then you have to define arithmetic operators yourself, give them alphanumeric names, and invoke them as functions.
It would be nice to be able to use the actual arithmetic operators, like you would for any other numbers.
>>
>>61138369
alright thanks
now i dont know how to define the compareTo method
ehhhh
>>
>>61138463
>Say for example if your program has to do math with arbitrarily large numbers.
then you'll have a bigint class.
>>
>>61138483
Oh. I didn't know about this.
This is awesome.
Thanks.
>>
File: 1496165557716.jpg (329KB, 1834x1200px) Image search: [Google]
1496165557716.jpg
329KB, 1834x1200px
>2017
>still using C
>>
>>61138484
I think this could be implemented with C++ templates
template<int Size>
class Number{
private:
std::array<byte, Size> cell;
public:
/* your methods go here */
};
>>
>>61138508
namespaces are POO
>>
>>61138483
>>61138500
You can use __attribute__((packed)) with most relevant compilers to pack several different types in the lowest possible space
>>
>>61138522

>POO=organized, scoped code
>>
>>61138544
modules > pooscopes
>>
>>61138508
>implying using C and using C++ are mutually exclusive
>not also having a good grasp on java and all the trashy "artistic" slowlangs like ruby, python, perl, lisp, scheme, clojure, javascript, haskell, and idris
>being this much of an angry little brainlet-elf
>>
>>61138566
>python
>artistic
>>
>>61138566
projecting
>>
>>61138574
C O D E 
A R T I S A N S
>>
>>61136300
Can I construct my values in a void field? Eclipse won't stop asking me for a place to return.
>>
>>61138586
    C O D E 
A R T I S A N S

Here it looks artsier now.
>>
>>61138594
show what you mean senpai
>>
>>61138594
post sexy code for us to programmerfap to or we cannot help
are u grill(((((((male)))))))
code or gtfo
>>
>>61138656
you have your cast backwards, lad
>>
>>61138616
I usually do
public Classname(){
x=0;
y=0;
}


And it works. Now Eclipse won't stop bugging me with an error message unless I do this:

public void Classname(){
x=0;
y=0;
}

>>61138656
I'm not a girl but my iq is 95 so please don't bully me
>>
>>61138710
Last setence isn't part of the code
>>
>>61138710
public void Classname(){
x=0;
y=0;
}

This is not a constructor, this is a plain old method. You're doing it wrong if you do this.
What is the error message?
>>
>>61138710
Post the whole file in a pastebin or something
>>
>>61137577
Projecting much?
>>
>>61137433
now here we have a real newfag, who labels anything he doesn't recognise 'reddit'. you've probably been on this site a maximum of three years at the very most
>>
>>61138710
>And it works. Now Eclipse won't stop bugging me with an error message
The constructor on the top looks fine to me so we'll need some more context. Namely:
* Does your constructor appear in a class declaration ("public class _____ { ... }")?
* Does the class declaration HAVE THE SAME NAME ("public class Classname { ... }")?
* Are x and y instance variables of the class?
If the answer to any of these is "no," you know what you need to fix.
>>
>>61138764
>>61138736
Wait a second, I'm a fucking retard. I was adding an extra letter to the constructor name, now it's working.
>>
>>61138762
This. I've been browsing 4chan since 1999. It's hilarious how newfags try harder and harder to make it look like their pathetic decade of experience has any worth.
>>
>>61138860
gtfo newfag, I've been here since 1971. I remember writing my shitposts in ed on a teletype.
>>
>>61138881
>tfw moot is actually 50+
>>
>>61138860
>bragging about browsing 4chan for 18 years
This is a special kind of pathetic.
>>
>>61138893
Who?
>>
File: 1494141338880.png (351KB, 496x577px) Image search: [Google]
1494141338880.png
351KB, 496x577px
I finally finished my prog assignments. Fuck yes.
>>
>>61138860
>has any worth
>implying this is the case about any experience on 4chan
>>
>>61138996
>he is a student
>>
File: 14558.png (380KB, 584x553px) Image search: [Google]
14558.png
380KB, 584x553px
>code works
>I don't know why it works
I though this was just a meme
>>
How do I correct this? Trying to catch an ArrayIndexOutOfBounds exception so my text-based game won't break if the player tries to move outside of the 2D array.
Posistion lastPos = player.getPosistion();
try{
player.playerMove(command);
}
catch(Exception ArrayIndexOutOfBoundsException){
System.out.println("Out of bounds! Try again!");
player.getPosistion().setPosistion(lastPos.x(), lastPos.y());
continue;
}
>>
File: 1466169987672.png (412KB, 553x562px) Image search: [Google]
1466169987672.png
412KB, 553x562px
>>61139021
I hate being a student but c'est la vie.
>>
>>61139021
That's half of the people here
>>
>>61139051
>>61139061
it's okay i am also a student
but just also also a meme shitter
>>
File: video, frames, composite.png (399KB, 612x792px) Image search: [Google]
video, frames, composite.png
399KB, 612x792px
Automatic stitching for anime
>>
>>61139047
Exceptions are expensive. It would be better to do bounds checking in player.playerMove, only move if the new position would be in bounds, and throw away lastPos altogether.
>>
>>61138035
Lisp is to lambda calculus what C is to modern computer architecture.

It "does everything" because it represents the basis of abstract computation, just as C "does everything" because it represents the basis of modern computer computation.
>>
>>61139108
/w/ would probably love that.
>>
>>61139128
The problem is that the player's position is entirely independent of the board, which i'm not realizing is kind of a bad idea but this code is already so spaghetti i'm scared to change that. This is literally the last thing I need before it works perfectly as planned. I guess I could just .get() the map boundaries and then check it from there. eh.
>>
>>61139150
>It "does everything"
Incorrect it does not go fast
>>
>>61139154
Good point, I'll shill it there once it becomes more usable.
>>
>>61139108
but how though?
>>
>>61139173
Clever man of the year award goes to this guy.
>>
>>61139184
>libavcodec
>motion vectors and scene change detection to find pans
>spit out PNGs
>feed PNGs to opencv
something like that. it's only half-done so far.
>>
>>61139191
But anon it does not go fast
This makes it a bad language because it is a universal law of ethics that Gotta Go Fast
>>
(defun random (n)
6)
>>
>>61139328
;; chosen by fair dice roll
>>
>unironically blaming VS and Emacs for "deleting" your code
I dont know why i keep watching jblow, hes such a shitter sometimes.
>>
>>61139348
How does emacs delete code if by default it creates backup files?
>>
>>61139348
Link?
>>
>>61139366
Not sure, dont use it. He always bitches about it though.
>>61139367
https://youtu.be/K2rvoCQksG8?t=2h4m26s
>>
Please don't call me a girl. There's no reason to use your pronouns randomly. Girls are a myth and they don't exist, they certainly don't visit /dpt/.
>>
File: 1495353961533.jpg (274KB, 721x887px) Image search: [Google]
1495353961533.jpg
274KB, 721x887px
>>61139432
>Girls are a myth and they don't exist
What is this image then?
>>
File: cat.png (144KB, 600x811px) Image search: [Google]
cat.png
144KB, 600x811px
>>61139432
You must be a little girl because we are all little girls here.
>>
>>61139432
All /dpt/ers are girlmales
>>
>>61139384
i hope jai never comes out

>>61139456
what about us girl (female) s?
>>
61139453
2d arent girls, theyre goddesses, noio-kun
>>
>>61139455
we are all little girls
there are no girls on the internet
the logical conclusion is that this is not the internet.
>>
>>61139473
>what about us girl (female) s?
girlmales with different parts
"you must be, or you wouldn't have come here"
>>
>>61139456
>>61139485
what's it called if you have a male body but identify as female but only to yourself and to everyone else you identify as male because it's easier to accept the discomfort of labels and expectations contrary to what you are than to try to explain to anyone and be laughed at
>>
>>61139519
daydreaming
>>
>>61139519
mental disorder
>>
File: didit.png (43KB, 1052x587px) Image search: [Google]
didit.png
43KB, 1052x587px
>>61136300
project euler.

Just did pic related. Took me waaaaaay to fuckin long, but I finally did it!
>>
>>61139453
it´s a male with a feminine penis
>>
>"So you program in Haskell?"
>"*blush* yes"
>"Isn't that kind of gay?"
>"it's not gay if it's a feminine monad"
>>
>>61139598
Functional programming makes people gay. more news at 11!
>>
File: babab.png (9KB, 399x467px) Image search: [Google]
babab.png
9KB, 399x467px
>tfw you have a problem and you sit there for like 50 minutes sitting there using various hacks and shit to try and force the program to work the way you want it to
>original structure is completely destroyed as you try various different solutions
>works the way you want it to, but it's absolutely hideous and horribly done
i feel awful, it's seriously gross what i've done, but it works and that's all that matters
>>
>>61136300
Struggling to understand work stealing load balancing enough to implement it, so that I won't have to wait on a slow processor.
>>
First time working with python, and also first time programming. I made a sort-of hangman game with what I could figure out. How did I do? Any improvements you could suggest?
import random
from collections import Counter
words=["scared","selection","won","zoo","wolf","shrimp", "binder","moon","elephant","light","dark","fish","television","victory"]
chosenword = random.choice(words)
Loopmechanism= 20
print("Welcome to the game. Input a letter and you will be given the number of times that letter appears in the word. You will have twenty attempts. Correct guesses do not count.")
while Loopmechanism > 0:
guess=input("Guess a letter or the word: ").lower()
dude = list(chosenword)
#print(chosenword)
guessnumber = Counter(chosenword)[guess]
if guessnumber > 0:
print(guessnumber)
if guessnumber == 0:
print(guessnumber)
Loopmechanism -= 1
if guess == chosenword:
print("Congratulations, you won.")
break
if Loopmechanism == 0:
print("You lose. The word was " + chosenword + ".")
>>
why /dpt/ has so much shitposting?
>>
So I'm teaching myself Haskell going through Project Euler. On number 39:

>If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.

>{20,48,52}, {24,45,51}, {30,40,50}

>For which value of p ≤ 1000, is the number of solutions maximised?

I did:

pythagPerimeterLength x = length [(a,b,c) | c <- [1..x], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2, a + b + c == x]

lilTupleMax x = maximum [(pythagPerimeterLength y, y) | y <- [1..x]]


This works:
ghci> lilTupleMax 120
(3,120)

But I ran l"ilTupleMax 1000" and it's been running for like 10 minutes.

This is all on a VM with one virtual processor. I don't know if that matters. Anyways, please tell me why I'm retarded.
>>
Tried to check for possible errors in my opengl program with valgrind but just initializing opengl makes it throw 35000 errors from nvidia's gl libs.
>>
>>61140033
x <- [1..n]
c <- [1..x]
b <- [1..c]
a <- [1..b]

where n = 1000

find a better solution
>>
>>61139873
looks alright.
Maybe do a version with a dictionary to get familiar with them.
>>
>>61140160
Number 2 sounds better, but you could also considering stopping at the boundary, and getting a message like
>you bumped into a wall
>>
>>61140043
You can make a valgrind filter file, to hide errors from certain libraries.
>>
>>61140358
>let's just sweep these error messages under carpet
Yeah but what's the point if the graphics drivers are raping my system beyond repair?
>>
My internet keeps dying, but I posted earlier about having issues with SDL2 and the gamecontroller.

Original post: >>61117788

In response to: >>61136340 and >>61136408

Thanks, but I was using those sources to begin with. In the case of https://wiki.libsdl.org/SDL_GameControllerOpen , it fails to work because SDL_IsGameController() still returns false.

Anything related to the game controller just doesn't work for me in SDL2, but I do not want to use the joysticks either.
>>
>>61140407
They're not, it's just that your drivers are not allocating and free-ing memory in a typical fashion. X11 does this, I think most graphics systems do this. NCurses does this too. They use all sorts of fuckery to work, and valgrind doesn't understand it.
>>
>>61140426
Did you build SDL2 yourself from MinGW?
>>
>>61140435
>B- Bu But they need to do it!
>valgrind is stupid!
I don't care if your program compiles and runs but I fucking paid for this video card and they better fucking work and not be some pajeet quality where it's fine even if there's more error messages than the terminals history can hold.
>>
>>61140495
Shut your slutty mouth. You don't know what you're talking about and you're shitting up my shitty thread. This is well documented behavior and you're too retarded to do any research.
>>
>>61140558
There is only place for nvidia apologist like you
>>>/v/
>>
>>61140579
>doesn't understand the concept of "valgrind clean"
>thinks I give a fuck about his gpu shitfits
run the same code under any drivers, you'll get the same result you retard. Go shit up any one of the 10s of gpu threads that you and your trash pollute /g/ with every day.
>>
>>61139158
Maybe impose an out-of-bounds area on the map so that when the player tries to go out of bounds you only have to check if the value is the const you filled the out-of-bounds area with and if it isn't then advance.
>>
What are some fun tiling algorithms for a window manager?
>>
>>61140672
Bogosort
>>
>>61140672
Could you write a tiling algorithm that would allow my windows to be stacking?
>>
>>61140435
Do you mean that these libs are literally too smart to free their allocated memory?
>>
>>61140686
I'm creating it for my personal use and I'd want it to start another layer after six windows. Also going to include an easy way to make the windows float.

>>61140677
It's in JS, it's already slow enough.
>>
>>61140716
No, what I mean is that they're not valgrind clean. Valgrind works by injecting it's own malloc and free into your program (among other things). When using a low-level interface like OpenGL, they use various fuckery to manage memory, in such a way that Valgrind cannot properly analyze.
>>
>tfw you realize all programming paradigms are shit and monkey brains are just incapable of managing complex state changes, regardless of how many shitty convoluted layers of abstraction you contrive
i'm sad
>>
How do I unbrainlet myself into becoming a good programmer?
>>
>>61140769
SICP
>>
>>61140769
>>61140778
*SICP and The Little Schemer
>>
>>61140778
>>61140786
But I'm a retard. Even if I do SICP it won't make me think quicker.
>>
>>61140769
>a good programmer
Define this, and then we can talk.
>>
>>61136326
Why do people like JIT over static compilation?
JIT is so hard to optimize, doesn't give you predictable results on your target platform/use and can occasionally cost you time.

I thought in the case of video games especially (that are meant to be soft real-time mostly) that would be undesirable.
>>
>>61140810
Someone who can design elegant and fitting architecture for programs, find the simplest but most efficient algorithms quickly and generally just be able to solve hard problems with fast programs.
>>
File: dum.png (62KB, 1023x477px) Image search: [Google]
dum.png
62KB, 1023x477px
any thoughts?
Bruteforcing that shit seems to be retarded as fuck
>>
>>61140803
SICP is like the old testament. The Little Schemer is the Gospel.
>>
>>61140859
>efficient algorithms
>fast programs
It's too late for you. You've already drank the /dpt/ kool-aid.
>>
>>61140769
1.
Learn to break down problems into parts in your head until they're small enough for you to actually do.
2.
Don't worry too much about implementing the details, they can be quite floaty until you get a code structure in place
3.
Remove all distractions
4.
Keep focused on smaller subsections of a problem. If you're writing a large application don't consider every step of it just consider the sub-system you're working on.
>>
>>61140842
muh runtime profiling
>>
>>61140863
In Project Euler bruteforcing is almost always the wrong way.
>>
>>61140899
yeah that's for sure
>>
>>61140874
>t. I make excel take minutes to start on your computer
Well done anon. Your kind is the ones that have plunged us into the current dark age of computing.
>>
>>61140863
>Brute force in C
VS
>clever algorithm in interpreted/garbage languages
Same speed.
>>
>>61140924
>excel taking minutes to start

Show me this occurring on a computer you or anyone you know owns.

Do you realize how long of a duration "minutes" is?
>>
>>61140960
But bruteforce would be 2000^2000, right?
>>
>>61140863
Seems like a starting point would be the following observations:
a, b, and n are integers
for several consecutive values of n, if i and j are integers and n^2 + an + b = ij, then either i or j = 1
>>
>>61140876
It's more like:
1. Learn to break down problems into parts until there are too many to manage and they're in a disjointed hierarchical mess that nobody can make sense of.
2. Hard code everything until you fuck it all up when you try to generalize.
3. Withdraw yourself from society and become isolated as your code slowly drives you insane.
4. Stop sleeping.
>>
>>61141060
Well, if a is even then b has to be uneven, because anyways it would be divisible by 2. So that would cut the possible combinations in half
>>
>>61141074
Ah. That's exactly what I meant to write anon thanks.
>>
>>61141074
1. identify the problem
2. learn to break down problems into parts until the parts are so small they are literally processor instructions
3. string the instructions together
4. test and redesign
5. back to step 1 unless it's perfect
6. because you started out with a more abstract model than processor instructions, artifacts of that model will inevitably be present in the form of small redundancies; acknowledge this
7. convert your sequence of instructions to a mathematical formula and simplify algebraically in order to identify the redundancies
8. eradicate them
9. verify it still works
10. if not, roll back all changes since step 7 and try again from there
11. publish
>>
>>61141194
u fokn wot
m9
>>
>>61140426
maybe you could use XInput directly alongside SDL?
>>
>>61136300
Does anyone know how 4chanX magically loads images quickly?

I made a chrome plugin for the archive website for 4chan, and for some reason it takes about two to three seconds to load an image, as opposed to nothing with 4chanX.

All I'm doing is traversing the DOM and getting the URLs and then inserting it to the page for viewing dynamically.

I'm going to try preloading all images to the HTML, hiding them, and then showing them when needed. Maybe that'll be better, IDK.
>>
>>61141360
>>>/g/wdg
>>
>>61141060
>>61141099
Wew, I just looked more closely at the problem and all coefficients are either primes or gaussian primes. Maybe that's a hint? Not even sure though.
>>
What's the best way to write javascript? In the past I've used compilers for Java, but for python I just write the files in a text editor then run them in the terminal. Are there compilers for javascript? If not, what software do people use to write in this language?
>>
Is there room for a C derivative that's graphic processing focused, or is something already out there?
>>
>>61141449
javascript is interpreted m8, just like python
>>
>>61141449
>>>/g/wdg
>>
>>61141457
Isn't this what GLSL was supposed to be for?
>>
>>61141457
C++
>>
>>61141457
https://processing.org/
>>
>>61141329
How could I go about doing that?
>>
File: Capture.png (3KB, 247x66px) Image search: [Google]
Capture.png
3KB, 247x66px
https://futhark-lang.org/index.html

>that tab icon
>>
>>61141449
Like Python, Javascript is interpreted. This means the "compiler" runs your program as it goes, instead of storing the instructions to an executable. However, unlike Python, Javascript is usually run in a Web browser, not in a terminal. The browser loads its scripts from webpages, but most browsers also have an interactive prompt.
To embed a Javascript file in a webpage, so it will run when the webpage loads:
<script src="path/to/script.js"></script>

To bring up the interactive prompt: F12 (usually)
>>
>>61136300
>What are you working on, /g/?

working on a (You)bot, a neural network that rates candidate posts a write by likelihood that i'll get a (You) so i can maximize (You)s
>>
>>61141535
gotta go fast
>>
>>61141449
I run them under v8 and use strict mode + linters to catch errors. Your editor of choice probably has support for linters as plugins (typically run on save).
Because the language itself lacks the concept of projects/modules you may end up having to hint how things are tied together (e.g. globals). This typically looks like
/* eslint-env: node */


or were you memeing javascript (because it's shit (it is))
>>
>>61141725
>This means the "compiler" runs your program as it goes

no it doesn't, most js engines are JITs, and even interpreters like python actually execute bytecode, storing the instruction in an executable, and not the actual program
>>
>>61141742
yeah but the point is it still runs your code as it "compiles" it, and not some indeterminate time afterward, whether "compiling" actually means compiling (JIT) or not
>>
>>61141457
Do you mean the processing you do with graphics objects before you send it off into the opengl/directx pipeline or do you mean something like a language made for Cuda/opencl or compute shaders?
>>
>>61141742
It's Impressively slow considering. I can hardly believe that's the case actually. It'd not rare for JS to be thousands or millions times slower than an equivalent C program.
>>
added some ugly magic to my lisp interpreter with annotations and reflection and now I feel dirty like pajeet after a designated street visit
>>
>>61142000
ugly magic is the true spirit of programming
>>
>>61141787
But I think Python does compile the source to bytecode BEFORE running it, it just does so as part of the run command, rather than as a separate compile and run command. And normally you don't care about keeping track of the compiled bytecode files, since there's a single program that does both the compiling and the bytecode interpreting, so there isn't much benefit to distributing Python programs in compiled form.
>>
>>61141997
>millions times slower than an equivalent C program

well that is just so wrong i have no idea were you read something like that
>>
>>61141997
>It'd not rare for JS to be thousands or millions times slower than an equivalent C program.
...Yes, yes it is.
>>
>>61142192
yeah that would probably only be if the js program used a different algorithm
>>
>>61141531
not sure if it'd work but. you'd need to include windows.h and input.h and link to xinput.lib

XINPUT_GAMEPAD *gamepad;
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
XINPUT_STATE state;

if (XInputGetState(i, &state) == ERROR_SUCCESS) {
printf("controller %d is connected\n", i);
gamepad = &state.Gamepad;
}
else {
printf("controller %d is not connected\n", i);
}
}


more info here and here
>https://msdn.microsoft.com/en-us/library/windows/desktop/ee417001(v=vs.85).aspx
>https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.xinput_gamepad(v=vs.85).aspx
>https://hero.handmade.network/episode/code/day006
>>
File: ,.png (168KB, 727x682px) Image search: [Google]
,.png
168KB, 727x682px
>>61140863
>>61140899
>>61140960
>>61141060
>>61141430
I did it. Also a and b had to be primes.
because it should get started with n=0 and f(0) = b and for a kind of the same, too lazy to write it down now.

#include <stdio.h>

void find_primes();
int is_prime(int);
int get_consecutives(int a, int b);


int primes[1000] = { 0 };
int primecount = 0;

int max_consecutive = 0;
int coefficient;

int main()
{
find_primes();

for(int a = 0; a < primecount+1; a++)
{
for(int b = 0; b < primecount+1; b++)
{
get_consecutives(primes[a], primes[b]);
get_consecutives(primes[a], -primes[b]);
get_consecutives(-primes[a], primes[b]);
get_consecutives(-primes[a], -primes[b]);
}
}

}

int get_consecutives(int a, int b)
{
int count = 0;
for(int n = 0; n < 10000; n++)
{
int fn = n*n + a*n + b;
if(is_prime(fn))
count++;
else
break;
}
if(count > max_consecutive)
{
printf("found new max for a=%d and b=%d coeff=%d n=%d\n", a, b, coefficient=a*b, count);
max_consecutive = count;
}
}

void find_primes()
{
for(int i = 2; i < 1000; i++)
{
if(is_prime(i))
{
primes[primecount++] = i;
}
}
}

int is_prime(int n)
{
if(n <= 1)
return 0;
else if(n <= 3)
return 1;
else if((n%2 == 0) || (n%3 == 0))
return 0;
int i = 5;
while(i*i <= n)
{
if((n%i == 0) || (n%(i+2) == 0))
return 0;
i += 6;
}
return 1;
}//is_prime



the final combination could prolly be improved, but I dont care
>>
>>61141531
>>61142327
also I don't have any controllers to check it with but it did compile and run with sdl and tell me I had no controllers
>>
>>61142345
dumb frogposter no wonder you had so much trouble with such a simple problem
>>
File: hammer_angry.jpg (90KB, 957x621px) Image search: [Google]
hammer_angry.jpg
90KB, 957x621px
>>61142409
fuck you, bobspeng
>>
>>61142409
>tfw brainlet
>>
>>61141997
Keep in mind that your typical C compiler is fairly slow - even on a decent machine, it usually takes a few seconds for GCC to generate the executable even for trivial programs. That's because it typically does a considerable amount of optimization (even at the minimum optimization setting), which takes more time then simply passing through the source and generating equivalent machine code. You don't have that kind of delay with JS typically, because it's compiling stage is very simple and straightforward, basically no optimizations at all. And only some JS engines JIT compile to machine code, many create bytecode which I suspect is really more like the old tokenized BASIC formats - it has the exact same semantics as the original JS, and still has to be interpreted by software, but replaces long keywoards with shorter byte sequences making it easier for a machine to parse (but also unreadable by humans). And any kind of bytecode is invariably going to be slower than machine code, since the whole instruction cycle has to be done in software, each cycle requiring MANY cycles of actual processor time. Even a ridiculously simple VM (byte-sized instruction, no operands, exits on 0xFF, advances on any other opcode) would need to be implemented by machine code that looks something like:

handle_instruction:
mov eax, byte ptr [_program + _pc]
cmp eax, 0xFF
jz call_exit
inc _pc
jmp handle_instruction
call_exit:
push 0
call _exit


And for any REAL bytecode, even if it is literally bytecode (i.e. 1 byte per instruction), the VM instruction cycle is going to be even more complicated. If it takes something like 5 machine instructions per bytecode instruction for something which has only two bytecode instructions, and isn't anywhere near Turing complete, it's obviously going to be much worse when it comes to any sort of useful bytecode VM.
>>
>>61142345
>>61142437
>ribbit the reddit frog
I don't want reddit stink nearby. Fuck off.
>>
>>61142476
>not knowing a quality ylilauta meme
you've outed yourself, >>>/reddit/
>>
>>61142489
>incorrect linking
Why do you keep denying being a redditor? Fuck off.
>>>/v/
>>
>>61142476
>>61142489
>>61142498
is this why the rest of 4chan hates general threads
>>
>>61142537
Generals are just subreddits for people who are "too cool" for reddit
>>
>>61142228
>>61142192
This is my own experiences. Sure they're manual rewrites. I shouldn't have said equivalent programs. It's actually programs that produce the same outputs for a given input. The ones I've compared have been fairly trivial programs though.
>>61142472
That would explain it. I suppose my coding style may influence this difference quite a bit then because I rely on the compiler to infer that a computation result is statically knowable quite a bit.
>>
>>61142544
A general is (effectively) a single thread, not a board.
>>
>>61142537
>>61142544
I want to see the reasoning why you're not from reddit, which you obviously are.
>>
>>61142572
>The ones I've compared have been fairly trivial programs though.
While I applaud your admittance of bias, this is the exact concept that I see from C-proponents far too often.

C absolutely shines in small, specific, trivial algorithms, performance-wise, but when extending that perceived advantage across an entire non-trivial application, you quickly see it vanish to nearly nothing, only to be replaced by insane amounts of developer cycles to try to implement the same at-hand functionality high-level languages offer.
>>
File: happy.png (44KB, 1027x731px) Image search: [Google]
happy.png
44KB, 1027x731px
>>61142476
Don't be meenie, fren! Dis is true /bant/ meem.
lemme hug u
>>
>when you know enough about a language that books on it can't help you, but randomly programming things with no feedback doesn't help you improve

What should I be doing? Going through other peoples' projects on github?
>>
>>61142642
What makes you think you need to improve?
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>61136379
Good pic but bad post.
>>
>>61142327
thanks! i'll look at it later and see how I can get it into MinGW.
>>
>>61142667
Because I'll never finish my MMORPG with neural networks at this rate.
>>
>>61136364
SML has slightly better syntax than ocaml.
>>
Is C++ a bad starting point?
I've no intentions of being a programmer by trade nor practice but do need to be able to unfuck some code, and it'd be nice to not ruin my ability to learn in the future with bad fundamentals.
>>
>>61136364
OCaml
>>
>>61142694
I hope you're joking. What projects have you done before this?
>>
>>61142707
C++ is about as bad a starting point as any other language. It's probably a bit worse than C but not by much.
>>
>>61142707
C++ is a very complicated and inelegant language. I don't think it will harm any later efforts to program like some other languages, but it will be difficult to learn in the first place.
>>
>>61142723
It's a meme, my friend.
>>
>>61142604
Generally speaking, you're not likely to see a C program with worse overall performance than a JS program, unless the developers ended up getting ridiculously sloppy and writing just plain horrible code. What you will see in large C programs is a much higher incidence of errors, buffer overflows and off-by-one errors and the like, and that a large program requires considerably more effort. You're likely to see C programs lacking features compared to JS programs with a comparable amount of development effort, but the C program actually being slower is highly unlikely. If C code is good enough to actually work, it's probably good enough to outperform JS.
>>
File: 1493064747460.png (1006KB, 912x1080px) Image search: [Google]
1493064747460.png
1006KB, 912x1080px
>>61142682
Why is my post bad? You can easily show that any C influenced language is pure trash.
None of the languages in your pic are "C influenced" though.
>>
>>61142472
can you explain your code please
>>
>>61142757
What is a "meme"
>>
>>61142734
Does C see much use these days? I never seem to hear about it.

>>61142744
Should I learn something else first to make it easier to learn?
>>
>>61142707
Not at all. You don't learn "bad fundamentals" from a language. I think you should do OCaml (Real World OCaml), then C (Modern C or C: a modern approach) and finally C++17 (cppreference).
>>
File: anime_varg.png (2MB, 1920x1080px) Image search: [Google]
anime_varg.png
2MB, 1920x1080px
>>61142776
Stop saving my screenshots and crops.
>>
>>61142800
It depends, why do you need to learn C++ to begin with?
>>
File: 1493270417104.png (587KB, 644x664px) Image search: [Google]
1493270417104.png
587KB, 644x664px
>>61142807
That sounds like a solid strategy.
>>
>>61142800
>Does C see much use these days
Yes, lots. It's just not as visible on shithub and stackoverflow
>>
>go to HackerNews
>want to kill self 10 minutes in
>>
File: 1478822164632.gif (2MB, 600x600px) Image search: [Google]
1478822164632.gif
2MB, 600x600px
>when you're programming and you look down and there's a spider on your foot
>>
>>61143001
what's the matter, are you a strayan?
>>
>>61139150
> what C is to modern computer architecture.
C is, compared to modern architecture, an oversimplification.

So I'm not sure any way in which this analogy makes sense
>>
>>61143001
That's why I always wear shoes when I program
>>
>>61142952
Literally only go to /g/ and my langs official sites for news.
>>
File: 1362960884713.png (28KB, 499x322px) Image search: [Google]
1362960884713.png
28KB, 499x322px
>>61143030
>the official C website
>>
>>61143028
>shoes
>not programming socks
>>
>>61143056
suckless
>>
>>61143056
I dont use C
>>
Are there any languages out there with better documentation and references than C/C++?
>>
>>61143100
java
>>
>>61143100
Emacs Lisp
>>
>>61143106
this, but C++ is good too
>>
File: 1490172246396.webm (3MB, 600x338px) Image search: [Google]
1490172246396.webm
3MB, 600x338px
>>61143068
You think socks would protect you from this?
>>
based on the column names of various csv files, how could I concatenate all of them into a single one? (keeping only the first row as the column name)
>>
>>61136944
Reminder that anime is a means to an end. A tool.

If you're not already well-versed in another useful topic, you're the definition of a weeaboo.
>>
>>61143166
It's true, the wife and I always watch some anime to get in the mood. It keeps the sex fresh.
>>
>>61143135
Literally hell
>>
>>61143210
No, I'm pretty sure it doesn't rain spiders in hell. You have to go to Australia for that kind of thing.
>>
what e-reader do you use to read your pirated programming books?
>>
File: brainlets_on_suicide_watch.png (761KB, 1186x860px) Image search: [Google]
brainlets_on_suicide_watch.png
761KB, 1186x860px
>>61136921
True.
>>61136944
Also true.
>>61143166
Also also true.
Feels good to be physics masterrace.
>>
>>61143268
SumatraPDF works for me. Minimalist and supports all kinds of file types.
>>
I need to run a program in the background of my program, so used popen.
This works really well, but I can only close it when the process prints some text.
What is the correct way to do it if I want to kill the process at any time for a process that is mostly silent?
>>
>+300
We need a new thread now!
>>
>>61143371
No we don't
>>
File: 1498158392899.jpg (313KB, 848x565px) Image search: [Google]
1498158392899.jpg
313KB, 848x565px
I'm trying to figure out why I'm getting an "RPC server is unavailable" when trying to use WMI in Powershell. Can anybody help?

Function Get-UserRSOP ($UserName) {

$pcs = Get-ADComputer -filter {name -like "FOOBARWKS*" -and enabled -eq "true"} | Select-Object name
Write-Host ("Finding PC for " + $UserName + "...")

foreach ($pc In $pcs)
{
if (@(Get-WmiObject -ComputerName $pc.name -Namespace root\cimv2 -Class Win32_ComputerSystem -ErrorAction Stop )[0].UserName -eq ("FOOBAR\" + $UserName))
{
$GPM = New-Object -ComObject GPMgmt.GPM
$Constants = $GPM.GetConstants()
$gpmRSOP = $GPM.GetRSOP($Constants.RSOPModeLogging, $null, 0)
$gpmRSOP.LoggingComputer = $PC.name
$gpmRSOP.LoggingUser = $UserName
$gpmRSOP.LoggingFlags = $Constants.RsopLoggingNoUser

Write-Host ("Getting RSOP for " + $UserName + "...")
$gpmRSOP.CreateQueryResults()

Write-Host ("Generating HTML report in \\FOOBAR\ResultantSetOfPolicy_" + $UserName + ".html...")
$gpmRSOP.GenerateReportToFile($Constants.ReportHTML, "\\FOOBAR\ResultantSetOfPolicy_" + $UserName + ".html")
}
}
}


That results in:
Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:8 char:15
>>
if /dpt/ dies all trannies die with it
>>
>>61143493
I hope so
>>
>>61140842
What the downside? Literally nothing. Someone already made the compiler, made the interface easy to use, mad it faster in all cases over the interpreted version (in terms of Lua or JS, or whatever). Not to mention a REPL is nice to have when scripting so you can make minor adjustments and immediately see the results.

All your other points aren't actually true.
>hard to optimize
Everything available to a static compiler is available to a JIT, and profiling allows for additional optimizations based on runtime information.
>unpredictable
This is a good thing, optimizes to the actual use, not the expected
>cost you time
literally how?

The only downside is profiling overhead.
>>
>>61143622
>literally
Yes, I am cucked.
>>
/!\ A L E R T /!\

New thread

>>61143699
>>61143699 >>61143699
>>61143699 >>61143699 >>61143699
>>61143699 >>61143699
>>61143699

/!\ A L E R T /!\
>>
>>61136976
Except he does you fucking idiot.
alignas + __packed is your solution.
>>
>>61142787
Basically, line by line it's:
1. Load the current bytecode instruction (located in the "program" array at an offset given by the "program counter" variable) into the accumulator (main register of the processor).
2-3. Compare the bytecode instruction with the hex value 0xff (255 in decimal).
4. If the comparison operands in the previous instruction compare equal (i.e. the current instruction has a value of 255), then jump to a label that will exit the program. Otherwise go to the next step.
5. Increment (add one to) the "program counteR" variable so it indicates the next instruction.
6. Return to the beginning of the "handle instruction" loop.

The equivalent C code would look something like:

while(true) {
if(program[pc] == 0xff) exit();
pc++;
};

with 'program' being an array of bytes representing the bytecode instruction, pc being an integer index into the array, and exit() being the standard CRT exit function. I just used assembly for example to show that even under the most optimistic assumptions, a bytecode "instruction" would require several CPU instructions to interpret, meaning it would probably entail at least an order of magnitude of slowdown compared to native code.
>>
>>61142800
>Does C see much use these days?
It's not commonly used for high-level application development, but a lot of libraries are written in it, it's the standard for writing operating systems and software for embedded devices (smartphones tend to use a higher level language these days, but older phones as well as simple devices like microwaves and DVD players are probably programmed in assembly or C) and largely for legacy reasons it's still the main language of a lot of GNU/Linux tools.

>>61143622
>Everything available to a static compiler is available to a JIT, and profiling allows for additional optimizations based on runtime information.
>>cost you time
>literally how?
Compiling stuff takes time. With a JIT you have to either accept a delay every time you run the program, or accept less intensively optimized code that doesn't run as fast. It usually has a clear advantage over regular interpreted code (though there may be a bit more of a delay up-front, rather than spread throughout runtime), but can't compete with regular pre-compiled code. Also, if the JIT compilation is only done as needed (i.e. not compiling a function until it's called), that does spread out the compiling delay, but it can reduce opportunities for whole-program optimization.
>>
>>61138415
>malloc
Lmao fuck off.
Don't heap allocate for no good reason.
>>
>>61138484
>give them alphanumeric names, and invoke them as functions.
No, you can just overload the operators.
>>
>>61144032
>wanting to waste RAM
>>
>>61144109
Are you brain damaged?
>>
>>61144131
unused RAM is wasted RAM :^)
>>
>>61138483
>>61138500
#include <iostream>
struct S {
// three-bit unsigned field,
// allowed values are 0...7
unsigned int b : 3;
};
int main()
{
S s = {7};
++s.b; // unsigned overflow (guaranteed wrap-around)
std::cout << s.b << '\n'; // output: 0
}


#include <iostream>
struct S {
// will usually occupy 2 bytes:
// 3 bits: value of b1
// 5 bits: unused
// 6 bits: value of b2
// 2 bits: value of b3
unsigned char b1 : 3;
unsigned char :0; // start a new byte
unsigned char b2 : 6;
unsigned char b3 : 2;
};
int main()
{
std::cout << sizeof(S) << '\n'; // usually prints 2
}


fucking sexy as hell

inb4 retarded rust shills
Thread posts: 340
Thread images: 35


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.