[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Daily Programming Thread /dpt/
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 25
File: Haskell.png (4 KB, 128x87) Image search: [Google]
Haskell.png
4 KB, 128x87
Old thread: >>51936223

Talk about what you're working on, or the homework you are doing, or funny memes like average two ints or grad student code
>>
List all of the projects you have started and given up on.
>>
First for there is absolutely nothing wrong with singly-linked stack implementations.
void stack_push(stack_t *stk, int data)
{
frame_t *frame = (frame_t *) malloc(sizeof(frame_t));
frame->data = data;
frame->next = stk->head;
stk->head = frame;
stk->size += 1;
}

int stack_pop(stack_t *stk)
{
if (stk->head == NULL)
printf("Stack empty.\n");
int data = stk->head->data;
frame_t *frame = stk->head;
stk->head = stk->head->next;
stk->size -= 1;
free(frame);
return data;
}
>>
>>51942701
void stack_push(stack_t *stk, int data) {
stk->array[stk->size++] = data;
}

int stack_pop(stack_t *stk) {
return stk->array[stk->size--];
}

retard
>>
>>51942697
Tenco clone for tracking Hisoutensoku stats (Basic functionality is there)
Net mahjong game (Game logic not done, some things like matching hands are implemented)
A shmup (I was writing it primarily to mess with a particular FRP library, and I kept getting time leaks)
NEAT library for Haskell (Not really given up on, but I haven't bothered adding features since last summer)
Mod for Minetest
>>
>>51942697

- A C preprocessor that adds foreach, ranges, etc
- A simple simulator that has a field with creatures in it that when they reach a food, their tail grows, and their tail slowly shrinks over time, if it hits 0, it dies
- A 2D gravity simulator that shows masses as they move around, and you can add them via a right-click menu (everything but adding them/the menu was done though)
>>
>>51942729
These are all projects I could see myself reviving at some point, though, except the shmup (I wouldn't write it with the same library)
>>
>>51942697
Program for my microcontroller that could manage my sex slave dungeon.

Turns out one already existed.
>>
>>51942716
void stack_push(stack_t *stk, int data) {
stk->array[stk->size++] = data;
if (stk->size == stk->alloced) {
stk->array = realloc(stk->array, (stk->size / 2 + stk->size) * sizeof(data));
}
}

fixed
>>
>>51942766
also update stk->alloced

I shouldn't code inside of the reply window, I forget stupid shit.
>>
>>51942697
A File Synchronizer server/client.
A Pictionary server/client.
A kernel/toy os.
A platform game mini engine with libgdx.
A clone of Battle City, too much sprites to cut.
>>
>>51942697
I've given up on everything. None of my programs are meaningful or memorable in any way. I should give up programming.
>>
>>51942716
>>51942766
Shouldn't that also be something for checking whether you're at the bottom of the stack or not?
>>
>>51942853
y e p
>>
>>51942766
Now write a tree backed by a memory pool, when the pool grows regenerate the tree.
>>
File: ss+(2015-12-19+at+02.43.30).png (48 KB, 740x521) Image search: [Google]
ss+(2015-12-19+at+02.43.30).png
48 KB, 740x521
>>51942697
A text editor in python.
Basic functionality is there but I can't figure out how the fuck to implement "save as" and "open". That's literally all I need, and I couldn't figure it out.
>>
File: linkedlist.png (81 KB, 1219x1301) Image search: [Google]
linkedlist.png
81 KB, 1219x1301
>>51942701
>linked list implementation runs 600% slower
>when built with optimizations, the linked list runs 1000% slower.

You're right, there is absolutely nothing wrong.
>>
>>51942885
https://raw.githubusercontent.com/someoneigna/python-projects/master/nexted/file.py

Perhaps that could help you.
>>
Why the fuck is the front end such a cluster fuck?

"JavaScript is a bit shitty, let's use Typescript"
"All JavaScript should run through a linting tool because the compiler is shit"
"The normal linting tool doesn't support Typescript so forget I said that"
"BTW we're using react, and the Typescript/React integration is from February, which means it's abandonware and there's no replacement tool"
"ES6 is awesome"
"Browsers don't run ES6, so there's a transpiler you need to use"

Ugh.. it's hell.
>>
>>51942924
>dpt
>front end
lol

>javascript in the first place
>>
>>51942924
Compile haskell to javascript

Every visitor to your page will have a piece of haskell delivered to them, in the form of run time system
>>
>>51942910

> not checking malloc() return value
>>
>>51942943
Malloc has never failed in the history of Windows.
>>
>>51942940
>piece of haskell delivered to them
great
>>
>>51942885
How are you storing the text? I'm trying to make a text editor myself and was interested in how others would do it.
>>
>>51942955
An array. No seriously, array traversals are incredibly fast, and the fastest solution for files <5MB. If your user absolutely must open enormous files, then you'd want some kind of rope data structure chaining 5MB arrays together.
>>
>>51942955
doubly linked list for every char in the file
>>
>>51942990
le plenty of memory in modern computers ;-^)
>>
File: 1428353052866.jpg (282 KB, 1000x1000) Image search: [Google]
1428353052866.jpg
282 KB, 1000x1000
>>51942990
>>
>>51942951
If you are out of memory, you can kind of expect your program to crash anyways. It'll probably segfault somewhere down the line anyways
>>
>>51942943
mem = malloc(...);
if(!mem) {
// what goes here?
}

Your move.
>>
>>51943017
if malloc returns a NULL value, you tell the user you're OUT OF MEMORY and promptly crash the program.
>>
>>51942943
>Oh dear, memory allocation failed
>segmentation fault

vs

>segmentation fault
>>
>>51943040
>why is my program segfaulting

vs

>why is my operating system out of memory
>>
>>51942924
Lodash and chill
>>
>>51943047
Modern OSes don't run out of memory. Virtual memory exists for a reason.
>>
>>51943047
In the extremely rare occurrence of running out of memory, I think you'd be able to tell.

Maybe if your program is trying to allocate multiple gigabytes all at once, you should make the check (or just you know, not do that?)
>>
>>51943069
My system has no swap and everything locks up when I run out of memory :^).
>>
>>51943078
get a better computer
>>
>>51943092
no
>>
>>51943092
>program is shit
>solution is get better pc
spoken like true webdev
>>
>>51943092
I don't feel like swapping out 4x 4 GB RAM sticks in favor of configuration like 4x 8 GB, I rarely hit the 16G limit, so that's unnecessary expense.
>>
I'm totally clueless about programming besides learning java in high school and not even getting high grades.

Are there any charts or infographs /g/ made about getting into it?
>>
>>51942701

http://pastebin.com/Ff6JRq9e

I made a benchmark of stacks implemented using singly-linked lists vs vectors. Making 5 trials, these are the times I got each time:

Linked List: 126 ms.
Vector: 4 ms.

Linked List: 130 ms.
Vector: 4 ms.

Linked List: 124 ms.
Vector: 5 ms.

Linked List: 115 ms.
Vector: 4 ms.

Linked List: 121 ms.
Vector: 3 ms.

This is an average of 123.2 milliseconds for the linked list implementation, and an average of 4 milliseconds for the vector implementation, making linked lists 30.8 times slower here.

The implementation was run on Windows 10 64-bit with a Haswell Core i5, but you are all free to test it yourself. I used GCC 5.1.0 with -O3 for my optimizations.

And of course the obligatory questions I'm about to get asked:

>Why C++ and not C?
std::chrono
>Why are you using malloc in C++
realloc not safe with new/delete, want to use same allocator for linked list and vector
>>
>>51943078
I run ubuntu and this happens to me when I use firefox
(doesn't happen on my Arch machine)
>>
>>51943116
>charts or infographs
Just leave.

On another note:
C Primer Plus by Stephen Prata
>>
>>51943121
I run Arch and yeah it happens anyway, I usually have to spam ctrl-alt-f2 to switch a tty, then wait 5 minutes to get a prompt, then kill xorg and start it again.
>>
>>51943120
>25x speed
Damn...
Do you think allocating larger data per node would cause a difference?
>>
>>51943120
>http://pastebin.com/Ff6JRq9e
Could you retards stop?
You have to make a memory pool to make the linked list perform almost on par. Of course assigning memory for each node is slow. This is not Java/C#, there you get memory from a memory pool.
>>
>>51943120
Can we get a cycle count? Execution time is pretty irrelevant.
>>
>>51943131
I'm from the old thread, I had C programming: A modern approach recommended to me, would C primer plus be a better book to read through?
>>
>>51943120
Now implement std::allocator alternative for the linked list and see the times drop. I swear Ruby you dumb shit stop posting, I wish I copied my FF profile over here so my filter list persisted, instead I have to put up with your bullshit again.
>>
>>51943078
>>51943121
>>51943138
shouldn't watchdog kill firefox before it can lock the system?
>>
>>51942961
Wouldn't insertion at the start of a file be slow? And how do you handle cursor movements between lines?
>>
>>51943131
>C Primer Plus by Stephen Prata
Should I start from this or python?
>>
>>51943175
It kills Firefox but only a while after the system lockup unfortunately so it's still faster to wait a few minutes to switch the tty and login than for FF to get killed.
>>
>>51943173
Just read the fucking book nigger
>>
>>51943188
No, insertion isn't slow at all. Like I said, it actually outperforms more convoluted data structures in most cases.

The typical text file is, what, a couple hundred KB? When you need to insert something at the start, you just make a new array, store whatever character the user typed at arr[0], then copy the rest of the array over after that. Processors can iterate over like 5 billion bytes a second or something.
>>
>>51943197
>linux
pfft
>>
>>51942990
is this how text editors in general are actually implemented? because it seems like it would get very messy if you did it any other way. like with files you just rewrite the whole damn file and a linked list is pretty much how you would avoid rewriting the whole text document all the time.
>>
>>51943241
Monolithic arrays are the best for "normal" datasets. This has been known for a decade+.
>>
>>51943241
http://www.cs.unm.edu/~crowley/papers/sds/sds.html
>>
>>51943150
If you can reduce the number of memory allocations, you would assuredly gain better performance.

>>51943159
>>51943174
>memory pools
>custom allocators
If I want to show to someone that their method of implementing stacks is shitty, is it not best to do so with their own stack implementation (albeit without the memory leaks)? If you guys want to show off some better performance results, feel free to add some more tests to the code. You have my full permission to edit/redistribute the benchmark code and so on (we'll say it's MIT licensed, knock yourself out).

>>51943160
Blarg, is there any easy way of doing that in-application?
>>
>>51943252
so every time i type a character at the start of the document it copies the whole thing below it one step down the array? it does make sense since computers are much faster than a human can type
>>
>>51943270
You can use __rdtsc() on Windows.
>>
>>51943241
I think emacs uses ropes. There's a page for ropes on wikipedia, and there's a paper named "Ropes: an Alternative to Strings" that introduces ropes.

https://en.wikipedia.org/wiki/Rope_%28data_structure%29
http://citeseer.ist.psu.edu/viewdoc/download?doi=10.1.1.14.9450&rep=rep1&type=pdf
>>
>>51943265
very interesting, thanks

http://www.cs.unm.edu/~crowley/papers/sds/node23.html#SECTION00091000000000000000
>REDO: be more positive about the gap method.
kek
>>
File: mot.png (738 KB, 800x942) Image search: [Google]
mot.png
738 KB, 800x942
Function block for controlling a three-phase induction motor
>>
>>51943287
Actually emacs uses gap method rather than ropes.
>>
>>51943280

http://pastebin.com/qXQ0YrNt

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> g++ --std=c++14 -Wall -Werror -O3 benchmark.cpp

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> a
Linked List: 113 ms. 280604793 clock cycles
Vector: 4 ms. 10105548 clock cycles

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> a
Linked List: 128 ms. 318875756 clock cycles
Vector: 4 ms. 9764784 clock cycles

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> a
Linked List: 123 ms. 308049717 clock cycles
Vector: 5 ms. 10805059 clock cycles

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> a
Linked List: 111 ms. 276182649 clock cycles
Vector: 4 ms. 9886340 clock cycles

Rubyist@TARDIS C:\Users\Rubyist\Desktop
> a
Linked List: 121 ms. 301932265 clock cycles
Vector: 4 ms. 8335000 clock cycles
>>
>>51943392
Christ, malloc is slow. That's insane.
>>
>>51943173
>>>51943131
>I'm from the old thread, I had C programming: A modern approach recommended to me, would C primer plus be a better book to read through?
They're practically the same book, you're fine.

>>51943193
Python is horrible to start with.
>>
>>51943404

Well yes, that's why many were recommending the use of a memory pool or some other custom allocator. Personally I say why bother? A vector is less work and still performs well.
>>
Anyone here work with/see Vulkan code? Is it C++-heavy? I like OpenGL because I'm a C-coder at heart. Don't think I could put up with some newfangled C++ bullshit in my graphics API.
>>
        private void DoConfirmationAnimation(Control control)
{
control.Visibility = Visibility.Visible;
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 0.25;
da.Duration = new Duration(TimeSpan.FromSeconds(0.6));
control.BeginAnimation(OpacityProperty, da);
da.Completed += (s, e) =>
{
DoConfirmationAnimationOut(control);
};
}

private void DoConfirmationAnimationOut(Control control)
{
DoubleAnimation db = new DoubleAnimation();
db.From = 0.25;
db.To = 0;
db.Duration = new Duration(TimeSpan.FromSeconds(0.6));
db.BeginTime = TimeSpan.FromSeconds(0.5);
control.BeginAnimation(OpacityProperty, db);
}


The fuck is this not firing for? I can't seem to get the "completed" event to actually fire off for some reason.

All I want to do is animate the fade out.
>>
Why does my codeeval submission segfault?
It runs perfectly fine on my machine and valgrind gives me no warnings.
>>
>>51943557
Never mind I'm an absolute fucking moron.

I shouldn't be programming this early in the morning clearly.
>>
>>51943471
Can anyone please answer my question here
>>
>>51943592
>mentioning web dev in /dpt/

Normies get out.
>>
>>51943557
>>51943567
        private void DoConfirmationAnimation(Control control)
{
control.Visibility = Visibility.Visible;
DoubleAnimation da = new DoubleAnimation();
da.From = 0;
da.To = 0.25;
da.Duration = new Duration(TimeSpan.FromSeconds(0.5));
da.Completed += (s, e) =>
{
DoubleAnimation db = new DoubleAnimation();
db.From = 0.25;
db.To = 0;
db.Duration = new Duration(TimeSpan.FromSeconds(0.5));
db.BeginTime = TimeSpan.FromSeconds(0.2);
db.Completed += (sender, eargs) =>
{
control.Visibility = Visibility.Hidden;
};
control.BeginAnimation(OpacityProperty, db);
};
control.BeginAnimation(OpacityProperty, da);
}


For anyone who might be as stupid as me and ever need to do something like this.
>>
>>51943592

I highly doubt many people here are going to be familiar with facebook APIs, mate. Read the documentation.

>>51943559

How do you expect us to be able to give you an answer to this question without showing a single line of code?
>>
How hard would it be to writ a program that takes in a list of inputs and outputs and then outputs that program? For example, you give t a file that has 1 1, 2 4, 3 9, 4 16, etc, and it outputs a program that takes for example 5, a number not in the file, and output 25?
>>
Daily reminder that self-taught programmers are worthless and they should not be allowed to program.
>>
>>51943662
what if I learned from K&R
>>
>>51943632
Hi there!

You seem to have made a bit of a mistake in your post. Luckily, the users of 4chan are always willing to help you clear this problem right up! You appear to have used a tripcode when posting, but your identity has nothing at all to do with the conversation! Whoops! You should always remember to stop using your tripcode when the thread it was used for is gone, unless another one is started! Posting with a tripcode when it isn't necessary is poor form. You should always try to post anonymously, unless your identity is absolutely vital to the post that you're making!

Now, there's no need to thank me - I'm just doing my bit to help you get used to the anonymous image-board culture!
>>
>>51943662
Reminder that some self taught programmers read through entire textbooks on their own instead of using shitty sites like Codecademy
>>
>>51943667
Then you wouldn't be on (8-4)chan in the first place.
>>
void fizz(double x) {
buzz(x);
}

// ...

long bar = b;
int baz = bazinga1;
int qux = cuck1;
for(int foo = (int) bar; foo < baz; foo += qux) {
fizz(foo);
}


vs

void fizz(double x) {
buzz(x);
}

// ...

long bar = b;
double baz = bazinga2;
double qux = cuck2;
for(double foo = bar; foo < baz; foo += qux) {
fizz(foo);
}


which do you think will have better performance? i'm thinking that the difference could be too small to matter but do you think the conversion from int to double is too heavy or will the cheaper int add and compare outweigh the cost of the conversion? which would you prefer from a purely performance point of view? the number of iterations will be around 42
>>
>>51943632
>How do you expect us to be able to give you an answer to this question without showing a single line of code?
Nevermind, it turns out codeeval was using inputs of 400 chars in length when I expected them to be much smaller.
>>
File: youcantstopliteracy.webm (3 MB, 640x360) Image search: [Google]
youcantstopliteracy.webm
3 MB, 640x360
Ask your favorite programming literate anything.
>>
>>51943670
>implying reading through textbooks helps you build logic.
No shit!
>>
>>51943677
lol? A lot of people here are self taught and learned from K&R etc.
>>
>>51943662
this is what normies actually believe
>>
>>51943686
confirmed for never reading a book on your own
>>
>>51943682

You should be able to handle inputs of any size.
>>
>>51943687
I thought you were referring to personalities, not the book :^P

>>51943699
Reading and absorbing are two different things.
>>
>>51943695
This is their coping mechanism for having $50,000 worth of student loans to pay for their adult day care education.

>>51943704
I know, but i was too lazy to add that, plus it's just a codeeval submission.
>>
>>51942701
This is incredibly wasteful, holy shit.
>>
>>51943662

I taught myself how to program, and then went to school to learn computer science. Honestly, one should not discount what one learns outside of one's traditional education. If one isn't constantly learning new things in this field, they will become irrelevant.
>>
>>51943800
This.

Besides which, teaching oneself anything shows more intuition, resourcefulness and flexibility. Of course, having a formal education on the top of that is the absolute goal; but I don't think it's as important as the fact that you can absorb such complex concepts on your own accord.

>>51943662
It was bait anyways. Most likely a failed self-taught programmer that gave up halfway into a post on reddit.
>>
>>51942910
>fixed size array
Apples and oranges dumbshit, try throwing in some reallocs every couple of pushes and see how your array works then.
>>
Holy shit, I just got an awesome idea. I need to pad my work history out with something besides "Neet for 3 years". What if I say I lived in a foreign country where they don't really speak English? Just list a random business in Japan or Brazil as my past employer. Then if HR bothers to call to confirm work history, they won't understand a word.

Fuuuuck I bet this would even work for foreign university credentials. Maybe I'll get a dev job after all, friends.
>>
>>51943878
Why realloc when you don't have to? Also >>51943392 handles reallocing and it's 30x faster than a naive linked list.
>>
>>51942683
Is haskell any good for someone interested in NLP?
>>
Daily reminder that all non-C languages are meme languages
>>
Can you do drag and drop gui programming with Scala? Like JavaFX or some shit
>>
>>51943892
>Why realloc when you don't have to?
Because you usually have to. Your program being fine for input of size N but not for N+1 (and overconsuming space for all input less than N) is a bad thing.

>>51943392 fixes the first problem but not the others and loses the benefit of immutability that any singly linked list implementation can trivially provide
>>
>>51943940
>immutability
We're talking about a stack, you know? Do you honestly think a linked list is a good fit for a stack? Are you retarded or just pretending?
>>
>>51943966
I could ask you the same question.
Do you even know what a stack is for?
Do you not understand why a linked list is the ideal implementation for a stack?
>>
File: coq.jpg (74 KB, 1045x636) Image search: [Google]
coq.jpg
74 KB, 1045x636
>>51943917

What about this one?
>>
>>51943966
>Do you honestly think a linked list is a good fit for a stack?
Yes, obviously. What about a linked list makes it inappropriate for a stack?
>>
/dpt/ is filled with Python babies who've clearly never analyzed the performance costs of a linked list on modern CPU architecture. There are no real benefits and the performance cost is immense.
>>
>>51943912
I haven't done much NLP, so I couldn't say, other than general things about how I find Haskell nice to program in. I don't know a whole lot about NLP libraries. It might be a better idea to ask in irc (#haskell on freenode) or the haskell-cafe mailing list.
>>
>>51944042
1 million push and pop operations on a singly linked stack
real    0m0.065s
user 0m0.048s
sys 0m0.016s


It's 2015, stop being autistic about a few extra cycles of overhead.
>>
>>51944062
that's 2 million operations total, i should have been more clear
>>
>>51944062
OK, now compare it with a vector. I'll wait. :^)
>>
What ML-like should I learn? F# or Ocaml?
>>
>>51943940

>and overconsuming space for all input less than N
Hence why std::vector contains a shrink_to_fit() and reserve() method for users who have a better idea of how much memory they're going to need. I could just as easily have implemented these, but it was pretty much irrelevant. At any given time, the stack contains at most twice as much memory as it needs (barring memory left over from popping). By simply doubling the capacity every time we hit our limit (a common tactic in vector implementations), we limit ourselves to O(log n) reallocs.

>immutability
Yeah, nah, fuck that noise.

>>51944062
Anon, I literally achieved a 30x performance boost from using a vector to implement a stack over a linked list. I also used 13 less lines of code (53 for linked list implementation, 40 for linked list). If I were to use a custom allocator, the amount of extra code written would explode, but I would have no guarantee of even approaching the level of performance offered by a vector.
>>
>>51943632
But reading the document I can't understand it :(
I'm new to Web dev
>>
>>51944113
Get out while you still can.
>>
>>51944105
there the same thing, F# is just a port of Ocaml to windows
>>
#include <stdio.h>
int main() {
int cookie = 0xdeadbeef;
char buffer[256];
gets(buffer);
if (cookie != 0xdeadbeef) {
puts("buffer overflow");
return -1;
}
printf("You entered: %s", buffer);
return 0;
}
>>
>>51944062
kill yourself
>>
>>51944113
>Web dev
shiggy doodely
>>
>>51944145
Is it supported well in .NET?
By the way, I'm mainly a C# guy, so I think I'll go with F#...
>>
File: 1441684460338.jpg (92 KB, 1280x720) Image search: [Google]
1441684460338.jpg
92 KB, 1280x720
>>51944204
>>
>>51944204
What if I write 256 bytes followed by 0xdeadbeef followed by whatever?
And I think your compiler can already do canaries like this by itself, I know GCC does.
>>
>>51944204

>Just prints

Segmentation fault (core dumped)


>Doesn't print your overflow warning
>>
>>51944204
==18875==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f25940eb7ad bp 0x7fff02d1ca38 sp 0x7fff02d1c670 T0)
>>
>>51943855
How about I have my education and do the same amount of research and projects a purely self-taught person does in my free time. Just because someone is in college, doesn't exclude them from self-teaching.
>>
>>51943918
Drag and drop GUI 'programming' is cancerous and only suitable when prototyping.
>>
http://perso.uclouvain.be/alphonse.magnus/num1a/remezp.htm

how do i run this? i tried copying
>http://perso.uclouvain.be/alphonse.magnus/num1a/remezp.java
into eclipse but i can't get it to run. nothing happens with
        remezp remezp = new remezp();
remezp.init();
remezp.start();
>>
Why you guys are still programming in c, one of the most disgusting programming languages ?
>>
>>51944656
Why you guys are still programming in <popular programming language>, one of the most disgusting programming languages ?
>>
>>51944656
I have to develop for Windows 95, it's the best choice.
>>
>>51944678
Except c is notorious for its uglyness and shitty semantics. A language of the past for the programming techniques of the past.
>>
>>51944711
So what do you consider a pretty language?
>>
>>51944719
Lambda calculus
>>
>>51944734
That's not a language stupid shit.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>51944734
>>
>>51944656
>>51944711
Why do you idiots have to always shitpost in every single on of these threads? Every single professional programmer knows that there will always be a language X available where features Y and Z are better than in the language they use. Yet they also know that if they want to continue working on certain kind of projects, it might be essential to use a certain language. Take embedded devices, it's either C, Assembly, or sometimes C++. There are some devices capable of executing JavaScript, Python, or some other high level language but try to get one approved for use in a factory, aircraft, or a cruise ship.
>>
>>51944139
>>51944217
Ayee they fell for the /g/ memes.
Web dev is a respectable position and if everyone is jerking off to c and c++ who the fuck is going to create those awesome multibillion dollar websites ?
>>
>>51944654
aww shit i clicked run as -> java applet but it only has 6 pre-defined functions and you don't get the coefficients. there seems to be no ready-made java code and the wikipedia explanation doesn't make sense FOR FUCK'S SAKE why do i have to do fucking everything myself all the time
>>
File: 1e9ksFAL1qa6cx6o1_500.jpg (51 KB, 500x375) Image search: [Google]
1e9ksFAL1qa6cx6o1_500.jpg
51 KB, 500x375
>>51944810
    //  interpolation with discrete orthogonal polynomials (very stable)
for(ii=0;ii<=NN;ii++){porth[ii][1]=1;} normp[0]=dg+2;
coeff[0]=0;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];coeff[0]+=fp[jj];}
coeff[0]=coeff[0]/normp[0];
coefs[0]=0;sgn=1;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];
coefs[0]+=sgn;sgn=-sgn;} coefs[0]=coefs[0]/normp[0];
for(ii=0;ii<=NN;ii++){errfp[ii]=fp[ii]-coeff[0];}
for(ii=0;ii<=NN;ii++){intsg[ii]=coefs[0];}
for(id=0;id<=dg;id++){
al[id]=0;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];
al[id]+=xp[jj]*porth[jj][1]*porth[jj][1];}
al[id]=al[id]/normp[id];
for(ii=0;ii<=NN;ii++){porth[ii][2]=(xp[ii]-al[id])*porth[ii][1];}
if(id>0){for(ii=0;ii<=NN;ii++){porth[ii][2]=porth[ii][2]-be2[id]*porth[ii][0];}}
normp[id+1]=0;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];
normp[id+1]+=porth[jj][2]*porth[jj][2];}
be2[id+1]=normp[id+1]/normp[id];
coeff[id+1]=0;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];
coeff[id+1]+=fp[jj]*porth[jj][2];} coeff[id+1]=coeff[id+1]/normp[id+1];
coefs[id+1]=0;sgn=1;for(ii=0;ii<=dg+1;ii++){ jj=idp[ii];
coefs[id+1]+=sgn*porth[jj][2];sgn=-sgn;} coefs[id+1]=coefs[id+1]/normp[id+1];
for(ii=0;ii<=NN;ii++){errfp[ii]=errfp[ii]-coeff[id+1]*porth[ii][2];}
for(ii=0;ii<=NN;ii++){intsg[ii]=intsg[ii]+coefs[id+1]*porth[ii][2];}
for(ii=0;ii<=NN;ii++){porth[ii][0]=porth[ii][1];
porth[ii][1]=porth[ii][2]; }
}
>>
>>51944748
>>51944751
>>51944771
You guys are in denial. Embrace the functional way or be doomed to miss the joy of intellectual programming. And to the guy who posted the fedora guy picture, that was grotesque.
>>
>>51944847
Functional programming is still not a language dumb fuck.
>>
>>51942683
I am trying to solve a junior interview task for first coding job, after a year of hard studying to code.
It is about creating an ASP Webforms control in a specific CMS system... I got the feeling it is quite of an overkill for a junior position as it is very hard for me to do it. But anyway I was drunk almost all the time its that time of the year I guess)_ since I got the task so... I guess I will manage to solve it.
>>
>>51944847
How the hell is one supposed to 100% embrace the functional way when the platform only supports C, there is only documentation in C, and no similar products area available that run something else?

