/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

github.com/tathougies/hos
elm-lang.org/
docs.python.org/3/howto/curses.html
eli.thegreenplace.net/2013/07/09/library-order-in-static-linking
enlightenment.org/
pastebin.com/UHsA3pUD
twitter.com/SFWRedditVideos

tell me about the project you should be working on right now, /dpt/.

$cat FuckX.h
>Fuck OpenGl
>Fuck Xlib
>Fuck GTK
>Fuck GTK++
>Fuck Ncurses
>Fuck Microsoft
>Fuck Apple
>Fuck Canonical
>Fuck Ajit Pai
>Fuck FCC

echo "Fuck me" >> FuckX.h

lua is good

what is the best way to read from a file line by line and word by word in c++?

asm keyword

getline and cin/cout

thanks

How to set different window cut ratio in emacs?

Is it really worth to get gud at emacs?

More work on my Brainfuck debugger from the last thread; it can toggle ASCII IO properly now.
Now to handle input and draw the interpreter's stack, maybe some file stuff.

no.

Fuck mutability

Stop with the government shilling .

You stop with the corporate shilling first, faggot.

it's worth getting good at evil+emacs:
Superior editing + Superior workflow

when are the gonna make an OS where all the memory is immutable and GC is built in

Can't we all just get along and establish an anarchist utopia free of unjustified hierarchy?

Kernel level is the one place I'm pretty okay quoth c or rust being around.

>emacs+vi
isn't that a bit too autistic

the future is now old man
github.com/tathougies/hos

been working on this for a while

>I need immutability and garbage collection to reason about my code
There are plenty of ways to model mutation and use types to ensure that it's well behaved.

I don't need them. I prefer them. Mutable legacy production code is a disease.

C doesn't have true immutability.

how would one go about making something that uses two languages at once together?
t. brainlet who has no experience.

Depends on which languages.

const

not for me at least. i use it only because i learned it years ago and don't have a reason to switch to anything else. i spend far more time thinking than actually editing so the editor becomes irrelevant. if you're typing that much that the editor becomes the bottleneck you have bigger problems to worry about.

not actually immutable.

pick C and Lua: easy as pie to interface, both languages very complimentary

>no const
bad
>mutable by default
actually worse because I'll write "const" everywhere
>immutable by default
good
>no mutability
too far

mprotect and you can make anything immutable. If you try to mutate it, your program will crash.

fun fact: const was a C++ feature ported back to C

Persistent data structures is what you want. Go for Clojure or C++ with immer

rust is ok

>have no clue when to use statics
>just throw one in if VS bitches about a method not being static
Is this Pajeet-tier or worse

mprotect is quasi-immutability and expensive.

no such thing

unless you're sure ipc will be too slow using sockets or pipes and passing information as plain text is the easiest way. a lot of scripting languages give the option of being extensible in c or embedded in a c program but in my experience this is usually overkill.

>too far
thing | thing + 1
immutable mutation > mutation

nah, pajeets know about static

In my defense I'm still learning basics

when you use a class method, it's actually kinda like this:
void method(int value)
equates to:
method(MyClass this, int value)
while
static void method(int value)
is literally just what you see; no implicit "self" or "this".

imo static variables are generally awful but static methods are good because you can reduce the amount of state in the function. You might understand what I mean when you learn more.

Weak défense. You're unable to compete with Superior Indian programmers: each student has to write an OS and a compiler before they graduate, that's how ahead Indian engineer factories are.

Meanwhile in the US:
muh bad structure, muh ugly code, muh inclusive gender pronouns, muh diversity, muh Ada Lovelace, muh CS belongs with the humanities!!!

There's no such thing as "worse than" pajeet-tier. If anything, what you're describing just sounds like a regular middle-of-the-road pajeet.
There's no room for optimism in this industry user.

I'm new to programming, the only langs I know is HTML and CSS, I want to create programs and games and shit, and I want to see immediate results, what programming language should I learn?

That's my kind of programming

>and I want to see immediate results
JS with a hotloader
Lua with a hotloader

but more seriously skip those, take your add meds, and just start with c++ and sfml.

Or check out nim if you want webshit games as well.

Since you're already into web stuff, check out Elm:
elm-lang.org/

Some static JS stuff maybe? Would put your html to work. There's a video on the tubes of some guy doing snake in JS with no framework at all

i've found it to be super interesting. what specifically are you into?

I started learning SQL on Kahn Academy to help at work, I think next I will learn Python.

Is there a better place to learn? KA seems pretty good so far but haven't started actual application IRL yet.

I've been using Udemy. I would highly recommend learning Java or C# instead, though

are there any good ncurses tutorials out there to make something that looks kinda like htop or ncdu

working on a basic file server and client, it was a uni project to learn about sockets, message queues and pipes

read the source code

Prion has a good intro to curses in the abstract. Too bad it's in Python.
docs.python.org/3/howto/curses.html

If i wanted to write a tool that quickly showed the model and size of every drive the user has plugged in, is it safe to assume that any linux machine out there will have the "/sys/block/" directory

