/dpt/ - Daily Programming Thread

What are you working on?

Previously

Attached: 1517452147559.jpg (1291x3600, 610K)

Other urls found in this thread:

youtube.com/watch?v=uNjxe8ShM-8
reddit.com/r/anime
codepen.io/Lindsor/pen/qdJMwK
stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule
twitter.com/NSFWRedditVideo

Haskell and Smalltalk.

>no anime girl in op
Kuso thread.

Attached: 1524792918662.jpg (1280x720, 164K)

>/dpt/
Where's the dp and anime?
Also is LaTeX a good way to make a document where you can have code embedded nicely into the document?

Attached: 1496413542676.jpg (382x415, 99K)

The 'listings' package, my dude.

Did you remember to do your daily reading of [THE BOOK] today?

Attached: Structure and interpretation of poopoo and peepee.png (1198x1728, 200K)

You're a fucking baka

Thanks user.

I'm working on an n puzzle solver where I have to get the Manhattan/taxicab distance of a n puzzle that is represented using a 1d array where all the elements are in row major order. Is it possible to get the distance without converting the array into a vector?

Careful kid, before I unleash my wrath.

Attached: 1524956303238.jpg (1920x1080, 504K)

Hey Jow Forums, I fibbed about having a degree and got a job working on a website using Zend framework.
I know absolute jack shit about Object Orientated Programming. Anyway the whole concept of ServiceManagers and Factories goes way over my head.

>POO

Attached: 1518706775928.jpg (5000x5000, 765K)

why is it that when I include something (like library) it fucks up everything in sepples?

1. everything ok, it compiles and runs
2. #include
3. everything red like there is an scope that is still open
wtf?

Attached: 1466716035850.png (541x541, 280K)

noob question: I have a file foo.c and I include stdio.h there.
in main.cI include foo.h and I also include stdio.h
Is there some kind of header guard for standard libraries or is it OK to include them in whatever files that needs them?

It's gotten to the point where I don't know if I'm laughing at the absurdity of adults making poo poo pee pee jokes or if I'm laughing at poo poo pee pee jokes myself.

Stop using C++

What is the most unexpected turing complete languages?

css

you can do branching in css???

My dick.

C

I'm not a webdev or anything close to that, but I need to create a website for a very small company I'm working on right now. The little knowledge I have on webdev is some basic JS/jQuery, HTML and CSS shit, along with some experience on PHP using the Laravel Framework.
All I need is a basic website with login functionalities and a basic shop that automates queries to an existing database.

My question is, what's the best way to tackle this in a clean and easy way? I'm not looking to build a base to create multiple websites of the same format, it's a one and done kind of deal. Do I just pick up some PHP framework, such as Laravel, and go off of that? Or would there be a better way using some other language?
I don't really know my way around in web development, so I have no clue what to use. pls halp

you have to actually have to tell the compiler how to link the library.

use the -l for dynamic linking

its a header only library and it gives me the following error:
>header stop not at file scope

all other dependencies work perfectly

PowerPoint
youtube.com/watch?v=uNjxe8ShM-8

Reminder that jaba can't even cross platform console beep.
It is so poo that you can't do a simple smooth resize on an empty window using OpenGL

Magic: The Gathering

Back to reddit.com/r/anime

That's an issue with your IDE, not C++.

codepen.io/Lindsor/pen/qdJMwK

What's a good practice project structure?
*.c files in /src/
*.h files in /includes/
final executable in /bin/
?

seems to be a missing ; somewhere. the error only happens in 1 specific header file. very strange

I dunno what your doing wrong. GLI.hpp is that opengl lib right? If so, I tired including it and got no errors.

Why are you encouraging people to join you on reddit?

Attached: 1524619973110.jpg (898x709, 162K)

I'm encouraging you to go back to where you came from.

Aoba is a cutie

But I'm already at home.

Attached: 1520639060602.jpg (720x720, 50K)

I see this structure a lot of open source code. My opinion is that this structure is alright if the project is small. But i would consider something else for larger projects.

yes. there is a scope problem...somewhere

My teacher told us this, how true is it?

>Warning: Some Haskel programmers tend to have exaggerated love for language.
Some caution may be warranted.

if i tell you haskell is a shit language how angry does that make you?

Attached: 1500713313484.jpg (6075x3932, 3.74M)