Yeah, let's stop building stuff altogether because some neckbeard in /g/ thinks that C sucks.

Besides, you can do functional in C, it just isn't very sensible thing to do.
>>
>>51944881
Anon is too stupid to understand pointers.
>>
>>51944833
this is the thing that keeps me up at nights
>>
>>51944916
and that guy is too stupid for realizing that there a multitude of FPL that have a frontend for gcc/llvm or which compile to C.
>>
>>51944881
>Besides, you can do functional in C, it just isn't very sensible thing to do.
lel. c has no concept of what is a function, there only procedures.
>>
>>51943655
what
>>
File: 1319396458001.jpg (12 KB, 177x278) Image search: [Google]
1319396458001.jpg
12 KB, 177x278
>>51943655
>>
>>51943193
>Python is horrible to start with.
Why?
>>
Can you do autistic functional programming buzzwords like monads in Scala?
>>
>>51945121

I am curious what distinction you make between "function" and "procedure", and how you have come to the conclusion that C does not have functions.
>>
File: Capture.png (50 KB, 474x657) Image search: [Google]
Capture.png
50 KB, 474x657
what the fuck microsoft
WHAT THE FUCK
>>
>>51945445
What version of Windows do you have
>>
>>51945083
A typical project has over 100k lines of existing C codebase. You can find people to continue those projects because there are many talented C programmers of which to choose from.

