[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

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

Thread replies: 364
Thread images: 27
You know what edition

Old thread: >>52304354
>>
first for Haskell
>>
First for F#
>>
Third for Brainfuck
>>
>>52309695
>>52309698
Haskell confirmed to be faster than F#
>>
If you guys forgot every language you knew and had to relearn a couple and or learn a new up and coming one, which would you choose and why?
>>
>>52309744
Brainfuck
>>
>>52309744
french and german
>>
File: swig.jpg (178 KB, 610x607) Image search: [iqdb] [SauceNao] [Google]
swig.jpg
178 KB, 610x607
Does Asperger's make you a better programmer?
>>
>>52309550
>>52309550

posting again from last thread. can anyone help?
>>
>>52309848
yes
>>
>>52309770
God dammit
>>
>>52309865
-smiles wryly-
>>
>>52309848
Tfw you link my post

I'm famous!
>>
>>52309934
but that's MY post.
>>
File: STRONGER.jpg (204 KB, 910x1308) Image search: [iqdb] [SauceNao] [Google]
STRONGER.jpg
204 KB, 910x1308
Anyone got that programming project roll image?
>>
>>52309975
Ayyy lmao jk just fuckin with you
>>
File: 1452205269733.jpg (752 KB, 1920x1080) Image search: [iqdb] [SauceNao] [Google]
1452205269733.jpg
752 KB, 1920x1080
>>52309977
>>
>>52309989
k np, but srsly can u help?
>>
File: trex.gif (1015 KB, 475x475) Image search: [iqdb] [SauceNao] [Google]
trex.gif
1015 KB, 475x475
>>52310008
Thanks anon - rolling, and saving it this time...

Have a cheeseburger trex for your hard work
>>
>>52310047
You can make a script that makes a roll from that image (either with OCR or copy pasting that text to a file) instead of posting here.

For instance: I'm bored, lets run rollproject.

>Rolling...
>Number: 23
>The selected project is Maze Generator/Solver.
>>
>>52310025
No man I have no fuckin clue about anything all I know is Python.
>>
>>52310008
Roll roll roll your boat gently down the street
>>
>>52309806
No because programming is very team focused and aspies can't work on a team.
>>
First for python
>>
File: PFvE9ye.webm (2 MB, 718x404) Image search: [iqdb] [SauceNao] [Google]
PFvE9ye.webm
2 MB, 718x404
Ask your beloved programming literate anything.
>>
>>52310205
Tetsumi, why haven't you killed yourself yet you weeaboo piece of shit
>>
>>52310205
It's so cut I think I'll die.
>>
>>52310120
There's a difference between the ability to cooperate on a team and being a leader of/the most sociable one on the team.

>>52310205
What is the Y combinator in lambda calculus?
>>
>>52310250
Communication is key in cooperating with a team. If you can't clearly express your ideas and concerns with your team, you will be far less effective than a non aspie.
>>
File: dh.webm (2 MB, 1220x610) Image search: [iqdb] [SauceNao] [Google]
dh.webm
2 MB, 1220x610
Finally touched up my tag tooltip preview thing for everyone's favorite cave drawing database to a shareable state.

Lets you examine possible topics at a glance in case you're somehow "handicapped" in your peripheral abilities.
>>
>>52310337
you're "handicapped" in the head, manchild pedophile.
>>
>>52310370
Sure you're right here?
>>
>>52309806
not really, maybe more pedantic but not necessarily in a good way

autism can make you better in some ways if you have the gifted type of autism
>>
//applies a 1xN kernel
template<bool parallel>
std::shared_ptr<Image> Image::filter(const FilterKernel &kernel)
{
auto ret = std::make_shared<Image>(this->height(), this->width());

const int OFFSET = (kernel.size() - 1) / 2;

for_each_pixel<parallel>([&, this](std::size_t y, std::size_t x)
{
auto& current_pixel = ret->data.at(y).at(x);

for(int i = 0; i < kernel.size(); ++i)
current_pixel = current_pixel + pixel_with_edge_handling(y, x - OFFSET + i) * Pixel(kernel[i], kernel[i], kernel[i]);
});

return ret;
}


Uni homework. Basically a filter to remove motionblur from images. Pretty neat stuff.
>>
Reminder on how to live your life

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>
What's /g/'s opinion on SFML?
>>
>>52310621
Great API, but developed by an irgnorant french Gorilla.

>still no fucking mipmap support because laurent doesn't get why they would be usefull in 2D
>>
which do you prefer, /dpt/?

tempList = []

for (item in initialList) {
if (item != test) {
tempList.add(item)
}
}

initialList = tempList


iter = initialList.iterable()

while (iter.hasNext()) {
item = iter.next()
if (item == test) {
iter.remove()
}
}
>>
File: n.png (150 KB, 587x855) Image search: [iqdb] [SauceNao] [Google]
n.png
150 KB, 587x855
>>52310621
i prefer clanlib when c++ and allegro when c.
>>
>>52310569
in other words a reminder not to use python
>>
>>52310646
the first
>>
>>52310642
There's even helpful 2D shit missing. Like sprite batching and tilemap support.

Also the API can get a little inconsistent at times. A lot of methods can either take a Vector2 argument or two individual x and y arguments, and a lot of methods don't. There's also no setters and getters for individual coordinates, which is just unnecessarily inconvenient.
>>
>>52310681
>notch implying he's experienced in java
>>
>>52310781
>Claims C++ sucks
>Makes fun of people for claiming Java sucks
oh notch
>>
>>52310811
he never said C++ sucks though
>>
File: notchsavior.png (111 KB, 605x674) Image search: [iqdb] [SauceNao] [Google]
notchsavior.png
111 KB, 605x674
>>52310811
Never he said that.
>>
>>52310646
filter (/=test) initialList
>>
>>52310822
>>52310859
What did you take this to mean then? Is this the type of thing people say about languages they think are good?
>>
>>52310822
>comparing it to javascript
he kinda did
>>
File: y-combinator.jpg (35 KB, 640x480) Image search: [iqdb] [SauceNao] [Google]
y-combinator.jpg
35 KB, 640x480
>>52310250
I know what the Y combinator is and how it works, but I actually looked it up and found out that the set of fixed point combinators is recursevely enumerable, in contrast to the set of non-standard fixed point combinators that isn't. A nice little factoid.

So thanks for that, I guess.
>>
>>52311013
he had one complaint with it, followed by a compliment ("Loving the performance")

he obviously doesn't think it "sucks" or he wouldn't be using it at all
>>
>>52310565
OpenCV?
>>
>>52311027
*recursively
(sorry about that)
>>
>>52311013
It's called humour
>>
>>52311033
one complaint and one compliment.

If he loved it he wouldn't feel dirty using it. I don't even care what he thinks, but I can't see how you can read those tweets and think he thinks C++ is good.

>>52311118
Yes. People like making fun of languages they don't like.
>>
>>52310646
Enum.filter(initialList, &(&1 != test))
>>
>>52310008
rolling
>>
File: 1369336185490.jpg (80 KB, 428x600) Image search: [iqdb] [SauceNao] [Google]
1369336185490.jpg
80 KB, 428x600
>>52310370
Thanks for reminding me to stop visiting this reddit 2.0 board.
>>
What are my options when it comes to programming on a netbook that doesn't support GNU/Linux? I don't want to install Visual Studio Community because it only has 32GB storage.
>>
https://matt.sh/howto-c
>It's an accident of history for C to have "brace optional" single statements after loop constructs and conditionals. It is inexcusable to write modern code without braces enforced on every loop and every conditional. Trying to argue "but, the compiler accepts it!" has nothing to do with the readabiltiy, maintainability, understandability, or skimability of code. You aren't programming to please your compiler, you are programming to please future people who have to maintain your current brain state years after everybody has forgotten why anything exists in the first place.
>>
>>52311351
vim
>>
>>52311381
vim is not a compiler.
>>
>>52311421
neither is Visual Studio
>>
>>52311421
Neither is Visual Studio Community.
>>
Visual Studio Community only takes up 4gb.
>>
>>52309744
F#
because futur
>>
>>52311459
4gb to write text
>>
File: hqdefault.jpg (10 KB, 480x360) Image search: [iqdb] [SauceNao] [Google]
hqdefault.jpg
10 KB, 480x360
>>52311459
>Visual Studio Community only takes up 4gb
>>
>>52311476
It does more than that anon
>>
>>52311476
VS does way more than write text.
>>
>>52311351
Which language? I'd recommend vim + the compiler/intepreter
>>
>>52311438
>>52311447
It includes a compiler, and from what I can tell you can't get the MSVC compiler on its own.

>>52311476
Idiot.
>>
>>52311481
Didn't say it was small. But will fit comfortably on a machine with 32gb storage.
>>
>>52311351
Depends on what you're wanting to do. MSYS2 is really great and is normally the best way to do C and C++ programming on Windows, as well as being a great way to install proper native Windows versions of any kind of software you'd normally run on Unix-like operating systems which might need for programming or using other languages.
>>
>>52311481
>muh shekels
>>
>>52311498
C mostly. I already have gVim and Python installed.
>>
>>52310205

Is it difficult to train your ham to stay up during the day?
I am not sure I want to yet, because I'm only home at night when I play with her.

Just wondering?
>>
>>52310565
>Basically a filter to remove motionblur from images
isn't it more general than that? also is the class c++ based or did you choose that.
>>
>>52311511
>from what I can tell you can't get the MSVC compiler on its own
You can, presuming you have VS installed.

That being said, it's easier to just download the windows port of gcc.
>>
>>52311493
>>52311494
Such as the placebo effect?
>>
>>52311531
Then use gVim (or vim, since it's console based and not graphic) and gcc
>>
>>52311371
>standard c99

stopped reading. ANSI C 4 lyfe
>>
>>52311514
>MSYS2
This is perfect, thanks.

>>52311549
>>52311563
There was no download on the GNU website so I assumed it wasn't available for Windows.
>>
>>52311560
>Such as the placebo effect
Not that I know of anon.
>>
>>52310008
roll
>>
>>52311600
GNU doesn't support Windows for obvious reasons, but GCC definitely has a Windows port.
It's part of MinGW, which is essentially a port of the GNU toolchain to WIndows.

http://www.mingw.org/

MSYS (also made by the MinGW team) is a little more specialized.
>>
Dear DPT:
When in you have this C expression
something ?: Nil;

what does that do?
I know the ternary operator works like an if but that one doesnt have anything in the 1st part, does it return the previous value?(ie something).
>>
Should I take machine learning or graphics programming?
>>
>>52311689
Yes.
>>
I finally figured out how my YouTube subscription manager will work.
It'll initially consists of three options: add, sync and remove. Add/remove manage the channels in the SQLite database. The sync options checks if one or more videos have been added the a channel. This is done by scraping the channel page. If one more more new videos have been found for each channel, the user is notified by an email, desktop notification or a custom command. Notification settings can be configured by editing the config file.
I want to keep it as generic as possible, so I can also manage Vimeo subscriptions. I also want to send a notification if a Twitch stream is online.
I'll be doing this in Go, SQLite3 and use JSON for the config file.
>>
>>52311689
No.
>>
>>52311722
>>52311740

Maybe?
Ok then what does that do?
>>
>>52311689
It's just an if statement turned into an expression.
It's the same as saying this:
if(something) {
} else {
Nil;
}
>>
>>52311772
Just tested it. It does work, and it returns the previous value. Never seen or tried this before.
>>
>>52311689
>>52311772
c = a ?: b;

is equivalent to:
c = a ? a : b;

But "a" will only get evaluated once.
>>
>>52311803
that's dumb, why not just if (!something)
>>
>>52311806
>>52311814

Ok thanks anons, the compiler am using doesn't seem to support it and I didnt have a Linux at hand.
>>
>>52309675
I have a hamster

its not dead

yet :)
>>
>>52311862
Yeah, it's (unfortunately) a non-standard operator.
>>
>>52311600
>>52311658
MSYS2 provides packages built with MinGW, as well as MinGW itself, which is a Windows build of gcc which generates native Windows binaries without a bunch of POSIX compatibility like Cygwin.

Just open the "MinGW64 Shell" and not the "MSYS2 Shell" once you've installed it, and do `pacman -Ss gcc` to search for the name of the gcc package, which should be prefixed by a bunch of mingw64 stuff, then `pacman -S mingw-w64-x86_64-gcc` or whatever it is. Then you can just run gcc as normal like `gcc -o program program.c` and it will all just werk.

Trying to download and set up MinGW and dependencies for any projects manually is a massive pain and is so much easier with MSYS2. "MSYS", which ships with MinGW's official distribution or whatever, is kind of rubbish. MSYS2 however has its own package repository using pacman which is awesome and just werks and allows you to easily get up to date development libraries which are all properly installed for you.
>>
>>52311803
what? no
#include <stdio.h>
int main()
{
int a = 1 ?: 5;
int by;
if(1)
{
} else {
b = 5;
}
printf("%i\n%i\n",a,b);
}

Running this prints:
1
0
So they are NOT the same.
>>
How to handle backtracking when parsing?

My idea is to keep a buffer, if there is nothing in the buffer read a byte and add it, otherwise read the next byte in the buffer. If parsing fails reset the location in the buffer to the start. If it succeeds copy the remaining data in the buffer to the start and repeat.

Thoughts?
>>
>>52311371
his only valid point was variable declaration and assignment on the same line
>>
>>52312188
YOU AINT BACKTRACKING ME IM BEHIND 7 PROXIES
Your solution sounds a bit complex tbqf friend. Mind giving a practical example.
>>
How do I write C programs that won't shit themselves as soon as they're hooked up to user input from the internet?

Should I just abandon ship and switch to Rust?
>>
>>52312293
>How do I write C programs that won't shit themselves as soon as they're hooked up to user input from the internet?
By writing them properly

>Should I just abandon ship and switch to Rust?
Jesus christ no. Use C# at least before for venture into any meme languages. And if you can't resist the urge to go full meme, use F# or ocaml. Most of everything else is garbage.
>>
I feel like a idiot for having to ask, but I can't remember how to code a rollover spoiler with usable inline tags like the ones used in the chans and I can't find a good copypasta for it, it's always some weird shit that isn't logical or is the wrong type.

IE:"["spoiler"]" "["/spoiler"]" or "["s"]" "["/s"]"
and its corresponding code.

Would anyone be kind enough to oblige me?
>>
>>52310205
fuck off
>>
>>52312259
Trying to parse either aaa or aba. You try one first, and if that fails you need to backtrack and try the other.
>>
>>52312346
>By writing them properly
But how? There's so many little security caveats that it seems like I can't keep track of them all.

Also, the reason that I'm writing C in the first place is for performance to speed up my genetic algorithm solver, so those other high level languages would be too slow.
>>
>>52312358
you can write a simple lexer and parser, or just match the string for ["spoiler"] and [/"spoiler"]
>>
>>52312403
>There's so many little security caveats that it seems like I can't keep track of them all.
So either try hard or give up

>Also, the reason that I'm writing C in the first place is for performance to speed up my genetic algorithm solver
How fast does it need to be. How much % of a speed decrease would you be willing to trade for increased productivity and security? Because you can write shit 10x faster and safer in C# for a 10-20% speed penalty, which you can of course almost always more than make up for by using a fraction of the time you safed implementing optimisations.

This is why C is hardly used for anything these days.
>>
>>52312403
learn to sanitize user input
assume your users are stupid and filter out things that aren't valid data
>>
>>52312400
How performance-intensive does it need to be?
>>
>>52312188
The dragon book has a good solution for a lexer (parsing is done later on) involving a forward pointer and a back buffer, I think in chapter 3.
>>
>>52311371
Wew, already follow all his rules besides the one you brought up. Fuck that.
>>
>>52312426
As of right now, I have a simple code that sets the background and text to black, and inverts the text color on mouseover, but nothing to set this to tags.

[I'm also tired and stupid, I know some programming, but I've forgotten 99% of it due to obscenely heavy stress in the last few years.]
>>
File: 1404591512474.png (889 KB, 756x715) Image search: [iqdb] [SauceNao] [Google]
1404591512474.png
889 KB, 756x715
Let's say I'm bored and want to learn how to make websites. Which languages should I learn : Ruby/PHP/JS or all of them?
>>
>>52312535
All of them. Except for Ruby and PHP. They are terrible. JS is necessary though.
>>
>>52312460
>10-20% speed penalty
pfffffttttttt. 100%-200% you mean.
>>
>>52310646
filter(lambda x: x == test, initialList)
>>
>>52312358
If you just want to handle general cases you could use regex.

\[spoiler\](.*?)\[/spoiler\]
>>
why do c++ templates exist when macros exist?
>>
>>52312557
nope. C# and Java are faster than you think. It very much depends on what you are doing exactly though.
>>
>>52312480
The faster the better.

>>52312482
Thanks I'll check it out.
>>
>>52312460
>So either try hard or give up
I'm not a C expert, where do I find how not to write security vulnerabilities?

>Because you can write shit 10x faster and safer in C# for a 10-20% speed penalty,
That's just plain wrong. C# is 4-8 times slower than C.

>>52312462
It's not quite that simple. It takes an untrusted binary file as input, then the genetic algorithm does a shitton of calculations based on that.
>>
>>52312559
this, pretty much, except using C#'s LINQ
>>
>>52312578
Macros don't have any kind of compile-time safety or calculation.
>>
>>52312426
>>52312516
Wait, I'm being unnecessarily dense, I forgot to mention why I need it and what it needs to be.
It's going to be a bbcode for a chan that recently is no longer kill and had to restart from scratch. Not sure if that helps, but I probably should've mentioned it to begin with.
>>
>>52312516
post a fiddle, i can take a look at it for a sec, i don't have a lot of time though
>>
>>52312578
They're both far more expressive and safer to use
>>
>>52312579
You obviously don't understand percentages. If something runs 2x as slow as something else (2-5x slower are about the area C# and Java are compared to C according to many benchmarks) that means the code takes 100% more time, or is 50% the performance.
>>
>>52312593
>C# is 4-8 times slower than C.
Where did you hear that? C# is not that much different to C. C# is just a safer version of most of the same shit. Both languages are compiled.
>>
>>52312579
>It very much depends on what you are doing exactly though.
no shit

but you're looking at way more than 10-20% for most general tasks outside of basic arithmetic or tight loops
>>
>>52312653
I don't know why you think I don't understand that.
>>
>>52312660
It run on a vm.
>>
>>52312660
Nigga, you're retarded.

Stop posting on /dpt/
>>
>>52312660
>Both languages are compiled

C# runs in a VM
>>
>>52312686
yes, the VM compiles it. In the end it's machine code just like C. The JIT overhead is not a big deal. And if you want you can AOT compile it and avoid the VM altogether.

>>52312700
no shit. It still get's compiled to machine code.
>>
>>52312685
You said 20% slower.
It doesn't allow you to directly compared C and C#, probably to prevent the kind of autism people like you exhibit.
https://benchmarksgame.alioth.debian.org/u64q/c.html
https://benchmarksgame.alioth.debian.org/u64q/csharp.html
>>
>>52312724
C# can't compete with C. It's too slow. Because it has dynamic typing, a lot of security check. C is bareback on the CPU, not C#.
>>
>>52312724
>the VM compiles it
No, the VM runs it. It's compiled to byte code, which is "machine code" for Microsoft's proprietary VM, not the actual hardware. There is still one more layer of translation there.
>>
>inb4 but le jit xd le better than compiler
JIT is a feature of a VM and has significant overhead, even if it can produce slightly faster native code for certain hot blocks. It is also a huge security risk as it involves allocating new executable memory.

Plus, you have all the runtime features of C# that can't be avoided, like GC and reflection, and you simply don't have as much control over memory especially as in C or C++.
>>
>>52312778
This nigga gets it.
But why is JIT not faster than compiled code without using march=native? It knows what instructions the machine has, so it should be able to produce the most efficient code.
>>
>>52312731
did you even read your own link?

https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=csharp&lang2=gpp

C# matches C for many of the benchmarks and beats it in some. Many is about 20-30% slower and yes, in some it's multiple times slower.

Keep in mind these benchmarks are arbitrary code tests written by random people, so on this site it's totally feasible to find a PHP benchmark that will beat a C one.
>>
File: res2_49a.jpg (34 KB, 590x419) Image search: [iqdb] [SauceNao] [Google]
res2_49a.jpg
34 KB, 590x419
>>52312616
>>
>>52312775
Jesus christ anon you dumb shit.

the C# compiler compiles C# to Intermediate Language. This is equivalent to bytecode in Java, neither of these are by ANY means "machine code", machine code is what is executed by real hardware.

When the VM gets the IL, it compiles it to actual machine code, just as the C compiler compiles C to machine code. Both C and C# become machine code before they are executed. C# just has the IL step in between.
>>
>>52312775
https://msdn.microsoft.com/en-GB/library/ht8ecch6(v=vs.100).aspx
>>
>>52312814
I did say that the resulting native code can be slightly faster. But really, any benefit of a JIT is completely negated if your application/library is distributed in source form to be compiled by the end user (end users who download a binary won't care about that anyways).

>>52312825
>C++

>>52312855
>When the VM gets the IL, it compiles it to actual machine code
It may, if it decides that a small section of code is being run enough to offset the costs of doing the compilation. Most of the code will still be used at the bytecode level.
>>
>>52312814
Most optimizing static compilers do function inlining as well as a host of other optimizations only available to static analysis. JITs have overhead depending upon the technology (tracing or whatnot).

>>52312825
>C# matches C for many of the benchmarks and beats it in some.
It beat C++ (not C lol) in none in any metric. Did you read your own link?
>>
File: image.gif (386 KB, 515x386) Image search: [iqdb] [SauceNao] [Google]
image.gif
386 KB, 515x386
>>52310008
Rolling
>>
>>52312731
Microbenchmarks strongly favors managed languages because it's not hard to get simple loops right these days.
What will kill you with these managed languages is memory accesses - in particular shuffling data around and iterating over collections with no particular super slow hotspot, but at the sum total there will be an overall sluggishness.
>>
How do I give another process the permission to send signals to my process?
>>
>>52312879
>C++
You can compare your own links too. I couldn't find a page that would compare C and C#, but the comparisons are about the same anyways.
>It may
afaik, the CLR always compiles it.
>Most of the code will still be used at the bytecode level.
That would very much depend on the program
>>
>>52312944
If the JIT were to be applied to all of the code in a program, it would incur the cost of doing a heavily optimized AOT compilation every single time it is run. And if you don't JIT with all possible optimizations of the target machine, you aren't gaining a thing.
>>
>>52312482
I just read it but I'm not sure I understand why you need to partition the buffer into two halves. Isn't getc already buffered by most compilers? Which would make reading a file in blocks unnecessary.
>>
>>52312882
>Did you read your own link?
Fuck, your right. Still mandelbrot and fasta-redux about about 20-40% slower only.
>>
>>52312944
>I couldn't find a page that would compare C and C#
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=csharp&lang2=gcc
>>
>>52312855
Nothing in this post even disagrees with what I said.

>neither of these are by ANY means "machine code",
Except they're running on a virtual machine, which makes it machine code for a virtual machine, hence "machine code", in quotes.

>When the VM gets the IL, it compiles it to actual machine code
Yes, and it has to be done at runtime, because it doesn't know what hardware it's going to be running on and it needs runtime information for features like reflection.

Dunno what you thought you were proving here.
>>
C# is slower than C, undeniably.

t. devoted C# fag
>>
>>52312970
>it would incur the cost of doing a heavily optimized AOT compilation
err... no. JIT is optimised for fast compilation. AOT is optimised for pushing out fast code.

>and if you don't JIT with all possible optimizations of the target machine, you aren't gaining a thing.
eh, depends what benefits you expect to get from C#.
>>
>>52313028
post a qt negress pls
>>
>>52313039
If that were the case, there'd be literally no reason to ever use JIT over AOT.
>>
>>52313028
Have you confessed your sins yet?
>>
>>52313008
>Except they're running on a virtual machine
yes, but that's not the term used. This is almost always called "bytecode" even when not referring to the JVM.

>Yes, and it has to be done at runtime, because it doesn't know what hardware it's going to be running on and it needs runtime information for features like reflection.
I know. And that's what I said.

>Dunno what you thought you were proving here.
I said the VM compiles the code to machine code. You took issue with that for some reason.
>>
>>52313095
There's a big difference between the statement "The VM compiles the bytecode to machine code" and "The VM can compile some bytecode to machine code". JIT is the latter. If you want the former, use AOT.
>>
>>52312976
In general, the double buffer is a more robust solution, and the reason for having two is so that you can load more input without overwriting the current buffer and without reallocating memory.

Exactly what kind of input are you trying to parse that has you using getc?
>>
>>52313095
You said
>Both languages are compiled.
I guess I misunderstood you, but if you meant compiled at runtime then I don't understand what you were claiming. All languages need to end up as machine code sooner or later, but not all languages can be described as "compiled".
>>
>>52313028
no ones claiming otherwise. What's in question is by how much.

>>52313062
Really now? Does "write one run anywhere" mean anything to you? Jitting has many benefits. One big one is security, you can sandbox certain applications. Doesn't matter where the IL code came from, the VM can guarantee it can't access certain parts of the system with high granularity. Hence things like silverlight. It's also nice to build assemblies that run flawlessly across different platforms. I've built server applications on windows and then run them on linux without requiring any code adjustments or recompilations. I've worked on a project at my last company where we did a cross platform mobile app with Xamarin running on WP, iOS and Android, and shared 90% of the code base. And even then, almost all that code was in a single assembly, and just needed to be included in each build. We could also headlessly test it on Windows and OS X.

Lots of good reasons for JIT. The main one I would say is security. Is performance a good one? Well it's faster than interpreting scripts, but not faster than AOT in any case I can think of.
>>
File: 1451779067201.png (20 KB, 418x359) Image search: [iqdb] [SauceNao] [Google]
1451779067201.png
20 KB, 418x359
>>52313142
>There's a big difference between the statement "The VM compiles the bytecode to machine code" and "The VM can compile some bytecode to machine code"
Neither of those terms are mutually exclusive.
>>
>>52313193
>All languages need to end up as machine code sooner or later
Never heard of interpreted languages then?
>>
>>52313146
>load more input without overwriting the current buffer and without reallocating memory
My method has that too, although I can see what you mean about more robust.

I'm writing a simple program for fun to deal with JSON.
>>
>>52313041
fuck off
>>
>>52313245
Code in interpreted languages has to be translated to machine code too. It'd be useless if it wasn't.
>>
>>52313286
>Code in interpreted languages has to be translated to machine code too.
no it doesn't.
>It'd be useless if it wasn't.
Not useless, just slow.
>>
>>52312616
>>52312516

<div style="background-color:#000000;color:#ffffff border:1px solid #ffffff;">
<span onmouseout="this.style.color=this.style.backgroundColor='#000000'" onmouseover="this.style.color='#ffffff';" class="spoiler" style="color: #000000; background-color: #00000;">{SAMPLE}</span>
</div>

Thanks
>>
>>52313286
>what are emulators
>what are interpreters
>>
>>52313306
How is it going to make use of the hardware in that case?

>>52313362
Both translators.
>>
File: sicpm.jpg (52 KB, 528x640) Image search: [iqdb] [SauceNao] [Google]
sicpm.jpg
52 KB, 528x640
>>52313386
nein. read chapter 4 of sicp, maybe you will learn something but i doubt that you have the required knowledge.
>>
>>52313386
>How is it going to make use of the hardware in that case?
by getting the interpreter to execute the program as it is described in the code file. This doesn't involve any code being translated to machine code.

>Both translators.
Emulators are not always. Interpreters never are by definition. Or at the very least they don't translate everything any merely interpret.
>>
File: >tfw.jpg (2 MB, 3538x3424) Image search: [iqdb] [SauceNao] [Google]
>tfw.jpg
2 MB, 3538x3424
>>52312293
>ask straightforward question
>start tangentially related shitstorm over C#
>question still isn't answered
Feels bad man.
>>
>>52313485
you're basically asking "how do i write good code". Ask about specific examples at least.
>>
>>52313510
I'm asking where do I learn how to avoid the numerous pitfalls in C.
>>
>>52313545
you don't, you walk into them and then learn to climb out and avoid them in the future
>>
>>52313469
>This doesn't involve any code being translated to machine code.
Of course it does. For every instruction in the source code, some corresponding machine code has to be generated. That's the very definition of translation.

>>52313445
I've read all of SICP. It doesn't ever claim that hardware can process anything besides machine code.
>>
>>52313571
>has to be generated
No it doesn't, it can be executed directly.
>>
File: mt-stupid.png (43 KB, 613x481) Image search: [iqdb] [SauceNao] [Google]
mt-stupid.png
43 KB, 613x481
>interpreters translate everything to machine code because a computer can't run anything but machine code
>>
>>52313571
>For every instruction in the source code, some corresponding machine code has to be generated. That's the very definition of translation.
well observed anon. This is exactly what interpreters do not do. What do you think the difference is between a compiler and an interpreter?
>>
>>52313250
>My method has that too
How are you doing that with only one buffer?
>>
>>52313567
Except that's a non-answer.
>>
>>52312846
kek
>>
>>52313571
>I've read all of SICP.
>lying this bad
sicp chapter 4 explains how to program a meta circular evaluator which interprets a lisp program without any compilation/translation involved. if you had truly read sicp, you would have know that. faggot.
>>
>>52313644
What are you expecting. You're still basically asking "how do i code good". His answer is as good as you can expect for such a broad question.
>>
>>52313656
Ho shit, I must read that book, especially that chapter 4.
>>
https://blog.jessfraz.com/post/this-industry-is-fucked/
>>
>>52310685
Provide a counter argument to any one of those ideals.

> wont happen
>>
>>52313592
How? It doesn't exist, all you have is source code. Whether it's compiled or interpreted, source code is useless to the hardware.

>>52313624
>This is exactly what interpreters do not do.
But they do. They have to spit out either machine code, or an intermediate language that goes into the next translator, inevitably becoming machine code that can actually be executed.

>>52313656
And that obviously wouldn't work unless you already had a Scheme interpreter to translate it to machine code. All you're doing is adding another hop.
>>
>>52313644
No it isn't, you learn by doing, you make mistakes, you figure out how to fix said mistakes and consequently how to avoid them in the future.
>>
>>52313656
>interprets
>without any translation involved
Interpretation is translation.
>>
>>52313636
Fixed buffer size and the current "length" of the buffer. If the position in the buffer is greater than the length, it reads a new character into ++length, otherwise it just returns the character at position.
>>
>>52310008
Rollerdoop
>>
>>52313730
What do you do when the buffer fills up in the middle of a token?
>>
>>52313714
>They have to spit out either machine code, or an intermediate language
No they don't. How about you spend 5 minutes reading what an interpreter is before shitposting from mount stupid about it. This is basic stuff.

Interpreters are not translators by definition. If they were they would be compilers.
>>
>>52313732
Re-rolling as I've completed this one before.
>>
>>52313698
i don't disagree with those ideals

but the way python is designed and implemented doesn't adhere to those ideals
>>
enum Op {
ADD,
SUBTRACT,
HALT
};

struct Term {
int x;
int y;
enum Op op;
};

int eval(struct Term term) {
switch(term.op) {
case ADD:
return term.x + term.y;
case SUBTRACT:
return term.x - term.y;
default:
exit(0);
}
}

Did I just generate machine code for the term and run it?
>>
>>52313667
>>52313722
Somehow I doubt that's the strategy employed by people writing production C code. I'm not some 'lel learn 2 code' fag. I just haven't spent much time writing C before.'
>>
>>52313823
Add AVERAGE to the enum.
>>
>>52313848
kek
>>
>>52313714
if (c == 'a') {
++x;
}


Let's say we're interpreting a language where 'a' means increment some variable. This code will do that. Note how no extra machine code is being generated when this program is executed.
>>
>>52313760
>Interpreters are not translators by definition.
They are.
> If they were they would be compilers.
Compilers and interpreters are both translators.
>>
>>52313760
Literally the only difference is that it's being done implicitly.

>>52313864
I didn't say extra machine code, I just said it had to be translated to machine code. And this case, 'a' is translated to whatever the appropriate opcodes and addresses/registers are at runtime.
>>
>>52313844
>Somehow I doubt that's the strategy employed by people writing production C code.
Hate to surprise you then anon. If you could be more specific with we could help you more.
>>
>>52313864
>This code will do that. Note how no extra machine code is being generated when this program is executed.
You need to take a wider look.
An inc or add instruction will be inserted into the cpus fetch&decode pipe when c == 'a', and if c wasn't 'a' it wont be inserted.
>>
>>52313028
You owe me a negress thread in /hc/
>>
>>52313923
>And this case, 'a' is translated to whatever the appropriate opcodes and addresses/registers are at runtime.
It's used as a predicate for a branch into entirely static machine code.

Is this being translated into the appropriate machine code depending on the value?
if(someBoolean) {
a += b;
} else {
printf("You're retarded\n");
}
>>
>>52313929
Just because the CPU translates ISA code to microcode doesn't mean that interpreters necessarily translate high level code to ISA you dumb fuck
>>
who wants to make a startup

>inb4 logo
>>
>>52313876
Just stop anon
>In computer science, an interpreter is a computer program that directly executes, i.e. performs, instructions written in a programming or scripting language, without previously compiling them into a machine language program.
>without previously compiling them into a machine language program.
https://en.wikipedia.org/wiki/Interpreter_(computing)
>>
>>52313973
I'll make the memes
>>
>>52313966
>Just because the CPU translates ISA code to microcode doesn't mean that interpreters necessarily translate high level code to ISA
There's no conceptual difference, which why they are both translators.
There are practical differences of course - which is where the different translators get their definitions from.
Compiler - a translator which takes some source level language and produce another, typically lower level language, and in common usage: object code.
Decompiler - a translator which does the reverse of the above.
Interpreter - a translator which takes a source language and executes it immediately (potentially with some intermediate transform like byte code beforehand).
>>
File: photo.jpg (25 KB, 437x437) Image search: [iqdb] [SauceNao] [Google]
photo.jpg
25 KB, 437x437
>i code exclusively in ANSI C
>>
>>52313944
It is still a translation if it's acting based on source code from a higher-level language, yes.

>>52313983
>An interpreter generally uses one of the following strategies for program execution:
> parse the source code and perform its behavior directly.
> translate source code into some efficient intermediate representation and immediately execute this.
> explicitly execute stored precompiled code[1] made by a compiler which is part of the interpreter system.
Did you read this before you posted?
>>
>>52313966
Any advice on compiler development and Cuda ? Golf tutorials Books? Llvm a plus
>>
>>52310205
>Thought this would be cute from the thumbnail.
>Doesn't look cute at all.
>More like what it really is.
>Filthy vermin in an unsuitable environment.
>I want crush that fucking faggot and throw it in the trash.

Why?
>>
>>52313983
https://en.wikipedia.org/wiki/Translator_(computing)
>>
>>52314054
>Interpreter - a translator which takes a source language and executes it immediately
Fascinating personal definition of "Interpreter" you have there.
>>
>>52313823
No. You'd have to manually create an array of machine words then cast it to a function pointer and execute it. Currently you're just interpreting it a fancy way.
>>
>>52314094
Not my definition.
>>
>>52313787
pascal.py
[CODE]
import sys
import argparse

parser = argparse.ArgumentParser("pascal.py")
parser.add_argument("-n", "--required-rows", type=int, required=True)

args = parser.parse_args()

def pascal(required_rows):
if required_rows <=0 : return
row = [1]
yield row
if required_rows == 1: return
row.append(1)
yield row
if required_rows == 2: return
for x in range(required_rows - 3):
new_row = []
for n, element in enumerate(row):
if n == 0:
previous = 0
else:
previous = row[n-1]

previous = row[n-1] if n != 0 else 0
current = row[n]
new_row.append(previous + current)

new_row.append(1)
yield new_row
row = new_row

if __name__ == '__main__':
for row in pascal(args.required_rows):
sys.stdout.write(" ".join(map(str, row)) + "\n")
[/CODE]
>>
>>52314070
>Did you read this before you posted?
Yes. None of those things are translating to machine code. Only one of them involves translating the code in your code file at all.
>>
>>52314120
pascal.py
    import sys
import argparse

parser = argparse.ArgumentParser("pascal.py")
parser.add_argument("-n", "--required-rows", type=int, required=True)

args = parser.parse_args()

def pascal(required_rows):
if required_rows <=0 : return
row = [1]
yield row
if required_rows == 1: return
row.append(1)
yield row
if required_rows == 2: return
for x in range(required_rows - 3):
new_row = []
for n, element in enumerate(row):
if n == 0:
previous = 0
else:
previous = row[n-1]

previous = row[n-1] if n != 0 else 0
current = row[n]
new_row.append(previous + current)

new_row.append(1)
yield new_row
row = new_row

if __name__ == '__main__':
for row in pascal(args.required_rows):
sys.stdout.write(" ".join(map(str, row)) + "\n")
>>
>>52314109
Who's then?
>>
>>52313944
>Is this being translated into the appropriate machine code depending on the value?
Yes.
>>
So I want to edit android kernel files and I'm using Sublimetext3. Loading the entire kernel as a project, in the defconfig file there are flags like
CONFIG_CPU_FREQ=y
and then in the source files it should only enable the code inside #ifdef CONFIG_CPU_FREQ and gray out the others. Is this even possible? Is there a a plugin for Sublimetext or any other C editor that can do this?
>>
This was an interview question asked by a senior manager.

>"Which is faster, while(1), or while(2)?"
I told him that there should be no difference since they both evaluate to true and any decent compiler would optimize it out anyway.
But the interviewer said confidently:
>"Check your basics. while(1) is faster than while(2)."

He was not testing my confidence.
Needless to say, I didn't get the job.
What the fuck.
>>
>>52314138
there's
a shitty python library probably not even written in python
for that
>>
>>52314215

Aren't you glad you aren't working for someone who doesn't know how to program but manages programmers?
>>
>>52314145
Dunno who coined the term, not an etymologist.
But if you search around the CS literature for "computer translator" or "computer language translator" you'll come across 3 common types of translators:
assemblers
compilers
interpreters
>>
>>52314215
On the bright side, at least you're not working there now.
>>
>>52314260
>translator
I was quoting your definition of interpreter anon
>>
So... I need a cross-platform library to display desktop notifications. Anyone?
>>
>>52314323
SDL
>>
>>52314330
SDL doesn't have any utility to display desktop notifications you liar
>>
>>52314351
It give you a nice platform-agnostic way of drawing graphics.
>>
>>52314351
That's true, but creating a window and writing some text in it is pretty easy.
>>
>>52314351
All you have to do is make a borderless window with whatever you want. Never specified it had to be native desktop notifications.
>>
>>52314323
There are none. Windows handles desktop notifications completely differently from Linux, and I'm also pretty sure that X handles them completely differently from Wayland.
>>
>>52314391
There are notifications in X and wayland?
I thought you have to target a toolkit for that.
>>
>>52314375
I don't want to draw graphics. I want to send a dbus message on linux, a winapi call on windows and a NSUserNotification on OS X without having to write them all myself (plus all the testing)

>>52314383
>>52314386
If you were thinking about writing my own notification system from scratch then consider suicide. I get cancer every time I have to see one of those.

>>52314391
That's exactly why I want the third party library. It's quite clear on each platform, but I don't want to do all that development myself.
>>
>>52314301
As I said, dunno who first came up with it, maybe John Mauchly's 'shortcode'.
>>
>>52314420
Honestly I don't know. I think it's server-level, but the handling of how its displayed is WM/DE level - for example both Awesome and Xfce display desktop notifications, but if both are running at once only Xfce will.
>>
>>52314428
If you just want to support those 3 platforms in this one specific way, just add some compiler directives #ifdefs for each platform you want to support
>>
>>52314420
Not really
Linux: https://developer.gnome.org/notification-spec/
OS X: https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSUserNotification_Class/
Windows: Some winapi shit
>>
>>52314463
Too much development on my side. I just want to display a notification, and all that would be wasting my time and more maintenance burden.
>>
What's the best c/c++ ide?
I would use Clion but I'm a poor bastard and couldn't find any license keys. I tried Code:Bollocks, but somehow it feels strange.
>>
>>52314221
from math import pascal
print(pascal(15))
>>
>>52314428
I think Qt has a universal 'desktop notification' module that uses the native notification system on both linux and windows
>>
>>52314351
Actually yes it does.
#include <stdlib.h>
#include <SDL.h>

int main(void)
{
system("notify-send 'This is a notification.'");
return 0;
}

Compile with
gcc -o notifysdl notifysdl.c `pkg-config --libs --cflags sdl2`
>>
>>52314496
Qt
>>
>>52314494
JUST DRAW A BOX ON THE SCREEN
it's much easier than dicksucking the API of every platform you want to support.
>>
We all technically code in machine code, because everything we say is translated by machine code into machine code which is executed by machine code.
>>
>>52314526
Is this a joke?
>>
>>52314494
>#ifdef is too much development
O-Ok anon
>>
>>52314526
that's linux specific you idiot
>>
>>52314539
This isn't exactly true. For example, C# code on Windows never makes it past the windows api.
Lua code is, unless specifically compiled into binary machine code, run 'atop' the interpreter, and thus never gets turned into machine code.

Ironically, Haskell is always compiled to machine code.
>>
>>52314449
>dunno who first came up with it
In any case it's not what the term means today
>>
File: .gif (403 KB, 245x118) Image search: [iqdb] [SauceNao] [Google]
.gif
403 KB, 245x118
>>52314526
>system
>>
>>52314507
Yeah, I thought Qt had everything but I'd rather avoid pulling in the whole framework. I thought about using libnotify, but after looking at the source it's freedesktop/dbus-specific.

>>52314537
Just kill yourself already with those shitty half-assed solutions

>>52314550
#ifdef isn't. Developing and testing on each platform is. By using a library I can simply call the same function everywhere and simply test once in each of them. Also way less code paths to maintain
>>
>>52314582
>>52314494
>add #define "muliplatform.h"
>multiplatform.h
>#ifdef __APPLE__
>#import ....

In your notification bar, add #ifdefs in your notify function.

THE END
>>
>>52314215
What the fuck. Did he explain why he thought that?
>>
>>52314572
But it is.
>>
>>52314587
>>#import
u wot
>>
>>52314606
#include

whatever
>>
>>52314587
Cool, that's the obvious part. Now read documentation about each platform, make sure to update the build system, try it everywhere, build everywhere, develop all three implementations, debug them, and then actually show the motherfucking notification.

Again, stop posting and leave
>>
>>52314618
deploying it on two other platforms would take you literally an hour at most
stop being lazy, anon
>>
>>52314618
You're just sending a single call to the system's inbuilt notification API, correct?
That shouldn't be more than a few lines of platform-specific code which is all neatly fenced between behind compiler directives.

You're just too lazy to do things the correct way.
>>
>>52310681
To be fair, Java does suck though.
Source: 14 years lost to the hell that is a career in software development
>>
>>52314618
>I don't want any half-assed solutions
>nor do I want to do any work
>but tell me how to do this faggots
>>
>>52314634
I simply refuse to touch the winapi and objective-c shit. I'd rather just write the proper code for the freedesktop interface and "system()" some OS X tool to display it.

>>52314640
Not exactly. Those APIs are in different languages with different designs. I'd need to go through 2 layers of FFI to actually use it (I'm not writing C but I can write bindings for it rather easily).

>>52314683
Get a job retard
>>
>>52314599
Never argue with dumbass.
>>
Is it really too much to ask to be able to write Common Lisp for a living?
But nooooo, I have to fucking wade through this cesspool of Python, VBA, C, and JavaScript.
>>
>>52314603
Source please. Wikipedia has a different definition, which generally does a pretty good job of showing the definition of terms most widely adopted. Source for your own definition being more correct or stop claiming it's valid. Might as well be claiming GNU/Linux cannot be referred to as "linux" because stallman said so.
>>
I remember doing notifications using pure WinAPI. Never again. I had to keep a hwnd to receive events from the notification("what, your application doesn't have a window? Too bad, make an invisible one") and some other retarded shit with structs. It was physically painful to code. I can't even understand that code now. They added new API in 8, it's worth checking out.
>>
>>52311498
> vim + compiler
Just go evil mode.
>>
Is common lisp still a meme?
>>
>tfw programming an adblocker blocker
>>
>>52314867
It still is.
Is there a lisp without that retarded head-tail terminology that operates on more sane collections with more POLA methods? I'd even trade homoiconicity for that, lisp macros are awful.
>>
>>52314867
https://drmeister.wordpress.com/2015/11/23/why-common-lisp-for-scientific-programming/
>>
>>52314867
It isn't a meme, it is a gift from god (aka John McCarthy)
>>
>his language of choice can't compile to PDF
why live?
>>
>>52309712

C - Low level, human readable.
C++ - Advantages of C, with language constructs to support code reuse
Python - Extensible,Legible, Friendly to new users.
Java - C like, with a cross platform VM
Erlang - Highly scalable and reliable
Haskell - A community of dicks...
>>
>>52310569
Explicit is NOT better than implicit.

Go away.
>>
>>52314955
>A community of dicks
What? It's commonly cited (and I will attest) that it is the opposite
>>
>>52314955
>C++ - Advantages of C, with language constructs to support code reuse
C++ misses all of the core advantages of C.
>>
>>52314955
Lazy infinite collection of dicks.
>>
>>52314922
Common lisp has collections.
Just because the the syntax is list and lisp has many operations on modifying lists doesn't mean you should use list.
You should use right tools for the task be it vector, hash table or whatever.
>>
>>52314985
Like? Oh boy, I have to cast pointers now. Or what? If you are about to tell something about the standard library, fuck off.
>>
>>52311118
This. Inferring beyond this is mother's prejudice. How can one not see that?
>>
>>52315013
>i have to cast pointers now
just use macros, you dumb shit
>>
>>52315013
>Easy to implement
>Stable ABI
>Encourages programmers to use simple and direct constructs
>Maps somewhat obviously to assembly (before optimisations)

C++ has none of those things.
>>
Start your day off right with a hime thread!

NEW THREAD
>>52315068
>>52315068
>>52315068
>>
>>52311260
Can't blame you but for clarity's sale, all this stuff happened because of iPhones and the woman's bias to defend things she doesn't understand. Her son compartmentalized that action and now defends against things he doesn't understand.
>>
>>52315066
I hoped we'll discuss the syntax, not the implementation. Don't bother replying.
>>
>>52315076
>under bump limit
faget
>>
>>52315076
Not ready for a new thread now, you dick.
>>
>>52314743
>Wikipedia has a different definition
Are you blind?
It agrees with what I said: https://en.wikipedia.org/wiki/Translator_(computing)
>>
>>52315103
>Thinks syntax is that important
Come back after you've finished CS101. Also, C++'s syntax is fucking horrible, I don't know how anybody could argue otherwise.
>>
So... Pretend I'm 6 years old.

What the fuck is Haskell for?
Beside academic lube.
>>
>>52315132
Implementation is a given.
>C++'s syntax is fucking horrible
It's richer than C's. That alone makes it better.
>>
>>52315122
>translator
We're talking about interpreter anon.
>>
>>52315151
It's the programming equivalent of painting.
It doesn't serve any purpose to society from a pragmatic standpoint, but occasionally something really beautiful gets made.
>>
>>52315151
Go back to reddit anon-chan.
>>
>>52315184
Look at the third type listed (or just read the whole text).
>>
>>52315151
Implementing compilers for programming languages.
Implementing proof assistants to help further the study of mathematics.
>>
>>52315151
It inspires other languages. Apparently, C#'s LINQ is monad-inspired. Who knew.
>>
>>52315166
>Implementation is a given
What the hell do you mean by that? Also, how the fuck is ease of implementation not important? Why do you think C was so popular to begin with? It could run on fucking anything.
>It's richer than C's. That alone makes it better.
C++'s syntax is an absolute clusterfuck. I can't even fathom how anyone can think otherwise.
#include <iostream>
#include <chrono>
using namespace std;

int main()
{
cout << chrono::high_resolution_clock::period::den << endl;
auto start_time = chrono::high_resolution_clock::now();
int temp;
for (int i = 0; i< 242000000; i++)
temp+=temp;
auto end_time = chrono::high_resolution_clock::now();
cout << chrono::duration_cast<chrono::seconds>(end_time - start_time).count() << ":";
cout << chrono::duration_cast<chrono::microseconds>(end_time - start_time).count() << ":";
return 0;
}
>>
>>52315232
It's not "monad-inspired", it is a monad.
>>
File: translators.png (79 KB, 1207x470) Image search: [iqdb] [SauceNao] [Google]
translators.png
79 KB, 1207x470
>>52315184
>>52315210
>>
>>52315232
LINQ was essentially an attempt to port F#'s functionality into C#'s syntax.
F# was essentially an attempt to bring Haskell's code beauty into the real world by making an actually useful programming language with it.
>>
>>52315234
>implying the standard library is syntax
>using std and not chrono
>>
>>52315245
LINQ is a monad? How so?
>>
>>52315151
Once you get used to it you feel really productive. Not even kidding, I feel I can write some things way faster in it than in any other language (only if it doesn't include GUI stuff)
>>
>>52315210
What about it?
>explicitly execute stored precompiled code[1] made by a compiler which is part of the interpreter system.
I don't see any translating being done here, except to other code that is not what is being interpreted.
>>
>>52315234
Seems concise enough for me. The cast is done as a template for some reason. Templates are good for optimization though.
>>
>>52315263
>useful
There's that word again.

>>52315273
LINQ's operators are defined in terms of the monadic operations "unit" (constructor, FromResult, etc.) and "bind" (SelectMany).
>>
>>52315273
You can define these operations:

// functor
IEnumerable<T2> Map<T1, T2>(IEnumerable<T1> xs, Func<T1, T2> f);

// pointed functor
IEnumerable<T> Pure<T>(T x);

// monad
IEnumerable<T> Join(IEnumerable<IEnumerable<T>> xss);


This, plus some laws is the definition of a monad
>>
>>52315340
>Join(

should be

>
Join<T>(
>>
>>52315332
Yes it's true, I forgot the SelectMany.

>>52315340
Map is already there, it's caleed select.
Pure, it's
new T[] {x}

Join is selectmany as said the previous anon.
>>
>>52315332
Not really, you need more stuff (catamorphisms for folds, anamorphisms for unfolds, etc)

>>52315377
Yeah, my point is that that's all you need to say that your thing has a monad instance
>>
>>52315256
Interpreters can be translators yes, but they don't translate to machine code. And they certainly don't have to be translators. Not sure how you are thinking any that justifies your definition of interpreters being translators.
>>
>>52315332

So JQuery is a monad?
>>
>>52315414
Yes, actually.
>>
>>52315294
>What about it?
It literally lists an interpreter as a type of translator.
>I don't see any translating being done here,
The interpreted source input to executed instruction IS the translation.
>>
>>52315395
But for me, I never see it as a monad. I see it as SQL, which is a monad. But I never see SQL as a monad.
>>
>>52315422

Or monadic?
>>
>>52315414
In fact everything is a monad.
>>
>>52315399
>Interpreters can be translators yes

>Not sure how you are thinking any that justifies your definition of interpreters being translators.
>>
>>52315437
It's hard to quantify, since JS doesn't have a notion of types. A type constructor is a monad, a value of that type constructor applied to some type is monadic.
>>
>>52315414
You can come up with a monad for the callback stuff for example. It's called the continuation monad, which actually allows you to implement pretty much any monad on top of it. Together with do-notation, this allows you to write fully asynchronous code with all kinds of finalization and exception handling machinery just like regular, good old imperative code. This even includes loops (which are higher order functions over an arbitrary monad).
>>
>>52315458
>Some cars can burn petrol
>Therefor the definition of a car must include that they burn petrol
>>
>>52315428
Well, the whole point of the monad abstraction is to be able to quantify over any monad. C# has a problem here, and it's the fact that it doesn't support higher-kinded generics (and you pretty much need them to represent this abstraction).

>>52315456
No, but you can actually built a free monad from any
* -> *
-kinded type. It's useless by itself, but together with an interpreter this lets you write DSL's with zero effort
>>
>>52315456

Is the term 'monad', just a fancy term for 'continuation passing'?
>>
>>52315527
Cool strawman.
>>
>>52315533
As soon as you have exception, you're in a monad. And I know no language without exceptions.
>>
>>52315542
It's exactly what you said. You said a interpreter is a translator, and backed it up with stuff saying interpreters can be translators. They are certainly not always, as the wikipedia definition tells you.
>>
Anyone tried C#'s "expression trees"? Is there any use?
https://msdn.microsoft.com/en-us/library/bb397951.aspx
>>52315566
C.
>>
>>52315537
Monads are an "interface" for it.
>>
>>52315542

That's not a strawman argument in this context. Read it back. It's a good simile.
>>
>>52315537
No, continuation-passing is a monad. Not all monads are about continuation passing (although the continuation-passing is a really interesting one)

>>52315566
Every language has the Identity and IO monads too. And?
>>
>>52315590
C has exception. It could do a a null ref exception (segfault). You never know if a function will return or trash your application. That's a monad.

>>52315616
I was talking about the monad error or exception.
>>
>>52315586
>It's exactly what you said.
No.
>You said a interpreter is a translator,
Yep.
>They are certainly not always,
Interpreters are always translators by definition.
>>
>>52315650
Exceptions and errors are very different.
>>
>>52315650
Dereferencing NULL is not an exception. It's just undefined behaviour.
>>
>>52315602

Sometimes, just sometimes, this these threads work...
>>
>>52315682
If a function can fail it's the proof that we're in an error/exception monad.

>>52315691
Undefined behavior means that we're outside of the type of the function => monad.
>>
>>52315709
That's what a monad is, in all practicality. It's just a common interface to a bunch of otherwise mostly unrelated things: error propagation, futures, continuation passing, region-based memory management, capture avoiding substitution, and the list goes on. Then you have things like do-notation and comprehensions, as well as plenty of library functions, that can be used for any monad.
>>
Enjoy

http://haddock.stackage.org/nightly-2016-01-08/tardis-0.3.0.0/Control-Monad-Tardis.html
>>
>>52315712
>Undefined behavior means that we're outside of the type of the function => monad.
Undefined behaviour doesn't mean anything. That's what makes it 'undefined'.
>>
>>52315984
It's a monad. I'm sorry for you if you don't get it.
>>
>>52315814
>The State monad transformer features a forwards-traveling state. You can retrieve the current value of the state, and you can set its value, affecting any future attempts to retrieve it.
6The Reverse State monad transformer is just the opposite: it features a backwards-traveling state. You can retrieve the current value of the state, and you can set its value, affecting any past attempts to retrieve it.
whoa
>>
>>52316011
Get your head out of your ass.
>>
>>52316045
>Haskell - A community of dicks...

>Haskell - A community of dicks...
Thread replies: 364
Thread images: 27
Thread DB ID: 383128



[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | 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.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.