/dpt/ - Daily Programming Thread

What are you working on?
What do you plan on learning?

Old thread:

Other urls found in this thread:

c-faq.com/aryptr/practdiff.html
stackoverflow.com/questions/13104123/cast-to-void-for-what-reason
youtube.com/watch?v=VqbtbTSeai0
gnumdk.github.io/lollypop-web/
twitter.com/SFWRedditGifs

Thought for the day
Having strings compute their hash when they're created and use that for string comparison

second for op is shit

Better thought, have a generic hash + value container that works for more than just strings and lets you avoid modifying the string type.

That makes more sense

p://www.emulator101.com/reference/8080-by-opcode.html

This guy says here that on 8080, little endian is used.Ok.

But let's take for example
00 00 00 c3 d4 18 00

he says that its:
NOP
NOP
NOP
JMP $18d4
NOP

Why are d4 and 18 reversed after c3?

I have a hard time understanding little/big endian.It is an extreme clusterfuck for me.

>strings don't change
std::unordered_set

Oh boy I sure do love functional programming yes sir I do

I don't mean a container of multiple values, I mean a container of a single value that computes a hash and uses it to accelerate certain operations.

Have the hash generated at comparison time if it doesn't exist already, if it's already been generated just use it.

> Why are d4 and 18 reversed after c3?
Because it's little-endian, the least significant byte, d4, goes first.

Can have it recomputed with assignment

Hey goys, what is the problem here? I can't find it.

I have this function
std::ostream& operator

so the rom file there is in big endian?

On the fence about dba stuff, exclusive and coders whine but watevs

No? Everything is little-endian, go read the wiki.

>I have this function
To be clear, that is a nonmember function, right?

What if you use just Rational r as the param without const reference?

fucfuckfuckfuck
I just realized, I only implemented it in the .cpp and didn't declare it in the .h
thanks doe, you made me check the header file

It looks fine, must be something with the compiler not being able to find the operator implementation. Where did you put it? It's better to have it as an inline function in a header with Rational itself.

Is Smalltalk worth learning? Is it an interesting language?
I've already learned OOP with C++, but Smalltalk is apparently a very well liked language

t. Uncle Bob

Yes, Pharo looks good and it has a lot of nice documentation, literally several nicely done books, I've been thinking about giving it a try for a while now. Stil tho, don't expect it to be of any practical use other than experience, the language is inherently slow, the libraries and community are non-existent and everything good was stolen by Python and Ruby decades ago.

can any one explain the array of pointers casting. is (void **) lineptr is equivalent to (void *) lineptr[]

sorta.

An array is not a pointer, an array will decay to a pointer to the first element of the array when referenced as a non-array.

What specific line/problem are you having trouble with?

why the need for another * though since we know from preceding declaration that lineptr is an array of char pointers. now wouldn't it make more sense to cast (void *) lineptr ?

What's a good text editor (+ plugins) for Haskell development?

>What specific line/problem are you having trouble with?
the qsort function inside the second if statement

What if you have hash collisions?

ed

Obviously you have to test the strings themselves if the hashes are equal.

vim, decent .vimrc, no plugins needed

Stop having shit luck

. . . so a guaranteed efficiency loss if we're in a situation where most of our comparisons are of identical strings, right?

>is (void **) lineptr is equivalent to (void *) lineptr[]
no.

Java sort of does this, it saves the hashcode value for the String when it is computed and uses that.

For C++ it would be very easy to make a type of structure that wraps an immutable object and stores the hashcode.

Yes. If you have a finite set of strings you can use a perfect hash function, of course, and then you don't need to compare both the hash and the string each time.

can you help me with this

Yeah of course that'd happen in that case. But if, for example, we have unknown data which always tends to contain many repeats, a perfect hash function wouldn't be possible so the whole thing would be a pointless exercise

c-faq.com/aryptr/practdiff.html

Totoro!

If you anticipate having many equal strings, a solution might be to have an indexed set of strings that acts as a perfect dynamic hash function. When a new string is encountered, it's checked against all the strings in the set. If it's already in the set, you assign it its index. If not, you add it to the set and assign it the next index. Then you can simply use indices to compare strings already in the system.

Seems like a good solution. I'm fairly convinced that this is a decent idea now.

Here's my best guess, qsort expects an array of pointers to something(void), lineptr is an array of pointers to chars, if you were to do (void *) lineptr you'd be casting the array as a pointer to void which it isn't, it's a pointer to a pointer to a char, the function wants the base address of the array which is **lineptr.

I'm no expert so I could be wrong on this, I often have to reference documentation when dealing with shit like this myself.

Employed Haskell programmer reporting in

>it's a pointer to a pointer to a char
Wait I think that's wrong. I don't know why they do this.

How many Good boy points do you earn?

I understand the distinction, I want to know about the additional * when casting however Also, this confirms my suspicion stackoverflow.com/questions/13104123/cast-to-void-for-what-reason

How the fuck am I supposed to pass math courses in CS?

300K starting

You must be swimming in tendies

stackoverflow.com/questions/13104123/cast-to-void-for-what-reason
>That's the type of argument qsort expects. When you pass lineptr, that would become a char** and the compiler should complain. Casting the pointer to the expected type shuts up the compiler because it says "I know what I'm doing" and converts the argument to the correct type.

