[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: 341
Thread images: 45

File: pure_fp.jpg (31KB, 896x469px) Image search: [Google]
pure_fp.jpg
31KB, 896x469px
Pure FP edition.

What are you working on /g/?

Previous thread: >>60718265
>>
You created this before the previous one hit the bump limit retard.
>>
>>60723587
Working on a bot that will spam comments sections to get people to vote Labour.

The messages need to be varied and realistic but I think I know enough about AI and Lisp to pull it off.

Wish me luck lads.
>>
>>60723587
Third for COBOL
>>
>>60723621
> AI and Lisp
What is this, the 80s?
>>
>>60723632
Lisp isn't dead.
>>
File: 1492238578659.jpg (33KB, 294x405px) Image search: [Google]
1492238578659.jpg
33KB, 294x405px
Daily reminder that python is being used in production environments
>>
>>60723603
Am I the only one to notice that this sort of things happens more often these days?
>>
>Pure FP edition.
I started a channel where I'll do a zero background introduction to dependent types using Idris

https://www.youtube.com/playlist?list=PL_vIhjXh1UTpfw8atiA31uP3F4Sjix_ZQ

>What are you working on /g/?
I'm currently editing the second video (pic related) going though the installation of Haskell, Idris and the Atom package for Idris
>>
>>60723663
What's wrong with that?
>>
>>60723705
It's a toy language.
>>
File: is_kill.png (39KB, 1167x623px) Image search: [Google]
is_kill.png
39KB, 1167x623px
>>60723655
Yeah, just like COBOL isn't dead.
>>
>>60723711
This >>60723663 literally disproves that.
>>
hello folks
idk if it's the place to post this but i'll try my luck
does anyone know how to connect to a wifi with password?
thx
>>
>>60723723
It can still be a toy language when it's being used in a production environment
>>
>>60723621
nice stuff m80
>>
>>60723763
>>>g/sqt/

and read the fucking sticky ffs.
>>
>>60723711
He's a toy poster.
>>
what can i say, im a nooobe, thx anyway
>>
>>60723587
I thought FP meme died already
>>
>>60723818

It did, save a few autists.
>>
File: 1423822370496.jpg (25KB, 333x365px) Image search: [Google]
1423822370496.jpg
25KB, 333x365px
Hi /dpt/,
i'm currently working on a function that moves a subtree of a BST one level up. the BST is saved in an array with the root of the tree being on index 0, the left child of i at 2i +1 and the right child at 2i + 2 and so one.
My current approach in pseudocode is:

void shiftUp(int from, int to) {
if (!existsNode(from))
return
tree[to] = tree[from]
tree[from] = NIL
shiftUp(leftChild(from), leftChild(to))
shiftUp(rightChild(from), rightChild(to))
}


But because of the recursion it won't copy every node correctly. any ideas?
>>
>>60723818
>meme
>>>/v/
>>
>>60723693
I noticed it too. For some reason the janitors don't seem to care (which we already knew seeing how last weeks have been "who are you quoting", gate keeper, Mozilla shills etc shitposting).
>>
>>60723990
Recursions aren't Turing complete.
>>
>What are you working on /g/?
A thread pool that would allow, at the same time, just throwing parallel work at it, and synchronized groups of tasks. Not a very good one mind you and nothing complicated like lockless stuff, but anyway.
Starting to be done with it for the moment so afterwards gonna start working on a networking API for the same program I need the pool for.
>>
>>60723621
What kind of AI and where did you learn it.
>>
>>60724057
No, not this shit again.
>>
Oops
>>
>>60723621
No you don't know enough AI to make it seem real. If you did you would not just "believe" to pull it off. You would know.
>>
Correct me if I'm wrong here.
In linux, when I open a file in my C program, and then outside of this program change the file, then the filesystem creates the new version in another "place" on the disk, and changes the old filesystem pointer to point to this new place, while my program still uses the old handle that point to the old data, that is still in the old place. Once the pointer is freed in the program, the old data is not pointed to by anything, therefore it's regarded as a writeable space.
Am I thinking about this right?
And if yes, does this happen every time a file is edited?
Writing the entire file into different space on disk instead of changing it in the current space?
>>
>>60723655
>>60723712
How can languages have "lives"?
>>
>>60723663
Which means it's probably garbage any sane person should avoid.
>>
>>60719511
Works on my machine.
>>
>>60724694
That you described happens if someone deletes the file you've opened or overwrites it via mv. If someone changes the file, i.e. if the inode of the file stays the same, all users of the file share it and can see each other's changes in the real time. This is why you're supposed to lock important files before reading them or writing to them if there's a chance of someone else messing with them.
>>
>>60724696
In the sense that the language's tooling is community is active. For instance, PL/I is a dead language because there is no active community towards developing its tool chain.
>>
Friends, I need some urgent help from java experts. how would I go about developing a java plugin for an application? Can anyone give me an idea where to start?
>>
File: 39203063_p0.jpg (597KB, 900x1200px) Image search: [Google]
39203063_p0.jpg
597KB, 900x1200px
guys, is there a way to read function calls to lib from an exe? or are lib contents inlined and there is no trace of function names?

i gotta find out what functions are called in an old exe made with borland c 6.
>>
>>60725354
could you elaborate on your task a bit more senpai
>>
>>60723621
Just check you're not breaking the law m8
>>
File: 024256.webm (2MB, 360x640px) Image search: [Google]
024256.webm
2MB, 360x640px
>>
>>60725634
But can you stimulate your prostate with it?
>>
>>60723587
>Pure shite edition
Dropped
>>
>>60725634
what's the point of this?
literally 2 minutes in arduino ide
>>
>>60725379
Why is she smiling like that?
>>
>>60725379
Sure is. You can even override the function calls using LD_PRELOAD
>>
File: 1495752259856.jpg (63KB, 640x640px) Image search: [Google]
1495752259856.jpg
63KB, 640x640px
>>60726277
what? i'm talking about winshit executables.
>>
finally finished my Instagram scraping script
>>
Starting a new research project where I perform statistics on compiler (and perhaps in the future, human) generated code for different computer architectures. Using those statistics I can draw some conclusions about bottlenecks in the architecture and extract idioms for the design of new architectures to improve their code density and performance.

This all started after I began designing the ISA for my new computer architecture. I was uncertain how to most efficiently design the ISA so that it doesn't stand in the way of a performant implementation. x86's ISA requires a hardware parser, u-op translation and packing, and a complex scheduler. It's part of the reason x86 will NEVER compete with ARM in the low-power market: operation for operation, x86 requires more hardware. ARM and most RISC ISAs do not have great code density: you don't need 32 bits to clear a register. That leads in the macro scale to general I-cache bloat, which means cache misses, which means less performance.

First thing this morning I wrote a little program in the vein of this https://www.strchr.com/x86_machine_code_statistics. It lists the top 20 most common instructions used in a program. Currently, I've only tested it on x86. The research project will have to involve making a bunch of cross-compilers and really improving on this simple analyzer. For example, 'mov' is a load, a store, and a register-to-register moving instruction; xor reg,reg and mov reg, 0 are both 'clears'; etc. And it's different for every architecture. And why the hell are there so many 'mov's? Is the compiler spilling because there aren't enough general purpose registers? Or are they necessary load and stores? Does ARM produce less loads and stores because of its greater number of general purpose registers?

TL;DR The script finds out the percentage of total instructions in a compiled program each instruction fills

https://pastebin.com/wtwSA2Hi
>>
File: dman-error.jpg (80KB, 463x640px) Image search: [Google]
dman-error.jpg
80KB, 463x640px
d(ead)
>>
>>60727039
please make it work with pipes; if there no argv[1], then read from stdin

objdump -d -Mintel /path/to/program | python3 thisscript.py
>>
>>60727045
F
>>
What books are good for learning HTML5, CSS3 and Javascript? Starting out in web coding.
>>
>>60727526
You're in the wrong thread. >>>/wdg/
>>
>>60727579
Ah. That is why I am asking simple questions
>>
>>60727039

>The research project will have to involve making a bunch of cross-compilers
Or you could just use LLVM?

>For example, 'mov' is a load, a store, and a register-to-register moving instruction
It might be more correct to say that there are three instructions here, just with the same mnemonic.
>>
For C++, std::tuple vs boost::tuple?
>>
File: rust_coc.png (54KB, 507x398px) Image search: [Google]
rust_coc.png
54KB, 507x398px
They're discussing the CoC on the /r/rust, and it's kinda interesting: https://www.reddit.com/r/rust/comments/6ewjt5/question_about_rusts_odd_code_of_conduct/ .
> If someone just can't get their work done effectively or can't enjoy themselves without stalking or harassing someone, or cracking a sexist or racist joke, or getting into a flame war, or insulting their colleagues, I suggest they go enjoy the numerous other totally viable language communities.
>>
>>60727774
kys
>>
File: rust_coc.png (7KB, 782x54px) Image search: [Google]
rust_coc.png
7KB, 782x54px
>>60727809
The thread is dead anyway.
>>
>>60727876
why doesn't someone just fork it and make a fascist version
>>
File: rust_but_with_more_yelling.png (89KB, 900x575px) Image search: [Google]
rust_but_with_more_yelling.png
89KB, 900x575px
>>60727929
Exactly. How does one "fork" the community tho?
>>
>>60723712
Still not as dead as haskek
>>
>>60727994
>he can't read graphs
Haskell has been more "alive" for 4 years already, and github stats kinda confirm it.
>>
>>60727990
Isn't that what hitler tried to do?
>>
>>60727774
>https://www.reddit.com/r/rust/comments/6ewjt5/question_about_rusts_odd_code_of_conduct/
MAn get a truckload of white testosterone to the straight white male (or so they say) cucks on plebbit, they already excuse themselves from not being intelligent enough to understand how "marginalized folks" feel about the issue, even though NO ONE has been able to bring up a SINGLE EXAMPLE of a community being "toxic" anywhere in the discussion. That's beyond ridiculous.
>>
I was bored today so I made this
https://github.com/ch0c0pain/tuturu

All you need is pulseaudio and ncurses.
>>
>>60728127
Non! Je refuse!
>>
>>60728127
>no readme
stopped reading right there
>>
>>60727773
Why would you ever use boost if you can use std?
>>
Whats the best python book?
>>
File: flac.png (7KB, 584x131px) Image search: [Google]
flac.png
7KB, 584x131px
>>60728127
No.
>>
>>60728234

I'm already using boost to parse an ini file.
>>
File: tinking.png (53KB, 256x256px) Image search: [Google]
tinking.png
53KB, 256x256px
Where is /dpt/ CoC though?
>>
>>60728334
>>>/global/rules
>>
Where should I start if I want to learn how computers work?

I want a solid base for network shit and general programming
>>
>>60723621
Isn't Labour still just Red Tories? Or did Corbyn finally manage to get rid of all the Blairites and Blue Tory plants?
>>
>>60728127
>pulseaudio
Utter
Trash
>>
>>60728296
>Using all of boost to parse an ini file once
This is exactly why people tell you to stay away from boost.
>>
>>60725634
> Putting metal like that near a powered bare board.

What are you thinking? Use something non-conductive!
>>
>>60725379
Yes-ish.

If the EXE statically links and you have a copy of the static libraries that were linked in then you should be able to disassemble and match various functions up based on diffing the assembly. If you don't have a copy of the static library and symbols were stripped from the EXE (I'm making some assumptions, I'm mostly familiar with ELF, not PE -- Portable Executable, which is what MS uses) then you'll have a rough time I think.

If it's dynamic linking there are probably easier tools but I don't have a whole lot of experience with those as most of what I do is embedded SW/FW.
>>
>wake up
>had a dream I was making app to sell on Windows Store
hmmm, I don't even have Windows and last time I touched c# was years ago

>there is a "4chan /b/rowser" for $2.49
heh
>>
>>60727039
This sounds like a really awesome project!

At some point you'll want to take a look to make sure that you're snagging instructions based on op code and associated fields since the mnemonics from disassembly can be misleading regarding the operation that happens. Using the mnemonics to get started is definitely a reasonable first approximation and should yield some reasonable data tho!

If you're willing to use Python, pyelftools is a really useful library I use extensively for doing elf related tasks at work.
>>
>>60728377
https://www.theguardian.com/politics/2017/may/10/labour-party-manifesto-pledges-to-end-tuition-fees-and-nationalise-railways
>>
File: Capture.png (52KB, 1340x616px) Image search: [Google]
Capture.png
52KB, 1340x616px
I am trying to code a Sudoku game.
I finally managed to fill the grid, but... well you see..
>>
>>60728619
The problem is not with the code you're showing, look at the stack trace.
>>
>>60728682
it's a problem with the class I was given.
I needed to use the lockAndDisplay Method beforehand.
Readng the output goes a long way I guess.
>>
>>60727990
>numerous other totally viable language communities
Is he implying Rust is one of these?
>>
>>60727774
>>60727876
>>60727990
I don't want reddit stink nearby. Fuck off.
>>>/r/abbit
>>
>>60727773
Always prefer the standard library unless you have a specific and explicit reason for using otherwise.
>>
>>60728800
So boost?
>>
>>60728815
xd
>>
>>60728815
Do you have a reason for using boost::tuple over std::tuple? Or will std::tuple solve the same problem the same way?
>>
File: ebin.MOV.webm (1MB, 1280x720px) Image search: [Google]
ebin.MOV.webm
1MB, 1280x720px
Can I sign up for google now? (I am not a tranny)
>>
How do I become 31337?
>>
>>60729018
rewrite this in Dart and we'll talk
>>
>>60729018
learn how to spell fagget
>>
>>60729018
Noice.
>>
I've been reading through SICP but the python version, the original seems different, does it matter too much or is the new one missing out on some things?
>>
I'm getting
../../externals/glad/libglad.a(glad.c.o): could not read symbols: Invalid operation

when trying to cross-compile a program. I can barely find any information about libglad, let alone its dependencies. The target is w64-mingw32. How do I fix this?
>>
>>60729018
>Can I sign up for google now?
probabl..
>I am not a tranny
yeah, no
>>
>>60728127
>canceraudio
>>>/trash/
>>
I am going to take an intro to programming class utilizing visual basic.
I feel stupid.
>>
>>60729133
>The target is w64-mingw32
>mingw
Sorry, but you signed up for one hell of a world of hurt.
>>
File: 1445658458237.png (602KB, 963x720px) Image search: [Google]
1445658458237.png
602KB, 963x720px
is OOP just structs with functions?
>>
>>60729168
No.
>>
>>60729168

OOP means something different depending on who you ask.
Are you a Java dev? C++? Ruby? Smalltalk?
>>
>>60729168
Yes. You don't need crazy stuff like polymorphism or multiple inheritance to do OOP. You just need objects, which are data with associated code, or structs with functions.
>>
>>60729168
In the purest sense, yes.
>>
>>60729256
>don't need polyforphism for oop
i beg you pardon?
>>
C++, got a template with let's say
template<size_t ayy, size_t lmao, bool bog, size_T whatever = 10>

I want to provide two specializations, one for bool bog as false and one for bool bog as true. What's the most elegant way? Do i just write a completely empty class and then specialize two times? Is there a way to avoid writing this empty class?
>>
>>60729361

He's probably a C++ programmer. The best way to use classes in C++ is to be as monomorphic as possible.
What's left is just C code with the boilerplate removed.
>>
>>60729168
I asked myself this in 5th grade.
>>
>>60729203
whats the difference? polymorphism?
>>60729249
c, objective-c dev
>>60729356
good
>>
File: games.png (39KB, 486x294px) Image search: [Google]
games.png
39KB, 486x294px
It feels like a lot of projects throw away C++ features
>>
>>60729249
>OOP means something different depending on who you ask.
no
>>
>>60729168
>>60729356
only if you are plt illiterate.
>>
>>60729436

Polymorphism is what most people would consider to be a defining trait of OOP.
>>
File: languages3.png (17KB, 522x384px) Image search: [Google]
languages3.png
17KB, 522x384px
Reminder that this image still is and will forever be accurate
>>
@60729479
Only if you are severely mentally ill.
>>
>>60723587
this, but stopped a few days ago because Im too dumb to figure out pythons native string formatting, and too lazy to dl one of the zillion modules, probably going to roll my own next time I get really bored
>>
>>60729458
Are you sure?
>>60729493
>>60729479
>>
>>60729493
>@
ANALLY ANNIHILATED
>>
>>60728045
>github stats
In that case, Lisp is alive.
>>
>>60729509
oops, code

def calc_drips(ml,drip_in_ml=35):
return float(ml) * drip_in_ml


def nic_in_ml(base_nic_str,desired_str,tot_vol):
return ( float(desired_str) / float(base_nic_str) ) * float(tot_vol)


def ret_percent(item_ml,tot_vol):
return (float(item_ml) / float(tot_vol)) * 100

def ret_ml(percent,tot_vol):
return (float(percent)/100) * float(tot_vol)

def calc_nic_args(des_str,tot_vol):
ml = nic_in_ml(48,des_str,tot_vol)
drops = calc_drips(ml)
percent = ret_percent(ml,tot_vol)
return ml,drops,percent



def println(item,ml,drops,percent):
print("{}: \t ml~{} \t drops~{} \t %{}".format(item,ml,drops,percent))

def print_recipe(rec,des_str,tot_vol):
nic_ml, nic_drops, nic_per = calc_nic_args(des_str,tot_vol)
println(" NICOTINE",nic_ml,nic_drops,nic_per)
for x in rec:
ml = ret_ml(rec[x],tot_vol)
println(x,
ml,
calc_drips(ml),
ret_percent(ml,tot_vol)
)


Ellas_Shortbread_Biscuit = {"Acetyl Pyrazine 5% (TPA)":0.5,
" Biscuit (INAWERA)":1.5,
" Sugar Cookie (CAP)":4,
"Vanilla Custard v1 (CAP)":2,
"Vanilla Shisha (INAWERA)":1
}

print_recipe(Ellas_Shortbread_Biscuit,15,10)
>>
>>60729168
Are traps just chicks with dicks?
>>
File: dptchallenge.png (302KB, 1920x1080px) Image search: [Google]
dptchallenge.png
302KB, 1920x1080px
rollin
>>
>>60729479
I didn't realize the word polymorphism anywhere here http://wiki.c2.com/?AlanKaysDefinitionOfObjectOriented
>>
>>60729482
in what world does python not have fast development?
>>
>>60729564
When the code is full of bugs because the language lacks any reasonable means of preventing them i.e. always
>>
File: 1390934508546.jpg (35KB, 500x500px) Image search: [Google]
1390934508546.jpg
35KB, 500x500px
>>60723587
Is there a version of this thread but for people with 90+ IQ?
>>
>>60729122
pls respond I'm a newfag
>>
>>60729598
There used to be a functional programming general, but there were only about 3 posters in it
>>
>>60729598
no
>>
>>60729598
Yeah but anime avatars and meta posting aren't allowed in our secret club so we decided to not let you in.
>>
>>60729598
Head on over to the /math/ general at /sci/.
>>
File: languages4.jpg (88KB, 1024x710px) Image search: [Google]
languages4.jpg
88KB, 1024x710px
>>60729482
Wrong image, bud.
>>
>>60729619
Functional or not, I think a thread for non-retards is severely needed.
>>60729624
Your parents just want the best for you anon.
>>
>>60729624
>anime avatars aren't allowed
she said 90+ IQ
>>
File: dpt.jpg (146KB, 1648x691px) Image search: [Google]
dpt.jpg
146KB, 1648x691px
>>60729598
As opposed to the 100+ IQ thread we're currently in?
>>
Allowing people without CS degrees to become programmers was a mistake
>>
File: file.png (93KB, 603x577px) Image search: [Google]
file.png
93KB, 603x577px
>>
>>60724696
If something is no longer seen and is no longer in the public eye, it is dead. Are you so retarded that you have never heard the phase "x is dead" because it is no longer being used? As improvements on things are made, older things (like languages) drop in favor and stop being used.
>>
>>60729589
i think you may just not be good at python
>>
>>60727360
(F)uck off
>>
>>60729698
chapel though
>>
>>60729018
How is that junior-level computer engineering program going?
>>
>>60729589
>Blames the language for your inability to write bug-free code

Every time. Fuck off.
>>
>>60729589
The one where the developers only really know Python, but don't want to admit it.
>>
>>60729795

Only shit languages force dynamic typing.
>>
>>60729772
Pretty good. Doing more than expected from me, atm working on lab4, most people are still stuck on lab1, and have showed the prof a few bugs in his descriptions n shit. He was very pleased that someone really debugged his shit lel
>>
>>60729811
This
>>
>>60729839
python doesn't force dynamic typing
>>
Dumb question: What is python? Why does it have a live environment thing-y on Linux like MATLAB?
>>
>>60729968
>What is python?
A beginner language more entry level than matlab.
>>
>>60729839
>python
>dynamic typing forced

Pick one, retard.
>>
>>60729995
>thinks high-level means it is always beginner

Only thing beginner here is you.
>>
File: smug_ran4.jpg (465KB, 565x800px) Image search: [Google]
smug_ran4.jpg
465KB, 565x800px
>>60730027
Exactly who are you quoting? Literally no one said that.
>>
>>60729155
Compiling actually worked pretty well, it's the linking that won't.
>>
>>60729968
it's interpreted, so it's easy for it to have an interactive shell. interpreted means you give python a command one at a time, and it follows the command. contrast that with a compiled language like C that translates an entire program to assembly code all at once
>>
>>60730074
Does this mean Python can be used to write programs on my computer, as well as be used for applications similar to MATLAB (idk if Python has math libraries or whatever)?
>>
>>60730137
>write programs on my computer
Meant to say write programs that would run on my computer, like a traditional language: C/Java/etc.
>>
what languages are you currently learning and which are you planning to learn in the future? i'm currently learning python & C, and i plan to learn C++, assembly, bash, and scheme next. i already have basic working knowledge of all of these except assembly, but i'm diving deep now
>>
>>60730155
you can have them in a python file and pretend that it's a program, but your computer will never compile it. you'll still have to give it to the python interpreter program installed on your computer. that's why python has poor performance, use google to answer any other questions you have
>>
How the hell are you supposed to decide on what IDE/text editor to use? I'm trying to learn programming and I'm going through the cources on Freecodecamp, but I'm trying to look at some different IDEs but I don't really know what to look for, the only thing I want is that it's available on both Windows, OSX and Linux.

Does it just come down to what languages you're going to focus on or is there any one size fits all solution?
>>
File: sakuya_shit.png (63KB, 320x218px) Image search: [Google]
sakuya_shit.png
63KB, 320x218px
>>60730170
I'm learning Finnish.
Might also look into Idris idk
>>
Which programming language should I teach my boa constrictor? Python? ASP?
>>
>>60730215
>I'm learning Finnish.
No fuck off we don't want you here.
>>
>>60730215
fuck OFF
>>
>>60730239
Why not? Afraid someone sociable might move to Finland?
>>
>>60730236
Python. Duh. Lisp too.
>>
>>60730239
>>60730251
Don't worry I'm just learning it for laughs.
lähetä minulle kuva kullistasi
>>
File: 2Ml9USDEJ68.jpg (90KB, 604x459px) Image search: [Google]
2Ml9USDEJ68.jpg
90KB, 604x459px
>>60730239
Finns have the best memes though
>>
>adult male
>not bilingual at the very least
lol

reminder that knowing foreign natural languages makes you better at programming and more attractive to hotties
>>
Sup /dpt/. I'm currently a "full stack" web developer and I hate my job more than I can handle.

How can I transition from web development to embedded development? Do I just apply and say "gibe job or I scream hhuehuehueheue"
>>
>>60730422
Are you upset that English won?
>>
>>60730483
You should at least learn some C first.
>>
>>60729850
Oh god tell me about it. I got the source code for one of my professor's lab applications. It was garbage. No one could get it to compile so they just used the binary that someone had made several years back that had been passed around. I went through it and no wonder it didn't compile: invalid pointer casts, K&R style argument declaration, etc. There was even a ton of use after frees and relying on undefined behavior in the pre-compiled application, so it crashed randomly all the time. I tried my best to salvage it, but I couldn't, so I re-wrote it. The teacher in question's pride was too much to accept a freshly written application so it never saw anything besides my lab reports. What a nightmare.
>>
I name class names with lower_snake_case.
>>
File: yukari_face.jpg (179KB, 637x900px) Image search: [Google]
yukari_face.jpg
179KB, 637x900px
>>60730422
>mfw know 4 natural languages and 6 programming languages
>>
>>60730483
Gain ten years of experience in embedded programming first.
>>
>>60730485
Native English speakers are the minority here tho.
>>
File: english.jpg (132KB, 421x1080px) Image search: [Google]
english.jpg
132KB, 421x1080px
>>60730485
Not at all senpai, I like English.
>>
>>60730531
>(((((Citation needed)))))
>>
>>60730515
literally triggered to tits rn desu
>>
Why does this C++ program close immediately after receiving input? Usually cin.get() stops the console window from closing but it closes instantly in this case.
cout << "Enter number\n";
int decision;
cin >> decision;

cout << "You entered " << decision;
cin.get();
>>
postin cool book I found https://cses.fi/book.html

useful if you want to have fun at topcoder, google code jam, etc.
>>
Tell me if this is a good practice or not.

When I want to implement some algorithm that has a lot of subprocedures that pass each other many arguments and so on I evade all scoping problems by making the algorithm a class and all the important and relevant variables private fields of that class. That way I mostly have left void functions that get passed almost no arguments between them.

I always distinguish fields from local stack variables by giving them a _ at the beginning of the identifier, so I hope that would make future reading of the code less confusing.
>>
>>60730832
>topcoder
>code jam
Aren't those both wastes of time?
>>
I've been asked to make something that sits and waits for any of 4 different signals over the network to tell it to do things and does those things. I've never written anything like this before so I'm trying to figure out where to start reading. My first instinct is to set up a simple HTTP server that is just listening for POST requests to tell it what to do. Maybe also serving up a status page. Does that sound reasonable?
>>
>>60730781
Don't people usually put get char there? I never did it with cin.get(), so I'm not sure if it will work the same way.

Also, it could be something with something left in the buffer, maybe the newline character? Put two cin.get().
>>
Writing a lot of Rust. It's a very complicated language, but I'm having fun with it.
>>
Currently learning Go, any ideas for small training programs?
>>
>>60730781
cin gets the value of decision after you type the newline character (enter), but it doesn't consume the newline character, which cim.get() does later. This has been asked 2 million+ times, please google a problem before asking. That's where you'll find the work around (hint: don't rely on that shit).
>>
>>60730840
it's preferable to write an algorithm that doesn't have alot of state that needs to be passed around, but if you do need to pass alot of state around that's probably the better way to do it
>>
>>60730907
Chat server
>>
>>60730907
Something that leverages Go's features like goroutines and channels. If you don't pipeline all your processes through threads, you're a loser.
>>
File: bleach-clorox-drinking-.jpg (16KB, 400x300px) Image search: [Google]
bleach-clorox-drinking-.jpg
16KB, 400x300px
still working on that hyper-simplistic math game of mine.
couldn't be arsed to catch "divide by zero" exceptions so i changed all integers to floats because:
1. i'm new at this and don't know how.
2. i'm too lazy to give a shit.