Haskell is shit but there's little chance that you're coming to that conclusion from the right angle.

because a library shall only provides the .h and the .lib files

rape angry but not murder angry

Attached: 1514397635836.jpg (1800x2048, 261K)

Not at all. Haskell has its strengths, and weaknesses.

Tying oneself to only one language is silly.

How do templates work for static libs?
Are they compiled as part of the executable (header templates)?
How do they work in a shared lib?

negative numbers can't be represented in functional programming languages

idris> -1 + 1
0 : Integer

Actual question, why is JavaScript not considered a programming language?

I get that it's garbage and all, personally I'd much rather be using C. But it's Turing complete, isn't it? And it provides facilities for human interaction, doesn't it? And it runs on a computer, doesn't it?

>inb4 "hurrr no it runs in a browser"
Which runs on a computer.
Interpreted languages are still programming languages.
>inb4 "hurrr no they aren't"
Oh yeah? Explain Java then, smartass. Does the fact that it's being interpreted make it any less a programming language?
>inb4 "hurrr it's being virtualized not interpreted, they aren't the same thing"
Actually yeah they are. What's a VM? A resource-limited Turing machine sitting between the host OS and some other software. What's an interpreter? A resource-limited Turing machine sitting between the host OS and some other software.
>inb4 "hurrr java is shitterlang for poojeets"
Didn't say it wasn't. But it's still a programming language.
>inb4 "hurrr java isn't a programming language, it's a POOgamming language"
Ok then, explain C or Haskell on virtualized Gentoo.
>inb4 "hurrr two-ring compleatness was a misteak"
I don't understand the source of this fucking meme but it has got to be the most retarded argument I've ever heard. Regressionism at its finest. "Hurrr all languages should be parsable by pushdown automata because turing machines are so complex that sometimes their behavior is undecidable!" That's like saying "hurrr we should go back to riding around in carriages all the time just because cars go so fast that sometimes the people driving them accidentally cause mass death!" As in, yes, you have a point, but on the other hand, fuck you let's not.

*quotients your path*
data Nat : Type where
zero : Nat
succ : Nat -> Nat

data Int : Type where
pos : Nat -> Int
neg : Nat -> Int
q : pos zero = neg zero

Is that an invitation?

>Integer
i rest my case

No one argues that you dummy.
stop taking "Js isn't programming" literally.

For what?
A gayla?
Fuck off js shitter

it can also be a net if i let it

Attached: 1497483605077.jpg (540x443, 54K)

Any PL with 'java' in its name happens to be a wide spread cancer full of security issues.

Well yeah, generally speaking, but why is JavaScript not considered a programming language tho?

>it can also be a net
that you just found?

you know i meant nat you mong

lol found the problem. gli needs glm. so much "for additional dependencies are required"

Attached: 1441795727734.jpg (768x820, 184K)

Well if you look at the project it actually has the external dependency as part of the repository and it's properly added to the CMakeLists project so I'm not sure what you expected.

>when you say go
>be ready to throw
>now go
>*donk*
>throw it at him not you
>OCH, let's try something else

Attached: 8DxmZY6.gif (320x320, 240K)

void me() noexcept {
try {
throw it;
} catch (...) {
him();
}
}

It is though.
Some consider a 'scripting language' to be less of a 'programming language' but that is pantsu on head retarded because nothing is stoping a PL from being interpreted or compiled.
Put simply, a scripting language is a programming language that supports writing scripts.

not everyone uses cmake. maybe mention it in the tutorial if you do it yourself?

>It is though.
It is a programming language, or it is CONSIDERED a programming language?
Because if the latter is your intended meaning, I disagree.

gcc -Wall -g -c ringbuffer.c
gcc -Wall -g -c -lm matrix.c
gcc -Wall -g -c main.c
gcc -g main.o matrix.o ringbuffer.o -o test


What would be a nice makefile for this?

For now I have
CC = gcc
CFLAG = -g -Wall
LIBS = -lm
SOURCES = main.c matrix.c ringbuffer.c
OBJS = $(SOURCES:.c=.o)
EXECUTABLE = test

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJS)
$(CC) $(CFLAGS) -c $(SOURCES) $(LIBS)
$(CC) $(OBJS) -o $(EXECUTABLE)

