/dpt/ - Daily Programming Thread

What have you been working on, /dpt/?

Old thread:

Attached: muh_books.jpg (770x524, 85K)

Other urls found in this thread:

github.com/jano017/Discord.hs.
github.com/commercialhaskell/stack/blob/master/doc/faq.md
github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md#system-ghc
github.com/atilaneves/cmake-ide
twitter.com/NSFWRedditVideo

Warning: Unreachable code detected after return statement.

I really need programming socks with animu images on them.

Attached: 1498414039751.jpg (450x522, 53K)

Haskell!

Attached: 1452715120528.png (561x800, 651K)

Also, C#.

nth for haskell

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

this
good post btw

Attached: 1483184268193.gif (553x600, 1.39M)

Lisp

Smalltalk!

Attached: !.png (456x456, 320K)

no

?

Attached: 1508279119854.png (828x496, 21K)

Don't have the full code but you are probably double freeing. Can you post more code and the full layout of your tileset structs?
>set
tileset
>type
types
>BYTE is an unsigned char
delete that typedef. Just write unsigned char
>unsigned long int
are you sure that has the sizeof you think it does? It's only guaranteed to be 4. Try unsigned long long int, which is guaranteed to be 8.

>What have you been working on, /dpt/?
Been writing papers the last weeks. Submitted one on Monday, and started working on a journal paper due in the end of the month.

>no
you

Attached: d25ad9f115a3e4e305591e1a8da8c8971409342182_full.png (640x358, 295K)

>21 KB

Attached: 1525547773667.png (828x496, 10K)

>31 KB
Thanks asshole

langlets get OUT OF MY THREAD

Attached: anime.png (1000x1300, 786K)

Haskell is the b-best, user-kun!

TIL that Smalltalk has no switch/case expression. I shall have to think of a work-around.

What's the matter, user? Do you need some help?

Attached: 1525547773667.jpg (1200x899, 40K)

>le haskell
Challenge one: be useful.

Attached: 151683119313077710.jpg (1505x2125, 173K)

*KiB

Haskell is useful in the same way qt anime girls are; it provides me with great comfort.

Not strictly programming-related, but this doesn't feel like it belongs on /sqt/ as well.
A local TV provider has an app that lets you watch their VOD from you phone.
I captured the data with burp and figured out they use DASH streaming. How can I try and actually play the thing on my desktop? What should I "feed" mpv?

Non-programming programming challenge:
Make a program without write any code at all, but instead only copy paste code snippet / all of your code from anywhere you can find.
Manually writing code only permitted to connect the copy-pasted code for example function calling.

or write a program that does the copying for you

This is literally what pajeets do when they code.

>Discord
I know.
I'm trying to get this library working for some meme shit: github.com/jano017/Discord.hs. It suggests using stack, but stack is being a fucking asshole for me, and reading the documentation, I'm inclined to believe it's trying to leverage known packages managers, of which mine is not one. I have stack installed, but can't actually do anything meaningful with it. Observe:
$ stack build
I don't know how to install GHC on your system configuration, please install manually
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
What the fuck do I have to do to get this dumb shit working so I can crank out a dumb meme bot to entertain my friends? I'm not particularly married to haskell, but figure that since pandoc was kind enough to pull in one-hundred and six packages worth of dependencies, I'd try and get my money's worth out of them.

Attached: 1515186843724.jpg (1280x1757, 459K)

Good for you. It also happens that other anons enjoy different langs as well.

Attached: AkO31UnkTCmP4T8CYxBfUQ[1].png (501x672, 177K)

That seems like a fun project to do

what OS are you using
also fuck stack

ok ,how do you compress images like this without loosing quality ?

Slackware 14.2
If there's a better way to get this library working, I'm all ears, but there's nothing in the library's documentation that'd lead me to believe otherwise.

I enjoy many different anime series, but I have a favourite obviously.

apparently it's a dead library

also stack doesn't necessarily use a pre-installed global ghc
you can try and set it up to use that

Is that a jojo pointer?

I don't know if no changes in a year means it's broken, but I was willing to at least try it out. This is as good of a reason to dip my toes in the language as any.

