/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

sqlite.org/appfileformat.html
seriot.ch/resources/talks_papers/20141106_asfws_unicode_hacks.pdf
mega.nz/#!s3BH0DjZ!cE9FZZRNpo_IQAcdq1x74fMbRVO0RXh4pckc6vR3kZM
twitter.com/SFWRedditImages

Both YAML and JSON are horrible languages.

idk stuff

yeah, Common Lisp really is the best language.

I know you're just trying to be provocative, so uh, good luck with that buddy.

{
"reddit": {
"subreddits": ["foo", "bar"]
},
"rss": {
"urls": ["foo.com", "bar.com"]
},
"console": {
"format": "{NAME}\n{URL}\n{DESCRIPTION}"
},
"mail": {
"host": "smtp.foo.com",
"port": 25
}
}

I have to agree, JSON does look nice.

What's better?
XML, JSON, or dumping your structs in a binary file for persistence?

SQLite.
sqlite.org/appfileformat.html

Binary if the user isn't supposed to change the file

XML is bloated garbage
JSON is alright for a human readable format
binary dump is the fastest

Could someone give me assistance? This program (left) stops at line 29 with a segmentation fault error and I don't know why.

CSV

why do people here hate on c#

pls no memes

JSON

Microsoft.

Not even the best lisp.

same reason they hate on Java

No linear types

And where is line 29?

Closed source. Enterprise-y.

clojure is not.
dumb jvm poster

Just memes. It's one of the best languages out there.

Line 29 is 'call factorial' located in the function.

ClojureScript :')

>tfw can't grok Rust lifetimes

javascript is C in lisp clothing.

Do they? I haven't noticed. Anyway, it's a good language and .net is a nice platform, if I had to choose a language with GC to make some enterprise shit, I would choose C#, but thank god I don't.

"Here's a nickel, Kid. Buy a real editor."

Also, solarized is so 2013.

seriot.ch/resources/talks_papers/20141106_asfws_unicode_hacks.pdf
Unicode was a mistake.

Well I have created this to reply to faggots
mega.nz/#!s3BH0DjZ!cE9FZZRNpo_IQAcdq1x74fMbRVO0RXh4pckc6vR3kZM