currently exporting it, once that's done i will distribute it here at something for beginners to fuck around in because it demonstrates:
>conditional loops
>switch statements
>variables
>importation and invocation of objects from other classes

i will be back here with a link to a github soon after i made a github account and finished exporting.
No this code is not a meme, fuck you.
>>
>>60730914
>>60730840
As long as you don't need to worry about multiple threads hitting your class at the same time and all the different ways those state variables could be mutated between calls. So lock it down in a monitor or whatever.
>>
File: 135.png (21KB, 700x700px) Image search: [Google]
135.png
21KB, 700x700px
>>60723587
>Pure FP edition.
So I want to learn some functional programming language. Which is the most reliable in 2017 and the most perspective? It must have built-in concurrency.

Have 10+ years experience with c and c++.
>>
>>60730935
>catching divide by zero
Not possible in C or C++. Just check for it first.

if (b != 0 && (c = a / b)) {
// c holds the result, and there was no divide by 0
} else {
// attempt to divide by zero, handle that shit
}
>>
>>60730970
Racket
>>
>>60730930
yeah i read about that, that its basically the best part about Go but I have no idea what to actually program with threads
>>
File: 16634.jpg (24KB, 318x470px) Image search: [Google]
16634.jpg
24KB, 318x470px
>>60730866
Idk, it can be relaxing to solve some "pure" problems sometimes without having to think about engineering shit and refreshing classic algorithms in your mind, it's even better to compete with others to do it faster, feels good and exciting. And some companies do their interviews with a "invert a binary tree" meme.