Some open source hipster fad bullshit is just not good enough, even if by some fucking holy miracle it actually compiles to code that 20MHz / 64KB microcontrollers run in an efficient manner (protip: even our team's hardcore Clojure fanatic has not been able to find anything decent). On top of that, those projects are usually maintained by a couple of basement dwelling autists who can't be relied on, the only people actually knowing the very ins and outs of those projects are the maintainers of the projects, and they would probably oppose working in a capitalist company driven by profit.

Have you ever actually worked in the industry or are you just some third year computer scientist who thinks he knows something? Give me one example to support your claim that there is a major project available which is used by a company actually worth something. If there is one, I promise I will look into it and actually go through my co-workers whether it's worth our time.
>>
>>51945445
>community
>>
>>51945445
>Win 7
>Works fine

Are you using Vista or something?
>>
>>51945453
I rolled back to w7 sp1 from 10 today

>>51945462
what's wrong with it?
>>
File: Capture.png (34 KB, 1210x187) Image search: [Google]
Capture.png
34 KB, 1210x187
>>51945469
still
what the fuck microsoft
>>
>>51945426
read a book, i am not your professor.
>>
>>51943655
Holy shit I've figured out what you mean. So you give it an array of arrays [(input, output), (input, output), ...] and it should figure out on its own how to calculate the output from the input?
>>
>>51945609
Windows 7 mainstream support ended in january. Time to upgrade son.
>>
>>51942846
do you make moneys?
actually you sound like on a very big hangover... you can aways find another way to save humanity other than coding while living out of it...
>>
>>51945724
I just capped the line where it says sp1 was installed
>>
>>51945752
Yeah man. I saw it. Your screencapping abilities are exquisite.
>>
What's a good online way to learn c? I know c# a decent amount, and am too poor for books. Gotta do something productive in the holidays.
>>
>>51946080
You can get pdfs of all books mentioned here
>>
>>51946080
download a pdf book
>>
>>51943009
>>51942951
malloc can fail if you run out of virtual memory space in a 32bit app.
>>
>>51945426
Functions are mappings. Procedures are code.
>>
File: LhqdNxv.png (109 KB, 1919x969) Image search: [Google]
LhqdNxv.png
109 KB, 1919x969
>>51942683

Bashing my head against this current problem of mine where the image I upload and convert to base 64 (using angularJS) becomes random garbage.

I have absolutely no clue why this is the case, would appreciate some help :/

js
http://pastebin.com/hRHdK9q2

html
http://pastebin.com/7Zw5PHzU
>>
>>51943655

string a;
cin >> a;
cout << a << endl;
a = "NIGGERS";
cout << a;

????

PROFIT
>>
>>51942701
>explicitly casting malloc
>>
Pointers are fun
int strend(char *s, char*t)
{
char *tstart = t;

while(*s++);
s--;
while(*t++);
t--;

for(;*s-- == *t--;)
{
if(t<tstart)
{
return 1;
}
}

return 0;
}
>>
>>51946411
I don't understand all this bit shifting.
>>
>>51946472
What if t is larger than s?
>>
>>51946510
It shouldn't be
If I was developing something important I'd check for errors and shit
That for loop should just be a while loop too
>>
>>51946527
But why would it be an error? If you are implementing the function "check whether s ends with t" then calling it with strlen(s) < strlen(t) is entirely valid, with a well-defined return value of "no".
>>
File: 1449363846702.jpg (40 KB, 405x451) Image search: [Google]
1449363846702.jpg
40 KB, 405x451
>Shell languages.
>Spawning a whole process and possibly multiple threads for every command.
>People make actual programs with these languages.
Haha kill yourself.
>>
Im making a header-only library.
Is the general way to do it to have a typical header-file and then have all the CPP implementations in an #ifdef and have the user include+define MY_LIBRARY_IMPLEMENT somewhere or is there a more elegant solution.
>>
>>51942683
>>51942683


What programming language should I learn first if my main goals in mind are application software, web applications and hacking? Mainly application software, on mobile and computers.
>>
>>51946589
#include<stdio.h>

int strend(char *s, char*t)
{
char *sstart = s;
char *tstart = t;

while(*s++);
s--;
while(*t++);
t--;

if(t-tstart>s-sstart)
{
return 0;
}

for(;*s-- == *t--;)
{
if(t<tstart)
{
return 1;
}
}

return 0;
}

int main()
{
char *s1;
char *s2;
s1 = malloc(1024);
s2 = malloc(1024);
strcpy(s1,"abc");
strcpy(s2,"aabc");
printf("%s, %s, %d",s1, s2,strend(s1,s2));
return 0;
}
>>
>>51946657
Better.
>>
>>51946639
It's like a retarded version of Erlang.
>>
>>51943983
>cock
>>
>>51946729
It's pronounced "co-que"
>>
Thinking about getting into a meme language over the break.
Hows those silly functional languages going? Which is the most popular?
>>
>>51946772
hasklel seems the most popular

F# seems to be getting the best reviews/shills
>>
>>51946639
Suggest a better language?
>>
>>51946772
haskell

Generate all n-combinations of a number of items
Input (5,2)
Output ((1,2) (1,3) (1,4) (1,5) (2,3) (2,4) (2,5) (3,4) (3,5) (4,5))
>>
>>51946772
What are your favourite non-meme languages?

The confident tone in your pleasantly jovial post means your opinion is valid.
>>
>>51946814
C++
Assembly(x86 and arm)
>>
>>51946814
Java, duh.
>>
>>51946782
What can F# do.
>>
Given a text representation I need to construct a tree.
The input looks like this, the nodes can be named anything.
Root
Child
Grandchild
Grandchild
Grandgrandchild
Grandchild
Child
Grandchild
Child


The number of spaces before the name represents the level inside the tree.

So I'd need to first create the Root, then stick all Children to it, then for every Child I'd need to stick all of its children etc.

I can't think out an effective logic of doing all this though could you guys help me?

Maybe to look at the number of spaces and always add to children if the number of spaces is bigger then the current element something like that?
>>
File: vs.png (8 KB, 322x221) Image search: [Google]
vs.png
8 KB, 322x221
>>51945609
>Windows 7 build 7600 - Final (Release to Manufacturing) build generally available to the public to buy and use.
>Windows 7 build 7601 - Update to Windows 7 RTM (build 7601)
>>
>>51946905
lmfao cakewalk, do your own homework faggot
>>
>>51946905
use a stack
>>
>>51945469
>I rolled back to w7 sp1 from 10 today
how come? i'm still on w7 but my mom is wondering if she should take the free upgrade
>>
>>51946964
oh you're right can't believe I didn't think of that

>>51946950
kill yourself
>>
>>51946905
easy as piss

if the next line is further indent, it's a child of the previous line

if the next line is the same indent, it's a child of the previous line's parent

if the next line is 1 indent back, it's a child of the child of the previous line's parent

and so on and so forth, I'm sure you see the pattern
>>
>>51946772
Make video games in COBOL
>>
>>51946964
recursionfags BTFO
>>
>>51946838
>>51946853

Is C a meme language, good sir?
>>
Im checking out F# and it looks like an idiotic fucking mess of a language.
Worst of all it's all CLI.
Fuck this.
>>
>>51947117
>Worst of all it's all CLI.
http://www.catb.org/~esr/writings/unix-koans/gui-programmer.html
>>
>>51947117
well you said you wanted a meme language
>>
>>51947149
kek
>>
>>51942683
what i'am doing wrong here?
this is the output i get,

File "variables.py", line 34
hello_dict["eye_colour"]))
^
SyntaxError: invalid syntax
>>
>>51947272
>best error message ever
>this is what newbies should learn as their first language
>>
Why is /dpt/ so racist?
>>
>>51946791
Every other language ever, seriously.
Even scripting languages are much better.
>>
>>51947363
I'm not racist, I've met some niggers before.
>>
You need a backslash on line 34

