/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Des_chiffres_et_des_lettres
play.google.com/store/apps/details?id=softin.my.fast.fitness&hl=en
wiki.haskell.org/Why_to_use_Haskell_for_GIS_programming_?
hackage.haskell.org/package/terrahs
twitter.com/NSFWRedditImage

Are you satisfied, sempai?

FP > OOP

Thank you for using a good porgramming language image.

He checks if NONE of the character EVER exists inside of the string.
You do not do that.

You output that "no character matches" when the last character in the string is not one of the searched for characters.
That is something different.

All good posts

Who /Haskell/ here?

Haskell is cute!

that lady has a GIANT chin

yeah i fucked up
see:

Right, but now you are not much different from the rest.
You say that having two "loop" instead of one is overhead.

But in fact, in the case of having all the characters not exist within the string, we do not even enter the second loop. Meaning we avoid work.

Both don't give or take much. Depending on the actual values they have different "speeds". Not that it matters anways.

In yours, worst case scenario is two loops though, best case scenario is one loop.

In mine is one either way

why did she declare winmain 5 times?

Fucking WinAPI, no one uses that. What the fuck did you do MAN

Is Automate the Boring Stuff good if you already have an intermediate understanding?

Does it teach good style?

Well, it's not my code that i am defending. My code is .

I am not too sure how his lambda expression actually works. Looking at it gives me AIDS, not too sure why people love it so much.

But it actually does seem like his expression actually runs through the entire search-String, instead of vice versa.
My code doesn't run through the search string. It runs through the string of characters to search for and sees if any of them exist.

And then the difference between my code and yours is as i said.

There's no such thing as good python style

Thank you for posting anime pictures

Chill, dude, this picture is from 1995.

Ask Ritsuko, she's not in charge of writing code.

What else would you suggest for GIS

GIS?

what do you use instead if you're C/C++ programmer?

NO
You asked if you did a better job quoting a guy that demanded a more interesting piece of code in the OP.

WinAPI IS NOT INTERESTING

Quick, someone propose a quick challenge

Depends on what you want to do.

There are many libraries that are proper C++ to use if you want to create GUI's or whatever.

Solver for en.wikipedia.org/wiki/Des_chiffres_et_des_lettres

filesystem management for example

boost

how about for plain old C?

Gonna ask again with all the info

I need your opinion /dpt/
I'll try to make it as short as possible.
So for end of study work, I chose to make a fitness app? Just like this one:
play.google.com/store/apps/details?id=softin.my.fast.fitness&hl=en

The thing is I'm alone on this project and I have to make it work for October. Didn't do anything for the moment. I'll do it in Java, mainly. I'm kind of good in Java. Like any regular student would be really.
Is it too ambitious ?
I also won't have really the time to only focus on this since I have an internship coming and classes.
Any opinions, advices ?

Sure, you could use WinAPI for that. It's a C-API after all.

Not too familiar with C-best practices.

GIS is not language specific.

GIS is predominantly working with two things:
>fucktons of your own data in a database
>fucktons of publicly available data via APIs

Both of these things are trivial in any modern, high-level language like Python, C#, Java, C++, and even some of the memelangs like Haskell.

You're effectively talking about CRUD when you work with GIS, as you will be using a mapping visualization stack that you yourself do not write.

Even if you did write the map visualization stack yourself, it sure as hell wouldn't be in Python. You'd be looking at something more along the lines of C++.

I'm making a backup manager for linux and windows and I'm trying to figure out which libraries to use and such. Trying to avoid GPL too

>pythonic way
>non-pythonic way

fucking what
you've got a tool which is never indented to be fast, just shitcode and run, it's inefficient as it is
no we want to argue which way to place bricks of shit is the only true way

i'm fucking mad

Read my response again from last thread, because it is the truth.

We don't know who you are, what your work ethic is, how intelligent you are, or how competent you are with learning new things and programming.

Yes, your goal is realistic for someone who is proficient in Java and has written an Android application before, or has a set of tools that can help facilitate the process.

I'm unsure of the cycles required for standard Android dev, but I know I could get something going with Xamarin + a few services in Azure very quickly, however, this would be with the intent to monetize to recoup Azure hosting costs if many people began using my application.

wew

wiki.haskell.org/Why_to_use_Haskell_for_GIS_programming_?
hackage.haskell.org/package/terrahs

I have been snoop doggifying my code as of late. All variables must end in the suffix "-izzle". It definitely helps with readability of the code

Please tell me what useful can be done with array-based programming language.
Hard mode: no "processing arrays"

is that show actually good or does it just get a pass for tiddies and coding

