Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Xik
Mar 10, 2011

Dinosaur Gum

Beef posted:

Or writing a source file, syscalling gcc and dlopening the result.

Is this seriously a real thing?

Adbot
ADBOT LOVES YOU

MrMoo
Sep 14, 2000

Xik posted:

Is this seriously a real thing?

MemSQL does this, works surprisingly well.

Beef
Jul 26, 2004
It is used for optimization at runtime, such as libxsmm (used by tensor flow) compiling matrix-size-specific routines. It is the standard way of providing hotswapping/dynamic compilation in C/C++. I assume Unreal 4 does it as well.

TheBlackVegetable
Oct 29, 2006

comedyblissoption posted:

Some languages handle errors as values and also will warn you if you accidentally don't use a return value and handle the error.

Implicitly letting programmers accidentally forget to handle errors should be blamed on the language and not the programmers.

That's one prime reason I've written all my new code in F# instead of C#, and made all my projects run with full warnings and warnings as errors - the Result pattern and the pain that was unhandled and essentially hidden code paths.

Eela6
May 25, 2007
Shredded Hen

TheBlackVegetable posted:

That's one prime reason I've written all my new code in F# instead of C#, and made all my projects run with full warnings and warnings as errors - the Result pattern and the pain that was unhandled and essentially hidden code paths.

I've never looked into F# before. It looks... good? Someone tell me the nightmare truth behind it before I get suckered into learning another language.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

Eela6 posted:

I've never looked into F# before. It looks... good? Someone tell me the nightmare truth behind it before I get suckered into learning another language.

F#'s biggest issue for me is the seeming lack of support from Microsoft. It's not as bad as it once was, but if you're looking for things like, say, templates or documentation from MS, it's not as good as C#. Also, if you wanna make a UWP app, you can't use F# until .NET Standard 2.0, since it doesn't support .NET Native until then.

Beyond that, it is really cool. I've been writing our internal tooling in F# for about a year now and it's great.

Bongo Bill
Jan 17, 2012

Poor vendor support, and all the libraries are actually C# libraries.

FlapYoJacks
Feb 12, 2009
I recently switched my embedded projects over to libressl, and got libressl accepted into buildroot mainline.

That's not the coding horror.

I learned today that OpenSSL has support for VMS and Big Endian AMD64. :psyduck:

comedyblissoption
Mar 15, 2006

Eela6 posted:

I've never looked into F# before. It looks... good? Someone tell me the nightmare truth behind it before I get suckered into learning another language.
Unless they fixed it, F# uses a single pass compiler that requires you to declare everything before use in a sequential manner and structure your source files accordingly w/o the benefit of header-like files. Some will claim this is a boon, but that is stockholm syndrome.

TheBlackVegetable
Oct 29, 2006

comedyblissoption posted:

Unless they fixed it, F# uses a single pass compiler that requires you to declare everything before use in a sequential manner and structure your source files accordingly w/o the benefit of header-like files. Some will claim this is a boon, but that is stockholm syndrome.

It is a boon, because if you think you need mutual references in your types, you probably have a bad architecture (use interfaces) - languages that let you mix and match are much more easily turned into spaghetti.

They did recently add the ability to mark a module "rec" so that all types declared in the file can refer to all others, if you really need to lean on that crutch.

Eela6
May 25, 2007
Shredded Hen

comedyblissoption posted:

Unless they fixed it, F# uses a single pass compiler that requires you to declare everything before use in a sequential manner and structure your source files accordingly w/o the benefit of header-like files. Some will claim this is a boon, but that is stockholm syndrome.

You have to do that in every interpreted lanaguage, so it's NBD to me. Not a boon, but I'm used to it already. I do prefer it the other way, though.

FrantzX
Jan 28, 2007
code:
if (key == 0)
{
    parsestate.ReadOperand(typeof(UInt16));
}
if (key == 1)
{
    parsestate.ReadOperands(typeof(Int32), typeof(Int32), typeof(Int32));
}
else
{
    parsestate.ReadOperands(typeof(UInt16), typeof(Int32), typeof(Byte));
}
I hate myself sometimes.

Workaday Wizard
Oct 23, 2009

by Pragmatica

FrantzX posted:

code:
if (key == 0)
{
    parsestate.ReadOperand(typeof(UInt16));
}
if (key == 1)
{
    parsestate.ReadOperands(typeof(Int32), typeof(Int32), typeof(Int32));
}
else
{
    parsestate.ReadOperands(typeof(UInt16), typeof(Int32), typeof(Byte));
}

I hate myself sometimes.

Looks normal. What am I missing?

QuarkJets
Sep 8, 2008

Shinku ABOOKEN posted:

Looks normal. What am I missing?

When key is 0, the if ==0 and the else block both execute

Also, magic numbers

Eela6
May 25, 2007
Shredded Hen

QuarkJets posted:

When key is 0, the if ==0 and the else block both execute

Also, magic numbers

I FIXED IT
code:
if (key == ZERO)
{
    parsestate.ReadOperand(typeof(UInt16));
}
if (key == ONE)
{
    parsestate.ReadOperands(typeof(Int32), typeof(Int32), typeof(Int32));
}
else
{
    parsestate.ReadOperands(typeof(UInt16), typeof(Int32), typeof(Byte));
}

Absurd Alhazred
Mar 27, 2010

by Athanatos

QuarkJets posted:

When key is 0, the if ==0 and the else block both execute

Also, magic numbers

Reminds me of a bug I found in our code a few months ago:

C++ code:
if (a == b);
{
	bar();
}

Volguus
Mar 3, 2009

Eela6 posted:

I FIXED IT
code:
if (key == ZERO)
{
    parsestate.ReadOperand(typeof(UInt16));
}
if (key == ONE)
{
    parsestate.ReadOperands(typeof(Int32), typeof(Int32), typeof(Int32));
}
else
{
    parsestate.ReadOperands(typeof(UInt16), typeof(Int32), typeof(Byte));
}