e.g.:
print(hello_dict...."has"+\
>>
>>51947363
it's not racism if it's the truth
>>
>>51947432
This was meant for:
>>51947272
>>
File: huhy.png (8 KB, 473x500) Image search: [Google]
huhy.png
8 KB, 473x500
/dpt/ has never made something that was/is used by more than 1,000 users.
>>
>>51947488
I made several games, at least 1 of which was played by 1000+ users. Nice try pepe
>>
>>51947272
try NOT separating out arguments to you function on different lines like an idiot and maybe you'll catch what you did wrong.
>>
>>51947432
still same output :(

File "variables.py", line 34
hello_dict["eye_colour"]))"has"+\
^
SyntaxError: invalid syntax
>>
>>51947488
I made games for Newgrounds with 10000+ views
Nothing in the past 5 years though
>>
>>51947616
lmao you listened to him, the problem is your parenthesis, you closed them all on line 32
>>
>>51947272
str.format takes multiple arguments when you have multiple {#} values in the string, so it might be that.
>>
>>51947080
I actually ended up solving it with recursion anyway :^)
>>
File: srsly.png (18 KB, 519x179) Image search: [Google]
srsly.png
18 KB, 519x179
>>51947272
>>51947616
Oh lord, looking over your code...
Every time you do a line break in Python without terminating a function, etc, you need to put a backslash