static void FindCharactersAndInformUserOfTheirBullshit(string input, IEnumerable characters)
{
var chars = characters as char[] ?? characters.ToArray();

if (input.IndexOfAny(chars) == -1)
{
Console.WriteLine("The string contains none of the supplied characters.");
return;
}

for (int i = 0; i < input.Length; i++)
{
if (chars.Contains(input[i]))
Console.WriteLine($"Found char {input[i]} at {i}.");
}
}

it's alright

anything since memory is an array

Highly parallel graphics programming, physics simulations, ... that sort of thing, which needs a lot of simple operations done at once. Array programming is basically to gpu what c is to processor (for example check out futhark language). It's for speed.

What do you consider to be an "array-based" programming language?

Fortran

Is anyone familiar with R? I am having some issues splitting rows full of characters into equal rows.

anyone here dropped out of uni and still did good?

No

Yeah I answered too in the last thread.
Other than my basic (not really basic) knowledge of Java, what do you want me to say. I'm as proficient as a student in the end of hi studies might be. I'm not one of the best student there but I'm pretty good.
Plus, really I didn't see the process of making this app being something other than creating a whole lot of DAO models and whole lot of data to put in the database with another bunch of query.
It doesn't have to be the prettiest ever either.

No, you're fucked for life

Reading the modern C pdf it's pretty great

>modern C

dumb weebposter

Google it trippo

I still have some courses left to get my degree. I was hired out of university and didn't finish them ._.

I still make a lot of money though

This compiles!

Finally, a Monad is just a Monoid in the category of endofunctors

What's the big deal?

Well, defining Monoidal categories, Functor categories and the necessary instances was definitely not trivial

Clearly you aren't on the spectrum.

I'm planning a a model of yeast epigenetics coupled to someone else's model of metabolic pathways.

Trouble is, the model of metabolic pathways was done in C, and the epigenetic models are best done in an object-oriented language (because there will need to be a seperate epigenetic map for each gene of interested, which would best be instantiated as objects).

I now need to either a) Learn to implement objects in C (I'm used to Java and Python because I'm a scrub), b) Get the C stuff to talk to epigenetic models in an object-oriented language or c) Update an old Python prototype of the current metabolic simulation to the state of the C version.

Cardgame webapp in flask
Its kinda my first project

To avoid I/O on each iteration of the loop, you should create a string and print it all at once.

In this case, I've used string.Join() which is optimized to hell and back with unsafe code:
Console.WriteLine(string.Join(Environment.NewLine, input.Select((x, i) => chars.Contains(x) ? $"Found char {x} at {i}." : null).Where(x => x != null)));

That being said, what you wrote would certainly be more readable to the average person.

You could even use regular foreach syntax with the indexer option.

Can anyone explain to me how returning functions work? It's the only part of coding I do not understand and I need to learn it. I'm learning Lua in case that matters. ty Sup Forums

Will you be affected by the H1-B visa changes, /dpt/?

What part is confusing to you?

I really wish there was a free alternative to this that was as easy to use.

>mfw Javafags will be gone in a couple of weeks
thank you based trump

test

Is that MATLAB?
Have you heard of GNU Octave?

lean about callbacks and also a bit about functional programming

some functions take a function as a parameter that they'll execute at some point in their scope. it's very useful to be able to modify this on the fly which is what lua lets you do.

I'm actually worried about politics for the first time in my life because Trump is an absolute madman

Languages like APL, J and K.

>Learn to implement objects in C
You can do a mock-up of OOP in C like this
#include
#include

typedef struct Array {
int* arr;
size_t length;
} Array;

Array* newArray(int len)
{
Array* ptr = malloc(sizeof(Array));
ptr->arr = malloc(sizeof(int) * len);
ptr->length = len;
return ptr;
}

void assign(Array* obj, size_t index, int x)
{
if (index > obj->length)
return;
else
obj->arr[index] = x;
}

int getNum(Array* obj, size_t index)
{
if (index > obj->length)
return 0;
else
return obj->arr[index];
}
// -----------------------------

int main()
{
size_t i;
Array* arr = newArray(10);
for (i = 0; i < arr->length; i++) {
assign(arr, i, i * 100);
}
for (i = 0; i < arr->length; i++) {
printf("%d\n", getNum(arr, i));
}
return 0;
}


>Get the C stuff to talk to epigenetic models in an object-oriented language
The easiest would be to use C++ with extern "C"
You could also create a Python wrapper or use the JNI