I worked with a competitive programming rockstar a few years ago, he was really good at coming up with solutions tbqh.
>>
>>60730999
Yeah, I can't think of a fun program for learning. I wrote a job control server with it. Not fun, but pretty interesting.
>>
>>60730907
Write a program that proves that Conway's game of life is Turing complete
>>
>>60730912
I did look up different solutions (trying system("PAUSE"), using cin.ignore() and other things) but none of them worked. I came here as a last resort. I think it's cause I don't know how streams work in C++.
Thanks for your help though.
>>
>>60730970
Javascript, duh
>>
>>60730982
No
>>60731029
No
>>
I want to develop something for android, but I don't feel like installing android studio, what's a good alternative?I'm currently using i3 manjaro
>>
>>60730832
wtf is competitive programming
do they write programs that try to delete each other first?
>>
>>60729482
Ruby should be bottom left
although it might be useful to add a thing for safety
>>
>>60731129
>putting Ruby in the same class as Haskell and Scheme
r u avin a giggle m8
>>
>>60731126
https://en.wikipedia.org/wiki/Competitive_programming
>>
>>60731162
i don't give a FUCK don't you ever reply to me ever again
>>
File: hillarycomic.png (429KB, 680x352px) Image search: [Google]
hillarycomic.png
429KB, 680x352px
can a person with a 100 iq become a professional programmer? I'm thinking a 100 IQ person is as smart as the dumbest person in your synagogue for reference.
>>
>>60730907
currently best idea is simple IRC (Internet Relay Chat-room)