calculus is easy peasy

What company? Or Industry?

The team who designed the microsoft database stack should be fucking gutted alive.

I think its slowly ruining my health. All the fucking incompatibilities and messed up data in mdb files makes me want to go on a rampage

>respond to /dpt/ shitposter
I shiggy diggy

No it isn't.

I'm gonna consider my answer close but half of my reasoning was wrong. double pointers, 2D arrays, and other multi layered pointer things in C are great but it's maybe the only part of the syntax I struggle with at times, I know what I want to do but not how to do it immediately.

Literal values given to assemblers / compilers are always assumed to be big endian. The only time you need to worry about byte ordering is if you're trying to use calculation results as literal values.

Every time I've been forced to interact with any of the Windows apis I've wanted to die, I don't doubt the rest of their stuff is bad too.

I mean just look at this.

Some lines get converted correctly while others are fucked up beyond help because of some minor incompatibility.

This is your brain on microsoft

Calculus is easy, but they can make it arbitrarily difficult by using super shitty textbooks and asking you to remember more stuff.

You just have to work your ass off. They use math to weed out people who can't work a project they don't like.

What is the programming equivalent of this?

youtube.com/watch?v=VqbtbTSeai0

You can't write desktop applications in Python, can you?

I'm sure there's a library for that.

It's not really accurate to say 'Calculus is easy/hard/anything', since it depends to what depth you're studying it. Same for algebra, topology, anything really. Like, yeah, sure memorising a bunch of integrals and knowing how to apply the chain rule is easy. Proving Clairaut's theorem for Fréchet differentiable functions between infinite-dimensional Banach spaces is less so.

So like interning them?

Might be even better.

There are python gui libs

Almost nobody does that in their undergrad calc 123 + diffeq. Maybe at a fancy school. If you're complaining about the math requirements in CS, odds are you're not in one of those.

you can
for example:
gnumdk.github.io/lollypop-web/

But you have to pack Python interpreter with your program, don't you?
I think it's a bad idea because it would caise unnecessary bloat.

just list python as a dependency :^)

yes, use py2exe or cx_freeze
>i thinki it's a bad idea because it would cause unnecessary bloat
many applications do embed runtimes, especially on systems where shared libs aren't a (common) thing (aka windows). compared to VC/.NET redistributables, a python interpreter is nothing.

Write in c++ with single header imgui lib

>Having strings compute their hash when they're created and use that for string comparison
Dumb idea. Who said the user wants to waste cycles computing hashes for strings that will never be compared to anything (which could very well be the vast majority of them)? If you really want to support this use case out of the box, provide a fast compare method that computes and caches a hash on demand.

I only know C. I have an idea for an app, that I would use myself. Would it be possible to create an app for android with C or do I need Java or some other language.
Also how hard is it to actually put an app on the market by yourself? Would I need to trade mark it's name or do some legal shit?

if you care about bloat you shouldn't be using python in general

>animeposter makes a good post
wow

If -kun says
>compared to VC/.NET redistributables, a python
>interpreter is nothing.
does it mean if I ever want to have non-bloated applications, I must not look at C# and program in C++, right?

You need to create the base application in java, then you can use something like SDL with opengl for graphics. There are existing templates that you can just for the java project. You can check sdl's android examples or something like that.
You could also compile GTK for android but there's some limitations.

If you want truly non-bloated applications, write everything in assembler.

If you want to produce apps this decade, stop worrying too much about bloat.

If you don't give shit at all about bloat, write it in Javascript.

if u have to write gui app in python that means u are windows faggot.
People rarely need real gui

If I want to create a chaotic map with gaussian formula, with alfa input and beta from -1 to 1, what I have to do with X?

ATS would be nice language by the features, too bad about the syntax...

most string comparisons I do involve substring comparisons, so if you mean to say I'm going to create a new substring + hash container for every substring I'm going to compare, you can go fuck yourself

In C.

I've just finished learning Python and feel like I'm capable. I'll still need practice.

But how about a language that will get me employed? No video gamer bullshit, what language should I learn for employment?

C? C++? C#? Lisp? Rust? Haskell? Ruby? Java? It's important to pick a solid one as I'll dedicate all my free time to it.

desktop apps are dead
long live the web
html and javascript for life
you're on a html gui application right now user

dont remind me

C++, C# or Java.
Python is more popular than Ruby now.
And other languages only for self-enjoynment.

>just embed chrome with your installer
:^)

Java. Java is the codemonkey language. Java is easy and fairly small.

Appreciate the input. I'm trying to stop being a useless shit.

What's the different between C++ and C? I know C is an assembler language unless I'm a literal retard. And I don't know anything of Java outside Java's webdev implications

>we could have had IMGUI but we got retained mode and web apps
Any other movies where the bad guys win?

you still have your imgui
dumb sepples poster

In Java, I have an iterator that fetches every thread on Sup Forums.
Iterator threads = ...
Obviously I dont want to keep all the threads in memory at once, so my iterator lazily fetches new threads as they are needed. The tricky bit is I only really care about all the posts in the thread, so I either want
Iterator posts = ...
or
Iterator posts = ...
is there a way to create posts without destroying the lazy fetching of threads?

the web is dead, long live mobile applications

>not writing everything in gtk+2

>obselete