>quasi-immutability
The only thing that's going to make it stop being immutable is if you intentionally mprotect it to be writeable, in which case it's your own damn fault.

>expensive
You only need to call it once, really.

Trying to understand the difference. I don't see any. No explanation follows. How is linking order matter in this example?

glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_NOTEQUAL, 0b0011, 0b0001);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// render1 (pass stencil test)
glStencilFunc(GL_NOTEQUAL, 0b0011, 0b0001);
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
// render2 (fail stencil test)
glStencilFunc(GL_GEQUAL, 0b0001, 0b0011);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// render3 (pass stencil test?!)

i'm losing my shit over here
why is render3 passing
what am i missing
if i change from glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP) to glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP) it does the needful in this specific test case
is it a driver bug??

GL_EQUAL instead of GL_GEQUAL has the same problem, so somehow it's reading a stencil value of 0b0001 after render2 was supposed to write 0b0011??

C is shit.
the two bars are technically different.

Actually I linked this right now and it works in both cases. WTF do I even read?

compare the gcc versions you use vs the books.

under normal circumstances you would always put the declaration in a header so it comes before the definition

We are linking not compiling so this should not matter

Fine I'm confirmed retard, didn't see main.c listing. It's actually there, now it makes sense.

Show simplemain.c pls user I am hella confused rn

eli.thegreenplace.net/2013/07/09/library-order-in-static-linking
int func(int);

int main(int argc, const char* argv[])
{
return func(argc);
}

Only func(1) is declared

Defend this.

#define u unsigned char /* disables -Wchar-subscripts */
static unsigned strtok_dry(char *str, const char *d)
{
unsigned count = 0;
unsigned char lut[UCHAR_MAX] = { 0 };
while ((lut[(u)*d] = *d) && d++);
while (*++str)
if (lut[(u)*str] && !lut[(u)*(str - 1)])
count++;
return count;
}
#undef u

>-Wchar-subscripts
>guarantees or rules being followed in C
wew lad

Casually researching blockchain stuff so I can understand how Bitcoin Core uses it in memory.

>dapps
Fuck that shit tech. Also, I'm US so I can't PnD anymore.

Also might write a Discord bot to get back into Python.

std::btfo(c.begin(), c.end(), true)

>iterating over one element

const was mistake

C was a mistake

>muh CS belongs with the humanities!!!
Based Stanford

According to the people at the 2012 Singularity Summit, the median predicted year that the technological singularity (brought about a artificial general intelligence) is 2040. I think this is a bit optimistic, but then again I have no idea what kind of secret AI tech militaries and 1337 hackers around the world are working with. "AI" applications in the public realm are so narrow in scope, and these programs have no way of increasing that scope on their own terms, of their own volition.

What do you guys think? Will we have an artificial superintelligence 2040?

i forgot to comment out a state change elsewhere... oh man

>2040
Wow, i'll actually still be young enough to be coherent when robots kill us all.

>Can't we all just get along and establish an anarchist utopia free of unjustified hierarchy?
>free of unjustified hierarchy
But lowlives wouldn't accept their place in a "justified" hierarchy, and proclaim it unjustified.

why is the modify button wider than the others?

What is the simplest library to make GUI in C under Linux?

OPENgl

dear imgui is bretty neat

is that "therapist debugger" or "the rapist debugger"?

>sepples shit
GTK, libui or xlib. If you want to make them yourself just use raw sdl2 or sdl2 for windowing and opengl + nuklear or opengl + nanovg.

libui is kinda dead tho

>latest commit nov 4, 2017

Also enlightment DE has some C libraries not sure how easy they are to use though. enlightenment.org/
Ecere has SDK for developing GUI applications for all relevant platforms and ec is ABI compatible with C, they also say they provide tools for exporting C API from the ec libraries.

Has anyone written a rough idea of milestones to work towards when teaching yourself to program?

I've been learning Python for a little while but I feel like I don't know what I'm working towards, just that I'm slowly picking things up. How will I know when I'm gud?

Didn't know that Dave Anthony is a national socialist

>How will I know when I'm gud?
When you're as good as people you judge being gud.

What are you people working on?
I'm trying to make a lame shitty irc bot in go

IntelliJ makes working with Java a pleasure. Also I didn't know Java was this fast nowadays. I get less input lag with a 500MB IDE than with most meme editors like VS Code or Atom.

What should I use to do Java web development? Spring or Play? And for GUIs, JavaFX or Swing?

Depends on the language. Dynamic typing language = you're probably good. Statically typed = an IDE with some kind of autocomplete you don't have to configure yourself is better here.

pls halp
what am i doing wrong here
>main.cpp: In member function 'bool unorderedLinkedList::search(const Type&) const':
main.cpp:427:15: error: 'first' was not declared in this scope
current = first; //set current to point to the first
^~~~~


pastebin.com/UHsA3pUD

adding first to the struct works, but i'm then unable to add items to the list