Then distribute to a friend after you have zipped it, and then chat with them through the chat-room. afterwards share it here.
>>
>>60730974
that 5+ extra lines i would have to make.
fuck that.
its easier to just represent the number as a float.
>>
File: 1458088950376.png (422KB, 572x632px) Image search: [Google]
1458088950376.png
422KB, 572x632px
>>60730907
Write a program that I can fug. Also make sure it constantly prints "I'm only 8 years old!" I like my programs fresh and plum.
>>
I want to learn java but don't care about gui's and I already do webdev so servers are boring. What should I learn about? I'm thinking maybe bittorrent?
>>
>>60728127
Post a webm, faggot.
>>
>>60731157
Ruby is just Perl+Lisp+ Smalltalk. Literally the definition of quick development
>>
>>60731289
8 year old plums are rotten.
>>
>>60731325
Truly, it is less than the sum of its parts.
>>
>>60731248
will probably go with that, thanks
>>
File: 1355534497911.jpg (168KB, 411x651px) Image search: [Google]
1355534497911.jpg
168KB, 411x651px
>>60730215
Ebin. Kuinka hyvin puhut suomea?
>>
>>60731344
Not when they're wrapped in human skin and glazed with my penile secretions.
>>
>>60731350
Then Perl, Lisp, and Smalltalk must be negative in quality.
>>
>>60730208
Please respond
>>
>>60723663
I mean a developer could save a lot of time by programming in python and it has very good compute capabilities.
Inb4 just write low level c code jeez
>>
File: yuuka_unamused.png (275KB, 568x310px) Image search: [Google]
yuuka_unamused.png
275KB, 568x310px
>>60731354
Not at all at the moment, I'm only learning some phrases from this one Finnish boy doing a MSc in maths.
>>
File: MrBeanFuckMeEyes.png (225KB, 597x489px) Image search: [Google]
MrBeanFuckMeEyes.png
225KB, 597x489px
>>60730935
having trouble running the .jar once completed, functions as a winrar rather than an app
fuck this.
>>
>>60729598
Same question here
>>
>>60727773
>The current state of C++
>>
C++ needs purged and restarted from the ground up.
>>
>>60731704
dlang-chan!
>>
>C is good
#include <stdio.h>

int main()
{

float f = 16777216.0f;
f = f + 1.0f;
printf("%f\n", f);

return 0;
}
>>
File: b81.jpg (44KB, 600x715px) Image search: [Google]
b81.jpg
44KB, 600x715px
>>60729598
>90+ IQ
>posts Touhou
>>
>>60731704
Rust, rust!
>>
>>60731723
good lad
>>
>>60731736
Rust is already as bad as Sepples in many regards, which isnt good. Also Mozi//////////////a care more about COCk than the actual language.
>>
>>60731769
[citation needed]
>>
>>60731769
Rust actually has modules and doesn't have 3 standard libraries like C++
>>
>>60731797
>>60731818
In its infancy, its syntax is already as much a clusterfuck and verbose as the worst offender in the STD.
Reading rust code makes me feel the same dread.
>>
>>60731733
$ dmd main.d && cat -n main.d && ./main
1 import std.stdio;
2
3
4 void main()
5 {
6
7 float f = 16777216.0;
8 f = f + 1.0;
9 f.writeln();
10 }
1.67772e+07
>>
>>60731818
>doesn't have 3 standard libraries like C++
maybe not, but it does have 2 string primitives, but muh safety, muh memes, etc.
A string should literally be represented the same way whether or not it is heap/stack allocated.
>>
>>60731846
>but it does have 2 string primitives
Ada has 8
>>
>>60731838
I believe d had the same problem
>>
>>60731851
I don't think you know what the word 'primitive' means in this context.
>>
>>60731838
floats are hard.
you could just round up and do
f.to!int.writeln();
>>
>>60731838
>>60731733
>.0
>using floats
>>
>>60732040
>>60731897
what problem?
>>
>>60732091
f not returning 16777217.0
>>
>>60732098
>>60731733
Please anon, you're embarrassing yourself.
>>
>>60732128
(You)
>>
>>60730970
After a few hours of researching I decided to start learning Haskell because it's only the true FP language others are just a miserable copy of Haskell.
>>
>>60732098
Oh that?
1. If you want precesision you can use libraries made for that
2. You don't use floats for general calculation. For example if you add 0.01 100 times you will not get 1
>>
>>60732146
Too bad haskell is a miserable language itself
>>
>>60732150
Im not even the OP, just saying. And yeah the use-case for that level of precision is so low it may as well be a non-problem.
>>
>>60732150
>For example if you add 0.01 100 times you will not get 1
What are you talking about?
#include <stdio.h>

int main()
{
_Decimal32 n = 0.0f;

for (int i = 0; i < 100; ++i)
n += 0.01df;

printf("%f\n", (float)n);
}

1.000000
>>
>>60732179
that's not a float type like >>60731733
don't try and pretend to be dense
>>
>>60731734
Touhou posters are known to have an average IQ of about 140.
>>
>>60732191
>that's not a float type
Yes it is.
>>
>>60732150
>Use libraries to simple math for me
Isn't C for the diy faggots?
>>
>>60732201
>_Decimal32
use float next time and fuck off with your shitty strawman
>>
>>60732218
Don't complain to me that your shitty language doesn't have radix 10 floating point numbers.
>>
>>60732207
>Isn't C for the diy faggots?
C appeals to people that don't care about libraries for some reason. Probably it's just /g/

I think you have to find a middle ground where you rely on libraries when it is needed and when calling libraries is just going to add an unnecessary overhead
>>
>>60732223
D natively supports all of C's types, idiot. Head back to 9gag you are not old enough to use this site.
>>
>>60732146
>it's only the true FP language
>doesnt even have DT

Hasklet is the C++ of FP.
>>
>>60732233
You don't need a fucking library to deal with what that retard is talking about.
Either use a type with higher precision (double) or use integers. He's complaining about something that isn't a flaw.

