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

/dpt/ - Daily Programming Thread

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

Thread replies: 324
Thread images: 27

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>62004107

What are you working on, /g/?
>>
File: 000111-VirtualBox.png (87KB, 669x1345px) Image search: [Google]
000111-VirtualBox.png
87KB, 669x1345px
can a memelang like python or go do anything this powerful?
>>
File: 1502832350889.jpg (239KB, 961x816px) Image search: [Google]
1502832350889.jpg
239KB, 961x816px
data Cow = Cow {
name :: String
, age :: Int
, weight :: Int
} deriving (Eq, Show)

type Valid = Either [String]

noEmpty :: String -> Valid String
noEmpty "" = Left ["Input cannot be empty"]
noEmpty str = Right str

noNegative :: Int -> Valid Int
noNegative n | n >= 0 = Right n
| otherwise = Left ["Number cannot be negative"]

mkCow :: String -> Int -> Int -> Valid Cow
mkCow name age weight = Cow <$> noEmpty name
<*> noNegative age
<*> noNegative weight


*Cow> mkCow "" (-1) (-1)
Left ["Input cannot be empty"]


Is there a reason Either's Applicative doesn't mappend Lefts?
>>
>>62011075
thanks for using anime image
>>
File: 1500898319001.png (26KB, 713x611px) Image search: [Google]
1500898319001.png
26KB, 713x611px
What's the worst code you've ever written?
Triangle:= VideoBuf^[(((mposx-155) div 8)-1)+(((mposy-167) div 9)-1)*ScreenWidth] shr 8 and 15;

>Man, I'm too lazy to write a function to put pixels on the screen, I'll just edit the buffer directly and test this real quick
t. me a couple of years ago
>>
>>62011101
you should turn that into a bitsieve, friend

also, for future questions these bounds are nice in conjunction with a sieve https://math.stackexchange.com/questions/1270814/bounds-for-n-th-prime
>>
wow what the fuck rand() is not [0.0, 1.0] ?
C has no such function for floats?

I am starting to hate this language.
>>
>>62011170
Are you literally too dumb to breath by yourself?
>>
>>62011119
Because it needs to be applicable across all types, not just monoids. There's no way to specificy in Haskell "mappend if its a monoid, or do nothing if it isn't", mainly because you could have some parametric type where you don't know if its a monoid or not.
>>
>>62011192
They could have just tacked on the monoid dependency, like the instance for tuples does.
>>
>>62011170
(float)rand() / RAND_MAX

That sure was difficult.

If you want to use some random functions that aren't completely shit, but the POSIX drand48() or some shit.
>>
>>62011197
a = Identity a
Either e a = Except e a
r -> a = Reader r a
(a,w) = Writer w a
s -> (a,s) = State s a

For the majority if cases, you don't need your exception type to be a monoid. But you always want your writer type to be a monoid. That's why the tuple has that dependency.
>>
>>62011200
does not change the fact that C is very easy to dislike
>>
>>62011134
probably like ~year ago when i was using crystal with it's strange type system, so e.g. you have an int var, then assign a string to this var so it becomes like [Int | String] and now you need to do .to_string to use string methods. At least that's how i remember it
>>
>>62011296
>that doesn't change my stupid opinion
ftfy
>>
>>62011235
That's fair; I'd assumed that monoids for plural failure would be a common or intuitive use case, though.
>>
Does anyone know of any good resources or tutorials for learning software security?
I'm a brainlet who's only ever done shitty math scripts in python and I want to branch out.
>>
How does /g/ feel about the trend of new compiled languages that try to feel like scripting languages? Nim as fast Python, Crystal as fast Ruby, etc. They seem popular on shithub but I'm skeptical whether they have a chance to take off.

The one I think was most interesting was some bizarre free-software Rebol kind of thing. Seems like it's being written by an idiot though, he's implementing the UI toolkit before the rest of the standard library.
>>
>>62011392
>the trend of new [...] languages
This is natural, everyone likes building languages. It feels like the second most complicated things to do after operating systems. The issue is the design is actually way more complicated than the implementation. Syntax has to serve semantics and all modern languages feel like they are built around syntax. See Pascal or older ML for an example of programs with a grammar that try to describe the semantics. Homoiconicity is the ideal version of this but it limits possible optimization.
tldr they're unironically all memes.
>>
>>62011170
retard
>>
>>62011413
That doesn't really address the idea behind them though, it looks more like they want to rehash existing designs intentionally.

Then there's Rebol and it's new freetard dialect. That language is just fucking weird.
>>
>>62011392
Nim somewhat reminds me pascal. At least it has some nice features like templates and work with AST in it's standard library. Also, LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR
>>
>>62011075
How does one accurately control the difficulty of a blockchain mining algorithm? I've tried sha256, md5 and a number of other methods but they're all "uneven." i.e. increasing/decreasing the target has random effects on the difficulty of the mining procedure. I need to be able to tell the mining difficulty for sure.
>>
>>62011075
Trying to understand programming but never done it before I feel like I got into something i shouldn't have.
>>
>>62011594
>Also, LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR
If this means they could just develop an implementation of Python that compiles to fast native code, they must be fucking morons, then.
>>
>>62011101
Hm eratosthenes sieve is quite basic, you could do much faster by using quadratic sieve. At any rate it may not be in your best interest to use fixed-width types. If you want to ensure at least 64 bit ints then use unsigned long long. Also, don't forget to use the same type for indices as that which you compare them against in the predicate of your loops.
>>
>>62011594
>LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR
There is an overhead from what you call interpreting. Then there's the very efficient JIT module, but again it pretty much requires having LLVM installed on the client computer.
>>
Carmack was right.
The true path to enlightenment is to write everything yourself, at least once. No matter how trivial, write your own libraries for everything, from string manipulation to vector matrixes.
Only then will you truly understand what's what.

