[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 28

File: 128326706456.jpg (263KB, 1118x1600px) Image search: [Google]
128326706456.jpg
263KB, 1118x1600px
What are you working on, /g/?

Old thread: >>59482218
>>
>>59486363
first for C#
>>
Reposting since the thread was dead
>>59485913 (You) here.

Would you say, (based on your feedback) this is a fair TL:DR to entering the Programming Industry?
1. Learn more Python, then Java
2. Take some beginners Comp Sci courses on Coursera/edX
3. Actually get good at Python/Java
4. Start learning C++
5. Wipe my ass with my Toilet Paper diploma and look for a job
>>
yeah fuck norskmaend
sut min brune pik
>>
>>59486394
>Python then Java
Fucking shit advice
>>
Real thread: >>59486332
>>
>>59486363
A puzzle-platformer.

C + OpenGL 3.3 + GLFW + gl3w + portaudio.

Python for level generation from images.
>>
>>59486394
holy shit who cares just get gud
start programming that's how you learn
>>
No, this is not the real thread, let it die and come here >>59486332
>>
>>59486394
Why exactly CS?
Are there other degrees?
>>
>>59486394
>Learn more Python, then Java
Wouldn't agree with this generally speaking, but your first languages should be based on what you actually want to do.

One does not typically do the same things with C#, C, and R.

If you just "want a job" then learn Java first. C# also has a fuckton of jobs, and C++/C/Python have plenty after that.
>>
>>59486404
>>59486421
>not in English
>>
>>59486363
What is the book in the OP? Looks pretty easy to understand.

>>59486404
>>59486421
>>>/int/
>>
File: 1480590811928.png (389KB, 934x1000px) Image search: [Google]
1480590811928.png
389KB, 934x1000px
>>59486454
> What is the book in the OP? Looks pretty easy to understand.
SICP
>>
>>59486454
SICP chapter 1 is the square part and chapter 3 is the cons thing
>>
>>59486437
>claims to be a programmer
>can't figure out a language very similar to one he is fluent in
>>
>>59486468
>>59486478
>SICP
Well, never mind, I guess.

I've tried starting both that and K&R and kept waiting for them to show me something useful and productive.
>>
>>59486498
K&R is just a book about C, what did you expect?
>>
File: 1489955229203.jpg (33KB, 366x321px) Image search: [Google]
1489955229203.jpg
33KB, 366x321px
What can I read to learn about various data structures?
>>
anybody here ever used a fibonacci heap or a van emde boas tree?
>>
Why .NET isn't anywhere wide as Java?
>>
Could someone help me write a method to clear (initialize/reset) elements in an array based priority queue?
>>
>>59486696
free(array)
>>
>>59486696

for(i=0;i++;i<lengthOfQueue)
q[i] = 0
>>
>>59486688
Nothing comes close to Java's market share.

I'm curious what it will look like 10 years from now once .NET Core becomes more robust and Mono/.NET Framework merge into a FOSS state of existence with more device penetration.
>>
I'm creating Abstract syntax trees for my programs.

what should i call the function that creates the nodes?

make_node
mk_node
create_node
...
>>
>>59486696
if the queue is contiguous in memory why not try memset(buffer,0,sizeofbuffer)? Its usually faster than just writing a loop.
>>
How does strcmp() work?

I know what it returns, but how does it actually work? What does it check for?

Because I'm comparing strings that are obviously different and strcmp returns 0.
So whatever strcmp checks for these strings have in common despite having different characters.

for example:
const char *hash = "50FhJkW";
cont char *new_hash = "50hjHHd";

if (strcmp(hash, new_hash) == 0)
{
printf("%s",new_hash);
}



will print out every new hash I generate despite being different from the original on a character by character basis.
>>
>>59486785
node.new
>>
>>59486790
it's a priority queue, it probably isn't contagious

if you want lg(n) time anyway
>>
>>59486785
node_create
>>
>>59486800
NAME
strcmp - compare two strings

SYNOPSIS
#include <string.h>

int strcmp(const char *s1, const char *s2);

DESCRIPTION
The strcmp() function compares the two strings s1 and s2. It returns an integer less
than, equal to, or greater than zero if s1 is found, respectively, to be less than, to
match, or be greater than s2.

RETURN VALUE
The strcmp() function returns an integer less than, equal to, or greater
than zero if s1 (or the first n bytes thereof) is found, respectively, to be less than,
to match, or be greater than s2.
>>
>>59486834
That doesn't answer my question. Do you have poor comprehension?
>>
What language has OOP implemented right?
>>
>>59486848
int strcmp(const char *cs, const char *ct)
{
unsigned char c1, c2;

while (1) {
c1 = *cs++;
c2 = *ct++;
if (c1 != c2) {
return c1 < c2 ? -1 : 1;
}
if (!c1) {
break;
}
}
return 0;
}
>>
>>59486855
https://github.com/yegor256/eo
>>
>>59486855
smalltalk and ocaml
>>
>>59486800
Nothing will be printed with your code. If you're going to post an example snippet, at least post one that shows the problem you're having.
>>
I want to track my sales from sites like redbubble myself and was thinking of using Python to write a script that read my emails, and used that information to fill a spreadsheet of my sales and sales times. Is python a good choice for this? I'm pretty new to coding but I don't feel like this sounds too hard to do.
>>
>>59486976
Yeah python is fine.
>>
>>59486891
>ocaml
I'm an OCaml lover but pretty much no one uses its OOP facilities though. I'm sure we'd find some shortcomings in it otherwise.
>>
>>59486976
I don't like Python, but for your task it's OK.
>>
>>59486785
What's your program structure? If you're doing something like C++ or Java where classes can have member functions, and you have the syntax tree as a separate structure from the nodes it contains, I'd suggest something like SyntaxTree.addNode(). If you're doing C-style ``OOP", on the other hand, my convention is to create new structs "manually", using either stack or heap allocation, and then calling an "init" function to set its initial values. To emulate C++ namespace behavior, I prefix the function name with the struct tag name, followed by an underscore, e.g. node_init() to initialize the value of the first node. A pointer to the object itself is passed as the first argument.
>>
>>59486976
Absolutely.
>>
Dependent types completely invalidate OOP. You don't need encapsulation to indirectly enforce an invariant any more, you just make the invariant part of the type.
>>
>>59486800
>I'm comparing strings that are obviously different and strcmp returns 0
I just ran your code and strcmp is returning -34, not 0.
>>
>>59487034
>-34
>>
If you don't learn a second language it is very unlikely that you will become a good programmer.
>>
>>59487054
Yes, -34.
>>
>>59487059
This, I'm going to learn 日本語
>>
>>59486800
>hash
Are you comparing binary values or actual strings? If your value contains a 0 byte, strcmp will stop at that point.

If that's the case, use memcmp instead.
>>
>>59487059
I am bilingual
>>
>>59487027
This, pretty much.

OOP has been on the ropes for a while but when dependently typed languages enter the mainstream, it will be completely obsolete.

Sadly, like COBOL, it will cling on for decades in legacy systems.
>>
>>59487084
Good.
>>
>>59487027
>>59487089
Xould you spoonfeed on dependent types?
>>
>>59487054
The value returned by strcmp is only defined to be less than, equal or greater than zero.

The implementation he is using is returning the difference of 'F' and 'h'. For easy calculation in your head the difference in ASCII between lower case and upper case is 32.
>>
>>59487131
https://www.youtube.com/watch?v=X36ye-1x_HQ
>>
>>59487157
>46 minutes video
Something to read, maybe?
>>
>use struct pointer in inline asm
>g++ optimizes the whole thing away
>make it volatile
>g++ takes 5 minutes to print all the invalid cast errors
>>
>>59487157
>type driven development
>Not Test Driven Development
>>
>>59487175
It's a really good video. You can stop around the 30 minute mark, where he goes into Idris' algebraic effect library and it's not really focused on dependent types any more.
>>
>>59487203
>meme driven development
>Not Meme Driven Development
>>
>>59487219
Sorry if you don't have a job don't reply to me
>>
>>59487227
>muh memes
>>
Want is the hardest, most complex programming language to learn? Besides assembly.
>>
What buzzwords do I need to know?
>>
>>59487271
inline Malboge
>>
>>59487271
Malbolge
>>
>>59487203
He actually explains that "type driven development" is pretty similar to test driven development. It makes sense, since dependent types (i.e. proving theorems about your program) do essentially replace unit tests.
>>
>>59487131
fun : Bool -> Type
fun True = Int
fun False = String

fun2 : (b : Bool) -> Int -> fun b
fun2 True = id
fun2 False = show
>>
>muh type feeree
i just came all over my haskel code
>>
>>59487294
Int -> fun b

Will it ever work? fun takes Bools.
>>
>>59487330
b is a Bool.
>>
>>59487330
fun is a function from a bool to a type

(b : Bool) -> Int -> fun b
indicates that the result type is
Int -> fun b
that b is the bool that was passed in, it DEPENDS on that value
>>
>>59486998
it's better than Java/C# style OOP at the very least. Crystal and Ruby are also pretty good implementations of OOP
>>
should i cast here?
struct xxx {
struct xxx *n1;
struct xxx *next;
};

struct xxx *node_create()
{
// cast or not??
struct xxx *temp = malloc(sizeof(struct xxx));
temp->n1 = NULL;
temp->next = NULL;
return temp;
}
>>
>>59487417
In C, no. In C++, yes but you're doing it wrong.
>>
File: Coyoter.png (187KB, 272x348px) Image search: [Google]
Coyoter.png
187KB, 272x348px
>Programming assignment that I need a B or higher on due in 2 hours
>Haven't done much work and barely know what's going on
>Probably going to fail this and then get kicked out of college
Quick suicide methods?
>>
>>59487417
no, casting malloc is dumb
>>
>>59487417
no
also no parens for sizeof
>>
>>59487436
ODing on heroin is probably the most fun but it'll take a while to die
>>
>>59487436
whats the assignment?
>>
>>59487442
hmmm
xxx.c:18:44: error: expected parentheses around type name in sizeof expression
struct xxx *temp = malloc(sizeof struct xxx);
^
( )
1 error generated.

>>
>>59487361
So, if I pass b = True, I get the id function as a result which is Int -> Int or if I pass b = False, I get the show function which is Int -> String?
>>
>>59487467
You need parentheses if doing

sizeof(struct xxx)


but not,

sizeof *temp


which is arguably better design.
>>
>>59487417
In C pointers are implicitly casted from void* to other types, so no, you don't.
>>
>>59487472
Yes.
>>
>>59487472
Yes, exactly.
And it's type safe, and can be checked at compile time.
>>
>>59487487
It's nothing new, you can do all of this in CL
>>
>>59487484
>>59487438
>>59487435
tanks
>>
>>59487417
run your compiler with all warnings enabled (-Wall for gcc and clang).
If there's no warning, your code is fine.
>>
new @ python 2.7 & bad

I want to take a list as an argument. The list is normally 3 items long, but is sometimes 4 items long.

I want to do something with this 4th item if it exists for the list. In order to do that, I need to check if it exists.

However, I can't do

if mylist[3]:


as a list index doesn't have boolean nature I think, I just get an index out of range error when I try the check.

How can I check it?
>>
>>59487506
>checked at compile time
>>
>>59487506
Except for, you know, the dependent types.
You know, the thing you asked about?

It's not just a macro
>>
>>59487511
Just do,

if len(myList) < 4:
do_something(myList)
else:
do_something_else(myList)
>>
>>59487511

you can retrieve the length of the list with
len(mylist)


and check if it's greater than 3
>>
>>59487534
Yes it is. Anything you can do in a compiler, you can also do in a macro.
>>
Begginer to C
What went wrong?
#include <stdio.h>
#define M_PI acos(-1.0)
/* Program that generates a table of an circle radius,area and perimeter. */
main() {
float radius, perimeter, area;
int low, high, step;
low = 0;
high = 20;
step = 1;
radius = low;
printf("Radius\tPerimeter\tArea\n");
while (radius <= high) {
perimeter = M_PI * 2.0 * radius;
area = M_PI * radius * radius;
printf("%dcm\t%3.0d cm\t%8.0d cm^2\n", radius, perimeter,area);
radius = radius + step;
}
}
>>
File: GeorgeZimmer.jpg (36KB, 347x512px) Image search: [Google]
GeorgeZimmer.jpg
36KB, 347x512px
>>59486394

IT Manager here.

I'm neither one way or the other about your 1-5 steps, because the real question is - well, what do you want to be doing?

If I get slapped by my C-Suite one day and they say, "You've got a db project for our client, we've budgeted for a new junior, don't fuck this up..." then I'm going to look for a junior who's got as much db experience or db projects as I can find. Same if it was a sysadmin/MSP shop and the senior left. Same if it was a webdev/Node.js shop and I'm just building it up.

Of course we give a shit about what languages you know. Multiple languages means multiple angles to attack a problem and pad our bottom line on time (I would pay you in blowjobs if I could depend on you to finish on time). But really, am I going to hire the guy who merely "learned" something off Code Academy, or someone whose done projects in the things we do?

What do you want to do, anon?
>>
>>59487592
>main()
Should at the very least be void main()

>acos
You haven't included the appropriate header file
>>
>>59487549
>>59487545

Damn, that was so simple that I regret asking. Thanks.
>>
File: 600px-M40A1_CPD.jpg (36KB, 600x263px) Image search: [Google]
600px-M40A1_CPD.jpg
36KB, 600x263px
>>59487457
Data Structure assignment that keeps track of files and stores information read from the first line.

>Supposed to be a group assignment
>Group for last assignment was 4 other people who all contributed
>My new "group" is just one other person who still hasn't responded to messages I've sent over social media/email to get in touch
>sitting here having panic attacks while I slowly add lines of code to a program that I honestly have no idea on whether or not it's going to work

Seriously, how do I off myself? I am so sick of sucking at everything in life.
>>
>>59487606
What about mid-level guys? Suppose I have 5 years experience in memelang1, but your company is using memelang2, will I get automatically rejected by HR drones?
>>
>>59487610
>You haven't included the appropriate header file
Which one?
>>
>>59487631
post the problem, and we'll do it.
>>
>>59487584
And you can also do it in a turing complete language, so what?
>>
>>59487643
math.h, I think?
>>
>>59487643
math.h
>>
guys I have a question. I want to develop a simple semi-professional looking finite element software, what language/libraries could be good for this? do people still use fortran and is it any better than C++ with regards to speed?
it will need to process quite heavy matrix calculations and printing pictures on the screen.
the only programming language I really know is MATLAB and I've only scratched the surface of C++
>>
>>59487610
He can't include math.h, M_PI will clash with the other M_PI.
>>
>>59487664
He can #undef it.
>>
>>59487511
why 2.7? If you're new learn Python 3, Python 2 is only maintained for legacy reasons
>>
>>59487664
Well the simple thing to do is just remove the existing #define, no need to reinvent the wheel when it's already given in <math.h>
>>
>>59487027
>>59487485
>>59487487
So...
Let's say I have this
class Day {
private integer day;
integer set(integer x) {
if (x >= 1 || x <= 31) {
day = x;
} else {
throw "Incorrect value";
}
}
integer get() { return day; }
}

How could I make this with dependent types?
Sorry my pseudocode, I haven't written OOP for long.
>>
javascript gives me headaches
>>
>>59487694

data Day where
DayConstructor : (x : Integer) -> (x <= 31) -> (x >= 1) -> Day
-- DayConstructor takes
-- >an integer x
-- >a proof x <= 31
-- >a proof x >= 1
>>
>>59487714
What is this language?
>>
>>59487663
Why not use MATLAB? maybe try to use Octave and write the program so it runs in both.
When using Fortran keep in mind probably no software engineer will ever look at it.
>>
>>59487723
Piet
>>
>>59487679
>>59487687
The program looks less cool when you can't find an excuse to use trig.
>>
>>59487723
Idris
>>
>>59487723
PHP
>>
>>59487740
Can I have it in Haskell?
>>
>>59487750
you can have anything you want
>>
>>59487750
LiquidHaskell might be able to do that particular example.
>>
>>59487694
template<typename T>
class Day{
T day;
public:
T set(T x){
if(x >= 1 || x <= 31) {
day = x;
}else{
throw "Incorrect value";
}
}
T get() { return day; }
};
>>
File: 6p2kwil.gif (161KB, 400x286px) Image search: [Google]
6p2kwil.gif
161KB, 400x286px
>>59487634

I work at a mid-sized company, so though we do have HR looking at your stuff, and we do filter for employees who do not meet at least bare-minimum requirements, I ultimately can go down to them and say, "This is the shit I'm looking for, and this is why we need it."

For a corporate job, it's pissing in the wind most of the time.

Still, it's a question of what's in my resume pile, isn't it? If I have 12 Python programmers, and four of them have Lua also, and what I specifically need is a Lua programmer, then fuck me if I just cut eight of them and save me some time. If all of those four suck, only then would I contemplate the other eight.

tl;dr - Either attempt to lie to me on your resume and show me projects you've got in the interview, or go find another job to apply to. Much as it pains me to go through the onboarding, firing you is always an option.
>>
>>59487766
>typical C++/Java/other OOP language user doesn't even understand the problem and thinks it's about generics/templates
Dijkstra was right.
>>
>>59487664
>>59487610
So I added the void and the math.h, deleted the define, but it still doesn't work, shit comes out like this.
Radius  Perimeter       Area
0cm cm cm^2
0cm 1072693248 cm 1610612736 cm^2
0cm 1073741824 cm 1610612736 cm^2
0cm 1074266112 cm -2147483648 cm^2
0cm 1074790400 cm 1610612736 cm^2
0cm 1075052544 cm 536870912 cm^2
0cm 1075314688 cm -2147483648 cm^2
0cm 1075576832 cm -536870912 cm^2
0cm 1075838976 cm 1610612736 cm^2
0cm 1075970048 cm -1073741824 cm^2
0cm 1076101120 cm 536870912 cm^2
0cm 1076232192 cm -1073741824 cm^2
0cm 1076363264 cm -2147483648 cm^2
0cm 1076494336 cm 1073741824 cm^2
0cm 1076625408 cm -536870912 cm^2
0cm 1076756480 cm -1610612736 cm^2
0cm 1076887552 cm 1610612736 cm^2
0cm 1076953088 cm cm^2
0cm 1077018624 cm -1073741824 cm^2
0cm 1077084160 cm -2147483648 cm^2
0cm 1077149696 cm 536870912 cm^2
>>
>>59487777
*sniff*
>>
>>59487795
Looks like an overflow
>>
>>59487795
Looks like integer overflow to me, anon
>>
>>59487750
almost with a bajillion extensions

in like 2 or 3 years we might have it properly
>>
>>59487795
forgot to add, this stopped working after I made the variables float, I was using int before
>>
>>59487794
> typical Haskell/other irrelevant language user that hasn't yet experienced the true power of templates and mentions them together with generics
>>
>>59487777
Would you really discard someone with, say, 5 years of experience at a top company, just because they haven't used your exact meme stack, in favor of someone with 2 years of mediocre experience? The first guy can probably pick up your stack in a couple of weeks.
>>
>>59487795
You're using %d to print floats.
>>
>>59487766
>templating
I don't even have non-integer days.
>>
>>59487592
You're using %d to print floats, use %f instead.
>>
>>59487795
#include <stdio.h>
#include <math.h>
// M_PI IS ALREADY DEFINED IN THE LIBRARY FAGGOT
int main() {
float radius, perimeter, area;
int low = 0;
int high = 20;
int step = 1;
radius = low;
printf("Radius\tPerimeter\tArea\n");
while (radius <= high) {
perimeter = M_PI * 2.0 * radius;
area = M_PI * radius * radius;
printf("%fcm\t%3.0f cm\t%8.0f cm^2\n", radius, perimeter,area);
radius += step;
}
return 0;
}
>>
>>59487763
French fries and small cola
>>
>>59487860
$4.90 please
>>
>>59487831
He mentioned them together because in that example you are using a template to construct a generic type and are not doing anything that templates do that generic types are not about.
>>
>>59487831
>C++ troglodyte thinks his language's template system being Turing-complete makes it useful
>>
>>59487834
> only considering those programmers for job interview that used exact meme stack that company wants to use

that's because these interviewers have a bachelors degree in economics and don't know shit about tech and how many meme stacks there are
>>
>>59487724
I have considered that, but I really have a hard time imagining an engineering firm purchasing software you need octave to use, ontop of that, matlab and octave are quite process heavy.
>>
File: Screenshot_10.png (20KB, 952x470px) Image search: [Google]
Screenshot_10.png
20KB, 952x470px
>>59487847
>>59487839
So I changed it and.
haha what the fuck
>>
>>59486363
How do I start working on pthreads in C.
This documentation here is quite esoteric It would take a while to understand things.

https://computing.llnl.gov/tutorials/pthreads/#Abstract
>>
>>59487888
see >>59487849
>>
>>59487892
Just upgrade to C++ and use std::thread instead.
>>
>>59487901
Just upgrade to Haskell and use forkIO instead.
>>
File: 1489965907794.png (388KB, 934x1000px) Image search: [Google]
1489965907794.png
388KB, 934x1000px
>>59487892
Some people, when confronted with a problem, think, 'I know, I'll use threads' - and then two they hav erpoblesms.
>>
File: 5UC6h2D.png (464KB, 797x540px) Image search: [Google]
5UC6h2D.png
464KB, 797x540px
>>59487834

Not always. Remember: I'm playing a game of odds in the hiring scheme. How am I to know that the first guy can pick up what we need in a few weeks? Has he worked with the libraries we use? What about internal docs and plans he'll need to get caught up on? Can he demonstrate proficiency in an interview? Can he go beyond proficiency? (We hate whiteboarding, we'd rather see work you've already done and then grill you on it with the code in front of us)

I'm trying to minimize risk. Onboarding is a painful, time-consuming, and sometimes expensive process. I can't always go back to my superiors and say, "Well we couldn't hire this round, maybe next round." Sometimes shit needs done. Sometimes we contract work because we're cutting it too close. Sometimes we need to up our budget and I have to fight for that.

And besides: if you're from a top company, you'll have work to show me anyway. I hope.
>>
>>59487909
Just upgrade to 4chan and realise the meaninglessness of programming
>>
>It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure.
>Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter.
t. Nathaniel Borenstein

what did he mean by this?
>>
>>59487920
>And besides: if you're from a top company, you'll have work to show me anyway. I hope.
Not always. Outside California, a lot of companies have clauses in their contracts that say they own all code their employees write, even code written in their own free time at home.
>>
>>59487943
(((Borenstein)))
>>
>>59487943
He meant that Bagdad isn't the only city where terrorists hide
>>
>>59487943
Imagine if someone made a gun that shoots children, rather than just making a gun.
>>
>>59487952
>even code written in their own free time at home.
Lol no
>>
How do i price a job that i never done and dont know how much it goes for in real life?

Have to write a simple program for microcontrollers, i have the equipment and some experience with the architecture. The programming part could be done in a day if im lucky. Then burn 100 devices with the program.
>>
imagine programming a gun
>>
>>59487901
> std::thread
this

look at std::thread and std::future.
Wonderful indeed.
>>
>>59487976
i am so /k/
i look at programs and see guns
>>
>>59487963
Sadly yes.
>>
Template *t = new Template
>>
>>59487975
>The programming part could be done in a day if im lucky.
Then charge for two weeks work and spend the rest of your time browsing 4chan.
>>
>>59487952
>even code written in their own free time at home.
That can't be legal, right? I'm sure you could successfully sue an employer if they tried to pull this shit.
>>
>>59488001
but how much?
>>
How do I declare a pointer to the stack?
>>
File: 123123.png (8KB, 641x675px) Image search: [Google]
123123.png
8KB, 641x675px
Saying that Java is nice because it works on every OS is like saying that anal sex is nice because it works on every gender.
>>
>>59488013
Depends on the laws where you live. Some places it's illegal, some places it isn't.
>>
>>59487993
Don't use new.
Use make_unique or make_shared if you need a pointer and a value type if you don't.
>>
>>59488018
There is no difference between a pointer that points to the stack and a pointer that points anywhere else.
>>
>>59488017
about 300k
>>
>>59488022
a fair comparison tho
>>
>>59488018
int a = 0;
int *ptr = &a;
>>
>>59487714
Do Haskel programmers avoid most medicines because they have side-effects?
>>
>>59488025
Jokes on them, all my code is unreadable Lisp.
>>
>>59488017
Find a college student and pay him 200-500$.
>>
File: tmp_6194-14869421696111623371754.jpg (193KB, 1300x1244px) Image search: [Google]
tmp_6194-14869421696111623371754.jpg
193KB, 1300x1244px
How do I make a login program which uses your voice as a login?
>>
>>59488056
Install Haskell and then include the voice Monad
>>
>>59488048
That's Idris code
>>
>>59488036
what currency?
>>
Nice
import std.stdio, std.math;

void main()
{
writeln("Radius\tPerimiter\tArea");
for(int r = 1; r < 20; r++)
{
writefln("%scm\t%scm\t%scm2", r, 2*PI*r, PI*r*r^^2);
}
}
>>
>>59488056
Learn NLP.
>>
_stack* stackPtr = &__stack
>>
>>59488034
Strictly speaking, that's not true. It's undefined behaviour to do pointer arithmetic or comparisons on pointers to two different allocations. This is to allow e.g. an architecture with segmented memory to have different representations for pointers to different areas of memory.
>>
>>59488055
shit.
i was planning to charge that amount
>>
>>59488056
https://pypi.python.org/pypi/SpeechRecognition/
>>
>>59488081
That's irrelevant. The C abstract machine has no concept of segregated memory.
The compiler may decide to implement them differently, but from a syntactic/semantic standpoint, they're completely identical.
>>
>>59488072
now implement power series of sin cos tan and arctan
>>
>>59488115
Saying that there is "no difference" might give someone the wrong idea and prompt them to do things that lead to UB. Rather, there is no well-defined way to discern a difference in the first place.
>>
>>59488128
>https://en.wikibooks.org/wiki/Trigonometry/Power_Series_for_Cosine_and_Sine
not all that different
>>
>>59487849
(By POSIX)
>>
>>59488168
the fuck you called me?
>>
>>59488072
What the fuck is the deal with the colour of your text?
That looks atrocious.
>>
I fell for the Idris meme and I swear to god it's the dumbest thing ever.
>want to do simple arithmetic to see how it outputs types
>takes more than 1 second to compute
Idris> 4*1026-1+5
4108 : Nat
>>
File: 021.png (29KB, 416x617px) Image search: [Google]
021.png
29KB, 416x617px
>>59486363
Patching a few bugs and making finishing touches to my bot before its 0.2.1 release (hopefully) later this month. The main addition was simplified syntax for single-word responses to logical statements/inquiries, in the hopes of facilitating attempts at unstructured exchanges in the future.

It's overdue for significant restructuring and simplification because it's a nightmare to maintain or write tests for and it's probably not efficient or robust enough for the kinds of theoretical buildouts I'd like to attempt in the future, let alone heavy usage with a persistent knowledge base.

Thankfully the most hellish modules to debug are pretty stable, but I can't count on that to be the case forever.
>>
>>59488185
>takes more than 1 second to compute
can you solve 3*6562-1+5 in less than a second?
>>
File: 1455650759908.png (20KB, 747x877px) Image search: [Google]
1455650759908.png
20KB, 747x877px
>>59487952
>>59488013

My personal advice is, if you work for a company like that, you are in the wrong company. And if you must work for a company like that, for whatever reason, I would learn how to properly shut the fuck up and hide what it is you do at home.

We do not exercise such non-compete/at-work clauses in my area here, so I'll admit to being a bit out of bounds.

Still, it's simple to grill someone on what they do and do not know. There's nothing legally against you saying you've worked on X project with Y framework or Z design patterns (after all, it might be on your resume). And there's nothing against me reading up on it, grilling you on the top level, and then my team and I drilling as deep as we can to see what you do and do not understand.
>>
Most people procrastinate on writing blog posts by writing a blogging platform... I built a general purpose zine based operating system whimsy.space, then built a blogging platform on top of that
>>
Beginning my first foray into learning Fortran. Anyone got any good resources?
>>
File: scrot.png (77KB, 942x666px) Image search: [Google]
scrot.png
77KB, 942x666px
>>59488276
nice daniel
but that's just javascript?
>>
>>59488185
CL-USER> (time (+ (- (* 4 1026) 1) 5))
Evaluation took:
0.000 seconds of real time
0.000000 seconds of total run time (0.000000 user, 0.000000 system)
100.00% CPU
1,776 processor cycles
0 bytes consed

4108
>>
>>59488294
http://www.fortrantutorial.com/documents/IntroductionToFTN95.pdf
>>
>>59488341
Danke, anon-san
>>
>>59488185
Idris tries to be a proof assistant too much, I think, and misses the mark a bit when it comes to being a good programming language. Nat is implemented as a recursive data structure even though, in practice, an unsigned integer is good enough. Values of Nat are going to exhaust memory before they overflow a machine word. Even then, it would be much more clever to implement Nat like GMP if you really wanted it to act unbounded.
>>
>>59488185
>Nat
there's your problem
>>
>>59488331

JavaScript and so much more...

Computation is life

To write a pure function you must first purify your soul
>>
>program with debug messages
>gcc -O3 -flto
>works fine
>remove debug messages
>program stops working
>>
>>59487943
Because what if Pyongyang or Beijing started launching missiles at you and you couldn't retaliate because your missile control software wasn't flexible enough?
>>
>>59488402
kys
>>
>>59487956
Somehow I knew you were going to say that.

>>59487992
What if you release it into the public domain and there's nothing indicating that you were involved in its creation?
>>
>>59488357
Also, it calls itself a systems programming language despite being garbage collected and having no capability to do manual memory management.
>>
>>59488464
If I did that, how could I claim to be the author when applying for a job?
>>
>>59486394
go for javascript and webdev
>>
adalisp or btfo
>>
>>59488447

Instructions unclear... was reborn to eternal life
>>
C++ is a broken language
C is outright garbage timesink
>>
>>59488615
What did he mean by this?
>>
>>59488080
Identifiers beginning with an underscore are reserved for use by the implementation.
>>
>>59488219
Is anon a computer?
>>
>A commit that I have been working on for the past 4 hours compiles and runs with no issues

This has to be a ruse right?
>>
>>59488474
You couldn't. What I would do is this:
>ask the employer to clarify the terms of the contract, specifically whether your intellectual property created off the job during the time of your employment is owned by them.
>if they say they're entitled to intellectual property created off the job, either quit or keep all your personal programming a secret
>if they say they don't own intellectual property you create while off the job, make them put it in writing so you can take them to court over it if they go back on their word
>>
>>59488734
C is fine as a portable assembler.

>>59488914
90% of your source code is commented out.
>>
Programming languages were a mistake.
>>
>>59488969
Oh I have no doubt I will run into issues once it is integrated into the source code. It is just surprising that there is no internal error yet.
>>
What do you think of pascal?
>>
>>59489003
Trash. Use Lisp.
>>
>>59489003
Trash. Use COBOL.
>>
>>59489003
A worse Ada
>>
>>59488868
For C, it's actually an underscore followed by either another underscore or a capital letter.
_stack is fine.
__stack or _Stack is not.
>>
I'm a bit of a category theoretic newb.

> tl;dr multidimensional (kD, not 2D) comonadic CA's in haskell: how do?

How would you define somethings like an n dimensional Cellular Automota in haskell?

I know given a Universe like
data U x = U [x] x [x]


you can make any dimension of CA
just apply U d times.
so a 2d CA would be something like
data Plane a = Plane (U (U a))


I also understand that a CA is comonadic and can be windowed for neighborhoods and rules easily.
But how do I get something where given a underlying type and a number of dimensions (axis), I can create a CA with that many dimensions and be able to act on each axis independently?
>>
>>59489108
Just include the cellular automata Monad.
>>
File: lana3_gli.jpg (181KB, 512x512px) Image search: [Google]
lana3_gli.jpg
181KB, 512x512px
I wrote a pixel sorter
>>
>>59487811
>>59487810
True C experience
>>
File: 1453306116180.png (58KB, 313x196px) Image search: [Google]
1453306116180.png
58KB, 313x196px
>>59489280
>Integer overflow doesn't exist in other languages
>>
>>59489108
What about free?

Free f a = a | f (Free (f a))

Otherwise, you could write a type family

type family X n f a where
X 0 f a = a
X n f a = f (X (n - 1) f a)
>>
>>59488981
What, you want to program in machine code? There's an emulator here that lets you try it, just like 1960s programmers, entering everything in through switches on the front panel:

http://www.s2js.com/altair/sim.html

Just try putting in a fizzbuzz program and you'll soon be thankful for C's buffer overflows and Java's slowness and bloat. There's a reason why programming languages were one of the first things people created after inventing computers. Even a naive and slow Fortran compiler was a vast improvement over the error prone process of entering obscure opcodes in binary.

>>59489003
Lacks a use case where it really excels. Its original niche was as an imperative language for teaching that made use of structured programming (which the standard teaching language of the time, BASIC, did not). C followed a few years after and basically ruined Pascal's chances of becoming a serious systems programming language, and nowadays virtually all mainstream imperative languages use C syntax, so modern Pascal not only lacks a real specialty, but is also at the disadvantage of requiring people to learn a new syntax. Pascal did pioneer the use of bytecode as an output format, but that's such a common feature these days that it's not really a reason to use Pascal itself when more modern languages do the same.

>>59489075
_stack is still a reserved identifier in the file scope namespace. You can only use it as a variable, typedef, or enum constant within a struct definition or a function. So it's not 100% illegal, but it's probably better to just avoid such identifiers on principle, since that's easier than having to remember the specific cases of where it's legal.
>>
>>59489304
Also, _stack is legal as a goto label, struct/union/enum tags, or struct/enum member, but again the overall point still holds; the benefit of using such identifiers doesn't override the possible risk of name collision, so it's better to just avoid them in general.
>>
>>59489298
sweet. just what I was looking for. I'm not good with haskell, yet.
>>
>>59489304
>_stack is still a reserved identifier in the file scope namespace
Where on earth does it say that?
I know for certain that ISO does not reserve that. I don't think POSIX does either.
>>
>>59489347
>2. All identifiers beginning with an underscore are reserved for ordinary identifiers (functions, variables, typedefs, enumeration constants) with file scope.

from http://c-faq.com/decl/namespace.html
>>
>>59489344
I don't know if this gives you what you want:

instance Comonad f => Comonad (Free f) where
extract (Pure x) = x
extract (Free f) = extract (extract f)
duplicate = return
>>
>>59489396
Wow, I'm surprised I did not know that.
You were right.
>>
>>59489433
I didn't know it off the top of my head either, I just looked it up. I just know the general principle is to avoid leading underscores in identifiers, because even if there are cases where it's "technically legal", there's not any particular advantage to it; even if you want to use it to distinguish variables from class members in C++ for example, it's much easier to verbally tell apart "data" and "m_data" as opposed to "data" and "_data".
>>
>>59489463
I normally use them to mean "implementation information" or "unimportant".
For example, a wrapper over a recursive function that sets the arguments
static int _fn(int arg1)
{
// Does an actual recursive call
}

int fn(void)
{
return _fn(10);
}

(I know this could be done as a macro, but usually it's more complicated than this)
I guess this is not totally conforming then.
>>
In your opinion what is the best GUI framework? Python compatibility preferred.
>>
>>59489537
They're all garbage.
>>
>>59489537
Haskell's GUI Monad
>>
i wanna take everything
and just put it all in one big STRUCT
>>
File: 1489981820968.png (1MB, 1440x2048px) Image search: [Google]
1489981820968.png
1MB, 1440x2048px
How does /dpt/ do it?
>>
>>59489659
if (conditional)
{

}
>>
>>59489659
(if conditional)
>>
>>59489537
HTML/CSS/JS. With electron, if you're targeting the desktop.
>>
>>59489659
if                                       (
a < 20 ){
printf (
"a is less than 20\n" );}
else {
printf (
"a is greater than or equal to 20\n" );}

The only correct way. Also, indentations must be a prime number of spaces, which is not 2.
>>
>>59489659
if (conditional)
{
}
>>
>>59489659
Depends on the language and the style guides
>>
>>59489726
Disgusting.
>>
>>59489726
lines 3 and 6 have 6 spaces of indentation, which is not prime.
>>
>>59489750
You're right. I fucked my own example up.
>>
>>59489779
What posts?
>>
File: 1489981307031.png (2MB, 1244x690px) Image search: [Google]
1489981307031.png
2MB, 1244x690px
talk shit about Java now bitch
>>
>>59489779
I have been using Haskell for awhile now, and this is what I have found wrong with the language:
>horrid macro system
>modules are deficient compared to the module system of OCaml or the package system of Common Lisp
>partial functions pervade the language
>broken records (ugly hacks are needed to get around their deficiencies, leading to overengineered libraries like lens)
>most libraries are in alpha and look like a college student's summer project
>library authors tend to pepper their libraries with ugly, meaningless, custom operators, contributing to the overall ugliness of the ecosystem
>String as [Char]
>easily subverted type system with unsafe functions
>laziness makes it a chore even for experienced programmers to reason about algorithmic complexity
>in 30 years of existence, Haskell has yet to become a proven asset in industry
>>
>>59489659
The first one is far better, because it uses vertical space more efficiently, and also looks better with editors that can collapse code.

>>59489726
Absolute meme tier.

>>59489730
That was GNU quality!
>>
>>59489800
Nice copypasta
>>
>>59489659
if( conditional ) {

}

ALWAYS braces even for single statement. This is the only way.
>>
>>59489804
Nice shitpost. Retard.
>>
>>59489659
if (conditional) {
{
// code goes here
}
}
>>
>>59489659
(((if))) (((conditional)))
>>
Not gonna lie, former Java programmer here. This is fucking hilarious not pooing in the loo. But in all seriousness we can't let these streets get designated.
>>
>>59489992
Too late, it is already designated. Thanks H1B1
>>
>>59489992
Quickest way to out yourself as a pajeet.
>>
>>59489992
>t. literal Rajesh
>>
>>59489659
I do Linux style but with 4 space indent instead of 8.
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>59490027
>4 space indent instead of 8
Why on earth would you do this?
>>
>dynamically sized data structures
Why would I ever want to fuck up my cache, /g/?
>>
>>59490092
>not using a dependent language and keeping the size of a dynamic list static, provably so at compile time
>>
>>59490092
Don't use them then, fag.
>>
How to tail recursion in Haskell?
>>
>>59490130
f = let f in f
>>
>>59487511
Don't check for it, just handle the IndexError
>>
>>59490130
Haskell is lazy, so it creates heap thunks anyway
If you use {-# LANGUAGE Strict #-} or bangpatterns or strictdata you can change this, but tail recursion is the same as any other lang
>>
>>59490108
>using a dependent language and dying of old age before any non-trivial project finally builds
>>
New to C++ and bad at it.

Trying to read in data from a .txt file that looks like this:
15
Last,First 9 3 7 5 8 0 0
Last,First 2 3 8 3 6 3 5
Last,First 8 8 3 0 8 2 0
Last,First 9 10 4 7 0 0 0
Last,First 5 6 5 6 5 6 5
Last,First 7 3 8 7 2 5 7
Last,First 2 5 3 0 4 9 4
Last,First 2 3 8 3 6 3 5
Last,First 8 8 3 0 8 2 0
Last,First 9 10 4 7 0 0 0
Last,First 5 6 5 6 5 6 5
Last,First 7 3 8 7 2 5 7
Last,First 10 10 0 10 12 0 0
Last,First 0 4 0 8 4 0 2
Last,First 1 6 2 0 0 1 0


I read in the first number, the count.

ifstream fin;
int count;
fin.open(file);
fin >> count;


I need to read the rest of the data into a vector of dynamically allocated structs.
I have my struct definition above main():
struct Record {
string name;
vector<int> values;
int totalValue;
};

where
vector<int> values
always needs to be size 7, and totalValue is the sum of the values in vector<int> values

I have a read function, I pass in the file input stream, a vector of my structs, a vector of pointers to structs, an int to hold values from the file, and the count.
void readData(ifstream& fin, vector<Record> vec, vector<Record*> var, int val, int ct)
{

for (int i = 0; i < ct; i++)
{
var[i] = new Record;
fin >> var[i]->name;
var[i]->totalValue = 0; // initialize value total
var[i]->values.resize(7); // initialize values vector
for (int j = 0; (fin >> val) && (j < 7); j++)
{
var[i]->values[j] = val;
var[i]->totalValue += val;
}
fin.clear(); // clear input stream and move to next line
}
}

This is where I'm fucking up.
Every time I take a line from the file, I need to create a new Record in dynamic memory, read the data into the Record, and add it to the vector. I have no idea how the fuck to go about this. My low-IQ cuck brain is killing me here.
>>
What is /g/'s opinion on groovy? Is it worth learning?
>>
>>59490033
>indent takes 10% of your line width
That's just nutty.
A simple nested conditional loop has you write your entire inner loop using only 70% of your line width. It's a pain in the ass.

I imagine that this might have been a way to discourage deep nesting. But there's plenty of situations where deep nesting is the best approach.
>just put your inner loop contents in functions
That's dumb. Makes code much harder to read.
>>
What do you guys think of syntactic salt?
>>
>>59490287
https://github.com/groovy/groovy-core/blob/master/src/main/org/codehaus/groovy/runtime/ArrayUtil.java
>>
>>59490287
Anon if you're the kind of person that likes to learn new languages and be hip then I suspect you doing your own analysis of if it's worth will be far more productive than asking /dpt/.
/dpt/ by and large are very conservative.
>>
>>59490269
Look up the documentation for vector.
>>
>tfw installing racket on linux from the installer on the website
what the fuck why can't more software be like this
>>
>>59490310
Wouldn't be needed if the language was properly designed.
>>
File: 1486514181162.jpg (347KB, 487x536px) Image search: [Google]
1486514181162.jpg
347KB, 487x536px
>>59490313
Christ almighty
>>59490318
I was just curious, I had it installed on my machine, when I was trying different languages for programming theory last semester.
>>
File: 1484540067343.jpg (55KB, 640x480px) Image search: [Google]
1484540067343.jpg
55KB, 640x480px
>>59490287
My impression is not really. It's pretty niche, and there's newer, trendier stuff in the same niche. Just git gud with Java desu. Groovy is the kind of thing you pick up for a specific job or pick up because it sounds fun. If you have to ask if it's worth learning, then in this case, it's probably not.
>>
>>59490330
>mixing brackets and parentheses
>>
>>59490269
>I need to create a new record in dynamic memory
That's
var.push_back(new Record);


I recommend you read documentation for the parts of the standard library you use.
>>
File: 6ose7ar3g9ly.jpg (1MB, 2091x2788px) Image search: [Google]
6ose7ar3g9ly.jpg
1MB, 2091x2788px
>see people talking about rust on reddit
>decide to check the language out
>it's not finished yet

wtf why do people even care about it
>>
>>59490313
>* This is a generated class used internally during the writing of bytecode within the CallSiteWriter logic.
>* This is not a class exposed to users, as is the case with almost all classes in the org.codehaus.groovy packages.
They even predicted you'd be asses like this.
>>
>>59490366
gotta be on the hypetrain for hipster cred.
>>
>>59490357
that's optional
>>
>>59490383
>I have to read bad code
Nothing is optional in programming. This is why C++ sucks.
>>
File: 1485557706957.png (102KB, 828x801px) Image search: [Google]
1485557706957.png
102KB, 828x801px
>>59490313
But why
>>
>>59490366
>reddit
You have to go back.
>>
>>59490393
What's wrong with this code?
>>
>>59490366
>ruSJWt
>on reddit

this comedy truly writes itself
>>
>>59490393
Is this an attempt at writing without functions or control flow other than if?
>>
>>59490413
>without functions
Utility functions.
>>
>>59490413
I'm not sure, but my mom gets paid to program in PHP like this.

She only learned how to use functions when I sold them to her as being like copy/paste but you can fix everything at once if you fuck up.

Classes will never happen.
>>
>>59490451
>women programmers

Also how did she get her job?
>>
public static final const constant constexpr literal fixed permanent immutable solid invulnerable Boolean killAllNiggers() = true;
>>
>>59490503
in Haskell this is just

killAllNiggers = True
>>
>>59490524
in Idris this is just
a veritable monad Kill, whence
NiggerConstructor:: (n Boolean whom) <>% (n **&&^^ j9 g8 k2 a9 (()))) KillAll {[(}
Kill__Constructor tolerates accepted
~~~~~~~~ one Nigger n
~~~~~~~proof of the Riemann Hypothesis
~~~~~~~~~~Infinite Jest
end scene Kill, exit stage left
>>
new
>>59490616
Thread posts: 315
Thread images: 28


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.