I tried that already. In theory, it should already be attempting to do so.
$ stack --system-ghc build
I don't know how to install GHC on your system configuration, please install manually
$ cat ~/.stack/config.yaml
templates:
params: null
system-ghc: true

I think it needs to know where ghc is
github.com/commercialhaskell/stack/blob/master/doc/faq.md

That's where I got the idea to run that command that adds that to the config file. As a counterpoint though:
github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md#system-ghc
>Enables or disables using the GHC available on the PATH. Useful to enable if you want to save the time, bandwidth or storage space needed to setup an isolated GHC. Default is false unless the Docker or Nix integration is enabled. In a Nix-enabled configuration, stack is incompatible with system-ghc: false.
# Turn on system GHC
system-ghc: true
Unless I'm looking in the wrong places like an idiot and not finding the other extra configuration option, it would appear to be looking for a ghc in $PATH. And it's there, just for whatever reason, stack is a special snowflake that can't find it.
$ stack exec -- which ghc
I don't know how to install GHC on your system configuration, please install manually

This seems too vague.
(define (factorial n) (apply * (iota n 1)))
This technically is factorial with only libraries and just "connecting glue." What sort of code can I write that breaks your rules?

I dunno why it doesn't work I guess it's just your OS that's the special snowflake, try looking for specific help?
you don't strictly need stack for Haskell, especially since we got the new cabal

>This is as good of a reason to dip my toes in the language as any.
A good reason to dip toes would be writing something on smaller scale. Like doing coding game excercises in that language before you feel comfortable to explore its quirks and only then using it for something more serious.

If I were you I'd write my own discord wrapper in haskell

Is perl6 a bad first language? Can you practically make a 3d or 2d game with perl? Or something like dorf fortress where it's all via terminal? Or is perl just for scraping websites and sorting databases?

I'm a fully retarded sysadmin who's programming to fill a company need. I built a powershell app with a shitty ui that lets people modify and interact with a set of lists. There are 2 separate scripts (admin/user) which have different capabilities but use the same form layout and I'd like to call it from a single external source rather than write it out in each script. Do i just build it with generic function calls on clicks, import it then define the functions in each script?
>Tl;dr: help me turn my 1000 lines of garbage into 900 lines of garbage

Just use C++ for game development. Perl is a scripting language and is thus not suitable for actual serious game development.

>is it a bad language
No idea. Perl used to be popular for webscraping, writing webpages and other text processing stuff, but it isn't so used anymore. If you want to write a game in basically any language that isn't C or C++ you'll have to write a bit of it in C or use a library that does it for you. If you want to write a terminal game, you can use ncurses which ALMOST CERTAINLY has a perl6 library. For both 2D and 3D you'll want to use OpenGL. Although OpenGL is a tall order so maybe if you want to make a baby tier 2D game like my first one was, you can use SDL blitting (I used java's awt canvas for my first I think).

t. writes games in scheme in his freetime

If you don't know how to program, it's going to be a while before you write your first "real" game. For context I learned how to program when I was 11 and only wrote my first "real" game (a galaga clone in java) when I was 15. You're probably smarter than an 11 year old so a year?

>c++
"no"

For real though, most actual serious game developers take it easy on the ++ in C++ because the ++ is slow. They might overload operators for vectors, MAYBE. You should just use C if you're starting a project from scratch.

Whatsup guys.

Currently working on a framework, how about y’all?

I only advice him to use C++ because C++ offers classes, which comes in very handy for game development. I dislike the other parts of C++ too.

From I found that I have been having a sigtrap problem with my code when I close the game.

I have a tileset, and each tile looks up what "type" it is (solid, slope, hollow, etc.). The size of the type is the no. of tiles in a tileset.

Like so:
set->type = (BYTE*)calloc ( set->num_tiles, sizeof(BYTE) );
memset ( set->type, 0, set->num_tiles * sizeof(BYTE) );

set->type is a BYTE, which is an unsigned char, so it can only do 0-255.

set->num_tiles is an unsigned long, although I will probably never even come close to using that many tiles, i'm not sure if it being an unsigned long has anything to do with it.

When I go to end the game, this code runs:

// Free the tile types
if ( set->type != NULL )
{
free ( set->type );
set->type = NULL;
}


M debugger will stop on free ( set->type ); and give me the following:
Program received signal SIGTRAP, Trace/breakpoint trap.
In ?? () ()
#7 0x00409705 in TilesetRemove (set=0x5250a0 ) at tile.c:255
->->tile.c:255:7405:beg:0x409705
At tile.c:255
#7 0x00409705 in TilesetRemove (set=0x5250a0 ) at tile.c:255
->->tile.c:255:7405:beg:0x409705


If I comment out that free command then the program will close without issue, but then there is the issue of set->type still in memory, right?

Any ideas?

Not sure if I am double freeing, I did think that earlier. I ctrl+f'd all my code and there is only once instance of free the tileset type data.

typedef struct tileset_s
{
bool active;
char *name;
image_t *image;
char *imagefile;
unsigned long img_w,
img_h;
unsigned short spacing,
margin;
unsigned long til_x,
til_y;
unsigned short til_w,
til_h;
unsigned long num_tiles;
box_t *tile;
unsigned char *type;
} tileset_t;

What is the python like equivalent to cargo/npm/composer?
"pip" isn't good enough for me and I'd like to use whatever is the most popular in the community for support reasons.

>google won't let me download my first game from my email because it is a JAR file.
REEEEE. Any tips on getting around google's faggotry?

>only one instance of free
Doesn't mean you're not double freeing. Post how you're making the tilesets.

I would consider refactor that code though. Group the names, images, tiles, and types into a a new tile struct.

if-else-if-else...

does it have first class functions, or some equivalent

because you can just do that

Attached: banter stops.png (500x611, 176K)

>most actual serious game developers take it easy on the ++ in C++ because the ++ is slow
The ++ does not stand for "… with classes"

Hi, just passing by to revive the "what's the best c++ ide to get used to" discussion.

Bless you!

Attached: 1494544655420.jpg (1600x1000, 241K)

The with classes is hardly the worst part of the ++. The templates, the "functional" programming, the standard library, the exceptions, the operator overloading (LOL

I thought that the ++ analogously meant C with OOP and libraries.

github.com/atilaneves/cmake-ide

templates are the only useful part of C++, the rest (classes especially) is trash

the reason "most actual serious game developers" take it easy on the ++ is because "most actual serious game code" written in C++ is older than C++11, where it was basically "C with objects"

Trying to make a png viewer, but am having a dumb issue with header files.

My program structure is as follows:
main includes "png.h" and uses the function checkPNGFile(FILE*)
to see if the "magic number" at the beginning is valid. However, when I compile using:

gcc png.h documentationTools.c main.c


I get the following error:
gcc png.h documentationTools.c main.c
Undefined symbols for architecture x86_64:
"_checkPNGFile", referenced from:
_main in main-c8b367.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Compilation exited abnormally with code 1 at Sat May 5 14:10:00


Why am I getting this error? I'm including png.h and png.c implements the function correctly

Here's the relevant part of "png.c"
#include
#include

#include "png.h"
...
void checkPNGFile( FILE* input)
{
if(readMagicNum(input))//success --> go back to main
return;
//Unsuccessful --> Exit
LOG_ERR("CORRUPTED PNG FILE - MAGIC NUMBER INCORRECT");
exit(-1);
}

Attached: Screen Shot 2018-05-05 at 2.07.30 PM.png (1644x726, 74K)

Reminder that programming languages are just tools, and you shouldn't be wanking over them.

this, and you shouldn't use outdated tools without a good reason

depends on the tool/application
older hammers(over 100 years) are better than newly made ones.

You shouldnt compile png.h compile png.c instead. A header file (in most cases) is used to describe what an implementation file exposes publically. They arent the implementation itself.

And they're so much worse than Java's. If you want templates just use Java or Hasklel. If you want macros just use Lisp. C++ is a historical curiosity that shouldn't exist outside of legacy.

>advocating C++11

your hipser pixel viewer is lower resolution than actual DOS terminals and NES games.

You need to include the png.c file too. Or just compile each source file separately and then bind up the objects.
gcc -c png.c
... etc
gcc -c main.c
gcc -o main main.o png.o ...

What's an efficient X86 approach to copying eg copying 3 bytes and skipping the 4th, especially in the same array?

Right now I align to where the end of the input data is a multiple of the register size, then have three pointers, the end address, read address, and write address. Just copies repeatedly. Originally it was a for loop and copied individual bytes, though.

It feels sloppy. Is there any better, and maybe more general approach? Have read through the whole x86(64) ISA, but can't yet make good use of it.

money is a tool.
doesn't matter how old it is. just how much you got.

>t.

Attached: bitcoin.jpg (1692x1167, 1.61M)

>include the png.c file
Include it in your compilation command I mean. Not your main.c

Use the best tool for the job, regardless of its age.

C++ templates have nothing to do with Java generics tho.

>not advocating C++11

32bit int and a bitmask

crypto was never a money.
at best it was a temporary trade medium, but in use it was more of a stock.

There's this url. If I do curl {url} I get an empty response. Completely empty. If I do curl -L {url} I get what I'm looking for, but I have no idea where I'm being redirected to. What can I do?

read 4 bytes from source (mov eax, dword [...])
shift or clear 8 bits
write to target
increment source pointer by 4
increment target pointer by 3

Gotcha...
So I should probably learn to make a (simple) Makefile if the project starts to get bigger.

>your hipser pixel viewer is lower resolution than actual DOS terminals and NES games.
Who needs resolution when you have
>A E S T H E T I C S

>What can I do?
And by that I mean - how can I find out where I'm being redirected?

Vector v;
ArrayList a;

>nothing to do
Don't post some C++ """meta""" programming as a refutation. Yeah C++ templates can do more but that isn't a good thing.

C++11 is a mixed bag. constexpr, auto, lambdas and improvements to templates are welcome.
rvalue references have braindamaged semantics and object construction is even more of an amazing clusterfuck to the point where you should just write off the whole objects thing.

>the syntax is similar so the functionality is the same

Attached: brainlet.png (621x702, 56K)

Dumb question about header files:

If you include a standard library in a header file, do you also have to include it in the regular file?

Like:

//--file1.h--
#include
#include
#include
void
function1();

And
#include
#include
#include
void
function1()
{ ... }


Because the program compiles if I don't include them in the header file, but the compilation crashes if I don't include it in the implementation file.

I guess what I'm asking is... When it comes to standard libraries, what's the best way of organizing them i your projects?
Does every file include its own set of stdlib functions?
Do only the headers include them?

What bug tracker does /dpt/ recommend for a project that doesn't have public code (it's for a game server) but still want people to be able to submit/track bugs publicly?

It's usual for an implementation file to include its own header.

[email protected]
(email)

>they achieve the same goal, aids notwithstanding, and have similar syntax but they're unrelated

Attached: slow.gif (645x773, 9K)

I use something like this to test the 4th byte initially (alpha channel).

Thanks.

Problems come from the possibility of 16 bit samples, but I can just have two loops and compile-time stuff for 64/32 bit.

When I was in High School C# was supposed to be the next big thing. Does anyone know much about it? It seems like a Java rip off which is what I'm planning on learning, but I still have some lingering intrigue from way back when.

No that's all it is. Microsoft is trying to make it matter but it's still just Java but without the utility.

Umm, have you heard of verbose output?
curl -vL gayanimesite.com

Generics are the statically typed version of Templates.
It is incredibly limited compared to templates and even more so in java because of type erasure.

love C#
using for cross-platform in xamarin
pretty verstile

not a NEET lang, tho

They can, for some special use cases, be used for the same goals (parametric containers, in your case), but the underlying details are very different.
Take your example, and suppose Vector and ArrayList are user-created classes, for the sake of simplicity.
In C++, Vector and Vector are different types at runtime, since the compiler, when seeing the templates, generates two different versions of the class from the unique class template Vector. But in Java, they are the same type at runtime. The compiler merely performs the casts for you. Therefore, Vector and Vector are the same type at runtime. This is done for compatibility reasons with respect to the old JVM, so that code compiled with generics can be run without changing the JVM.
C++ templates, however, can do a shitload more. Hell, they have been proven to be Turing complete.

isn't java generics interface polymorphism while c++ templates type polymorphism?

Thanks, now how would I do that using python-requests? I know I can use socket, but it seems like there should be an easier way.