I did a couple of attempts of writing my own graphics rendering from scratch and even that small experience gave me many insights to WHY things are done the way they are.
>>
>>62011739
>couple of attempts of writing my own graphics rendering
Tell us more about your GPU driver
>>
>>62011679
There is one by dropbox, but it's 2.7 and deprecated
>>
>>62011742
>computer graphics = hardware acceleration
Retard.

That's why I'm smarter than you.
>>
>>62011739
what if you are a lazy fuck?
I wish I had your drive, I feel like a hack...
>>
>>62011765
>to write everything yourself
You sure are.
>>
>>62011742
>look mom I can fill triangles
>>
File: 1487194759108s.jpg (7KB, 250x206px) Image search: [Google]
1487194759108s.jpg
7KB, 250x206px
>>62011771
This is what happens when someone who doesn't even understand the topic at hand tries to argue.

Pro tip, you don't need a GPU or dedicated hardware to draw pixels to a screen.
>>
>>62011790
Oh, so you're doing software rendering and calling that "graphics".
Even more pathetic.
>>
>>62011075
burn in hell for not using an anime image
>>
>>62011790
>when someone who doesn't even understand the topic at hand tries to argue
Except unlike you I've actually written a GPU driver. You can keep feeling enlightened, dumb frogposter.
>>
>>62011652
help
>>
>>62011813
Apparently, you're still too dumb to understand what "computer graphics" or you're a gamer kiddie or whom "graphics" is equivalent "vidya cards"
You went full retard, now stop trying to save face.
>>
>>62011805
it's anime
>>
>>62011830
>trying this hard to invert roles
You were the one acting all defensive in >>62011765 but whatever. Now reply to this so you can have the last word and I can be done with you.
>>
I'm using C# to capture an image but I have it hot keyed to the print screen button (It's kinda like puush but for my own website so I'd prefer to keep it that way), but because of this I cannot copy the link to the clipboard presumably because windows is copying the snapshot instead. Can you guys think of a way around this?
>>
File: d20.jpg (20KB, 420x420px) Image search: [Google]
d20.jpg
20KB, 420x420px
>>62011770
I'm also lazy as shit, the trick is to do something funny and personally stimulating as an excuse to learn those concepts.
Think of it as an art project rather than something you need to be "good".

>>62011861
Sure, I'll humor you with a (You), if you're so desperate. Now go be butthurt somewhere else.
>>
>>62011797
I bet you were born like a decade after 3dfx was founded.
>>
Is it feasible to train a neural network with lots of censored 2D anime girls and the corresponding uncensored versions to create an automatic decensoring software?

Asking for a friend.
>>
>>62011974
It is. I'd even say it's on the easier side of ML.
>>
>>62012040
Would you have to stick to one specific censoring method (like mosaic)? Or would it work to train it universally for all of them.

I'm not really sure how these things work, like how big of a training data set you'd need for decent results.

I'm gonna look into that waifu2x project.
>>
>>62011974
Didn't someone already do that exact thing in these threads?
>>
>>62012191
If they did it must've been very unsuccessful or everyone would know about it.
>>
File: 1475339581250.png (34KB, 259x309px) Image search: [Google]
1475339581250.png
34KB, 259x309px
What programming language goes best with pink-and-white stripped socks?
>>
>>62011101
Color scheme please
>>
File: IMG_20170821_111322.jpg (224KB, 890x1280px) Image search: [Google]
IMG_20170821_111322.jpg
224KB, 890x1280px
>>62012257
LISP or any derivative like Clojure
>>
>>62012248
He only posted about it a few times, and it was several months ago.
He said the vaginas it was generating looked weird.
>>
>>62012257
>>62012417
>Le fag socks
Stop posting this fucking shitty forced meme.
>>
File: 000112-VirtualBox.png (75KB, 877x340px) Image search: [Google]
000112-VirtualBox.png
75KB, 877x340px
>>62012298
>>
>>62012455
Thanks, sexy son of a gun :33
>>
>>62011101
What do you plan on moving to, after c?
>>
>go to mediocre state school
>learn c++
>transfer to '''''good'''" school
>they use java
why
>>
>>62012602
Because the language (they use for introductory stuff) doesn't matter, it's just a tool.
>>
>>62012613
Why would anyone voluntarily use java?
>>
>>62011739
So a raytracer. Now do photon mapping or radiosity.
>>
>>62012625

I would say because of an absolutely massive number of job opportunities for Java developers which could help you, you know, get a job and earn some money (for instance to pay those ridiculous loans of yours)
>>
doing wordpress migrations and plugin development
pls kill me
>>
>>62012851
A colleague of mine had to work with wordpress for uni.

I feel your pain.
>>
>>62012878
i have to do it to survive (no degree and clients want wordpress because they're retarded) i make good money but it kills me inside. i cant wait for the weekend to bust some arm64 assembly :D
>>
>>62012417
dumb rust shill, don't drag lisp into your gay shitposting.
>>
File: 1491014298907.png (576KB, 531x720px) Image search: [Google]
1491014298907.png
576KB, 531x720px
>VS Code
>Doesn't know the difference between .C and .c files
lmfao
>>
File: gen eq.jpg (27KB, 647x415px) Image search: [Google]
gen eq.jpg
27KB, 647x415px
>>62007851
>>
>>62012963
wth dude
>>
>>62012963
How's your first day in /dpt/?
>>
File: Lists.png (15KB, 652x235px) Image search: [Google]
Lists.png
15KB, 652x235px
>the procedure list-ref takes as arguments a list and a number n and returns the nth item of the list
>For n = 0, list-ref should return the car of the list. Otherwise, list-ref should return the (n - 1)st item of the cdr of the list.
Those statements clearly contradict each other!
Why would someone want to number the first element with 0 anyway?
>>
>>62013175
>Posting tired and forced memes make you le oldfag
Piss off, fag enabler.
>>
>>62013309
Enjoy your stay, fagboi :^)
>>
File: Wew .net Core .png (38KB, 960x352px) Image search: [Google]
Wew .net Core .png
38KB, 960x352px
Fucking Microsoft can't even use their own rules. People that think it's ok for their program to use .files or .folders should get gassed. The same goes for using %userprofile% or ~ to store your config files.
>>
Which one would you prefer?
#include <iostream>
#include <string>
using namespace std;