>>60732248
Please show me deadlang using _Decimal32 then.
>>
>>60732262
>He's complaining about something that isn't a flaw
Brainlet, apologist detected
>>
>>60731418
> compute capabilities
what the fuck does that even mean
every programming language "computes" things
>>
>>60732262

_Decimal32 is not a part of C, it's a GNU extension.
>>
>>60732262
You dont even need it if you ever want to port
 float r = 123.456;
float r2 = 654.321;
float r3 = r+r2;
writeln(r.sizeof,r2.sizeof, r3.sizeof);

444
>>
>>60732400
It's part of TS 18661, which is very likely to be included in the next C standard. So yes, I know I was not being entirely accurate to say C "has" them, but it's very likely that it will get them.
>>
>>60732461

>the next C standard
Which is what, 3 to 5 years away? I'd say it wouldn't be quite fair to give C this as a feature over other languages just yet.
>>
>>60732591
TS 18661 is already a thing in its own right; "C with TS 18661" supports them.
>>
>tfw considered a C++ expert
>wouldn't be able to teach the language nor explain how to learn it
>>
>>60732661
You can't explain because you don't understand it well enough
>>
>>60732400
>>60732591
>Actually replaying and enabling underage shitposters
>>
>>60732661
>expert
>wouldn't be able to teach the language nor explain
The only person who would consider you an expert is yourself
>>
>>60731835
>not even an example
>still no source
>>
>>60732257
Are you retarded or something? Haskell is the purest FP language.
>>
>>60731918
Rust has one string primitive.
>>
hey /dpt/ I'm just now learning about variables and types in Python and i was wondering, does anyone use programs to program? I know I'm autistic but thanks
>>
>>60732726
What's your point?
>>
>>60732715
>this is what hakellards believe
>>
>>60732732
Do you have brain damage?
>>
>>60732732
pointing out that >>60731846(You) was wrong
>>
>>60732715
>Haskell is the purest FP language.
>still has a fractured userbase from the 90s
>Xtensions splitting it up further
>doesnt even have all the features of a proper FPL
wew lad
>>
>>60732715
>purest
>has unsafePerformIO
>>
>>60732758
There are two hasklels which one?
>>
>>60732749
>>60732751
Are you new to this site?
>>
>>60732767
https://haskell-lang.org/
https://www.haskell.org/
>>
>>60729365

BRAAAAPPPPT

template<size_t ayy, size_t lmao, bool bog = true, size_T whatever = 10>
class ebin
{
// bog = true specialization
};

template<size_t ayy, size_t lmao, size_T whatever>
class ebin<ayy, lmao, false, whatever>
{
// bog = false specialization
};


Though, it really depends on the number of different specializations needed for different combinations of the arguments.
>>
>>60732803
concept here is called "partial specialization" btw
>>
>>60732780
which one?

>>60732776
Is being an mouth drooling fucktard the norm around here?
>>
>>60730970
>It must have built-in concurrency
Elixir.
>>
>>60732826
Usually only newfags assume the person that replied to them was the person they were previously talking to.
>>
>>60732728
>does anyone use programs to program?
uwotm8
>>
>>60732934
He probably means an IDE
>>
>>60731733
>Playing the guessing game on the precision your implementation provides
with Ada.Text_IO;

procedure Good is
type Float_N is digits 9;
package Float_IO is new Ada.Text_IO.Float_IO (Float_N);

type Decimal_N is delta 0.1 digits 9;
package Decimal_IO is new Ada.Text_IO.Decimal_IO (Decimal_N);

type Fixed_N is delta 0.1 range -99999999.0 .. 99999999.0;
package Fixed_IO is new Ada.Text_IO.Fixed_IO (Fixed_N);


Float_N_Example : Float_N := 16777216.0;
Decimal_N_Example : Decimal_N := 16777216.0;
Fixed_N_Example : Fixed_N := 16777216.0;

begin -- Good

Float_N_Example := Float_N_Example + 1.0;
Decimal_N_Example := Decimal_N_Example + 1.0;
Fixed_N_Example := Fixed_N_Example + 1.0;

end Good;
>>
>>60723587
i know you probably get this question alot but should I learn C++ if I want to get into game development?
>>
>>60733013
It's up to you.

When it comes to game dev, there's way too many things to consider.

>Platform?
>Using an engine?
>portability?
etc
>>
rod-cutting(p,n): // p: array of prices, n: length of rod
let r[0..n] be a new array
r[0] = 0
for j = 1 to n
q = -infinity
for i = 1 to j
q = max(q,p[i] + r[j-i])
r[j] = q
return r[n]


isn't this incorrect? in line 7, it adds the original price for one of the cut halves to the optimal price for the other of the cut halves. i don't see how that's correct
>>
>>60733013
We do; google it, fagboy.
>>
>>60733034
I'm attempting to use Unreal engine 4
>>
>>60733002
VOMIT.webm
>>
>>60733013
"Game development" is too vague to recommend a specific language. Different languages are better for different games and platforms.
>>
>>60733002
>:=
absolutely gross
>>
should i write a cyberpunk text only rpg in C?
>>
>>60733111
>text only rpg
literally why, id rather just read a book.
>>
>>60733111
>cyberpunk text only rpg
>in C

