/dpt/ - Daily Programming Thread

Real Programmers Edition #10

Previous thread: What are you working on, Jow Forums?

Attached: linus.jpg (1619x2024, 1.27M)

Other urls found in this thread:

stackoverflow.com/questions/24264195/repeated-include-in-headers
nim-lang.org/docs/tut1.html
twitter.com/NSFWRedditVideo

Lenses.

profunctor or van laarhoven?

Wishing I was lovingly thigh-locked by a cute anime girl.

>working on

Graduate lectures in complexity theory.
Now all those algorithm analysis books finally make sense.

putting my shit together and doing bunch of wrappers for C:
- simpler network interface, plan9-like dial-like, djb-like socket_connect, something for server, so unsure if use non-blocking by default or not
- I/O - signal-safe, atomic, buffered, lined, readall, ...
- signal handling
- random_uniform and getentropy seed for linux
- dynamic vector with the tailing null-terminator
- some filesystem functions
- overflow checks
- formattings and de/encodings
- in-house implementations of common extensions like strlcpy, strlcat, strtonum, mempcpy, ...
- packing of integers and floats with endianness control
and whatever comes to my mind, just in one place repo I can copy from when I need it

Van laarhoven I think?

In fact I'm pretty sure with some things you can blend both, at least the lens library has stuff like iso lenses that work for all profunctors.

Everything Edward Kmett builds confuses and frightens me.

Mine I was allowed to do on a white board. I can easily look back and say the code was pretty shit (this was a coding job I *started* at three days out of Uni... for a BS in EE). It was to uppercase a string.

A new task which was more interesting, the guy who asked the same question during the interview was thinking of more questions to ask. How many blades of grass are there on the planet? He asked all the guys at the company (10 or so) and said we all used different results. I did a fuckload of unit conversions, estimating the radius of the Earth as 3,000 miles. One of the only constants I needed. Yes it's nearly 4,000, but he was looking for process. Not surprisingly, I was a tool designer/programmer&debugger (and have a math minor), so just fucking burning through numbers, estimates, and references and just doing the fucking task is like more how I work.

Data File Processing for Big Data Analysis. (Python, SQL)
Custom Win7 Audio Device so I can set it as default and route two+ applications that don't support selecting audio devices to different audio devices. (C++)
Cached Dual-Issue Dual-Pipelined Synchronous Processor. (System Verilog)

Do you know where to make proposals or suggestions for base?

What happens if I have a cpp file with some unknow function from a library like SDL on their cpp file or header?

Do I need to include the SDL library on every header?

go back and read a c++ book m8.

Imagine if other mainstream languages had libraries even half as powerful as those Haskell has

pls halp.

;_;

...

Well, if I were interviewing a candidate, I'd just look out for basic things:
1) Do they understand the essential logic behind the question? (e.g. with FizzBuzz: using remainders/modulos or perhaps some faster equivalent, along with figuring out how to create the phrase)
2) If I'm emphasizing that they use a specific language (rather than using pseudocode), do they grasp the syntax? Mind you, FizzBuzz is nothing too difficult, but if I'm specifically searching for someone who should be good at C, you better know how to create a for-loop.
3) Most importantly, can they walk through the code and explain how it works and, if it doesn't seem to work, what they might try to do differently? If you're nervous, this is your chance to show that you can still be good -- I mean, in reality, everybody makes mistakes when they program (and not just small "missed a semi-colon" mistakes, but logical gaps), which their compiler/interpreter will hopefully catch. If I'm a decent interviewer, I'll try to be like a compiler and say, "This might be a mistake; what did you mean by this?"

If you somehow fail these three things (especially with just FizzBuzz), then you don't know what you're doing and/or don't have a problem solving mentality.

It's actually quite crazy, and equally crazy is how good GHC is at optimising code

stackoverflow.com/questions/24264195/repeated-include-in-headers

this doesn't solve my question.

Do I need to include SDL in every header?

When interviewing people I typically ask them what monads are, why they are useful, and to write monad instances for various types. Then, if they're hired, they end up writing Java all day.

Thank you

Attached: 392-math-not-even-once-1.png (489x448, 155K)

Should I learn Python or Perl? I am trying to learn something that would be useful in systems administration. I already use Bash scripting to automate tasks and create simple programs, but I'm finding it limiting for when I can't easily make pipes and read and write files.

Perl

Perl is easy as fuck, once you get used to it. It has a weird way of doing things that reminds me a lot more of C than anything else I've seen. You can use objects (they're not hard, even a C programmer can do it). I only used an object for the socket listener. I've written a few libraries for my own use. Pic related, loads options from a file (not the safest way, but it's wonderful)