int
main(int argc, char** argv)
{
for (int i = 1; i < argc; i++) {
cout << stoi(*(i + argv)) << endl;
}
return 0;
}

or
#include <iostream>
#include <sstream>

int
main(int argc, char* argv[])
{

std::stringstream convert(argv[1]);
int myint;
if (!(convert >> myint))
myint = 0;

std::cout << myint << std::endl;

return 0;
}
>>
>>62013370
I never understood why people use C# over real languages like C++ really
>>
>>62013384
First one, but please stop using
char* str
style.
>>
>>62013400
>please stop using char* str style
What's the alternative?
>>
>>62013425
Switch to a programming language that doesn't require identifiers.
>>
>>62013425
char *str

The * is part of the declarator, not the type specifier.
>>
>>62013435
If the type is not declared the program is either monumentally slow or massively bloated
>>
>>62013448
char* is a type, no?
>>
>>62013435
For example?
>>
>>62013388
Support for modules, GC, fully defined ABI for compatibility between different compilers.
>>
>>62013466
Sure is, but C doesn't declare identifiers by naming their types. That's too easy.
>>
>>62013478
C++ has all 3, with clang
>>
>>62013466
char* is actually char *(unnamed variable). I know it's stupid but that's what C programmers like.
>>
>>62013468
Scratch
>>
>>62013466
Using char *x rather than char* x is mostly considered a better practice because in e.g. char* x,y one might think thay both x and y are pointers, but x is a pointer and y isn't, which is kinda confusing, but with char *x, *y everything is obvious
>>
>>62013495
>fully defined ABI for compatibility between different compilers.
>C++ has it with this one specific compiler
:thinking:
>>
>>62013495
Clang is a compiler, C++ is a language.
C++ does not have those things. Nothing that a compiler does can fix this.
>>
>>62013509
>C#
>Compiler
:thinking harder:
>>
Is there any way I can do something like this
#if __FILE__ == __MAIN__
int main()
{
...
}
#endif