public class FizzBuzz {
public static void main(String[] args) {
for (int i = 1; i

>Is that MATLAB?
No. Mathematica.

No where has taught me how to use them.

I took CS50 for a few lessons to learn syntax, then took a full JS course on codecademy and now I've made a few game mods while avoiding the use of it.

Like for example I need to call a function from the game API that returns a string. My objective is to just print the string in chat so I can see it works. Once it's there I know what to do with it.

> function find:Finder()
> local location = GetLocationName()
> return location
> end

I know the code is probably incorrect but for something like that. I want to be able to use it correctly. And if that code saves the result of GetLocationName() to var location how do I use the variable outside of the function if its local scope confines it there

ty user, I'll look more into those. I am comfortable with freehanding functions it's just returning them I don't understand

> some functions take a function as a parameter that they'll execute at some point in their scope. it's very useful to be able to modify this on the fly which is what lua lets you do.

gonna save that in my goodadvice/g/gaveme text doc

It may not be as easy to use, but have you tried Sage?

procedural > functional

I already know a lot of programming (C++ and C). What other languages should i learn and what certs are people looking for in an employee? It doesn't have to be programming certs specifically. Looking at CompTIA now.

>C
>C++
>Java
How rich am I?

Are you a C programmer?
I'll have you try this (Cross-thread) and realize how hard it is to
1. Come up with a working code in time
2. Then making it secure

Yes. It's okay and probably the closest thing to a competitor Wolfram has right now but it's still a long way off. Ironically I think it'd do better if they ditched Python as the interface and came up with their own language for it. Something more LISP like but better.

I have a question.

I was a prospective student of Chemistry but I'm pretty much deciding to go the other way (CS+IT) last minute.
For someone who finds C++ easy up until OOP/classes but didn't have the drive to learn more, how hard is it going to be for me.

Of course, I also have a more extensive knowledge of hardware and I know just a bit about networking. Figured this would be the best general to ask in.

20 rupees per hour. you're well on your way to that yacht.

20 rupees > 0

just make sure to buy a toilet, pajeet. you've gotta have priorities.

Keep learning those two.
You don't need programming languages. You need to learn technologies, frameworks, things that are being used in companies.

You can also never be perfect in C++. The language is huge and if you truly want to be good in it then you will need at least another decade of working with it.
Read effective c++, more effective c++, etc. Improve and focus on one language, not 10.

No one cares about certs unless they are specific to a business framework - e.g. Hybris.

So bitter lol

(cont.)
I just realized I forgot to write a function that frees memory, but that's easy
void deleteArray(Array* obj)
{
free(obj->arr);
free(obj);
}


Ask me questions if you don't understand, but basically. the struct is like a class, the newArray function allocates memory for the pseudo-object and return a pointer to it, just new does in C++ and Java, and then I pass that pointer to a bunch of functions to mutate that pseudo-object.

I think you can do real OOP with functions pointers and shit if you are an absolute madman, there is even a 220-page long pdf somewhere on the internet explaining how to do it, but I think this approach should suffice.

absolutely designated

>Structs and functions that work on those structs are OOP
No. That's procedural programming.

>I think you can

Sure as hell you can, methods are nothing but function-pointers.
But it's stupid as fuck to simulate OOP'ness with C.
People that code and live in C actually love the paradigms of C.
They don't want OOP.

Holy fuck this place is still hyper obsessed with muh dichotomous programming paradigms instead of actually programming stuff

I'm writing a function that multicasts one large block of information (512kb to 32MB) out to multiple peers via TCP in Linux. Would this benefit from multiple threads?

Reminder

I'd quite like a language that lies somewhere between C and C++, with namespaces, maybe a simpler template system. I'm on the fence about RAII.

Sup Forums is a hell hole but it's the only anonymous community with enough people to be useful.

A scripting language like Python is useful to know, but if you are already good at C++, you won't have any picking it up.

You could also learn a bit of Lisp and Haskell just to get a taste of different ways of programming, but if your only concern is doing practical stuff, then you don't need anything else than C/C++ and Python (unless you want to make web or mobile stuff).

OOP = POO

It belongs in the loo

>Python
Way to tell him to do the programming equivalent of giving himself a lobotomy.

ok, so I have the area of a rectangle, and the ratio of length to width
how do I determine the individual length and width?

Ive been reading a bunch of anti-OOP articles. It seems the programming world is moving away from OOP, I believe someone called it the next goto.

how do I properly write say, game objects, or something that would've been easily represented in an inheritance hierarchy without OOP? There has to be a better way than functions that operate on structs.

Mathematics.

a = w . h

w = r . h

∴ a = r . h^2 = w^2 / r