Attached: wew.png (1235x744, 55K)

>Should I learn Python or Perl?
No.

No, I imagine a lot gets kicked around on the mailing list. From the (far) outside it looks like there are a few factions in the Haskell world: finance & consulting bros (stack, Snoyman, etc.), CS teachers (Haskell "platform", muh beginner friendly error messages, muh List-specific map in Prelude), type-level computation + dependent types reformers (SPJ likely sympathetic, Richard Eisenberg, ...), and let's-back-into-Python-via-category-theory (Kmett, lens).

Uh, I forgot the question. No idea. Probably the mailing list.

Don't forget the "waaaahhhh! mtl is too hard!" crowd.

> back-into-Python-via-category-theory

I say this semi-fondly, currently fucking around with a dependently-typed polymorphic record system so that JS & Python programmers can have their precious "objects" in a functional system.

I was leaning towards perl because the syntax is more C-like and isn't completely dictated by stupid indentation
What should I learn then if not Python or Perl?

>What should I learn then if not Python or Perl?
Miranda, ML, Haskell, PureScript, Idris, or Agda. Take your pick.

>JS & Python "programmers"
Would that we did not have to care about them and their meritless views on programming.

python is more relevant both in number of job openings and the amount it's used but even modern new stuff will be written in python27, python will also be more preferable if you're working with other peoples code due to perl typically being known for a read once language due the overabundance of low quality system admins writing terrible quality perl scripts - python at least forces syntax and doesn't give you 500 ways to do 1 thing
for writing your own small stuff quickly nothing beats perl though

Learn Ruby. It is a really nice language.

>Ruby
>nice language
haha no. more like ad-hoc nonsense-ridden language

install crystal

Lol what? Ruby is not ad-hoc at all. If anything, it is very well designed. Now Perl and Python are ad-hoc. In fact, everything in Python is basically ad-hoc to make up for inconsistent language design. Even the OOP facilities in Python were ad-hoc.

The day you realise that C is the only language you will ever need is the day you grow up... baka...

Attached: 03-800x445.jpg (800x445, 735K)

Perl in a Nutshell is a good starter. I only read up until the end of the first major section with function definitions and regex. Anything else I needed I pulled from online examples.

One of the most bullshit things I could explicitly give to you: Perl's internal environment is entirely capitalized. I needed it because I was running an autobuilder. It would go through some master->revision->patch files and run each line of a build bash/batch process checking return values - a lot more things, but simplest description). Well compiler directories and some other environment things are stored in case-sensitive environment variable names. Took me a long ass time to figure out that was why shit was failing terribly. Literally had to write a thing to save every variable from the environment on the first step (where we add specific compilers) and then unset and reset the environment every step.

I give a warning, I AM mentally ill (I'm here aren't I).

Notepad++ has a really nice theme. I never tried any Perl IDEs, and we wrote code outside of an IDE for our work.

Attached: Perl.png (2560x1344, 199K)

Why is programming so hard

t. doesn't understand any other language

most languages can interop with c, there's zero reasons to only use it.

What's there to understand? Muh OO, muh dynamic typing, muh monads... Yes, all very useful and requiring a high IQ... not!

>You can call my inefficient bloatware from C, so there's no reason not to!

Attached: Barbra-Streisand-young-pictures.jpg (2221x2400, 1.12M)

not sure what you were trying to do exactly but as with the case with most languages perl on windows is an absolute trainwreck

i meant the other way around.
I can wrap and use UFCS and other niceties with C.

I suggest you keep focusing on trivialities in C and leave the competent programmers undisturbed so they can work on useful things.

Because it's an engineering discipline marketed to students as alternately an art (look how creative you can be! hour of code!) and a science (expand knowledge! show how smart you are!) and viewed by managers as a magic black box that occasionally coughs up a few million dollars.

In a commercial setting, you'll always be rushed, at best you'll have a spec in English put together by someone who will end up actually using the result, in general you'll usually have gibberish produced by what we call a "people person".

And the machine gives not one fuck: how pretty you are, who your dad knows, how bad you want to punch Nazis, how hard you want to own libs, are you rich, do people just like you?

It's an engineering discipline. No magic. Some basic pieces, some quantitative principles, some experience people wrote down over the years. Make it work, make it fast, now change it all. Easier than a lot of jobs. But sold very, very poorly to kids who've never had to do anything truly hard in their lives. And the guys up top just read breathless articles about "leverage AI on the blockchain" and cream their pants.

It's the most fun in the world! For a certain flavor of brain damage.

>so they can work on useful things
Like what, a Python script to download trap porn from /gif/? Truly groundbreaking...