So that I can run tests if I compile the library separately and remove them when I am compiling the library into my program?
>>
>>62013516
>C++ does not have those things
Clang has modules for C++, you can add a GC to your C++ (I don't know why you need GC), and C++ has a standard ABI
>>
>>62013532
The only standard ABI C++ has is extern "C".
>>
>>62013542
Which is more supported than C# ever was, and will be
>>
>>62013532
>C++ has a standard ABI
laughinggirls.jpg
>>
>>62013532
>C++ has a standard ABI
Prove it. I know for a fact that name mangling is different for Clang and MS compilers.

>I don't know why you need GC
Me and hundreds of thousands of other programmers using GC languages*

>>62013561
C# defines name mangling at standard level, unlike C++ which does not.
>>
>>62013562
>C# has a standard ABI
laughingpajeets.jpg
>>
>>62013532
As for
>Clang has modules for C++
Again, this is not C++. Failures of C++ are not mended by demonstrating a language that looks like C++ but isn't actually C++.
>>
>>62013568
>>C# has a standard ABI
>laughingpajeets.jpg
Never said that but C# runs on virtual machine so the CLR bytecode works as standardized ABI.
>>
>>62013584
That's not what standard ABI is
>>
how do I properly into graphics and sound programming?

opengl articles seem to be based on old as fuck versions and the new extensions and stuff is so convoluted i dunno what should be used or disregarded

audio i know how to beep with \a character (where the fuck is this so called mobo speaker anyway), i wanna play and even synthesize some music
>>
>>62013388
Because c++ has to many quirks and c# is just easier to create programs with on Windows.
>>
>>62013597
If I know a function signature, can I call that function?
>yes
standardized ABI
>no
no standardized ABI
>>
>>62013582
Modules is proposed already though, C++ may eventually get modules support, one less reason to use C# ever for any reason
>>
>>62013624
Wtf, that's not what standard ABI is
>>
>>62013607
Python is easier to program than C#. What's the point of using it over python?
>>
>>62013532
>C++ has a standard ABI

HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHUAHUEHUEHUEHUEHUEHU
>>
>>62013626
Well done. I hope this has been a fruitful discussion and you now understand why people might want to use C# over C++.
>>
>>62013626
Modules won't make all the old C++ code switch to using modules.
I have no idea how modules are going to work with C++'s linkage model, I'll have to relearn all that shit.
>>
>>62013532
>you can add a GC to your C++ (I don't know why you need GC)
Maybe you should expand your programming horizons a bit more then.
>>
>>62013647
>Modules
Is that why people use C# over C++?
>>
>>62013639
ABI defines the calling convention and how data is stored.
CLR must be well standardized because there exists multiple languages that compile to the bytecode.
>>
>>62013642
I find C# easier than Python desu
>>
>>62013644
>C# has a standard ABI
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHUAHUEHUEHUEHUEHUEHUHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAAHAHAHAHAHAHAHAHUAHUEHUEHUEHUEHUEHU
>>
4-14 of the C 2nd book? I am currently getting paid to practice programming. Boss wants me to become a debugger down the road. Literally learning to program properly is my job and I was very confused for a long time.
>>
Does clang support concepts yet?
>>
>>62013657
Among other things. I listed some for you before. If you're interested, scroll up and have a read.
>>
>>62013672
What other things? C++ is supported in more platforms VM langs like C# can almost never touch
>>
>>62013680
This is retarded.
>>
>.NET itself is written in C/C++
kek
>>
>>62013687
>cross-platform compatibility is retarded
pajeets, everyone
>>
File: c-baby.jpg (248KB, 808x805px) Image search: [Google]
c-baby.jpg
248KB, 808x805px
WHY DID C HAVE TO DIE?
>>
>>62013701
C will never die. C is ageless.
>>
>>62013701
Well, C++ (and now Rust) gives nearly the same results
>>
>>62013697
The post I replied to was retarded. Considering your reading comprehension level, you might be too.
>>
>>62013715
>I got owned: the post
>>
>>62013715
what
>>
>>62013708
>rust
Fuck off SJW.
>>
>>62013737
C, C++ and Rust are on a different level entirely.
>>
>>62013680
You can find the post where I listed them and have a read. Do note that supported platforms and standardized ABI have nothing to do with each other.
>>
>>62013722
>>62013729
I'll spell it out for your primitive brains then. Porting a VM to a new architecture requires less work than porting a compiler back-end. Now go fuck yourselves.
>>
File: 1503050907210.jpg (344KB, 1605x655px) Image search: [Google]
1503050907210.jpg
344KB, 1605x655px
>>62013704
>no updates in years
FUCK
>>
>>62013737
Nothing wrong with Rust, it's low level, has no GC, and in the same ball park of C++ speed, really.
>>
>>62013770
C does not need to be updated, because C is timeless.
>>
>>62013766
Go port your 1GB VM to embedded systems then, dumb pajeet
>>
>>62013766
ehhhh...
Seems dubious, if it's a proper VM with some form of JIT built-in.
>>
>>62013522
>Is there any way I can do something like this

No.

>So that I can run tests if I compile the library separately

You always want to run tests every time your library gets built.

>remove them when I am compiling the library into my program?

Python doesn't remove your tests. They're still part of the code. If the "is it main?" check fails, they become dead code, but will probably remain in memory unless the interpreter optimizes it away.

You could conditionally include another C file into your library code based on whether some symbol like ENABLE_TESTS is defined but that's just stupid and will result in building the library twice.

Write an actual, completely separate testing program for your library. Have it link against it and use it in the course of testing its functions. That's the right way to do it.
>>
>>62013766
Your VM is written in C/C++ that's why lmao
>>
>>62013770
MS cucks can't even support C99, C is waiting for them to catch up
>>
>>62013737
>Muh SJW
>>
>>62013787
>JIT
What? This is only an issue if the JIT compiles to native code, in which case it's not a VM but a JIT compiler.

@62013782
>every VM is JVM-like heavyweight
Stop posting in this thread dumbass.
>>
>>62013770
If your language needs to be update then it's failed language. You wouldn't trust the same retards to update your language because they would introduce new problems, see sepples for example.
>>
>>62013665
It actually does you dumbfuck. It's a virtualized system but the CLR allows full interoperation between shit tons of languages. The JVM supports even more languages running on top of the platform and interfacing with each other. Not only that, both also have bidirectional interface between the host ABI and the virtualized programs

Call me when C++ implements SystemV ABI properly.
>>
When will C/C++ catch up to C# and support JSON/XML serialization?
>>
>>62013819
>oh look guys, it's like 700MB now, so lighter than JVM
Meanwhile Java is faster than C# impls
>>
>>62013819
Multiple Javascript implementations, Java and Microsoft's dot net all compile to machine code in some form or another, and they are still called VMs.
>>
>>62011119
Left indicates failure
>>
>>62013832
well oracle java is worth it, it's a bit faster than microsoft java
>>
>>62013782
>he doesn`t know that zillions of smartcards actually run Java

/g/ really is made of a bunch of meme-parroting retards.
>>
>>62013860
Yeah this is not worth contributing to.
>>
>>62013860
>>62013862
>Java VM and .NET VM is written in C++
kek
>>
>>62013770
C is on track for a new standard every 10 years or so, so keep up with the major changes in technology.
This is not Sepples where they shit out a bunch of random, useless shit onto the language.
>>
>>62013874
Can I use C11 threading yet?
>>
>>62013881
not with glibc.
>>
>>62013881
Yes
>>
>>62013890
https://sourceware.org/ml/libc-alpha/2017-06/msg01413.html
It's likely to be in the next version or maybe the one after.
>>
>>62013848
>Java and Microsoft's dot net all compile to machine code in some form or another
The VM are implemented in machine code. The JIT'd code isn't run by the VM, so no, the things you describe aren't part of the VM. I think you misunderstand what "VM" means. It's an abstract machine that runs on top of your hardware. When Java compiles to the JVM it's to bytecode which is read by said abstract machine. Same for V8 and Javascript etc. Note that a language is not defined by an unique implementation. There are implementations of some languages that don't require VMs and some that do. Nothing would prevent anyone from running a VM that reads bytecode compiled from C.
>>
>>62013881
musl-libc supports C11 threading
>>
>>62013900
>i-it's ok, the next version will be good
cniles are just as bad as sepplesfags baka
>>
>>62013905
Case in point, the ocamlc byte code compiler exists explicitly to support OCaml on platforms that aren't targeted by the native ocamlopt compiler. Both are implementations of the exact same language. One runs on a VM and one does not.
>>
>>62013918
What the fuck do glibc versions have to do with fucking C standards?
>>
>>62013918
What do you mean? C11 threading is already supported in many libraries, you just have to include them
>>
>>62013935
Probably referring to the fact that no one bothered correcting glibc's (still bugged afaik) implementation of threads because everyone uses pthread on Unix.
>>
>>62013905
The fuck all this has to do with what I said? Porting a proper VM with some form of JIT built-in would be about as difficult as porting compiler backend. That's what I said.
>>
Could one give a book about essentials of C++ for those, who know C?
>>
>>62013965
Step 1) Don't.
>>
>>62013965
the essentials of C++ differ depending on who you ask

the best way to learn C++ coming from C is to fuck around with all the new features until you burn yourself
>>
>>62013963
In what you describe the byte code is nothing but an intermediate language, that's what Java does. The JVM reads the byte code and compiles it if it's JIT'd, it doesn't run it when it's JIT'd. It's still more complicated than having a VM implemented run byte code directly in any language i.e. if the JVM ran byte code directly and if you fail to realize that I can't help you.
>>
>>62014004
>The JVM reads the byte code and compiles it if it's JIT'd, it doesn't run it when it's JIT'd.
That's literally what compiler back-end does, produce machine code from an intermediate language.
>>
>>62013848
They're called virtual machines because they literally virtualize the code they're running. Just because they may choose to selectively compile parts of that code and run it directly on the processor, devirtualizing it, doesn't mean it's not a virtual machine.

Try embedding the JVM into your normal operating system process and calling a Java method. Were it any other language with a SystemV ABI like Pascal or Fortran you'd be just link the symbol and call it from C directly as a function. This is not the case with the JVM. You have to talk to it instead and have it call the method for you. When it comes back, it hands you a completely virtual "jobject" return value, a type that can stand for nearly any value that Java can return. Only the primitives like integers are returned directly. On some other virtual machine implementations they're actually embedded in the pointers themselves.

That's what virtualization is.
>>
File: 7721.jpg (199KB, 719x799px) Image search: [Google]
7721.jpg
199KB, 719x799px
Literally shaking.
>>
>>62014019
Thank you for explaining to me something that I already know. My statement about difficulty of porting a VM that does JIT still stands.
>>
You're all using Eclipse Oxygen as your IDE today, right?
>>
>>62014020
Did mozilla get more money somewhere to spend on shills or why are these poor faggots shitposting so much?
>>
>>62014020
>Being such an insecure autist, you made a bunch of edits of le sad reddit man
You sure showed everybody.
>>
>>62014031
I use CLion. CMake only C++ IDE, Jetbrains.
>>
>>62014029
>if I disregard everything that was said I am right
>>
>>62014034
Why does Mozilla hate anything related to C so much anyway?
>>
>>62014053
not enough pink-haired trans programmers using C
>>
>>62014047
You made on effort to explain how this would make a VM easier to port than a compiler backend.
>>
File: 1502976352738.jpg (54KB, 500x375px) Image search: [Google]
1502976352738.jpg
54KB, 500x375px
Is this accurate?
>>
>>62014053
>If C is shit that would somehow make rust better
Or something like that.
>>
>>62014064
no effort*
>>
>>62014053
They don't hate C. It's just very hard to write safe C code, this is why they encourage the use of Rust instead.
>>
>>62014078
So instead of it being hard to write safe code it is impossible to write sane code at all.
>>
>>62014029
It's easier than you think.

JIT is desirable, but not necessary. You can just disable it on the new platform and focus on making the virtualized code run. You just have to port the virtual machine itself, a much, much easier task than code generation and optimization. The virtual machine is likely written in C, and that language's compiler's already done the hard part. Once it's running stable, you can add a JIT compilation target for the new platform and make it fast.
>>
>>62014097
Well, I meant porting along with JIT part, not disabling it. We want performance after all.
>>
>>62014093
Stop shitposting Anon. Rust is annoying because it forces you to implement error handling for every single thing that can go wrong but it's also the reason why Rust is considered safer than C.
>>
>>62014034
>>62014053
You do realize these are Microsoft C# shills, right?
>>
>>62014064
>porting a program that decodes byte code instructions and runs them: build it for the new target
vs
>porting a program that builds native code instructions: new instructions, ABIs, OS, memory model, other conventions, etc
I'm not here to make your education on compilers and their implementation, I've already been way more patient than the average 4chan user.
>>
>>62013984
> depending on who you ask
Elaborate please?
>>
>>62014115
you heard it here first boys Rust can solve the halting problem
>>
>>62014141
there are many, many styles of C++
>>
>>62014122
Right, there seems to be a misunderstanding, when I said with JIT I meant to have JIT enabled and working for the port, not just disabled.
>>
>>62014141
There exist at least 2 million styles of what people call "C++".
>>
File: memelang.png (40KB, 1620x774px) Image search: [Google]
memelang.png
40KB, 1620x774px
>>62014053
Because their angle is safety and performance while not having to worry as much about gotchas. They're shouting the same thing C++ has been for years so they too can have a foothold in the industry.
>>
>>62014150
And I've been telling you in my last billion posts that JITing makes your program a compiler, not a virtual machine.
Which is harder to implement than the virtual machine part.
>>
>>62014163
There are things that are called virtual machines and include JIT, and I explicitly mentioned VM with JIT in my post.
>>
>>62014176
>JIT
>Just In Time compilation
>Not a compiler
>>
>>62011101
your code is shit desu senpai, is this supposed to be ironic?
>>
>>62014149
>>62014158
I want to know them all
>>
>>62014206
then experiment
>>
>>62014176
Compiling is exactly the process of transforming a language into another (usually lower level) language. This is not the role of a VM which is supposed to be a machine eg run provided instructions. I don't see how I can explain anything if you don't want to accept that. Read my message about how languages aren't defined by their implementation. Nothing prevents you from mixing a VM with compilers but this doesn't change the fact that the VM part is going to be infinitely easier to port than the JIT part.
>>
>>62014181
>>62014216
Yes, VM does compilation. It remains a VM while it's doing compilation, despite doing compilation, and despite (*GASP*) the word Compilation almost being a part of JIT abbreviation. This might be shocking to some but for most it's a reality. Sun's Java VM does this, Microsoft's dot net, and multiple Javascript implementations.
>>
>>62014206
No you don't.
>>
>>62014222
So... you're saying that... every compiler... is a VM?
:thinking to the max:
>>
>>62014222
>It remains a VM while it's doing compilation
It does compilation so that the VM DOESN'T HAVE to run the code but it can be run on the concrete machine (because it is faster)
>>
>>62014243
Where are you getting that from? VM remains a VM even though it does some compilation. Nowhere it is mentioned that all features of VM are present in any compiler and any compiler can safely be called a VM.
>>
>>62014264
The software that is labeled as VM is doing compilation. Yes. Glad we reached an agreement.
>>
>>62014114
Supporting a target architecture isn't the same as optimizing for that architecture. You support the virtualized language, and you optimize it by selectively devirtualizing parts of the programs at runtime at various levels of aggressiveness.

Nevertheless, it's about as hard as supporting and optimizing for a new target architecture in GCC. Dynamic programming language machinery and optimization techniques are pretty different but are still at the same general "requires reading and implementing unreadable CS papers" level of difficulty, so only the top 0.1% of programmers even attempt it. Pretty much any sufficiently-motivated idiot can implement a really simple virtualizing interpreter for any language.

>>62014163
Java has a compiler that emits Java bytecode, the intermediate representation consumed by the Java virtual machine, which either interprets that bytecode or compiles it to architecture's instruction set.

Virtual machine means processor. The JVM is a custom software processor running on top of a real CPU. Not unlike the virtualized x86_64 instructions implemented by microcode.
>>
>>62011101
is this supposed to be """powerful"""?
lmao brainlet code is funny
>>
>>62014294
>which either interprets that bytecode or compiles it to architecture's instruction set
>Nothing prevents you from mixing a VM with compilers
Also the JVM is called so for historic reasons. It wasn't always doing JIT. When the JVM compiles to architecture code, it doesn't act as a VM.
>>
Should I program on Pascal?
>>
>>62014216
Compilation is either producing a byte code for a VM or a machine code for a chip.
>>
>>62014366
explain the purpose of this post
>>
>>62014342
What even is your point anyway?

>>62014348
No.
>>
>>62014378
What's yours? Mine has always been that porting a VM is easier than a (JIT) compiler.
>>
File: 150330661860.gif (929KB, 500x388px) Image search: [Google]
150330661860.gif
929KB, 500x388px
Do there exist programming taskbooks for practice?
I mean, not big tasks involving all the features of learned language but basic tasks to get used to creating algorithms.
>>
>>62014388
Obviously. That's the whole point.
>>
File: 306607.jpg (29KB, 225x350px) Image search: [Google]
306607.jpg
29KB, 225x350px
Remember that Nene says C++ is the best language! You know what to do!
>>
Hey /dpt/, I've noticed that I've got this up down left right pattern all over one of my programs and there seems to be a ton of duplicated lines.
Is there any way to shorten code like
if (input.is_pressed(UP)) {
delta_y = std::clamp(delta_y - 1, -1023, 1023);
calculate_line(delta_x, delta_y, scale, intensity, instructions);
}
if (input.is_pressed(DOWN)) {
delta_y = std::clamp(delta_y + 1, -1023, 1023);
calculate_line(delta_x, delta_y, scale, intensity, instructions);
}
if (input.is_pressed(LEFT)) {
delta_x = std::clamp(delta_x - 1, -1023, 1023);
calculate_line(delta_x, delta_y, scale, intensity, instructions);
}
if (input.is_pressed(RIGHT)) {
delta_x = std::clamp(delta_x + 1, -1023, 1023);
calculate_line(delta_x, delta_y, scale, intensity, instructions);
}

and
if (input.on_press(UP)) {
intensity = 15;
intensity_changed = true;
} else if (input.on_press(DOWN)) {
intensity = 12;
intensity_changed = true;
} else if (input.on_press(LEFT)) {
intensity = 7;
intensity_changed = true;
} else if (input.on_press(RIGHT)) {
intensity = 0;
intensity_changed = true;
}

?
>>
>>62014410
>Obviously
Apparently not, read the replies to >>62013766
>>
>>62014373
>Compiling is exactly the process of transforming a language into another (usually lower level) language.
Because that is incorrect statement. A frontend of a compiler transforms a code of some grammar into another (usually intermediate) language, the compiler as a whole doesn't produces a code, it produces optimised instructions for either a VM or a chip.
>>
>>62014435
I explicitly mentioned including JIT into the VM in the reply. You are upset that there is software that is both 1. named VM 2. includes JIT, but that doesn't make my point any less valid - porting VM with JIT included, not disabled, is not any easier than writing compiler backend.
>>
>>62014419
struct Inputs{
Direction dir;
int dx;
int dy;
} inputs[] = {
{ UP, 0, 1 },
{ DOWN, 0, -1 },
{ LEFT, -1, 0 },
{ RIGHT, 1, 0 },
};

<...>

for( auto inp : inputs){
if (! input.is_pressed(inp.dir)) continue;

if(inp.dx!=0) delta_x = std::clamp(delta_x + inp.dx, -1023, 1023);
if(inp.dy!=0) delta_y = std::clamp(delta_y + inp.dy, -1023, 1023);

calculate_line(delta_x, delta_y, scale, intensity, instructions);
}
>>
File: 1502752496926.jpg (229KB, 574x640px) Image search: [Google]
1502752496926.jpg
229KB, 574x640px
>>62014419
>c++ user does not know about jump tables nor switch cases
sasuga, complexity
>>
Not really programming related, but not worth creating a new thread either:

What's the laziest way I can sandbox/virtualize/chroot my distro(Xubuntu) in order to run some proprietary/untrusted software temporarily? The software will have to link up with Firefox and a USB e-token, so internet access and USB access would be needed for the sandbox.
>>
>>62014503
>jump tables
>switch cases
Don't think either will do in his case, as multiple inputs can be activated at once.
>>
Hello /g/,

I noticed jetbrains IDEs are really fucking slow and I am wondering if installing them into a RAM disk could help.

Do you use RAM disk?
Did you install a jetbrain IDE into a RAM disk? Is it useful?

http://appnee.com/primo-ramdisk
>>
>>62014503
I don't see how since I have some areas where all buttons can be pressed at once, some where only one can be pressed at once, some where the input is on press, others when the input is pressed, and sometimes different variables used for the x/y parts.
>>
>>62014520
I run CLion on a HDD in a virtual machine, and it runs just fine for me.
>>
>>62014503
What C++ has to do with it?
>>
>>62014529
UP and Down are disjoint sets, LEFT and RIGHT too, calculate_line can not be in every if-block since that call isn't different from others.
>>
>>62014447
>the compiler as a whole doesn't produces a code, it produces optimised instructions for either a VM or a chip
That's the only incorrect statement here. See parser generators (also called compiler compilers) for another case. The Typescript compiler is also a compiler.
>>
>>62014514
>what is arithmetic
hell,
>what is a loop
inputs are serial by nature, if your library doesn't accept that it's shit
>>62014539
understanding complex concepts like oop and generics before understanding how to make a comparator is trademark c++
>>
>>62014520
I doubt it has an impact on anything apart from the startup speed. You most likely have a bottleneck somewhere else
>>
>>62014447
>produces optimised instructions
Not every compiler is an optimizing compiler.
>>
>>62014598
I did post code recommending a loop just few posts earlier.
>>
>>62014589
That's a flexible bisonshit, parser generators are generators, not compilers.
>>
>>62014514
Not him but he could turn the idiotic "input" structure, whatever that thing is, into a really simple bit vector for every state. This way, combinations are just numbers and can be used as indexes into an array of function pointers, or even an array of labels you can goto if you're using GNU C.

https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

This is some really cool shit used to dramatically speed up switched code like instruction interpreters, the whole idea of which not being very different from what his code is doing.

https://www.usenix.org/legacy/publications/library/proceedings/jvm01/gagnon/gagnon_html/node4.html
>>
>>62014582
>UP and Down are disjoint sets, LEFT and RIGHT too

That's stupid. All four directions can be pressed at the same time. The hardware supports it.
>>
>>62014610
ah yes of course, the notorious unoptimizing compiler that takes your code and actively attempts to make it slower
>>
>>62014622
Yet that's how they're called. I mean, you're so wrong I don't even feel like explaining. You do realize your compiler produces assembly, not actual machine code right? That's the assembler's job. Even then it's not the final representation since produced object code goes through the linker and loader before running on "the chip".
>>
>>62014625
I understand his desire is to not write 4 handlers, one for each of directions every time, so getting an index into an array of function pointers here is not going to be very helpful.
>>
>>62014610
It depends on a structure of a back-end of a compiler it may and may not optimise. But if they call Webpack a compiler then that anon seems to be right.
>>
>>62013833
The best way of doing this with C# is with a library anyway. I don't see your point.

>>62014117
>shilling for FOSS
?
>>
>>62014646
when was the last time you didn't take left+right the same way as !left+!right
>>
>>62014647
https://en.wikipedia.org/wiki/Optimizing_compiler
Please kill yourself
>>
>>62014666
Crypt of the Necrodancer, a videogame I played yesterday.
>>
>>62014654
Compiler does not produce assembly unless you tell him to do that, e.g. gcc -S, it produces actual binary machine code. A chip doesn't give a damn about assembly, assembly is a bag of human readable mnemonics.
>>
>>62014690
Compilers produce whatever the fuck they want. Your shitty opinion doesn't change the academic truth. What you describe happens because the "gcc" you use is the toolchain driver. Why do you think gas is a separate program? Try to remove it from your system and then run gcc again on a source file. Spoiler: it'll complain it can't find the assembler. Also
>>62014690
>A chip doesn't give a damn about assembly, assembly is a bag of human readable mnemonics
>what are labels to address computation
>>
>>62014654
Linker and loader are needed to run it on OS, not a chip. Not every chip has an OS.
>>
>>62014732
And now you're moving the goalpost. The OS isn't the chip. The compiler builds for the OS.
>>
File: eclipse.png (165KB, 451x289px) Image search: [Google]
eclipse.png
165KB, 451x289px
eclipse is the best IDE
>>
>itt poorfags trying to eat rich programmer food

http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html

educate yourself morons you dont even know what a compiler is
>>
>>62014776
Do you seriously have or want to waste time reading that shit?
>>
File: dokuro-chan_laugh8.gif (101KB, 351x398px) Image search: [Google]
dokuro-chan_laugh8.gif
101KB, 351x398px
>using compilers
Fucking pathetic.
>>
>>62014759
I've already admitted that in the modern terminology compilers can "compile" into JavaScript and other languages.

>>62014731
It's just another layer in the back-end of a compiler, they moved gas outside.

>>62014759
Because linkers and loaders are a part of a binary interface of an OS, a compiler does not have to produce only user-space applications.
>>
>>62014816
So you just don't know what you're talking about. This is pointless, good bye.
>>
>>62014761
Is that like saying horse shit is the best kind of shit?
>>
>>62014868
>This is pointless. Good bye.
That's /g/ in a nutshell
>>
>>62014816
>It's just another layer in the back-end of a compiler
Hmmmmm... I wonder what compiler they moved nasm, yasm, tasm and all these stand alone assemblers outside from...
>>
>>62014868
I perfectly know what I'm talking about but I agree that's good idea for you too keep your ill-bred manners to yourself.
>>
>>62014898
>I perfectly know what I'm talking about
I assure you; you absolutely don't.
>>
>>62014906
Thank's I'll take it into account, your opinion is very important to me.
>>
>>62014916
Cool. As long as you stop spreading your retardation on /g/ I'm glad I could help!
>>
>>62014921
Indeed.
>>
>>62014898
>says assemblers are part of a compiler's back end
>pretends he knows what he's talking about
The empire of /dpt/
>>
>>62014930
If A can't function without B it can very well be said that B is a part of A, even if B is something standalone.
>>
>>62014930
The GNU assembler is a part of the GNU Binary Utilities (binutils), and a back-end to the GNU Compiler Collection.
>>
>>62015059
I'd say no. You have more convenience with C++, not control.
>>
File: 1494857129840.png (164KB, 413x352px) Image search: [Google]
1494857129840.png
164KB, 413x352px
>that one fucking guy who keeping cross-linking /v/ every other thread
>>
>>62015096
Because they have similar skills to her.
>>
>>62015096
Is that the cd code cd.. cd .. cd code cd .. programmer girl?
>>
What the fuck is wrong with java Generics?
>>
>>62015117
Is something wrong?
>>
>>62015117
They don't exist.
With Java 5 Oracle introduced Generics, but they wanted to maintain bytecode compatibility with classes compiled under older versions of Java. Therefore Java Generics are purely a compiletime artifact. The typesafety they introduce is flimsy and easy to subvert, and it's impossible to determine a type parameter using reflection because it simply doesn't exist.
Almost everything wrong with them can be blamed upon the choice to maintain backwards compatibility.
>>
File: morgan4.jpg (62KB, 560x460px) Image search: [Google]
morgan4.jpg
62KB, 560x460px
What does /dpt/ think of Morgan Webb? She's an expert in Java.
>>
>>62014776
this is the most autistic blog post I've ever skimmed over
>>
>>62015117
https://gist.github.com/rgrig/b4cdaed3ed9a70dbdb6f158f14b57263
Nothing, because they can do everything.
>>
>>62015144
>Almost everything wrong with everything can be blamed upon the choice to maintain backwards compatibility.

fixd
>>
I've built a crawler to download images from a site, and now I'm trying to make a gui for it, to look more professional(tm). I've spent whole day tinkering with tkinter, but it turned out it's single threaded and it freezes when I hit the download button. Now I'm trying to learn kivy. Anybody here python+web scraping?
>>
>>62015167
>let's fuck every code base in existence each time we update the language
Rust devs stop shilling on /g/ pls
>>
Just hired a pajeet to do some web scraping.
>>
>>62015169
http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/
>>
>>62015167
correct, C++ wouldn't be so bad if it broke more C features
>>
>>62014761
I use Netbeans
>>
Does C# have an API documentation like Java's? I can't seem to find any.
>>
How do I deal with the quilty feeling when I browse /dpt/ at work?
>>
>>62015285
It's been very popular lately for a reason, but "by far best" is wrong.
>>
>>62015285
?
>>
>>62015285
i prefer lua for scripting in games

also please stop just linking to posts on /v/
>>
>>62015391
Really?
>>
>>62011101
what's with that obese code

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
struct primes {
int size;
int *primes;
} find_primes(int num) {
int *primes = calloc(sqrt(num)+1, sizeof(int));
bool *sieve = calloc(num, sizeof(bool));
int count = 0;
for(int i=2; i<num; ++i) {
if(!sieve[i]) {
primes[count++] = i;
for(int j=0; (j+=i)<num;) sieve[j] = true;
}
}
return (struct primes){count, primes};
}
int main() {
struct primes p = find_primes(100);
for(int i=0; i<p.size; ++i) {
printf("%d\n", p.primes[i]);
}
return 0;
}
>>
>>62014520
IDE's are a bad idea unless you are doing something like Arduino ( which almost requires the IDE ) or some kind of big GUI dependent shit like Android / IOS.

As far as running shity IDEs written in Java, the CPU core count is really what you'll get the most kick from.

My older Dual Xeon workstations are still is faster with some IDE's than my newer i7s.
>>
>>62015445
>IDEs are a bad idea
>you need an IDE for embedded toolchains
Look at these hot opinions.
>>
>>62015405
memory leaks
>>
>>62015471
for the sake of this toy program, there are none
>>
>>62015405
>return (struct primes)
>stdbool
>>
>>62015482
So you rely on an OS to free the memory after a process exit.
>>
>>62015471
It's not a leak if when the program ends you still have a pointer to it.
>>
>>62015509
std::sort > qsort
>>
>>62015509
std::sort > qsort
>>
>>62015460
You "can" do it without the IDE obviously, but do you have any advice on a workflow that would be as fast / efficient without it?

I'm even down for Emacs / VIM weirdness.
>>
>>62015483
structs are disposable. If I was using a lang with a proper slice type, I'd just do that instead. stdbool shows my intent to both the reader and compiler.
>>
>>62015530
>but do you have any advice on a workflow that would be as fast / efficient without it?
Set up build and flashing macros that invoke your toolchain in vim and then map them to keybindings.
>>
>>62011075
Any programmers here? I'm about to begin my bachelors degree in uni and wondering if 14" is too tiny.

Can't decide between the 15.6 inch T570 and X1 Carbon

(posted in thinkpad thread as well but its kinda dead atm)
>>
>>62015502
the os has to do it regardless when it drops your pages
the only argument against letting it is if your code later gets c+p'd into something bigger or if your program is so big that it shifts it's memory usage by significant amounts (for significant periods of time) over the course of it's run time
>>
>>62015504
He allocates a memory on a heap and assigns it to the pointers allocated on a stack, after a function call is finished the pointers to the allocated memory are destroyed, he has nothing to free the memory, only OS will free it after the exit of a process.

And you're talking something about C++ programmers.
>>
>>62015550
in hindsight i probably should've omitted the "any programmers here" lmao
>>
>>62015471
just let the kernel handle it, that's its' job after all
>>
>>62015554
He still has a pointer to it when main() ends. It's not a leak. Valgrind would not consider it a leak.
>>
>>62015550
Get the T570, X1's have much thinner keyboards that just aren't as good.

Personally though I'd say T470.
>>
New thread:

>>62015577
>>62015577
>>62015577
>>
>>62015187
cool, I may try this. kivy seems to much of an overkill for a small app.
>>
>>62015552
I agree on that, just a bad practice.
>>
>>62015578
It's not tedious at all for you to program on a tiny 13 inch screen?
>>
>>62013860
there are multiple Java implementations...
"Java" isn't a single "Java".
>>
>>62015705
it's 14 inches. And no.
>>
>>62015107
N I N E T Y P E R C E N T of /g/ is just /v/ crossposters. This is the current state of /g/.
>>
File: union.png (153KB, 480x444px) Image search: [Google]
union.png
153KB, 480x444px
Thread posts: 324
Thread images: 27


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

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


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