[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: 322
Thread images: 37

File: mokou_k&r.png (161KB, 392x462px) Image search: [Google]
mokou_k&r.png
161KB, 392x462px
What are you working on, /g/?

Old thread: >>59666918
>>
First for Javascript
>>
>>59672986
First for C AND Lisp
>>
>>59673013
& or &&?
>>
>>59673029
&&&!
>>
>>59673062
haha you memester :33!
>>
C, C++ and OCaml are the only white man's languages.
>>
So functional fags, can you sell me Idris? Why would I need theorem proving facilities in a general purpose language and in general why should I learn it?

I have a lot of free time lately so I may try to learn it
>>
File: dt170331.gif (114KB, 900x280px) Image search: [Google]
dt170331.gif
114KB, 900x280px
LOL
>>
>>59673105
OCaml is for faggots
>>
>>59673110
>I have a lot of free time lately so I may try to learn it
Well you're gonna need it because thanks to all the retarded abstractions you probably spend more time compiling than writing your programs. If you want to prove theorems relatives to your code, use Coq or Isabelle and export to a saner language.
>>
File: 1362276663661.png (14KB, 494x495px) Image search: [Google]
1362276663661.png
14KB, 494x495px
>>59673094
:3
>>
Really wanna get into learning the meme-language.

Trying to come up with ideas for suitable projects is hard though. The same issue I usually have with C++.
>>
>>59673110
Theorem proving is how you verify that a program meets a specification. Dependent types let you write very expressive specifications.
>>
Posted this in last thread not too long ago:

Anyone able to help me with my Java program? It's shitty but due in soon and all I have to do is implement a betting system.

I can send you the folder of everything you need to have a look at it through email.

Thanks in advance
>>
>>59673131
Can you explain dependent types to someone having just a basic grasp of Haskell?
>>
>>59673230
>>59667161
>>
(1 << 31) == (1U << 31)


true or false?
>>
>>59673145
post a link to the files and your problem. I'll take a look
>>
>>59673242
True
>>
File: 1477031585182.png (813KB, 1280x720px) Image search: [Google]
1477031585182.png
813KB, 1280x720px
Friendly reminder that Rust is for straight white level-headed men.
>>
>>59673279
>straight
>posts animu
>>
Hi
I'm new to programming
What should I learn ?
>>
>>59673303
It's a female, just in 2 dimensions which makes it better.
>>
>>59673279
>straight
>white
You mean bisexual. That's how you call white men who are attracted to women.
>>
>>59673273
is the 1 in (1 << 31) promoted to unsigned? if not, won't the value be undefined because of signed overflow?
>>
>>59673321
Are you somehow implying that women are men? because I don't understand your post otherwise.
>>
>>59673311
programming
>>
>>59673242
If the left is signed, False.
>>
>>59673230
basically a type dependent on a value. For example in Haskell you can say "this function takes in a list" but you can't say "this function takes in a list of length exactly 4." likewise you cant say "this function takes in an even number." of course you can get around that with custom types and smart constructors.
>>
>>59673311
>What should I learn ?
To fucking kill yourself.
>>
>>59673311
java and C++ are good

whatever you do, don't start with python or haskell

https://docs.oracle.com/javase/tutorial/
>>
File: 1478838811226.png (165KB, 327x316px) Image search: [Google]
1478838811226.png
165KB, 327x316px
>>59673389
>java and C++ are good
>>
>>59673242
Left one overflows, so false.
>>
What is the most redpilled programming language?
>>
>>59673329
Yes, I believe so by the standard. I went to check as well:
unsigned x = 0xFFFFFFFB;
int y = -5
cout << (y == x) << endl;

Returns true
>>
>>59673241
>>59673362
Meh, I guess I'll take a look
>>
File: smugpepe.jpg (37KB, 788x685px) Image search: [Google]
smugpepe.jpg
37KB, 788x685px
>>59673311
Hello new friend
You should start with Java, because then you can learn javascript (an extension of java) which is the most powerful language out there!
>>
File: 594854.jpg (15KB, 261x264px) Image search: [Google]
594854.jpg
15KB, 261x264px
>>59673410
>unironically using greentext to quote someone
>>
>>59673311
C, because you'll be forced to learn how some things in high level programming languages work. Then you could go C#, since it has C-like syntax, more modern than Java and evolving unlike Java.
Learn the basics, then go OOP.
>>
>>59673478
*physical pain*
>>
>>59673490
Why would you deliberately regress?
>>
>>59673440
Anything OOP, because if you try it, you can't go back. xd
>>
>>59673499
>regressing
Try writing maintainable game or database application with C.
You just don't
>>
>>59673557
I was referring to "then go OOP".
>>
If I can easily solve all SICP exercises am I MIT-level?

:^)
>>
>>59673564
Since when is OOP regressive?
>>
>>59673572
MIT is not some next step in human evolution
>>
>>59673591
Always has been and always will be.
>>
>>59673311
I'd suggest starting out with C. Make sure to learn about structs.

When you move to C++, think of it as being like C except you have "classes" which are basically structs except that the functions needed to operate on them are fields of them, functions that are fields of a class are passed a hidden "this" parameter that points to the instance they're to operate on, and fields can be "public" which is like you're used to or "private" which means they can only be accessed from the aforementioned field functions.

When you move to Java, think of it as being like C++, except everything is implicitly passed by pointer and you don't have to manually free anything.
>>
>>59673591
>Since when is OOP regressive
>>59673557
>Try writing maintainable game or database application

Games should be written using the entity-component-system paradigm, not OOP. Database applications should be written in database languages, not OOP.
>>
>>59673608
>move to Java
That would be a horrible mistake
>>
File: SICP.png (384KB, 1024x768px) Image search: [Google]
SICP.png
384KB, 1024x768px
>>59672986
Some light reading.
>>
>>59673366
You will not divide us
>>
>>59673311
Learn C. Once you understand C you can understand pretty much every other programming language easily.
>>
>>59673633
>Games should be written using the entity-component-system paradigm
I prefer to just call it procedural.
>>
>>59673674
us /= 2; // where is your god now
>>
File: 1490833599030.png (728KB, 960x776px) Image search: [Google]
1490833599030.png
728KB, 960x776px
>>59672986
Exhausting the shit off my brain solving exercises on Haskell

(I'm new to programming, and i've just gotten into college of Science of Computing)
>>
File: 1490340835473.jpg (340KB, 1024x576px) Image search: [Google]
1490340835473.jpg
340KB, 1024x576px
From last thread

>>2017
>>D still can't read a single character input from stdin
>This is literally killing me inside out

>Just WHY

void main(string[] args)
{
import std.stdio : readf, writeln;
char c;
readf("%c\n", &c);
c.writeln;
}


or you can call into the C library if you want
>>
>>59673734
But that's not what it is. It's not procedural, it's data-oriented. And it's not just data-oriented, it's the entity-component-system paradigm. Other data-oriented approaches don't tend to work as well.
>>
>>59673753
That's not a single character input, that's a two-characters input, and one of them has to be a newline.

When will D be able to read a single-character input typed in without pressing Enter?
>>
>>59673633
I meant OOP languages, f.e. C++, C#, Java.
However "database languages" like SQL can't be used to write any application. You still need some other language preferably, an OOP one like Java or C# with Entity Framework or equivalent.
>>
>>59673756
ECS is very procedural. You split the data from the code and composition is your main method of reuse. Data-oriented design is something that lends itself well to ECS but it isn't necessary for it.
>>
>g++ -O3 > 20MB
>g++ -Os > 12MB
>strip -S > 10MB
>upx -9 > 300KB
holy shit what is this wizerdry!?
>>
>>59673633
>entity-component-system
>not OOP
that's a subset of OOP you dummy
>>
>>59673778
Is there a language that can do that?
>>
>>59673874
C
>>
>>59673889
Post code
>>
>>59673889
You have to press enter though
>>
>>59673756
>its not oop its just data with methods bound to it!
>>
char* str = "hello";

>assigning a string literal to a string gives a warning in C
defend this
>>
>>59674017
const char*, not char*
>>
>>59674017
try
*str = 'H';

you were warned
>>
>>59674017
because they are immutable
>>
>>59673242
True
>>
File: 324497029_870418510c_o.jpg (242KB, 1250x937px) Image search: [Google]
324497029_870418510c_o.jpg
242KB, 1250x937px
void main(string[] args)
{
import std.stdio : readf, writeln;
import core.sys.posix.termios;
import core.sys.posix.unistd;
char c = 0;
termios oldt, newt;

tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;

newt.c_lflag &= ~(ICANON);

tcsetattr(STDIN_FILENO, TCSANOW, &newt);

while(1)
{
readf("%c", &c);
if (c == '\n') break;
c.writeln;
}

tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
}


t. Stack Overflow
>>
File: IMG_1077.jpg (514KB, 3000x2000px) Image search: [Google]
IMG_1077.jpg
514KB, 3000x2000px
Got this book lying around for quite some time now.
Guess Ima start actually reading it. Only read a few pages of it til now.
>>
>>59674158
>zed shaw
you got meme'd
>>
>>59673894
Not this guy but you can achieve this by setting the terminal in non canonical mode. There is documentation around. That's how libraries like nurses are made.
>>
File: 5CJTPZ4.jpg (466KB, 1600x2200px) Image search: [Google]
5CJTPZ4.jpg
466KB, 1600x2200px
>>59673756
>And it's not just data-oriented, it's the entity-component-system paradigm.
And it's not just the entity-component-system paradigm, it's Prince Herman in a can.

You should let him out.
>>
>>59673874
>>59674147
std::cin.get()

get on my level.
>>
>>59673894
>>59673900
https://stackoverflow.com/questions/32781937/getting-a-single-character-without-pressing-enter
>>
>>59674248
That's not what he was asking for
>>59674259
Yeah, I figured it out >>59674147
>>
>>59673737
>
where is your god now

I don't know, was God in the first half or the second half?
>>
>>59674306
>Yeah, I figured it out
Congrats!
>>
>>59674309
In none, because he doesn't exist.
>>
>>59674368
atheist nigger
>>
>>59674375
Oxymoron
All blacks are inherently religious and religion is inherently black
>>
>>59673674
HWNDU was such cringe lol
>>
https://www.youtube.com/watch?v=PeXEWsobJRE

loooooooooool
>>
>>59674421
Desert religions are inherently black*
The non-desert religions are fine.
>>
JVM or CLR
>>
>>59674537
OK then, Odin worship and Svetovid worship is not black.
But the desert trilogy (jew->christian->muslim) is blacker than KFC+purple drank+watermelon combo.
>>
reminder that vundle is a piece of shit.
>>
>>59674544
>poop or turds
>>
>>59674525
better vid

https://www.youtube.com/watch?v=vw9zyxm860Q

my sides
>>
>>59674525
>>59674630
This thread is about programming
>>
>>59674642
poo in loo
>>
>>59674544
JVM by far

microsoft is so fucking shit like you can't even imagine
>>
c or c++ as a beginner?
>>
>>59674693
C++

C is outdated trash for brainlets
>>
>>59672986
testing my vector2/matrix code
io::keyboard keyb { std::make_shared<io::ps2_interface>() };

chrono::chrono::setup_pit(true, 0x1000);
chrono::chrono::setup_tsc(10000);
using clock = chrono::tsc;

dpmi::mapped_dos_memory<std::uint16_t> screen_ptr { 80 * 50, dpmi::far_ptr16 { 0xB800, 0 } };
matrix<std::uint16_t> screen { 80, 50, screen_ptr.get_ptr() };

fixed_matrix<std::uint16_t, 80, 50> m { };
m.fill(0x1000);

auto r = m.make_range({ 5,5 }, { 70,40 });
r.fill(0x2000);

vector2f delta { 0,0 };
vector2f player { 20,20 };
auto last_now = clock::now();
while (true)
{
auto now = clock::now();
float dt = (now - last_now).count() / 1e9f;
last_now = now;

using namespace io;
vector2f new_delta { 0,0 };
keyb.update();
if (keyb[key::up]) new_delta += vector2f::up();
if (keyb[key::down]) new_delta += vector2f::down();
if (keyb[key::left]) new_delta += vector2f::left();
if (keyb[key::right]) new_delta += vector2f::right();
if (keyb[key::space]) r.fill(0x2000);
if (keyb[key::esc]) break;

new_delta.clamp_magnitude(1);
delta += new_delta;

r(player) = 0;
player += delta * dt * .2f;
r(player) = 0x0F02; //
delta -= delta * dt * 2;
screen.assign(m);
thread::yield();
}
return 0;

(don't mind the shitty frame rate, virtualbox video capture only goes up to 30fps)
>>
>>59674709
isn't c considered like the most robust and reliable?
>>
>>59674741
> C or C++ was ever considered robust or reliable
????
>>
File: 1488850051000.jpg (396KB, 1175x2048px) Image search: [Google]
1488850051000.jpg
396KB, 1175x2048px
I made a simple collab drawing app.

http://52.56.197.112/d/u7fx34lb8wwfuk3z

Still in early stages. Will be accessible via drawy.io once I figure out how to get the node.js server running / restarting automatically, probably in the next few hours.
>>
>>59674768
i don't know. i'm a beginner. that's why i'm asking.

thx tho
>>
>>59674782
Pfff pretty gay
>>
>>59674801
It's sanic fast due to how much unspecified behavior can you invoke and how low level it is.
But it's about as robust and reliable as you can guarantee with static analysis tools (not bundled with compiler).
>>
File: 1470950158496.jpg (111KB, 1252x1252px) Image search: [Google]
1470950158496.jpg
111KB, 1252x1252px
I don't even know what to program anymore. My skill is just going to waste.
>>
>>59674630
this channel is fucking gold thank you
>>
I'm learning opengl with sdl2 and glew, with some glm for comfy in c++. Might make a game when I get the basics.
>>
I thought Python generators were meant to be fast?
>>
File: America.png (765KB, 1099x571px) Image search: [Google]
America.png
765KB, 1099x571px
>>59672986
Why no work help pls
def count_letter(ltr,string):
count=0
for i in string:
if i==ltr:
count+=1
print(count)
return count
>>
>>59674896
I think you have to give the for statement a range
>>
>>59674896
print(len([x if x == ltr for x in string]))
>>
>>59674711
Although you cant post code as easily, /agdg/ might like your project more than /dpt/. Theres a few others doing emu games as well.
>>
>>59673650
>SICP
>light reading
WEW LAD
>>
>>59674885
>glew
absolutely disgusting
>>
>>59674976
What would you do instead of glew? The horrible tedious process of defining them yourself?
>>
File: Crawling_in_my_Crawl.jpg (22KB, 480x269px) Image search: [Google]
Crawling_in_my_Crawl.jpg
22KB, 480x269px
>>59674576
>not worshiping vishnu
>>
>>59674857
Sudoku solver
>>
>>59674976
y
>>
>>59675036
Somehow I don't find it weird that a board known for Windows shilling has people into Hinduism.
>>
>>59675073
every morning he wakes up and creates the universe

over the course of the day he oversees and protects it

at night just before going to sleep he destroys it

each of these tasks is also done by three different people

(they're all him though)
(also the morning daytime and night being discussed is in a trans-temporal notion of days)
>>
File: 1472233917561.jpg (83KB, 898x1097px) Image search: [Google]
1472233917561.jpg
83KB, 898x1097px
>>59675105
>trans
>>
File: undefined.png (372KB, 742x614px) Image search: [Google]
undefined.png
372KB, 742x614px
>>59674955
thanks, posted it there too.
>>
I need some help.

I'm working with an Eventbrite API, and my client wants to be able to click a button and get a list of all the users on their website that registered for one of their Eventbrite events.

The only issue is that if I try to get the information for more than 15 events at a time I get a 500 internal server error.

What's the best way to keep the server from shitting itself when running a bunch of PHP scripts at once?
>>
>>59675123
that's not what i meant

however we should accept the transgenders because they are only fulfilling the purpose to which vishnu has assigned them by way of the nature of what they are

they probably have bad karma from past life and that is why they are stuck with a kind of nature of being which inclines them toward performing task so dehumanizing as being ladyboy

some people are worse than trans, they are reborn as bee

do not squish bee?
do not hate on trans
>>
>>59675216
*tips poo*
>>
>>59673853
Why do people say this? ECS has nothing to do with OOP.

>>59674015
Functions can't do anything if not on data. OOP is specifically encapsulating data and methods into objects. ECS is procedural and separates the functions from the data, although the functions still take the data as inputs/outputs.
>>
>>59675216
squish bee
>>
>>59673831

-O3 optimizes for speed, -Os optimizes for application size. Obviously, -Os will produce a smaller binary. Strip removes sections of the executable normally only needed for debugging. Finally, upx compresses the application. At this point, you're not actually optimizing things. Think of it like you're creating a zip inside of your executable, and a small bit of stub code to unpack it, and the zip contains the rest of the program.
>>
>>59675261
no plis :-(
>>
>>59674896
count_letter = lambda ltr, string:  list(string).count(ltr)
>>
File: flat,800x800,075,f.jpg (42KB, 800x522px) Image search: [Google]
flat,800x800,075,f.jpg
42KB, 800x522px
>>59675216
>they are reborn as bee
ur damn right nigga
>>
>>59674017

Mutable pointer to immutable data. If you want to store a string literal on the stack, use a char array.
>>
>>59675246
>Entity: The entity is a general purpose object.
>Component: the raw data for one aspect of the object
>object
>ECS follows the Composition over inheritance principle
>Composition over inheritance (or composite reuse principle) in object-oriented programming is the principle that classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class.[2] This is an often-stated principle of OOP, such as in the influential book Design Patterns.[3]
>>
>>59675281
I know how it works, I just found it fascinating how upx just strips away 98% of the entire binary size.
>>
>>59675304
and if you want to store a string literal on the heap use memcpy
>>
>>59672986
Ive written a custom error handler for my game.
https://my.mixtape.moe/paiiiu.webm

hirosimoot vp9 pls
>>
>>59675328
That's a really poor definition that only reflects the bad object-oriented implementations like Unity's. Composition over inheritance taken to the extreme is not using OOP at all, too.
>>
File: xN76md9.jpg (101KB, 555x712px) Image search: [Google]
xN76md9.jpg
101KB, 555x712px
>>59675363
>>
>>59675392
>Imgur filename
>scumbag steve exploitable
>>>/r/eddit
>>>/f/acebook
>>
File: efe.jpg (65KB, 544x960px) Image search: [Google]
efe.jpg
65KB, 544x960px
>>59675412
>>
>>59675427
What does this have to do with ECS, OOP, or programming at all?
>>
>>59675427
Pol Pot ain't communist.
>>
>>59675392
>called dictatorship "communist"
Source?
>>
>>59675328
Better definitions:
>Entity: The entity is an index.
>Component: a table of procedures and properties indexed by entity
>System: a procedure responsible for making proper use of component procedures
>>
>>59675435
>ECS isn't OOP
>unity uses ECS
>it's OOP
>i-it doesn't count
>only my specific brand of ECS which only exists in my deluded mind counts as ECS
>>
>>59675490
>>Entity: The entity is an index.
object reference
>>Component: a table of procedures and properties indexed by entity
vtable
>>System: a procedure responsible for making proper use of component procedures
methods
>>
>>59675490
I don't like this formulation either. What happened to structs and procedures?

>>59675493
How about this: good ECS isn't object-oriented.
>>
>>59675518
http://www.thesaurus.com/browse/entity
>Synonyms for entity
>object that exists
>>
Can someone enlighten me on lambdas and why I should care about them?
>>
>>59675541
>when people use the word "object" in English it means muh Java objects

>>59675548
They're values that represent code rather than data.
>>
>>59675551
>when people use the word "object" it means muh java inheritance
>>
>>59675548
lambdas are function pointers with disgusting syntax and you should disregard them
>>
>>59675564
OOP without inheritance is possible but without encapsulation (which is what makes object-oriented ECS so bad) you don't have OOP anymore.
>>
>>59675548
see example (note mine)
>>59674953
>>
File: 99b.gif (3MB, 623x350px) Image search: [Google]
99b.gif
3MB, 623x350px
>>59674782
FlockDraw killa
>>
>>59675513
>vtable
agree
>methods
agree
>object reference
What is the object here?
The point is that there is none. An entity BEHAVES like an object reference, but the need for an actual object to exist has been abstracted out.
>>
File: 1424105125282.jpg (40KB, 500x484px) Image search: [Google]
1424105125282.jpg
40KB, 500x484px
Option 1:
Write project in C and have to write a lot of data structures to complement the design just to get started on the actual project

Option 2:
Write in C++ and use standard library and other libs that give most of the functionality


what is better in the long run?
>>
>>59675672
Rust
>>
>>59674782
Fucking win
>>
>>59675679
fuck off rustfag
>>
>>59675679
What do I get out of Rust that I can't in C?
>>
>>59675577
Correction: lambdas are pointers to anonymous functions defined in the same operation as that in which the pointer is retrieved, and this inline definition may be achieved indirectly by composition from preexisting lambdas, and you should use them because they are the cornerstone of advanced functional programming.
>>
>>59675702
Abstraction
Safety
>>
>>59675672
>have to write a lot of data structures
You know there exists multiple different libraries that provide data structures and lot more like glib, tbox, qlibc, cprops, klib, ...
>>
>>59675712
Abstraction is bad though in most cases.
>>
>>59675712
>Safety
Not with LLVM which effectively optimizes your safety away
>>
>>59675702
30 hours not debugging memory errors.
>>
>>59675707
Lambdas are anonymous functions. Function pointers are pointers to executable code. In many cases you use a function pointer (at least under the hood) to point to the executable code of a lambda, but function pointers aren't necessary.
>>
File: 2.png (24KB, 142x132px) Image search: [Google]
2.png
24KB, 142x132px
>>59675672
>Option 3: write project in C with no data structures, inline needed algorithms and perform them directly on memory
>>
>>59675735
Learn to use pointers correctly
>>
my 2 digit iq brain cant fucking understand how to solve this problem
im just so goddamn stupid, everytime i try arrays it python screams at me that they are going out of range

 def check_for_replies():
check_this = str(get_shitpost())
num_of_hits = len(re.findall('>>8\d{5,}', check_this))
new_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), check_this, 1)
if num_of_hits == 2:
new2_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new_check_this, 1)
return new2_check_this
if num_of_hits == 3:
new2_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new_check_this, 1)
new3_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new2_check_this, 1)
return new3_check_this
if num_of_hits == 4:
new2_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new_check_this, 1)
new3_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new2_check_this, 1)
new4_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new3_check_this, 1)
return new4_check_this
if num_of_hits == 5:
new2_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new_check_this, 1)
new3_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new2_check_this, 1)
new4_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new3_check_this, 1)
new5_check_this = re.sub('>>8\d{5,}', ">>" + get_random_reply(), new4_check_this, 1)
>>
>>59675722
Rust has zero-cost abstractions for the most part. It's the fastest language behind C, even faster than C++.

>>59675728
LLVM's optimizations can't change the behaviour of the program unless you are already doing something unsafe and depending on undefined behaviour.
>>
>>59675749
>learn
>use
You are talking to rustfag. They are unable to learn and they don't even program in the language they shill for.
>>
>>59675672
OCaml
>>
>>59675749
>im the perfect programmer and have never made a mistake
alright lad
>>
If I want to compound all the bitflags in 3 different bitfields, I can just do this right?

short vec = col | row | box[i/3][j/3];


I'm rewriting my sudoku solver with bitwise arithmetic.
>>
File: 1481100956747.jpg (33KB, 400x387px) Image search: [Google]
1481100956747.jpg
33KB, 400x387px
Can't we just all get along?
(Python is shit though)
>>
>>59675766
>doing something unsafe
*doing anything useful
>>
>>59675735
>>59675777
You just need better unit tests
>>
>>59675775
>OCaml
Enjoy your GIL faggot
>>
>>59675801
you mean a non-shit language
>>
>>59675792
99% of the time writing Rust you don't need to write any unsafe code yourself since it has already been written as part of the libraries you are using. Otherwise it's the same as C where you have well-defined behaviour and undefined behaviour. If you're depending on undefined behaviour that's your mistake.
>>
>>59675813
>your GIL
My what?
>>
>>59675818
In other words, the libraries you are using may break instead of you own code. Doesn't sound much better.
>>
>>59675818
>99% of the time writing Rust you don't need to write any unsafe code
Actual rust devs would disagree. All the talks ive watched. They all make a joke about lots of unsafe blocks
>>
>>59675790
I like Java.
>>
>>59675837
Even in unsafe Rust you still have all the regular type/lifetime rules. The only difference is that you can dereference arbitrary pointers, access static variables, and call foreign functions. It's much easier to write correct unsafe code in Rust than it is in C because you still use safe constructs as much as possible.

>>59675841
People doing talks on Rust are generally using it in more advanced and systems programming scenarios where unsafe is more prominent. For regular application development you probably won't need any unsafe.
>>
What is man supposed to use when here's just no good statically typed and compiled language that doesn't require huge vm like java or c#.
>sml
no good implementaion
>ocaml
sml with shitty syntax, also does not support native threads
>lisp
too verbose
>c
decent but manual memory management is annoying in prototyping phase
>sepples
cluster fuck that no sane person would touch
>d
can't decide if it wants to have gc or no
>rust
better stay away from it because it attract lot of crazy hipsters
>>
>>59675903
>using it in more advanced and systems programming
>For regular application development you probably won't need any unsafe.

Do you see the problem here?
>>
>>59675903
>dereference arbitrary pointers
>easier to write correct unsafe code
pick one
>>
>>59675907
>lisp
>too verbose
nice shitposting senpai
>>
>>59675919
No.

>>59675928
The point is that those are the only three things you ever need to worry about doing correctly without the help of the type/lifetime system.
>>
>>59675907
>lisp
>verbose
>>
>>59675907
>lisp
>too verbose
scheme
>>
>>59673311
>Assembly
>Java
>PHP
>C (and dérivatives like C++, C# and Objective C)
>>
>>59675940
(let ((v (make-vector 5)))
(setf (aref v 0) 10)
v)

int v[5];
v[0] = 10;
>>
>>59675907
One of these complaints is not like the others.
>>
>age
>years of programming experience
>fav lang
>job/student/NEET
>virgin
>>
>>59675988
20
10
Rust
Student (maths)
No
>>
>>59675969
That's not verbose though
>>
>>59675988
19
~10 but it's been on and off other than the last three years
python
student
i literally forgot how many partners i've had if that tells you anything
>>
>>59676023
>~10
stop
>>
>>59676033
I'm really not lying, when I was a kid I was obsessed with botting runescape and used botting software to bot runescape.

Fuck it's a miracle i'm not a virgin huh?
>>
So what's the deal with functional programming? Is it just a meme or do people genuinely prefer it to other paradigms? For what kind of projects would it be better than OOP for instance?
>>
Java opened my eyes to how OOP promotes bad design

Common Lisp opened my eyes to the power of a good macro system

Rust opened my eyes to how unsafe C really was!
>>
>>59676049
>with botting runescape and used botting software to bot runescape.
So you have 10 years as a skiddy
>>
>>59675988
Nice try Jewgle
>>
>>59676056
Everything.
>>
>>59672986
Text Adventure in python.

I want the room description be a function/method or a script for maximum flexibility.

But I don't know how to do it, without deriving a new class from Room for every single room I create.

Example:

class Room_001 (Room):
def description(self):
>>
>>59676049
>>59676033
The language I used was somewhat similar to pascal, it's actually still around. I'll link it if there's some interest.
>>59676061
Well, it was like an ide where you program your own routines, searching for colors with tolerance, etc. It's not like I was just using someone else's scripts, I built my own. I didn't say it was _good_ experience.

I work as a research assistant now.

>>59676056
Before you listen to anyone on the 4chans, just watch this.
https://www.youtube.com/watch?v=XrNdvWqxBvA
>>
>>59676057
>unsafe C
Quite a bit of the unsafeness in C is from the compiler optimizing it away, and rust has that problem too.
>>
>>59675907
crystal? nim?
>>
>>59676056

object.do_something(that)

vs.

do_something(object, that)
>>
>>59676113
memes
>>
In Haskell is it even possible to write an iterative function or do even simple functions have to be recursive
>>
>>59676084
Think of a class like a model. Then you create objects using that model.
class Room(self):
def __init__(self, title, description):
self.description = description
self.title = title
def __str__(self):
return self.title


Now we declare an object of class room

room_001 = Room('Room 1', 'The first room')


Got it?
>>
>>59676136
Clojure?
>>
File: ziggy.gif (969KB, 606x304px) Image search: [Google]
ziggy.gif
969KB, 606x304px
>>59676139
>In Haskell
>>
>>59675769
>they don't even program in the language they shill for
funny because it's true
>>
>>59676163
requires jvm
>>
>>59676174
go?
>>
>>59676056
Functional programming will make you realize it was the correct paradigm from the start. You have more power to define more precise programs with more expressive types.

Imperative programming has you doing things backwards with debugging types and side effects.
(pure) FP has you building your own types side-effect free. So you dont waste time with silly errors. Pick a language with dependent types and youll see for yourself. Going back is gross.
>>
>>59676139
All iterative functions are tail recursive. You can use combinators like folds if you really want to avoid writing something with recursive calls directly.
>>
File: 1486680826838.jpg (106KB, 895x746px) Image search: [Google]
1486680826838.jpg
106KB, 895x746px
>>59674782
Can I draw penises?
>>
>>59676106
This is called undefined behaviour and C has a hell of a lot more of it than Rust does. If optimization changes the behaviour of your program, you have a broken program!
>>
>>59676191
> :=
>automatically inserts semicolon
>no macros
>>
>>59676056
>>59676192
Data oriented programming is where performance is at.

FP is for people who don't care about how slow their shit is.
>>
>>59676222
The only thing I can think of is Rust. The language is good, but the community will kill it very soon.
>>
http://rustbyexample.com/primitives.html
>signed integers: i8, i16, i32, i64 and isize (pointer size)


>i8
>pointer size

so there's no way to get 1 byte data in Rust?
>>
>>59676224
There's nothing stopping you from writing data-oriented and functional code.

>>59676253
i8 and u8 are byte sized. isize and usize are pointer sized.
>>
>>59676224
>FP is slow
nice meme
>>
>>59676213
>C has more UB than rust
Try using "unsafe" rust and see how much the optimizers bite back at you.
>>
>>59676266
Not him, but you have to use something like 'nomangle' to prevent the compiler from screwing up your code.
>>
>>59676260
>>59676259
Good luck making a good performance engine with pure FP.
>>
>>59676192
I learned functional programming first and then transitioned from it to Java
It was glorious

(Tip for anyone who started off with functional programming: think of an object as being like a procedure closed around mutable locals, some of which are also procedures; depending on the parameters to the "object," it can expand to an invocation of one of these "sub"-procedures, which can then mutate and/or return the locals in various ways; and then, think of a class as like a procedure which creates and returns objects, and injects properties into the scope they close around that can identify them as instances of the class)
>>
>transitioned from it to Java
>It was glorious
you dont even deserve a fake (You)
>>
>>59675833
GNU Intermediate Language
>>
File: 123ertrsdfgsdf.png (171KB, 512x232px) Image search: [Google]
123ertrsdfgsdf.png
171KB, 512x232px
what did they mean by this
>>
>>59676393
Global Interpreter Cucklock
>>
>>59676266
I've never had problems. Likely you are making invalid assumptions and subtly violating Rust's rules, like obtaining a pointer from a mutable reference and then using the reference as an immutable reference yet still writing through the pointer. That could lead to a hazard.

>>59676311
Purity just means that you have no side effects. You can still do all your mutation and pointer arithmetic and manual memory management if you make the effects first class through monads, linear types, etc.
>>
>>59676159
But how do I make that object having a diffrent function/method/script than the class?

def description(self):
print "You are in the house"
print "What do you want to do?"
inp = raw_input()
if inp = "w":
print "not a good idea."


When I look at other professional games.
They implement scripts like this as a file.

Like a script which has a dialogue and choices.

I want every room to have it's very own special script or method. But creating an other class feels bothersome and not very elegant.

The idea of making a quick text adventure sounds fun, but I always stop when I'm at that point.
>>
>>59675847
Me too :)
>>
>>59676445
>subtly violating rules
Just like C
>>
>>59675988
>22
>3
>C
>student
>yes
>>
>>59676479
Shhh
>>
>>59676446
just define it's individual description as a function

class Room():
def __init__(self, description):
self.description = description

def room_001_desc():
print("Fuck me in my tight hole!")

room_001 = Room(room_001_desc)

room_001.description()


Get it? You can pass functions to properties of classes.
>>
>>59675988
>26
>16
>c++
>neet
>yes
>>
>>59675988
>22
>7
>hard to decide between C and Ruby
>student
>technically not a virgin (thanks dad)
>>
>>59675988
30
stop and go since I started with qbasic back in the day
none favorite, ruby language is pretty sexy though
NEET
yes
>>
>>59676567
lmao
>>
>>59676118
The first is OOP, the second is imperative. Neither one is functional. Functional is basically about encapsulating state inside functions, rather than inside classes.
>>
>>59676479
I guess it is a valid point that writing correct unsafe code in Rust can sometimes be tricky since you have to worry about the assumptions that are present in safe Rust that allow it to be optimized so aggressively. The C analogue of this issue is using "restrict" and violating the associated rules.

Most C programmers don't use "restrict" (and are thus not attaining the top performance they brag about on /dpt/) and thus aren't used to dealing with such things.
>>
>>59676588
(apply do-something (list object that))
>>
>>59675988
24
3
C for serious stuff, Python for scripting
PhD student
No
>>
File: Ritsuko_Akagi.jpg (28KB, 225x366px) Image search: [Google]
Ritsuko_Akagi.jpg
28KB, 225x366px
>>59675988
23
13
C
CS Student
Yes
>>
>>59676023
>19y/o
>i literally forgot how many partners i've had if that tells you anything
seems legit
>>
File: dpt.png (378KB, 1450x1080px) Image search: [Google]
dpt.png
378KB, 1450x1080px
I won't do it anyways, but I still want to roll.
>>
>>59676646
i'm a faggot, so it is, unfortunately
>>
>>59676588
Functional programming is not "about" encapsulating state within functions. That's just how closures capturing free variables works.
>>
>>59674693
C first, then C++ when you have a decent understanding of C.
>>
>>59674891
Yes.
>>
>>59676653
rolly
>>
>>59674896
The return is indented one level too deep/far.
>>
>>59676656
sorry for your butt :(
>>
On that note, how many self-styled master C programmers here that never ever make a mistake use restrict?
>>
>>59676656
>tfw I get judged because of people like you while I'm actually a permavirgin
>>
>>59676535
That's ridiculous though, if the only difference between the functions is the string they print. You should store the description in an instance variable and have that be printed by the describe() function.

class room()
>>
>>59676750
Just ignore that "class room()" at the bottom, I was going to provide example code but ended up desciding it wasn't needed.
>>
>>59676750
That's another way of doing it, but it sounded like that anon wanted to do more than just print the description.

I was just telling anon there's a way to define different functions and include them into an object model without creating a new model for each object lol.

>>59676745
s-sorry. it's not like i'm proud of being a degenerate
>>
File: Screenshot (19).png (108KB, 1920x917px) Image search: [Google]
Screenshot (19).png
108KB, 1920x917px
>>59674782
not bad anon
>>
>>59676844
ty
still needs some work to be a proper production server. This thing's got vulnerabilities like the sleeve of a wizard
>>
>>59676535

class Room:
def __init__(self, description):
self.description = description
self.variable = "a variable"

def room_001_description(self):
print "This is a test"
print "This is a variable: ", self.variable

room_001 = Room(room_001_description)

room_001.description(room_001)


Ok, managed to make it work and access the member variables, but it looks silly, and is a bit bothersome.
>>
>>59676888
there's probably a simpler way of doing this anon, but this will keep you going for now. Sorry if I wasn't enough help!
>>
>>59676750
It's just an example.

There can be more in the description( description may not be the perfect wording)

Skill test, dialogue branching, picking up items etc...
>>
>>59676599
>Most C programmers don't use "restrict"
And guess why?
There's no such thing in K&R.
>>
>>59676567
ouch
>>
this
create database jcoach;
use jcoach;
create table user (
id bigint unsigned primary key auto_increment,
name varchar(64) not null,
email varchar(64) not null unique,
pass_salt char(64) not null,
pass_hash binary(64) not null,
signup_verification_code char(8) not null,
verified boolean not null default 0,
date_registered timestamp not null default current_timestamp,
logged_in boolean not null default 0,
index (email),
index (date_registered) );
create table user_client (
id bigint unsigned primary key auto_increment,
ip int unsigned not null,
user_id bigint unsigned not null, foreign key (user_id) references user(id) on delete cascade,
date_last_used timestamp not null default current_timestamp on update current_timestamp,
unique key (ip, user_id),
index (ip),
index (user_id, date_last_used) );
create table goal (
id bigint unsigned primary key auto_increment,
label varchar(256) not null,
user_id bigint unsigned not null, foreign key (user_id) references user(id) on delete cascade,
index (user_id) );
create table goal_report (
id bigint unsigned primary key auto_increment,
goal_id bigint unsigned not null, foreign key (goal_id) references goal(id) on delete cascade,
date_written timestamp not null default current_timestamp,
positive boolean not null,
notes varchar(512),
index (goal_id, date_written) );
create table goal_obstacle (
id bigint unsigned primary key auto_increment,
goal_id bigint unsigned not null, foreign key (goal_id) references goal(id) on delete cascade,
label varchar(256) not null,
present boolean not null default 1,
date_last_present timestamp not null default current_timestamp on update current_timestamp,
index (goal_id, date_last_present) );
>>
>>59676953
Well I don't think there's any situation where you could say K&R C is better than Rust.
>>
>>59676913
Maybe one day, I will know how.
It's free advise so it's ok.
>>
>>59673311
No start with lua and love2d game engin its the best :)
>>
File: 1486669460245.png (581KB, 600x848px) Image search: [Google]
1486669460245.png
581KB, 600x848px
>>59676844

Can now access my app using http://www.drawy.io

If the DNS in your region has updated yet
>>
>>59676913
cool, found it

http://stackoverflow.com/questions/6478371/assigning-a-function-to-an-object-attribute

Thanks for the help!
>>
>>59677262
yeah that's perfect anon
>>
>tfw codemonkey that almost exclusively uses plain lists for everything
>>
>>59677294
Just like all lispers do?
>>
Which language should I learn if I want to be a condescending neckbeard who can't be memed at, but who can always meme at fucking normies and females for their bad choice of favorite language?
>>
>>59677350
C++
>>
>>59677350
all languages can be meme'd at, at least in the minds of the memesters

>>59677362
but this is your best choice
>>
>>59677350
C++
>>
>>59677350
rust
>>
>>59673242
Depends on the native integer size of the target
>>
>>59677423
>muh safety
>muh unwarranted elitism
>muh inferior C++ clone with no userbase outside of mozilla
>muh sjw
>>
Are there any anime's that have programming as a topic?

I'm weedbix weeb nigga
>>
>>59677452
>muh joke
>yur hed
>>
You know I'm looking through all this Rust documentation and I'm just sitting here thinking to myself why the fuck did they complicate so much of the syntax. Different ways to call static/non-static, printing has weird function names, all sorts of inconsistencies all over the place, weird fucking names for simple tasks. I mean fuck it just seems all over the place with how they designed this.
>>
>>59677589
Rust++ will take the borrow idea and do it better. Rust is just a building block language like haskell
>>
>>59677589
>Different ways to call static/non-static
a_class().an_instance_member_function();
a_class::a_static_member_function();
>>
>>59677589
>Different ways to call static/non-static
:: vs .? What's the big deal?

>printing has weird function names, all sorts of inconsistencies all over the place, weird fucking names for simple tasks
Like?
>>
>>59676056
How can any paradigm be a "meme"? What the fuck are you even trying to say?
>>
>>59677480
plenty but none of them actually know what programming is
>>
>>59676056
FP tards are hipsters who only like it because it's less popular, they feel special for using it, they compare themselves to the pooest pajeets to convince themselves that they're smarter than all non-FP programmers
>>
>>59677620
Strict syntax is important.
>>
What kind of programming is the Theano/Tensorflow calculation graph thing?
Still imperative?
>>
>>59677730
It is strict. :: is for namespaces and . is for UFCS. Presumably, using the same symbol for both would have lead to parsing ambiguity or something.
>>
https://fossbytes.com/microsoft-open-source-company-windows-office-free/

will you use microsoft products now?
>>
i kinda want to install arch again, but too lazy to spend an entire day setting things up
>>
>>59677809
>not having prepared files in case of new installation
>>
New thread:

>>59677821
>>59677821
>>59677821
>>
>>59677150
Had a good time, ty
>>
>>59677820
yeah, doing backups isn't my strongest side
>>
>>59677804
you got me you fucker
>>
File: VN.png (282KB, 490x639px) Image search: [Google]
VN.png
282KB, 490x639px
>studying math
>every CS student barely grasps highschool topics
>they even pull the "lol I hate math" shit
How can this be? It's so ugly and bizarre to me.
>>
>>59677904
normies are fucking pathetic. doesn't matter if you're a "nerd" when you're the one raking in the millions
>>
>>59677904
im CS on faculty of science and mathematics
50% of our exams are == math students exams
we hate and love math
depends which math is coz there are fucking too many of them
>>
>>59677066
I don't think anyone's ported a Rust compiler to the PDP-11 yet.
>>
>>59677362
>>59677417
>tfw you fell for the sepples meme
>>
>>59677804
I'm disappointed that I didn't get rickroll'd
>>
File: professional bitcoin trader.jpg (72KB, 497x501px) Image search: [Google]
professional bitcoin trader.jpg
72KB, 497x501px
How difficult would it be to program a bitcoin trading bot?

I imagine it would be simple, since I'm just automating buying and selling based off real-time data, but the most complex program I've ever made was a text-based calculator in Pascal.

Also, which language would be best for something like this?
Thread posts: 322
Thread images: 37


[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.