Attached: Barbra_Streisand_1962.jpg (2166x2500, 491K)

It worked perfectly. There is a technically annoyance with Perl itself not forking into a new executable when you fork, but that hasn't caused me any issues. exec/system/whatever forks off a process just fine, so the compiler runs on it's own merry way, multithreaded.

I missed my job (they weren't paying me - cash flow problems)

>the absolute state of putting a black/white header on a fax, on-the-fly, pixel perfectly

Attached: faxheader.png (2275x1074, 104K)

alternate comedy answer: because you fell for the Python meme

In the middle of making a shitty breakout clone.

Attached: 2018-07-26-194843_1280x800_scrot.png (1280x800, 66K)

It's hot. I am tired. My feet hurt.

Is this a good name for this interface, or is it awful? I can't decide... Any Module that wants to be notified by the engine that it's deactivating must implement this, and the engine will call that method.

public interface IWatchesForDeactivation : IModule
{
void Deactivate();
}

hola cristian
burrito o taco?

just put it in IModule and make it optional to implement or use an event

I've just eaten a taco once, never a burrito.

I'm not mexican.

do include goes before ifndef in c++?

This is why every language needs a gofmt equivalent

>do include goes before ifndef in c++?
The purpose of the ifndef is to prevent including something that has already been included. The ifndef would be pointless if it came after the include.

Attached: 1531721950111.png (403x448, 53K)

I prefer to not put optional methods in an interface. It seems messy to me. Also, I wouldn't be able to use LINQ to do a simple:

modules
.Where(module => module is IWatchesForDeactivation)
.Select(module => module as IWatchesForDeactivation)
.ForEach(module => module.Deactivate());

Not using events because I'm deliberately not giving the modules references to the engine. It's a plugin system, and I don't trust any future potential plugin developers.

c++ really needs to just steal more things from d and add a version(){} block so it's much clearer when doing multi-plat/whatever.

is there a character invisible to the terminal besides null (value zero)? i would like to avoid array concatenation.

Attached: dick yay.jpg (5000x5000, 1.91M)

IShutdownListener

help pls.

Attached: 2018-07-26-202733_1440x900_scrot.png (1440x900, 312K)

You forgot Game.cpp

(you need to either pass it to g++ with the other .cpp files [not .h files, unless you've really fucked the dog], or compile each separately and then link)

do I need to include both header and cpp files in a makefile?

just the cpp, how else is it gonna know how to link it otherwise?

Thanks.

Attached: 2018-07-26-204406_1440x900_scrot.png (1440x900, 217K)

I think I might know what you’re talking about.
You have a file, headers.h
In that file, you include headers from a library, such as SDL
You want to know whether you have to include the sdl library.

If the implementation actually uses the sdl lib’s functionality, then yes. Your executable needs to be able to locate those sdl functions when they’re called.
It could be (but is unlikely) that you just include an sdl file, but never use it. In this case, linking isn’t necessary, but you would need to be able to find the header file.

This is going off of memory and I don’t know exactly if I answered your question, so let me know if I screwed up somewhere

headers are for definitions, if you're not calling the functions in your file you don't need to include the definition

it's not going to kill you to include it because the linker isn't retarded, it's bad practice though

You can create anything.

This is a blessing and a curse. There are many ways to do the same thing. Other engineering disciplines are harshly constrained by physics. It is easier for them to predict the consequences of their design choices than it is with computer programs.

Is Scrum a methodology or a framework? Google has mixed answers, forums/articles says framework, Wikipedia says methodology.

Why do you shitheels make it so impossible to even get to the interview so we can actually prove these three things?

Any book recommendation on Python/parallelism, multiprocessing, threading?
I got 'Python Parallel Programming Cookbook' recommended by a colleague, but it looks rather shilled and basic to me.

Attached: 1436536625152.jpg (400x517, 28K)

blame other programmers for spamming buzzwords and lying on their resumes

just install nim.
it's python syntax in an actual systems lang.
nim-lang.org/docs/tut1.html
python will be terribly slow no matter how much optimizations you try.

>nim
nah, use a real language

what's "fake" about it?

not ready for production use
no clear use case
can't decide whether it wants a gc or not
relies on an army of shills

>not ready for production use
false, there's already companies using it.
false
it doesn't have to, it gives you the choice to either use it, don't use it, or use it sparingly.
>army
it's pretty much just been me occasionally shilling it desu.

Explain this bullshit please

>occasionally
continually and repeatedly attempting to shoehorn it in in response to every question. still i guess at least you don't rely on fake benchmarks like the julia shills do

i really only bring it up if someone mentions learning python or their first programming lang. And i keep it to a few times a thread max.

>get homework assignment as part of interview for employer
>they want me to edit some project in react.js
>not what I signed up for, but okay I guess
>open the JS fiddle link
>their code is so bloated and slow that it freezes firefox
I-is this part of the test?

Attached: 1481729208533.jpg (460x532, 33K)

That's still irresponsible. We should be directing people to mature, principled, reasonable, cruft-free languages like Scheme and ML for learning.

>Lisp
no that's irresponsible.
Stop suggesting shitlangs.
>ML
Idris.

>Lisp
I agree that most lisps are unsuitable. However, Scheme is an exception.
>Idris
A fine second programming language.

i just don't see the point of Scheme when both Nim or Idris can do everything it can and more.

It's for an assignment, so i'd rather just use what's given.

You're a big big retard, is that a photo of yourself?

#ifndef FIRST_FILE
#define FIRST_FILE
#include
#endif

#ifndef SECOND_FILE
#define SECOND_FILE
#include
#endif

Now, what happens when both 1st file and 2nd file are included in the main?
That's right, something gets included twice (iostream).
Obviously iostream also has header guards, pragma once, whatever you want, so nothing bad happens.
But it still got included twice.
It wouldn't make a difference if #include was typed before #ifndef.

This is something so obvious and immediate to know, the fact that you made this post shows that you don't use C++.
This is who posts brainlet wojacks to mock others, this is also why Jow Forums is shit

Attached: 1375845710375.jpg (600x579, 83K)

Attached: use nim.png (750x750, 228K)

Nim is a meme. Use python

y tho

But python is deprecated. See

>Idris
As I've said, it's a fine language. However, I think a first programming language should be fairly small so that students are not overwhelmed by it. Even Edwin Brady has written (see his twitter account) that it's feasible to simply read the Scheme spec when you get stuck.
>Nim
You just can't resist suggesting it, can you? You're up to two out of 'a few' times in this thread already. Three if is also you. Anyway, I don't think it's suitable for a teaching language:
>immature and unproven, hasn't even hit 1.0 yet
>multi-paradigm kitchen sink, a teaching language should be focused
>more subjective, but I don't think people should be exposed to mutation at the start of their programming education

we're having a conversation, but no that mong isn't me.
>>multi-paradigm kitchen sink, a teaching language should be focused
Who cares? People can use the language how they want and discover other features later. This is a non-argument. If you want to learn it like OOP you can, if you want to learn it as FP you can, if you want a middle-ground that's fine too.
>but I don't think people should be exposed to mutation at the start of their programming education
i disagree, mutation is a simple but important subject to understand. Hiding it until later only hurts.

Isn't the point of interfaces to force methods, it's not messy it sucks the logic that makes the thing useful in the first place

>pass intro to Javascript on Codecademy
>exercises and quizzes bulwarked by paywall
...any alternatives? I like to review and sandbox the basics before going further.

Perhaps if you have a teacher then they can keep you on the straight and narrow, but if you're new to programming and you start using a multi-paradigm language then the odds are good that you'll end up writing balls of mud. Imagine a newbie without any direction starting with C++ as a first language. If you learn FP and OOP separately and in isolation then you will be able to appreciate their strengths and weaknesses better than if you mix them together while learning. (Aside: I don't actually think anyone should learn OOP because I don't believe it has any merit. Cynic that I am, I idly wonder whether you are a secret OOP zealot trying to sneak it in under the radar to new learners.)

Avoiding mutation leads to being able to reason about your code better. If mutation is only introduced later, by then you will be in a position to appreciate the benefits of avoiding it as much as possible.

Okay guys. Here's a question.
Can you build glew on windows for mingw, without using visual studio?
Because it reeeeeally doesn't look like it wants to do that.
Everything i can find suggests if you're doing windows, you should be using visual studio. And if you don't want to use visual studio, you can fuck yourself sideways.

You're gonna write nothing but shit your first few years anyway. Artificially restricting yourself won't prevent that, no matter what language you use.
And most new people are gonna stay away from FP anyway because it's "scary".
>If you learn FP and OOP separately and in isolation then you will be able to appreciate their strengths and weaknesses better than if you mix them together while learning.
Most people do learn this way though.
They have tiny 100 line programs where they play with map, filter and range operations. And then another tiny module where they play with classes and inheritance.
> I idly wonder whether you are a secret OOP zealot
I've never advocated POO, only the option to use it. I personally prefer FP, and write all my code as pure and FP-like as possible. But i guess trying to be agnostic upsets autists like you.

Honestly the way you favor restriction is disgusting, and i'm surprised you aren't here shilling rust.