If you don't trust links I can share source code but it's xtremly spaggety (I've started CS 2 weeks ago so yeh)

But Scheme is.

Every scheme ends up providing the same things as Common Lisp but in non portable way.
dumb racket poster

>his language doesn't store all string as utf8 internally
>the char type in his language isn't 32 bits wide
Sucks to be you.

Beginning to get more comfortable with working exclusively with the terminal.
I'm loving it -- There's no distractions or shitty GUI's I have to deal with.
One question about emacs though:
How do I get the undo-tree C-x u to appear on the right side of the screen?
I've tried to do C-x 2 or/and C-x 3 to split the panes, but that only further splits the two panes I have.

Every scheme ends up providing 20% of Common Lisp and that's the point.

No matter how you slice it, it's unstable garbage. UCS-2 (UTF-16 static length) would have been enough if they didn't pander to the chinks by not unifying their fucking massive character set because of "muh legacy encodings", then they would have no problem fitting in everything they needed in BMP.

t. somebody who have never read Common Lisp standard or any scheme compilers documentation.

And also, there shouldn't be any RTL support. Arabic text should have been stored reverse, and applications would have to input it in the rendering order (e.g store "As-salamu Alaykum" as "mukyalA umalas-sA", then x11 people get to make sure the selection goes haywire properly)

I'm a beginning noob and I'm learning C from a book. So far I'm making decent progress. I'm taking small steps and doing as much typing and testing the concepts that I can. Right now I'm trying to make a math game that allows the player to set how many questions it will ask, keep track of how many they get right and wrong and display that at the end of the quiz.

I feel like I understand the simple things but I don't know how to plan and organize the programs I'm making. I feel like they could be better designed but I'm not really sure. Any books that would possibly help me do that? C is my first and only language so far. I'll be starting community college in January to start learning all of this stuff in a classroom setting but I want to get ahead now while I have the change.

Is there any way to manipulate the tokenized representation of C source code? I don't want to write my own tokenizer.

> No matter how you slice it, it's unstable garbage.
It's quite stable now, utf8 works just fine, it's only unstable for the platforms from the 90s that embraced UTF-16 too hard too early.
> then they would have no problem fitting in everything they needed in BMP
But what about character? How would we live without it?

(You)
Wew, apparently Sup Forums doesn't like my perfectly fine Unicode block: U+1F4A9 PILE OF POO (HTML 💩)

Organisational code will be something you'll get better at over time. Everybody sucks at it when they start.

You should try to split everything up into smaller functions as much as possible, until you feel you've gone too far. That's the gist of it, there are several books on it.

Sup Forums strips emoji and shit from posts

>"""""Design Patterns"""
That list is garbage, unless it's there as an example of what NOT to do.

> i havent noticed
go to previous dpt thread mr dummass

>Organisational
Organising*
I realised I picked the wrong spelling correction.

Unstable garbage in the sense that it's unreliable. When there are security vulnerabilities in text rendering, something has gone horribly horribly wrong.
Sup Forums is quite strict on the unicode, you can't have too many combining characters (zalgo) and Cyrillic acexopy gets replaced with acexopy. This confuses and enrages the google translate.
>some of these are utter garbage.png

I figured that might be the case. As I'm doing more varied programs and solving how to go about making them I've gotten quicker at figuring things out.

Thanks for the list. I'll check some of them out. So far I'm just working on nesting things and making sense of how much nesting is necessary. Also when using "if, else" vs a switch and two or more cases.

>2017
>C and C++
>Overflow on signed types is undefined behavior
>No built in way to check if overflow has occurred
defend this

It's architecture specific, how should they implement it? You can check the overflow flag on x86 and friends, you can write a safe addition routine that warns you beforehand. What do you want?

>but I don't know how to plan and organize the programs I'm making.
Split your code up into different layers.
UI (GUI/CLI) glue code (business logic) backend (I/O such as database interaction)
It's not exactly programming related, but 'The Art of Unix Programming' has some tips and tricks to keep your code modular.

It's FAST and PORTABLE

Most other languages either explicitly define that integer overflow wraps around (because that's how it works on 99.9% of processors) or that it triggers an exception of some sort (because it's checkable on 99.99% of processors).
In C, the compiler is allowed to generate code that works differently under different optimization flags. E.g.
int test(int x) {
return (x+1) > x;
}

>You can check the overflow flag on x86 and friends
Would be lovely if C had any functionality to let me do it.

>Wanting your language to be slow as balls by doing everything instead of letting the programmer worry about relevant parts of code execution
If you want something done right, do it yourself:
long sat_add(long a, long b, int bitwidth)
{
int sign_state, temp_sign;
long temp_addition;
sign_state = get_sign_state(a, b, bitwidth);
temp_addition = a + b;

temp_sign = get_sign(temp_addition, bitwidth);

/* Make a decision of what to return based on the signs of the inputs */
switch(sign_state)
{
case(BOTH_POSITIVE):
/* We know if an overflow/underflow happens if the sign of the addition is
different than from one of the inputs (and both inputs have the same sign) */
if(temp_sign != get_sign(a, bitwidth))
return signed_max(bitwidth); /* Overflow */
else
return temp_addition;
break;
case(BOTH_NEGATIVE):
if(temp_sign != get_sign(a, bitwidth)) /* Underflow */
return signed_min(bitwidth);
else
return temp_addition;
break;
default: /* case(SIGNS_DIFFER) */
return temp_addition; /* Business as usual */
}

If 99.9% is good enough for you, then rely on UB. It's that simple.
Write a macro that checks if you're on an arch where you can check overflow flag, if so evaluates to inline assembly snippet, if not evaluates to safe addition snippet. Simple as.

>sign(a + b)
IT'S ALREADY TOO LATE

>then rely on UB
That's not what UB means. UB doesn't mean "architecture specific". UB means "the compiler is allowed to completely ignore the effects in the case of the UB event happening, so you literally cannot predict the result of your code even if you know how it is *usually* implemented on your architecture"

Also: C is not anywhere close to a "short translation away from assembly" as most people claim.

learned about functions today in class
you REALLY have to read the code! in C, at least

I can see how it can get very messy very fast

>integers in his language don't have wrapped_*, saturated_*, checked_* and overflow_* methods

eww

>checked_abs

and?

with systems that use two's complement the most negative value cannot converted to positive with same bit width.

wanna check my abs?

check this out:
01000100 01000001 01010100 01000001 00100000 01010011 01000101 01000111 01001101 01000101 01001110 01010100 00001101 00001010 00100000 00100000 00100000 00100000 00100000 01001110 01010101 01001101 00110001 00100000 01000100 01000010 00100000 00111001 01001000 00001101 00001010 00100000 00100000 00100000 00100000 00100000 01001110 01010101 01001101 00110010 00100000 01000100 01000010 00100000 00110111 01001000 00001101 00001010 00100000 00100000 00100000 00100000 00100000 01010010 01000101 01010011 01010101 01001100 01010100 00100000 01000100 01000010 00100000 00111111 00001101 00001010 01000101 01001110 01000100 01010011 00001101 00001010 00100000 00001101 00001010 01000011 01001111 01000100 01000101 00100000 01010011 01000101 01000111 01001101 01000101 01001110 01010100 00100000 00100000 00001101 01001100 00100000 00100000 00001101 00001010 00100000 00001101 00001010 00100000 00100000 00100000 00100000 00100000 00100000 01001101 01001111 01010110 00100000 01000001 01001000 00101100 00110100 01000011 01001000 00001101 00001010 00100000 00100000 00100000 00100000 00100000 00100000 01001001 01001110 01010100 00100000 00110010 00110001 01001000 00100000 00100000 00100000 00100000 00100000 00100000 00001101 00001010 01000101 01001110 01000100 01010011 00001101 00001010 01000101 01001110 01000100 00100000 01010011 01010100 01000001 01010010 01010100

>Most
Literally only the minimum value.

DATA SEGMENT
NUM1 DB 9H
NUM2 DB 7H
RESULT DB ?
ENDS

CODE SEGMENT
L

MOV AH,4CH
INT 21H
ENDS
END START

dumb binary poster

>the most negative value
dumb spanish poster

>What are you working on, Sup Forums?
Writing a standard neutal network in C++ using Eigen for matrix stuff. Just for practice/fun.

>:^(
01010111 01100101 01101100 01101100 00100000 01100110 01110101 01100011 01101011 00100000 01111001 01101111 01110101 00100000 01110100 01101111 01101111 00100000 00111110 00111010 01011110 01111100

So I have a industry related question. So after a few years of experience, degrees and qualifications don't matter as much. Now my question is, does the success/scale of previous projects get taken into consideration when hiring someone?

Let's say for example (which is kinda the position I'm in), you work for a company, they assign you as the only developer for a product. The product is quite successful and gets deployed nationwide by 2 or more very big companies. If you were to apply for a job which require way more qualifications/experience than what you have, would you even get considered based on the scale/success of this project? Because to me it feels like it's an experience or gtfo industry. And how do you even get noticed in the industry when working for a company (you can't show anyone the code).

Why is writing libraries in C++ a bad idea?

C++ has no stable ABI so you can't distribute compiled object code.

The language is shit to begin with.
Unstable ABIs, making your library stupidly hard to link with.

sql is really fucking cool in so many ways

thanks senpai

You propably need to use libraries to build your own library. Most sepples libraries are shit and cluster fucks of template mess.

error: unresolved external ___SDfSDF_ASCASDc_______ASEFDasd__Hello_World_ZSD123D@#FD123dfc

That terminology is used all the time in science because if you just say "minimum" it's not always clear whether you are talking about the minimum magnitude or the minimum value. Saying "most negative" makes it explicitly clear that you mean the number with the lowest value, not the closest to zero.

In CS the distinction is less meaningful because whatever zero represents for a given dataset might as well be arbitrary, but it's not a bad habit and certainly isn't exclusive to non-native English speakers.

>Now my question is, does the success/scale of previous projects get taken into consideration when hiring someone?
Success no, scale yes.
It's the job of the marketeer to make the product/service commercially successful. Your job is to make it as good as possible for the given time/resources.
Having experience in large scale projects is a big bonus. Everyone can write a simple script, but mastering a large scale project is tricky. You have to take into account performance, maintainability and scalability. Those three aspects are also relevant to small projects, but they really make or break large scale projects. Architecture is very important during technical interviews. Make sure to convince the interviewer why your architecture is so great and what you contributed to it.

Here is pretty much the worst place to complain about this because y'all will just tell me to use C or something if I want speed, but matplotlib is fucking slow! I thought it would be cool to represent some of my data as a 3D surface, but if I try to render it with enough resolution to actually look like something, I run out of memory. I guess that means no easy surfaces for me.

> C++ has no stable ABI so you can't distribute compiled object code.
It has no stable cross-platform ABI, but that doesn't mean you can't distribute compiled object code within a platform.

I'm working on a command-line tracker that synthesizes music from text files. I originally only planned on making the synthesizer part (as a means to play music live), but I wanted to be able to store and playback music. It's currently got support for sine/square/pulse waves, polyphony, and the ability to change the duty cycle on the pulse wave. My next goal is to make each channel independent of one another, allowing for standard features like having different waves play in different channels.

Stack overflows.

Fuck you, and fuck your boost. C++ code using std::string compiled using c++11 mode can't be linked to C++ using previous c++ standards.

Yes, because the internal representation of std::string in libstdc++ has changed, they used to have some optimizations the new standard specifically forbid IIRC. It's a gcc problem tho, not C++ one.

It's a gcc problem, and what this problem means is that c++ does not actually have a stable ABI within a single platform either.

Well, ok, you're kinda right, but that doesn't stop all the C++ libraries from being distributed as compiled shared libraries. I mean, Qt works fine everywhere, yet no one links to it statically.

Why aren't you learning Haskell, Sup Forums?

Doesn't have linear types

Static Qt is intentionally gimped, last time I checked you couldn't even have Wekbit if you compiled it as a static lib.

But static/shared distinction is completely irrelevant for the question, since both suffer the same from the lack of stable ABI.

I learned Perl because it made easy things trivial and difficult things possible. Haskell makes easy things difficult and trivial things possible. I gave up trying to make any use of it.

So I want to create a child process and redirect its stdin and stdout to the parent, then go back and forth - send string to child, get response, send another string, get next response, and so on. Unless I close the pipe write handle(which I don't want to because I want multiple writes), ReadFile() will block indefinitely (despite the child process writing something to stdout immediately after startup, so at least the first read should go through). Also if I ignore the ReadFile() issue for a moment and just call WriteFile() a couple of times, only the first write works out.
Halp. Has anyone else done this sort of stuff?

> But static/shared distinction is completely irrelevant for the question, since both suffer the same from the lack of stable ABI
According to you the lack of stable ABI is such a huge problem "you can't distribute compiled object code", yet the fact that all the Linux distributions have no problem deploying C++ libraries as compiled shared libraries makes your statement demonstrably false.

>but that doesn't mean you can't distribute compiled object code within a platform.
So long as "within a platform" means "I've got exactly the same versions of everything" then yes.

Qt does better than that because it actually tries to avoid putting implementation details in places where they'd get compiled into client code, but that's very much the exception in C++ land.

Don't see how. All distributions compile their own libraries and software packages. If you want to distribute binary library you expect that whoever makes the software will build that software himself, not ask for you to build it or build it using the compiler you provide.

>winapi
I'm sorry user

I don't know about Windows, but on Linux the typical problems would be:

1. You not flushing the buffer after writing to it.
2. The program you write to detecting that stdout is not a tty and therefore not flushing its own output buffer.
3. Using a function that tries to read the amount of data you ask for instead of returning when it gets anything (i.e. hanging until you get your full 4096 bytes)