Pic related
>>
>>51947693
Also, you had a typo:

print(hello_dict["first_name"]+"''+hello_dict...
is supposed to be:
print(hello_dict["first_name"]+"'"+hello_dict...

you swapped a double quote with a single quote.
>>
File: WorkingOn.png (119 KB, 1782x1051) Image search: [Google]
WorkingOn.png
119 KB, 1782x1051
>talk about what you're working on

I made a graphical text editor in python. I'm a bit of a noob so it feels cool to me. Is there any way I should improve on it?

Also post the challenges someone, I need something to do.

Code is pic related open in pycharm and itself
>>
>>51947745
Implement undo/redo.
>>
>>51947693
Ty guys but i'am done with that fucking meme language, syntax this syntax that, syntax my fucking cock python fuck you, i'am going back to c+
>>
>>51945038
eclipse cleaned it up for me, and i added my own function. but it seems like it's fucking broken because the contents of coeff are vaguely correct but contain garbage too, with different garbage depending on the degree of your polynomial. fucking hell
>>
What's with all the python "programmers" here? Useless meme language
>>
Camera calibration based on apparent and expected star positions.
>>
>>51947745
I'm making a semantic analyzer.
>>
File: kid.jpg (38 KB, 362x346) Image search: [Google]
kid.jpg
38 KB, 362x346
What communication method do you guys prefer with threads?

1) Low level mutex/semaphores
2) Erlang style mailboxes based on an Actor model
3) STM
4) ???
>>
>>51947770
>The problem? It’s hard to find. The most popular algorithm to find it is the Remez exchange algorithm, and few people really seem to understand how it works (or there would be a lot less Taylor series). I am not going to explain it right now. Usually you need professional math tools such as Maple or Mathematica if you want to compute a minimax polynomial. The Boost library is a notable exception, though.
thank god. i think i'm gonna try one of those mathfag programs. a taylor series might be more desirable for my purposes though if i can figure out how to find it
>>
>>51947869
busyloops
>>
Haskell is a meme language that's practically only used in Academia because time isn't money when you're in a non corporate environment.

Prove me wrong.
>>
>>51947790
How so?
>>
>>51947869
Go style channels
>>
>>51947953
Inefficient garbage, absolutely no practical use - anything you can think of doing in python can be done better in another language. Python is only popular because of the "it's a good starting language" meme. (It's not, most skills you learn in python really can't be applied to anything else)
>>
>>51947998
> anything you can think of doing in python can be done better in another language
But anon that's true for all Turing Complete languages.
>>
Hey /dpt/, what do you guys think of pascal?
>>
>>51947896
dank
>>
>>51942697
super smash brothers melee box that works similarly to brawlbox
>>
>>51948116
deprecated
>>
>>51947869
1
>>
What's a poster child for excellent UI?
>>
>>51948213
bool even(int x)
{
for (int i=0; i<=x; i+=2)
if (i==x)
return true;
return false;
}

Part of my homework is determining if a number is even. Why is this so stupidly hard.
>>
>>51948263
your mom
>>
>>51948268
low quality bait
>>
>>51948278
Well excuse me for taking intro cs classes. Should have just jumped right into advanced algorithms.
Thread replies: 255
Thread images: 25

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.