.PHONY: clean
clean:
rm -f $(EXECUTABLE) *.o

run: $(EXECUTABLE)
./$(EXECUTABLE)


but this outputs
gcc -c -o main.o main.c
gcc -c -o matrix.o matrix.c
gcc -c -o ringbuffer.o ringbuffer.c
gcc -c main.c matrix.c ringbuffer.c -lm
gcc main.o matrix.o ringbuffer.o -o test

and does not show warnings nor let me see what's going on with gdb.

Also, some might argue that JS is nothing without the DOM but is like saying C is not a PL without libc

>CFLAG
>CFLAGS

It is a bloody PL following the ECMAScript standard.

DOM is HTML specific, js can also work in non-browser environment.
Your statement makes no fucking sense.

>gcc -Wall -g -c -lm matrix.c
You realize the -lm will be ignored due to the -c, right?

Doing my first deployment to a production environment today... pretty nervous. I hope my shit works.

Yeah but it's not CONSIDERED a PL.
hence my post

How to cast a float to unsigned integer bitwisely in C++, other than using pointer hack?
by pointer hack I mean:
unsigned int foo(float bar){
return *((unsigned int *) & bar);
}

if you're not using the established standard practice then maybe expect to have to jump through some hoops

Why do you expect a reasonable person to know why retards do what they do?

>I hope my shit works.
you know the nice thing about programming is you don't have to hope. But then again, you are a webdev.

You cant

T-thanks.
Otherwise, any comments about the makefile?
Now this outputs
gcc -g -Wall -c -o main.o main.c
gcc -g -Wall -c -o matrix.o matrix.c
gcc -g -Wall -c -o ringbuffer.o ringbuffer.c
gcc main.o matrix.o ringbuffer.o -o test


To be honest I didn't.
I used to gcc -g -Wall main.c matrix.c ringbuffer.c -o test but I decided that this would be the time where I would try to understand what gcc is doing step by step.

I'm learning how to render OpenGL surfaces on Wayland. I almost want to kill myself.

wrong. it's typical open sore autism. there are actually not many projects out there that took a moment to think about who could use it and how they will perceive it. good example: libgdx. bad example: almost everything else.

why should anyone care about your autistic ways because you're too stubborn to use cmake?

because that's exactly the reason why the year of the linux desktop will never come

what do these things have to do with each other lmao

read this, before you go further into UB-land
stackoverflow.com/questions/98650/what-is-the-strict-aliasing-rule

the autism of open sore, you dingus.

feel free to use a proprietary alternative then

I do wherever I can.

Well, I would say not all scripting languages are programming languages. Bash, for example, isn't really a programming language. Although this classification is up to debate.
I also wouldn't say interpreted vs. compiled is the differentiator between scripting languages and non-scripting languages. A scripting language is one primarily meant to script some other program, for example, Javascript was originally for scripting browsers.

C preprocessor macros.

not turing complete

>not everyone uses cmake.
Not everyone cares

>C++
There's your problem

that's fine. but dont be surprised when normies dont appreciate such autism

I don't care what "normies" appreciate either.

>Tying oneself to only one language is silly.
Right, the language doesn't actually matter, only the computation being executed. Which is why you should always use a low-level language that closely reflects the machine code the computer will actually run.

Use a union.
Pointer casting is a Very Bad Thing because of what's known as strict aliasing. You don't have to learn the rules but the gist of it is that trying to access anything through the correct kind of pointer for the declaration or a char* gives the compiler leeway to fuck up your program.

>I used to gcc -g -Wall main.c matrix.c ringbuffer.c -o test but I decided that this would be the time where I would try to understand what gcc is doing step by step.
The reason -lm will be ignored due to -c is because GCC likes to have linking always be done all at once in one step, and always be the last step of building. You should put -lm into the line gcc main.o matrix.o ringbuffer.o -o test. Think of the m that's being l'd as something similar to one of your .o files. A .o file never depends on another .o file; it can depend on symbols exported by that other .o file, but then it should still just be able to exist on its own and sit around waiting to be linked to that other .o file by the linker at the end of the process. Hence why, even if you use math.h in a .c file, you don't need -lm when compiling that specific .c file, only when linking all your .o files at the end.

>implying a programmer in a low level language will always be patient enough to beat the compiler of a high level language
And I use "patient" to be as nice as possible.