No

Do it in html
More portability
easy to host
no need to download and run a random binary for no reason
>>
>>60733118
you don't need a gui to do combat or exploration
>>
>>60732696
Strongest math researchers in my department also are the biggest spergs
>>
>>60733111
Why not?
>C-"strings" suck ass
Doesn't matter. It's a text adventure game. You're definitively going to be wanting to define your world outside of C and read it in to your text adventure engine.

If you're making a new imaginative combinatorics driven text rpg you should probably look to do it in a language that lets you do more high level things easier than C.
>>
>>60733104
>Being this devoid of intelligent critique
>>
>>60733136
Yes, but all the elements you remove are again, better suited to a novel.
And no matter how dork_fort-tier autistic you get with the combat, its still just going to be math with no front-end to make it fun.
Text RPGs are shit.
>>
>>60733180
i wouldn't want someone like you playing my game if i made it anyways. i bet you think roguelikes are shit too
>>
File: putin_3463140k.jpg (96KB, 858x536px) Image search: [Google]
putin_3463140k.jpg
96KB, 858x536px
If Putin could program, what would he work on?
>>
>>60732661
There's a difference between not being able to teach it and students who aren't willing to learn. It is a pretty obnoxious language to try to find a starting point though.

I'd say the first category of teaching C++ (provided the students have knowledge of programming in general) would be to start with the memory model. Teach constructors, destructors, placement new. Talk about data lifetimes and how that kind of things binds. Speak a little bit about move versus copy semantics but save the details for later.

Next move on to references, pointers, talk about copy elision via binding temporaries to const&. Describe WHEN to use references versus pointers and strategies for aggregation like how to deal with cyclic dependencies. This segues nicely into inheritance and virtual functions which you can offer as an aside (specifically, child objects defining interfaces the parent object can implement and have its instance be passed by reference into the child object on construction.)

At this point, assuming the student knows how and is willing to learn, there should be a pretty decent grounding of actually useful C++ concepts and you can move on to using constexpr to perform actions at compile-time then introduce using templates as a way to provide "constexpr parameters" do your constexpr functions. Finally, talking about basic template metaprogramming once that part is introduced.

All throughout you should be demanding your student read and research the fucking error messages CAREFULLY and analyzing the offending code. My biggest problem with using C++ in the workplace is people who don't actually try to identify the problem the compiler is warning or erroring about and just massage the code. I worked in one place where it was decreed "we can't use virtual functions since they require libstdc++" because the guy responsible for getting our code linking without libstdc++ didn't know how to search the internet for `__cxx_pure_virtual`. Fucking garbageperson.
>>
>>60733002
Reminds me of Pascal desu, it shows they were around during the same time.
>>
>>60733206
Hacking the DNC
>>
>>60733196
>i bet you think roguelikes are shit too
RNG is objectively shit and not fun.
RL's are shit because by nature they have more RNG than design.
This isnt the 70s anymore, we arent restrained to ASCII bullshit.
>>
>>60733212
Good post.
>try to find a starting point though
That's my biggest problem. I would start with imperative programming then move towards lvalue vs rvalue semantics but that's probably quite specific. It doesn't help that I don't really remember how I started with C++.
>>
I have my C exam tomorrow.

Wish me luck, /dpt/
>>
>>60733271
Break a leg anon
>>
>>60733216
?
>>
>>60733223
do you also use windows because of the pretty colors?
>>
>>60733214
It's about 20 years younger
>>
>>60733249
Yeah. I think a LOT of stuff about C++ doesn't make sense until you understand the basics and the requirements behind "zero cost abstractions."

I started C++ with a base of C, Java, and a strong grounding in program logic. I learned mostly on the job by asking a lot of questions about various designs and following up by googling everything then progressed by researching "how do I do <X>?" and really making an effort to grok implementation-ish details like symbols and linking, what kind of code is guaranteed or not to be generated where, etc etc. Once you start to understand the foundational details a lot of the stuff in the language starts naturally falling into place, which is why I suggested starting with the memory model since it's such a huge part of why and how C++ language features are the way they are.
>>
>>60733376
>Its not enjoyable unless its as devoid of fun as possible
masochists out
>>
Allowing people without CS degrees to write software was a mistake
>>
>>60733394
>zero cost abstractions
Compilers are too stupid for this to be a reality right now. There's so much stuff that can fuck you up that C++ would have you read all the assembly in your compiled program just to make sure one of your "zero cost abstractions" don't fuck you up bad.
Generally the same happens in C but it's features doesn't encourage provoking these problems. Even innocent looking things like operator overloading can be terrible.

But in theory zero cost abstractions are zero cost if the design wasn't adapted to them.
>>60733442
We'd have much more unpredictable performance if this were the case
>>
>>60733442
>CS degrees mean youre competent
wew lad.
Programming,CS/CE needs its own specialty trade-school desu. (((Uni))) was a mistake.
>>
>>60731237
Autism defense mode: active
>>
New thread:
>>60733497
>>60733497
>>60733497
>>
why does unix have file i/o at the same time as stdin/stdout streams.

kind of redundant
>>
>>60733641
There is "low level" I/O provided by POSIX/the operating system, and "high level" I/O provided by stdio.
Stdio does things like buffering, and is portable across all C implementations. read/write just does exactly what it says: reads and writes, without any other shit on top, and is tied to the way Unix does things.
They both have their advantages and uses.
>>
>>60732871
Have you tried getting a brain?
>>
>>60733054
Then not really. C++ in UE4 is not used for gamedev, but rather for optimizations. For example, much of the engine-related machinery is exposed via blueprints, but the C++ api is broken/missing for those same components. That is because C++ is meant to build up computational blocks to tie into a blueprint graph.
Thread posts: 341
Thread images: 45


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