Hahaha. I saw that kind of thing in code (#define BILLION 1000000000 or something like that). And the developer even defended it :negative:.

Spatial
Nov 15, 2007

Obviously the correct way is to employ a user-defined literal :grin:

C++ code:
uint64_t operator "" _billion( uint64_t billions ) {
    return billions * 1'000'000'000;
}

auto x = 100_billion;

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Volguus posted:

Hahaha. I saw that kind of thing in code (#define BILLION 1000000000 or something like that). And the developer even defended it :negative:.

I guess we'll see who's laughing when you have to compile the british version of this program.

Workaday Wizard
Oct 23, 2009

by Pragmatica

QuarkJets posted:

When key is 0, the if ==0 and the else block both execute

Ugh that's the worst. I genuinely couldn't see it.

Jaded Burnout
Jul 10, 2004


Dr. Stab posted:

I guess we'll see who's laughing when you have to compile the british version of this program.

I'm sorry to say that this is the same in the UK. The other billion definition went away long ago.

Athas
Aug 6, 2007

fuck that joker

Eela6 posted:

I've never looked into F# before. It looks... good? Someone tell me the nightmare truth behind it before I get suckered into learning another language.

F# probably has better tooling than any other functional language. It has flaws compared to the big functional languages (Haskell, OCaml, SML, Scala), but unless you're experienced in them, you won't notice. Some of its uglier parts are rooted in compromises to enable good .NET compatibility, but that is probably also its main selling point, so somewhat unavoidable.

It is good language and nobody will leave you out of their party invitations for using it.

Xerophyte
Mar 17, 2008

This space intentionally left blank

Jaded Burnout posted:

I'm sorry to say that this is the same in the UK. The other billion definition went away long ago.

The long scale has survived in the rest of Europe and half the Americas so there's still tons of people to confuse by using billion as a constant name.

Doom Mathematic
Sep 2, 2008

Absurd Alhazred posted:

Reminds me of a bug I found in our code a few months ago:

C++ code:
if (a == b);
{
	bar();
}

This should be a syntax error.

Vanadium
Jan 8, 2005

I'm gonna defend the BILLION define because I don't want to count the zeroes every time someone uses a huge number, and people don't use 1e9 etc for integers.

zergstain
Dec 15, 2005

Is that not at least a warning on all good compilers?

brap
Aug 23, 2004

Grimey Drawer

TheBlackVegetable posted:

It is a boon, because if you think you need mutual references in your types, you probably have a bad architecture (use interfaces) - languages that let you mix and match are much more easily turned into spaghetti.

They did recently add the ability to mark a module "rec" so that all types declared in the file can refer to all others, if you really need to lean on that crutch.

Some things are mutually recursive by nature (think syntax trees) and there's nothing wrong with it.

https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/TypeChecker.fs#L4142 scroll down to line 11803 where this let rec...and... block ends and tell me that single pass is good.

In many languages, people put their public methods at the top of the file so that people coming in can look at the class's behavior from the top-down. F# helpfully requires users to specify the behavior of everything in the universe from the bottom-up, making the best way to look for the interesting part of a program to go to the bottom of the last source file and work your way up.

Interfaces doesn't solve the issue of types that are mutually recursive and single-pass makes traversal of mutually recursive structures like syntax trees or other PL-related data structures hard to maintain, if you couldn't tell from that code sample. Single-pass is on the short list of mistakes F# makes that make it totally unviable for mainstream development.

brap fucked around with this message at 15:09 on Jul 16, 2017

TheBlackVegetable
Oct 29, 2006

fleshweasel posted:

Some things are mutually recursive by nature (think syntax trees) and there's nothing wrong with it.

https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/TypeChecker.fs#L4142 scroll down to line 11803 where this let rec...and... block ends and tell me that single pass is good.

In many languages, people put their public methods at the top of the file so that people coming in can look at the class's behavior from the top-down. F# helpfully requires users to specify the behavior of everything in the universe from the bottom-up, making the best way to look for the interesting part of a program to go to the bottom of the last source file and work your way up.

Interfaces doesn't solve the issue of types that are mutually recursive and single-pass makes traversal of mutually recursive structures like syntax trees or other PL-related data structures hard to maintain, if you couldn't tell from that code sample. Single-pass is on the short list of mistakes F# makes that make it totally unviable for mainstream development.

I disagree bottom-up being a problem, though I'm phone posting so I didn't look at that code yet. Fair enough if you're writing lots of syntax trees and the like (are you? Is that mainstream development? Does your data structure not fit in one file?), but F# is entirely viable and suitable for mainstream development because most code isn't like that and I believe it benefits from strict hierarchical requirements.

TheBlackVegetable fucked around with this message at 15:33 on Jul 16, 2017

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

fleshweasel posted:

Some things are mutually recursive by nature (think syntax trees) and there's nothing wrong with it.

https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/TypeChecker.fs#L4142 scroll down to line 11803 where this let rec...and... block ends and tell me that single pass is good.

Single-pass doesn't prevent you from coding those things, it makes you place them next to each other. Which is probably where they should be.

Yes, the example you quote is super long (because the F# type-checker is actually a complicated piece of work), but would that code be improved by scattering those mutually-recursive types across fifteen different files, instead of sticking them together? I doubt it.

Along similar lines, when I use inheritance - in any language - I generally place the subclasses in the same file as the base class. Often I make them nested classes, if I think the info is worth the extra verbosity (e.g. Vehicle.Car.Toyota.Corolla). I believe any tight coupling in the code should be reflected in the code layout.

quote:

In many languages, people put their public methods at the top of the file so that people coming in can look at the class's behavior from the top-down. F# helpfully requires users to specify the behavior of everything in the universe from the bottom-up, making the best way to look for the interesting part of a program to go to the bottom of the last source file and work your way up.

This is why projects generally introduce .fsi files (which the compiler can generate automatically) once they become too big to navigate by quickly skimming. No need to screw up the code's logical structure just for the sake of having a quick reference.

I do actually think that it might be nice if the F# compiler proceeded upwards instead of downwards, privileging the code reader over the code writer. The problem is that it would be super confusing to have local declarations go one way and global declarations the other way. And having local declarations go from last to first, like in Haskell's 'where', would work very poorly in an eager-by-default language.

NihilCredo fucked around with this message at 15:50 on Jul 16, 2017

FlapYoJacks
Feb 12, 2009
I found this page that aggregated commits to LibreSSL until they switched to GitHub.

http://opensslrampage.org/page/49

Some of the things they found is just... :stare: The INTERNET runs off of this piece of poo poo.

omeg
Sep 3, 2012

ratbert90 posted:

I found this page that aggregated commits to LibreSSL until they switched to GitHub.

http://opensslrampage.org/page/49

Some of the things they found is just... :stare: The INTERNET runs off of this piece of poo poo.

After having to use OpenSSL just for some relatively simple crypto stuff I can say that its API is hot garbage and makes you :psyboom:

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun

omeg posted:

After having to use OpenSSL just for some relatively simple crypto stuff I can say that its API is hot garbage and makes you :psyboom:
The API is basically the worst thing I've ever seen. It's so bad that it has to have been intentionally designed to cause madness.

FlapYoJacks
Feb 12, 2009

Ghost of Reagan Past posted:

The API is basically the worst thing I've ever seen. It's so bad that it has to have been intentionally designed to cause madness.

Well when you rewrite malloc that doesn't free because your mallocs now live in a LIFO, your API is probably the least of your worries.

Also supporting BIG ENDIAN AMD64 AND VMS.

idiotmeat
Apr 3, 2010

Absurd Alhazred posted:

Reminds me of a bug I found in our code a few months ago:

C++ code:
if (a == b);
{
	bar();
}

Yeah a colleague had done that years ago as well in Java. Caused a really nasty bit of corruption.

Actual content: it is not so much a coding gorror as development process horror, but apparently I am doing things incorrectly by not checking the assembly before I delivered the code to ensure that the compiler is doing its job.

Volguus
Mar 3, 2009

Vanadium posted:

I'm gonna defend the BILLION define because I don't want to count the zeroes every time someone uses a huge number, and people don't use 1e9 etc for integers.

I'm sorry, it is not defensible in any situation (#define, const long, whatever). And that applies to numbers like 55, 100, or a googol. That constant/macro you define for a purpose: sleep time in an infinite loop, maybe magic number, maybe ... whatever it may be. Then entire reason to have it a constant is so that you can change it easily should you need to, and only change it in one spot and to give it a name that shows its purpose. You can never change BILLION to have value 23, it wouldn't make any sense.

This kind of code

code:
final long FIVE = 5;
#define MILLION 1000000
does not provide any information about those constants/macros. Have no value whatsoever and serve no purpose and no developer should ever, under any circumstances, do this.

JawnV6
Jul 4, 2004

So hot ...

idiotmeat posted:

Actual content: it is not so much a coding gorror as development process horror, but apparently I am doing things incorrectly by not checking the assembly before I delivered the code to ensure that the compiler is doing its job.

I mean, that’s not totally unreasonable? What test content had you run that passed? In the event there’s no existing content or HW to check high level code against, asm inspection is fine.

zergstain
Dec 15, 2005

idiotmeat posted:

Yeah a colleague had done that years ago as well in Java. Caused a really nasty bit of corruption.

Actual content: it is not so much a coding gorror as development process horror, but apparently I am doing things incorrectly by not checking the assembly before I delivered the code to ensure that the compiler is doing its job.

I thought any decent compiler would emit a warning if you put a semicolon after an if like that. Actually, though, would anything be lost if they made it so that a semicolon by itself isn't a valid C statement?

Absurd Alhazred
Mar 27, 2010

by Athanatos

Volguus posted:

I'm sorry, it is not defensible in any situation (#define, const long, whatever). And that applies to numbers like 55, 100, or a googol. That constant/macro you define for a purpose: sleep time in an infinite loop, maybe magic number, maybe ... whatever it may be. Then entire reason to have it a constant is so that you can change it easily should you need to, and only change it in one spot and to give it a name that shows its purpose. You can never change BILLION to have value 23, it wouldn't make any sense.

This kind of code

code:
final long FIVE = 5;
#define MILLION 1000000
does not provide any information about those constants/macros. Have no value whatsoever and serve no purpose and no developer should ever, under any circumstances, do this.

Do you feel the same way about pi or e?

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Absurd Alhazred posted:

Do you feel the same way about pi or e?

You mean the constants that are almost always provided by a math library? The reason you make constants out of those kinds of things is to prevent typos.

Adbot
ADBOT LOVES YOU

Nippashish
Nov 2, 2005

Let me see you dance!

Absurd Alhazred posted:

Do you feel the same way about pi or e?

I'd be pretty upset if you had made a constant called THREE_POINT_ONE_FOUR_ONE_FIVE_NINE.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply