[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: 318
Thread images: 39

File: 1485438720022.png (423KB, 720x720px) Image search: [Google]
1485438720022.png
423KB, 720x720px
Old thread: >>59116218

What are you working on /g/?
>>
>>59121588
First for D
>>
>>59121588
x86/arm Forth with an editor which traces the stack items lifetime to make it easier to teach kids with it. Mainly for a 7 year old but will add binding for opengl, ect... so might end up as a learning tool for older ages
>>
Nothing. I started doing some apps on Xamarin and I got bored at how primitive it is, and the java interface of Android Studio almost gave me cancer with the high latency of the IDE. I'd rather develop WPF on Visual Studio desu.
>>
>>59121601
I tried D today. It's pretty good.
Now tell me why I shouldn't use it.
>>
>>59121708
D stands for Dead.
>>
C and D are muh waifus
>>
I have started programming a few weeks ago. Using html5 w/ javascript. Not best combination, but it's easy to learn and works for what I want to make. Currently working on a tile based puzzle game. Like conway's game of life and minesweeper.
>>
>>59121708
Use it if it werks 4u
>>
No one answered what anime girl is Rust. Lain does make sense for Lisp though.
>>
>>59122085
umaru. the reason is obvious
>>
>Other thread talking about programming
>This thread is talking about anime

Why should I use this thread again?
>>
>>59122138
animu + programming > programming
>>
>>59121588

float Q_rsqrt_distance(glm::vec3 vector1,glm::vec3 vector2){

// remove this and it will not be reliable{
float value = abs(
(vector1.x-vector2.x) * (vector1.x-vector2.x)+
(vector1.y-vector2.y) * (vector1.z-vector2.y)+
(vector1.z-vector2.z) * (vector1.z-vector2.z)
);
if(value <= 0.0f){
printf("value: %f\n",value);
}
// }
return Q_rsqrt(
abs(
(vector1.x-vector2.x) * (vector1.x-vector2.x)+
(vector1.y-vector2.y) * (vector1.z-vector2.y)+
(vector1.z-vector2.z) * (vector1.z-vector2.z)));
}


C++11 compiled with g++
.x,.y,.z are floats
>>
>>59122272
Why not use glm::distance?
>>
>>59122475

because square roots take too long

when you only want to find the order of objects in 3d space (the actual quantity doesn't matter) fast inverse square root is better
>>
>>59122520
how do these libraries normally calculate square roots?
>>
>>59122737

If it outputs the real distance, it uses the standard math.sqrt()
>>
>>59122755
and how does math.sqrt() calculate it? newton's method?
>>
>>59122737
Some variation of Newton's method or Pell's equation or something. They're not too intensive, but if you're doing millions of them 140 times a second, it can be worth it to break out the old floating point bitmath voodoo.
>>
>>59122770

I don't know

I think probably a taylor series representation of the square root would be the best
>>
>>59122802
>>59122833
thanks anons
>>
I'm currently coming up with syntax ideas for C-like a programming language I want to make.
Does anyone have any opinions or suggestions? These are just random ideas that I've jotted down, so they haven't been thought through thoroughly, and may have weird inconsistencies and not work in all situations.
>>
>>59122272
Pretty much every processor made in the last decade implements invsqrt() in hardware. You're slowing yourself down by using a technique meant for 90s hardware. The obvious method will actually be faster.
>>
Why do people have babies when they could write code?
>>
What sort of free software projects can I contribute to in order to better learn how to program?

How do I like, get into a project at all?

I know Java, Haskell and Prolog. Maybe a little C++.
>>
>>59123278
I forgot to mention a couple of things:
'a' and 'b' are always supposed to be the same type, and const qualified. None of the pointed-to types are supposed to be const qualified though.
>>
>>59121588
developing a UWP app for xbox1, using visual studio + c# + monogame.

super easy to setup and get working. very fast to develop. an empty frame takes about 300 ticks to draw, so fast enough for anything i can throw at it.
>>
>>59123322
because normalfags gonna normalfag
>>59123328
browse github or any gitshit site until you find a suitable project
>>
>>59123278
C-like is so uninteresting
>>
>>59123356
What does the app do?
>>
I made a program in java that alphabetically lists the items in a specified directory and marks them as file or directory. Defaults to the current directory. It works, but I have a feeling that it is a shit implementation.

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Arrays;

public class ListDirectory{
public static void main(String[] args) {
// Default directory
String path = System.getProperty("user.dir");

// Check for path argument
if(args.length > 0){
path = args[0];
}

// File objects
File folder = new File(path);

// Check if directory exists
if(!folder.exists()){
System.out.println("Directory does not exist.");
System.exit(-1);
}

// Create array of File objects
File[] fileList = folder.listFiles();

// Array to hold strings of file and directory names
ArrayList<String> filenames = new ArrayList<>();

// Variables for counts
int dirCount, fileCount;
dirCount = fileCount = 0;

// Add strings to array
for(File file : fileList){
if(file.isFile()){
filenames.add("[FILE] " + file.getName());
fileCount++;
}
if(file.isDirectory()){
filenames.add("[DIRECTORY] " + file.getName());
dirCount++;
}
}
System.out.println("DIRECTORY: " + folder.getPath() + "\n");

// Sort alphabetically and print
Collections.sort(filenames);
for(int i = 0; i < filenames.size(); i++){
System.out.println(filenames.get(i));
}

// Print counts
System.out.println("\nAMOUNT OF DIRECTORIES: " + dirCount);
System.out.println("AMOUNT OF FILES: " + fileCount);
}
}

>>
>>59123604
Learn how to write comparators senpai.
>>
rate my scala fizzbuzz
i started programming 6 hours ago so dont be rude
for (number <- 1 to 100) {
var toprint =""
if (number % 3 == 0)
toprint = toprint + "fizz"
if (number % 5 == 0)
toprint = toprint + "buzz"
if (toprint.isEmpty)
println (number)
else
println (toprint)
}
>>
How realistic is it to think i'll find employment if i'm a self-taught C++ programmer?
>>
>>59123686
Not at all, just repeat after me:

>would you like fries with that?
>>
>>59123596
its actually a game, i'm using the term app loosely. basically, its zelda:lttp with modern improvements, a synthwave soundtrack, and a dark adult oriented story.
>>
>>59123662
PROTIP: put code inside <code>...</code> but with square brackets instead of angle brackets.
>>
>>59123686
dont forget to use the "friend" keyword alot, so everyone knows how popular you are. srsly, c++ is poorly designed garbage from a bygone era.
>>
>>59123717
 This is an example post to show what anon is talking about 
>>
I have a semi random question. Why do almost all code programs default to courier new. Is there a special reason?
>>
Trying to convert C code from an executable to a DLL. I'm not getting the same output and have no fucking clue why.
>>
>>59123755
It's a very widely available monospace font that is already installed on most systems.
>>
i just want to make video games to play
i went to computer science because i wanted to program video games like crysis and blackops
>>
>>59123794
>>>/vg/agdg
>>
>>59123805
do they make video games like crysis and blackops there?
>>
>>59123805
Please don't respond to obvious bait.
>>
>>59123824
Yes, totally
>>
>>59123833
i don't see anything about that? what the heck dude?
>>
>>59123857
You have to learn to read between the lines.
>>
>>59123876
explain?
>>
professional programmer here

I will write you one function for your program
>>
>>59123931
You think they're actually posting about what they're posting about?
>>
>>59123944
Write a function that will generate code for the perfect waifu
>>
>>59123944
i would like the identity function please
>>
>>59123944
write me a ps/2 mouse interrupt handler
as C++ class member function
>>
>>59123945
yeah, do you have reasons to believe otherwise?
>>
>>59123970
Yes.
>>
>>59123981
i'm all ears.
>>
>>59123988
Then how are you typing?
>>
>>59123959
perfectWaifu :: ∀ a. a -> a
perfectWaifu = undefined
>>
>>59123997
by hitting the big keys on the machine
>>
>Tfw Java now has Lambda
>>
>>59124053
did java not have functions before?
>>
>>59124071

you can now use -> to get rid a ton of OOP bloat it is very useful and makes Java less verbose
>>
>>59124053
its supported lambdas for a couple of years anon
>>
>>59124053
>took java around 80 years to catch up with everyone else
>>
>>59124084
how does that answer my question?
>>
>>59124053
>java
Die of AIDS already holy fuck
>>
>>59124123
waaay past your bedtime.
>>
>>59124134
Do you have brain damage?
>>
>>59124134
>responding to meme posts
>>
>Javascript
>>
File: Capture.jpg (106KB, 940x654px) Image search: [Google]
Capture.jpg
106KB, 940x654px
>>59121588
Trying to learn me some ruby on rails,

can someone tell me why it's rendering show.html.erb instead of goy.html.erb?

If you can see, the articles controller defines goy.
>>
I have to read and scan a large text file (20+ mb) in java. Then search through it depending on whatever the user is looking for. All advice leads to using Java's stream operations but I can't wrap my head around how to use it.
>>
So, when I write a C program, I compile the source to object code, then link the object code to an executable, right?

Let's say I have a really basic program that doesn't use any external libraries. If the object code is just machine code with no external dependencies, why can't I just compile the source with "gcc -c" and run the object code directly?

Why do I still need a linking step in this situation?
>>
>>59121720
C stands for cancer
>>
>>59124201
do not defile anime by your redditry.
>>
>>59124194
> using notepad++ to code
Scared of a real IDE?
Scared of a debugger?
>>
>>59124233
Yes to both, thanks for the help.
>>
>>59124201
That is one of the best books for java programming it is really good with all the exercises in there for every single subject on programming
>>
>>59124233
Scared of not shitposting?
>>
>>59124233
Vim + GDB master race
>>
>>59124156
Obviously he does since he's using java.
>>
File: 1455950055870.jpg (32KB, 300x470px) Image search: [Google]
1455950055870.jpg
32KB, 300x470px
Hey guyz how can i print the following with C?
1 2 3
1 2 3
1 2 3

I'm using C if that matters XD The best language :DD
>>
>>59124270
return to your shitty thread, namefag.
>>
File: 1479234222596.gif (1MB, 300x300px) Image search: [Google]
1479234222596.gif
1MB, 300x300px
>>59124207
somebody PLEASE respond
>>
>>59124270
>>59124279
Looks like the type of problem a C toddler would run into
>>
File: 1488067629397s.jpg (5KB, 193x250px) Image search: [Google]
1488067629397s.jpg
5KB, 193x250px
>>59124279
No bully
>>
>>59124288
Im using C btw
>>
>>59124301
THAT DOESN'T ANSWER MY QUESTION
>>
File: superior_gui_library_javaFX.png (445KB, 433x713px) Image search: [Google]
superior_gui_library_javaFX.png
445KB, 433x713px
>>59124224
Sorry senpai is this better

>>59124248
It has helped out a bunch.
>>
>>59123618
why?
>>
>>59124288
I was thinking about responding, but then you posted a fucking frog.
>>
>>59124303
I'm using C if that matters
>>
>>59124308
i ran out of animes
>>
>>59124314
yup, that was a trick question. definitely confirmed for plebbitor.
>>
>>59124207
>>59124288

File formats. An object file is not an executable. Neither one is raw machine code. An executable is an ELF binary on Linux, Mach-O on Mac, etc. They have headers and other structure.
>>
>>59124304
how is that Pro JavaFx 8 one? I have never seen it or read it
>>
You a data structures man, or an algorithms man?
>>
>>59124353
"Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious." -Fred Brooks, The Mythical Man-Month
>>
>>59124324
But aren't both these files ELF binaries?

user@box:~/test$ file test.o
test.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
user@box:~/test$ file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped


I used "gcc -c test.c" to make test.o, and "ld test.o" to make "a.out".
test.c is just an empty main function.

I guess my question is, what is the object file missing in particular that prevents it from being run?
>>
>>59124270
(let ((x '(1 2 3))) (format t "~@{~{~a~^ ~}~^~%~}" x x x))
>>
>>59124345
I haven't read through it yet, I did read some other one made by the same people called "Learn JavaFX." Only the threading section tho.

They don't have a lot of fluff, just straight to the point, so whether or not that is good is up to you.
>>
>tfw had to copy the insert sort pseudocode and run it to understand how it works
fuck, why im such a brainlet /dpt/
>>
>>59124408
Apply yourself.
>>
>>59124408
You have to look at lots of different code and solutions to code and how it is explained to fully understand how to program it is a long journey
>>
>>59124418
(apply self '())

okay what's next?
>>
>>59124371
ples respond
>>
>>59124427
(remove-if (lambda (x) (eq x 'you)) gene-pool)
>>
>>59124371
Huh I didn't know object files were ELF too. It says it's a "relocatable" so I think that means it's a library. It probably doesn't have an entry point pointing to main(). In the executable it doesn't have one pointint to main() either, it would point to __start() or something, which calls your main().
>>
>>59124482
Yeah, I think you're right.
Here's a diff of both files' readelf outputs: http://pastebin.com/raw/sLpXmnxU

I understand the parts about entry point, but not much else
>>
<html>
<body>
<b>
<p>
welcome to my website
</b>
</p>
</body>

Just getting started.
>>
>>59124576
Stop while you still can
>>
>>59124576
nice anon, check this out


<h3 style="border:red;">This is red!</h3>
>>
File: yellow rage.png (448KB, 900x900px) Image search: [Google]
yellow rage.png
448KB, 900x900px
>>59124576
><b><p>
></b></p>
>>
old language officially discontinued
new language officially in development
>>
https://www.youtube.com/watch?v=XHosLhPEN3k
>>
>>59124690
What do you mean, doggo?
>>
>>59124742
my old language (Malfoy) is dropped. im starting a new language that compiles into Erlang and is based on Ruby (but is nothing like Elixir)
>>
Isn't D a garbage collected language? If so, is it required to have a D runtime environment or a virtual machine installed in the machine to run a DMD compiled D binary?
>>
>>59124802
when are you going to release Jai, johnathan?
>>
File: oc programming.jpg (407KB, 2048x1765px) Image search: [Google]
oc programming.jpg
407KB, 2048x1765px
Working on a city building game as part of 3rd year comp sci. Pic related sums up some of the worst examples of code in terms of aesthetics I've written for this project. Works perfectly mind you.

It's fun though, recently learnt to use a texture atlas in opengl as well as game loops and the like. Currently building an agriculture tick function that will process the growing of crops, its pretty comfy.
>>
>>59124882
>leftCon == true && rightCon == false
>not leftCon && !rightCon
>>
>>59124882
> passing 4 booleans seperately to a function, instead of using a bitField or list of booleans
i could optimize the shit outta that code
>>
>>59124882
open source it when you're done
>>
File: 1444992494491.png (260KB, 563x542px) Image search: [Google]
1444992494491.png
260KB, 563x542px
>>59124953
When confronted with not having to think and getting it done within a minute or so and having to put literally any effort into it at all, I chose the more common option.

I'll maybe get around to optimising it later but it works for now eh?

>>59124907
I like this, think I'll use it later. Cheers
>>
>>59124953
but you won't, because unlike >>59124882 you have never accomplished anything and never will
>>
>>59124371
>>59124482
Executable AND LINKING format. Apart from those 2 things it also stores core dumps. Think of ELF as a general purpose process file format.

The linkers job is to resolve a name(i.e. main) to an address. An example, you have 2 separate objects, foo.o and bar.o. In foo.o, you have a function `foo' and you need to call function `bar' in bar.o. When bar.o is compiled you cannot give it a definite address, how would foo.o know where `bar' is?

Instead neither object embeds a definite address, they use a relocation table. It's essentially a list of (symbol, offset) pairs to define the object. That's what the linker uses to resolve the addresses.

Library loading is actually pretty complicated, especially with dynamic loading.

To answer the question: what's missing is those addresses, and obviously an entry point(where to begin execution).
>>
File: 1487721924356.gif (2MB, 220x190px) Image search: [Google]
1487721924356.gif
2MB, 220x190px
>>59124989
bully.

actually i've written 7 games (on my 8th), am a contributing dev to an open source project, used to develop 3d plugins (which were used worldwide), and started this while ride more than a decade ago building shitty flash websites.

so suck my nuts little guy
>>
>>59124882
>(*it)->
My least favourite aspect of C++98 iterators
Can you use C++11/14 style? Makes iteration so much friendlier and less bug-prone.

I noticed you've got integers describing building types - have you considered making an enum for it? Just a thought.
>>
Useful tip of the day: stack alignment
and esp, -0x10
>>
>>59125069
How can I use this in my node.js project?
>>
>>59125047
>Anonymous
wow ok cool

tell us more pls anon
>>
File: 1487017015668.png (2MB, 4124x5928px) Image search: [Google]
1487017015668.png
2MB, 4124x5928px
>>59125048
We're only just being taught C++ 11/14 style this term now so for now I'm sticking with the old ways and since I've written a bunch of code already, I don't want to make it inconsistent.

From what I've seen of the newer styles, it's so much better and I'm really looking forward to using them more in the future. It's just so much cleaner to say the least.

Again same with the building type, its been defined as an int and used everywhere through the code so I'm sticking with it as is. You know I've never actually used enum's before in my code, I haven't seen much of it in practical examples either in code we've been given or in fellow student's code. I may give them a proper look over for some of my assignments coming up, thanks.
>>
>>59125078
Buffer overflow in the interpreter.
>>
>>59125047
Yeah? Well actually i've written 8 games (on my 9th), am a contributing dev to an libre source project, used to develop 4d plugins (which were used galaxywide), and started this while ride more than a century ago building shitty babbage machines
so rim my ring big guy
>>
>>59125104
> when you non-ironically make a fresh pasta
fuck, what have i become?
>>
>>59125046
I see, thank you for the detailed response.

I am interested in learning more about the ELF format and how linking/loading works.

Would you know of any easy-to-read resources I could use to learn more?
>>
>>59125138
For ELF, the file format is explained in the elf man page. You might also want to reference <elf.h>.

For linking, not sure. Can't remember why I know. Search around for dynamic linking/loading, sure to find articles.
>>
>>59125188
Will do, thanks again
>>
>>59124882
struct TransformInfo {
bool left, right, up, down;
unsigned type;
};

std::vector<TransformInfo> Infos = {
{{true, false, false, false, 10}},
// ...
};

void transformSelfRoad(int x, int y, bool left, bool right, bool up, bool down)
{
int type = -1;
for (const auto &info: Infos) {
if (info.left == left && info.right == right && info.up == up && info.down == down) {
type = info.type;
break;
}
}

if (type == -1) {
return;
}

for (auto &building: buildingPtr) {
if (building->getXPos() == x && building->getYPos() == y) {
building->setBuildingType(type);
}
}
}
>>
>>59125251
(((struct)))
>>
File: 1444990712650.jpg (34KB, 368x368px) Image search: [Google]
1444990712650.jpg
34KB, 368x368px
>>59125251
Cheers will look into implementing later, got the code pasted into my cpp and commented out for now.
>>
>>59123662
>toprint =""
garbage as you assign an empty string that will never be used.
why not assign number to it and overwrite if necessary?
>toprint = torpint + fizz
just make it:
toprint = fizz
>>
Hey /dpt/
What would you recommend to a Sysadmin willing to improve his code? (mainly Python by now)
Is SCIP only a meme or actually good?

I only recently started to use git and I love it. I see potential to automate a lot of things with git + ansible.
>>
>>59125610
>meme is defined as the opposite of good
Fuck off back to the shitty website you came from.
>>
Requesting the pic of /g/ programming challenges, pls anons
>>
>>59125610
>hey /dpt/
>code
>"SCIP"
>reddit formatting
>"meme"
Pretty obvious attempt. But at least you tried.
>>
>>59125640
No. Go away.
>>
File: 1486509005680.gif (2MB, 500x342px) Image search: [Google]
1486509005680.gif
2MB, 500x342px
Daily reminder why Rust will never be popular

> Rust is currently unable to call directly into a C++ library
>>
>>59125802
what languages can?
>>
>>59125812
Ada does decently
>>
>>59125610
SICP won't do you any good for automation, learn the Python standard library for process spawning, text processing and what not and also if you don't want to deal with cron this library is quite handy: https://github.com/dbader/schedule
>>
>>59125812
C++ can sometimes
>>
>>59125802
That's C++'s fault, not Rust's.
>>
>>59121588
I want to fuck dpt-chan
>>
why aren't you using swift (front-end) + haskell (backend logic) to make macOS gui's?

https://github.com/nanotech/swift-haskell-tutorial
>>
>>59125802
No one can, they all need a C middle man. This is why you don't write C++ libraries if you intend for it to be used everywhere like C libraries
>>
>>59125850
Because that sounds like an awful experience
>>
>>59125819
Thanks.

I wonder if there's an easy introduction to unit testing.
That's the one thing I never got around learning.
>>
Is Java programming even that hard?
>>
>>59125893
>unit testing
Don't bother
>>
>>59123763
Did you turn optimizations off? Dynamic linkin makes inlining at least more difficult i would imagine
>>
>>59125825
kek
>>
>>59124207
Along with file formats, linking is also done with the stdlib i believe. On windows for example, i believe you dont get to use floats if you disable the standard library linking
>>
File: 1471655512416.png (451KB, 718x904px) Image search: [Google]
1471655512416.png
451KB, 718x904px
>mfw coding in Fortran
You have to declare and set up everything yourself Jesus Christ lfmao what a barebone language
>>
Rate my fizzbuzz
print('\n'.join(list(map(lambda i: "Fizz Buzz" if i % 3 == 0 and i % 5 == 0 else "Fizz" if i % 3 == 0 else "Buzz" if i % 5 == 0 else str(i), [i for i in range(1, 21)]))))
>>
File: Capture.png (130KB, 802x627px) Image search: [Google]
Capture.png
130KB, 802x627px
Comfy simulator
>>
File: 1470683823791.png (192KB, 714x963px) Image search: [Google]
1470683823791.png
192KB, 714x963px
>>59123278
>C-like
Why?
>>
can anyone tell me how I can turn a into kanji again?

# -*- coding: utf-8 -*-
import re
s = 'your mother is a わたしは にほんごがすこししか はなせません'
a = str(re.findall('.* is a (.*)', s, re.IGNORECASE))

print a
>>
>>59126100
Thanks for replying to my 6 hour old post.
Most popular programming languages are C-like, though. Although I'm not making it because I want it to be popular, it's just something I want to do to test out some ideas, and also just for the fun of it.
I'm very aware that some of the examples are extremely ugly. C's function pointers are infamous in that way. I was wondering if there was a better way of expressing the syntax, while staying somewhat close to C.
>>
>>59126262
>Trying to use Unicode in Python 2
Use Python 3 and it will just work. All you have to do is add parens to your print statement.
>>
>>59126262
Didn't memesnek 3 fix all of the unicode shit?
>>
>>59126262
yes, use python3
>>
>>59126296
not an answer
>>59126304
not an answer
>>59126306
not an answer
>>
>>59126315
I'm pretty sure those are answers, you snekshitter.
I ran your dumb shit through python3 and it worked fine.
>>
>>59126315
okay, here's a proper answer then https://docs.python.org/2/
>>
>>59126322
who the hell uses python 3? everything I use uses python 2.7. I figure those people had this same problem and they solved it without going to memesnek3

just say "I'm as stupid as the person asking" and it will all be understood
>>
>>59126345
Nice reddit formatting you have there.
I'm sure everyone is going to take your opinion seriously.
>>
>>59126350
I'm not giving an opinion, I'm asking something no one is incapable of solving without telling me to use python 3. That's what happens always in this board
>>
Inheritance and subclasses was a mistake.
>>
>>59126394
OOP was a mistake.
>>
>>59126394
Why's that? I think used correctly it was a very good paradigm
>>
>>59126369
>Try to change your formatting to "fit in"
>You still let it slip
Anyway, why are you snekfags so insufferable and resistant to change?
You're fucking worse than the C89fags.
>>
>>59126404
typeclasses deprecates it

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.99.8567&rep=rep1&type=pdf
>>
>>59126414
No solution, only excuses.

I guess that's how /g/ rolls
>>
>>59126404
Because using them correctly takes so much work and concentration that it negates any intended benefits.
>>
>>59126427
You can fuck right off then.
Your kind is not welcome here.
>>
Why is Go so good?
>>
>>59126439
It's not though?
What are you talking about?
>>
>>59123278
>>59126285
Don't just blindly copy C:

https://eev (dot) ee/blog/2016/12/01/lets-stop-copying-c
>>
>>59126262
You don't.
>>
What language is the most likely to get someone employed?
>>
>>59126528
English
>>
that TSR guy

T, S, R are data constructors, they all have the same type of TSR (which is a sum type).
>>
>>59126533
Lost
>>
>>59126448

Uh ya it actually is...very much so. The logo is gay tho
>>
>>59126427
>rejects solution given
>claims we're being unhelpful
seems like you're the one making excuses
>>
>>59126540
It wasn't very funny
>>
>>59126558
Lost
>>
>>59126553
you make excuses not to show you don't know how. I make excuses not to have to rewrite my fuckng script. Everyone makes excuses.
>>
>>59125875
But everybody writes C++ libraries.
>>
>>59126540
>>59126570
Are you looking for reddit?
>>
>>59126584
Who? Almost every library that is trying to be taken seriously is written in C.
>>
>>59126577
Just fucking stop you retard. Python 2 strings do not go beyond ASCII, you can get it back as Kanji only as a byte array or Unicode object - which you're already doing albeit wrong because you're converting the entire result list to a string instead of its elements. If you want to have Unicode-aware str type then you use Python 2, otherwise you use byte arrays.
>>
>>59125802
Retard
>>
>>59126606
s/use Python 2/use Python 3
>>
>>59126462
Who said I was blindly copying C?
>>
>>59126592
Every modern library that people want to use is C++, anon.
>OpenCV
>TensorFlow
>Qt
>etc
>>
File: 1464368374034.webm (685KB, 1364x835px) Image search: [Google]
1464368374034.webm
685KB, 1364x835px
>>59121588
>what are you working on /g/?
this
>>
>>59126262
print unicode(a[0], 'utf-8')
>>
>>59121720
n-no it's stands for [D]eliciousa!
>>
>>59124882
>no const correctnes at all

what the fuck do they teach you at your university? it took me 3 months to get const correct in c++, and you can't get it in 3 years?
>>
>>59126707
const correctness is a meme
>>
Which GTK applications should be ported to Qt?
>All of them

Which GTK applications should be ported to Qt next?
>>
>>59126839
better start working on Qt bindings for Vala
>>
>>59126839
Qt is garbage as well. I don't know why you would waste your time porting anything to that.
You're basically taking a pile of horse shit and trying to change it into a pile of cow shit.
>>
>>59126877
>I'm too stupid for Qt
>>
>>59126707
const doesn't even do anything. You can change const parameters if you try hard enough, the compiler isn't that smart.
>>
>>59126877
Qt is the least worst toolkit for GNU/Linux.
>>
>>59126894
That's undefined behaviour, fuckface.
>>
>>59126894
sure you can do, your team will surely appreciate your technique in the code review
>>
>>59126907
>undefined behavior
>what is pointer arithmetic
>>
>>59126926
>>what is pointer arithmetic
That has literally nothing to do with what we're talking about.
>>
File: fuck.png (90KB, 512x512px) Image search: [Google]
fuck.png
90KB, 512x512px
Finally got some fucking 8-bit textures dumped from SILENT HILL 3...
>>
File: waschbecken_stoepsel_big_37874.jpg (63KB, 610x610px) Image search: [Google]
waschbecken_stoepsel_big_37874.jpg
63KB, 610x610px
https://stackoverflow.com/questions/42468347/how-upload-files-to-a-specific-html-tag-using-php-and-mysql

good question, linked image, and user profile
woow
>>
The whole point of a systems programing language is to work smoothly with the underlying operating system, no?

If so, then why is Rust so bad at doing so?
You can't use any system calls without first wrapping them in functions to make them safe
>>
>>59127680

Try to have/eat cake, simultaneously. That's its major flaw.
>>
>>59127680
Once wrapped they can be packaged as a library and re-used
>>
>>59122158
false
>>
I need some help with python. I can't get this while function working correctly. I'm trying to make a function that will count the number of even digits in a number.
def num_even_digits(n):
count = 0
while n / 10 != 0:
n = n // 10
if n % 2 == 0:
count = count + 1
else:
continue
return count


If I test it with the arguments 222. It outputs 3 which is correct. If I test it with 221 it outputs 3 which isn't correct. But if I test it with 22212 it outputs 4 which is correct. So I don't know what's going on. What did I do wrong?
>>
>>59128023
The code you posted doesn't test the first rightmost digit.
>>> num_even_digits(222)
2
>>> num_even_digits(221)
2
>>> num_even_digits(22212)
3

I assume you have updated the code if you're getting the results you claim? Otherwise, reserve the floor division till the end of the loop.
>>
>>59128023
your code doesn't test the first (rightmost) digit.

def num_even_digits(n):
count = 0
while n != 0:
print(n)
if n % 2 == 0:
count += 1
n = n // 10
return count
>>
File: tim.png (261KB, 606x444px) Image search: [Google]
tim.png
261KB, 606x444px
>>59121588
>What are you working on, /g/?
I made a program which checks all userstyles added with StylRRR addon (https://addons.mozilla.org/en-Us/firefox/addon/stylrrr/) and replaces them with the most up-to-date versions from userstyle.org so now I have completely replaced the Stylish botnet. Currently deciding if I make GUI for it.
>>
>>59121588
Rate my fizzbuzz:
                                                                                                                                                                                                                                                                     


Fuck you!
>>
I wrote a simple python script for a friend.
Needless to say he uses windows.
Is there a way to convert/compile the script with the python executable into one exe?
>>
>>59128302
http://www.py2exe.org/
>>
File: 1476811327277.jpg (38KB, 640x480px) Image search: [Google]
1476811327277.jpg
38KB, 640x480px
>>59128268
>>
>>59128320
I'm sorry I should have been more clear.
I'm using linux, is there a way to convert py scripts to windows excutables on linux?
>>
>>59121588
>What are you working on /g/?
Upboat and tags for 4chan

It's a REST web service that allows you to tag posts with icons, e.g. LOL, U MAD, IRONY and so on

A GreaseMonkey extension then overlays the votes on 4chan

Version 2 will support upvotes and downvotes but I'm not sure about the best UI for that yet
>>
>>59128231

TimBL is British. Of course Trump isn't his president.
>>
>>59128371
DELET
>>
File: drone.jpg (401KB, 2000x1000px) Image search: [Google]
drone.jpg
401KB, 2000x1000px
>>59125812
>what languages can?
That which wants to defeat C++!
>>
>>59128179
I tried shifting the floor division to the end of the loop but it just resulted in an infinite loop.
>>
>>59128592
>>59128179
Nevermind. I figured it out
>>
>>59121588
Fizzbuzz Hypercube edition: Construct a 100 dimension hypercube where the nth vertex contains the result of the nth iteration of fizzbuzz.
>>
>>59128670
What do you mean by "contains"?
>>
>>59128724
Should be "associated with," but I had in mind an illustration in which each vertex was either numbered or contained one of Fizz, Buzz, or FizzBuzz.
>>
>no stupid question thread up
Ok boys help me out.

Whats the difference between "programming" and "coding"?
Are Java, Python, C++ and Ruby on Rails all programming languages?
How many do you know/are learning? Which is/are recommended/necessary for most jobs?

Is programming/coding necessary for web design? What stuff might you need for web design? CSS, HTML?

Are all these languages, html, css, etc universal around the world regardless of linguistic language?
>>
>>59128859
It doesn't really matter. Your number one priority is being able to learn new things quickly.
>>
File: 1471671029308.png (99KB, 422x309px) Image search: [Google]
1471671029308.png
99KB, 422x309px
so /dpt/ this term in university I have to write a project in C++ and I'm going to make a simple roguelike game from scratch (imagine a shitty version of DCSS) because it sounds fun
the question is that I'm new to coding and i'm having second thoughts because making a game from scratch sounds something hard and out of my beginners skill range, should I go for this? if yes then can anyone point me to the right direction OR I should just go for a simple text adventure game and that's way out of my league.
pointers and tips for both projects are much appreciated
>>
>tfw too stupid to learn coding
why is it that whenever I try to learn coding or basically anything that cannot be fully understood in one sitting, I get a weird headache and my brain just shuts down.
>>
>>59128873
>Dear hiring manager, I don't know any programming languages, html, css, premiere, after effects, photoshop, maya, 3d modeling, animation, or non linear editing systems, but im a fast learner :)
>>
>>59128903
Chunk tasks to ease your mind.

You're daily schedule may be
>groom
>go to work
>go shopping
>cook and eat dinner
>clean up
which is pretty simple and easy to manage, but each of those is comprised of tons of smaller tasks. if you thought about each of those individual tasks all at once it would certainly give you a headache.

set small goals, focus on them and dont rush. as with anything in life
>>
>>59128928
>he doesn't know how to lie
Either way, nowhere in my post did I suggest going into an interview without a lick of experience, you buffoon. My point still remains. You will be valuable if you can pick up new things quickly.
>>
>>59128998
no one said a thing about experience, were talking pure ability.

you cant lie about experience. theyll ask you what you did at some place and likely even contact that employer.

lie about your ability? they almost always ask for a portfolio or example and theyll be able to tell if you dont actually possess a certain skill
>>
>>59128964
I will try, thanks
>>
>>59129028
>no one said a thing about experience, were talking pure ability.
You gain such ability through experience with your tools. Do you not understand how to interpret the word experience?
>>
>>59129115
youre really stretching that word to suit your needs. my initial questions are obviously from someone who "hasnt a lick of experience" in any of these looking for basic information on where to start. all you said in response was "doesnt matter just be a fast learner'
>>
>>59128859
>Are all these languages, html, css, etc universal around the world regardless of linguistic language?
Yes.
>Is programming/coding necessary for web design? What stuff might you need for web design? CSS, HTML?
Ask in webdevgeneral. But I'd say you would need to know at least CSS HTML and javascript.
>Are Java, Python, C++ and Ruby on Rails all programming languages?
Pretty sure, yes.
>Whats the difference between "programming" and "coding"?
Not really well defined imo
Scripting however I would argue is distinct; specifically I would say scripting is something like making a short program with an interpreted language.
>>
>>59129292
>Scripting however I would argue is distinct; specifically I would say scripting is something like making a short program with an interpreted language.
Also, this being said, scripting is still programming. It is a certain kind of programming.
>>
>>59129228
I am not stretching the word at all. If you are having trouble interpreting this word, I suggest taking a basic course in English. You will accrue experience in a language which may prove valuable to a potential employer.
>>
>>59129028
>no one said a thing about experience, were talking pure ability.
I think the word you're looking for is talent
An experienced individual is generally going to be more able than before they accrued that experience, thus 'ability' surely must account for experience.
>>
File: 1474325315193.jpg (44KB, 636x616px) Image search: [Google]
1474325315193.jpg
44KB, 636x616px
>>59126528
>What language is the most likely to get someone employed?
Haskell
>>
How does learning a programming language compare to learning, say, Chinese?

Is harder to become function in Java or fluent in Chinese?
>>
>>59129654
Fluency in Chinese is much harder.
You'd need to live there for years.
>>
File: wojak_brain_1.jpg (32KB, 402x414px) Image search: [Google]
wojak_brain_1.jpg
32KB, 402x414px
>Tried leetcode over reading week
>Struggle to come up with solutions that have good time complexity.

Im not going to make it....
>>
>>59129738
It's NP-hard.
>>
>>59126639
Noob here. I am curious on how you are able to do that anon. I remember youtube had that kind of "linked thread" back in the day. I always thought it was the best way to trace previous comments. Anyways, I am truly curious to see how you are able to do that. Cheers!
>>
>>59129583
Who's ell
>>
>>59124270
puts("1 2 3\n 1 2 3\n 1 2 3");
>>
http://250bpm.com/blog:8
>Why should I have written ZeroMQ in C, not C++
sepples turds BTFO!
>>
For a personal project, I need to "regroup" (for lack of a better word) data as follows:
I'm taking a list of tuples where the left value is a list of categories and the second is a value
I want to output it as a list of categories and along with values.

For example: I'll take in the list
([cat, dog], 5)
([mouse, horse, dog], 7)
([cat, mouse], 3)
([mouse, dog], 8)

And output:
(cat, [5, 3])
(dog, [5, 7, 8])
(mouse, [7, 3, 8])
(horse, [7])

I've written this code:
regroup :: Ord a => [([a], b)] -> [(a, [b])]
regroup = M.assocs . foldl' (\m -> uncurry (multiadd m)) M.empty

-- Insert the given value into multiple keys
multiadd :: Ord a => Map a [b] -> [a] -> b -> Map a [b]
multiadd m ks val = foldl' (\m' k -> M.insertWith (++) k [val] m') m ks


However, I have a suspicion that it's not efficient and there's probably at least one bug. Is there a term for what I'm trying to do? I'd rather not be re-inventing the wheel and just use an existing Haskell library.
>>
File: IMG_0295.jpg (457KB, 2500x1667px) Image search: [Google]
IMG_0295.jpg
457KB, 2500x1667px
Working on a remote for my eos700d.
Apperently it is working as expected. Now just gotta programm a timing function.
Then buy a nice, small LCD, fit everything onto a small PCB and we are done.
T-2Months to go, so plenty of time
>>
>>59128898
it's not that hard if you limit yourself a little, we've had one assignment like that for programming 102 in uni. You won't make a full big roguelike in one semester especially if you're a beginner. A small subset of the functionality is possible to make though. Text adventures are way too basic, that doesn't even require that much coding, definitely don't do that for a uni project.

Familiarize yourself with the curses library. Make a game loop (Get input->update logic->update the screen->repeat)Then start with just getting a map on screen with some walls and a player character and try to get the player to move, then handle collisions so he can't pass walls, add somr static npv first, handle collisions with them, then make them move maybe, then add some ai so they walk towards the player etc. DO it step by step, make sure you debug it until it works only then start coding new features.

Here's a nice article on FOV in roguelikes that might come in handy: http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html
>>
File: 1473210615551.jpg (75KB, 545x939px) Image search: [Google]
1473210615551.jpg
75KB, 545x939px
>>59129801
Tbh it's really hackish and disgusting right now because when I started I didn't know a lick of javascript; i'm trying to rewrite it so it's cleaner.
>>
>>59130130
>when I started I didn't know a lick of javascript
I should also say I still don't really know much as this is the only javascipt i've ever done, but I think I can improve it a fair bit anyway.
>>
How do I run a 1st function without any arguments, but then have the return of the 2nd function be the argument for the 1st function? I can't run the 1st function because it expects an argument. But I don't need an argument for it right now. I want the argument for it to be the return from another function.

def start_game(a):
print("Starting the game now.")
play_once(True)
if result == 1:
print("I win!")
elif result == 0:
print("Game drawn!")
elif result == -1:
print("You win!")


start_game()
>>
>>59130254
You can have a default argument

def do_something(a=0):
print(a + 1)

do_something()
do_something(5)
>>
File: 1483234737598.png (46KB, 476x583px) Image search: [Google]
1483234737598.png
46KB, 476x583px
>>59129801
And pic related is the start of my attempt to rewrite it.
>>
>>59130396
How do you program in that font
>>
>>59130396
Why the fuck are you using that font?
>>
>>59130254
If you weren't doing full retard python and you were using something like c then you could use a switch statement. Switch statements and ternary operations are simply the best.
>>
>>59130419
pattern matching > switch statements
>>
>>59130412
>>59130410
What is wrong with it?
>>
>>59123278
What will it compile into? That's gonna be a whole bloody load of work.
>>
>>59130494
>serif
>not monospace
>cannot easily distinguish lower case L and digit 1
>>
File: 1473535455703.png (426B, 178x18px) Image search: [Google]
1473535455703.png
426B, 178x18px
>>59130530
>>cannot easily distinguish lower case L and digit 1
Looks pretty obvious to me
>>
>I am subscribing to support essential investigative journalism such as the New York Times, Los Angeles Times, and Washington Post.
where were you when codinghorror killed itself?
>>
>>59123794
You can only program those kind of games by joining a large game company where you'll probably just recycle old games, make microtransactions/dlc or take on a pointless bit of the project. Either find a reliable indie company (e.g. not making early-access survival games) or get out. If this wasn't bait, that kind of world isn't worth your time.
>>
>>59123944
Write an ackerman function but everytime it recusively calls itself, it opens a new window.
>>
>>59130377
I was stupid. This was all I had to do
def start_game():
print("Starting the game now.")
result = play_once(True)
if result == 1:
print("I win!")
elif result == 0:
print("Game drawn!")
elif result == -1:
print("You win!")
>>
>>59124270
Here's another one:
(format t "~3@{~{~a~^ ~}~:*~^~%~}" '(1 2 3))
>>
>>59124053
Really? Does it take 100 lines to make a single Lambda function?
>>
>>59130396
Ignore the haters m8. Proportional width fonts are good for programming. Larger tabs could do, though.
>>
>>59124264
Can't go wrong when using vim with :syntax on. Remember kids, some of the most essential things we use today were made in a command line, without fancy Visual Studio.
>>
>>59126089
Are you using processing for that?
>>
>>59130606
just stop posting m8
>>
File: syntaxon.jpg (63KB, 700x340px) Image search: [Google]
syntaxon.jpg
63KB, 700x340px
>>59130634
terminus + vim + solarized faggot detected

>>59130618
>:syntax on
>>
Does anyone have any idea how you would go about making something like vim in a console. Do you have to use a special library or is just priting to the console then clearing it over and over again.
>>
>>59130654
It looks so much prettier desu.
>>
Try this out in Python:

def make_closure():
i = 0

def my_function():
result = i
i = i + 1
return result

return my_function

make_closure()()
>>
>>59124194
Bump for this please.
>>
File: tfw__.png (31KB, 372x300px) Image search: [Google]
tfw__.png
31KB, 372x300px
>tfw the more you learn, the more you realize how wrong you were
>>
File: 1465091917375.jpg (40KB, 390x418px) Image search: [Google]
1465091917375.jpg
40KB, 390x418px
>>59130419
>switch statements
>C
>>
Suppose I am multiplying two NxN matrices, T=A*B. This is the algorithm I need as I understand it.

>by M(x,y) I mean the entry in M at row x, column y
>to compute T(x,y):
>let left_row equal y
>let right_col equal x
>var result equal 0
>for i in 1..N:
>let left_entry equal L(i, left_row)
>let right_entry equal R(right_col, i)
>add (left_entry * right_entry) to result
>end for
>set T(x,y) to result

Questions:
>Is this correct?
>Is this a good way to think about it?
>Is this a not-totally-inefficient way to implement it in code?
>This is for row-major. Why do some APIs use column-major? It would seem to only complicate things without giving advantages.
>>
>>59131039
Nigga I am not reading all that shit.

void
matmul(Matrix a, Matrix b)
{
int i, j, k;
double sum;
Matrix tmp;
for(i=0;i!=4;i++) for(j=0;j!=4;j++){
sum=0;
for(k=0;k!=4;k++)
sum+=a[i][k]*b[k][j];
tmp[i][j]=sum;
}
for(i=0;i!=4;i++) for(j=0;j!=4;j++)
a[i][j]=tmp[i][j];
}


For a 1D array, substitute [i][j] for [i*4 + j].
>>
>>59128344
Anyone?
>>
>>59131195
pyinstaller
>>
>>59131215
Wasn't there some controversy over it being malware or something?
>>
New thread:

>>59131250
>>59131250
>>59131250
>>
>>59131245
Dunno. Google isn't returning any results about it *itself* being malware.
>>
>>59126462
This furry blog is absolute fucking garbage
>C is shit because logic ! operators are hard to see
>C is shit because brakes are unnecesary
>>
>>59131123
Language?
>>
File: tmp_7142-1486111903655-580155076.png (225KB, 868x1224px) Image search: [Google]
tmp_7142-1486111903655-580155076.png
225KB, 868x1224px
where to move from html, css, js/jq?
>>
>>59129958

Here's a silly version, without resorting to Maps.

ir = sort $ concatMap tuples input
where tuples (xs, y) = zip xs $ repeat y

main = print $ map (first head . unzip) grouped
where grouped = groupBy (on (==) fst) ir
>>
File: 1486041039860-1.png (2MB, 3840x2160px) Image search: [Google]
1486041039860-1.png
2MB, 3840x2160px
>>59125640
Thread posts: 318
Thread images: 39


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